mulmoclaude 2.10.0 → 2.11.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 (34) hide show
  1. package/README.md +11 -0
  2. package/bin/mulmoclaude.js +32 -17
  3. package/client/assets/{JsonEditor-E3FJ7oRf.js → JsonEditor-DnC5hozl.js} +1 -1
  4. package/client/assets/{marp-CmMNIT1E.js → marp-DvbfD9EO.js} +1 -1
  5. package/client/assets/material-symbols-outlined-DzTrJqFk.woff2 +0 -0
  6. package/client/assets/{feat-3497-Cwr8t4l4.js → mulmoclaude3-BUmaA-ZX.js} +588 -582
  7. package/client/assets/mulmoclaude3-D93Ihflz.css +2 -0
  8. package/client/assets/vue-i18n-BVPWXOdL.js +3 -0
  9. package/client/index.html +3 -3
  10. package/package.json +20 -20
  11. package/server/agent/backend/claude-code.ts +50 -5
  12. package/server/agent/config.ts +3 -1
  13. package/server/agent/sandboxEnv.ts +148 -0
  14. package/server/agent/sandboxEnvPlan.ts +188 -0
  15. package/server/api/auth/bearerAuth.ts +19 -10
  16. package/server/api/auth/clientTokenAccess.ts +57 -0
  17. package/server/api/auth/clientTokenCli.ts +13 -0
  18. package/server/api/auth/clientTokenCommands.ts +90 -0
  19. package/server/api/auth/clientTokenRule.ts +115 -0
  20. package/server/api/auth/clientTokenStore.ts +178 -0
  21. package/server/api/auth/principal.ts +33 -0
  22. package/server/api/routes/collections.ts +73 -35
  23. package/server/build/mcp-server.mjs +617 -608
  24. package/server/events/pub-sub/handshakeAuth.ts +3 -5
  25. package/server/events/pub-sub/index.ts +22 -4
  26. package/server/index.ts +3 -1
  27. package/server/system/env.ts +4 -0
  28. package/server/system/logs/aaa +737 -0
  29. package/server/system/logs/bb +446 -0
  30. package/src/components/SessionHistoryRow.vue +11 -1
  31. package/src/utils/html/customViewSrcdoc.ts +5 -0
  32. package/client/assets/feat-3497-DEfIEPf6.css +0 -2
  33. package/client/assets/material-symbols-outlined-Bn5lkljl.woff2 +0 -0
  34. package/client/assets/vue-i18n-BHWgmfE3.js +0 -3
@@ -1,9 +1,7 @@
1
- import { isAuthorizedToken } from "@mulmoclaude/common/token-guard";
2
1
  import { isRecord } from "../../utils/types.js";
3
2
 
4
3
  // `auth` is whatever the socket.io client put in `io({ auth })`. Only a record
