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
@@ -0,0 +1,85 @@
1
+ // Settings → client tokens (#3637): list them, revoke one. Issuing stays on the
2
+ // CLI so a token's value never reaches a browser. Under `/api/config`, which
3
+ // `clientTokenAccess.ts` keeps owner-only, so a client token cannot list or
4
+ // revoke tokens.
5
+
6
+ import { Router, type Request } from "express";
7
+
8
+ import { API_ROUTES } from "../../../src/config/apiRoutes.js";
9
+ import { log } from "../../system/logger/index.js";
10
+ import { errorMessage } from "../../utils/errors.js";
11
+ import { badRequest, conflict, notFound, serverError, type ApiResponse } from "../../utils/httpError.js";
12
+ import { listStoredClientTokens, type StoredClientTokenListing } from "../auth/principal.js";
13
+ import { ClientTokenLockBusyError, REVOKE_OUTCOMES, clientTokensPath, revokeStoredClientToken, type RevokeOutcome } from "../auth/clientTokenStore.js";
14
+
15
+ export type ClientTokensResponse = StoredClientTokenListing;
16
+
17
+ export interface RevokeClientTokenResponse {
18
+ revoked: string;
19
+ }
20
+
21
+ export interface ClientTokensDeps {
22
+ /** Throws when the store cannot be read. */
23
+ list: () => StoredClientTokenListing;
24
+ revoke: (target: { name: string; id: string }) => RevokeOutcome;
25
+ }
26
+
27
+ const defaultDeps: ClientTokensDeps = {
28
+ list: listStoredClientTokens,
29
+ revoke: (target) => revokeStoredClientToken(clientTokensPath(), target),
30
+ };
31
+
32
+ const REFUSALS: Record<Exclude<RevokeOutcome, typeof REVOKE_OUTCOMES.revoked>, { send: typeof conflict; message: string }> = {
33
+ [REVOKE_OUTCOMES.notFound]: { send: notFound, message: "no client token by that name" },
34
+ [REVOKE_OUTCOMES.changed]: { send: conflict, message: "that name now belongs to a different token; reload the list" },
35
+ [REVOKE_OUTCOMES.unreadableEntries]: {
36
+ send: conflict,
37
+ message: "client-tokens.json has entries this server cannot read; revoking here would drop them, so use `mulmoclaude token revoke`",
38
+ },
39
+ };
40
+
41
+ function answerRevoke(outcome: RevokeOutcome, name: string, res: ApiResponse<RevokeClientTokenResponse>): void {
42
+ if (outcome === REVOKE_OUTCOMES.revoked) {
43
+ log.info("auth", "client token revoked from Settings", { client: name });
44
+ res.json({ revoked: name });
45
+ return;
46
+ }
47
+ const refusal = REFUSALS[outcome];
48
+ refusal.send(res, refusal.message);
49
+ }
50
+
51
+ function revokeOrRefuse(deps: ClientTokensDeps, target: { name: string; id: string }, res: ApiResponse<RevokeClientTokenResponse>): void {
52
+ try {
53
+ answerRevoke(deps.revoke(target), target.name, res);
54
+ } catch (err) {
55
+ if (err instanceof ClientTokenLockBusyError) {
56
+ conflict(res, errorMessage(err));
57
+ return;
58
+ }
59
+ log.warn("auth", "client token revoke failed", { client: target.name, error: errorMessage(err) });
60
+ serverError(res, errorMessage(err));
61
+ }
62
+ }
63
+
64
+ function listOrFail(deps: ClientTokensDeps, res: ApiResponse<ClientTokensResponse>): void {
65
+ try {
66
+ res.json(deps.list());
67
+ } catch (err) {
68
+ log.warn("auth", "client token list failed", { error: errorMessage(err) });
69
+ serverError(res, errorMessage(err));
70
+ }
71
+ }
72
+
73
+ export function createClientTokensRouter(deps: ClientTokensDeps = defaultDeps): Router {
74
+ const router = Router();
75
+ router.get(API_ROUTES.config.clientTokens, (_req: Request, res: ApiResponse<ClientTokensResponse>) => listOrFail(deps, res));
76
+ router.delete(API_ROUTES.config.clientToken, (req: Request<{ name: string }>, res: ApiResponse<RevokeClientTokenResponse>) => {
77
+ const { id } = req.query;
78
+ if (typeof id !== "string" || id === "") {
79
+ badRequest(res, "id is required");
80
+ return;
81
+ }
82
+ revokeOrRefuse(deps, { name: req.params.name, id }, res);
83
+ });
84
+ return router;
85
+ }
@@ -63,7 +63,7 @@ import {
63
63
  import { clampImageMaxEdge, clampLimit, clampOffset, normalizeFields, normalizeMutate } from "@mulmoclaude/core/remote-view";
64
64
  import { resolveThumbnail } from "../../utils/files/thumbnail-store.js";
65
65
  import { badRequest, notFound, conflict, forbidden, methodNotAllowed, serverError, serviceUnavailable, type ApiResponse } from "../../utils/httpError.js";
66
- import { isClientTokenRequest } from "../auth/principal.js";
66
+ import { isClientTokenRequest, isCollectionVisibleToRequest } from "../auth/principal.js";
67
67
  import { startsAgentRun } from "../auth/clientTokenAccess.js";
68
68
  import { requestBodyRecord } from "../../utils/requestBody.js";
69
69
  import { ONE_MINUTE_MS } from "../../utils/time.js";
@@ -269,16 +269,25 @@ async function toClientSummary(collection: LoadedCollection): Promise<Collection
269
269
  return { ...summary, icon, iconSources: [spec.source.collection] };
270
270
  }
