fix(daemon): forward snapshot entries and map workspace errors

- Preserve the snapshot entries tail in the cache and WS frames (cold,
  cached and bus paths), so the browser receives {state, entries}.
- Await a plugin snapshot on the first subscribe of a fresh session.
- Return E_FORBIDDEN (403) for workspace paths outside PI2_WORKSPACE_ROOTS.
- Mint cli.token only after the singleton lock is held, so a second daemon
  cannot invalidate the running one.
- Add hostname/os/version/uptimeMs/pid/port to /api/v1/info and make
  /health reflect instance, workspace and auth state.
This commit is contained in:
yuez committed 2026-10-21 20:42:02 +08:00
1 parent 31f36302bd
commit 5572ac0d84
15 files changed
+661 -22

No files matched your search

+2
View File
@@ -10,6 +10,7 @@ import { attachWsServer, type WsServerHandle } from "./ws.js";
export interface WsServerOverrides {
heartbeatMs?: number;
authTimeoutMs?: number;
snapshotWaitMs?: number;
maxBufferedBytes?: number;
closeBufferedBytes?: number;
maxConnections?: number;
@@ -82,6 +83,7 @@ export async function startServer(config: Config, deps: ServerDeps): Promise<Sta
now: deps.now,
heartbeatMs: wsOverrides.heartbeatMs ?? deps.heartbeatMs,
authTimeoutMs: wsOverrides.authTimeoutMs,
snapshotWaitMs: wsOverrides.snapshotWaitMs,
maxBufferedBytes: wsOverrides.maxBufferedBytes,
closeBufferedBytes: wsOverrides.closeBufferedBytes,
maxConnections: wsOverrides.maxConnections,