codex-copilot-dx 1.4.17 → 1.4.18

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/docs/REFERENCE.md CHANGED
@@ -284,9 +284,9 @@ The initial internal ceiling is 128 concurrent requests per source/account. This
284
284
 
285
285
  Settings separates saved preferences from effective state. Auto-save applies changes by default; required restarts remain explicit. Restore-defaults creates a backup first and keeps accounts, keys, model plans and chats. CLI preference reset/restore uses its own service-only backup; it does not change browser appearance or replace the Web UI's backup.
286
286
 
287
- **Settings → Bark notifications** sends one notification after a supported local Codex turn finishes. Enable it and paste the URL containing the device key from Bark. The minimum duration defaults to 30 minutes. Zero includes every eligible completed turn. Title and description are optional. The Codex icon comes from [Lobe Icons](https://github.com/lobehub/lobe-icons) and is included in the settings page. The phone retrieves the public icon URL separately.
287
+ **Settings → Bark notifications** is collapsed by default. Enable it and paste the URL containing the device key from Bark. The minimum duration defaults to 30 minutes. Zero includes every eligible completed turn. Leave the title and description blank to use the name of the app that finished. The phone retrieves the matching public PNG from [Lobe Icons](https://github.com/lobehub/lobe-icons).
288
288
 
289
- CCDX checks recent local Codex session files while the service runs. It uses the recorded turn duration. Intermediate API responses, cancelled turns and background subagents are skipped. The notification carries the selected title and description, with no prompt or response content. The saved push URL stays in the OS credential store. Cloud-only sessions, Claude and Antigravity are outside this version's notification coverage.
289
+ CCDX checks local Codex turns, Claude Desktop sessions in Code mode, and Antigravity sessions with a complete local transcript and a fully idle main conversation. Each source must provide matching start and completion evidence. Intermediate API responses, cancelled turns and background subagents are skipped. The notification carries the configured text and a client icon. Prompt and response content stay local, and the push URL stays in the OS credential store. Cloud-only sessions and ordinary Claude Chat and Cowork sessions lack these local completion records.
290
290
 
291
291
  Web and terminal colors are independent. Web appearance is browser-local. **Settings → Web appearance → Grid paper** gives the light theme a warm paper color and faint gray grid, with a matching dark variant. The terminal keeps its selected color and animation; NO_COLOR, dumb/non-TTY and narrow output remain supported. Reduced motion disables decorative movement. Closed tabs and hidden views stop scheduled work. Model/usage data loads on demand; the Web UI adds no inference calls.
292
292
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-copilot-dx",
3
- "version": "1.4.17",
3
+ "version": "1.4.18",
4
4
  "description": "Local gateway for Codex, Claude and Gemini Antigravity with Copilot, Microsoft 365 and custom APIs",
5
5
  "author": "Dale Xiao",
6
6
  "type": "module",
@@ -1,20 +1,28 @@
1
1
  import fs from "node:fs";
2
2
  import files from "node:fs/promises";
3
+ import os from "node:os";
3
4
  import path from "node:path";
4
5
  import { createHash, randomBytes } from "node:crypto";
5
6
  import { createApiSecretStore } from "./api-secrets.mjs";
6
7
  import { atomicWriteFileSync } from "./atomic-file.mjs";
7
8
  import { codexPaths } from "./codex-paths.mjs";
9
+ import { claudeClientPaths } from "./claude-client-config.mjs";
8
10
  import { withFileLockSync } from "./lock.mjs";
9
- import { readBoundedFileSync } from "./bounded-file.mjs";
11
+ import { readBoundedFile, readBoundedFileSync } from "./bounded-file.mjs";
10
12
  import { readBoundedResponseText } from "./http-transport.mjs";
11
13
  import { userSettingsPath } from "./user-settings.mjs";
12
14
 
13
- const DEFAULTS = { enabled: false, minutes: 30, title: "", body: "" };
15
+ const DEFAULTS = { enabled: false, minutes: 30, title: "", body: "", language: "en" };
14
16
  const ID = /^[a-zA-Z0-9-]{1,120}$/;
15
17
  const ROLLOUT = /^rollout-[^/\\]+\.jsonl$/;
18
+ const CLAUDE_SESSION = /^local_[0-9a-f-]{36}\.json$/i;
16
19
  const MB = 1024 * 1024;
17
- const ICON = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png/light/codex-color.png";
20
+ const ICONS = "https://cdn.jsdelivr.net/npm/@lobehub/icons-static-png/light/";
21
+ const APPS = {
22
+ codex: { name: "Codex", icon: "codex-color.png" },
23
+ claude_app: { name: "Claude", icon: "claude-color.png" },
24
+ antigravity: { name: "Antigravity", icon: "antigravity-color.png" },
25
+ };
18
26
 
19
27
  function invalid() { return new Error("ccdx_bark_invalid"); }
20
28
 
@@ -65,16 +73,87 @@ async function completions(file, since) {
65
73
  || turn.root_turn_id && turn.root_turn_id !== turn.turn_id
66
74
  || turn.status != null && turn.status !== "completed") return [];
67
75
  const id = createHash("sha256").update(meta.payload.id + "/" + turn.turn_id).digest("hex");
68
- return [{ id, time, duration: turn.duration_ms }];
76
+ return [{ id, time, duration: turn.duration_ms, application: "codex" }];
69
77
  });
