mulmoclaude 2.11.0 → 2.12.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.
Files changed (39) hide show
  1. package/README.md +5 -1
  2. package/bin/mulmoclaude.js +13 -35
  3. package/client/assets/{marp-DvbfD9EO.js → marp-BH7JDaRq.js} +1 -1
  4. package/client/assets/{mulmoclaude3-BUmaA-ZX.js → mulmoclaude2-wt3640-35L_u9kD.js} +926 -921
  5. package/client/assets/mulmoclaude2-wt3640-DzadcIZy.css +2 -0
  6. package/client/index.html +2 -2
  7. package/package.json +4 -4
  8. package/server/api/auth/bearerAuth.ts +24 -12
  9. package/server/api/auth/bearerExemption.ts +38 -0
  10. package/server/api/auth/clientTokenCommands.ts +28 -8
  11. package/server/api/auth/clientTokenRule.ts +9 -8
  12. package/server/api/auth/clientTokenScope.ts +73 -0
  13. package/server/api/auth/clientTokenStore.ts +50 -2
  14. package/server/api/auth/clientTokenUsage.ts +85 -0
  15. package/server/api/auth/clientTokenUsageRule.ts +59 -0
  16. package/server/api/auth/ownerTokenHandoff.ts +73 -0
  17. package/server/api/auth/principal.ts +64 -3
  18. package/server/api/routes/clientTokens.ts +85 -0
  19. package/server/api/routes/collections.ts +20 -11
  20. package/server/api/routes/files.ts +4 -6
  21. package/server/build/mcp-server.mjs +727 -727
  22. package/server/index.ts +33 -53
  23. package/server/utils/wait-ready.d.mts +20 -0
  24. package/server/utils/wait-ready.mjs +64 -0
  25. package/src/components/SessionHistoryRow.vue +47 -41
  26. package/src/components/SettingsClientTokensTab.vue +176 -0
  27. package/src/components/SettingsModal.vue +4 -1
  28. package/src/config/apiRoutes.ts +4 -0
  29. package/src/lang/de.ts +25 -0
  30. package/src/lang/en.ts +24 -0
  31. package/src/lang/es.ts +24 -0
  32. package/src/lang/fr.ts +25 -0
  33. package/src/lang/ja.ts +24 -0
  34. package/src/lang/ko.ts +24 -0
  35. package/src/lang/pt-BR.ts +24 -0
  36. package/src/lang/zh.ts +23 -0
  37. package/client/assets/mulmoclaude3-D93Ihflz.css +0 -2
  38. package/server/system/logs/aaa +0 -737
  39. package/server/system/logs/bb +0 -446
package/server/index.ts CHANGED
@@ -80,6 +80,7 @@ import { fakeEchoBackend } from "./agent/backend/fake-echo.js";
80
80
  import { startMacosReminderAdapter } from "./notifier/macosReminderAdapter.js";
81
81
  import notifierRoutes from "./api/routes/notifier.js";
82
82
  import { createShutdownRouter } from "./api/routes/shutdown.js";
83
+ import { createClientTokensRouter } from "./api/routes/clientTokens.js";
83
84
  import { initNotifier } from "./notifier/engine.js";
84
85
  import { registerSaveAttachmentHook } from "./utils/files/attachment-store.js";
85
86
  import { capturePhotoLocation } from "./workspace/photo-locations/index.js";
@@ -108,6 +109,7 @@ import { WORKSPACE_DIRS, WORKSPACE_PATHS } from "./workspace/paths.js";
108
109
  import { resolveClientDir } from "./utils/clientDir.js";
109
110
  import { serverError } from "./utils/httpError.js";
110
111
  import { browserVisibleOrigin } from "./utils/forwardedOrigin.js";
112
+ import { decideOwnerTokenHandoff } from "./api/auth/ownerTokenHandoff.js";
111
113
  import { makeUuid } from "./utils/id.js";
112
114
  import { mcpToolsRouter, mcpTools, isMcpToolEnabled, MCP_TOOL_PROMPT_FILE_SOURCES } from "./agent/mcp-tools/index.js";
113
115
  import { preflightUserServers, logPreflightResult } from "./agent/mcpPreflight.js";
@@ -142,7 +144,8 @@ import { connectRelay } from "./events/relay-client.js";
142
144
  import { startConfiguredBridges } from "./bridges/registry.js";
143
145
  import { requireSameOrigin } from "./api/csrfGuard.js";
144
146
  import { bearerAuth } from "./api/auth/bearerAuth.js";
145
- import { isAuthorizedBearer } from "./api/auth/principal.js";
147
+ import { isBearerExempt } from "./api/auth/bearerExemption.js";
148
+ import { flushClientTokenUsage, isSocketAuthorizedBearer } from "./api/auth/principal.js";
146
149
  import { isViewDataPath } from "./api/auth/viewToken.js";
147
150
  import { deleteTokenFile, generateAndWriteToken, getCurrentToken } from "./api/auth/token.js";
148
151
  import { boundPortOf, deleteServerPort, publishServerPort, setBoundPort } from "./workspace/serverPort.js";