5
- // whose `token` passes the shared bearer rule connects; a server with no token
6
- // yet refuses everything, as `bearerAuth` does for HTTP.
7
- export function isAuthorizedPubSubHandshake(auth: unknown, expectedToken: string | null): boolean {
8
- return isRecord(auth) && isAuthorizedToken(auth.token, expectedToken);
4
+ // whose `token` passes `authorizeToken` (the host's bearer rule) connects.
5
+ export function isAuthorizedPubSubHandshake(auth: unknown, authorizeToken: (token: unknown) => boolean): boolean {
6
+ return isRecord(auth) && authorizeToken(auth.token);
9
7
  }
@@ -3,6 +3,7 @@ import { Server as IOServer, type Socket } from "socket.io";
3
3
 
4
4
  import { UNAUTHORIZED_MESSAGE } from "@mulmoclaude/common/token-guard";
5
5
  import { log } from "../../system/logger/index.js";
6
+ import { ONE_SECOND_MS } from "../../utils/time.js";
6
7
  import { isAuthorizedPubSubHandshake } from "./handshakeAuth.js";
7
8
 
8
9
  export interface IPubSub {
@@ -11,9 +12,25 @@ export interface IPubSub {
11
12
  }
12
13
 
13
14
  export interface PubSubOptions {
14
- /** The bearer token a handshake must present. `null` while the server
15
- * has none yet, which refuses every handshake. */
16
- tokenProvider: () => string | null;
15
+ /** Whether a handshake's token is accepted; refuses everything until the
16
+ * server has a token of its own. */
17
+ authorizeToken: (token: unknown) => boolean;
18
+ /** Test seam for how often open sockets are re-checked. */
19
+ revalidateIntervalMs?: number | undefined;
20
+ }
21
+
22
+ // The token is checked at the handshake; this re-checks open sockets so a
23
+ // revoked client token stops receiving events without waiting to reconnect.
24
+ const REVALIDATE_INTERVAL_MS = 5 * ONE_SECOND_MS;
25
+
26
+ function startRevalidation(server: http.Server, ioServer: IOServer, authorizeToken: (token: unknown) => boolean, intervalMs: number): void {
27
+ const timer = setInterval(() => {
28
+ ioServer.sockets.sockets.forEach((socket) => {
29
+ if (!isAuthorizedPubSubHandshake(socket.handshake.auth, authorizeToken)) socket.disconnect(true);
30
+ });
31
+ }, intervalMs);
32
+ timer.unref();
33
+ server.once("close", () => clearInterval(timer));
17
34
  }
18
35
 
19
36
  const logRoomError =
@@ -73,7 +90,7 @@ export function createPubSub(server: http.Server, options: PubSubOptions): IPubS
73
90
  // destroys the client socket, so socket.io does not retry it — the SPA
74
91
  // reads that as "reload for a fresh token" rather than spinning.
75
92
  ioServer.use((socket, next) => {
76
- if (isAuthorizedPubSubHandshake(socket.handshake.auth, options.tokenProvider())) {
93
+ if (isAuthorizedPubSubHandshake(socket.handshake.auth, options.authorizeToken)) {
77
94
  next();
78
95
  return;
79
96
  }
@@ -81,6 +98,7 @@ export function createPubSub(server: http.Server, options: PubSubOptions): IPubS
81
98
  next(new Error(UNAUTHORIZED_MESSAGE));
82
99
  });
83
100
 
101
+ startRevalidation(server, ioServer, options.authorizeToken, options.revalidateIntervalMs ?? REVALIDATE_INTERVAL_MS);
84
102
  ioServer.on("connection", bindRoomEvents);
85
103
 
86
104
  return {
package/server/index.ts CHANGED
@@ -142,6 +142,7 @@ import { connectRelay } from "./events/relay-client.js";
142
142
  import { startConfiguredBridges } from "./bridges/registry.js";
143
143
  import { requireSameOrigin } from "./api/csrfGuard.js";
144
144
  import { bearerAuth } from "./api/auth/bearerAuth.js";
145
+ import { isAuthorizedBearer } from "./api/auth/principal.js";
145
146
  import { isViewDataPath } from "./api/auth/viewToken.js";
146
147
  import { deleteTokenFile, generateAndWriteToken, getCurrentToken } from "./api/auth/token.js";
147
148
  import { boundPortOf, deleteServerPort, publishServerPort, setBoundPort } from "./workspace/serverPort.js";
@@ -747,6 +748,7 @@ const chatService = createChatService({
747
748
  // Socket.io handshake (see #268 Phase A) needs to validate the
748
749
  // same bearer token the HTTP middleware enforces.
749
750
  tokenProvider: getCurrentToken,
751
+ authorizeToken: isAuthorizedBearer,
750
752
  listSessions: listSessionsForBridge,
751
753
  getSessionHistory: getSessionHistoryForBridge,
752
754
  getSessionRole: getSessionRoleForBridge,
@@ -1472,7 +1474,7 @@ process.on("SIGTERM", () => {
1472
1474
  // (CodeRabbit review on PR #1196). Both `createPubSub` and
1473
1475
  // `initNotifier` are sync, so wiring them up here costs nothing
1474
1476
  // and closes the window.
1475
- const earlyPubsub = createPubSub(httpServer, { tokenProvider: getCurrentToken });
1477
+ const earlyPubsub = createPubSub(httpServer, { authorizeToken: isAuthorizedBearer });
1476
1478
  initNotifier({
1477
1479
  publish: (channel, payload) => earlyPubsub.publish(channel, payload),
1478
1480
  });
@@ -96,6 +96,10 @@ export const env = Object.freeze({
96
96
  sandboxSshAgentForward: asFlag(process.env.SANDBOX_SSH_AGENT_FORWARD),
97
97
  sandboxSshAllowedHosts: process.env.SANDBOX_SSH_ALLOWED_HOSTS || "github.com",
98
98
  sandboxMountConfigs: asCsv(process.env.SANDBOX_MOUNT_CONFIGS),
99
+ // Extra env for the Docker sandbox (#3617): host variables by name, and an
100
+ // env file handed to docker as `--env-file`. Both off by default.
101
+ sandboxEnvNames: asCsv(process.env.SANDBOX_ENV),
102
+ sandboxEnvFile: process.env.SANDBOX_ENV_FILE || undefined,
99
103
 
100
104
  // API credentials (undefined when not configured). `GEMINI_API_KEY` is
101
105
  // deliberately NOT here — Settings can write it while the server runs, so