70
78
  } finally { await handle.close(); }
71
79
  }
72
80
 
73
- export function createBarkNotifications({ env = process.env, home, platform = process.platform, fetchImpl = fetch,
81
+ async function claudeCompletion(file, since, previousCount) {
82
+ const session = record(await readBoundedFile(file, { encoding: "utf8", maxBytes: MB }));
83
+ if (!session || path.basename(file) !== session.sessionId + ".json") return null;
84
+ const count = session.completedTurns ?? 0;
85
+ if (!Number.isSafeInteger(count) || count < 0) return null;
86
+ const start = session.latestUserFrameAt, time = session.lastTurnEdgeAt;
87
+ // Claude Desktop's Code mode increments completedTurns only on a successful SDK result.
88
+ const advanced = previousCount === undefined ? count === 1 && session.createdAt >= since : count > previousCount;
89
+ if (!advanced || session.spawnedFrom || session.lastTurnCutShort || session.lastTurnStopped || session.interruptedAwaitingPerson
90
+ || !Number.isSafeInteger(start) || !Number.isSafeInteger(time) || time < since || time <= start
91
+ || Number.isSafeInteger(session.errorAt) && session.errorAt >= start) return { count };
92
+ const id = createHash("sha256").update("claude_app/" + session.sessionId + "/" + count).digest("hex");
93
+ return { count, event: { id, time, duration: time - start, application: "claude_app" } };
94
+ }
95
+
96
+ function notificationMessage(settings, event) {
97
+ const { name, icon } = APPS[event.application];
98
+ const zh = settings.language === "zh";
99
+ return { title: settings.title || (zh ? name + " 任务完成" : name + " task completed"),
100
+ body: settings.body || (zh ? "一个 " + name + " 任务已完成。" : "A " + name + " task has finished."),
101
+ icon: ICONS + icon, group: "CCDX" };
102
+ }
103
+
104
+ async function antigravityCompletion(file, size, row, since) {
105
+ const handle = await files.open(file, fs.constants.O_RDONLY | (fs.constants.O_NOFOLLOW || 0));
106
+ try {
107
+ const tail = Buffer.alloc(Math.min(size, MB));
108
+ const offset = size - tail.length;
109
+ const read = await handle.read(tail, 0, tail.length, offset);
110
+ const lines = tail.subarray(0, read.bytesRead).toString("utf8").split("\n");
111
+ if (offset) lines.shift();
112
+ if (lines.pop() !== "") return null;
113
+ const end = record(lines.pop());
114
+ // An idle summary alone also occurs on errors, interruption or overdue background work.
115
+ if (end?.type !== "PLANNER_RESPONSE" || end.source !== "MODEL" || end.status !== "DONE"
116
+ || !Number.isSafeInteger(end.step_index) || end.step_index + 1 !== row.step_count
117
+ || typeof end.content !== "string" || !end.content.trim()
118
+ || end.tool_calls != null && (!Array.isArray(end.tool_calls) || end.tool_calls.length)) return null;
119
+ const input = lines.map(record).findLast(step => step?.type === "USER_INPUT");
120
+ const startIndex = row.last_user_input_step_index === -1 ? 0 : row.last_user_input_step_index;
121
+ if (end.step_index <= startIndex || (input ? input.step_index !== startIndex : !offset || row.last_user_input_step_index < 0)) return null;
122
+ // Long turns may have pushed their input row out of the bounded transcript tail.
123
+ const time = Date.parse(end.created_at), start = Date.parse(input?.created_at ?? row.last_user_input_time);
124
+ if (!Number.isFinite(time) || !Number.isFinite(start) || time < since || time < start
125
+ || Date.parse(row.last_modified_time) < time) return null;
126
+ const id = createHash("sha256").update("antigravity/" + row.conversation_id + "/" + startIndex).digest("hex");
127
+ return { id, time, duration: time - start, application: "antigravity" };
128
+ } finally { await handle.close(); }
129
+ }
130
+
131
+ async function antigravityIdleConversations(root) {
132
+ const file = path.join(root, "conversation_summaries.db");
133
+ if (!(await files.lstat(file)).isFile()) return [];
134
+ const { DatabaseSync } = await import("node:sqlite");
135
+ const db = new DatabaseSync(file, { readOnly: true });
136
+ try {
137
+ return db.prepare(`SELECT conversation_id, last_user_input_step_index, last_user_input_time, last_modified_time, step_count
138
+ FROM conversation_summaries
139
+ WHERE status = 'CASCADE_RUN_STATUS_IDLE' AND not_fully_idle = 0 AND killed = 0
140
+ AND nesting_depth = 0 AND COALESCE(parent_conversation_id, '') = ''
141
+ ORDER BY last_modified_time DESC LIMIT 256`).all();
142
+ } finally { db.close(); }
143
+ }
144
+
145
+ export function createBarkNotifications({ env = process.env, home = os.homedir(), platform = process.platform, fetchImpl = fetch,
74
146
  secretStore = createApiSecretStore({ env, home, platform }), now = Date.now, scanIntervalMs = 10000 } = {}) {
75
147
  const folder = path.dirname(userSettingsPath({ env, home }));
76
148
  const file = path.join(folder, "bark.json"), ledger = path.join(folder, "bark-delivered.json");
77
- const sessions = path.join(codexPaths({ env, home }).directory, "sessions");
149
+ const claude = claudeClientPaths({ env, home, platform });
150
+ const sources = [
151
+ { directory: path.join(codexPaths({ env, home }).directory, "sessions"), pattern: ROLLOUT, application: "codex" },
152
+ ...[...new Set([claude.threep, claude.normal])].map(file => ({
153
+ directory: path.join(path.dirname(file), "claude-code-sessions"), pattern: CLAUDE_SESSION, application: "claude_app",
154
+ })),
155
+ ];
156
+ const antigravity = path.join(home, ".gemini", "antigravity");
78
157
  let timer, lastResult = null, closed = false, running = false, watching = false, since = now();
79
158
  let settings = readSettings();
80
159
  const scanned = new Map();
@@ -85,7 +164,12 @@ export function createBarkNotifications({ env = process.env, home, platform = pr
85
164
  if (!value || typeof value.enabled !== "boolean" || !Number.isSafeInteger(value.minutes)
86
165
  || value.minutes < 0 || value.minutes > 10080 || typeof value.title !== "string" || typeof value.body !== "string") return { ...DEFAULTS };
87
166
  const ref = /^[a-f0-9]{32}$/.test(value.ref || "") ? value.ref : undefined;
88
- return { enabled: value.enabled && Boolean(ref), minutes: value.minutes, title: value.title, body: value.body, ref };
167
+ // 1.4.17 persisted placeholders as text. Only migrate its exact default copy.
168
+ const legacy = value.language === undefined;
169
+ const zh = value.language === "zh" || legacy && ["Codex 任务完成", "一个 Codex 长任务已完成。"].some(word => word === value.title || word === value.body);
170
+ const title = legacy && ["Codex task completed", "Codex 任务完成"].includes(value.title) ? "" : value.title;
171
+ const body = legacy && ["A long Codex task has finished.", "一个 Codex 长任务已完成。"].includes(value.body) ? "" : value.body;
172
+ return { enabled: value.enabled && Boolean(ref), minutes: value.minutes, title, body, language: zh ? "zh" : "en", ref };
89
173
  } catch { return { ...DEFAULTS }; }
90
174
  }
91
175
 
@@ -106,42 +190,93 @@ export function createBarkNotifications({ env = process.env, home, platform = pr
106
190
  if (running) return;
107
191
  running = true;
108
192
  const snapshot = settings;
193
+ let foundSource = false;
194
+ try {
195
+ for (const source of sources) {
196
+ if (closed || snapshot !== settings) return;
197
+ const root = await files.realpath(source.directory).catch(() => null);
198
+ if (!root) continue;
199
+ foundSource = await scanSource(source, root, snapshot) || foundSource;
200
+ }
201
+ if (!closed && snapshot === settings) foundSource = await scanAntigravity(snapshot) || foundSource;
202
+ } finally {
203
+ if (snapshot === settings) watching = foundSource;
204
+ running = false;schedule();
205
+ }
206
+ }
207
+
208
+ function remember(file, value) {
209
+ scanned.set(file, value);
210
+ if (scanned.size > 4096) scanned.delete(scanned.keys().next().value);
211
+ }
212
+
213
+ async function deliver(event, snapshot) {
214
+ if (closed || snapshot !== settings || event.duration < snapshot.minutes * 60000) return;
215
+ try {
216
+ const destination = parseBarkUrl(await secretStore.get(snapshot.ref));
217
+ if (closed || snapshot !== settings || !claim(event)) return;
218
+ const result = await fetchImpl(destination.endpoint, {
219
+ method: "POST", headers: { "Content-Type": "application/json" }, redirect: "error", signal: AbortSignal.timeout(5000),
220
+ body: JSON.stringify({ device_key: destination.deviceKey, ...notificationMessage(snapshot, event) }),
221
+ });
222
+ const reply = await readBoundedResponseText(result, { maxBytes: 4096, label: "Bark response" });
223
+ if (snapshot === settings) lastResult = result.ok && record(reply)?.code === 200 ? "sent" : "failed";
224
+ } catch {
225
+ if (snapshot === settings) lastResult = "failed";
226
+ }
227
+ }
228
+
229
+ async function scanAntigravity(snapshot) {
230
+ let root, rows;
231
+ try {
232
+ root = await files.realpath(antigravity);
233
+ rows = await antigravityIdleConversations(root);
234
+ } catch { return false; }
235
+ for (const row of rows) {
236
+ if (closed || snapshot !== settings) break;
237
+ if (!/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(row.conversation_id || "")
238
+ || !Number.isSafeInteger(row.last_user_input_step_index) || row.last_user_input_step_index < -1
239
+ || !(Date.parse(row.last_modified_time) >= since)) continue;
240
+ const key = "antigravity:" + row.conversation_id;
241
+ try {
242
+ const file = path.join(root, "brain", row.conversation_id, ".system_generated", "logs", "transcript.jsonl");
243
+ if (await files.realpath(file) !== file) continue;
244
+ const stat = await files.lstat(file);
245
+ if (!stat.isFile() || !stat.size) continue;
246
+ // Both files matter: the summary may be written before the final transcript line.
247
+ const stamp = [row.last_modified_time, row.step_count, stat.ino, stat.size, stat.mtimeMs].join(":");
248
+ if (scanned.get(key)?.stamp === stamp) continue;
249
+ const event = await antigravityCompletion(file, stat.size, row, since);
250
+ if (event) await deliver(event, snapshot);
251
+ if (snapshot === settings) remember(key, { stamp });
252
+ } catch { /* The client may be writing or rotating its transcript. */ }
253
+ }
254
+ return true;
255
+ }
256
+
257
+ async function scanSource(source, root, snapshot) {
109
258
  try {
110
- const root = await files.realpath(sessions);
111
259
  const entries = (await files.readdir(root, { recursive: true, withFileTypes: true }))
112
- .filter(entry => entry.isFile() && ROLLOUT.test(entry.name)).sort((a, b) => b.name.localeCompare(a.name)).slice(0, 4096);
260
+ .filter(entry => entry.isFile() && source.pattern.test(entry.name)).sort((a, b) => b.name.localeCompare(a.name)).slice(0, 4096);
113
261
  if (closed || snapshot !== settings) return;
114
- watching = true;
115
262
  for (const entry of entries) {
116
263
  if (closed || snapshot !== settings) break;
117
264
  try {
118
265
  const file = path.join(entry.parentPath, entry.name);
119
266
  const stat = await files.stat(file);
120
- if (stat.mtimeMs < since - 1000) continue;
267
+ if (source.application === "codex" && stat.mtimeMs < since - 1000) continue;
121
268
  const stamp = [stat.ino, stat.size, stat.mtimeMs].join(":");
122
- if (scanned.get(file) === stamp) continue;
269
+ const previous = scanned.get(file);
270
+ if (previous?.stamp === stamp) continue;
123
271
  if (!(await files.realpath(file)).startsWith(root + path.sep)) continue;
124
- for (const event of await completions(file, since)) {
125
- if (closed || snapshot !== settings || event.duration < snapshot.minutes * 60000) continue;
126
- const destination = parseBarkUrl(await secretStore.get(snapshot.ref));
127
- if (closed || snapshot !== settings || !claim(event)) continue;
128
- const result = await fetchImpl(destination.endpoint, {
129
- method: "POST", headers: { "Content-Type": "application/json" }, redirect: "error", signal: AbortSignal.timeout(5000),
130
- body: JSON.stringify({ device_key: destination.deviceKey, title: snapshot.title || "Codex task completed",
131
- body: snapshot.body || "A long Codex task has finished.", icon: ICON, group: "CCDX" }),
132
- });
133
- // Bark can report an application error with HTTP success.
134
- const reply = await readBoundedResponseText(result, { maxBytes: 4096, label: "Bark response" });
135
- if (snapshot === settings) lastResult = result.ok && record(reply)?.code === 200 ? "sent" : "failed";
136
- }
137
- if (snapshot === settings) {
138
- scanned.set(file, stamp);
139
- if (scanned.size > 4096) scanned.delete(scanned.keys().next().value);
140
- }
141
- } catch (error) { if (error.code !== "ENOENT" && snapshot === settings) lastResult = "failed"; }
272
+ const claude = source.application === "claude_app" ? await claudeCompletion(file, since, previous?.count) : null;
273
+ const events = source.application === "codex" ? await completions(file, since) : claude?.event ? [claude.event] : [];
274
+ for (const event of events) await deliver(event, snapshot);
275
+ if (snapshot === settings) remember(file, { stamp, count: claude?.count });
276
+ } catch { /* The client may be writing or rotating its session file. */ }
142
277
  }
143
- } catch { watching = false; }
144
- finally { running = false;schedule(); }
278
+ return true;
279
+ } catch { return false; }
145
280
  }
146
281
 
147
282
  function schedule(interval = scanIntervalMs) {
@@ -151,23 +286,23 @@ export function createBarkNotifications({ env = process.env, home, platform = pr
151
286
 
152
287
  function snapshot() {
153
288
  const { enabled, minutes, title, body, ref } = settings;
154
- return { enabled, minutes, title, body, configured: Boolean(ref), watching, delivery: lastResult };
289
+ return { enabled, minutes, title, body, sources: Object.keys(APPS), configured: Boolean(ref), watching, delivery: lastResult };
155
290
  }
156
291
 
157
292
  schedule(0);
158
293
  return {
159
294
  snapshot,
160
- async save({ enabled, minutes, title, body, url = "" }) {
295
+ async save({ enabled, minutes, title, body, url = "", language = settings.language }) {
161
296
  if (typeof enabled !== "boolean" || !Number.isSafeInteger(minutes) || minutes < 0 || minutes > 10080
162
297
  || typeof title !== "string" || title.length > 160 || typeof body !== "string" || body.length > 500
163
- || typeof url !== "string") throw invalid();
298
+ || typeof url !== "string" || !["en", "zh"].includes(language)) throw invalid();
164
299
  const prior = settings.ref;
165
300
  const replacement = url.trim() !== "";
166
301
  if (replacement) parseBarkUrl(url);
167
302
  if (enabled && !replacement && !prior) throw invalid();
168
303
  const ref = replacement ? randomBytes(16).toString("hex") : prior;
169
304
  if (replacement) await secretStore.set(ref, url.trim());
170
- const next = { enabled, minutes, title: title.trim(), body: body.trim(), ref };
305
+ const next = { enabled, minutes, title: title.trim(), body: body.trim(), language, ref };
171
306
  try {
172
307
  fs.mkdirSync(folder, { recursive: true, mode: 0o700 });
173
308
  atomicWriteFileSync(file, JSON.stringify(next), { mode: 0o600 });
@@ -10,6 +10,8 @@
10
10
  for (const key of ["minutes", "title", "body"]) fields[key].value = data[key];
11
11
  fields.enabled.checked = data.enabled;
12
12
  fields.url.value = "";
13
+ const apps = (data.sources || []).map(id => globalThis.ccdxLanguage.format("bark_source_" + id)).join(", ");
14
+ if (apps) globalThis.ccdxLanguage.set(el("bark-sources"), "bark_active_sources", { apps });
13
15
  if (data.configured) words(fields.url, "bark_url_saved", "placeholder");
14
16
  else { fields.url.removeAttribute("data-i18n-placeholder");fields.url.placeholder = "https://bark.example/…"; }
15
17
  const message = data.delivery === "sent" ? "bark_sent" : data.delivery === "failed" ? "bark_failed"
@@ -26,7 +28,8 @@
26
28
  let data;
27
29
  try {
28
30
  data = await api({ action: "bark", enabled: fields.enabled.checked, minutes: fields.minutes.valueAsNumber,
29
- title: fields.title.value.trim() || fields.title.placeholder, body: fields.body.value.trim() || fields.body.placeholder, url: fields.url.value });
31
+ title: fields.title.value, body: fields.body.value, url: fields.url.value,
32
+ language: document.documentElement.lang.startsWith("zh") ? "zh" : "en" });
30
33
  dirty = false;notice = "api_saved";
31
34
  } catch (error) { words(status, error.message === "ccdx_bark_invalid" ? "bark_invalid" : "bark_save_failed"); }
32
35
  finally { saving = false;fieldset.disabled = false; }
@@ -527,21 +527,44 @@
527
527
  <div class="section-actions"><button id="privacy-cancel" type="button" hidden data-i18n="cancel">Cancel</button><button id="privacy-retry" type="button" hidden data-i18n="view_retry">Retry</button><button id="privacy-remove" type="button" hidden data-i18n="privacy_remove">Delete model</button><p id="privacy-error" class="hint" role="alert"></p></div>
528
528
  </section>
529
529
  <dialog id="privacy-dialog" class="preferences-dialog" aria-labelledby="privacy-dialog-title"><h2 id="privacy-dialog-title" data-i18n="privacy_enable">Local masking</h2><p data-i18n="privacy_download">Downloads about 39 MB plus the local component. Checks may add delay or mistake ordinary text.</p><p data-i18n="privacy_fail_closed">If a check cannot finish, the request is not sent.</p><div class="section-actions"><button id="privacy-dialog-cancel" type="button" data-i18n="cancel">Cancel</button><button id="privacy-dialog-confirm" type="button" data-i18n="privacy_confirm">Download &amp; enable</button></div></dialog>
530
- <section class="panel dashboard-section" aria-labelledby="bark-heading">
531
- <h2 id="bark-heading"><img src="@@BARK_CODEX_PNG@@" width="24" height="24" alt=""><span data-i18n="bark_heading">Bark notifications</span></h2>
530
+ <details class="panel dashboard-section" id="bark-notifications">
531
+ <summary class="panel-heading"><h2 id="bark-heading" data-i18n="bark_heading">Bark notifications</h2></summary>
532
532
  <form id="bark-settings">
533
533
  <fieldset disabled>
534
- <div class="setting-row"><label for="bark-enabled" data-i18n="bark_enable">Notify when a Codex task finishes</label><input id="bark-enabled" name="enabled" type="checkbox"></div>
535
- <div class="appearance-row"><label for="bark-url" data-i18n="bark_url">Bark URL with key</label><input id="bark-url" name="url" type="password" maxlength="2048" autocomplete="off" spellcheck="false"></div>
536
- <div class="appearance-row"><label for="bark-minutes" data-i18n="bark_minutes">Minimum duration (minutes)</label><input id="bark-minutes" name="minutes" type="number" min="0" max="10080" step="1" value="30" required></div>
537
- <div class="appearance-row"><label for="bark-title" data-i18n="bark_title">Notification title</label><input id="bark-title" name="title" maxlength="160" data-i18n-placeholder="bark_title_default" placeholder="Codex task completed"></div>
538
- <div class="appearance-row"><label for="bark-body" data-i18n="bark_body">Notification description</label><input id="bark-body" name="body" maxlength="500" data-i18n-placeholder="bark_body_default" placeholder="A long Codex task has finished."></div>
534
+ <label class="bark-toggle"><input id="bark-enabled" name="enabled" type="checkbox" role="switch"><span data-i18n="bark_enable">Notify when a task finishes</span></label>
535
+ <p id="bark-sources" class="hint" data-i18n="bark_sources">Supported local clients appear here when settings load.</p>
536
+ <div class="bark-fields">
537
+ <label for="bark-url" data-i18n="bark_url">Bark URL with key</label><input id="bark-url" name="url" type="password" maxlength="2048" autocomplete="off" spellcheck="false">
538
+ <label for="bark-minutes" data-i18n="bark_minutes">Minimum duration (minutes)</label><input id="bark-minutes" name="minutes" type="number" min="0" max="10080" step="1" value="30" required>
539
+ <label for="bark-title" data-i18n="bark_title">Notification title</label><input id="bark-title" name="title" maxlength="160" data-i18n-placeholder="bark_title_default" placeholder="Automatic">
540
+ <label for="bark-body" data-i18n="bark_body">Notification description</label><input id="bark-body" name="body" maxlength="500" data-i18n-placeholder="bark_body_default" placeholder="Automatic">
541
+ </div>
539
542
  <div class="section-actions"><button type="submit" data-i18n="api_save">Save</button><span id="bark-status" role="status" aria-live="polite"></span></div>
540
543
  </fieldset>
541
544
  </form>
542
- </section>
545
+ </details>
543
546
 
544
- <details class="panel dashboard-section" id="request-limits"><summary data-i18n="advanced_limits">Advanced: request limits</summary><div class="section-actions"><label><span data-i18n="decoded_limit">Decoded request limit (MiB)</span><input id="decoded-limit" type="number" min="128" max="512" step="1"></label><button id="decoded-limit-save" type="button" data-i18n="api_save">Save</button><button id="decoded-limit-default" type="button" data-i18n="limit_default">Use default</button></div><p id="decoded-limit-note" class="hint" role="status"></p><div class="section-actions"><label><span data-i18n="inflight_body_limit">Shared request-body limit (MiB)</span> <input id="inflight-body-limit" type="number" min="32" max="128" step="1" required aria-describedby="inflight-body-limit-note" disabled></label><button id="inflight-body-limit-save" type="button" data-i18n="api_save" disabled>Save</button><button id="inflight-body-limit-default" type="button" data-i18n="limit_default" disabled>Use default</button></div><p id="inflight-body-limit-note" class="hint" role="status"></p></details>
547
+ <details class="panel dashboard-section" id="request-limits">
548
+ <summary data-i18n="advanced_limits">Advanced: request limits</summary>
549
+ <div class="request-limit">
550
+ <label for="decoded-limit" data-i18n="decoded_limit">Decoded request limit (MiB)</label>
551
+ <div class="section-actions">
552
+ <input id="decoded-limit" type="number" min="128" max="512" step="1">
553
+ <button id="decoded-limit-save" type="button" data-i18n="api_save">Save</button>
554
+ <button id="decoded-limit-default" type="button" data-i18n="limit_default">Use default</button>
555
+ </div>
556
+ <p id="decoded-limit-note" class="hint" role="status"></p>
557
+ </div>
558
+ <div class="request-limit">
559
+ <label for="inflight-body-limit" data-i18n="inflight_body_limit">Shared request-body limit (MiB)</label>
560
+ <div class="section-actions">
561
+ <input id="inflight-body-limit" type="number" min="32" max="128" step="1" required aria-describedby="inflight-body-limit-note" disabled>
562
+ <button id="inflight-body-limit-save" type="button" data-i18n="api_save" disabled>Save</button>
563
+ <button id="inflight-body-limit-default" type="button" data-i18n="limit_default" disabled>Use default</button>
564
+ </div>
565
+ <p id="inflight-body-limit-note" class="hint" role="status"></p>
566
+ </div>
567
+ </details>
545
568
 
546
569
  <section class="panel dashboard-section" id="settings-preferences" aria-labelledby="preferences-heading">
547
570
  <h2 id="preferences-heading" data-i18n="preferences_heading">SAVE &amp; RESTORE</h2>
@@ -1,15 +1,20 @@
1
1
  (() => {
2
2
  const translations = {
3
3
  bark_heading: ["Bark notifications", "Bark 通知"],
4
- bark_enable: ["Notify when a Codex task finishes", "Codex 任务完成时通知"],
4
+ bark_enable: ["Notify when a task finishes", "任务完成时通知"],
5
+ bark_sources: ["Supported local clients appear here when settings load.", "加载后显示支持的本机应用。"],
6
+ bark_active_sources: ["Local completion signals: {apps}", "支持的本机任务完成信号:{apps}"],
7
+ bark_source_codex: ["Codex", "Codex"],
8
+ bark_source_claude_app: ["Claude Desktop (Code)", "Claude 桌面端(Code)"],
9
+ bark_source_antigravity: ["Antigravity", "Antigravity"],
5
10
  bark_url: ["Bark URL with key", "带 key 的 Bark URL"],
6
11
  bark_url_saved: ["Saved. Enter a new URL to replace it.", "已保存。输入新地址可替换。"],
7
12
  bark_minutes: ["Minimum duration (minutes)", "最短任务时长(分钟)"],
8
13
  bark_title: ["Notification title", "消息标题"],
9
14
  bark_body: ["Notification description", "消息描述"],
10
- bark_title_default: ["Codex task completed", "Codex 任务完成"],
11
- bark_body_default: ["A long Codex task has finished.", "一个 Codex 长任务已完成。"],
12
- bark_waiting: ["Waiting for the local Codex session directory.", "正在等待本机 Codex 会话目录。"],
15
+ bark_title_default: ["Automatic", "自动生成"],
16
+ bark_body_default: ["Automatic", "自动生成"],
17
+ bark_waiting: ["Waiting for local completion records.", "正在等待本机任务完成记录。"],
13
18
  bark_sent: ["Last notification accepted by Bark.", "Bark 已接收最近一条通知。"],
14
19
  bark_failed: ["Bark delivery failed.", "Bark 推送失败。"],
15
20
  bark_invalid: ["Check the Bark URL and minimum duration.", "请检查 Bark URL 和最短任务时长。"],
@@ -680,9 +680,24 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
680
680
 
681
681
  /* Settings-page preferences keep their own draft, save and recovery controls. */
682
682
  .preferences-status { color:var(--muted); font-size:11px; }
683
- #bark-heading { display:flex; align-items:center; gap:8px; }
684
- #bark-settings fieldset { margin:0; padding:0; min-width:0; border:0; }
685
- #bark-settings .appearance-row input { width:min(100%,340px); }
683
+ #bark-settings { max-width: 38rem; margin-top: 14px; }
684
+ #bark-notifications:not([open]) #bark-settings { display: none; }
685
+ #bark-settings fieldset { margin: 0; padding: 0; min-width: 0; border: 0; }
686
+ .bark-toggle { display: inline-flex; align-items: center; gap: 10px; min-height: var(--control-height); cursor: pointer; }
687
+ #bark-sources { margin: 4px 0 16px; }
688
+ .bark-fields { display: grid; grid-template-columns: minmax(11rem, max-content) minmax(0, 1fr); align-items: center; gap: 10px 18px; }
689
+ .bark-fields input { box-sizing: border-box; width: 100%; min-width: 0; height: var(--control-height); padding: 7px 9px; font: inherit; color: var(--text); background: var(--page); border: 1px solid var(--border); }
690
+ .bark-fields input[type="number"] { max-width: 8rem; }
691
+ .bark-fields input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
692
+ #bark-settings .section-actions { margin-top: 16px; }
693
+ @media (max-width: 640px) {
694
+ .bark-fields { display: block; }
695
+ .bark-fields label { display: block; margin-bottom: 6px; }
696
+ .bark-fields input { display: block; margin-bottom: 12px; }
697
+ }
698
+ @media (pointer: coarse) {
699
+ .bark-toggle, .bark-fields input { min-height: 44px; }
700
+ }
686
701
  .preferences-row { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:12px 0; font-size:13px; }
687
702
  .preferences-row:last-of-type { padding-bottom:0; }
688
703
  .preferences-row .hint { margin-top:5px; }
@@ -780,6 +795,9 @@ input[role="switch"]:disabled { opacity: .5; cursor: wait; }
780
795
  .http-error-table :is(th,td) { text-align: right; white-space: normal; padding-block: 4px; font-variant-numeric: tabular-nums; }
781
796
  .http-error-grid { display: none; }
782
797
  .request-limits-line { display: flex; flex-wrap: wrap; gap: 4px 10px; }
798
+ .request-limit { margin-top: 14px; }
799
+ .request-limit > label { display: block; color: var(--muted); font-size: 12px; }
800
+ .request-limit .section-actions { margin-top: 7px; }
783
801
  .recent-request-duration { text-align: right; font-variant-numeric: tabular-nums; }
784
802
  @media (max-width: 620px) {
785
803
  .http-error-table { display: none; }
package/src/dashboard.mjs CHANGED
@@ -38,11 +38,7 @@ let bundle;
38
38
  function assets() {
39
39
  bundle ||= Promise.all([...ASSETS].map(async ([name, [file, type]]) => {
40
40
  let body = await readFile(new URL(file, import.meta.url));
41
- if (name === "/") {
42
- const icon = await readFile(new URL("./dashboard/bark-codex.png", import.meta.url));
43
- body = Buffer.from(body.toString().replace("@@BARK_CODEX_PNG@@", "data:image/png;base64," + icon.toString("base64"))
44
- .replace(/(src|href)="(\/[a-z-]+\.(?:js|css))"/g, `$1="$2?v=${ADAPTER_VERSION}"`));
45
- }
41
+ if (name === "/") body = Buffer.from(body.toString().replace(/(src|href)="(\/[a-z-]+\.(?:js|css))"/g, `$1="$2?v=${ADAPTER_VERSION}"`));
46
42
  return [name, { body, type, etag: `"${createHash("sha256").update(body).digest("hex")}"` }];
47
43
  })).then(async entries => {
48
44
  const installed = JSON.parse(await readFile(new URL("../package.json", import.meta.url), "utf8"));
@@ -74,7 +74,7 @@ export function createServiceControl({ env = process.env, home, platform = proce
74
74
  application: ["action", "id", "operation", "confirmed", "fresh", "expected_pid", "expected_started"],
75
75
  update: ["action", "confirmed"], decoded_limit: ["action", "mib"], inflight_body_limit: ["action", "mib"],
76
76
  error_capture: ["action", "operation", "source", "model"],
77
- bark: ["action", "enabled", "minutes", "title", "body", "url"],
77
+ bark: ["action", "enabled", "minutes", "title", "body", "url", "language"],
78
78
  preferences: ["action", "values", "revision"], reset_preferences: ["action", "revision", "backup_id", "scope"], restore_preferences: ["action", "revision", "backup_id", "scope"],
79
79
  provider: ["action", "operation", "provider", "model", "auto_review_model", "auto_review_effort", "account_id"] }[input.action];
80
80
  if (!allowed || Object.keys(input).some(key => !allowed.includes(key))) throw new Error("Unknown setting action or field");
Binary file