@@ -169,6 +172,20 @@ import { SCHEDULE_TYPES, MISSED_RUN_POLICIES } from "@receptron/task-scheduler";
169
172
 
170
173
  const HTML_TOKEN_PLACEHOLDER = "__MULMOCLAUDE_AUTH_TOKEN__";
171
174
 
175
+ // Withheld from a page load that came through a tunnel or proxy (#3627); the
176
+ // page then treats itself as signed out.
177
+ function ownerTokenForPage(req: Request): string {
178
+ const handoff = decideOwnerTokenHandoff({
179
+ remoteAddress: req.socket.remoteAddress,
180
+ target: req.originalUrl,
181
+ headers: req.headers,
182
+ rawHeaders: req.rawHeaders,
183
+ });
184
+ if (handoff.ok) return getCurrentToken() ?? "";
185
+ log.warn("auth", "index.html served without the owner token: not a direct localhost load", { reason: handoff.reason, path: req.path });
186
+ return "";
187
+ }
188
+
172
189
  const __filename = fileURLToPath(import.meta.url);
173
190
  const __dirname = path.dirname(__filename);
174
191
 
@@ -325,53 +342,10 @@ app.use((req, res, next) => {
325
342
  // Layered *on top of* CSRF guard so we catch both cross-origin
326
343
  // browser attacks (origin check) and local sibling processes that
327
344
  // bypass browser CORS (bearer check). See #272 and
328
- // plans/done/feat-bearer-token-auth.md.
329
- //
330
- // /api/files/* is exempt because <img src="/api/files/raw?path=...">
331
- // tags in rendered markdown can't attach Authorization headers.
332
- // /api/plugins/runtime/<pkg>/<version>/<file> (#1043 C-2) is exempt
333
- // for the same reason: the frontend dynamic-imports plugin assets
334
- // (`import("/api/plugins/runtime/<pkg>/<ver>/dist/vue.js")`) and the
335
- // browser cannot attach Authorization headers to those module
336
- // requests. The pattern "4+ segments past /plugins/runtime/" only
337
- // matches asset GETs — `/plugins/runtime/list` (3 segments) and
338
- // `/plugins/runtime/<pkg>/dispatch` (3 segments) still require auth.
339
- // Path traversal is hardened separately by `resolveWithinRoot` in
340
- // the asset route handler.
341
- // The CSRF origin check + loopback-only binding still apply.
342
- const RUNTIME_PLUGIN_ASSET_PATH_RE = /^\/plugins\/runtime\/[^/]+\/[^/]+\//;
343
- // Generic OAuth callback receiver for runtime plugins (#1162). Same
344
- // browser-redirect-can't-carry-Authorization-header reason as the
345
- // asset path above. Trust model: registry-membership (the host's
346
- // route handler 404s an unknown :alias) plus the plugin's single-use
347
- // `state` for CSRF.
348
- const RUNTIME_PLUGIN_OAUTH_CALLBACK_RE = /^\/plugins\/runtime\/oauth-callback\/[^/]+$/;
345
+ // plans/done/feat-bearer-token-auth.md. The requests a browser makes
346
+ // without a header are exempt — see `isBearerExempt`.
349
347
  app.use("/api", (req, res, next) => {
350
- if (req.path.startsWith("/files/")) {
351
- next();
352
- return;
353
- }
354
- // Custom-view data endpoints carry a scoped capability token, not the
355
- // global bearer (the sandboxed iframe can't read it). `requireViewToken`
356
- // guards them instead. See server/api/auth/viewToken.ts.
357
- if (isViewDataPath(req.path)) {
358
- next();
359
- return;
360
- }
361
- if ((req.method === "GET" || req.method === "HEAD") && RUNTIME_PLUGIN_ASSET_PATH_RE.test(req.path)) {
362
- // HEAD is bypassed for the same reason as GET: the frontend
363
- // runtime-plugin loader HEAD-probes `dist/vue.js` to distinguish
364
- // "no Vue bundle (404, server-only plugin)" from real load
365
- // failures before `import()`-ing the asset (#1273 follow-up).
366
- // That probe is a raw `fetch`, not the bearer-attaching `apiGet`,
367
- // and the actual `import()` itself can't attach Authorization
368
- // either — so the auth-bypass must cover both verbs or every
369
- // runtime plugin's Vue View silently downgrades to a
370
- // definition-only entry (401 → "unexpected status" → no view).
371
- next();
372
- return;
373
- }
374
- if (req.method === "GET" && RUNTIME_PLUGIN_OAUTH_CALLBACK_RE.test(req.path)) {
348
+ if (isBearerExempt({ method: req.method, path: req.path }, isViewDataPath)) {
375
349
  next();
376
350
  return;
377
351
  }
@@ -489,6 +463,7 @@ const getWorkspaceDirReal = makeCachedRealpath(workspacePath);
489
463
  // runaway loop hammering the filesystem, not to police normal use. Same limiter
490
464
  // the collection view routes use.
491
465
  const HTML_FILE_RATE_LIMIT_PER_MINUTE = 600;
466
+ const INDEX_HTML_RATE_LIMIT_PER_MINUTE = 600;
492
467
  const htmlFileRateLimit = makeViewActionRateLimiter(HTML_FILE_RATE_LIMIT_PER_MINUTE, ONE_MINUTE_MS);
493
468
  app.use(HTML_FILE_MOUNT, htmlFileRateLimit, async (req, res, next) => {
494
469
  if (!HTML_PREVIEW_EXT_RE.test(req.path)) {
@@ -748,7 +723,7 @@ const chatService = createChatService({
748
723
  // Socket.io handshake (see #268 Phase A) needs to validate the
749
724
  // same bearer token the HTTP middleware enforces.
750
725
  tokenProvider: getCurrentToken,
751
- authorizeToken: isAuthorizedBearer,
726
+ authorizeToken: isSocketAuthorizedBearer,
752
727
  listSessions: listSessionsForBridge,
753
728
  getSessionHistory: getSessionHistoryForBridge,
754
729
  getSessionRole: getSessionRoleForBridge,
@@ -768,6 +743,7 @@ app.use(createTranslationRouter());
768
743
  app.use(mcpToolsRouter);
769
744
  app.use(schedulerTasksRoutes);
770
745
  app.use(createShutdownRouter());
746
+ app.use(createClientTokensRouter());
771
747
 
772
748
  if (env.isProduction) {
773
749
  // `{ index: false }` so express.static doesn't intercept `GET /`
@@ -784,7 +760,10 @@ if (env.isProduction) {
784
760
  const clientDir = resolveClientDir(process.env.MULMOCLAUDE_CLIENT_DIR, path.join(__dirname, "../client"));
785
761
  app.use(express.static(clientDir, { index: false }));
786
762
  const indexHtmlPath = path.join(clientDir, "index.html");
787
- app.get("/{*splat}", (_req: Request, res: Response) => {
763
+ // Every client-side route lands here, so the bucket is roomy: it bounds a
764
+ // runaway reload loop re-reading index.html, not normal navigation.
765
+ const indexHtmlRateLimit = makeViewActionRateLimiter(INDEX_HTML_RATE_LIMIT_PER_MINUTE, ONE_MINUTE_MS);
766
+ app.get("/{*splat}", indexHtmlRateLimit, (req: Request, res: Response) => {
788
767
  let html: string;
789
768
  try {
790
769
  html = readFileSync(indexHtmlPath, "utf-8");
@@ -793,9 +772,10 @@ if (env.isProduction) {
793
772
  serverError(res, "Internal Server Error");
794
773
  return;
795
774
  }
796
- const token = getCurrentToken() ?? "";
797
- html = html.replace(HTML_TOKEN_PLACEHOLDER, token);
775
+ html = html.replace(HTML_TOKEN_PLACEHOLDER, ownerTokenForPage(req));
798
776
  res.set("Content-Type", "text/html; charset=utf-8");
777
+ // The page may carry the owner token, so no proxy or browser cache may keep it.
778
+ res.set("Cache-Control", "no-store");
799
779
  res.send(html);
800
780
  });
801
781
  }
@@ -1366,7 +1346,7 @@ async function startRuntimeServices(httpServer: ReturnType<typeof app.listen>, p
1366
1346
  // (#3082). That residue is accepted and reasoned about in
1367
1347
  // `docs/bridge-protocol.md`; it is not covered by this cleanup, which only
1368
1348
  // closes the graceful path.
1369
- const shutdownHooks: (() => void)[] = [stopWhisperSidecar];
1349
+ const shutdownHooks: (() => void)[] = [stopWhisperSidecar, flushClientTokenUsage];
1370
1350
  function registerShutdownHook(hook: () => void): void {
1371
1351
  shutdownHooks.push(hook);
1372
1352
  }
@@ -1474,7 +1454,7 @@ process.on("SIGTERM", () => {
1474
1454
  // (CodeRabbit review on PR #1196). Both `createPubSub` and
1475
1455
  // `initNotifier` are sync, so wiring them up here costs nothing
1476
1456
  // and closes the window.
1477
- const earlyPubsub = createPubSub(httpServer, { authorizeToken: isAuthorizedBearer });
1457
+ const earlyPubsub = createPubSub(httpServer, { authorizeToken: isSocketAuthorizedBearer });
1478
1458
  initNotifier({
1479
1459
  publish: (channel, payload) => earlyPubsub.publish(channel, payload),
1480
1460
  });
@@ -0,0 +1,20 @@
1
+ // Type declarations for wait-ready.mjs.
2
+
3
+ export const READY_POLL_INTERVAL_MS: number;
4
+
5
+ export const SLOW_START_NOTICE_AFTER_MS: number;
6
+
7
+ export function shouldAnnounceSlowStart(state: { elapsedMs: number; announced: boolean }): boolean;
8
+
9
+ export function slowStartMessage(url: string, options: { willOpenBrowser: boolean }): string;
10
+
11
+ export interface WaitUntilReadyOptions {
12
+ port: number;
13
+ isServerAlive: () => boolean;
14
+ onSlowStart: () => void;
15
+ probe?: (port: number) => Promise<boolean>;
16
+ sleep?: (delayMs: number) => Promise<void>;
17
+ now?: () => number;
18
+ }
19
+
20
+ export function waitUntilReady(options: WaitUntilReadyOptions): Promise<boolean>;
@@ -0,0 +1,64 @@
1
+ // "Has the server we just spawned started answering yet?"
2
+ //
3
+ // There is no deadline on purpose. A fixed window used to give up without a
4
+ // word (#3623), and the server legitimately spends a long time before
5
+ // `listen()` — a first sandbox image build, a slow synced workspace. The
6
+ // launcher exits when the server does, so waiting while it lives cannot hang.
7
+ //
8
+ // Plain `.mjs` for the same reason as `port.mjs`: the npm launcher boots before
9
+ // tsx. Sibling `wait-ready.d.mts` carries the type declarations.
10
+ import { detectRunningServer, SERVER_PRESENCE } from "./launcher/detect-server.mjs";
11
+
12
+ export const READY_POLL_INTERVAL_MS = 300;
13
+ export const SLOW_START_NOTICE_AFTER_MS = 15_000;
14
+
15
+ const MS_PER_SECOND = 1000;
16
+
17
+ /**
18
+ * @param {{ elapsedMs: number, announced: boolean }} state
19
+ * @returns {boolean}
20
+ */
21
+ export function shouldAnnounceSlowStart({ elapsedMs, announced }) {
22
+ return !announced && elapsedMs >= SLOW_START_NOTICE_AFTER_MS;
23
+ }
24
+
25
+ /**
26
+ * @param {string} url
27
+ * @param {{ willOpenBrowser: boolean }} options
28
+ */
29
+ export function slowStartMessage(url, { willOpenBrowser }) {
30
+ const seconds = Math.round(SLOW_START_NOTICE_AFTER_MS / MS_PER_SECOND);
31
+ const prefix = `Still starting after ${seconds}s`;
32
+ if (!willOpenBrowser) return `${prefix} — open ${url} once the server answers.`;
33
+ return `${prefix} — the browser opens once the server answers. To open it yourself: ${url}`;
34
+ }
35
+
36
+ /** @param {number} port */
37
+ async function isMulmoClaudeAnswering(port) {
38
+ return (await detectRunningServer(port)) === SERVER_PRESENCE.mulmoclaude;
39
+ }
40
+
41
+ /** @param {number} delayMs */
42
+ function sleepMs(delayMs) {
43
+ return new Promise((resolve) => setTimeout(resolve, delayMs));
44
+ }
45
+
46
+ /**
47
+ * Resolve true once the server answers, false if it dies first.
48
+ * @param {import("./wait-ready.d.mts").WaitUntilReadyOptions} options
49
+ * @returns {Promise<boolean>}
50
+ */
51
+ export async function waitUntilReady({ port, isServerAlive, onSlowStart, probe = isMulmoClaudeAnswering, sleep = sleepMs, now = Date.now }) {
52
+ const startedAt = now();
53
+ const state = { announced: false };
54
+ while (isServerAlive()) {
55
+ // A server that died mid-probe is not ready, whatever the probe saw.
56
+ if (await probe(port)) return isServerAlive();
57
+ if (shouldAnnounceSlowStart({ elapsedMs: now() - startedAt, announced: state.announced })) {
58
+ state.announced = true;
59
+ onSlowStart();
60
+ }
61
+ await sleep(READY_POLL_INTERVAL_MS);
62
+ }
63
+ return false;
64
+ }
@@ -1,21 +1,60 @@
1
1
  <template>
2
+ <!-- Not a control itself: the open button, the bookmark toggle and the
3
+ menu are siblings inside it, so none nests in another. The card's
4
+ own click is a mouse-only convenience; keyboard users have the open
5
+ button. -->
2
6
  <div
3
- tabindex="0"
4
- role="button"
5
- :aria-label="rowAria"
7
+ class="relative cursor-pointer rounded p-2 text-sm transition-colors"
6
8
  :title="primaryText"
7
- class="relative cursor-pointer rounded p-2 text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400"
8
9
  :class="rowClasses"
9
10
  :data-testid="`session-item-${session.id}`"
10
11
  @click="emit('select', session.id)"
11
- @keydown.enter.prevent.self="onActivateKey"
12
- @keydown.space.prevent.self="onActivateKey"
13
12
  >
13
+ <!-- Primary line prefers the AI-generated summary (chat indexer,
14
+ #123) when present — it's typically more informative than
15
+ the first user message. Fall back to the first user message,
16
+ then to a "no messages" placeholder. `line-clamp-2` lets a
17
+ summary wrap so more of it is readable at a glance; the raw
18
+ first-message fallback stays on a single line via `truncate`
19
+ so short prompts don't disturb row heights. -->
20
+ <div class="flex items-start gap-1.5">
21
+ <button
22
+ type="button"
23
+ class="flex-shrink-0 mt-0.5 rounded focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400"
24
+ :title="bookmarkLabel"
25
+ :aria-label="t('sessionHistoryPanel.bookmark')"
26
+ :aria-pressed="session.isBookmarked === true"
27
+ :data-testid="`session-row-icon-bookmark-${session.id}`"
28
+ @click.stop="emit('toggleBookmark', session)"
29
+ >
30
+ <SessionRoleIcon :session="session" :roles="roles" size="sm" />
31
+ </button>
32
+ <!-- No handler: the click bubbles to the card, which selects, and on to the panel's document listener, which closes an open menu. -->
33
+ <button
34
+ type="button"
35
+ class="flex flex-1 min-w-0 items-start gap-1.5 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400"
36
+ :aria-label="rowAria"
37
+ :aria-current="selected ? 'true' : undefined"
38
+ :data-testid="`session-row-open-${session.id}`"
39
+ >
40
+ <span
41
+ class="flex-1 min-w-0"
42
+ :class="[previewClasses, hasVisibleSummary ? 'line-clamp-2' : 'block truncate']"
43
+ :data-testid="`session-row-preview-${session.id}`"
44
+ >
45
+ {{ primaryText }}
46
+ </span>
47
+ <span v-if="session.isRunning" class="flex-shrink-0 flex items-center mt-0.5" :aria-label="t('sessionHistoryPanel.running')">
48
+ <span class="w-1.5 h-1.5 rounded-full bg-yellow-400 animate-pulse" />
49
+ </span>
50
+ </button>
51
+ </div>
14
52
  <!-- Timestamp pill straddling the top border, mirroring the
15
53
  SessionSidebar card design. The kebab "..." button sits
16
54
  next to it on the same border line — clicking opens a
17
- popover with delete + bookmark actions. The running
18
- indicator still renders inline in the meta line below
55
+ popover with delete + bookmark actions. It comes last in the
56
+ markup so the tab order runs bookmark, open, menu. The running
57
+ indicator still renders inline in the meta line
19
58
  (it's a status, not a time); unread is signalled through
20
59
  previewClasses (bold text); bookmark state is signalled
21
60
  via the green role icon. -->
@@ -27,8 +66,6 @@
27
66
  :aria-label="t('sessionHistoryPanel.rowMenuAria')"
28
67
  :data-testid="`session-row-menu-${session.id}`"
29
68
  @click.stop="emit('toggleMenu', session.id)"
30
- @keydown.enter.stop
31
- @keydown.space.stop
32
69
  >
33
70
  <span class="material-icons !text-[14px] leading-none" aria-hidden="true">more_horiz</span>
34
71
  </button>
@@ -59,30 +96,6 @@
59
96
  {{ t("sessionHistoryPanel.delete") }}
60
97
  </button>
61
98
  </div>
62
- <!-- Primary line prefers the AI-generated summary (chat indexer,
63
- #123) when present — it's typically more informative than
64
- the first user message. Fall back to the first user message,
65
- then to a "no messages" placeholder. `line-clamp-2` lets a
66
- summary wrap so more of it is readable at a glance; the raw
67
- first-message fallback stays on a single line via `truncate`
68
- so short prompts don't disturb row heights. -->
69
- <div class="flex items-start gap-1.5">
70
- <!-- Mouse-only on purpose: a <button> would nest inside the role="button" row; keyboard users have the menu item. -->
71
- <span
72
- class="flex-shrink-0 mt-0.5 cursor-pointer"
73
- :title="bookmarkLabel"
74
- :data-testid="`session-row-icon-bookmark-${session.id}`"
75
- @click.stop="emit('toggleBookmark', session)"
76
- >
77
- <SessionRoleIcon :session="session" :roles="roles" size="sm" />
78
- </span>
79
- <p class="flex-1 min-w-0" :class="[previewClasses, hasVisibleSummary ? 'line-clamp-2' : 'truncate']">
80
- {{ primaryText }}
81
- </p>
82
- <span v-if="session.isRunning" class="flex-shrink-0 flex items-center mt-0.5" :aria-label="t('sessionHistoryPanel.running')">
83
- <span class="w-1.5 h-1.5 rounded-full bg-yellow-400 animate-pulse" />
84
- </span>
85
- </div>
86
99
  </div>
87
100
  </template>
88
101
 
@@ -140,11 +153,4 @@ const hasVisibleSummary = computed(() => sessionHasVisibleSummary(props.session)
140
153
  const rowClasses = computed(() => (props.selected ? "border-2 border-blue-500 hover:bg-gray-50" : "border border-gray-200 hover:bg-gray-50"));
141
154
 
142
155
  const previewClasses = computed(() => (props.session.hasUnread ? "text-gray-900 font-bold" : "text-gray-700"));
143
-
144
- // Held Enter / Space on a native <button> activates once per physical
145
- // press, not per OS auto-repeat tick (#684).
146
- function onActivateKey(event: KeyboardEvent): void {
147
- if (event.repeat) return;
148
- emit("select", props.session.id);
149
- }
150
156
  </script>
@@ -0,0 +1,176 @@
1
+ <template>
2
+ <div ref="tabRoot" class="space-y-3 outline-none" tabindex="-1" data-testid="settings-client-tokens-tab">
3
+ <p class="text-sm text-gray-700">{{ t("settingsModal.clientTokensTab.description") }}</p>
4
+ <p class="text-xs text-gray-500">
5
+ {{ t("settingsModal.clientTokensTab.issueHint") }}
6
+ <code class="rounded bg-gray-100 px-1 py-0.5 font-mono text-gray-800">{{ t("settingsModal.clientTokensTab.issueCommand") }}</code>
7
+ </p>
8
+
9
+ <p v-if="loading" class="text-sm text-gray-500" data-testid="settings-client-tokens-loading">{{ t("settingsModal.clientTokensTab.loading") }}</p>
10
+ <p v-else-if="tokens.length === 0 && !loadError" class="text-sm text-gray-500" data-testid="settings-client-tokens-empty">
11
+ {{ t("settingsModal.clientTokensTab.empty") }}
12
+ </p>
13
+
14
+ <table v-else-if="tokens.length > 0" class="w-full text-sm" data-testid="settings-client-tokens-list">
15
+ <thead>
16
+ <tr class="text-left text-xs text-gray-500 border-b border-gray-200">
17
+ <th class="py-1 pr-3 font-medium">{{ t("settingsModal.clientTokensTab.columnName") }}</th>
18
+ <th class="py-1 pr-3 font-medium">{{ t("settingsModal.clientTokensTab.columnScopes") }}</th>
19
+ <th class="py-1 pr-3 font-medium">{{ t("settingsModal.clientTokensTab.columnCreated") }}</th>
20
+ <th class="py-1 pr-3 font-medium">{{ t("settingsModal.clientTokensTab.columnLastUsed") }}</th>
21
+ <th class="py-1" />
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr v-for="token in tokens" :key="token.id" class="border-b border-gray-100 align-top" :data-testid="`settings-client-token-${token.name}`">
26
+ <td class="py-1.5 pr-3 font-mono text-gray-900">{{ token.name }}</td>
27
+ <td class="py-1.5 pr-3 font-mono text-xs text-gray-700">{{ token.scopes.join(", ") }}</td>
28
+ <td class="py-1.5 pr-3 text-xs text-gray-700">{{ formatIso(token.createdAt) }}</td>
29
+ <td class="py-1.5 pr-3 text-xs text-gray-700" data-testid="settings-client-token-last-used">
30
+ {{ token.lastUsedAt === null ? t("settingsModal.clientTokensTab.neverUsed") : formatIso(token.lastUsedAt) }}
31
+ </td>
32
+ <td class="py-1.5 text-right">
33
+ <div v-if="confirmingName === token.name" class="flex justify-end gap-2">
34
+ <button
35
+ type="button"
36
+ class="rounded bg-red-700 px-2 py-1 text-xs font-medium text-white hover:bg-red-800 disabled:opacity-50"
37
+ :disabled="revokingName !== null"
38
+ :aria-describedby="CONFIRM_BODY_ID"
39
+ data-testid="settings-client-token-confirm-btn"
40
+ @click="revoke(token)"
41
+ >
42
+ {{ revokingName === token.name ? t("settingsModal.clientTokensTab.revoking") : t("settingsModal.clientTokensTab.confirmLabel") }}
43
+ </button>
44
+ <button
45
+ :ref="rememberCancelButton"
46
+ type="button"
47
+ class="rounded border border-gray-300 px-2 py-1 text-xs text-gray-700 hover:bg-gray-100 disabled:opacity-50"
48
+ :disabled="revokingName !== null"
49
+ :aria-describedby="CONFIRM_BODY_ID"
50
+ data-testid="settings-client-token-cancel-btn"
51
+ @click="cancelConfirm(token.name)"
52
+ >
53
+ {{ t("common.cancel") }}
54
+ </button>
55
+ </div>
56
+ <button
57
+ v-else
58
+ :ref="(el) => rememberRevokeButton(token.name, el)"
59
+ type="button"
60
+ class="rounded border border-red-300 bg-red-50 px-2 py-1 text-xs font-medium text-red-800 hover:bg-red-100 disabled:opacity-50"
61
+ :disabled="revokingName !== null"
62
+ data-testid="settings-client-token-revoke-btn"
63
+ @click="openConfirm(token.name)"
64
+ >
65
+ {{ t("settingsModal.clientTokensTab.revokeLabel") }}
66
+ </button>
67
+ </td>
68
+ </tr>
69
+ </tbody>
70
+ </table>
71
+
72
+ <p v-if="confirmingName !== null" :id="CONFIRM_BODY_ID" class="text-xs text-red-900" role="status" data-testid="settings-client-token-confirm-body">
73
+ {{ t("settingsModal.clientTokensTab.confirmBody", { name: confirmingName }) }}
74
+ </p>
75
+ <p class="text-xs text-gray-500">{{ t("settingsModal.clientTokensTab.lastUsedNote") }}</p>
76
+ <p v-if="unreadableEntryCount > 0" class="text-sm text-amber-800" role="status" data-testid="settings-client-tokens-unreadable">
77
+ {{ t("settingsModal.clientTokensTab.unreadableEntries", { count: unreadableEntryCount }) }}
78
+ </p>
79
+ <p v-if="loadError" class="text-sm text-red-700" role="alert" data-testid="settings-client-tokens-error">{{ loadError }}</p>
80
+ <p v-if="revokeError" class="text-sm text-red-700" role="alert" data-testid="settings-client-tokens-revoke-error">{{ revokeError }}</p>
81
+ </div>
82
+ </template>
83
+
84
+ <script setup lang="ts">
85
+ import { nextTick, onMounted, ref, type ComponentPublicInstance } from "vue";
86
+ import { useI18n } from "vue-i18n";
87
+ import { apiDelete, apiGet } from "../utils/api";
88
+ import { API_ROUTES } from "../config/apiRoutes";
89
+ import { formatDateTime } from "../utils/format/date";
90
+
91
+ interface ClientTokenRow {
92
+ name: string;
93
+ id: string;
94
+ createdAt: string;
95
+ scopes: string[];
96
+ lastUsedAt: string | null;
97
+ }
98
+
99
+ const { t } = useI18n();
100
+
101
+ const tokens = ref<ClientTokenRow[]>([]);
102
+ const unreadableEntryCount = ref(0);
103
+ const loading = ref(true);
104
+ const loadError = ref("");
105
+ const revokeError = ref("");
106
+ const confirmingName = ref<string | null>(null);
107
+ const revokingName = ref<string | null>(null);
108
+
109
+ // The confirm swaps out the button that had focus, so focus is moved on purpose:
110
+ // to Cancel when it opens, back to the row's Revoke when cancelled, and to the
111
+ // tab once the row is gone.
112
+ const CONFIRM_BODY_ID = "settings-client-token-confirm-body";
113
+ const tabRoot = ref<HTMLElement | null>(null);
114
+ const revokeButtons = new Map<string, HTMLButtonElement>();
115
+ const cancelButton = ref<HTMLButtonElement | null>(null);
116
+
117
+ type TemplateRef = Element | ComponentPublicInstance | null;
118
+
119
+ function rememberRevokeButton(name: string, element: TemplateRef): void {
120
+ if (element instanceof HTMLButtonElement) revokeButtons.set(name, element);
121
+ else revokeButtons.delete(name);
122
+ }
123
+
124
+ function rememberCancelButton(element: TemplateRef): void {
125
+ cancelButton.value = element instanceof HTMLButtonElement ? element : null;
126
+ }
127
+
128
+ async function openConfirm(name: string): Promise<void> {
129
+ confirmingName.value = name;
130
+ await nextTick();
131
+ cancelButton.value?.focus();
132
+ }
133
+
134
+ async function cancelConfirm(name: string): Promise<void> {
135
+ confirmingName.value = null;
136
+ await nextTick();
137
+ revokeButtons.get(name)?.focus();
138
+ }
139
+
140
+ function formatIso(iso: string): string {
141
+ const epochMs = Date.parse(iso);
142
+ return Number.isNaN(epochMs) ? iso : formatDateTime(epochMs);
143
+ }
144
+
145
+ async function load(): Promise<void> {
146
+ const response = await apiGet<{ tokens: ClientTokenRow[]; unreadableEntryCount: number }>(API_ROUTES.config.clientTokens);
147
+ loading.value = false;
148
+ if (!response.ok) {
149
+ loadError.value = response.error || t("settingsModal.clientTokensTab.loadError");
150
+ return;
151
+ }
152
+ loadError.value = "";
153
+ tokens.value = response.data.tokens;
154
+ unreadableEntryCount.value = response.data.unreadableEntryCount;
155
+ }
156
+
157
+ // Revoking stays disabled until the reload lands, so an older list can never
158
+ // arrive after a newer one and bring a revoked row back.
159
+ async function revoke(token: ClientTokenRow): Promise<void> {
160
+ if (revokingName.value !== null) return;
161
+ revokingName.value = token.name;
162
+ // The id pins the row the user confirmed: a token re-issued under the same
163
+ // name since the list loaded is refused rather than revoked.
164
+ const response = await apiDelete<{ revoked: string }>(API_ROUTES.config.clientToken.replace(":name", encodeURIComponent(token.name)), undefined, {
165
+ query: { id: token.id },
166
+ });
167
+ confirmingName.value = null;
168
+ revokeError.value = response.ok ? "" : response.error || t("settingsModal.clientTokensTab.revokeError");
169
+ await load();
170
+ revokingName.value = null;
171
+ await nextTick();
172
+ (revokeButtons.get(token.name) ?? tabRoot.value)?.focus();
173
+ }
174
+
175
+ onMounted(load);
176
+ </script>
@@ -175,6 +175,7 @@
175
175
  survive the compiler. This tab is mutually exclusive with
176
176
  the rest by construction, so it does not need to be in it. -->
177
177
  <SettingsQuitTab v-if="activeTab === 'quit'" @stopped="emit('stopped')" />
178
+ <SettingsClientTokensTab v-if="activeTab === 'clientTokens'" />
178
179
  </template>
179
180
  </div>
180
181
  </div>
@@ -211,6 +212,7 @@ import SettingsChatIndexTab from "./SettingsChatIndexTab.vue";
211
212
  import SettingsJournalTab from "./SettingsJournalTab.vue";
212
213
  import SettingsNotificationsTab from "./SettingsNotificationsTab.vue";
213
214
  import SettingsQuitTab from "./SettingsQuitTab.vue";
215
+ import SettingsClientTokensTab from "./SettingsClientTokensTab.vue";
214
216
  import SkillsView from "../plugins/manageSkills/View.vue";
215
217
  import RolesView from "./RolesView.vue";
216
218
  import PluginScopedRoot from "./PluginScopedRoot.vue";
@@ -283,6 +285,7 @@ type TabId =
283
285
  | "notifications"
284
286
  | "skills"
285
287
  | "roles"
288
+ | "clientTokens"
286
289
  | "quit";
287
290
 
288
291
  const activeTab = ref<TabId>("tools");
@@ -310,7 +313,7 @@ const GROUPS: readonly { key: string; items: readonly TabId[] }[] = [
310
313
  { key: "management", items: ["skills", "roles"] },
311
314
  // Last on purpose: stopping the server is a deliberate act, not
312
315
  // something to sit a mis-click away from the controls above (#2616).
313
- { key: "server", items: ["quit"] },
316
+ { key: "server", items: ["clientTokens", "quit"] },
314
317
  ];
315
318
 
316
319
  // The file to name in the Gemini tab. The bare filename is the fallback
@@ -116,6 +116,10 @@ const HOST_API_ROUTES = {
116
116
  // Safe to call ad-hoc — pure side effect, no body.
117
117
  refresh: "/api/config/refresh",
118
118
  connectors: "/api/config/connectors",
119
+ /** GET → { tokens: [{ name, id, createdAt, scopes, lastUsedAt }] } (#3637). Never a value. */
120
+ clientTokens: "/api/config/client-tokens",
121
+ /** DELETE → revoke that client token (404 unknown name, 409 while a CLI token command runs). */
122
+ clientToken: "/api/config/client-tokens/:name",
119
123
  },
120
124
 
121
125
  files: {
package/src/lang/de.ts CHANGED
@@ -281,6 +281,7 @@ const deMessages = {
281
281
  notifications: "Web Push",
282
282
  skills: "Skills",
283
283
  roles: "Rollen",
284
+ clientTokens: "API-Tokens",
284
285
  quit: "Beenden",
285
286
  },
286
287
  groups: {
@@ -347,6 +348,30 @@ const deMessages = {
347
348
  loadError: "Einstellungen konnten nicht geladen werden",
348
349
  saveError: "Speichern fehlgeschlagen",
349
350
  },
351
+ clientTokensTab: {
352
+ description:
353
+ "Benannte Tokens für Bridges, n8n-Workflows und Skripte. Wird eines hier widerrufen, wird dieser Client ab seiner nächsten Anfrage abgewiesen – ohne Neustart und ohne die anderen zu berühren.",
354
+ issueHint: "Tokens werden im Terminal ausgestellt, damit ihr Wert nie über diese Seite läuft:",
355
+ // Message function: the `<` and `>` would otherwise reach the message compiler.
356
+ issueCommand: () => "npx mulmoclaude token add <name>",
357
+ loading: "Wird geladen…",
358
+ empty: "Keine Tokens ausgestellt.",
359
+ columnName: "Name",
360
+ columnScopes: "Bereiche",
361
+ columnCreated: "Erstellt",
362
+ columnLastUsed: "Zuletzt verwendet",
363
+ neverUsed: "Nie",
364
+ revokeLabel: "Widerrufen",
365
+ confirmBody:
366
+ "„{name}“ widerrufen? Ein Client, der es verwendet, wird ab seiner nächsten Anfrage abgewiesen, und eine offene Verbindung wird binnen Sekunden geschlossen.",
367
+ confirmLabel: "Widerrufen",
368
+ revoking: "Wird widerrufen…",
369
+ lastUsedNote: "Die letzte Verwendung wird minutengenau erfasst.",
370
+ unreadableEntries:
371
+ "client-tokens.json enthält {count} Einträge, die dieser Server nicht lesen kann. Sie berechtigen zu nichts, und diese Seite widerruft nicht, solange sie vorhanden sind, weil ein Neuschreiben der Datei sie entfernen würde. `mulmoclaude token revoke` funktioniert weiterhin und entfernt sie.",
372
+ loadError: "Tokens konnten nicht geladen werden",
373
+ revokeError: "Token konnte nicht widerrufen werden",
374
+ },
350
375
  quitTab: {
351
376
  description:
352
377
  "Beendet den MulmoClaude-Server auf diesem Rechner. Über das Symbol gestartet, läuft er weiter, auch wenn du diesen Tab schließt — hier beendest du ihn ohne Terminal.",