271
271
 
272
- router.get(API_ROUTES.collections.list, async (_req: Request, res: ApiResponse<CollectionsListResponse>) => {
273
- try {
274
- const collections = await discoverCollections();
275
- const summaries = await Promise.all(collections.map(toClientSummary));
276
- res.json({ collections: summaries });
277
- } catch (err) {
278
- log.warn("collections", "list failed", { error: errorMessage(err) });
279
- serverError(res, errorMessage(err));
280
- }
281
- });
272
+ export interface CollectionsListDeps {
273
+ discover: () => Promise<LoadedCollection[]>;
274
+ summarize: (collection: LoadedCollection) => Promise<CollectionSummary>;
275
+ }
276
+
277
+ /** A scoped client token (#3636) sees only its own collections. */
278
+ export function createCollectionsListHandler(deps: CollectionsListDeps = { discover: () => discoverCollections(), summarize: toClientSummary }) {
279
+ return async (req: Request, res: ApiResponse<CollectionsListResponse>): Promise<void> => {
280
+ try {
281
+ const collections = (await deps.discover()).filter((collection) => isCollectionVisibleToRequest(req, collection.slug));
282
+ res.json({ collections: await Promise.all(collections.map(deps.summarize)) });
283
+ } catch (err) {
284
+ log.warn("collections", "list failed", { error: errorMessage(err) });
285
+ serverError(res, errorMessage(err));
286
+ }
287
+ };
288
+ }
289
+
290
+ router.get(API_ROUTES.collections.list, createCollectionsListHandler());
282
291
 
283
292
  // Raw workspace-ontology entries (buildWorkspaceOntology — derived on
284
293
  // demand, never stored); the /collections Map tab builds its graph from
@@ -112,8 +112,8 @@ const SENSITIVE_BASENAMES = new Set([
112
112
  "credentials.json",
113
113
  // Claude Code credentials file written by server/credentials.ts.
114
114
  ".session-token",
115
- // Bearer auth token file — readable without auth via /api/files/*
116
- // exemption, so it must be blocked here (defense in depth).
115
+ // Bearer auth token file — readable without auth via the
116
+ // `GET /api/files/*` exemption, so it must be blocked here (defense in depth).
117
117
  ".npmrc",
118
118
  ".htpasswd",
119
119
  // Neither carries an extension, and `classify` answers "text" for every
@@ -202,10 +202,8 @@ export const VIDEO_EXTENSIONS = new Set([".mp4", ".webm", ".mov", ".m4v", ".ogv"
202
202
 
203
203
  /** Things a later double-click would execute. Refused on upload — a drop into
204
204
  * the workspace is for data, not for programs — and refused by the write gate
205
- * for the same reason: `/api/files/*` is exempt from bearer auth
206
- * (`server/index.ts`), so create and PUT are reachable by anything that can
207
- * talk to the loopback port, and "typed through one unauthenticated route" is
208
- * not a weaker capability than "dropped through another". PREVIEW is
205
+ * for the same reason: "typed through one route" is not a weaker capability
206
+ * than "dropped through another". PREVIEW is
209
207
  * deliberately unaffected — a `.sh` still renders as text, it just cannot be
210
208
  * written here. */
211
209
  export const BLOCKED_UPLOAD_EXTENSIONS = new Set([".exe", ".dll", ".so", ".dylib", ".bat", ".cmd", ".com", ".scr", ".msi", ".app", ".sh", ".ps1"]);