agent-log-viewer 1.2.1 → 1.2.2
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/dist/mcp-server.mjs +2225 -1385
- package/dist/runtime-host.mjs +1690 -972
- package/dist/standalone/.next/BUILD_ID +1 -1
- package/dist/standalone/.next/app-path-routes-manifest.json +26 -24
- package/dist/standalone/.next/build-manifest.json +2 -2
- package/dist/standalone/.next/prerender-manifest.json +4 -4
- package/dist/standalone/.next/required-server-files.json +1 -0
- package/dist/standalone/.next/routes-manifest.json +12 -0
- package/dist/standalone/.next/server/account-migration-controller-worker.js +1 -1
- package/dist/standalone/.next/server/app/_global-error/page.js +2 -2
- package/dist/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/dist/standalone/.next/server/app/_global-error.html +1 -1
- package/dist/standalone/.next/server/app/_global-error.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/dist/standalone/.next/server/app/_not-found/page.js +1 -1
- package/dist/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/dist/standalone/.next/server/app/_not-found.html +1 -1
- package/dist/standalone/.next/server/app/_not-found.rsc +2 -2
- package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
- package/dist/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
- package/dist/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
- package/dist/standalone/.next/server/app/api/access/route.js +1 -1
- package/dist/standalone/.next/server/app/api/access/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/account-migrations/[intentId]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/account-migrations/[intentId]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/account-project-bindings/route.js +1 -1
- package/dist/standalone/.next/server/app/api/account-project-bindings/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/[id]/status/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/[id]/status/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/active/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/active/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/limits/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/limits/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/input/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/input/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/policy/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/policy/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/terminal/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/claude/terminal/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/cli/route.js +1 -0
- package/dist/standalone/.next/server/app/api/accounts/cli/route.js.nft.json +1 -0
- package/dist/standalone/.next/server/app/api/accounts/cli/route_client-reference-manifest.js +1 -0
- package/dist/standalone/.next/server/app/api/accounts/codex/active/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/active/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/limits/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/limits/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/policy/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/policy/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/reset-credits/route.js +2 -2
- package/dist/standalone/.next/server/app/api/accounts/codex/reset-credits/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/terminal/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/codex/terminal/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/accounts/route.js +1 -1
- package/dist/standalone/.next/server/app/api/accounts/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/agent/route.js +1 -1
- package/dist/standalone/.next/server/app/api/agent/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/agent/snapshot/route.js +1 -1
- package/dist/standalone/.next/server/app/api/agent/snapshot/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/answer/route.js +1 -1
- package/dist/standalone/.next/server/app/api/answer/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/artifact/route.js +1 -1
- package/dist/standalone/.next/server/app/api/artifact/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/attach-command/route.js +1 -1
- package/dist/standalone/.next/server/app/api/attach-command/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/attention/[id]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/attention/[id]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/attention/route.js +1 -1
- package/dist/standalone/.next/server/app/api/attention/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/board/route.js +1 -1
- package/dist/standalone/.next/server/app/api/board/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/bridge/route.js +1 -1
- package/dist/standalone/.next/server/app/api/bridge/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/conversation-host/route.js +1 -1
- package/dist/standalone/.next/server/app/api/conversation-host/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/conversation-host/targets/route.js +1 -1
- package/dist/standalone/.next/server/app/api/conversation-host/targets/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/conversations/[conversationId]/migration/route.js +1 -1
- package/dist/standalone/.next/server/app/api/conversations/[conversationId]/migration/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/conversations/route.js +1 -1
- package/dist/standalone/.next/server/app/api/conversations/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/files/route.js +6 -3
- package/dist/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/flows/[id]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/flows/[id]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/flows/route.js +1 -1
- package/dist/standalone/.next/server/app/api/flows/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/image/route.js +1 -1
- package/dist/standalone/.next/server/app/api/image/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/inbox/route.js +2 -2
- package/dist/standalone/.next/server/app/api/inbox/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/lifecycle/reaper/route.js +1 -1
- package/dist/standalone/.next/server/app/api/lifecycle/reaper/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/limits/history/route.js +1 -1
- package/dist/standalone/.next/server/app/api/limits/history/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/limits/route.js +1 -1
- package/dist/standalone/.next/server/app/api/limits/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/log/preflight/route.js +1 -1
- package/dist/standalone/.next/server/app/api/log/preflight/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/log/project-delete/route.js +1 -1
- package/dist/standalone/.next/server/app/api/log/project-delete/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/log/provenance/route.js +14 -12
- package/dist/standalone/.next/server/app/api/log/provenance/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/log/route.js +1 -1
- package/dist/standalone/.next/server/app/api/log/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/log/suggestions/route.js +2 -2
- package/dist/standalone/.next/server/app/api/log/suggestions/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/logs/route.js +1 -1
- package/dist/standalone/.next/server/app/api/logs/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/logs/stream/route.js +2 -2
- package/dist/standalone/.next/server/app/api/logs/stream/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/monitor/runs/route.js +1 -1
- package/dist/standalone/.next/server/app/api/monitor/runs/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/monitor/seat-tick/route.js +6 -5
- package/dist/standalone/.next/server/app/api/monitor/seat-tick/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/monitor/seat-tick/settings/route.js +2 -2
- package/dist/standalone/.next/server/app/api/monitor/seat-tick/settings/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/onboarding/route.js +1 -0
- package/dist/standalone/.next/server/app/api/onboarding/route.js.nft.json +1 -0
- package/dist/standalone/.next/server/app/api/onboarding/route_client-reference-manifest.js +1 -0
- package/dist/standalone/.next/server/app/api/orchestrator/rotate/route.js +1 -1
- package/dist/standalone/.next/server/app/api/orchestrator/rotate/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/orchestrator/seat/route.js +1 -1
- package/dist/standalone/.next/server/app/api/orchestrator/seat/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/orchestrator/seat/status/route.js +1 -1
- package/dist/standalone/.next/server/app/api/orchestrator/seat/status/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/[id]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/[id]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/preflight/route.js +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/preflight/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/route.js +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/pipelines/tick/route.js +1 -2
- package/dist/standalone/.next/server/app/api/pipelines/tick/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/proc/route.js +1 -1
- package/dist/standalone/.next/server/app/api/proc/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/projects/create/route.js +2 -2
- package/dist/standalone/.next/server/app/api/projects/create/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/projects/crown/route.js +1 -1
- package/dist/standalone/.next/server/app/api/projects/crown/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/projects/directories/route.js +1 -1
- package/dist/standalone/.next/server/app/api/projects/directories/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/push/route.js +2 -2
- package/dist/standalone/.next/server/app/api/push/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/resources/route.js +1 -1
- package/dist/standalone/.next/server/app/api/resources/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/roles/route.js +3 -3
- package/dist/standalone/.next/server/app/api/roles/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/answer/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/answer/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/[deploymentId]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/[deploymentId]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/capabilities/v1/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/capabilities/v1/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/deployments/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/hosts/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/hosts/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/inject/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/inject/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/interrupt/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/interrupt/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/operations/[operationId]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/operations/[operationId]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/operations/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/operations/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/queue/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/queue/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/realtime/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/realtime/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/send/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/send/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/snapshot/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/snapshot/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/spawn/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/spawn/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/steer/route.js +1 -1
- package/dist/standalone/.next/server/app/api/runtime/steer/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/runtime/stream/route.js +2 -2
- package/dist/standalone/.next/server/app/api/runtime/stream/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/search/transcripts/route.js +1 -1
- package/dist/standalone/.next/server/app/api/search/transcripts/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/session/route.js +1 -1
- package/dist/standalone/.next/server/app/api/session/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/session/supersedence/route.js +1 -1
- package/dist/standalone/.next/server/app/api/session/supersedence/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/session/title/route.js +1 -1
- package/dist/standalone/.next/server/app/api/session/title/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/spawn/policy/route.js +2 -2
- package/dist/standalone/.next/server/app/api/spawn/policy/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/spawn/route.js +1 -1
- package/dist/standalone/.next/server/app/api/spawn/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/spawn/validate/route.js +1 -1
- package/dist/standalone/.next/server/app/api/spawn/validate/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/staging/route.js +2 -2
- package/dist/standalone/.next/server/app/api/staging/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/task-attachments/route.js +2 -2
- package/dist/standalone/.next/server/app/api/task-attachments/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/assignment/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/assignment/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/send/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/send/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/spawn/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/[id]/spawn/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/curator/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/curator/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tasks/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tasks/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/telegram/reports/route.js +1 -1
- package/dist/standalone/.next/server/app/api/telegram/reports/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/telegram/route.js +1 -1
- package/dist/standalone/.next/server/app/api/telegram/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/timeline/route.js +1 -1
- package/dist/standalone/.next/server/app/api/timeline/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tmux/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tmux/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tmux/targets/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tmux/targets/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/transcribe/backend/route.js +2 -2
- package/dist/standalone/.next/server/app/api/transcribe/backend/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/transcribe/route.js +2 -2
- package/dist/standalone/.next/server/app/api/transcribe/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/transcribe/token/route.js +2 -2
- package/dist/standalone/.next/server/app/api/transcribe/token/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tts/backend/route.js +1 -1
- package/dist/standalone/.next/server/app/api/tts/backend/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/tts/route.js +2 -2
- package/dist/standalone/.next/server/app/api/tts/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/view/presence/route.js +2 -1
- package/dist/standalone/.next/server/app/api/view/presence/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/workflows/[id]/route.js +1 -1
- package/dist/standalone/.next/server/app/api/workflows/[id]/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/api/workflows/route.js +1 -1
- package/dist/standalone/.next/server/app/api/workflows/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/favicon.ico/route.js +1 -1
- package/dist/standalone/.next/server/app/favicon.ico/route.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/index.html +1 -1
- package/dist/standalone/.next/server/app/index.rsc +3 -3
- package/dist/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
- package/dist/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
- package/dist/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
- package/dist/standalone/.next/server/app/page.js +20 -20
- package/dist/standalone/.next/server/app/page.js.nft.json +1 -1
- package/dist/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/dist/standalone/.next/server/app-paths-manifest.json +26 -24
- package/dist/standalone/.next/server/chunks/107.js +1 -1
- package/dist/standalone/.next/server/chunks/1106.js +5 -0
- package/dist/standalone/.next/server/chunks/112.js +1 -0
- package/dist/standalone/.next/server/chunks/1406.js +35 -168
- package/dist/standalone/.next/server/chunks/1585.js +3 -3
- package/dist/standalone/.next/server/chunks/160.js +18 -18
- package/dist/standalone/.next/server/chunks/1617.js +1 -1
- package/dist/standalone/.next/server/chunks/1849.js +1 -1
- package/dist/standalone/.next/server/chunks/1952.js +1 -1
- package/dist/standalone/.next/server/chunks/2499.js +1 -0
- package/dist/standalone/.next/server/chunks/2555.js +1 -1
- package/dist/standalone/.next/server/chunks/2589.js +127 -0
- package/dist/standalone/.next/server/chunks/261.js +1 -0
- package/dist/standalone/.next/server/chunks/2744.js +1 -1
- package/dist/standalone/.next/server/chunks/286.js +2 -2
- package/dist/standalone/.next/server/chunks/2914.js +20 -21
- package/dist/standalone/.next/server/chunks/2916.js +1 -0
- package/dist/standalone/.next/server/chunks/3086.js +1 -1
- package/dist/standalone/.next/server/chunks/3407.js +1 -1
- package/dist/standalone/.next/server/chunks/3509.js +1 -0
- package/dist/standalone/.next/server/chunks/3570.js +1 -1
- package/dist/standalone/.next/server/chunks/3696.js +5 -0
- package/dist/standalone/.next/server/chunks/3743.js +9 -9
- package/dist/standalone/.next/server/chunks/3784.js +5 -0
- package/dist/standalone/.next/server/chunks/3830.js +1 -1
- package/dist/standalone/.next/server/chunks/3957.js +1 -0
- package/dist/standalone/.next/server/chunks/4037.js +1 -1
- package/dist/standalone/.next/server/chunks/4651.js +1 -1
- package/dist/standalone/.next/server/chunks/4972.js +38 -16
- package/dist/standalone/.next/server/chunks/53.js +1 -0
- package/dist/standalone/.next/server/chunks/5408.js +1 -1
- package/dist/standalone/.next/server/chunks/5465.js +156 -0
- package/dist/standalone/.next/server/chunks/5545.js +1 -1
- package/dist/standalone/.next/server/chunks/568.js +1 -1
- package/dist/standalone/.next/server/chunks/6023.js +1 -1
- package/dist/standalone/.next/server/chunks/6211.js +1 -0
- package/dist/standalone/.next/server/chunks/6289.js +1 -2
- package/dist/standalone/.next/server/chunks/6418.js +1 -0
- package/dist/standalone/.next/server/chunks/6453.js +1 -1
- package/dist/standalone/.next/server/chunks/6522.js +1 -1
- package/dist/standalone/.next/server/chunks/6796.js +1 -1
- package/dist/standalone/.next/server/chunks/6826.js +3 -3
- package/dist/standalone/.next/server/chunks/6942.js +3 -3
- package/dist/standalone/.next/server/chunks/6978.js +1 -1
- package/dist/standalone/.next/server/chunks/7008.js +21 -19
- package/dist/standalone/.next/server/chunks/7192.js +1 -1
- package/dist/standalone/.next/server/chunks/7238.js +2 -2
- package/dist/standalone/.next/server/chunks/7294.js +1 -0
- package/dist/standalone/.next/server/chunks/7722.js +1 -1
- package/dist/standalone/.next/server/chunks/781.js +17 -17
- package/dist/standalone/.next/server/chunks/8027.js +1 -1
- package/dist/standalone/.next/server/chunks/8330.js +1 -0
- package/dist/standalone/.next/server/chunks/8444.js +1 -1
- package/dist/standalone/.next/server/chunks/8512.js +1 -1
- package/dist/standalone/.next/server/chunks/8513.js +2 -2
- package/dist/standalone/.next/server/chunks/8617.js +1 -1
- package/dist/standalone/.next/server/chunks/8817.js +2 -2
- package/dist/standalone/.next/server/chunks/8966.js +1 -1
- package/dist/standalone/.next/server/chunks/8985.js +1 -1
- package/dist/standalone/.next/server/chunks/8996.js +1 -1
- package/dist/standalone/.next/server/chunks/9006.js +1 -0
- package/dist/standalone/.next/server/chunks/9060.js +4 -0
- package/dist/standalone/.next/server/chunks/9296.js +20 -21
- package/dist/standalone/.next/server/chunks/9298.js +1 -2
- package/dist/standalone/.next/server/chunks/9307.js +1 -1
- package/dist/standalone/.next/server/chunks/9360.js +12 -12
- package/dist/standalone/.next/server/chunks/9517.js +1 -1
- package/dist/standalone/.next/server/chunks/9611.js +1 -0
- package/dist/standalone/.next/server/chunks/9822.js +1 -1
- package/dist/standalone/.next/server/chunks/9839.js +5 -0
- package/dist/standalone/.next/server/chunks/9867.js +1 -0
- package/dist/standalone/.next/server/chunks/9940.js +37 -15
- package/dist/standalone/.next/server/chunks/9998.js +1 -1
- package/dist/standalone/.next/server/file-scanner-worker.js +1 -1
- package/dist/standalone/.next/server/files-response-worker.js +2 -2
- package/dist/standalone/.next/server/functions-config-manifest.json +2 -0
- package/dist/standalone/.next/server/middleware-build-manifest.js +1 -1
- package/dist/standalone/.next/server/middleware.js +3 -3
- package/dist/standalone/.next/server/pages/404.html +1 -1
- package/dist/standalone/.next/server/pages/500.html +1 -1
- package/dist/standalone/.next/server/resource-collector-worker.js +1 -1
- package/dist/standalone/.next/server/server-reference-manifest.json +1 -1
- package/dist/standalone/.next/server/state-backup-worker.js +3 -0
- package/dist/standalone/.next/server/wakatime-sync-worker.js +1 -1
- package/dist/standalone/.next/static/chunks/9591-0fd6a5a4172de16d.js +1 -0
- package/dist/standalone/.next/static/chunks/app/_global-error/page-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/access/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/account-migrations/[intentId]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/account-project-bindings/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/[id]/status/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/active/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/limits/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/input/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/policy/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/terminal/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/cli/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/active/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/limits/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/policy/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/reset-credits/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/terminal/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/accounts/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/agent/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/agent/snapshot/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/answer/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/artifact/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/attach-command/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/attention/[id]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/attention/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/board/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/bridge/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/conversation-host/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/conversation-host/targets/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/conversations/[conversationId]/migration/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/conversations/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/files/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/flows/[id]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/flows/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/image/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/inbox/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/lifecycle/reaper/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/limits/history/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/limits/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/log/preflight/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/log/project-delete/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/log/provenance/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/log/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/log/suggestions/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/logs/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/logs/stream/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/monitor/runs/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/settings/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/onboarding/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/rotate/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/status/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/pipelines/[id]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/pipelines/preflight/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/pipelines/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/pipelines/tick/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/proc/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/projects/create/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/projects/crown/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/projects/directories/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/push/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/resources/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/roles/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/answer/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/[deploymentId]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/capabilities/v1/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/hosts/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/inject/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/interrupt/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/operations/[operationId]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/operations/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/queue/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/realtime/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/send/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/snapshot/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/spawn/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/steer/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/runtime/stream/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/search/transcripts/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/session/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/session/supersedence/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/session/title/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/spawn/policy/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/spawn/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/spawn/validate/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/staging/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/task-attachments/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/assignment/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/send/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/spawn/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/curator/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tasks/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/telegram/reports/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/telegram/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/timeline/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tmux/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tmux/targets/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/transcribe/backend/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/transcribe/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/transcribe/token/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tts/backend/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/tts/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/view/presence/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/workflows/[id]/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/api/workflows/route-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/app/page-a2e19d755e17b569.js +125 -0
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-151390fbd8c93c25.js +1 -0
- package/dist/standalone/.next/static/css/9b32c3f7f468cbcc.css +1 -0
- package/dist/standalone/.next/static/fQ2a5S10vvpyAqE0L_wUj/_buildManifest.js +1 -0
- package/dist/standalone/package.json +1 -1
- package/dist/standalone/server.bun.js +1 -1
- package/dist/standalone/src/lib/viewerInstrumentation.ts +44 -1
- package/package.json +1 -1
- package/dist/standalone/.next/server/chunks/1888.js +0 -1
- package/dist/standalone/.next/server/chunks/4127.js +0 -1
- package/dist/standalone/.next/server/chunks/606.js +0 -126
- package/dist/standalone/.next/static/836HTp-5V8cZC5YWFVOCk/_buildManifest.js +0 -1
- package/dist/standalone/.next/static/chunks/7333-cf17cea2a91e7b4b.js +0 -1
- package/dist/standalone/.next/static/chunks/app/_global-error/page-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/access/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/account-migrations/[intentId]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/account-project-bindings/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/[id]/status/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/active/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/limits/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/input/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/policy/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/claude/terminal/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/active/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/limits/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/policy/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/reset-credits/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/codex/terminal/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/accounts/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/agent/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/agent/snapshot/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/answer/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/artifact/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/attach-command/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/attention/[id]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/attention/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/board/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/bridge/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/conversation-host/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/conversation-host/targets/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/conversations/[conversationId]/migration/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/conversations/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/files/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/flows/[id]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/flows/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/image/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/inbox/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/lifecycle/reaper/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/limits/history/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/limits/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/log/preflight/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/log/project-delete/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/log/provenance/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/log/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/log/suggestions/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/logs/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/logs/stream/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/monitor/runs/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/settings/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/rotate/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/status/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/pipelines/[id]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/pipelines/preflight/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/pipelines/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/pipelines/tick/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/proc/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/projects/create/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/projects/crown/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/projects/directories/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/push/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/resources/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/roles/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/answer/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/[deploymentId]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/capabilities/v1/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/hosts/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/inject/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/interrupt/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/operations/[operationId]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/operations/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/queue/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/realtime/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/send/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/snapshot/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/spawn/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/steer/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/runtime/stream/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/search/transcripts/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/session/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/session/supersedence/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/session/title/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/spawn/policy/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/spawn/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/spawn/validate/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/staging/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/task-attachments/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/assignment/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/send/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/spawn/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/curator/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tasks/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/telegram/reports/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/telegram/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/timeline/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tmux/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tmux/targets/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/transcribe/backend/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/transcribe/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/transcribe/token/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tts/backend/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/tts/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/view/presence/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/workflows/[id]/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/api/workflows/route-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/app/page-1cde2db61f461960.js +0 -125
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-60a25d1c4cbf0128.js +0 -1
- package/dist/standalone/.next/static/css/b25c03e915fd256b.css +0 -1
- /package/dist/standalone/.next/static/{836HTp-5V8cZC5YWFVOCk → fQ2a5S10vvpyAqE0L_wUj}/_ssgManifest.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";exports.id=4972,exports.ids=[4972],exports.modules={1198:(a,b,c)=>{function d(a,b){let c=RegExp(`^${b}:\\s+(\\d+)\\s*kB`,"m").exec(a);if(!c)return null;let d=Number(c[1]);return Number.isFinite(d)?1024*d:null}function e(a){let b=d(a,"MemTotal"),c=d(a,"MemAvailable");if(null===b||null===c||b<=0)return null;let e=d(a,"SwapTotal")??0,f=d(a,"SwapFree")??e;return{ramTotal:b,ramAvailable:c,swapTotal:e,swapUsed:Math.max(0,e-f)}}function f(a){return{rssBytes:d(a,"VmRSS")??0,swapBytes:d(a,"VmSwap")??0}}function g(a){let b=Number(/page size of (\d+) bytes/.exec(a)?.[1]);if(!Number.isFinite(b)||b<=0)return null;let c=b=>{let c=RegExp(`^${b}:\\s+(\\d+)\\.?`,"m").exec(a);return c?Number(c[1]):null},d=c("Pages free"),e=c("Pages inactive");return null===d||null===e?null:(d+e+(c("Pages purgeable")??0))*b}c.d(b,{CT:()=>k,Lc:()=>g,NW:()=>e,mO:()=>l,sW:()=>f,yh:()=>j});let h=/([\d.]+)\s*([KMGT])/;function i(a){let b=h.exec(a);if(!b)return null;let c=Number(b[1]);return Number.isFinite(c)?Math.round(c*({K:1024,M:1048576,G:0x40000000,T:0x10000000000})[b[2]]):null}function j(a){let b=/total\s*=\s*(\S+)/.exec(a)?.[1],c=/used\s*=\s*(\S+)/.exec(a)?.[1];if(!b||!c)return null;let d=i(b),e=i(c);return null===d||null===e?null:{swapTotal:d,swapUsed:e}}function k(a){let b=new Map;for(let c of a.split("\n")){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(c);a&&b.set(Number(a[1]),1024*Number(a[2]))}return b}function l(a,b){let c=new Map;for(let[a,d]of b){if(a===d)continue;let b=c.get(d);b?b.push(a):c.set(d,[a])}let d=new Set([a]),e=[],f=[a];for(;f.length;){let a=f.pop();for(let b of(e.push(a),c.get(a)??[]))d.has(b)||(d.add(b),f.push(b))}return e}},14928:(a,b,c)=>{c.d(b,{Gw:()=>
|
|
1
|
+
"use strict";exports.id=4972,exports.ids=[4972],exports.modules={1198:(a,b,c)=>{function d(a,b){let c=RegExp(`^${b}:\\s+(\\d+)\\s*kB`,"m").exec(a);if(!c)return null;let d=Number(c[1]);return Number.isFinite(d)?1024*d:null}function e(a){let b=d(a,"MemTotal"),c=d(a,"MemAvailable");if(null===b||null===c||b<=0)return null;let e=d(a,"SwapTotal")??0,f=d(a,"SwapFree")??e;return{ramTotal:b,ramAvailable:c,swapTotal:e,swapUsed:Math.max(0,e-f)}}function f(a){return{rssBytes:d(a,"VmRSS")??0,swapBytes:d(a,"VmSwap")??0}}function g(a){let b=Number(/page size of (\d+) bytes/.exec(a)?.[1]);if(!Number.isFinite(b)||b<=0)return null;let c=b=>{let c=RegExp(`^${b}:\\s+(\\d+)\\.?`,"m").exec(a);return c?Number(c[1]):null},d=c("Pages free"),e=c("Pages inactive");return null===d||null===e?null:(d+e+(c("Pages purgeable")??0))*b}c.d(b,{CT:()=>k,Lc:()=>g,NW:()=>e,mO:()=>l,sW:()=>f,yh:()=>j});let h=/([\d.]+)\s*([KMGT])/;function i(a){let b=h.exec(a);if(!b)return null;let c=Number(b[1]);return Number.isFinite(c)?Math.round(c*({K:1024,M:1048576,G:0x40000000,T:0x10000000000})[b[2]]):null}function j(a){let b=/total\s*=\s*(\S+)/.exec(a)?.[1],c=/used\s*=\s*(\S+)/.exec(a)?.[1];if(!b||!c)return null;let d=i(b),e=i(c);return null===d||null===e?null:{swapTotal:d,swapUsed:e}}function k(a){let b=new Map;for(let c of a.split("\n")){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(c);a&&b.set(Number(a[1]),1024*Number(a[2]))}return b}function l(a,b){let c=new Map;for(let[a,d]of b){if(a===d)continue;let b=c.get(d);b?b.push(a):c.set(d,[a])}let d=new Set([a]),e=[],f=[a];for(;f.length;){let a=f.pop();for(let b of(e.push(a),c.get(a)??[]))d.has(b)||(d.add(b),f.push(b))}return e}},14928:(a,b,c)=>{c.d(b,{Gw:()=>P,M:()=>N,N$:()=>K,UY:()=>Q,Vx:()=>M,bG:()=>t,iy:()=>r,jY:()=>O,nF:()=>J,t0:()=>E,tD:()=>I});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(55686),k=c(34402),l=c(89204),m=c(95697);let n=new Int32Array(new SharedArrayBuffer(4)),o=new Set,p=0;function q(){let a=process.getBuiltinModule?.("bun:sqlite");if(!a)throw Error("SQLite state stores require the Bun runtime");return a.Database}function r(a){o.add(i().resolve(a))}function s(a,b){let c=a.query("SELECT schema_version, migration_id FROM state_collections WHERE collection = ?");return b.every(a=>{let b=c.get(a.collection);return b?.schema_version===a.schemaVersion&&b.migration_id===a.migrationId})}function t(a,b){if(!g().existsSync(a))return!1;let c=null;try{return c=y(a),s(c,b)}catch{return!1}finally{c?.close()}}function u(a){if(!(0,m.Ny)(i().dirname(a)))throw new l.Qm("hot state writes are fenced during release handoff")}function v(a,b=!1){if((0,m.Ny)(i().dirname(a))||o.has(i().resolve(a))&&(0,m.T2)(i().dirname(a)))return;let c=(0,m.jU)(i().dirname(a)),d=(0,m.a5)(i().dirname(a));if(!b||null===c||d?.mode!=="fencing"||d.releaseRevision!==c)throw new l.Qm("hot state migration is waiting for release promotion")}function w(a){return(0,k.PK)(a,()=>x(a))}function x(a){g().mkdirSync(i().dirname(a),{recursive:!0,mode:448});let b=new(q())(a,{create:!0,strict:!0});try{for(let a=0;a<6e3;a+=1)try{return b.exec("PRAGMA busy_timeout = 0; PRAGMA synchronous = FULL; PRAGMA journal_size_limit = 67108864; PRAGMA foreign_keys = ON;"),b}catch(a){if(!C(a))throw a;Atomics.wait(n,0,0,5)}throw new l.Qm("state database connection is busy")}catch(a){throw b.close(),a}}function y(a){return p+=1,(0,k.PK)(a,()=>{var b;let c;return b=a,(c=new(q())(b,{readonly:!0,strict:!0})).exec("PRAGMA busy_timeout = 0; PRAGMA foreign_keys = ON;"),c})}function z(a){return(0,k.PK)(a,()=>(function(a){let b=x(a);try{for(let c=0;c<6e3;c+=1)try{return b.exec("PRAGMA journal_mode = WAL; PRAGMA auto_vacuum = INCREMENTAL;"),b.exec("BEGIN IMMEDIATE"),b.exec(`
|
|
2
2
|
CREATE TABLE IF NOT EXISTS state_collections (
|
|
3
3
|
collection TEXT PRIMARY KEY,
|
|
4
4
|
schema_version INTEGER NOT NULL,
|
|
@@ -38,34 +38,56 @@
|
|
|
38
38
|
owner_start_identity TEXT,
|
|
39
39
|
acquired_at INTEGER NOT NULL
|
|
40
40
|
);
|
|
41
|
-
|
|
41
|
+
CREATE TABLE IF NOT EXISTS state_imports (
|
|
42
|
+
collection TEXT PRIMARY KEY REFERENCES state_collections(collection) ON DELETE CASCADE,
|
|
43
|
+
source_name TEXT NOT NULL,
|
|
44
|
+
source_sha256 TEXT,
|
|
45
|
+
source_bytes INTEGER NOT NULL,
|
|
46
|
+
row_count INTEGER NOT NULL,
|
|
47
|
+
row_digest TEXT NOT NULL,
|
|
48
|
+
gap TEXT,
|
|
49
|
+
release TEXT,
|
|
50
|
+
imported_at TEXT NOT NULL,
|
|
51
|
+
mirror_sha256 TEXT,
|
|
52
|
+
mirror_revision INTEGER
|
|
53
|
+
);
|
|
54
|
+
`),b.query("PRAGMA table_info(state_collections)").all().some(a=>"change_floor"===a.name)||b.exec("ALTER TABLE state_collections ADD COLUMN change_floor INTEGER NOT NULL DEFAULT 0"),b.exec("COMMIT"),A(a),b}catch(a){if(B(b),!C(a))throw a;Atomics.wait(n,0,0,5)}throw new l.Qm("state database initialization is busy")}catch(a){throw b.close(),a}})(a))}function A(a){for(let b of[a,`${a}-wal`,`${a}-shm`])try{g().chmodSync(b,384)}catch(a){if("ENOENT"!==a.code)throw a}}function B(a){try{a.exec("ROLLBACK")}catch{}}function C(a){let b=a instanceof Error?a.message:String(a);return/database is (?:locked|busy)|SQLITE_BUSY/i.test(b)}function D(a,b,c){for(let b=0;b<6e3;b+=1)try{a.exec("BEGIN IMMEDIATE");let b=c();return a.exec("COMMIT"),b}catch(b){if(B(a),!C(b))throw b;Atomics.wait(n,0,0,5)}throw new l.Qm(b)}function E(a,b,c={}){!function(a,b){let c=i().resolve(a);if(o.has(c)||t(a,b))return;let d=i().dirname(a);if(null===(0,m.X4)(d))return o.add(c);if(!(0,m.Ny)(d))throw new l.Qm("hot state migration is waiting for release promotion");o.add(c)}(a,b);let d=!c.reimportExisting&&t(a,b),e=z(a);try{for(let f=0;f<6e3;f+=1)try{if(e.exec("BEGIN IMMEDIATE"),v(a,d),c.reimportExisting&&!s(e,b)){let a=e.query("DELETE FROM state_leases WHERE collection = ?"),c=e.query("DELETE FROM state_collections WHERE collection = ?");for(let d of b)a.run(d.collection),c.run(d.collection)}for(let a of b){let b=e.query("SELECT schema_version, migration_id FROM state_collections WHERE collection = ?").get(a.collection);if(b){if(b.schema_version!==a.schemaVersion)throw Error(`unsupported ${a.collection} SQLite schema: ${b.schema_version}`);if(b.migration_id!==a.migrationId)throw Error(`unsupported ${a.collection} SQLite migration: ${b.migration_id}`);continue}!function(a,b){let c=b.loadRecords(),d=+(c.length>0);a.query(`
|
|
42
55
|
INSERT INTO state_collections(collection, schema_version, revision, migration_id, imported_at)
|
|
43
56
|
VALUES (?, ?, ?, ?, ?)
|
|
44
57
|
`).run(b.collection,b.schemaVersion,d,b.migrationId,new Date().toISOString());let e=a.query(`
|
|
45
58
|
INSERT INTO state_rows(collection, row_key, value_json, row_order, row_revision, controller_active)
|
|
46
59
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
47
|
-
`),f=new Set;c.forEach((a,c)=>{let g=b.key(a);if(!g||f.has(g))throw Error(`duplicate or empty ${b.collection} migration key: ${g}`);f.add(g),e.run(b.collection,g,JSON.stringify(a),c,d,+(b.controllerActive?.(a)!==!1))})}(e,a),c.afterCollectionImport?.(a.collection)}
|
|
60
|
+
`),f=new Set;c.forEach((a,c)=>{let g=b.key(a);if(!g||f.has(g))throw Error(`duplicate or empty ${b.collection} migration key: ${g}`);f.add(g),e.run(b.collection,g,JSON.stringify(a),c,d,+(b.controllerActive?.(a)!==!1))})}(e,a),c.afterCollectionImport?.(a.collection)}v(a,d),e.exec("COMMIT"),A(a);return}catch(a){if(B(e),!C(a))throw a;Atomics.wait(n,0,0,5)}throw new l.Qm("state migration is busy")}finally{e.close()}}class F extends Error{constructor(a){super(a),this.name="StateImportVerificationError"}}function G(a){let b=e().createHash("sha256");for(let c of a)b.update(c).update("\n");return b.digest("hex")}function H(a,b){let c=a.query("SELECT * FROM state_imports WHERE collection = ?").get(b);return c?{collection:c.collection,sourceName:c.source_name,sourceSha256:c.source_sha256,sourceBytes:c.source_bytes,rowCount:c.row_count,rowDigest:c.row_digest,gap:c.gap,release:c.release,importedAt:c.imported_at,mirrorSha256:c.mirror_sha256,mirrorRevision:c.mirror_revision}:null}function I(a,b){if(!g().existsSync(a))return null;let c=y(a);try{return H(c,b)}catch(a){if(/no such table/i.test(a instanceof Error?a.message:String(a)))return null;throw a}finally{c.close()}}function J(a,b){let c=b.rows.map(a=>({...a,valueJson:JSON.stringify(a.value)})),d=new Set;for(let a of c){if(!a.key||d.has(a.key))throw Error(`duplicate or empty ${b.collection} import key: ${a.key}`);d.add(a.key)}let e=G(c.map(a=>a.valueJson)),f=z(a);try{let d=D(f,`${b.collection} import is busy`,()=>{u(a);let d=H(f,b.collection);if(d)return{imported:!1,record:d};if(f.query("SELECT 1 FROM state_collections WHERE collection = ?").get(b.collection))throw new F(`${b.collection} collection exists without import evidence`);let g=+(c.length>0),h=new Date().toISOString();f.query(`
|
|
61
|
+
INSERT INTO state_collections(collection, schema_version, revision, migration_id, imported_at)
|
|
62
|
+
VALUES (?, ?, ?, ?, ?)
|
|
63
|
+
`).run(b.collection,b.schemaVersion,g,b.migrationId,h);let i=f.query(`
|
|
64
|
+
INSERT INTO state_rows(collection, row_key, value_json, row_order, row_revision, controller_active)
|
|
65
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
66
|
+
`);c.forEach((a,c)=>{i.run(b.collection,a.key,a.valueJson,c,g,+!!a.controllerActive)}),b.beforeVerify?.((a,...b)=>{f.query(a).run(...b)});let j=f.query("SELECT value_json FROM state_rows WHERE collection = ? ORDER BY row_order, row_key").all(b.collection).map(a=>a.value_json),k=G(j);if(j.length!==c.length||k!==e)throw new F(`${b.collection} import verification failed: ${j.length}/${c.length} rows, digest mismatch=${k!==e}`);return f.query(`
|
|
67
|
+
INSERT INTO state_imports(collection, source_name, source_sha256, source_bytes, row_count, row_digest, gap, release, imported_at)
|
|
68
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
69
|
+
`).run(b.collection,b.sourceName,b.sourceSha256,b.sourceBytes,c.length,k,b.gap,b.release,h),u(a),{imported:!0,record:H(f,b.collection)}});return A(a),d}finally{f.close()}}function K(a,b,c,d){let e=w(a);try{D(e,`${b} import is busy`,()=>{e.query("UPDATE state_imports SET mirror_sha256 = ?, mirror_revision = ? WHERE collection = ?").run(c,d,b)})}finally{e.close()}}function L(a){let b=[a];for(let c of[a,`${a}-wal`])try{let a=g().statSync(c,{bigint:!0});b.push(`${i().basename(c)}:${a.mtimeNs}:${a.size}`)}catch{b.push(`${i().basename(c)}:missing`)}return b.join("|")}function M(a,b){return N(a,[b]).get(b)??null}function N(a,b){let c=new Map(b.map(a=>[a,null]));if(!g().existsSync(a)||0===b.length)return c;let d=y(a);try{let a=b.map(()=>"?").join(", ");for(let e of d.query(`
|
|
48
70
|
SELECT collections.collection, rows.row_key, rows.value_json
|
|
49
71
|
FROM state_collections AS collections
|
|
50
72
|
LEFT JOIN state_rows AS rows ON rows.collection = collections.collection
|
|
51
73
|
WHERE collections.collection IN (${a})
|
|
52
74
|
ORDER BY collections.collection, rows.row_order, rows.row_key
|
|
53
|
-
`).all(...b)){let a=c.get(e.collection)??[];if(c.set(e.collection,a),null!==e.row_key&&null!==e.value_json)try{a.push(JSON.parse(e.value_json))}catch(a){throw Error(`corrupt ${e.collection} SQLite row: ${e.row_key}`,{cause:a})}}return c}catch(a){if(/no such table/i.test(a instanceof Error?a.message:String(a)))return c;throw a}finally{d.close()}}function
|
|
75
|
+
`).all(...b)){let a=c.get(e.collection)??[];if(c.set(e.collection,a),null!==e.row_key&&null!==e.value_json)try{a.push(JSON.parse(e.value_json))}catch(a){throw Error(`corrupt ${e.collection} SQLite row: ${e.row_key}`,{cause:a})}}return c}catch(a){if(/no such table/i.test(a instanceof Error?a.message:String(a)))return c;throw a}finally{d.close()}}function O(a,b){return P(a,[b]).get(b)??null}function P(a,b){let c=new Map(b.map(a=>[a,null]));if(!g().existsSync(a))return c;let d=y(a);try{if(0===b.length)return c;let a=b.map(()=>"?").join(", ");for(let e of d.query(`
|
|
54
76
|
SELECT collection, revision FROM state_collections
|
|
55
77
|
WHERE collection IN (${a})
|
|
56
|
-
`).all(...b))c.set(e.collection,e.revision);return c}catch(a){if(/no such table/i.test(a instanceof Error?a.message:String(a)))return c;throw a}finally{d.close()}}class
|
|
78
|
+
`).all(...b))c.set(e.collection,e.revision);return c}catch(a){if(/no such table/i.test(a instanceof Error?a.message:String(a)))return c;throw a}finally{d.close()}}class Q{constructor(a,b){this.filename=a,this.options=b,this.cache=null,this.revisionCache=null,this.readDb=z(a);const c=this.collectionMeta();if(!c)throw Error(`SQLite state collection is not initialized: ${b.collection}`);if(c.schema_version!==b.schemaVersion)throw Error(`unsupported ${b.collection} SQLite schema: ${c.schema_version}`)}revision(){let a=L(this.filename);if(this.revisionCache?.signature===a)return this.revisionCache.revision;let b=this.collectionMeta()?.revision??0,c=L(this.filename);return c===a&&(this.revisionCache={signature:c,revision:b}),b}signature(){return`${this.filename}:${this.options.collection}:${this.revision()}`}snapshot(){return this.loadReadonly().map(a=>this.options.clone(a))}snapshotForController(){return this.loadControllerReadonly().map(a=>this.options.clone(a))}get(a){let b=this.readDb.query("SELECT value_json FROM state_rows WHERE collection = ? AND row_key = ?").get(this.options.collection,a);if(!b)return null;let c=this.decodeRow(b.value_json);return null===c?null:this.options.clone(c)}keyRange(a,b,c){if(!Number.isSafeInteger(c)||c<1||c>512)throw Error("invalid state page limit");return this.readDb.query(`
|
|
57
79
|
SELECT value_json FROM state_rows
|
|
58
80
|
WHERE collection = ? AND row_key > ? AND row_key <= ? ORDER BY row_key LIMIT ?
|
|
59
|
-
`).all(this.options.collection,a,b,c).map(a=>{let b=this.decodeRow(a.value_json);if(null===b)throw Error("invalid bounded state row");return this.options.clone(b)})}boundedPatch(a,b){if(!Number.isSafeInteger(a)||a<1||a>4096)throw Error("invalid state patch limit");
|
|
81
|
+
`).all(this.options.collection,a,b,c).map(a=>{let b=this.decodeRow(a.value_json);if(null===b)throw Error("invalid bounded state row");return this.options.clone(b)})}boundedPatch(a,b){if(!Number.isSafeInteger(a)||a<1||a>4096)throw Error("invalid state patch limit");u(this.filename);let c=this.acquireLeaseSync();try{let d=w(this.filename);try{let e=D(d,this.options.busyMessage,()=>{u(this.filename),this.assertLease(d,c);let e=this.collectionMeta(d).revision+1,f=a,g=()=>{if(--f<0)throw Error("state patch row budget exceeded")},h=new Map,i=b({get:a=>{g();let b=d.query("SELECT value_json FROM state_rows WHERE collection = ? AND row_key = ?").get(this.options.collection,a);if(!b)return null;let c=this.decodeRow(b.value_json);if(null===c)throw Error("invalid bounded state row");return this.options.clone(c)},put:a=>{g(),this.validate(a);let b=this.options.key(a);d.query(`INSERT INTO state_rows(collection,row_key,value_json,row_order,row_revision,controller_active)
|
|
60
82
|
VALUES (?,?,?,0,?,?) ON CONFLICT(collection,row_key) DO UPDATE SET
|
|
61
|
-
value_json=excluded.value_json,row_revision=excluded.row_revision,controller_active=excluded.controller_active`).run(this.options.collection,b,JSON.stringify(a),e,+(this.options.controllerActive?.(a)!==!1)),h.set(b,"upsert")},delete:a=>{g(),d.query("DELETE FROM state_rows WHERE collection = ? AND row_key = ?").run(this.options.collection,a),h.set(a,"delete")}});if(i instanceof Promise)throw Error("bounded state patches must be synchronous");if(
|
|
83
|
+
value_json=excluded.value_json,row_revision=excluded.row_revision,controller_active=excluded.controller_active`).run(this.options.collection,b,JSON.stringify(a),e,+(this.options.controllerActive?.(a)!==!1)),h.set(b,"upsert")},delete:a=>{g(),d.query("DELETE FROM state_rows WHERE collection = ? AND row_key = ?").run(this.options.collection,a),h.set(a,"delete")}});if(i instanceof Promise)throw Error("bounded state patches must be synchronous");if(u(this.filename),h.size){for(let[a,b]of h)d.query("INSERT INTO state_changes(collection,revision,row_key,operation) VALUES (?,?,?,?)").run(this.options.collection,e,a,b);d.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(e,this.options.collection),this.pruneChanges(d,e)}return i});return A(this.filename),this.invalidateAfterCommit(),e}finally{d.close()}}finally{this.releaseLeaseSync(c)}}loadReadonly(){this.readDb.exec("BEGIN");try{let a=this.collectionMeta();if(!a)throw Error(`SQLite state collection disappeared: ${this.options.collection}`);let b=a.revision;if(this.cache?.revision===b)return this.readDb.exec("COMMIT"),this.cache.ordered;if(!this.cache||this.cache.revision>b||this.cache.revision<a.change_floor){let a=this.loadFull(b);return this.readDb.exec("COMMIT"),a}let c=this.readDb.query(`
|
|
62
84
|
SELECT DISTINCT row_key FROM state_changes
|
|
63
85
|
WHERE collection = ? AND revision > ? AND revision <= ?
|
|
64
86
|
ORDER BY revision, row_key
|
|
65
87
|
`).all(this.options.collection,this.cache.revision,b);if(0===c.length){let a=this.loadFull(b);return this.readDb.exec("COMMIT"),a}this.options.onIncrementalReadSnapshot?.(b);let d=[...new Set(c.map(a=>a.row_key))],e=new Map;for(let a=0;a<d.length;a+=400){let b=d.slice(a,a+400),c=b.map(()=>"?").join(", "),f=[this.options.collection,...b];for(let a of this.readDb.query(`
|
|
66
88
|
SELECT row_key, value_json, row_order, row_revision, controller_active
|
|
67
89
|
FROM state_rows WHERE collection = ? AND row_key IN (${c})
|
|
68
|
-
`).all(...f))e.set(a.row_key,a)}let f=new Map(this.cache.records),g=!1;for(let a of d){let b=e.get(a);if(!b){f.has(a)&&(g=!0),f.delete(a);continue}let c=f.get(a);if(c&&c.order===b.row_order||(g=!0),c?.valueJson===b.value_json){f.set(a,{...c,order:b.row_order,rowRevision:b.row_revision});continue}let d=this.decodeRow(b.value_json);null===d?f.delete(a):f.set(a,{valueJson:b.value_json,value:d,order:b.row_order,rowRevision:b.row_revision})}let h=g?this.rememberCache(b,f):this.rememberCacheWithOrder(b,f,this.cache.orderedKeys);return this.readDb.exec("COMMIT"),h}catch(a){throw
|
|
90
|
+
`).all(...f))e.set(a.row_key,a)}let f=new Map(this.cache.records),g=!1;for(let a of d){let b=e.get(a);if(!b){f.has(a)&&(g=!0),f.delete(a);continue}let c=f.get(a);if(c&&c.order===b.row_order||(g=!0),c?.valueJson===b.value_json){f.set(a,{...c,order:b.row_order,rowRevision:b.row_revision});continue}let d=this.decodeRow(b.value_json);null===d?f.delete(a):f.set(a,{valueJson:b.value_json,value:d,order:b.row_order,rowRevision:b.row_revision})}let h=g?this.rememberCache(b,f):this.rememberCacheWithOrder(b,f,this.cache.orderedKeys);return this.readDb.exec("COMMIT"),h}catch(a){throw B(this.readDb),a}}async moveMatchingTo(a,b,c={}){if(a===this||a.filename!==this.filename)throw Error("atomic state moves require two collections in one database");u(this.filename);let d=[this,a].sort((a,b)=>a.options.collection.localeCompare(b.options.collection)),e=new Map;try{for(let a of d)e.set(a,await a.acquireLease());let f=w(this.filename);try{let d=D(f,this.options.busyMessage,()=>{u(this.filename),this.assertLease(f,e.get(this)),a.assertLease(f,e.get(a));let d=f.query(`
|
|
69
91
|
SELECT row_key, value_json, row_order, row_revision, controller_active
|
|
70
92
|
FROM state_rows WHERE collection = ? ORDER BY row_order, row_key
|
|
71
93
|
`).all(this.options.collection).flatMap(a=>{let c=this.decodeRow(a.value_json);return null!==c&&b(c)?[{row:a,record:c}]:[]});if(0===d.length)return 0;for(let b of d)a.validate(b.record);let g=this.collectionMeta(f).revision+1,h=a.collectionMeta(f),i=new Map(f.query(`
|
|
@@ -81,14 +103,14 @@
|
|
|
81
103
|
`),n=f.query(`
|
|
82
104
|
INSERT INTO state_changes(collection, revision, row_key, operation)
|
|
83
105
|
VALUES (?, ?, ?, ?)
|
|
84
|
-
`);for(let b of k)m.run(a.options.collection,b.key,b.valueJson,b.order,l,b.controllerActive),n.run(a.options.collection,l,b.key,"upsert");let o=f.query("DELETE FROM state_rows WHERE collection = ? AND row_key = ?");for(let{row:a}of d)o.run(this.options.collection,a.row_key),n.run(this.options.collection,g,a.row_key,"delete");return f.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(g,this.options.collection),k.length>0&&f.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(l,a.options.collection),this.pruneChanges(f,g),k.length>0&&a.pruneChanges(f,l),c.beforeCommit?.(),d.length});return d>0&&(
|
|
106
|
+
`);for(let b of k)m.run(a.options.collection,b.key,b.valueJson,b.order,l,b.controllerActive),n.run(a.options.collection,l,b.key,"upsert");let o=f.query("DELETE FROM state_rows WHERE collection = ? AND row_key = ?");for(let{row:a}of d)o.run(this.options.collection,a.row_key),n.run(this.options.collection,g,a.row_key,"delete");return f.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(g,this.options.collection),k.length>0&&f.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(l,a.options.collection),this.pruneChanges(f,g),k.length>0&&a.pruneChanges(f,l),c.beforeCommit?.(),d.length});return d>0&&(A(this.filename),this.invalidateAfterCommit(),a.invalidateAfterCommit()),d}finally{f.close()}}finally{for(let a of[...d].reverse()){let b=e.get(a);b&&await a.releaseLease(b)}}}replaceSync(a,b={}){u(this.filename);let c=this.acquireLeaseSync();try{b.beforePersist?.(a),this.persistReplacement(c,a,!0===b.mergeOmitted,b.deleteKeys??[])}finally{this.releaseLeaseSync(c)}}patchSync(a,b={}){let c=b.fenceOwner?()=>v(this.filename,!0):()=>u(this.filename);c();let d=this.acquireLeaseSync();try{let b=a();this.persistReplacement(d,b.records,!0,b.deleteKeys??[],c,new Set(b.appendKeys??[]))}finally{this.releaseLeaseSync(d)}}rowRevisions(){return new Map(this.readDb.query("SELECT row_key, row_revision FROM state_rows WHERE collection = ?").all(this.options.collection).map(a=>[a.row_key,a.row_revision]))}withSnapshotSync(a){let b=this.acquireLeaseSync();try{return a(this.snapshot())}finally{this.releaseLeaseSync(b)}}async mutate(a,b,c=!1,d){u(this.filename);let e=await this.acquireLease(d);try{let d=c?this.loadControllerReadonly():this.loadReadonly(),f=this.track(d);return await a(f.records,a=>{this.persistSession(e,f,b,a)})}finally{await this.releaseLease(e)}}checkpointMirror(a){let b=this.acquireLeaseSync();try{let b=this.snapshot();a(b,this.revision())}finally{this.releaseLeaseSync(b)}}checkpointMirrorForDemotion(a,b=2){for(let c=0;c<b;c+=1){let b=-1;if(this.checkpointMirror((c,d)=>{b=d,a(c,d)}),this.revision()===b)return b}throw Error(`${this.options.collection} rollback checkpoint did not converge`)}async checkpointMirrorForDemotionAsync(a,b=2){for(let c=0;c<b;c+=1){let b,c=await this.acquireLease();try{let c=this.snapshot();b=this.revision(),a(c,b)}finally{await this.releaseLease(c)}if(this.revision()===b)return b}throw Error(`${this.options.collection} rollback checkpoint did not converge`)}collectionMeta(a=this.readDb){return a.query("SELECT revision, schema_version, change_floor FROM state_collections WHERE collection = ?").get(this.options.collection)??null}decodeRow(a){try{let b=this.options.decode(JSON.parse(a));if(null===b&&this.options.strictDecode)throw Error(`${this.options.collection} SQLite row is malformed`);return b}catch(a){if(this.options.strictDecode)throw this.options.decodeError?.(a)??a;return this.options.onDecodeError?.(a),null}}loadControllerReadonly(){return this.readDb.query(`
|
|
85
107
|
SELECT value_json FROM state_rows
|
|
86
108
|
WHERE collection = ? AND controller_active = 1
|
|
87
109
|
ORDER BY row_order, row_key
|
|
88
110
|
`).all(this.options.collection).flatMap(a=>{let b=this.decodeRow(a.value_json);return null===b?[]:[b]})}loadFull(a){let b=new Map;for(let a of this.readDb.query(`
|
|
89
111
|
SELECT row_key, value_json, row_order, row_revision
|
|
90
112
|
FROM state_rows WHERE collection = ? ORDER BY row_order, row_key
|
|
91
|
-
`).all(this.options.collection)){let c=this.decodeRow(a.value_json);null!==c&&b.set(a.row_key,{valueJson:a.value_json,value:c,order:a.row_order,rowRevision:a.row_revision})}return this.rememberCache(a,b)}rememberCache(a,b){let c=[...b.entries()].sort((a,b)=>a[1].order-b[1].order||a[0].localeCompare(b[0])),d=c.map(a=>a[0]),e=c.map(a=>a[1].value);return this.cache={revision:a,records:b,orderedKeys:d,ordered:e},this.revisionCache=null,e}rememberCacheWithOrder(a,b,c){let d=c.flatMap(a=>{let c=b.get(a);return c?[c.value]:[]});return this.cache={revision:a,records:b,orderedKeys:c,ordered:d},this.revisionCache=null,d}invalidateAfterCommit(){this.revisionCache=null}track(a){let b=new Map,c=[...a],d={records:[],rawRecords:c,materialized:b,structural:!1},e=a=>{if("string"!=typeof a||!/^(?:0|[1-9][0-9]*)$/.test(a))return null;let b=Number(a);return Number.isSafeInteger(b)?b:null};return d.records=new Proxy(c,{get:(a,c,d)=>{let f=e(c);if(null===f||f>=a.length)return Reflect.get(a,c,d);if(!b.has(f)){let c=this.options.clone(a[f]);a[f]=c,b.set(f,{originalKey:this.options.key(c),persistedJson:JSON.stringify(c),value:c})}return a[f]},set:(a,c,f)=>{d.structural=!0;let g=e(c);return null!==g&&b.delete(g),Reflect.set(a,c,f)},deleteProperty:(a,c)=>{d.structural=!0;let f=e(c);return null!==f&&b.delete(f),Reflect.deleteProperty(a,c)},defineProperty:(a,c,f)=>{d.structural=!0;let g=e(c);return null!==g&&b.delete(g),Reflect.defineProperty(a,c,f)}}),d}persistSession(a,b,c,d){if(d){if(0===d.length)return;c?.({records:b.records,dirtyRecords:d,structural:!1}),this.persistChangedRows(a,d);let e=new Set(d.map(a=>this.options.key(a)));for(let a of b.materialized.values()){let b=this.options.key(a.value);e.has(b)&&(a.originalKey=b,a.persistedJson=JSON.stringify(a.value))}return}let e=[];if(b.structural){for(let a of b.records)e.push(a);c?.({records:b.records,dirtyRecords:e,structural:!0}),this.persistReplacement(a,e,!1),b.structural=!1,b.materialized.clear(),b.rawRecords.forEach((a,c)=>b.materialized.set(c,{originalKey:this.options.key(a),persistedJson:JSON.stringify(a),value:a}));return}for(let d of b.materialized.values()){if(this.options.key(d.value)!==d.originalKey)return b.structural=!0,this.persistSession(a,b,c);JSON.stringify(d.value)!==d.persistedJson&&e.push(d.value)}if(0!==e.length)for(let d of(c?.({records:b.records,dirtyRecords:e,structural:!1}),this.persistChangedRows(a,e),b.materialized.values()))d.originalKey=this.options.key(d.value),d.persistedJson=JSON.stringify(d.value)}validate(a){if(!this.options.key(a))throw Error(`refusing to persist an empty ${this.options.collection} row key`);this.options.validate?.(a)}persistChangedRows(a,b){for(let a of b)this.validate(a);let c=
|
|
113
|
+
`).all(this.options.collection)){let c=this.decodeRow(a.value_json);null!==c&&b.set(a.row_key,{valueJson:a.value_json,value:c,order:a.row_order,rowRevision:a.row_revision})}return this.rememberCache(a,b)}rememberCache(a,b){let c=[...b.entries()].sort((a,b)=>a[1].order-b[1].order||a[0].localeCompare(b[0])),d=c.map(a=>a[0]),e=c.map(a=>a[1].value);return this.cache={revision:a,records:b,orderedKeys:d,ordered:e},this.revisionCache=null,e}rememberCacheWithOrder(a,b,c){let d=c.flatMap(a=>{let c=b.get(a);return c?[c.value]:[]});return this.cache={revision:a,records:b,orderedKeys:c,ordered:d},this.revisionCache=null,d}invalidateAfterCommit(){this.revisionCache=null}track(a){let b=new Map,c=[...a],d={records:[],rawRecords:c,materialized:b,structural:!1},e=a=>{if("string"!=typeof a||!/^(?:0|[1-9][0-9]*)$/.test(a))return null;let b=Number(a);return Number.isSafeInteger(b)?b:null};return d.records=new Proxy(c,{get:(a,c,d)=>{let f=e(c);if(null===f||f>=a.length)return Reflect.get(a,c,d);if(!b.has(f)){let c=this.options.clone(a[f]);a[f]=c,b.set(f,{originalKey:this.options.key(c),persistedJson:JSON.stringify(c),value:c})}return a[f]},set:(a,c,f)=>{d.structural=!0;let g=e(c);return null!==g&&b.delete(g),Reflect.set(a,c,f)},deleteProperty:(a,c)=>{d.structural=!0;let f=e(c);return null!==f&&b.delete(f),Reflect.deleteProperty(a,c)},defineProperty:(a,c,f)=>{d.structural=!0;let g=e(c);return null!==g&&b.delete(g),Reflect.defineProperty(a,c,f)}}),d}persistSession(a,b,c,d){if(d){if(0===d.length)return;c?.({records:b.records,dirtyRecords:d,structural:!1}),this.persistChangedRows(a,d);let e=new Set(d.map(a=>this.options.key(a)));for(let a of b.materialized.values()){let b=this.options.key(a.value);e.has(b)&&(a.originalKey=b,a.persistedJson=JSON.stringify(a.value))}return}let e=[];if(b.structural){for(let a of b.records)e.push(a);c?.({records:b.records,dirtyRecords:e,structural:!0}),this.persistReplacement(a,e,!1),b.structural=!1,b.materialized.clear(),b.rawRecords.forEach((a,c)=>b.materialized.set(c,{originalKey:this.options.key(a),persistedJson:JSON.stringify(a),value:a}));return}for(let d of b.materialized.values()){if(this.options.key(d.value)!==d.originalKey)return b.structural=!0,this.persistSession(a,b,c);JSON.stringify(d.value)!==d.persistedJson&&e.push(d.value)}if(0!==e.length)for(let d of(c?.({records:b.records,dirtyRecords:e,structural:!1}),this.persistChangedRows(a,e),b.materialized.values()))d.originalKey=this.options.key(d.value),d.persistedJson=JSON.stringify(d.value)}validate(a){if(!this.options.key(a))throw Error(`refusing to persist an empty ${this.options.collection} row key`);this.options.validate?.(a)}persistChangedRows(a,b){for(let a of b)this.validate(a);let c=w(this.filename);try{let d=D(c,this.options.busyMessage,()=>{u(this.filename),this.assertLease(c,a);let d=this.collectionMeta(c),e=c.query(`
|
|
92
114
|
SELECT row_key, value_json, row_order, row_revision, controller_active
|
|
93
115
|
FROM state_rows WHERE collection = ? AND row_key = ?
|
|
94
116
|
`),f=b.map(a=>{let b=this.options.key(a),c=JSON.stringify(a),d=+(this.options.controllerActive?.(a)!==!1);return{key:b,valueJson:c,controllerActive:d,row:e.get(this.options.collection,b)}}).filter(a=>a.row?.value_json!==a.valueJson||a.row.controller_active!==a.controllerActive);if(0===f.length)return null;let g=d.revision+1,h=(c.query("SELECT COALESCE(MAX(row_order), -1) AS value FROM state_rows WHERE collection = ?").get(this.options.collection)?.value??-1)+1,i=c.query(`
|
|
@@ -101,10 +123,10 @@
|
|
|
101
123
|
`),j=c.query(`
|
|
102
124
|
INSERT INTO state_changes(collection, revision, row_key, operation)
|
|
103
125
|
VALUES (?, ?, ?, 'upsert')
|
|
104
|
-
`);for(let a of f){let b=a.row?.row_order??h++;i.run(this.options.collection,a.key,a.valueJson,b,g,a.controllerActive),j.run(this.options.collection,g,a.key)}return c.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(g,this.options.collection),this.pruneChanges(c,g),g});null!==d&&(
|
|
126
|
+
`);for(let a of f){let b=a.row?.row_order??h++;i.run(this.options.collection,a.key,a.valueJson,b,g,a.controllerActive),j.run(this.options.collection,g,a.key)}return c.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(g,this.options.collection),this.pruneChanges(c,g),g});null!==d&&(A(this.filename),this.invalidateAfterCommit())}finally{c.close()}}persistReplacement(a,b,c,d=[],e=()=>u(this.filename),f=new Set){for(let a of b)this.validate(a);let g=new Set;for(let a of b){let b=this.options.key(a);if(g.has(b))throw Error(`duplicate ${this.options.collection} row key: ${b}`);g.add(b)}let h=new Set(d);if(h.size!==d.length||[...h].some(a=>!a||g.has(a)))throw Error(`invalid ${this.options.collection} row deletion`);let i=w(this.filename);try{let d=D(i,this.options.busyMessage,()=>{e(),this.assertLease(i,a);let d=this.collectionMeta(i),j=new Map(i.query(`
|
|
105
127
|
SELECT row_key, value_json, row_order, row_revision, controller_active
|
|
106
128
|
FROM state_rows WHERE collection = ?
|
|
107
|
-
`).all(this.options.collection).map(a=>[a.row_key,a])),
|
|
129
|
+
`).all(this.options.collection).map(a=>[a.row_key,a])),k=b.map((a,b)=>({key:this.options.key(a),valueJson:JSON.stringify(a),order:b,controllerActive:+(this.options.controllerActive?.(a)!==!1)})).filter(a=>{let b=j.get(a.key);return!b||b.value_json!==a.valueJson||b.controller_active!==a.controllerActive||!c&&b.row_order!==a.order}),l=c?[...h].filter(a=>j.has(a)):[...j.keys()].filter(a=>!g.has(a));if(0===k.length&&0===l.length)return null;let m=d.revision+1,n=c?Math.max(-1,...[...j.values()].map(a=>a.row_order))+1:0,o=i.query(`
|
|
108
130
|
INSERT INTO state_rows(collection, row_key, value_json, row_order, row_revision, controller_active)
|
|
109
131
|
VALUES (?, ?, ?, ?, ?, ?)
|
|
110
132
|
ON CONFLICT(collection, row_key) DO UPDATE SET
|
|
@@ -112,10 +134,10 @@
|
|
|
112
134
|
row_order = excluded.row_order,
|
|
113
135
|
row_revision = excluded.row_revision,
|
|
114
136
|
controller_active = excluded.controller_active
|
|
115
|
-
`),
|
|
137
|
+
`),p=i.query(`
|
|
116
138
|
INSERT INTO state_changes(collection, revision, row_key, operation)
|
|
117
139
|
VALUES (?, ?, ?, ?)
|
|
118
|
-
`);for(let a of
|
|
140
|
+
`);for(let a of k){let b=j.get(a.key),d=c?(f.has(a.key)?void 0:b?.row_order)??n++:a.order;o.run(this.options.collection,a.key,a.valueJson,d,m,a.controllerActive),p.run(this.options.collection,m,a.key,"upsert")}let q=i.query("DELETE FROM state_rows WHERE collection = ? AND row_key = ?");for(let a of l)q.run(this.options.collection,a),p.run(this.options.collection,m,a,"delete");return i.query("UPDATE state_collections SET revision = ? WHERE collection = ?").run(m,this.options.collection),this.pruneChanges(i,m),m});null!==d&&(A(this.filename),this.invalidateAfterCommit())}finally{i.close()}}assertLease(a,b){let c=a.query("SELECT owner_token FROM state_leases WHERE collection = ?").get(this.options.collection);if(c?.owner_token!==b)throw new l.Qm(this.options.busyMessage)}pruneChanges(a,b){let c=b-1024;c<=0||(a.query(`
|
|
119
141
|
DELETE FROM state_changes WHERE rowid IN (
|
|
120
142
|
SELECT rowid FROM state_changes
|
|
121
143
|
WHERE collection = ? AND revision <= ?
|
|
@@ -130,6 +152,6 @@
|
|
|
130
152
|
`).get(this.options.collection);if(d&&Number.isInteger((c={pid:d.owner_pid,startIdentity:d.owner_start_identity}).pid)&&c.pid>0&&function(a,b){if(!j.B.pidAlive(a))return!1;if(null===b)return!0;let c=j.B.processIdentity(a);return null===c||c===b}(c.pid,c.startIdentity))return a.exec("ROLLBACK"),!1;return d&&a.query("DELETE FROM state_leases WHERE collection = ?").run(this.options.collection),a.query(`
|
|
131
153
|
INSERT INTO state_leases(collection, owner_token, owner_pid, owner_start_identity, acquired_at)
|
|
132
154
|
VALUES (?, ?, ?, ?, ?)
|
|
133
|
-
`).run(this.options.collection,b,process.pid,j.B.processIdentity(process.pid),Date.now()),a.exec("COMMIT"),!0}catch(b){if(
|
|
134
|
-
`;try{if(e().existsSync(c))return void o.add(a);if(!e().existsSync(b)){e().mkdirSync(a,{recursive:!0}),e().writeFileSync(c,d()),o.add(a);return}if(!e().existsSync(a)){e().mkdirSync(i().dirname(a),{recursive:!0});let c=`${a}.migrating.${process.pid}`;e().rmSync(c,{recursive:!0,force:!0});try{e().cpSync(b,c,{recursive:!0}),e().writeFileSync(i().join(c,p),d()),e().renameSync(c,a)}catch(a){throw e().rmSync(c,{recursive:!0,force:!0}),a}o.add(a);return}e().cpSync(b,a,{recursive:!0,force:!1,errorOnExist:!1}),e().writeFileSync(c,d()),o.add(a)}catch(c){console.error(`viewer state migration ${b} -> ${a} failed; will retry:`,c)}}function r(){let a=process.env.LLV_STATE_DIR;if(j()){var b=a;let c=b||i().join(m(),k,"state-staging"),d=i().resolve(c);if([i().join(m(),k,"state"),i().join(m(),l,"state"),i().join(g().homedir(),".claude","viewer-state")].some(a=>i().resolve(a)===d))throw Error(`staging mode refuses the production state dir ${d}; set LLV_STATE_DIR to a staging-only dir`);return c}if(a)return a;let c=i().join(m(),k,"state");return q(c,i().join(g().homedir(),".claude","viewer-state")),c}function s(...a){return i().join(r(),...a)}function t(){if(j())return s("inbox");let a=i().join(m(),k,"inbox");return q(a,i().join(g().homedir(),".claude","viewer-inbox")),a}},55686:(a,b,c)=>{let d,e;c.d(b,{B:()=>O});var f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(1198);let k="/proc";function l(a){try{return g().readFileSync(i().join(k,String(a),"cmdline"),"utf8").split("\0").filter(Boolean)}catch{return[]}}function m(a){try{return g().readlinkSync(i().join(k,String(a),"cwd"))}catch{return null}}function n(a){let b;try{b=g().readFileSync(i().join(k,String(a),"stat"),"utf8")}catch{return null}return b.slice(b.lastIndexOf(")")+2).trim().split(/\s+/)}function o(a){try{return(128&g().lstatSync(a).mode)!=0}catch{return!1}}function p(a){let b;try{b=g().readdirSync(k,{withFileTypes:!0})}catch{return}for(let c of b){let b;if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let d=Number(c.name),e=i().join(k,c.name,"fd");try{b=g().readdirSync(e,{withFileTypes:!0})}catch{continue}for(let c of b){let b,f=i().join(e,c.name);try{b=g().readlinkSync(f)}catch{continue}a(b,d,()=>o(f))}}}let q={name:"linux",pidAlive:function(a){return Number.isInteger(a)&&a>0&&g().existsSync(i().join(k,String(a)))},readArgv:l,readCwd:m,readPpid:function(a){let b=n(a),c=b?Number(b[1]):NaN;return Number.isInteger(c)&&c>1?c:null},processIdentity:function(a){let b=n(a),c=b?.[19];return c?`${a}:${c}`:null},processCpuMs:function(a){let b=n(a),c=Number(b?.[11]),d=Number(b?.[12]);return Number.isFinite(c)&&Number.isFinite(d)?(c+d)/100*1e3:null},readEnvVar:function(a,b){let c;try{c=g().readFileSync(i().join(k,String(a),"environ"),"utf8")}catch{return null}let d=b+"=",e=null;for(let a of c.split("\0"))a.startsWith(d)&&(e=a.slice(d.length));return e},listProcesses:function(){let a,b=[];try{a=g().readdirSync(k,{withFileTypes:!0})}catch{return b}for(let c of a){if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let a=Number(c.name);b.push({pid:a,argv:l(a),cwd:m(a),tty:function(a){let b=n(a),c=b?Number(b[4]):NaN;return Number.isInteger(c)&&c>0?c:0}(a)})}return b},systemMemory:function(){try{return(0,j.NW)(g().readFileSync(i().join(k,"meminfo"),"utf8"))}catch{return null}},processMemory:function(a){let b=new Map;for(let c of a)if(Number.isInteger(c)&&!(c<=0))try{b.set(c,(0,j.sW)(g().readFileSync(i().join(k,String(c),"status"),"utf8")))}catch{}return b},ppidMap:function(){let a,b=new Map;try{a=g().readdirSync(k,{withFileTypes:!0})}catch{return b}for(let c of a){if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let a=Number(c.name),d=n(a),e=d?Number(d[1]):NaN;Number.isInteger(e)&&e>0&&b.set(a,e)}return b},scanFdTargetsUnder:function(a,b){p(b)},scanFdTargetsFor:function(a,b){p(b)},pidWritesPath:function(a,b){let c,d;try{c=g().realpathSync(b)}catch{c=null}let e=i().join(k,String(a),"fd");try{d=g().readdirSync(e,{withFileTypes:!0})}catch{return!1}for(let a of d){let d,f=i().join(e,a.name);try{d=g().readlinkSync(f)}catch{continue}if((d===b||d===c)&&o(f))return!0}return!1},pidHoldsPath:function(a,b){let c;try{c=g().readdirSync(i().join(k,String(a),"fd"),{withFileTypes:!0})}catch{return!1}for(let d of c)try{if(g().readlinkSync(i().join(k,String(a),"fd",d.name))===b)return!0}catch{continue}return!1}};var r=c(31421),s=c(48161),t=c.n(s),u=c(21420);function v(a,b){let c=(0,r.spawnSync)(a,b,{encoding:"utf8",maxBuffer:0x1000000,timeout:1e4});return c.error||"string"!=typeof c.stdout?"":c.stdout}let w=new Map,x=1,y=/^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.*)$/;function z(a,b){let c=0,d="";for(let e of a.split("\n")){if(!e)continue;let a=e[0],f=e.slice(1);if("p"===a)c=Number(f),d="";else if("f"===a)d="";else if("a"===a)d=f;else if("n"===a&&c>0&&f){let a="w"===d||"u"===d;b(f,c,()=>a)}}}let A=null;function B(){let a=Date.now();if(A&&a-A.at<5e3)return A.byPid;let b=function(a){let b=new Map;for(let c of a.split("\n")){let a=y.exec(c);if(!a)continue;let d=Number(a[1]),e=Number(a[2]),f=(a[4]??"").trim().split(/\s+/).filter(Boolean);b.set(d,{ppid:Number.isInteger(e)&&e>1?e:null,tty:function(a){if(!a||"?"===a||"??"===a||"-"===a)return 0;let b=w.get(a);return void 0===b&&(b=x,x+=1,w.set(a,b)),b}(a[3]??""),argv:f})}return b}(v("ps",["-axo","pid=,ppid=,tty=,args="])),c=function(a){let b=new Map,c=0;for(let d of a.split("\n")){if(!d)continue;let a=d[0],e=d.slice(1);"p"===a?c=Number(e):"n"===a&&c>0&&b.set(c,e)}return b}(v("lsof",["-w","-d","cwd","-Fpn"])),d=new Map;for(let[a,e]of b)d.set(a,{argv:e.argv,ppid:e.ppid,tty:e.tty,cwd:c.get(a)??null});return A={at:a,byPid:d},d}let C={name:"portable",pidAlive:function(a){if(!Number.isInteger(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}},readArgv:function(a){return B().get(a)?.argv??[]},readCwd:function(a){return B().get(a)?.cwd??null},readPpid:function(a){return B().get(a)?.ppid??null},processIdentity:function(a){return!Number.isInteger(a)||a<=0?null:"darwin"===process.platform?(0,u.P3)(a):null},processCpuMs:function(){return null},readEnvVar:function(){return null},listProcesses:function(){let a=[];for(let[b,c]of B())a.push({pid:b,argv:c.argv,cwd:c.cwd,tty:c.tty});return a},systemMemory:function(){let a=t().totalmem(),b=(0,j.Lc)(v("vm_stat",[]));if(!a||null===b)return null;let c=(0,j.yh)(v("sysctl",["-n","vm.swapusage"]));return{ramTotal:a,ramAvailable:Math.min(b,a),swapTotal:c?.swapTotal??0,swapUsed:c?.swapUsed??0}},processMemory:function(a){let b=new Set;for(let c of a)Number.isInteger(c)&&c>0&&b.add(c);let c=new Map;if(0===b.size)return c;for(let[a,d]of(0,j.CT)(v("ps",["-axo","pid=,rss="])))b.has(a)&&c.set(a,{rssBytes:d,swapBytes:0});return c},ppidMap:function(){let a=new Map;for(let[b,c]of B())null!==c.ppid&&a.set(b,c.ppid);return a},scanFdTargetsUnder:function(a,b){a&&g().existsSync(a)&&z(v("lsof",["-w","+D",a,"-Fpfan"]),b)},scanFdTargetsFor:function(a,b){let c=[...new Set(a.filter(Boolean))];0!==c.length&&z(v("lsof",["-w","-Fpfan","--",...c]),b)},pidWritesPath:function(a,b){let c=!1;return z(v("lsof",["-w","-a","-p",String(a),"-Fpfan","--",b]),(a,b,d)=>{d()&&(c=!0)}),c},pidHoldsPath:function(a,b){let c=!1;return z(v("lsof",["-w","-a","-p",String(a),"-Fpfan","--",b]),()=>{c=!0}),c}},D=BigInt(0),E=BigInt("125911584000000000"),F=BigInt(0);function G(a){if(!a)return null;let b=Number(a.trim());return Number.isSafeInteger(b)?b:null}function H(a){let b=a?.trim();return b&&/^\d+$/.test(b)?BigInt(b):null}let I=["ProcessId","ParentProcessId","CommandLine","WorkingSetSize","UserModeTime","KernelModeTime","Created"],J=BigInt(1e4),K=null;function L(){let a,b=Date.now();return K&&b-K.at<5e3?K:K={at:b,data:function(a){let b=new Map,c=function(a){let b=65279===a.charCodeAt(0)?a.slice(1):a,c=[],d=[],e="",f=!1,g=!1,h=()=>{d.push(e),e="",g=!1},i=()=>{h(),(d.length>1||""!==d[0])&&c.push(d),d=[]};for(let a=0;a<b.length;a+=1){let c=b[a];if(f){'"'===c?'"'===b[a+1]?(e+='"',a+=1):f=!1:e+=c;continue}if('"'===c&&!g){f=!0,g=!0;continue}if(","===c){h();continue}if("\r"!==c){if("\n"===c){i();continue}e+=c,g=!0}}return(""!==e||d.length>0)&&i(),c}(a),d=c[0];if(!d)return{rows:b,ppids:new Map};let e=new Map(I.map(a=>[a,d.indexOf(a)])),f=e.get("ProcessId")??-1;if(f<0)return{rows:b,ppids:new Map};let g=(a,b)=>{let c=e.get(b)??-1;return c<0?void 0:a[c]};for(let a of c.slice(1)){let c=G(a[f]);null===c||c<=0||b.set(c,{pid:c,rawPpid:G(g(a,"ParentProcessId")),argv:function(a){let b=[],c=a??"",d=0,e=()=>{for(;d<c.length&&(" "===c[d]||" "===c[d]);)d+=1};if(e(),d>=c.length)return b;let f="";if('"'===c[d]){for(d+=1;d<c.length&&'"'!==c[d];)f+=c[d],d+=1;d<c.length&&(d+=1)}else for(;d<c.length&&" "!==c[d]&&" "!==c[d];)f+=c[d],d+=1;for(b.push(f);e(),!(d>=c.length);){let a="",e=!1;for(;d<c.length;){if("\\"===c[d]){let b=0;for(;d<c.length&&"\\"===c[d];)b+=1,d+=1;if('"'===c[d]){if(a+="\\".repeat(b>>1),b%2==1){a+='"',d+=1;continue}}else{a+="\\".repeat(b);continue}}if('"'===c[d]){d+=1,e&&'"'===c[d]?(a+='"',d+=1):e=!e;continue}if(!e&&(" "===c[d]||" "===c[d]))break;a+=c[d],d+=1}b.push(a)}return b}(g(a,"CommandLine")??""),created:function(a){let b=H(a);return null!==b&&b>BigInt(0)?b:null}(g(a,"Created")),workingSetBytes:Math.max(0,G(g(a,"WorkingSetSize"))??0),cpuMs:function(a,b){let c=H(a),d=H(b);if(null===c&&null===d)return null;let e=((c??BigInt(0))+(d??BigInt(0)))/J;return e>BigInt(Number.MAX_SAFE_INTEGER)?null:Number(e)}(g(a,"UserModeTime"),g(a,"KernelModeTime"))})}return{rows:b,ppids:function(a){let b=new Map;for(let[c,d]of a){let e=d.rawPpid;if(null===e||e<=0||e===c)continue;let f=a.get(e);f&&(null!==f.created&&null!==d.created&&f.created>d.created||b.set(c,e))}return b}(b)}}((a=(0,r.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from("$ErrorActionPreference='SilentlyContinue'\n[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false\nGet-CimInstance Win32_Process |\n Select-Object ProcessId,ParentProcessId,CommandLine,WorkingSetSize,UserModeTime,KernelModeTime,\n @{n='Created';e={if ($_.CreationDate) { $_.CreationDate.ToFileTimeUtc() }}} |\n ConvertTo-Csv -NoTypeInformation","utf16le").toString("base64")],{encoding:"utf8",maxBuffer:0x2000000,timeout:15e3,windowsHide:!0})).error||"string"!=typeof a.stdout?"":a.stdout),cwds:new Map}}function M(a){let b=L(),e=b.cwds.get(a);if(void 0!==e)return e;let f=function(a){if(!Number.isInteger(a)||a<=0)return null;let b=function(){if(void 0!==d)return d;if("win32"!==process.platform)return d=null;try{let a=c(85786),{i32:b,u32:e,u64:f,ptr:g}=a.FFIType,h=a.dlopen("kernel32.dll",{OpenProcess:{args:[e,b,e],returns:f},CloseHandle:{args:[f],returns:b},ReadProcessMemory:{args:[f,f,g,f,g],returns:b},IsWow64Process:{args:[f,g],returns:b}}),i=a.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[f,b,g,e,g],returns:b}}),j=new Map,k=a=>{let b=j.get(a);if(void 0!==b)return b;for(let b of[1040,4112]){let c=BigInt(h.symbols.OpenProcess(b,0,a));if(c!==D)return j.set(a,c),c}return null},l=(b,c,d)=>{let e=Buffer.alloc(8),f=h.symbols.ReadProcessMemory(b,c,a.ptr(d),BigInt(d.byteLength),a.ptr(e));return 0!==f&&e.readBigUInt64LE(0)===BigInt(d.byteLength)};d={parametersAddress(b){let c=k(b);if(null===c)return null;let d=Buffer.alloc(4);if(0!==h.symbols.IsWow64Process(c,a.ptr(d))&&0!==d.readInt32LE(0))return null;let e=Buffer.alloc(48),f=Buffer.alloc(8),g=i.symbols.NtQueryInformationProcess(c,0,a.ptr(e),48,a.ptr(f));if(0!==g)return null;let j=e.readBigUInt64LE(8);if(j===BigInt(0))return null;let m=Buffer.alloc(8);if(!l(c,j+BigInt(32),m))return null;let n=m.readBigUInt64LE(0);return n===BigInt(0)?null:n},read(a,b,c){let d=k(a);if(null===d||c<=0)return null;let e=Buffer.alloc(c);return l(d,b,e)?e:null},close(a){let b=j.get(a);if(void 0!==b){j.delete(a);try{h.symbols.CloseHandle(b)}catch{}}}}}catch{d=null}return d}();if(!b)return null;try{let c=b.parametersAddress(a);if(null===c)return null;let d=b.read(a,c,80);if(!d)return null;return function(a,b){if(a.byteLength<80)return null;let c=a.readUInt16LE(56),d=a.readBigUInt64LE(64);if(0===c||c%2!=0||c>32766||d===BigInt(0))return null;let e=b(d,c);if(!e||e.byteLength<c)return null;let f=e.subarray(0,c).toString("utf16le");return 0===f.length?null:f}(d,(c,d)=>b.read(a,c,d))}catch{return null}finally{b.close(a)}}(a),g=null===f?null:function(a){let b=a.replace(/\0[\s\S]*$/,"").trim();if(!b)return null;if(/^[A-Za-z]:[\\/]$/.test(b))return b[0].toUpperCase()+":\\";let c=b.replace(/[\\/]+$/,"");return c?/^[a-z]:/.test(c)?c[0].toUpperCase()+c.slice(1):c:null}(f);return b.cwds.set(a,g),g}let N={name:"windows",pidAlive:function(a){if(!Number.isInteger(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}},readArgv:function(a){return L().data.rows.get(a)?.argv??[]},readCwd:function(a){return M(a)},readPpid:function(a){return L().data.ppids.get(a)??null},processIdentity:function(a){var b=a;if(!Number.isInteger(b)||b<=0)return null;let d=function(){if(void 0!==e)return e;if("win32"!==process.platform)return e=null;try{let a=c(85786),{i32:b,u32:d,u64:f,ptr:g}=a.FFIType,h=a.dlopen("kernel32.dll",{OpenProcess:{args:[d,b,d],returns:f},CloseHandle:{args:[f],returns:b},GetProcessTimes:{args:[f,g,g,g,g],returns:b},GetExitCodeProcess:{args:[f,g],returns:b}});e=(b,c)=>{let d=BigInt(h.symbols.OpenProcess(4096,0,b));if(d===F)return!1;let e=[Buffer.alloc(8),Buffer.alloc(8),Buffer.alloc(8)];try{let b=Buffer.alloc(4);if(0!==h.symbols.GetExitCodeProcess(d,a.ptr(b))&&259!==b.readUInt32LE(0))return!1;return 0!==h.symbols.GetProcessTimes(d,a.ptr(c),a.ptr(e[0]),a.ptr(e[1]),a.ptr(e[2]))}finally{h.symbols.CloseHandle(d)}}}catch{e=null}return e}();if(!d)return null;let f=Buffer.alloc(8);try{var g=d(b,f);if(!Number.isInteger(b)||b<=0||!g||f.byteLength<8)return null;let a=f.readBigUInt64LE(0);return a<E?null:`${b}:${a}`}catch{return null}},processCpuMs:function(a){return L().data.rows.get(a)?.cpuMs??null},readEnvVar:function(){return null},listProcesses:function(){var a=L().data;let b=[];for(let[c,d]of a.rows)b.push({pid:c,argv:d.argv,cwd:!function(a){for(let b of a.slice(0,2)){let a=b.split(/[\\/]/).pop()?.toLowerCase()??"";if("claude"===a||"claude.exe"===a||"codex"===a||"codex.exe"===a)return!0}return!1}(d.argv)?null:M(c),tty:1});return b},systemMemory:function(){let a=t().totalmem();return a?{ramTotal:a,ramAvailable:Math.min(t().freemem(),a),swapTotal:0,swapUsed:0}:null},processMemory:function(a){let b=L().data.rows,c=new Map;for(let d of a){if(!Number.isInteger(d)||d<=0)continue;let a=b.get(d);a&&c.set(d,{rssBytes:a.workingSetBytes,swapBytes:0})}return c},ppidMap:function(){return new Map(L().data.ppids)},scanFdTargetsUnder:function(){},scanFdTargetsFor:function(){},pidWritesPath:function(){return!1},pidHoldsPath:function(){return!1}},O=function(a=process.platform,b=process.env.VIEWER_PROC_BACKEND){return"portable"===b?C:"linux"===b?q:"windows"===b?N:"linux"===a?q:"win32"===a?N:C}()},61532:(a,b,c)=>{c.d(b,{Qu:()=>j,lk:()=>g,vE:()=>h,xE:()=>i,xl:()=>k});let d=process;function e(){return{state:"pending",phase:"waiting for structured startup",completedHosts:0,totalHosts:null,updatedAt:new Date().toISOString()}}function f(a,b){if(!Number.isSafeInteger(b.completedHosts)||b.completedHosts<0)throw Error("structured host startup completed count is invalid");if(null!==b.totalHosts&&(!Number.isSafeInteger(b.totalHosts)||b.totalHosts<b.completedHosts))throw Error("structured host startup total count is invalid");let c=d.__llvStructuredHostStartupProgress,e=new Date().toISOString(),f=c?.phase!==b.phase||c.state!==a;f&&console.error("[structured hosts] startup progress",{pid:process.pid,phase:b.phase,state:a,previousPhase:c?.phase??null,previousPhaseMs:c?.phaseStartedAt?Math.max(0,Date.now()-Date.parse(c.phaseStartedAt)):null}),d.__llvStructuredHostStartupProgress={...b,state:a,updatedAt:e,phaseStartedAt:f?e:c?.phaseStartedAt??e,pid:process.pid}}function g(a){f(!0===d.__llvStructuredHostStartupFailed?"failed":"pending",a)}function h(){d.__llvStructuredHostStartupFailed=!0,f("failed",d.__llvStructuredHostStartupProgress??e())}function i(){d.__llvStructuredHostStartupFailed=!1,f("ready",{...d.__llvStructuredHostStartupProgress??e(),phase:"ready"})}function j(){d.__llvStructuredDeliveryControllerReady=!0}function k(){d.__llvStructuredDeliveryControllerReady=!1}},76190:(a,b,c)=>{c.d(b,{N:()=>d});function d(a=process.env){return"1"===a.LLV_WAKATIME_ENABLED}},76385:(a,b,c)=>{let d;c.d(b,{$k:()=>m,O1:()=>o,Ue:()=>l,gI:()=>n,h_:()=>i,y6:()=>k});var e=c(31421),f=c(73024),g=c.n(f),h=c(55686);function i(){if(void 0!==d)return d;if("linux"===process.platform){try{let a=g().readFileSync("/proc/sys/kernel/random/boot_id","utf8").trim(),b=g().readlinkSync("/proc/self/ns/pid");d=a&&b?`linux:${a}:pidns:${b}`:null}catch{d=null}return d}if("darwin"===process.platform){let a=(0,e.spawnSync)("sysctl",["-n","kern.boottime"],{encoding:"utf8",timeout:2e3}),b="string"==typeof a.stdout?/sec\s*=\s*(\d+)\s*,\s*usec\s*=\s*(\d+)/.exec(a.stdout):null;return d=b?`darwin:${b[1]}:${b[2]}`:null}return d="win32"===process.platform?"windows:absolute-process-creation-filetime":null}let j={pidAlive:a=>h.B.pidAlive(a),processIdentity:a=>h.B.processIdentity(a),bootEpoch:i};function k(a,b=j,c){return{pid:a,startIdentity:void 0===c?b.processIdentity(a):c,bootEpoch:b.bootEpoch()}}function l(a,b=j){if(!Number.isSafeInteger(a.pid)||a.pid<=0||!b.pidAlive(a.pid))return"dead";let c=b.processIdentity(a.pid);if(null===a.startIdentity||null===c)return"unverified";if(c!==a.startIdentity)return"dead";let d=b.bootEpoch();return"string"==typeof a.bootEpoch&&a.bootEpoch&&null!==d?d===a.bootEpoch?"alive":"dead":"unverified"}function m(a,b=j){return"dead"!==l(a,b)}function n(a,b=j){return"dead"===l(a,b)}function o(a,b){return a.pid===b.pid&&a.startIdentity===b.startIdentity&&(void 0===b.bootEpoch||a.bootEpoch===b.bootEpoch)}},89204:(a,b,c)=>{c.d(b,{Ol:()=>t,Qm:()=>l,aO:()=>n,pM:()=>u});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(55686);let k=new Int32Array(new SharedArrayBuffer(4));class l extends Error{constructor(a){super(a),this.name="FileTransactionBusyError"}}class m extends l{constructor(a,b){super(a),this.retryable=!0,this.name="StoreBusyBeforeAdmissionError",b&&"cause"in b&&(this.cause=b.cause)}}async function n(a){let b=!1;try{return await a(()=>{b=!0})}catch(a){if(!b&&a instanceof l&&!(a instanceof m))throw new m(a.message,{cause:a});throw a}}function o(a){try{let b=JSON.parse(g().readFileSync(a,"utf8"));if("number"==typeof b.pid&&Number.isInteger(b.pid)&&b.pid>0){let a="string"==typeof b.startIdentity?b.startIdentity:null;if(!j.B.pidAlive(b.pid))return!0;if(null!==a){let c=j.B.processIdentity(b.pid);return null!==c&&c!==a}return!1}return Date.now()-g().statSync(a).mtimeMs>3e4}catch{try{return Date.now()-g().statSync(a).mtimeMs>3e4}catch{return!1}}}function p(a,b){try{JSON.parse(g().readFileSync(a,"utf8")).token===b&&g().rmSync(a,{force:!0})}catch{}}function q(a){let b=`${a}.write-lock`,c=`${a}.write-locks`;g().mkdirSync(c,{recursive:!0,mode:448});let d={pid:process.pid,startIdentity:j.B.processIdentity(process.pid),token:e().randomUUID()},f=i().join(c,`${String(Date.now()).padStart(16,"0")}-${process.pid}-${e().randomUUID()}.json`);return g().writeFileSync(f,JSON.stringify(d),{encoding:"utf8",flag:"wx",mode:384}),{lockPath:b,queuePath:c,owner:d,ticketPath:f}}function r(a){let b;if(function(a){let b=[];for(let c of g().readdirSync(a.queuePath).filter(a=>a.endsWith(".json")).sort()){let d=i().join(a.queuePath,c);if(o(d)){g().rmSync(d,{force:!0});continue}g().existsSync(d)&&b.push(d)}return b[0]??null}(a)!==a.ticketPath)return null;try{b=g().openSync(a.lockPath,"wx",384)}catch(b){if("EEXIST"!==b.code)throw b;return o(a.lockPath)&&g().rmSync(a.lockPath,{force:!0}),null}try{return g().writeFileSync(b,JSON.stringify(a.owner),"utf8"),g().fsyncSync(b),b}catch(c){throw g().closeSync(b),g().rmSync(a.lockPath,{force:!0}),c}}function s(a,b){g().closeSync(b),p(a.lockPath,a.owner.token)}function t(a,b,c){let d=q(a);try{for(let a=0;a<6e3;a+=1){let a=r(d);if(null===a){Atomics.wait(k,0,0,5);continue}try{return c()}finally{s(d,a)}}throw new l(b)}finally{p(d.ticketPath,d.owner.token)}}async function u(a,b,c){let d=q(a);try{for(let a=0;a<6e3;a+=1){let a=r(d);if(null===a){await new Promise(a=>setTimeout(a,5));continue}try{return await c()}finally{s(d,a)}}throw new l(b)}finally{p(d.ticketPath,d.owner.token)}}},93994:(a,b,c)=>{c.d(b,{Hr:()=>h,o7:()=>j,sS:()=>l});var d=c(77030),e=c.n(d),f=c(16196);let g=[];class h extends Error{constructor(a,b){super(a),this.code=b}}let i=new Set(["runtime host request timed out","runtime host is unavailable","runtime host response exceeds limit","runtime host returned invalid JSON","runtime host response id mismatch"]);function j(a){return a instanceof h&&void 0===a.code&&i.has(a.message)}class k{constructor(a,b=3e3,c=12e4,d=1e4){this.socketPath=a,this.timeoutMs=b,this.deploymentTimeoutMs=c,this.snapshotTimeoutMs=d}nativeQueueRead(a){return this.call("native-queue-read",{conversationId:a})}nativeQueueTransition(a,b){return this.call("native-queue-transition",{operationId:a,transition:b})}nativeQueueSettleCompacted(a){return this.call("native-queue-settle-compacted",{...a})}snapshot(a,b){return this.call("snapshot",b,this.snapshotTimeoutMs,a)}events(a,b){return this.call("events",{after:a},this.timeoutMs,b)}waitEvents(a,b=15e3,c){return this.call("wait",{after:a,timeoutMs:b},b+1e3,c)}append(a){return this.call("append",{event:a})}operation(a){return this.call("operation",{event:a})}command(a){return this.call("command",{command:a})}operationStatus(a,b={}){return this.call("operation-status",{operationId:a,...b.currentRetryLeaf?{currentRetryLeaf:!0}:{}})}claimDeliveryAction(a,b){return this.call("operation-delivery-action",{operationId:a,action:b})}retryOperation(a,b,c={}){return this.call("operation-retry",{operationId:a,...void 0!==b?{nextIdempotencyKey:b}:{},...void 0!==c.requireHostedConversationId?{requireHostedConversationId:c.requireHostedConversationId}:{}})}producerCursor(a,b){return this.call("producer-cursor",{producerKind:a,eventKeyPrefix:b})}effectBatch(a,b=0){let c={...a?{kinds:[...a]}:{},...0!==b?{afterEventSeq:b}:{}};return this.call("effect-batch",Object.keys(c).length>0?c:void 0)}transitionOperation(a,b,c,d={}){return this.call("operation-transition",{operationId:a,status:b,...c?{details:c}:{},...d.fromStatuses?{fromStatuses:[...d.fromStatuses]}:{},...d.awaitProjection?{awaitProjection:!0}:{}})}acknowledgeTerminalProjection(a){return this.call("operation-projection-ack",{operationIds:[...a]})}requestViewerDeployment(a){return this.call("viewer-deployment-request",a,this.deploymentTimeoutMs)}cancelViewerDeployment(a){return this.call("viewer-deployment-cancel",{deploymentId:a})}readViewerDeployment(a){return this.call("viewer-deployment-read",{deploymentId:a})}admitMcpHealthProbe(a){return this.call("mcp-health-probe-admission",{capability:a})}call(a,b,c=this.timeoutMs,d){return new Promise((f,i)=>{let j={id:crypto.randomUUID(),method:a,...b?{params:b}:{}},k=e().createConnection(this.socketPath),l=performance.now(),m="",n=!1,o=setTimeout(()=>{let b=performance.now()-l;console.error(`[runtime host] request timed out method=${a} elapsedMs=${Math.max(0,Math.round(b))}`),p(new h("runtime host request timed out"),void 0,!0,b)},c),p=(b,c,e=!1,h=performance.now()-l)=>{!n&&(n=!0,clearTimeout(o),d?.removeEventListener("abort",q),k.destroy(),"wait"!==a&&(g.push({elapsedMs:Math.max(0,Math.round(h)),timeout:e}),g.length>256&&g.splice(0,g.length-256)),b?i(b):f(c))},q=()=>p(new h("runtime host request cancelled"));if(d?.aborted)return q();d?.addEventListener("abort",q,{once:!0}),k.once("error",()=>p(new h("runtime host is unavailable"))),k.on("data",a=>{if(m+=String(a),Buffer.byteLength(m)>0x4000000)return p(new h("runtime host response exceeds limit"));let b=m.indexOf("\n");if(!(b<0))try{let a=JSON.parse(m.slice(0,b));if(a.id!==j.id)return p(new h("runtime host response id mismatch"));p(a.ok?void 0:new h(a.error??"runtime host rejected request",a.code),a.result)}catch{p(new h("runtime host returned invalid JSON"))}}),k.once("connect",()=>k.write(JSON.stringify(j)+"\n"))})}}function l(a=process.env){let b=(0,f.S0)(a);return b?new k(b):null}},94972:(a,b,c)=>{c.r(b),c.d(b,{accountControllerDelayMs:()=>y,activateViewerRuntimeWhenCurrent:()=>x,checkpointHotStateRollbackMirrorsForDemotion:()=>B,classifyStructuredHostStartupError:()=>L,completeViewerReleaseDemotion:()=>A,completeViewerRuntimeActivation:()=>N,establishHotStateCutoverBoundary:()=>w,initializeHotStateStoresAtStartup:()=>C,initializeOperatorSpawnCapabilityAtStartup:()=>E,registerViewerRuntime:()=>O,runIdentityWaveMigrationWithoutBlockingStartup:()=>G,runStructuredHostStartup:()=>M,scheduleAccountMigrationController:()=>z,startCurrentReleaseControllers:()=>D,startWakatimeIntegrationIfEnabled:()=>F,viewerReleaseBoundary:()=>u,viewerReleaseOwnsTraffic:()=>t});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(93994),l=c(16196),m=c(95697),n=c(14928),o=c(61532),p=c(21420),q=c(65281),r=c(76190);let s=globalThis;function t(a=process.env,b=()=>g().readFileSync((0,j.BQ)("viewer-release.json"),"utf8")){let c,d=a.PORT?.trim();if(!d)return!0;try{c=b()}catch(a){return"ENOENT"===a.code}try{let a=JSON.parse(c);if("string"!=typeof a.endpoint)return!1;return new URL(a.endpoint).port===d}catch{return!1}}function u(a=()=>g().readFileSync((0,j.BQ)("viewer-release.json"),"utf8")){let b;try{b=a()}catch{return`viewer-release:pid-${process.pid}`}let c=e().createHash("sha256").update(b).digest("hex").slice(0,16);return`viewer-release:${c}`}function v(){return["flows.json","pipelines.json","pipelines-archive.json","workflows.json"].map(a=>{let b=(0,j.BQ)(a);try{let c=g().statSync(b,{bigint:!0});return`${a}:${c.mtimeNs}:${c.size}`}catch{return`${a}:missing`}}).join("|")}async function w(a,b={}){let d=i().dirname((0,j.BQ)("state.sqlite")),e=(0,m.jU)(d);if((null!==e||g().existsSync((0,j.BQ)("viewer-release.json")))&&null===e)throw Error("viewer release cannot publish hot-state authority");if(null===e)return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:null,reimportLegacy:!1};let f=(0,m.a5)(d);if(f?.mode==="sqlite"&&f.releaseRevision!==e)return f=(0,m.RG)(d,"sqlite",e),(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};if(f?.mode==="sqlite"&&f.releaseRevision===e)return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};if(f?.mode==="fencing")throw Error("hot-state cutover cannot replace an active rollback fence");(f?.mode!=="preparing"||f.releaseRevision!==e)&&(f=(0,m.RG)(d,"preparing",e));let{hotStateMigrationApplied:h,hotStateMigrationDryRun:k}=await Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8817),c.e(6796),c.e(5682)]).then(c.bind(c,25682));if(h())return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};let l=b.pollMs??250,o=b.stablePolls??3,p=b.maxPolls??12,q=b.schedule??((a,b)=>setTimeout(a,b)),r=b.legacySignature??v,s=r(),t=0;for(let b=0;b<p;b+=1){if(await new Promise(a=>q(a,l).unref?.()),!a())throw Error("viewer release lost traffic during hot-state cutover");let b=r();if(t=b===s?t+1:0,s=b,t>=o)return k(),(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!0}}throw Error("legacy hot-state files did not quiesce during release cutover")}async function x(a,b,c={}){let d=c.pollMs??250,e=c.schedule??((a,b)=>setTimeout(a,b)),f=c.log??console.error,g=!1,h=!1,i=!1,j=null,k=()=>{if(h)return;if(g&&!b()){h=!0,Promise.resolve(c.onDemoted?.({fenced:null!==j})).catch(a=>{f("[viewer release] demotion checkpoint failed",a)});return}let a=g?c.fenceRequest?.()??null:null;a&&"fencing"===a.mode?j===a.epoch||i||(i=!0,Promise.resolve(c.onFenceRequested?.(a)).then(()=>{j=a.epoch}).catch(a=>{f("[viewer release] hot-state fence checkpoint failed",a)}).finally(()=>{i=!1})):i||(j=null),e(k,d).unref?.()},l=async()=>{g||(g=!0,e(k,d).unref?.(),await a())};if(b())return void await l();let m=()=>{if(!g){if(!b())return void e(m,d).unref?.();l().catch(a=>f("[viewer release] deferred runtime activation failed",a))}};e(m,d).unref?.()}function y(a=process.env){let b=Number(a.LLV_ACCOUNT_CONTROLLER_DELAY_MS??0);return Number.isFinite(b)?Math.max(0,b):0}function z(a,b){let c=()=>{a().catch(a=>{console.error("[account migration controller] initial durable reconciliation failed",a)})},d=setTimeout(()=>{b>0?c():setTimeout(c,0).unref?.()},b);d.unref?.()}async function A(a,b=a=>process.exit(a),d=console.error,e=async()=>{let{releaseStructuredDeliveryHostsForDemotion:a}=await Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(6277)]).then(c.bind(c,2749));await a()}){let f=null;try{await e()}catch(a){f=a}try{await a()}catch(a){f??=a}if(f){d("[viewer release] demotion cleanup failed",f),b(1);return}b(0)}async function B(){let[a,b,d]=await Promise.all([Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8817)]).then(c.bind(c,98817)),Promise.all([c.e(8027),c.e(1888)]).then(c.bind(c,18027)),Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8817),c.e(6796)]).then(c.bind(c,96796))]),e=await a.checkpointFlowRollbackMirrorForDemotionAsync(),f=await b.checkpointPipelineRollbackMirrorsForDemotionAsync(),g=await d.checkpointWorkflowRollbackMirrorForDemotionAsync();return{flows:e,pipelines:f.pipelines,pipelinesArchive:f.pipelinesArchive,workflows:g}}async function C(a={authority:null,reimportLegacy:!1},b={}){let[d,e,f]=await Promise.all([Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8817)]).then(c.bind(c,98817)),Promise.all([c.e(8027),c.e(1888)]).then(c.bind(c,18027)),Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8817),c.e(6796)]).then(c.bind(c,96796))]);return((0,n.t0)((0,j.BQ)("state.sqlite"),[d.flowStateCollectionSeed(),...e.pipelineStateCollectionSeeds(),f.workflowStateCollectionSeed()],{reimportExisting:a.reimportLegacy,...b.afterCollectionImport?{afterCollectionImport:b.afterCollectionImport}:{}}),d.loadFlows(),e.loadPipelines(),e.loadArchivedPipelines(),f.loadWorkflows(),a.authority?.mode==="preparing")?(0,m.H0)(i().dirname((0,j.BQ)("state.sqlite")),a.authority):a.authority}async function D(a=process.env,b={loadFlowPipelineController:()=>Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(8444),c.e(9298)]).then(c.bind(c,60156)),loadAccountMigrationController:()=>Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(8444),c.e(3570)]).then(c.bind(c,37868)),loadTelegramReportScheduler:()=>Promise.all([c.e(1952),c.e(9777),c.e(2549),c.e(773),c.e(3830)]).then(c.bind(c,83830)),loadTelegramConnectorBoot:()=>Promise.all([c.e(9777),c.e(773),c.e(5545)]).then(c.bind(c,95545)),loadStructuredHostRetirement:()=>Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(9307),c.e(9296)]).then(c.bind(c,50261)),loadSeatTick:()=>Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(9307),c.e(8444),c.e(606)]).then(c.bind(c,56592))}){let{startFlowPipelineController:d}=await b.loadFlowPipelineController();d();try{let a=await b.loadTelegramConnectorBoot?.();a&&a.provisionTelegramConnectorAtStartup().catch(a=>console.error("[telegram connector] boot provisioning failed",a instanceof Error?a.name:"unknown"))}catch(a){console.error("[telegram connector] boot provisioning unavailable",a instanceof Error?a.name:"unknown")}try{let a=await b.loadTelegramReportScheduler?.();a?.ensureTelegramReportScheduler()}catch(a){console.error("[telegram report] scheduler start failed",a instanceof Error?a.name:"unknown")}try{let a=await b.loadStructuredHostRetirement?.();a?.startStructuredHostRetirement()}catch(a){console.error("[host retirement] sweep start failed",a instanceof Error?a.name:"unknown")}try{let a=await b.loadSeatTick?.();a?.startSeatTick()}catch(a){console.error("[seat tick] start failed",a instanceof Error?a.name:"unknown")}if("1"===a.LLV_ACCOUNT_CONTROLLER_DISABLED)return;let{startAccountMigrationController:e}=await b.loadAccountMigrationController();z(e,y(a))}async function E(a=process.env,b=a=>console.error(a)){let{ensureOperatorSpawnCapability:d,rotateOperatorSpawnCapability:e}=await c.e(4260).then(c.bind(c,74260));"1"===a.LLV_ROTATE_OPERATOR_SPAWN_CAPABILITY?e():d();let f=a.PORT?.trim()||"8898";b(`[viewer] Open http://127.0.0.1:${f}.`)}async function F(a=process.env,b=H,c=(a,b)=>console.error(a,b)){if((0,r.N)(a))try{await b()}catch{c("[wakatime] startup_failed",{})}}function G(a,b=console.error,c={}){let d=Math.max(1,Math.floor(c.maxAttempts??3)),e=Math.max(0,c.initialRetryMs??5e3),f=c.schedule??((a,b)=>setTimeout(a,b)),g=0,h=()=>{g+=1;try{a()}catch(c){if(g>=d)return void b("[identity-wave] registry migration failed; retry limit reached",{attempt:g,error:c});let a=e*2**(g-1);b("[identity-wave] registry migration failed; retry scheduled",{attempt:g,retryInMs:a,error:c}),f(h,a).unref?.()}};h()}async function H(){if(s.__llvWakatimeWorker)return;let a=process.cwd(),b=i().join(a,"src/lib/wakatimeSync.worker.ts"),d=i().join(a,".next/server/wakatime-sync-worker.js"),e="/usr/local/bin/bun-container",f=g().existsSync(b)&&g().existsSync(e)?{executable:e,workerPath:b}:g().existsSync(d)?{executable:process.versions.bun?process.execPath:process.env.LLV_BUN_EXECUTABLE||"bun",workerPath:d}:{executable:process.execPath,workerPath:b},{spawn:h}=await Promise.resolve().then(c.t.bind(c,31421,23)),j=g().existsSync("/usr/bin/nice"),k=h(j?"/usr/bin/nice":f.executable,[...j?["-n","10",f.executable]:[],f.workerPath],{cwd:a,stdio:["ignore","inherit","inherit"],env:{...(0,q.Fd)(process.env),LLV_WAKATIME_SYNC_WORKER:"1"}});s.__llvWakatimeWorker=k,k.once("error",a=>{console.error("[wakatime] worker_start_failed",{message:a.message})}),k.once("exit",(a,b)=>{if(s.__llvWakatimeWorker===k&&(s.__llvWakatimeWorker=void 0),s.__llvWakatimeWorkerRestart)return;console.error("[wakatime] worker_exited",{code:a,signal:b});let c=setTimeout(()=>{s.__llvWakatimeWorkerRestart=void 0,H()},1e3);c.unref?.(),s.__llvWakatimeWorkerRestart=c})}let I=new Set(["EAGAIN","EBUSY","ECONNREFUSED","ECONNRESET","EINTR","EIO","EMFILE","ENFILE","ENOENT"]),J=new Set(["SQLITE_CORRUPT","SQLITE_NOTADB"]);function K(a,b){if("object"!=typeof a||null===a||!(b in a))return"";let c=a[b];return"string"==typeof c?c:""}function L(a){let b=K(a,"name"),c=K(a,"code"),d=K(a,"message");return a instanceof p.bL||"StructuredRuntimeRequirementError"===b?{disposition:"terminal",category:"configuration",action:"Correct the structured-host configuration and restart the Viewer."}:"RegistryParityError"===b||"RegistryBackendIdentityError"===b||J.has(c)||/corrupt .* SQLite row|SQLite row is malformed|schema is unsupported/i.test(d)?{disposition:"terminal",category:"data-corruption",action:"Repair or restore the reported state data, then restart the Viewer."}:"structured-delivery-controller-unavailable"===c?{disposition:"recoverable",category:"instrumentation-order",action:"Retry after the process controller publication becomes visible."}:"ETIMEDOUT"===c||/\btimed out\b/i.test(d)?{disposition:"recoverable",category:"timeout",action:"Retry after the dependency response window."}:"FileTransactionBusyError"===b?{disposition:"recoverable",category:"registry-contention",action:"Retry after the active registry transaction releases its lock."}:I.has(c)?{disposition:"recoverable",category:"transient-io",action:"Retry after the local I/O dependency recovers."}:a instanceof k.Hr||/^runtime host (?:is unavailable|request cancelled|response exceeds limit|returned invalid JSON|response id mismatch)$/i.test(d)?{disposition:"recoverable",category:"runtime-host-unavailable",action:"Retry after the runtime host becomes available."}:{disposition:"recoverable",category:"unknown-recoverable",action:"Retry with bounded backoff while the Viewer remains unavailable for structured delivery."}}async function M(a,b=console.error,c={}){let d=c.schedule??((a,b)=>setTimeout(a,b)),e=c.maxRetryMs??1e3,f=Math.min(Math.max(c.jitterRatio??.2,0),1),g=c.random??Math.random,h=c.initialRetryMs??100,i=!1,j=0,k=null,l=null,m=c.waitUntilReady?new Promise((a,b)=>{k=a,l=b}):null,n=async()=>{j+=1;try{c.signal?.throwIfAborted(),await a(),c.signal?.throwIfAborted(),(0,o.xE)(),k?.(),j>1&&b("[structured hosts] startup adoption recovered",{attempts:j})}catch(p){if((0,o.vE)(),c.signal?.aborted)throw l?.(p),p;let a=L(p);if("terminal"===a.disposition)throw b("[structured hosts] startup adoption failed",p,{category:a.category,action:a.action}),l?.(p),p;if(i)return;let k=1+(2*Math.min(Math.max(g(),0),1)-1)*f,m=Math.min(e,Math.max(0,Math.round(h*k)));h=Math.min(2*h,e),i=!0,1===j&&b("[structured hosts] startup adoption failed; retry scheduled",p),d(()=>{i=!1,n().catch(a=>{b("[structured hosts] startup adoption retry aborted",a)})},m).unref?.()}},p=()=>{(0,o.vE)(),i&&l?.(c.signal?.reason)};if(c.signal?.addEventListener("abort",p,{once:!0}),m){try{await Promise.all([n(),m])}finally{c.signal?.removeEventListener("abort",p)}return}await n()}async function N(a){await a.initializeOperatorCapability(),await a.runIdentityMigration?.(),await a.startWakatime(),a.publishHotStateActivation(),a.startStructuredHosts?.(),await a.startControllers(),a.publishViewerReleaseReady()}async function O(){(0,q.kL)();let a=()=>t(),b=i().dirname((0,j.BQ)("state.sqlite")),d=null,e=new AbortController,f=null,g=async()=>{e.abort(Error("structured startup retired by release handover")),await f?.catch(()=>{})},h=()=>{a()&&(0,m.a5)(b)?.mode!=="fencing"||e.abort(Error("structured startup lost release authority")),e.signal.throwIfAborted()},k=async()=>{let{releaseStructuredHostsForViewerDemotion:a}=await Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(9307),c.e(644)]).then(c.bind(c,23886));await a({boundary:u()})};await x(async()=>{let g=await w(a);d=g.authority?.releaseRevision??null;let i=await C(g),j=null;await N({initializeOperatorCapability:E,runIdentityMigration:async()=>{let{runIdentityWaveMigrationAtStartup:a}=await Promise.all([c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(9307),c.e(2150)]).then(c.bind(c,22150));G(a)},startWakatime:F,startStructuredHosts:(0,l.cM)()?()=>{(f=(async()=>{let{adoptStructuredHostsAtStartup:a}=await Promise.all([c.e(7826),c.e(8027),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(9777),c.e(9360),c.e(9307),c.e(644)]).then(c.bind(c,23886));await M(()=>a({assertActive:h}),console.error,{waitUntilReady:!0,signal:e.signal})})()).catch(a=>console.error("[structured hosts] background startup aborted",a))}:null,startControllers:D,publishHotStateActivation:()=>{i&&(j=(0,m.tT)(b,i))},publishViewerReleaseReady:()=>{j&&(0,m.uB)(b,j)}})},a,{fenceRequest:()=>{let a=(0,m.jU)(b),c=(0,m.a5)(b);return null!==a&&c?.mode==="fencing"&&c.releaseRevision===a?c:null},onFenceRequested:async a=>{await g(),await k();let d=await B(),{agentRegistry:e}=await Promise.all([c.e(8027),c.e(160),c.e(1952)]).then(c.bind(c,70160));e().checkpointRollbackMirrorForDemotion(),(0,m.u_)(b,a,d)},onDemoted:async({fenced:a})=>{await g(),await A(async()=>{if(a)return;let e=(0,m.a5)(b);if(!d||e?.releaseRevision!==d||"sqlite"!==e.mode&&"fencing"!==e.mode)return;let{agentRegistry:f}=await Promise.all([c.e(8027),c.e(160),c.e(1952)]).then(c.bind(c,70160));await B(),f().checkpointRollbackMirrorForDemotion()},void 0,void 0,k)}})}},95697:(a,b,c)=>{c.d(b,{H0:()=>x,Ny:()=>r,RG:()=>v,T2:()=>s,X4:()=>p,a5:()=>o,jU:()=>q,tT:()=>y,uB:()=>z,u_:()=>w});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(89204),k=c(76385);let l="LLV_HOT_STATE_RELEASE_REVISION";function m(a){return i().join(a,"hot-state-authority.json")}function n(a){return"string"==typeof a&&/^[0-9a-f]{40}$/.test(a)}function o(a){try{var b;let c=!(b=JSON.parse(g().readFileSync(m(a),"utf8")))||"object"!=typeof b||Array.isArray(b)?null:1===b.schemaVersion&&Number.isInteger(b.epoch)&&!(b.epoch<1)&&["legacy","preparing","sqlite","fencing"].includes(String(b.mode))&&(null===b.releaseRevision||n(b.releaseRevision))&&"string"==typeof b.updatedAt&&(void 0===b.activationReadyAt||"string"==typeof b.activationReadyAt)&&(void 0===b.releaseReadyAt||"string"==typeof b.releaseReadyAt)&&(void 0===b.releaseReadyAt||void 0!==b.activationReadyAt)&&(void 0===b.activationOwner||b.activationOwner&&Number.isSafeInteger(b.activationOwner.pid)&&!(b.activationOwner.pid<=0)&&(null===b.activationOwner.startIdentity||"string"==typeof b.activationOwner.startIdentity)&&(void 0===b.activationOwner.bootEpoch||null===b.activationOwner.bootEpoch||"string"==typeof b.activationOwner.bootEpoch))&&(void 0===b.checkpoint||function(a){if(!a||"object"!=typeof a||Array.isArray(a))return!1;let b=a.revisions,c=b?[b.flows,b.pipelines,b.pipelinesArchive,b.workflows]:[];return"string"==typeof a.acknowledgedAt&&4===c.length&&c.every(a=>Number.isInteger(a)&&a>=0)}(b.checkpoint))?b:null;if(!c)throw Error("hot-state authority is invalid");return c}catch(a){if("ENOENT"===a.code)return null;throw a}}function p(a,b=process.env){let c=b.LLV_VIEWER_DEPLOY_TARGET?.trim()||i().join(a,"viewer-release.json");try{var d;let a=!(d=JSON.parse(g().readFileSync(c,"utf8")))||"object"!=typeof d||Array.isArray(d)?null:"string"==typeof d.endpoint&&n(d.revision)&&(void 0===d.hotStateBackend||"sqlite-v1"===d.hotStateBackend)?d:null;if(!a)throw Error("Viewer release target cannot authorize hot state");return a}catch(a){if("ENOENT"===a.code)return null;throw a}}function q(a,b=process.env){let c=p(a,b);if(!c)return null;let d=b[l]?.trim();if(d)return n(d)&&d===c.revision?d:null;let e=b.PORT?.trim();if(!e)return null;try{return new URL(c.endpoint).port===e?c.revision:null}catch{return null}}function r(a,b=process.env){let c=p(a,b);if(!c)return!0;let d=o(a),e=q(a,b);return e?d?.mode==="sqlite"&&d.releaseRevision===e&&c.revision===e:!(b[l]?.trim()||b.PORT?.trim())&&d?.mode==="sqlite"&&d.releaseRevision===c.revision&&"string"==typeof d.activationReadyAt}function s(a,b=process.env){let c=p(a,b);if(!c)return!0;let d=q(a,b);if(!d)return!1;let e=o(a);return e?.mode==="preparing"&&e.releaseRevision===d&&c.revision===d}function t(a,b){return null!==a&&JSON.stringify(a)===JSON.stringify(b)}function u(a,b,c,d,f={}){if(f.releaseReadyAt&&!f.activationReadyAt)throw Error("Viewer release readiness requires completed hot-state activation");let h={schemaVersion:1,epoch:f.epoch??(b?.epoch??0)+1,mode:c,releaseRevision:d,updatedAt:new Date().toISOString(),...f.activationReadyAt?{activationReadyAt:f.activationReadyAt}:{},...f.releaseReadyAt?{releaseReadyAt:f.releaseReadyAt}:{},...f.checkpoint?{checkpoint:f.checkpoint}:{},...f.activationOwner?{activationOwner:f.activationOwner}:"fencing"===c&&b?.releaseRevision===d&&b.activationOwner?{activationOwner:b.activationOwner}:{}};if(!Number.isInteger(h.epoch)||h.epoch<1)throw Error("hot-state authority epoch is invalid");if(b&&h.epoch<b.epoch)throw Error("hot-state authority epoch cannot regress");return!function(a,b){let c=i().dirname(a);g().mkdirSync(c,{recursive:!0,mode:448});let d=i().join(c,`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`),f=g().openSync(d,"wx",384);try{g().writeFileSync(f,`${JSON.stringify(b,null,2)}
|
|
155
|
+
`).run(this.options.collection,b,process.pid,j.B.processIdentity(process.pid),Date.now()),a.exec("COMMIT"),!0}catch(b){if(B(a),C(b))return!1;throw b}}acquireLeaseSync(){let a=w(this.filename),b=e().randomUUID();try{for(let c=0;c<6e3;c+=1){if(this.tryAcquireLease(a,b))return b;Atomics.wait(n,0,0,5)}throw new l.Qm(this.options.busyMessage)}finally{a.close()}}async acquireLease(a){let b=w(this.filename),c=e().randomUUID(),d=void 0===a?null:Date.now()+Math.max(0,a);try{for(let a=0;a<6e3;a+=1){if(this.tryAcquireLease(b,c))return c;if(null!==d&&Date.now()>=d)break;await new Promise(a=>setTimeout(a,5))}throw new l.Qm(this.options.busyMessage)}finally{b.close()}}releaseLeaseSync(a){let b=w(this.filename);try{for(let c=0;c<6e3;c+=1)try{b.exec("BEGIN IMMEDIATE"),b.query("DELETE FROM state_leases WHERE collection = ? AND owner_token = ?").run(this.options.collection,a),b.exec("COMMIT");return}catch(a){if(B(b),!C(a))throw a;Atomics.wait(n,0,0,5)}throw new l.Qm(this.options.busyMessage)}finally{b.close()}}async releaseLease(a){let b=w(this.filename);try{for(let c=0;c<6e3;c+=1)try{b.exec("BEGIN IMMEDIATE"),b.query("DELETE FROM state_leases WHERE collection = ? AND owner_token = ?").run(this.options.collection,a),b.exec("COMMIT");return}catch(a){if(B(b),!C(a))throw a;await new Promise(a=>setTimeout(a,5))}throw new l.Qm(this.options.busyMessage)}finally{b.close()}}}},16196:(a,b,c)=>{function d(a){return`${a} is unavailable; start agent-log-viewer through its CLI and check the CLI log for the host startup failure`}function e(a){if(void 0===a)return!1;switch(a.trim().replace(/^(["'])([\s\S]*)\1$/,"$2").trim().toLowerCase()){case"0":case"false":case"off":case"no":return!0;default:return!1}}function f(a=process.env){return!e(a.LLV_STRUCTURED_HOSTS)}function g(a=process.env){return e(a.LLV_RUNTIME_EVENTS)}function h(a=process.env){return!g(a)&&!!j(a)}function i(a=process.env){return!e(a.NEXT_PUBLIC_RUNTIME_UI)}function j(a=process.env){return a.LLV_RUNTIME_HOST_SOCKET?.trim()||null}c.d(b,{Ee:()=>i,S0:()=>j,Zn:()=>h,cM:()=>f,ji:()=>g,lN:()=>d})},21420:(a,b,c)=>{let d;c.d(b,{P3:()=>h,bL:()=>f,x_:()=>g});let e=BigInt(1e6);class f extends Error{constructor(...a){super(...a),this.name="StructuredRuntimeRequirementError"}}function g(a=process.platform,b=process.versions){if("darwin"===a&&!b.bun)throw new f("structured hosts on macOS require the Viewer server to run with Bun")}function h(a){if(!Number.isInteger(a)||a<=0)return null;let b=function(){if(void 0!==d)return d;if("darwin"!==process.platform)return d=null;try{let a=c(85786),b=a.dlopen("/usr/lib/libproc.dylib",{proc_pidinfo:{args:[a.FFIType.i32,a.FFIType.i32,a.FFIType.u64,a.FFIType.ptr,a.FFIType.i32],returns:a.FFIType.i32}});d=(c,d)=>Number(b.symbols.proc_pidinfo(c,3,BigInt(0),a.ptr(d),d.byteLength))}catch{d=null}return d}();if(!b)return null;let f=Buffer.alloc(136);try{var g=b(a,f);if(!Number.isInteger(a)||a<=0||g<136||f.byteLength<136||f.readUInt32LE(12)!==a)return null;let c=f.readBigUInt64LE(120),d=f.readBigUInt64LE(128);return c===BigInt(0)||d>=e?null:`${a}:${c}:${d.toString().padStart(6,"0")}`}catch{return null}}},27146:(a,b,c)=>{c.d(b,{ks:()=>n,oy:()=>t,Pn:()=>r,BQ:()=>s});var d=c(73024),e=c.n(d),f=c(48161),g=c.n(f),h=c(76760),i=c.n(h);function j(a=process.env){return"1"===a.LLV_STAGING}let k="agent-log-viewer",l="live-log-viewer";function m(){return process.env.XDG_CONFIG_HOME||i().join(g().homedir(),".config")}function n(a){var b=m(),c=a;let d=i().join(b,k,c);if(e().existsSync(d))return d;let f=i().join(b,l,c);return e().existsSync(f)?f:d}let o=new Set,p=".migrated-from-legacy";function q(a,b){if("1"===process.env.LLV_RESOURCE_OBSERVATION_WORKER||o.has(a))return;let c=i().join(a,p),d=()=>`${new Date().toISOString()} ${b}
|
|
156
|
+
`;try{if(e().existsSync(c))return void o.add(a);if(!e().existsSync(b)){e().mkdirSync(a,{recursive:!0}),e().writeFileSync(c,d()),o.add(a);return}if(!e().existsSync(a)){e().mkdirSync(i().dirname(a),{recursive:!0});let c=`${a}.migrating.${process.pid}`;e().rmSync(c,{recursive:!0,force:!0});try{e().cpSync(b,c,{recursive:!0}),e().writeFileSync(i().join(c,p),d()),e().renameSync(c,a)}catch(a){throw e().rmSync(c,{recursive:!0,force:!0}),a}o.add(a);return}e().cpSync(b,a,{recursive:!0,force:!1,errorOnExist:!1}),e().writeFileSync(c,d()),o.add(a)}catch(c){console.error(`viewer state migration ${b} -> ${a} failed; will retry:`,c)}}function r(){let a=process.env.LLV_STATE_DIR;if(j()){var b=a;let c=b||i().join(m(),k,"state-staging"),d=i().resolve(c);if([i().join(m(),k,"state"),i().join(m(),l,"state"),i().join(g().homedir(),".claude","viewer-state")].some(a=>i().resolve(a)===d))throw Error(`staging mode refuses the production state dir ${d}; set LLV_STATE_DIR to a staging-only dir`);return c}if(a)return a;let c=i().join(m(),k,"state");return q(c,i().join(g().homedir(),".claude","viewer-state")),c}function s(...a){return i().join(r(),...a)}function t(){if(j())return s("inbox");let a=i().join(m(),k,"inbox");return q(a,i().join(g().homedir(),".claude","viewer-inbox")),a}},34402:(a,b,c)=>{c.d(b,{PK:()=>k,h2:()=>h,mm:()=>g});var d=c(73024),e=c.n(d);class f extends Error{constructor(a){super(a),this.code="LLV_DATABASE_REPLACED",this.name="DatabaseReplacedError"}}function g(a){try{let b=e().statSync(a,{bigint:!0});return`${b.dev}:${b.ino}`}catch{return null}}function h(a){return`${a}.swapping`}function i(a,b=Date.now()){try{return b-e().statSync(h(a)).mtimeMs<6e5}catch{return!1}}let j=new Set(["exec","run","query","prepare","transaction","serialize","loadExtension","fileControl"]);function k(a,b,c={}){let d,e=()=>{for(let c=0;c<3;c+=1){if(i(a))throw new f(`${a} is being restored from a backup; try again`);let c=g(a),d=b(),e=g(a);if((null===c||c===e)&&!i(a))return{db:d,identity:e};d.close()}throw new f(`${a} kept changing while it was opened`)},h=e(),l=()=>!i(a)&&g(a)===h.identity;return d=new Proxy(h.db,{get(b,g){j.has(g)&&(b=>{let g=h.db;if(g.inTransaction){if(!b||l())return;try{g.exec("ROLLBACK")}catch{}throw new f(`${a} was replaced while this transaction was open; it was rolled back`)}if(l())return;let i=e();try{g.close()}catch{}h=i,c.reopened?.(d)})("exec"===g);let i=Reflect.get(h.db,g,h.db);return"function"==typeof i?i.bind(h.db):i},set:(a,b,c)=>Reflect.set(h.db,b,c,h.db)})}},55686:(a,b,c)=>{let d,e;c.d(b,{B:()=>O});var f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(1198);let k="/proc";function l(a){try{return g().readFileSync(i().join(k,String(a),"cmdline"),"utf8").split("\0").filter(Boolean)}catch{return[]}}function m(a){try{return g().readlinkSync(i().join(k,String(a),"cwd"))}catch{return null}}function n(a){let b;try{b=g().readFileSync(i().join(k,String(a),"stat"),"utf8")}catch{return null}return b.slice(b.lastIndexOf(")")+2).trim().split(/\s+/)}function o(a){try{return(128&g().lstatSync(a).mode)!=0}catch{return!1}}function p(a){let b;try{b=g().readdirSync(k,{withFileTypes:!0})}catch{return}for(let c of b){let b;if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let d=Number(c.name),e=i().join(k,c.name,"fd");try{b=g().readdirSync(e,{withFileTypes:!0})}catch{continue}for(let c of b){let b,f=i().join(e,c.name);try{b=g().readlinkSync(f)}catch{continue}a(b,d,()=>o(f))}}}let q={name:"linux",pidAlive:function(a){return Number.isInteger(a)&&a>0&&g().existsSync(i().join(k,String(a)))},readArgv:l,readCwd:m,readPpid:function(a){let b=n(a),c=b?Number(b[1]):NaN;return Number.isInteger(c)&&c>1?c:null},processIdentity:function(a){let b=n(a),c=b?.[19];return c?`${a}:${c}`:null},processCpuMs:function(a){let b=n(a),c=Number(b?.[11]),d=Number(b?.[12]);return Number.isFinite(c)&&Number.isFinite(d)?(c+d)/100*1e3:null},readEnvVar:function(a,b){let c;try{c=g().readFileSync(i().join(k,String(a),"environ"),"utf8")}catch{return null}let d=b+"=",e=null;for(let a of c.split("\0"))a.startsWith(d)&&(e=a.slice(d.length));return e},listProcesses:function(){let a,b=[];try{a=g().readdirSync(k,{withFileTypes:!0})}catch{return b}for(let c of a){if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let a=Number(c.name);b.push({pid:a,argv:l(a),cwd:m(a),tty:function(a){let b=n(a),c=b?Number(b[4]):NaN;return Number.isInteger(c)&&c>0?c:0}(a)})}return b},systemMemory:function(){try{return(0,j.NW)(g().readFileSync(i().join(k,"meminfo"),"utf8"))}catch{return null}},processMemory:function(a){let b=new Map;for(let c of a)if(Number.isInteger(c)&&!(c<=0))try{b.set(c,(0,j.sW)(g().readFileSync(i().join(k,String(c),"status"),"utf8")))}catch{}return b},ppidMap:function(){let a,b=new Map;try{a=g().readdirSync(k,{withFileTypes:!0})}catch{return b}for(let c of a){if(!c.isDirectory()||!/^\d+$/.test(c.name))continue;let a=Number(c.name),d=n(a),e=d?Number(d[1]):NaN;Number.isInteger(e)&&e>0&&b.set(a,e)}return b},scanFdTargetsUnder:function(a,b){p(b)},scanFdTargetsFor:function(a,b){p(b)},pidWritesPath:function(a,b){let c,d;try{c=g().realpathSync(b)}catch{c=null}let e=i().join(k,String(a),"fd");try{d=g().readdirSync(e,{withFileTypes:!0})}catch{return!1}for(let a of d){let d,f=i().join(e,a.name);try{d=g().readlinkSync(f)}catch{continue}if((d===b||d===c)&&o(f))return!0}return!1},pidHoldsPath:function(a,b){let c;try{c=g().readdirSync(i().join(k,String(a),"fd"),{withFileTypes:!0})}catch{return!1}for(let d of c)try{if(g().readlinkSync(i().join(k,String(a),"fd",d.name))===b)return!0}catch{continue}return!1}};var r=c(31421),s=c(48161),t=c.n(s),u=c(21420);function v(a,b){let c=(0,r.spawnSync)(a,b,{encoding:"utf8",maxBuffer:0x1000000,timeout:1e4});return c.error||"string"!=typeof c.stdout?"":c.stdout}let w=new Map,x=1,y=/^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.*)$/;function z(a,b){let c=0,d="";for(let e of a.split("\n")){if(!e)continue;let a=e[0],f=e.slice(1);if("p"===a)c=Number(f),d="";else if("f"===a)d="";else if("a"===a)d=f;else if("n"===a&&c>0&&f){let a="w"===d||"u"===d;b(f,c,()=>a)}}}let A=null;function B(){let a=Date.now();if(A&&a-A.at<5e3)return A.byPid;let b=function(a){let b=new Map;for(let c of a.split("\n")){let a=y.exec(c);if(!a)continue;let d=Number(a[1]),e=Number(a[2]),f=(a[4]??"").trim().split(/\s+/).filter(Boolean);b.set(d,{ppid:Number.isInteger(e)&&e>1?e:null,tty:function(a){if(!a||"?"===a||"??"===a||"-"===a)return 0;let b=w.get(a);return void 0===b&&(b=x,x+=1,w.set(a,b)),b}(a[3]??""),argv:f})}return b}(v("ps",["-axo","pid=,ppid=,tty=,args="])),c=function(a){let b=new Map,c=0;for(let d of a.split("\n")){if(!d)continue;let a=d[0],e=d.slice(1);"p"===a?c=Number(e):"n"===a&&c>0&&b.set(c,e)}return b}(v("lsof",["-w","-d","cwd","-Fpn"])),d=new Map;for(let[a,e]of b)d.set(a,{argv:e.argv,ppid:e.ppid,tty:e.tty,cwd:c.get(a)??null});return A={at:a,byPid:d},d}let C={name:"portable",pidAlive:function(a){if(!Number.isInteger(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}},readArgv:function(a){return B().get(a)?.argv??[]},readCwd:function(a){return B().get(a)?.cwd??null},readPpid:function(a){return B().get(a)?.ppid??null},processIdentity:function(a){return!Number.isInteger(a)||a<=0?null:"darwin"===process.platform?(0,u.P3)(a):null},processCpuMs:function(){return null},readEnvVar:function(){return null},listProcesses:function(){let a=[];for(let[b,c]of B())a.push({pid:b,argv:c.argv,cwd:c.cwd,tty:c.tty});return a},systemMemory:function(){let a=t().totalmem(),b=(0,j.Lc)(v("vm_stat",[]));if(!a||null===b)return null;let c=(0,j.yh)(v("sysctl",["-n","vm.swapusage"]));return{ramTotal:a,ramAvailable:Math.min(b,a),swapTotal:c?.swapTotal??0,swapUsed:c?.swapUsed??0}},processMemory:function(a){let b=new Set;for(let c of a)Number.isInteger(c)&&c>0&&b.add(c);let c=new Map;if(0===b.size)return c;for(let[a,d]of(0,j.CT)(v("ps",["-axo","pid=,rss="])))b.has(a)&&c.set(a,{rssBytes:d,swapBytes:0});return c},ppidMap:function(){let a=new Map;for(let[b,c]of B())null!==c.ppid&&a.set(b,c.ppid);return a},scanFdTargetsUnder:function(a,b){a&&g().existsSync(a)&&z(v("lsof",["-w","+D",a,"-Fpfan"]),b)},scanFdTargetsFor:function(a,b){let c=[...new Set(a.filter(Boolean))];0!==c.length&&z(v("lsof",["-w","-Fpfan","--",...c]),b)},pidWritesPath:function(a,b){let c=!1;return z(v("lsof",["-w","-a","-p",String(a),"-Fpfan","--",b]),(a,b,d)=>{d()&&(c=!0)}),c},pidHoldsPath:function(a,b){let c=!1;return z(v("lsof",["-w","-a","-p",String(a),"-Fpfan","--",b]),()=>{c=!0}),c}},D=BigInt(0),E=BigInt("125911584000000000"),F=BigInt(0);function G(a){if(!a)return null;let b=Number(a.trim());return Number.isSafeInteger(b)?b:null}function H(a){let b=a?.trim();return b&&/^\d+$/.test(b)?BigInt(b):null}let I=["ProcessId","ParentProcessId","CommandLine","WorkingSetSize","UserModeTime","KernelModeTime","Created"],J=BigInt(1e4),K=null;function L(){let a,b=Date.now();return K&&b-K.at<5e3?K:K={at:b,data:function(a){let b=new Map,c=function(a){let b=65279===a.charCodeAt(0)?a.slice(1):a,c=[],d=[],e="",f=!1,g=!1,h=()=>{d.push(e),e="",g=!1},i=()=>{h(),(d.length>1||""!==d[0])&&c.push(d),d=[]};for(let a=0;a<b.length;a+=1){let c=b[a];if(f){'"'===c?'"'===b[a+1]?(e+='"',a+=1):f=!1:e+=c;continue}if('"'===c&&!g){f=!0,g=!0;continue}if(","===c){h();continue}if("\r"!==c){if("\n"===c){i();continue}e+=c,g=!0}}return(""!==e||d.length>0)&&i(),c}(a),d=c[0];if(!d)return{rows:b,ppids:new Map};let e=new Map(I.map(a=>[a,d.indexOf(a)])),f=e.get("ProcessId")??-1;if(f<0)return{rows:b,ppids:new Map};let g=(a,b)=>{let c=e.get(b)??-1;return c<0?void 0:a[c]};for(let a of c.slice(1)){let c=G(a[f]);null===c||c<=0||b.set(c,{pid:c,rawPpid:G(g(a,"ParentProcessId")),argv:function(a){let b=[],c=a??"",d=0,e=()=>{for(;d<c.length&&(" "===c[d]||" "===c[d]);)d+=1};if(e(),d>=c.length)return b;let f="";if('"'===c[d]){for(d+=1;d<c.length&&'"'!==c[d];)f+=c[d],d+=1;d<c.length&&(d+=1)}else for(;d<c.length&&" "!==c[d]&&" "!==c[d];)f+=c[d],d+=1;for(b.push(f);e(),!(d>=c.length);){let a="",e=!1;for(;d<c.length;){if("\\"===c[d]){let b=0;for(;d<c.length&&"\\"===c[d];)b+=1,d+=1;if('"'===c[d]){if(a+="\\".repeat(b>>1),b%2==1){a+='"',d+=1;continue}}else{a+="\\".repeat(b);continue}}if('"'===c[d]){d+=1,e&&'"'===c[d]?(a+='"',d+=1):e=!e;continue}if(!e&&(" "===c[d]||" "===c[d]))break;a+=c[d],d+=1}b.push(a)}return b}(g(a,"CommandLine")??""),created:function(a){let b=H(a);return null!==b&&b>BigInt(0)?b:null}(g(a,"Created")),workingSetBytes:Math.max(0,G(g(a,"WorkingSetSize"))??0),cpuMs:function(a,b){let c=H(a),d=H(b);if(null===c&&null===d)return null;let e=((c??BigInt(0))+(d??BigInt(0)))/J;return e>BigInt(Number.MAX_SAFE_INTEGER)?null:Number(e)}(g(a,"UserModeTime"),g(a,"KernelModeTime"))})}return{rows:b,ppids:function(a){let b=new Map;for(let[c,d]of a){let e=d.rawPpid;if(null===e||e<=0||e===c)continue;let f=a.get(e);f&&(null!==f.created&&null!==d.created&&f.created>d.created||b.set(c,e))}return b}(b)}}((a=(0,r.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-EncodedCommand",Buffer.from("$ErrorActionPreference='SilentlyContinue'\n[Console]::OutputEncoding = New-Object System.Text.UTF8Encoding $false\nGet-CimInstance Win32_Process |\n Select-Object ProcessId,ParentProcessId,CommandLine,WorkingSetSize,UserModeTime,KernelModeTime,\n @{n='Created';e={if ($_.CreationDate) { $_.CreationDate.ToFileTimeUtc() }}} |\n ConvertTo-Csv -NoTypeInformation","utf16le").toString("base64")],{encoding:"utf8",maxBuffer:0x2000000,timeout:15e3,windowsHide:!0})).error||"string"!=typeof a.stdout?"":a.stdout),cwds:new Map}}function M(a){let b=L(),e=b.cwds.get(a);if(void 0!==e)return e;let f=function(a){if(!Number.isInteger(a)||a<=0)return null;let b=function(){if(void 0!==d)return d;if("win32"!==process.platform)return d=null;try{let a=c(85786),{i32:b,u32:e,u64:f,ptr:g}=a.FFIType,h=a.dlopen("kernel32.dll",{OpenProcess:{args:[e,b,e],returns:f},CloseHandle:{args:[f],returns:b},ReadProcessMemory:{args:[f,f,g,f,g],returns:b},IsWow64Process:{args:[f,g],returns:b}}),i=a.dlopen("ntdll.dll",{NtQueryInformationProcess:{args:[f,b,g,e,g],returns:b}}),j=new Map,k=a=>{let b=j.get(a);if(void 0!==b)return b;for(let b of[1040,4112]){let c=BigInt(h.symbols.OpenProcess(b,0,a));if(c!==D)return j.set(a,c),c}return null},l=(b,c,d)=>{let e=Buffer.alloc(8),f=h.symbols.ReadProcessMemory(b,c,a.ptr(d),BigInt(d.byteLength),a.ptr(e));return 0!==f&&e.readBigUInt64LE(0)===BigInt(d.byteLength)};d={parametersAddress(b){let c=k(b);if(null===c)return null;let d=Buffer.alloc(4);if(0!==h.symbols.IsWow64Process(c,a.ptr(d))&&0!==d.readInt32LE(0))return null;let e=Buffer.alloc(48),f=Buffer.alloc(8),g=i.symbols.NtQueryInformationProcess(c,0,a.ptr(e),48,a.ptr(f));if(0!==g)return null;let j=e.readBigUInt64LE(8);if(j===BigInt(0))return null;let m=Buffer.alloc(8);if(!l(c,j+BigInt(32),m))return null;let n=m.readBigUInt64LE(0);return n===BigInt(0)?null:n},read(a,b,c){let d=k(a);if(null===d||c<=0)return null;let e=Buffer.alloc(c);return l(d,b,e)?e:null},close(a){let b=j.get(a);if(void 0!==b){j.delete(a);try{h.symbols.CloseHandle(b)}catch{}}}}}catch{d=null}return d}();if(!b)return null;try{let c=b.parametersAddress(a);if(null===c)return null;let d=b.read(a,c,80);if(!d)return null;return function(a,b){if(a.byteLength<80)return null;let c=a.readUInt16LE(56),d=a.readBigUInt64LE(64);if(0===c||c%2!=0||c>32766||d===BigInt(0))return null;let e=b(d,c);if(!e||e.byteLength<c)return null;let f=e.subarray(0,c).toString("utf16le");return 0===f.length?null:f}(d,(c,d)=>b.read(a,c,d))}catch{return null}finally{b.close(a)}}(a),g=null===f?null:function(a){let b=a.replace(/\0[\s\S]*$/,"").trim();if(!b)return null;if(/^[A-Za-z]:[\\/]$/.test(b))return b[0].toUpperCase()+":\\";let c=b.replace(/[\\/]+$/,"");return c?/^[a-z]:/.test(c)?c[0].toUpperCase()+c.slice(1):c:null}(f);return b.cwds.set(a,g),g}let N={name:"windows",pidAlive:function(a){if(!Number.isInteger(a)||a<=0)return!1;try{return process.kill(a,0),!0}catch(a){return"EPERM"===a.code}},readArgv:function(a){return L().data.rows.get(a)?.argv??[]},readCwd:function(a){return M(a)},readPpid:function(a){return L().data.ppids.get(a)??null},processIdentity:function(a){var b=a;if(!Number.isInteger(b)||b<=0)return null;let d=function(){if(void 0!==e)return e;if("win32"!==process.platform)return e=null;try{let a=c(85786),{i32:b,u32:d,u64:f,ptr:g}=a.FFIType,h=a.dlopen("kernel32.dll",{OpenProcess:{args:[d,b,d],returns:f},CloseHandle:{args:[f],returns:b},GetProcessTimes:{args:[f,g,g,g,g],returns:b},GetExitCodeProcess:{args:[f,g],returns:b}});e=(b,c)=>{let d=BigInt(h.symbols.OpenProcess(4096,0,b));if(d===F)return!1;let e=[Buffer.alloc(8),Buffer.alloc(8),Buffer.alloc(8)];try{let b=Buffer.alloc(4);if(0!==h.symbols.GetExitCodeProcess(d,a.ptr(b))&&259!==b.readUInt32LE(0))return!1;return 0!==h.symbols.GetProcessTimes(d,a.ptr(c),a.ptr(e[0]),a.ptr(e[1]),a.ptr(e[2]))}finally{h.symbols.CloseHandle(d)}}}catch{e=null}return e}();if(!d)return null;let f=Buffer.alloc(8);try{var g=d(b,f);if(!Number.isInteger(b)||b<=0||!g||f.byteLength<8)return null;let a=f.readBigUInt64LE(0);return a<E?null:`${b}:${a}`}catch{return null}},processCpuMs:function(a){return L().data.rows.get(a)?.cpuMs??null},readEnvVar:function(){return null},listProcesses:function(){var a=L().data;let b=[];for(let[c,d]of a.rows)b.push({pid:c,argv:d.argv,cwd:!function(a){for(let b of a.slice(0,2)){let a=b.split(/[\\/]/).pop()?.toLowerCase()??"";if("claude"===a||"claude.exe"===a||"codex"===a||"codex.exe"===a)return!0}return!1}(d.argv)?null:M(c),tty:1});return b},systemMemory:function(){let a=t().totalmem();return a?{ramTotal:a,ramAvailable:Math.min(t().freemem(),a),swapTotal:0,swapUsed:0}:null},processMemory:function(a){let b=L().data.rows,c=new Map;for(let d of a){if(!Number.isInteger(d)||d<=0)continue;let a=b.get(d);a&&c.set(d,{rssBytes:a.workingSetBytes,swapBytes:0})}return c},ppidMap:function(){return new Map(L().data.ppids)},scanFdTargetsUnder:function(){},scanFdTargetsFor:function(){},pidWritesPath:function(){return!1},pidHoldsPath:function(){return!1}},O=function(a=process.platform,b=process.env.VIEWER_PROC_BACKEND){return"portable"===b?C:"linux"===b?q:"windows"===b?N:"linux"===a?q:"win32"===a?N:C}()},61532:(a,b,c)=>{c.d(b,{Qu:()=>j,lk:()=>g,vE:()=>h,xE:()=>i,xl:()=>k});let d=process;function e(){return{state:"pending",phase:"waiting for structured startup",completedHosts:0,totalHosts:null,updatedAt:new Date().toISOString()}}function f(a,b){if(!Number.isSafeInteger(b.completedHosts)||b.completedHosts<0)throw Error("structured host startup completed count is invalid");if(null!==b.totalHosts&&(!Number.isSafeInteger(b.totalHosts)||b.totalHosts<b.completedHosts))throw Error("structured host startup total count is invalid");let c=d.__llvStructuredHostStartupProgress,e=new Date().toISOString(),f=c?.phase!==b.phase||c.state!==a;f&&console.error("[structured hosts] startup progress",{pid:process.pid,phase:b.phase,state:a,previousPhase:c?.phase??null,previousPhaseMs:c?.phaseStartedAt?Math.max(0,Date.now()-Date.parse(c.phaseStartedAt)):null}),d.__llvStructuredHostStartupProgress={...b,state:a,updatedAt:e,phaseStartedAt:f?e:c?.phaseStartedAt??e,pid:process.pid}}function g(a){f(!0===d.__llvStructuredHostStartupFailed?"failed":"pending",a)}function h(){d.__llvStructuredHostStartupFailed=!0,f("failed",d.__llvStructuredHostStartupProgress??e())}function i(){d.__llvStructuredHostStartupFailed=!1,f("ready",{...d.__llvStructuredHostStartupProgress??e(),phase:"ready"})}function j(){d.__llvStructuredDeliveryControllerReady=!0}function k(){d.__llvStructuredDeliveryControllerReady=!1}},76190:(a,b,c)=>{c.d(b,{N:()=>d});function d(a=process.env){return"1"===a.LLV_WAKATIME_ENABLED}},76385:(a,b,c)=>{let d;c.d(b,{$k:()=>m,O1:()=>o,Ue:()=>l,gI:()=>n,h_:()=>i,y6:()=>k});var e=c(31421),f=c(73024),g=c.n(f),h=c(55686);function i(){if(void 0!==d)return d;if("linux"===process.platform){try{let a=g().readFileSync("/proc/sys/kernel/random/boot_id","utf8").trim(),b=g().readlinkSync("/proc/self/ns/pid");d=a&&b?`linux:${a}:pidns:${b}`:null}catch{d=null}return d}if("darwin"===process.platform){let a=(0,e.spawnSync)("sysctl",["-n","kern.boottime"],{encoding:"utf8",timeout:2e3}),b="string"==typeof a.stdout?/sec\s*=\s*(\d+)\s*,\s*usec\s*=\s*(\d+)/.exec(a.stdout):null;return d=b?`darwin:${b[1]}:${b[2]}`:null}return d="win32"===process.platform?"windows:absolute-process-creation-filetime":null}let j={pidAlive:a=>h.B.pidAlive(a),processIdentity:a=>h.B.processIdentity(a),bootEpoch:i};function k(a,b=j,c){return{pid:a,startIdentity:void 0===c?b.processIdentity(a):c,bootEpoch:b.bootEpoch()}}function l(a,b=j){if(!Number.isSafeInteger(a.pid)||a.pid<=0||!b.pidAlive(a.pid))return"dead";let c=b.processIdentity(a.pid);if(null===a.startIdentity||null===c)return"unverified";if(c!==a.startIdentity)return"dead";let d=b.bootEpoch();return"string"==typeof a.bootEpoch&&a.bootEpoch&&null!==d?d===a.bootEpoch?"alive":"dead":"unverified"}function m(a,b=j){return"dead"!==l(a,b)}function n(a,b=j){return"dead"===l(a,b)}function o(a,b){return a.pid===b.pid&&a.startIdentity===b.startIdentity&&(void 0===b.bootEpoch||a.bootEpoch===b.bootEpoch)}},89204:(a,b,c)=>{c.d(b,{Ol:()=>t,Qm:()=>l,aO:()=>n,pM:()=>u});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(55686);let k=new Int32Array(new SharedArrayBuffer(4));class l extends Error{constructor(a){super(a),this.name="FileTransactionBusyError"}}class m extends l{constructor(a,b){super(a),this.retryable=!0,this.name="StoreBusyBeforeAdmissionError",b&&"cause"in b&&(this.cause=b.cause)}}async function n(a){let b=!1;try{return await a(()=>{b=!0})}catch(a){if(!b&&a instanceof l&&!(a instanceof m))throw new m(a.message,{cause:a});throw a}}function o(a){try{let b=JSON.parse(g().readFileSync(a,"utf8"));if("number"==typeof b.pid&&Number.isInteger(b.pid)&&b.pid>0){let a="string"==typeof b.startIdentity?b.startIdentity:null;if(!j.B.pidAlive(b.pid))return!0;if(null!==a){let c=j.B.processIdentity(b.pid);return null!==c&&c!==a}return!1}return Date.now()-g().statSync(a).mtimeMs>3e4}catch{try{return Date.now()-g().statSync(a).mtimeMs>3e4}catch{return!1}}}function p(a,b){try{JSON.parse(g().readFileSync(a,"utf8")).token===b&&g().rmSync(a,{force:!0})}catch{}}function q(a){let b=`${a}.write-lock`,c=`${a}.write-locks`;g().mkdirSync(c,{recursive:!0,mode:448});let d={pid:process.pid,startIdentity:j.B.processIdentity(process.pid),token:e().randomUUID()},f=i().join(c,`${String(Date.now()).padStart(16,"0")}-${process.pid}-${e().randomUUID()}.json`);return g().writeFileSync(f,JSON.stringify(d),{encoding:"utf8",flag:"wx",mode:384}),{lockPath:b,queuePath:c,owner:d,ticketPath:f}}function r(a){let b;if(function(a){let b=[];for(let c of g().readdirSync(a.queuePath).filter(a=>a.endsWith(".json")).sort()){let d=i().join(a.queuePath,c);if(o(d)){g().rmSync(d,{force:!0});continue}g().existsSync(d)&&b.push(d)}return b[0]??null}(a)!==a.ticketPath)return null;try{b=g().openSync(a.lockPath,"wx",384)}catch(b){if("EEXIST"!==b.code)throw b;return o(a.lockPath)&&g().rmSync(a.lockPath,{force:!0}),null}try{return g().writeFileSync(b,JSON.stringify(a.owner),"utf8"),g().fsyncSync(b),b}catch(c){throw g().closeSync(b),g().rmSync(a.lockPath,{force:!0}),c}}function s(a,b){g().closeSync(b),p(a.lockPath,a.owner.token)}function t(a,b,c){let d=q(a);try{for(let a=0;a<6e3;a+=1){let a=r(d);if(null===a){Atomics.wait(k,0,0,5);continue}try{return c()}finally{s(d,a)}}throw new l(b)}finally{p(d.ticketPath,d.owner.token)}}async function u(a,b,c){let d=q(a);try{for(let a=0;a<6e3;a+=1){let a=r(d);if(null===a){await new Promise(a=>setTimeout(a,5));continue}try{return await c()}finally{s(d,a)}}throw new l(b)}finally{p(d.ticketPath,d.owner.token)}}},93994:(a,b,c)=>{c.d(b,{Hr:()=>h,o7:()=>j,sS:()=>l});var d=c(77030),e=c.n(d),f=c(16196);let g=[];class h extends Error{constructor(a,b){super(a),this.code=b}}let i=new Set(["runtime host request timed out","runtime host is unavailable","runtime host response exceeds limit","runtime host returned invalid JSON","runtime host response id mismatch"]);function j(a){return a instanceof h&&void 0===a.code&&i.has(a.message)}class k{constructor(a,b=3e3,c=12e4,d=1e4){this.socketPath=a,this.timeoutMs=b,this.deploymentTimeoutMs=c,this.snapshotTimeoutMs=d}nativeQueueRead(a){return this.call("native-queue-read",{conversationId:a})}nativeQueueTransition(a,b){return this.call("native-queue-transition",{operationId:a,transition:b})}nativeQueueSettleCompacted(a){return this.call("native-queue-settle-compacted",{...a})}snapshot(a,b){return this.call("snapshot",b,this.snapshotTimeoutMs,a)}events(a,b){return this.call("events",{after:a},this.timeoutMs,b)}waitEvents(a,b=15e3,c){return this.call("wait",{after:a,timeoutMs:b},b+1e3,c)}append(a){return this.call("append",{event:a})}operation(a){return this.call("operation",{event:a})}command(a){return this.call("command",{command:a})}operationStatus(a,b={}){return this.call("operation-status",{operationId:a,...b.currentRetryLeaf?{currentRetryLeaf:!0}:{}})}claimDeliveryAction(a,b){return this.call("operation-delivery-action",{operationId:a,action:b})}retryOperation(a,b,c={}){return this.call("operation-retry",{operationId:a,...void 0!==b?{nextIdempotencyKey:b}:{},...void 0!==c.requireHostedConversationId?{requireHostedConversationId:c.requireHostedConversationId}:{}})}producerCursor(a,b){return this.call("producer-cursor",{producerKind:a,eventKeyPrefix:b})}effectBatch(a,b=0){let c={...a?{kinds:[...a]}:{},...0!==b?{afterEventSeq:b}:{}};return this.call("effect-batch",Object.keys(c).length>0?c:void 0)}transitionOperation(a,b,c,d={}){return this.call("operation-transition",{operationId:a,status:b,...c?{details:c}:{},...d.fromStatuses?{fromStatuses:[...d.fromStatuses]}:{},...d.awaitProjection?{awaitProjection:!0}:{}})}acknowledgeTerminalProjection(a){return this.call("operation-projection-ack",{operationIds:[...a]})}requestViewerDeployment(a){return this.call("viewer-deployment-request",a,this.deploymentTimeoutMs)}cancelViewerDeployment(a){return this.call("viewer-deployment-cancel",{deploymentId:a})}readViewerDeployment(a){return this.call("viewer-deployment-read",{deploymentId:a})}admitMcpHealthProbe(a){return this.call("mcp-health-probe-admission",{capability:a})}call(a,b,c=this.timeoutMs,d){return new Promise((f,i)=>{let j={id:crypto.randomUUID(),method:a,...b?{params:b}:{}},k=e().createConnection(this.socketPath),l=performance.now(),m="",n=!1,o=setTimeout(()=>{let b=performance.now()-l;console.error(`[runtime host] request timed out method=${a} elapsedMs=${Math.max(0,Math.round(b))}`),p(new h("runtime host request timed out"),void 0,!0,b)},c),p=(b,c,e=!1,h=performance.now()-l)=>{!n&&(n=!0,clearTimeout(o),d?.removeEventListener("abort",q),k.destroy(),"wait"!==a&&(g.push({elapsedMs:Math.max(0,Math.round(h)),timeout:e}),g.length>256&&g.splice(0,g.length-256)),b?i(b):f(c))},q=()=>p(new h("runtime host request cancelled"));if(d?.aborted)return q();d?.addEventListener("abort",q,{once:!0}),k.once("error",()=>p(new h("runtime host is unavailable"))),k.on("data",a=>{if(m+=String(a),Buffer.byteLength(m)>0x4000000)return p(new h("runtime host response exceeds limit"));let b=m.indexOf("\n");if(!(b<0))try{let a=JSON.parse(m.slice(0,b));if(a.id!==j.id)return p(new h("runtime host response id mismatch"));p(a.ok?void 0:new h(a.error??"runtime host rejected request",a.code),a.result)}catch{p(new h("runtime host returned invalid JSON"))}}),k.once("connect",()=>k.write(JSON.stringify(j)+"\n"))})}}function l(a=process.env){let b=(0,f.S0)(a);return b?new k(b):null}},94972:(a,b,c)=>{c.r(b),c.d(b,{accountControllerDelayMs:()=>y,activateViewerRuntimeWhenCurrent:()=>x,checkStateDatabasesBeforeStores:()=>O,checkpointHotStateRollbackMirrorsForDemotion:()=>B,classifyStructuredHostStartupError:()=>L,completeViewerReleaseDemotion:()=>A,completeViewerRuntimeActivation:()=>N,establishHotStateCutoverBoundary:()=>w,initializeHotStateStoresAtStartup:()=>C,initializeOperatorSpawnCapabilityAtStartup:()=>E,registerViewerRuntime:()=>P,runIdentityWaveMigrationWithoutBlockingStartup:()=>G,runStructuredHostStartup:()=>M,scheduleAccountMigrationController:()=>z,startCurrentReleaseControllers:()=>D,startWakatimeIntegrationIfEnabled:()=>F,viewerReleaseBoundary:()=>u,viewerReleaseOwnsTraffic:()=>t});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(93994),l=c(16196),m=c(95697),n=c(14928),o=c(61532),p=c(21420),q=c(65281),r=c(76190);let s=globalThis;function t(a=process.env,b=()=>g().readFileSync((0,j.BQ)("viewer-release.json"),"utf8")){let c,d=a.PORT?.trim();if(!d)return!0;try{c=b()}catch(a){return"ENOENT"===a.code}try{let a=JSON.parse(c);if("string"!=typeof a.endpoint)return!1;return new URL(a.endpoint).port===d}catch{return!1}}function u(a=()=>g().readFileSync((0,j.BQ)("viewer-release.json"),"utf8")){let b;try{b=a()}catch{return`viewer-release:pid-${process.pid}`}let c=e().createHash("sha256").update(b).digest("hex").slice(0,16);return`viewer-release:${c}`}function v(){return["flows.json","pipelines.json","pipelines-archive.json","workflows.json"].map(a=>{let b=(0,j.BQ)(a);try{let c=g().statSync(b,{bigint:!0});return`${a}:${c.mtimeNs}:${c.size}`}catch{return`${a}:missing`}}).join("|")}async function w(a,b={}){let d=i().dirname((0,j.BQ)("state.sqlite")),e=(0,m.jU)(d);if((null!==e||g().existsSync((0,j.BQ)("viewer-release.json")))&&null===e)throw Error("viewer release cannot publish hot-state authority");if(null===e)return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:null,reimportLegacy:!1};let f=(0,m.a5)(d);if(f?.mode==="sqlite"&&f.releaseRevision!==e)return f=(0,m.RG)(d,"sqlite",e),(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};if(f?.mode==="sqlite"&&f.releaseRevision===e)return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};if(f?.mode==="fencing")throw Error("hot-state cutover cannot replace an active rollback fence");(f?.mode!=="preparing"||f.releaseRevision!==e)&&(f=(0,m.RG)(d,"preparing",e));let{hotStateMigrationApplied:h,hotStateMigrationDryRun:k}=await Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8817),c.e(6796),c.e(5682)]).then(c.bind(c,25682));if(h())return(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!1};let l=b.pollMs??250,o=b.stablePolls??3,p=b.maxPolls??12,q=b.schedule??((a,b)=>setTimeout(a,b)),r=b.legacySignature??v,s=r(),t=0;for(let b=0;b<p;b+=1){if(await new Promise(a=>q(a,l).unref?.()),!a())throw Error("viewer release lost traffic during hot-state cutover");let b=r();if(t=b===s?t+1:0,s=b,t>=o)return k(),(0,n.iy)((0,j.BQ)("state.sqlite")),{authority:f,reimportLegacy:!0}}throw Error("legacy hot-state files did not quiesce during release cutover")}async function x(a,b,c={}){let d=c.pollMs??250,e=c.schedule??((a,b)=>setTimeout(a,b)),f=c.log??console.error,g=!1,h=!1,i=!1,j=null,k=()=>{if(h)return;if(g&&!b()){h=!0,Promise.resolve(c.onDemoted?.({fenced:null!==j})).catch(a=>{f("[viewer release] demotion checkpoint failed",a)});return}let a=g?c.fenceRequest?.()??null:null;a&&"fencing"===a.mode?j===a.epoch||i||(i=!0,Promise.resolve(c.onFenceRequested?.(a)).then(()=>{j=a.epoch}).catch(a=>{f("[viewer release] hot-state fence checkpoint failed",a)}).finally(()=>{i=!1})):i||null===j||(j=null,Promise.resolve(c.onFenceWithdrawn?.()).catch(a=>{f("[viewer release] withdrawn fence recovery failed",a)})),e(k,d).unref?.()},l=async()=>{g||(g=!0,e(k,d).unref?.(),await a())};if(b())return void await l();let m=()=>{if(!g){if(!b())return void e(m,d).unref?.();l().catch(a=>f("[viewer release] deferred runtime activation failed",a))}};e(m,d).unref?.()}function y(a=process.env){let b=Number(a.LLV_ACCOUNT_CONTROLLER_DELAY_MS??0);return Number.isFinite(b)?Math.max(0,b):0}function z(a,b){let c=()=>{a().catch(a=>{console.error("[account migration controller] initial durable reconciliation failed",a)})},d=setTimeout(()=>{b>0?c():setTimeout(c,0).unref?.()},b);d.unref?.()}async function A(a,b=a=>process.exit(a),d=console.error,e=async()=>{let{releaseStructuredDeliveryHostsForDemotion:a}=await Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(6277)]).then(c.bind(c,2749));await a()}){let f=null;try{await e()}catch(a){f=a}try{await a()}catch(a){f??=a}if(f){d("[viewer release] demotion cleanup failed",f),b(1);return}b(0)}async function B(){let[a,b,d]=await Promise.all([Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8817)]).then(c.bind(c,98817)),Promise.all([c.e(8027),c.e(112)]).then(c.bind(c,18027)),Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8817),c.e(6796)]).then(c.bind(c,96796))]),e=await a.checkpointFlowRollbackMirrorForDemotionAsync(),f=await b.checkpointPipelineRollbackMirrorsForDemotionAsync(),g=await d.checkpointWorkflowRollbackMirrorForDemotionAsync(),{checkpointLegacyCollectionMirrorsForDemotion:h}=await c.e(7294).then(c.bind(c,77294));return await h(),{flows:e,pipelines:f.pipelines,pipelinesArchive:f.pipelinesArchive,workflows:g}}async function C(a={authority:null,reimportLegacy:!1},b={}){let[d,e,f]=await Promise.all([Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8817)]).then(c.bind(c,98817)),Promise.all([c.e(8027),c.e(112)]).then(c.bind(c,18027)),Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8817),c.e(6796)]).then(c.bind(c,96796))]);return((0,n.t0)((0,j.BQ)("state.sqlite"),[d.flowStateCollectionSeed(),...e.pipelineStateCollectionSeeds(),f.workflowStateCollectionSeed()],{reimportExisting:a.reimportLegacy,...b.afterCollectionImport?{afterCollectionImport:b.afterCollectionImport}:{}}),d.loadFlows(),e.loadPipelines(),e.loadArchivedPipelines(),f.loadWorkflows(),a.authority?.mode==="preparing")?(0,m.H0)(i().dirname((0,j.BQ)("state.sqlite")),a.authority):a.authority}async function D(a=process.env,b={loadFlowPipelineController:()=>Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(8444),c.e(9298)]).then(c.bind(c,60156)),loadAccountMigrationController:()=>Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(8444),c.e(3570)]).then(c.bind(c,37868)),loadTelegramReportScheduler:()=>Promise.all([c.e(1952),c.e(9777),c.e(2549),c.e(773),c.e(3830)]).then(c.bind(c,83830)),loadTelegramConnectorBoot:()=>Promise.all([c.e(9777),c.e(773),c.e(5545)]).then(c.bind(c,95545)),loadStructuredHostRetirement:()=>Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(9307),c.e(9296)]).then(c.bind(c,50261)),loadSeatTick:()=>Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(9307),c.e(8444),c.e(2589)]).then(c.bind(c,74409))}){let{startFlowPipelineController:d}=await b.loadFlowPipelineController();d();try{let a=await b.loadTelegramConnectorBoot?.();a&&a.provisionTelegramConnectorAtStartup().catch(a=>console.error("[telegram connector] boot provisioning failed",a instanceof Error?a.name:"unknown"))}catch(a){console.error("[telegram connector] boot provisioning unavailable",a instanceof Error?a.name:"unknown")}try{let a=await b.loadTelegramReportScheduler?.();a?.ensureTelegramReportScheduler()}catch(a){console.error("[telegram report] scheduler start failed",a instanceof Error?a.name:"unknown")}try{let a=await b.loadStructuredHostRetirement?.();a?.startStructuredHostRetirement()}catch(a){console.error("[host retirement] sweep start failed",a instanceof Error?a.name:"unknown")}try{let a=await b.loadSeatTick?.();a?.startSeatTick()}catch(a){console.error("[seat tick] start failed",a instanceof Error?a.name:"unknown")}if("1"===a.LLV_ACCOUNT_CONTROLLER_DISABLED)return;let{startAccountMigrationController:e}=await b.loadAccountMigrationController();z(e,y(a))}async function E(a=process.env,b=a=>console.error(a)){let{ensureOperatorSpawnCapability:d,rotateOperatorSpawnCapability:e}=await c.e(4260).then(c.bind(c,74260));"1"===a.LLV_ROTATE_OPERATOR_SPAWN_CAPABILITY?e():d();let f=a.PORT?.trim()||"8898";b(`[viewer] Open http://127.0.0.1:${f}.`)}async function F(a=process.env,b=H,c=(a,b)=>console.error(a,b)){if((0,r.N)(a))try{await b()}catch{c("[wakatime] startup_failed",{})}}function G(a,b=console.error,c={}){let d=Math.max(1,Math.floor(c.maxAttempts??3)),e=Math.max(0,c.initialRetryMs??5e3),f=c.schedule??((a,b)=>setTimeout(a,b)),g=0,h=()=>{g+=1;try{a()}catch(c){if(g>=d)return void b("[identity-wave] registry migration failed; retry limit reached",{attempt:g,error:c});let a=e*2**(g-1);b("[identity-wave] registry migration failed; retry scheduled",{attempt:g,retryInMs:a,error:c}),f(h,a).unref?.()}};h()}async function H(){if(s.__llvWakatimeWorker)return;let a=process.cwd(),b=i().join(a,"src/lib/wakatimeSync.worker.ts"),d=i().join(a,".next/server/wakatime-sync-worker.js"),e="/usr/local/bin/bun-container",f=g().existsSync(b)&&g().existsSync(e)?{executable:e,workerPath:b}:g().existsSync(d)?{executable:process.versions.bun?process.execPath:process.env.LLV_BUN_EXECUTABLE||"bun",workerPath:d}:{executable:process.execPath,workerPath:b},{spawn:h}=await Promise.resolve().then(c.t.bind(c,31421,23)),j=g().existsSync("/usr/bin/nice"),k=h(j?"/usr/bin/nice":f.executable,[...j?["-n","10",f.executable]:[],f.workerPath],{cwd:a,stdio:["ignore","inherit","inherit"],env:{...(0,q.Fd)(process.env),LLV_WAKATIME_SYNC_WORKER:"1"}});s.__llvWakatimeWorker=k,k.once("error",a=>{console.error("[wakatime] worker_start_failed",{message:a.message})}),k.once("exit",(a,b)=>{if(s.__llvWakatimeWorker===k&&(s.__llvWakatimeWorker=void 0),s.__llvWakatimeWorkerRestart)return;console.error("[wakatime] worker_exited",{code:a,signal:b});let c=setTimeout(()=>{s.__llvWakatimeWorkerRestart=void 0,H()},1e3);c.unref?.(),s.__llvWakatimeWorkerRestart=c})}let I=new Set(["EAGAIN","EBUSY","ECONNREFUSED","ECONNRESET","EINTR","EIO","EMFILE","ENFILE","ENOENT"]),J=new Set(["SQLITE_CORRUPT","SQLITE_NOTADB"]);function K(a,b){if("object"!=typeof a||null===a||!(b in a))return"";let c=a[b];return"string"==typeof c?c:""}function L(a){let b=K(a,"name"),c=K(a,"code"),d=K(a,"message");return a instanceof p.bL||"StructuredRuntimeRequirementError"===b?{disposition:"terminal",category:"configuration",action:"Correct the structured-host configuration and restart the Viewer."}:"RegistryParityError"===b||"RegistryBackendIdentityError"===b||J.has(c)||/corrupt .* SQLite row|SQLite row is malformed|schema is unsupported/i.test(d)?{disposition:"terminal",category:"data-corruption",action:"Repair or restore the reported state data, then restart the Viewer."}:"structured-delivery-controller-unavailable"===c?{disposition:"recoverable",category:"instrumentation-order",action:"Retry after the process controller publication becomes visible."}:"ETIMEDOUT"===c||/\btimed out\b/i.test(d)?{disposition:"recoverable",category:"timeout",action:"Retry after the dependency response window."}:"FileTransactionBusyError"===b?{disposition:"recoverable",category:"registry-contention",action:"Retry after the active registry transaction releases its lock."}:I.has(c)?{disposition:"recoverable",category:"transient-io",action:"Retry after the local I/O dependency recovers."}:a instanceof k.Hr||/^runtime host (?:is unavailable|request cancelled|response exceeds limit|returned invalid JSON|response id mismatch)$/i.test(d)?{disposition:"recoverable",category:"runtime-host-unavailable",action:"Retry after the runtime host becomes available."}:{disposition:"recoverable",category:"unknown-recoverable",action:"Retry with bounded backoff while the Viewer remains unavailable for structured delivery."}}async function M(a,b=console.error,c={}){let d=c.schedule??((a,b)=>setTimeout(a,b)),e=c.maxRetryMs??1e3,f=Math.min(Math.max(c.jitterRatio??.2,0),1),g=c.random??Math.random,h=c.initialRetryMs??100,i=!1,j=0,k=null,l=null,m=c.waitUntilReady?new Promise((a,b)=>{k=a,l=b}):null,n=async()=>{j+=1;try{c.signal?.throwIfAborted(),await a(),c.signal?.throwIfAborted(),(0,o.xE)(),k?.(),j>1&&b("[structured hosts] startup adoption recovered",{attempts:j})}catch(p){if((0,o.vE)(),c.signal?.aborted)throw l?.(p),p;let a=L(p);if("terminal"===a.disposition)throw b("[structured hosts] startup adoption failed",p,{category:a.category,action:a.action}),l?.(p),p;if(i)return;let k=1+(2*Math.min(Math.max(g(),0),1)-1)*f,m=Math.min(e,Math.max(0,Math.round(h*k)));h=Math.min(2*h,e),i=!0,1===j&&b("[structured hosts] startup adoption failed; retry scheduled",p),d(()=>{i=!1,n().catch(a=>{b("[structured hosts] startup adoption retry aborted",a)})},m).unref?.()}},p=()=>{(0,o.vE)(),i&&l?.(c.signal?.reason)};if(c.signal?.addEventListener("abort",p,{once:!0}),m){try{await Promise.all([n(),m])}finally{c.signal?.removeEventListener("abort",p)}return}await n()}async function N(a){await a.initializeOperatorCapability(),await a.runIdentityMigration?.(),await a.startWakatime(),a.publishHotStateActivation(),a.startStructuredHosts?.(),await a.startControllers(),a.publishViewerReleaseReady()}async function O(a){try{let{checkStateDatabasesAtActivation:b,startStateDurability:d}=await c.e(9839).then(c.bind(c,9839)),e=b(a);return{start:b=>{d({stateDirectory:a,incidents:e,ownsTraffic:b})}}}catch(a){return console.error("[state durability] activation check failed",a instanceof Error?a.message:String(a)),{start:()=>{}}}}async function P(){(0,q.kL)();let a=()=>t(),b=i().dirname((0,j.BQ)("state.sqlite")),d=()=>(0,m.jU)(b),e=null,f=new AbortController,g=null,h=async()=>{f.abort(Error("structured startup retired by release handover")),await g?.catch(()=>{})},k=()=>{a()&&(0,m.a5)(b)?.mode!=="fencing"||f.abort(Error("structured startup lost release authority")),f.signal.throwIfAborted()},n=async()=>{let{releaseStructuredHostsForViewerDemotion:a}=await Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(9307),c.e(644)]).then(c.bind(c,23886));await a({boundary:u()})};await x(async()=>{let d=await w(a);e=d.authority?.releaseRevision??null;let h=await O(b),i=await C(d),{ensureLegacyCollectionsImported:j}=await c.e(7294).then(c.bind(c,77294));await j();let n=null;await N({initializeOperatorCapability:E,runIdentityMigration:async()=>{let{runIdentityWaveMigrationAtStartup:a}=await Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(9307),c.e(2150)]).then(c.bind(c,22150));G(a)},startWakatime:F,startStructuredHosts:(0,l.cM)()?()=>{(g=(async()=>{let{adoptStructuredHostsAtStartup:a}=await Promise.all([c.e(7826),c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952),c.e(8465),c.e(8817),c.e(6796),c.e(3509),c.e(9777),c.e(9360),c.e(9307),c.e(644)]).then(c.bind(c,23886));await M(()=>a({assertActive:k}),console.error,{waitUntilReady:!0,signal:f.signal})})()).catch(a=>console.error("[structured hosts] background startup aborted",a))}:null,startControllers:D,publishHotStateActivation:()=>{i&&(n=(0,m.tT)(b,i))},publishViewerReleaseReady:()=>{n&&(0,m.uB)(b,n)}}),h.start(a)},a,{fenceRequest:()=>{let a=d(),c=(0,m.a5)(b);return null!==a&&c?.mode==="fencing"&&c.releaseRevision===a?c:null},onFenceRequested:async a=>{await h(),await n();let d=await B(),{agentRegistry:e}=await Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952)]).then(c.bind(c,70160));e().checkpointRollbackMirrorForDemotion(),(0,m.u_)(b,a,d)},onFenceWithdrawn:async()=>{let e=d(),f=(0,m.a5)(b);if(!a()||null===e||f?.mode!=="sqlite"||f.releaseRevision!==e)return;let{ensureLegacyCollectionsImported:g}=await c.e(7294).then(c.bind(c,77294));await g()},onDemoted:async({fenced:a})=>{await h(),await A(async()=>{if(a)return;let d=(0,m.a5)(b);if(!e||d?.releaseRevision!==e||"sqlite"!==d.mode&&"fencing"!==d.mode)return;let{agentRegistry:f}=await Promise.all([c.e(3696),c.e(8027),c.e(261),c.e(160),c.e(1952)]).then(c.bind(c,70160));await B(),f().checkpointRollbackMirrorForDemotion()},void 0,void 0,n)}})}},95697:(a,b,c)=>{c.d(b,{H0:()=>x,Ny:()=>r,RG:()=>v,T2:()=>s,X4:()=>p,a5:()=>o,jU:()=>q,tT:()=>y,uB:()=>z,u_:()=>w});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(89204),k=c(76385);let l="LLV_HOT_STATE_RELEASE_REVISION";function m(a){return i().join(a,"hot-state-authority.json")}function n(a){return"string"==typeof a&&/^[0-9a-f]{40}$/.test(a)}function o(a){try{var b;let c=!(b=JSON.parse(g().readFileSync(m(a),"utf8")))||"object"!=typeof b||Array.isArray(b)?null:1===b.schemaVersion&&Number.isInteger(b.epoch)&&!(b.epoch<1)&&["legacy","preparing","sqlite","fencing"].includes(String(b.mode))&&(null===b.releaseRevision||n(b.releaseRevision))&&"string"==typeof b.updatedAt&&(void 0===b.activationReadyAt||"string"==typeof b.activationReadyAt)&&(void 0===b.releaseReadyAt||"string"==typeof b.releaseReadyAt)&&(void 0===b.releaseReadyAt||void 0!==b.activationReadyAt)&&(void 0===b.activationOwner||b.activationOwner&&Number.isSafeInteger(b.activationOwner.pid)&&!(b.activationOwner.pid<=0)&&(null===b.activationOwner.startIdentity||"string"==typeof b.activationOwner.startIdentity)&&(void 0===b.activationOwner.bootEpoch||null===b.activationOwner.bootEpoch||"string"==typeof b.activationOwner.bootEpoch))&&(void 0===b.checkpoint||function(a){if(!a||"object"!=typeof a||Array.isArray(a))return!1;let b=a.revisions,c=b?[b.flows,b.pipelines,b.pipelinesArchive,b.workflows]:[];return"string"==typeof a.acknowledgedAt&&4===c.length&&c.every(a=>Number.isInteger(a)&&a>=0)}(b.checkpoint))?b:null;if(!c)throw Error("hot-state authority is invalid");return c}catch(a){if("ENOENT"===a.code)return null;throw a}}function p(a,b=process.env){let c=b.LLV_VIEWER_DEPLOY_TARGET?.trim()||i().join(a,"viewer-release.json");try{var d;let a=!(d=JSON.parse(g().readFileSync(c,"utf8")))||"object"!=typeof d||Array.isArray(d)?null:"string"==typeof d.endpoint&&n(d.revision)&&(void 0===d.hotStateBackend||"sqlite-v1"===d.hotStateBackend)?d:null;if(!a)throw Error("Viewer release target cannot authorize hot state");return a}catch(a){if("ENOENT"===a.code)return null;throw a}}function q(a,b=process.env){let c=p(a,b);if(!c)return null;let d=b[l]?.trim();if(d)return n(d)&&d===c.revision?d:null;let e=b.PORT?.trim();if(!e)return null;try{return new URL(c.endpoint).port===e?c.revision:null}catch{return null}}function r(a,b=process.env){let c=p(a,b);if(!c)return!0;let d=o(a),e=q(a,b);return e?d?.mode==="sqlite"&&d.releaseRevision===e&&c.revision===e:!(b[l]?.trim()||b.PORT?.trim())&&d?.mode==="sqlite"&&d.releaseRevision===c.revision&&"string"==typeof d.activationReadyAt}function s(a,b=process.env){let c=p(a,b);if(!c)return!0;let d=q(a,b);if(!d)return!1;let e=o(a);return e?.mode==="preparing"&&e.releaseRevision===d&&c.revision===d}function t(a,b){return null!==a&&JSON.stringify(a)===JSON.stringify(b)}function u(a,b,c,d,f={}){if(f.releaseReadyAt&&!f.activationReadyAt)throw Error("Viewer release readiness requires completed hot-state activation");let h={schemaVersion:1,epoch:f.epoch??(b?.epoch??0)+1,mode:c,releaseRevision:d,updatedAt:new Date().toISOString(),...f.activationReadyAt?{activationReadyAt:f.activationReadyAt}:{},...f.releaseReadyAt?{releaseReadyAt:f.releaseReadyAt}:{},...f.checkpoint?{checkpoint:f.checkpoint}:{},...f.activationOwner?{activationOwner:f.activationOwner}:"fencing"===c&&b?.releaseRevision===d&&b.activationOwner?{activationOwner:b.activationOwner}:{}};if(!Number.isInteger(h.epoch)||h.epoch<1)throw Error("hot-state authority epoch is invalid");if(b&&h.epoch<b.epoch)throw Error("hot-state authority epoch cannot regress");return!function(a,b){let c=i().dirname(a);g().mkdirSync(c,{recursive:!0,mode:448});let d=i().join(c,`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`),f=g().openSync(d,"wx",384);try{g().writeFileSync(f,`${JSON.stringify(b,null,2)}
|
|
135
157
|
`,"utf8"),g().fsyncSync(f)}finally{g().closeSync(f)}g().renameSync(d,a);let h=g().openSync(c,"r");try{g().fsyncSync(h)}finally{g().closeSync(h)}}(m(a),h),h}function v(a,b,c,d={}){if(null!==c&&!n(c))throw Error("hot-state release revision is invalid");return(0,j.Ol)(m(a),"hot-state authority is busy",()=>u(a,o(a),b,c,d))}function w(a,b,c){return(0,j.Ol)(m(a),"hot-state authority is busy",()=>{let d=o(a);if(!d||"fencing"!==d.mode||d.epoch!==b.epoch||d.releaseRevision!==b.releaseRevision||d.checkpoint)throw Error("hot-state fence request changed before checkpoint acknowledgement");if(d.activationOwner&&!(0,k.O1)((0,k.y6)(process.pid),d.activationOwner)&&"dead"!==(0,k.Ue)(d.activationOwner))throw Error("live Viewer must acknowledge its own hot-state fence");return u(a,d,"fencing",d.releaseRevision,{epoch:d.epoch,checkpoint:{acknowledgedAt:new Date().toISOString(),revisions:c}})})}function x(a,b){return(0,j.Ol)(m(a),"hot-state authority is busy",()=>{let c=o(a);if(!c||!t(c,b)||"preparing"!==c.mode)throw Error("hot-state preparation changed before completion");return u(a,c,"sqlite",c.releaseRevision,{epoch:c.epoch})})}function y(a,b){return(0,j.Ol)(m(a),"hot-state authority is busy",()=>{let c=o(a);if(!c||!t(c,b)||"sqlite"!==c.mode)throw Error("hot-state authority changed before activation completed");return u(a,c,"sqlite",c.releaseRevision,{epoch:c.epoch,activationReadyAt:new Date().toISOString(),activationOwner:(0,k.y6)(process.pid)})})}function z(a,b){return(0,j.Ol)(m(a),"hot-state authority is busy",()=>{let c=o(a);if(!c||!t(c,b)||"sqlite"!==c.mode||"string"!=typeof c.activationReadyAt)throw Error("hot-state authority changed before Viewer release startup completed");return u(a,c,"sqlite",c.releaseRevision,{epoch:c.epoch,activationReadyAt:c.activationReadyAt,...c.activationOwner?{activationOwner:c.activationOwner}:{},releaseReadyAt:new Date().toISOString()})})}}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.id=53,exports.ids=[53],exports.modules={90053:a=>{a.exports=JSON.parse('{"name":"agent-log-viewer","version":"1.2.2","bin":{"agent-log-viewer":"bin/cli.mjs","agent-log-viewer-mcp":"bin/mcp-server.mjs"},"exports":{"./mcp-server":"./bin/mcp-server.mjs","./package.json":"./package.json"},"files":["bin","dist","vendor"],"engines":{"node":">=20.9.0","bun":">=1.4.0"},"os":["linux","darwin","win32"],"scripts":{"dev":"NODE_ENV=development bun --bun node_modules/.bin/next dev --webpack --hostname 127.0.0.1","build":"next build --webpack && bun run build:mcp","build:mcp":"bun scripts/build-mcp.ts","demo:capture":"bun scripts/demo-capture.ts","deploy:staging":"bun scripts/deploy-staging.ts","bootstrap:runtime-host":"bun scripts/bootstrap-runtime-host.ts","demo:motion":"bun scripts/demo-motion.ts","start":"bun --bun node_modules/.bin/next start","lint":"eslint","prepack":"node scripts/prepack.mjs","privacy:check":"LLV_PRIVACY_KNOWN_VALUE_FINGERPRINTS_FILE=scripts/privacy-known-value-fingerprints.json LLV_PRIVACY_OCR_LANGUAGES=eng+ukr bun scripts/privacy-publication-gate.ts --require-known-values --check-commits --base origin/main","privacy:fingerprints":"bun scripts/generate-privacy-known-value-fingerprints.ts","privacy:github-audit":"LLV_PRIVACY_KNOWN_VALUE_FINGERPRINTS_FILE=scripts/privacy-known-value-fingerprints.json bun scripts/privacy-github-audit.ts","privacy:placeholders":"bun scripts/generate-privacy-placeholders.ts","telegram:provision":"node bin/provision-telegram-connector.mjs","test":"bun test"},"dependencies":{"@modelcontextprotocol/sdk":"1.30.0","entities":"^8.0.0","highlight.js":"^11.11.1","lucide-react":"^1.23.0","next":"16.3.3","pdfjs-dist":"^6.2.108","qrcode":"^1.5.4","qrcode-terminal":"^0.12.0","react":"19.2.8","react-dom":"19.2.8","zod":"4.4.3"},"devDependencies":{"@tailwindcss/postcss":"^4","@types/bun":"^1.3.14","@types/node":"^26","@types/qrcode":"^1.5.6","@types/react":"^19","@types/react-dom":"^19","eslint":"^10","eslint-config-next":"16.3.2","happy-dom":"^20.10.6","playwright-core":"1.62.1","tailwindcss":"^4","typescript":"^5"},"ignoreScripts":["sharp","unrs-resolver"],"trustedDependencies":["sharp","unrs-resolver"],"description":"Local web UI that renders Codex / Claude Code agent logs as a live chat-style feed with a session parentage tree","repository":{"type":"git","url":"git+https://github.com/Latand/live-log-viewer-next.git"},"license":"MIT","overrides":{"fast-uri":"^3.1.6"},"patchedDependencies":{"next@16.3.3":"patches/next-16.3.3.patch"}}')}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.id=5408,exports.ids=[5408],exports.modules={15408:(a,b,c)=>{c.r(b),c.d(b,{ORCHESTRATOR_SEATS_SCHEMA_VERSION:()=>m,ORCHESTRATOR_SEAT_HISTORY_CAP:()=>n,abandonStillbornOrchestratorSeat:()=>I,activeOrchestratorSeats:()=>K,activeOrchestratorSeatsForMigration:()=>N,activeOrchestratorSeatsOrUnknown:()=>L,beginOrchestratorSeatIntent:()=>E,canonicalOrchestratorProject:()=>p,completeOrchestratorSeatIntent:()=>F,confirmOrchestratorSeatMaterialization:()=>J,failOrchestratorSeatIntent:()=>H,orchestratorRevocations:()=>P,orchestratorSeatFor:()=>D,orchestratorSeatForOrUnknown:()=>M,readOrchestratorSeatFile:()=>x,rekeyOrchestratorSeatPaths:()=>O,repairOrchestratorSeatRuntimeIdentity:()=>G,revokedOrchestratorSeatConversationsOrUnknown:()=>Q});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(22962),k=c(91724),l=c(89940);let m=1,n=50,o=()=>(0,k.BQ)("orchestrator-seats.json");function p(a){return(0,l.G$)(a.trim())}function q(){return{schemaVersion:m,nextSeatEpoch:1,seats:{},pending:{},revocations:[],history:[],rollbacks:{}}}function r(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,JSON.stringify(b,null,2)+"\n","utf8"),g().renameSync(c,a)}function s(a){if(!a||"object"!=typeof a||Array.isArray(a)||"operator"!==a.kind&&"agent"!==a.kind)return null;let b="string"==typeof a.conversationId&&a.conversationId?a.conversationId:null,c="number"==typeof a.seatEpoch&&Number.isInteger(a.seatEpoch)&&a.seatEpoch>=1?a.seatEpoch:null;return{kind:a.kind,conversationId:b,seatEpoch:c}}function t(a){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.project||!a.project||"number"!=typeof a.seatEpoch||!Number.isInteger(a.seatEpoch)||a.seatEpoch<1||null!==a.conversationId&&"string"!=typeof a.conversationId||null!==a.path&&"string"!=typeof a.path||"string"!=typeof a.mandate||"pending"!==a.state&&"active"!==a.state)return null;let b=a.intent;if(!b||"string"!=typeof b.clientRequestId||!b.clientRequestId||"spawn"!==b.mode&&"existing"!==b.mode||"string"!=typeof a.designatedAt||null!==a.activatedAt&&"string"!=typeof a.activatedAt)return null;let c="string"==typeof a.engine&&a.engine.trim()?a.engine:null,d="string"==typeof a.model&&a.model.trim()?a.model:null,e="boolean"==typeof a.runtimeIdentityFrozen?a.runtimeIdentityFrozen:!!(c||d);return{project:a.project,seatEpoch:a.seatEpoch,conversationId:a.conversationId??null,path:a.path??null,engine:c,model:d,runtimeIdentityFrozen:e,mandate:a.mandate,promptVersion:"number"==typeof a.promptVersion&&Number.isInteger(a.promptVersion)?a.promptVersion:null,predecessorConversationId:"string"==typeof a.predecessorConversationId?a.predecessorConversationId:null,triggeredBy:s(a.triggeredBy),state:a.state,intent:{clientRequestId:b.clientRequestId,mode:b.mode,launchId:"string"==typeof b.launchId?b.launchId:null,error:"string"==typeof b.error?b.error:null},designatedAt:a.designatedAt,activatedAt:a.activatedAt??null}}function u(a,b){return a.history.push(b),a.history.length>n&&a.history.splice(0,a.history.length-n),b}function v(a,b){let c=a[b.project];(!c||b.seatEpoch>c.seatEpoch)&&(a[b.project]=b)}function w(){let a;try{a=g().readFileSync(o(),"utf8")}catch(a){return a?.code==="ENOENT"?q():null}try{let b=JSON.parse(a);if(b.schemaVersion!==m)return null;let c=q();for(let[a,d]of(c.nextSeatEpoch="number"==typeof b.nextSeatEpoch&&Number.isInteger(b.nextSeatEpoch)&&b.nextSeatEpoch>=1?b.nextSeatEpoch:1,Object.entries(b.seats??{}))){let b=t(d);b&&b.project===a&&"active"===b.state&&b.conversationId&&v(c.seats,{...b,project:p(a)})}for(let[a,d]of Object.entries(b.pending??{})){let b=t(d);b&&b.project===a&&"pending"===b.state&&v(c.pending,{...b,project:p(a)})}for(let[a,d]of Object.entries(b.rollbacks??{})){let b=t(d);b&&b.conversationId&&(c.rollbacks[p(a)]=b)}for(let a of Array.isArray(b.revocations)?b.revocations:[])"string"==typeof a.project&&"string"==typeof a.conversationId&&"number"==typeof a.seatEpoch&&Number.isInteger(a.seatEpoch)&&"string"==typeof a.revokedAt&&c.revocations.push({project:p(a.project),conversationId:a.conversationId,seatEpoch:a.seatEpoch,revokedAt:a.revokedAt,successorConversationId:"string"==typeof a.successorConversationId?a.successorConversationId:null,triggeredBy:s(a.triggeredBy)});for(let a of Array.isArray(b.history)?b.history:[]){let b=t(a.seat);b&&("terminal_error"===a.reason||"superseded_epoch"===a.reason)&&"string"==typeof a.terminalizedAt&&c.history.push({seat:{...b,project:p(b.project)},reason:a.reason,terminalizedAt:a.terminalizedAt})}let d=Math.max(0,...Object.values(c.seats).map(a=>a.seatEpoch),...Object.values(c.pending).map(a=>a.seatEpoch),...Object.values(c.rollbacks).map(a=>a.seatEpoch),...c.revocations.map(a=>a.seatEpoch),...c.history.map(a=>a.seat.seatEpoch));return c.nextSeatEpoch<=d&&(c.nextSeatEpoch=d+1),c}catch{return null}}function x(){return w()??q()}function y(a){return void 0===a?Error("orchestrator seat evidence is malformed"):Error("orchestrator seat evidence is malformed",{cause:a})}function z(a,b){if(void 0===a)return{};if(!a||"object"!=typeof a||Array.isArray(a))throw y(Error(`${b} is invalid`));return a}function A(a,b){if(void 0===a)return[];if(!Array.isArray(a))throw y(Error(`${b} is invalid`));return a}function B(){let a,b;try{a=g().readFileSync(o(),"utf8")}catch(a){if(a&&"object"==typeof a&&"ENOENT"===a.code)return{raw:null,normalized:q()};throw a}try{b=JSON.parse(a)}catch(a){throw y(a)}if(!b||"object"!=typeof b||Array.isArray(b))throw y();let c=b;if(c.schemaVersion!==m||"number"!=typeof c.nextSeatEpoch||!Number.isInteger(c.nextSeatEpoch)||c.nextSeatEpoch<1)throw y();let d=q();for(let[a,b]of(d.nextSeatEpoch=c.nextSeatEpoch,Object.entries(z(c.seats,"seats")))){let c=t(b);if(!c||c.project!==a||"active"!==c.state||!c.conversationId)throw y();let e=p(a);if(d.seats[e])throw y();d.seats[e]={...c,project:e}}for(let[a,b]of Object.entries(z(c.pending,"pending"))){let c=t(b);if(!c||c.project!==a||"pending"!==c.state)throw y();let e=p(a);if(d.pending[e])throw y();d.pending[e]={...c,project:e}}for(let a of A(c.revocations,"revocations")){if(!a||"object"!=typeof a||"string"!=typeof a.project||!a.project||"string"!=typeof a.conversationId||!a.conversationId||"number"!=typeof a.seatEpoch||!Number.isInteger(a.seatEpoch)||a.seatEpoch<1||"string"!=typeof a.revokedAt||void 0!==a.successorConversationId&&null!==a.successorConversationId&&"string"!=typeof a.successorConversationId)throw y();d.revocations.push({project:p(a.project),conversationId:a.conversationId,seatEpoch:a.seatEpoch,revokedAt:a.revokedAt,successorConversationId:a.successorConversationId??null,triggeredBy:s(a.triggeredBy)})}for(let a of A(c.history,"history")){let b=t(a?.seat);if(!a||!b||"terminal_error"!==a.reason&&"superseded_epoch"!==a.reason||"string"!=typeof a.terminalizedAt)throw y();d.history.push({seat:{...b,project:p(b.project)},reason:a.reason,terminalizedAt:a.terminalizedAt})}return{raw:c,normalized:d}}function C(a){r(o(),a)}function D(a){let b=x(),c=p(a);return{active:b.seats[c]??null,pending:b.pending[c]??null,history:b.history.filter(a=>a.seat.project===c)}}function E(a){return(0,j.oV)(()=>{let b,c=x(),d=p(a.project),e=c.seats[d];if(e&&e.intent.clientRequestId===a.clientRequestId)return{kind:"completed",seat:e};let f=c.pending[d];if(f&&null===f.intent.error&&f.intent.clientRequestId===a.clientRequestId)return{kind:"replay",seat:f};if(f){if(!(null!==f.intent.error||void 0!==e&&f.seatEpoch<e.seatEpoch))return{kind:"in_progress",seat:f};b=u(c,{seat:f,reason:null!==f.intent.error?"terminal_error":"superseded_epoch",terminalizedAt:a.now??new Date().toISOString()}),delete c.pending[d]}let g={project:d,seatEpoch:c.nextSeatEpoch,conversationId:a.conversationId??null,path:null,engine:a.engine?.trim()||null,model:a.model?.trim()||null,runtimeIdentityFrozen:!!(a.engine?.trim()&&a.model?.trim()),mandate:a.mandate,promptVersion:a.promptVersion??null,predecessorConversationId:null,triggeredBy:a.triggeredBy??null,state:"pending",intent:{clientRequestId:a.clientRequestId,mode:a.mode,launchId:null,error:null},designatedAt:a.now??new Date().toISOString(),activatedAt:null};return c.nextSeatEpoch+=1,c.pending[d]=g,C(c),{kind:"begun",seat:g,...b?{terminalized:b}:{}}})}function F(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(d&&d.intent.clientRequestId===a.clientRequestId)return{kind:"replay",seat:d};let e=b.pending[c];if(!e||e.intent.clientRequestId!==a.clientRequestId)return{kind:"missing"};let f=a.now??new Date().toISOString(),g=null;d&&d.conversationId&&d.conversationId!==a.conversationId&&(g={project:c,conversationId:d.conversationId,seatEpoch:d.seatEpoch,revokedAt:f,successorConversationId:a.conversationId,triggeredBy:e.triggeredBy??null},b.revocations.push(g)),"spawn"===e.intent.mode&&null===a.path&&d?.conversationId&&d.conversationId!==a.conversationId?b.rollbacks[c]=d:delete b.rollbacks[c];let h={...e,conversationId:a.conversationId,path:a.path,engine:e.engine??(a.engine?.trim()||null),model:e.model??(a.model?.trim()||null),runtimeIdentityFrozen:!0===e.runtimeIdentityFrozen||!!(a.engine||a.model),predecessorConversationId:g?.conversationId??e.predecessorConversationId,state:"active",intent:{...e.intent,launchId:a.launchId??e.intent.launchId,error:null},activatedAt:f};return delete b.pending[c],b.seats[c]=h,C(b),{kind:"activated",seat:h,revoked:g}})}function G(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.conversationId!==a.conversationId)return null;let e=d.engine??(a.engine?.trim()||null),f=d.model??(a.model?.trim()||null);if(e===d.engine&&f===d.model)return d;let g={...d,engine:e,model:f};return b.seats[c]=g,C(b),g})}function H(a,b,c,d){return(0,j.oV)(()=>{let e=x(),f=p(a),g=e.pending[f];if(!g||g.intent.clientRequestId!==b)return null;g.intent.error=c.slice(0,500);let h=u(e,{seat:g,reason:"terminal_error",terminalizedAt:d??new Date().toISOString()});return delete e.pending[f],C(e),h})}function I(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.intent.clientRequestId!==a.clientRequestId||"active"!==d.state||"spawn"!==d.intent.mode||null!==d.path||!d.conversationId)return null;let e=a.now??new Date().toISOString(),f=b.rollbacks[c]??null,g=f?null:[...b.revocations].reverse().find(a=>a.project===c&&a.successorConversationId===d.conversationId)?.conversationId??null,h=f??(g?a.restorableSeat?.({conversationId:g,stillborn:d})??null:null),i=!!(h?.conversationId&&a.resolvable&&!a.resolvable(h.conversationId)),j=i?null:h,k=null;j?.conversationId?(k={...j,project:c,seatEpoch:b.nextSeatEpoch,state:"active",activatedAt:e},b.nextSeatEpoch+=1,b.seats[c]=k):delete b.seats[c],b.revocations.push({project:c,conversationId:d.conversationId,seatEpoch:d.seatEpoch,revokedAt:e,successorConversationId:k?.conversationId??null,triggeredBy:d.triggeredBy??null}),delete b.rollbacks[c];let l=i?`${a.error}; the predecessor ${h.conversationId} it would have been rolled back to is no longer resolvable either, so the project is left undesignated`:a.error,m=u(b,{seat:{...d,intent:{...d.intent,error:l.slice(0,500)}},reason:"terminal_error",terminalizedAt:e});return C(b),{terminalized:m,restored:k}})}function J(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.intent.clientRequestId!==a.clientRequestId||d.conversationId!==a.conversationId)return null;if(d.path===a.path&&!b.rollbacks[c])return d;let e={...d,path:a.path};return b.seats[c]=e,delete b.rollbacks[c],C(b),e})}function K(){return Object.values(x().seats)}function L(){let a=w();return null===a?null:Object.values(a.seats)}function M(a){let b=w();if(null===b)return null;let c=p(a);return{active:b.seats[c]??null,pending:b.pending[c]??null}}function N(){return Object.values(B().normalized.seats)}function O(a){0!==a.length&&(0,j.oV)(()=>{let b=B();if(!b.raw||0===Object.keys(b.normalized.seats).length)return;let c=new Map(a.map(a=>[a.legacyPath,a.sharedPath])),d=z(b.raw.seats,"seats"),e=!1;for(let a of Object.values(d)){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.path)continue;let b=c.get(a.path);b&&(a.path=b,e=!0)}e&&r(o(),b.raw)})}function P(){return x().revocations}function Q(a=a=>a){let b=w();if(null===b)return null;let c=new Map,d=b=>{if(!b.conversationId)return;let d=a(b.conversationId);c.set(d,Math.max(c.get(d)??0,b.seatEpoch))};for(let a of Object.values(b.seats))d(a);for(let a of Object.values(b.pending))null===a.intent.error&&d(a);let e=new Set;for(let d of b.revocations){let b=a(d.conversationId);d.seatEpoch>=(c.get(b)??0)&&e.add(b)}return e}}};
|
|
1
|
+
"use strict";exports.id=5408,exports.ids=[5408],exports.modules={15408:(a,b,c)=>{c.r(b),c.d(b,{ORCHESTRATOR_SEATS_SCHEMA_VERSION:()=>m,ORCHESTRATOR_SEAT_HISTORY_CAP:()=>n,abandonStillbornOrchestratorSeat:()=>I,activeOrchestratorSeats:()=>K,activeOrchestratorSeatsForMigration:()=>N,activeOrchestratorSeatsOrUnknown:()=>L,beginOrchestratorSeatIntent:()=>E,canonicalOrchestratorProject:()=>p,completeOrchestratorSeatIntent:()=>F,confirmOrchestratorSeatMaterialization:()=>J,failOrchestratorSeatIntent:()=>H,orchestratorRevocations:()=>P,orchestratorSeatFor:()=>D,orchestratorSeatForOrUnknown:()=>M,readOrchestratorSeatFile:()=>x,rekeyOrchestratorSeatPaths:()=>O,repairOrchestratorSeatRuntimeIdentity:()=>G,revokedOrchestratorSeatConversationsOrUnknown:()=>Q});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(22962),k=c(91724),l=c(89940);let m=1,n=50,o=()=>(0,k.BQ)("orchestrator-seats.json");function p(a){return(0,l.G$)(a.trim())}function q(){return{schemaVersion:m,nextSeatEpoch:1,seats:{},pending:{},revocations:[],history:[],rollbacks:{}}}function r(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,JSON.stringify(b,null,2)+"\n","utf8"),g().renameSync(c,a)}function s(a){if(!a||"object"!=typeof a||Array.isArray(a)||"operator"!==a.kind&&"agent"!==a.kind)return null;let b="string"==typeof a.conversationId&&a.conversationId?a.conversationId:null,c="number"==typeof a.seatEpoch&&Number.isInteger(a.seatEpoch)&&a.seatEpoch>=1?a.seatEpoch:null;return{kind:a.kind,conversationId:b,seatEpoch:c}}function t(a){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.project||!a.project||"number"!=typeof a.seatEpoch||!Number.isInteger(a.seatEpoch)||a.seatEpoch<1||null!==a.conversationId&&"string"!=typeof a.conversationId||null!==a.path&&"string"!=typeof a.path||"string"!=typeof a.mandate||"pending"!==a.state&&"active"!==a.state)return null;let b=a.intent;if(!b||"string"!=typeof b.clientRequestId||!b.clientRequestId||"spawn"!==b.mode&&"existing"!==b.mode||"string"!=typeof a.designatedAt||null!==a.activatedAt&&"string"!=typeof a.activatedAt)return null;let c="string"==typeof a.engine&&a.engine.trim()?a.engine:null,d="string"==typeof a.model&&a.model.trim()?a.model:null,e="boolean"==typeof a.runtimeIdentityFrozen?a.runtimeIdentityFrozen:!!(c||d);return{project:a.project,seatEpoch:a.seatEpoch,conversationId:a.conversationId??null,path:a.path??null,engine:c,model:d,runtimeIdentityFrozen:e,mandate:a.mandate,..."string"==typeof a.roleTable?{roleTable:a.roleTable}:{},promptVersion:"number"==typeof a.promptVersion&&Number.isInteger(a.promptVersion)?a.promptVersion:null,predecessorConversationId:"string"==typeof a.predecessorConversationId?a.predecessorConversationId:null,triggeredBy:s(a.triggeredBy),state:a.state,intent:{clientRequestId:b.clientRequestId,mode:b.mode,launchId:"string"==typeof b.launchId?b.launchId:null,error:"string"==typeof b.error?b.error:null},designatedAt:a.designatedAt,activatedAt:a.activatedAt??null}}function u(a,b){return a.history.push(b),a.history.length>n&&a.history.splice(0,a.history.length-n),b}function v(a,b){let c=a[b.project];(!c||b.seatEpoch>c.seatEpoch)&&(a[b.project]=b)}function w(){let a;try{a=g().readFileSync(o(),"utf8")}catch(a){return a?.code==="ENOENT"?q():null}try{let b=JSON.parse(a);if(b.schemaVersion!==m)return null;let c=q();for(let[a,d]of(c.nextSeatEpoch="number"==typeof b.nextSeatEpoch&&Number.isInteger(b.nextSeatEpoch)&&b.nextSeatEpoch>=1?b.nextSeatEpoch:1,Object.entries(b.seats??{}))){let b=t(d);b&&b.project===a&&"active"===b.state&&b.conversationId&&v(c.seats,{...b,project:p(a)})}for(let[a,d]of Object.entries(b.pending??{})){let b=t(d);b&&b.project===a&&"pending"===b.state&&v(c.pending,{...b,project:p(a)})}for(let[a,d]of Object.entries(b.rollbacks??{})){let b=t(d);b&&b.conversationId&&(c.rollbacks[p(a)]=b)}for(let a of Array.isArray(b.revocations)?b.revocations:[])"string"==typeof a.project&&"string"==typeof a.conversationId&&"number"==typeof a.seatEpoch&&Number.isInteger(a.seatEpoch)&&"string"==typeof a.revokedAt&&c.revocations.push({project:p(a.project),conversationId:a.conversationId,seatEpoch:a.seatEpoch,revokedAt:a.revokedAt,successorConversationId:"string"==typeof a.successorConversationId?a.successorConversationId:null,triggeredBy:s(a.triggeredBy)});for(let a of Array.isArray(b.history)?b.history:[]){let b=t(a.seat);b&&("terminal_error"===a.reason||"superseded_epoch"===a.reason)&&"string"==typeof a.terminalizedAt&&c.history.push({seat:{...b,project:p(b.project)},reason:a.reason,terminalizedAt:a.terminalizedAt})}let d=Math.max(0,...Object.values(c.seats).map(a=>a.seatEpoch),...Object.values(c.pending).map(a=>a.seatEpoch),...Object.values(c.rollbacks).map(a=>a.seatEpoch),...c.revocations.map(a=>a.seatEpoch),...c.history.map(a=>a.seat.seatEpoch));return c.nextSeatEpoch<=d&&(c.nextSeatEpoch=d+1),c}catch{return null}}function x(){return w()??q()}function y(a){return void 0===a?Error("orchestrator seat evidence is malformed"):Error("orchestrator seat evidence is malformed",{cause:a})}function z(a,b){if(void 0===a)return{};if(!a||"object"!=typeof a||Array.isArray(a))throw y(Error(`${b} is invalid`));return a}function A(a,b){if(void 0===a)return[];if(!Array.isArray(a))throw y(Error(`${b} is invalid`));return a}function B(){let a,b;try{a=g().readFileSync(o(),"utf8")}catch(a){if(a&&"object"==typeof a&&"ENOENT"===a.code)return{raw:null,normalized:q()};throw a}try{b=JSON.parse(a)}catch(a){throw y(a)}if(!b||"object"!=typeof b||Array.isArray(b))throw y();let c=b;if(c.schemaVersion!==m||"number"!=typeof c.nextSeatEpoch||!Number.isInteger(c.nextSeatEpoch)||c.nextSeatEpoch<1)throw y();let d=q();for(let[a,b]of(d.nextSeatEpoch=c.nextSeatEpoch,Object.entries(z(c.seats,"seats")))){let c=t(b);if(!c||c.project!==a||"active"!==c.state||!c.conversationId)throw y();let e=p(a);if(d.seats[e])throw y();d.seats[e]={...c,project:e}}for(let[a,b]of Object.entries(z(c.pending,"pending"))){let c=t(b);if(!c||c.project!==a||"pending"!==c.state)throw y();let e=p(a);if(d.pending[e])throw y();d.pending[e]={...c,project:e}}for(let a of A(c.revocations,"revocations")){if(!a||"object"!=typeof a||"string"!=typeof a.project||!a.project||"string"!=typeof a.conversationId||!a.conversationId||"number"!=typeof a.seatEpoch||!Number.isInteger(a.seatEpoch)||a.seatEpoch<1||"string"!=typeof a.revokedAt||void 0!==a.successorConversationId&&null!==a.successorConversationId&&"string"!=typeof a.successorConversationId)throw y();d.revocations.push({project:p(a.project),conversationId:a.conversationId,seatEpoch:a.seatEpoch,revokedAt:a.revokedAt,successorConversationId:a.successorConversationId??null,triggeredBy:s(a.triggeredBy)})}for(let a of A(c.history,"history")){let b=t(a?.seat);if(!a||!b||"terminal_error"!==a.reason&&"superseded_epoch"!==a.reason||"string"!=typeof a.terminalizedAt)throw y();d.history.push({seat:{...b,project:p(b.project)},reason:a.reason,terminalizedAt:a.terminalizedAt})}return{raw:c,normalized:d}}function C(a){r(o(),a)}function D(a){let b=x(),c=p(a);return{active:b.seats[c]??null,pending:b.pending[c]??null,history:b.history.filter(a=>a.seat.project===c)}}function E(a){return(0,j.oV)(()=>{let b,c=x(),d=p(a.project),e=c.seats[d];if(e&&e.intent.clientRequestId===a.clientRequestId)return{kind:"completed",seat:e};let f=c.pending[d];if(f&&null===f.intent.error&&f.intent.clientRequestId===a.clientRequestId)return{kind:"replay",seat:f};if(f){if(!(null!==f.intent.error||void 0!==e&&f.seatEpoch<e.seatEpoch))return{kind:"in_progress",seat:f};b=u(c,{seat:f,reason:null!==f.intent.error?"terminal_error":"superseded_epoch",terminalizedAt:a.now??new Date().toISOString()}),delete c.pending[d]}let g={project:d,seatEpoch:c.nextSeatEpoch,conversationId:a.conversationId??null,path:null,engine:a.engine?.trim()||null,model:a.model?.trim()||null,runtimeIdentityFrozen:!!(a.engine?.trim()&&a.model?.trim()),mandate:a.mandate,..."string"==typeof a.roleTable?{roleTable:a.roleTable}:{},promptVersion:a.promptVersion??null,predecessorConversationId:null,triggeredBy:a.triggeredBy??null,state:"pending",intent:{clientRequestId:a.clientRequestId,mode:a.mode,launchId:null,error:null},designatedAt:a.now??new Date().toISOString(),activatedAt:null};return c.nextSeatEpoch+=1,c.pending[d]=g,C(c),{kind:"begun",seat:g,...b?{terminalized:b}:{}}})}function F(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(d&&d.intent.clientRequestId===a.clientRequestId)return{kind:"replay",seat:d};let e=b.pending[c];if(!e||e.intent.clientRequestId!==a.clientRequestId)return{kind:"missing"};let f=a.now??new Date().toISOString(),g=null;d&&d.conversationId&&d.conversationId!==a.conversationId&&(g={project:c,conversationId:d.conversationId,seatEpoch:d.seatEpoch,revokedAt:f,successorConversationId:a.conversationId,triggeredBy:e.triggeredBy??null},b.revocations.push(g)),"spawn"===e.intent.mode&&null===a.path&&d?.conversationId&&d.conversationId!==a.conversationId?b.rollbacks[c]=d:delete b.rollbacks[c];let h={...e,conversationId:a.conversationId,path:a.path,engine:e.engine??(a.engine?.trim()||null),model:e.model??(a.model?.trim()||null),runtimeIdentityFrozen:!0===e.runtimeIdentityFrozen||!!(a.engine||a.model),predecessorConversationId:g?.conversationId??e.predecessorConversationId,state:"active",intent:{...e.intent,launchId:a.launchId??e.intent.launchId,error:null},activatedAt:f};return delete b.pending[c],b.seats[c]=h,C(b),{kind:"activated",seat:h,revoked:g}})}function G(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.conversationId!==a.conversationId)return null;let e=d.engine??(a.engine?.trim()||null),f=d.model??(a.model?.trim()||null);if(e===d.engine&&f===d.model)return d;let g={...d,engine:e,model:f};return b.seats[c]=g,C(b),g})}function H(a,b,c,d){return(0,j.oV)(()=>{let e=x(),f=p(a),g=e.pending[f];if(!g||g.intent.clientRequestId!==b)return null;g.intent.error=c.slice(0,500);let h=u(e,{seat:g,reason:"terminal_error",terminalizedAt:d??new Date().toISOString()});return delete e.pending[f],C(e),h})}function I(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.intent.clientRequestId!==a.clientRequestId||"active"!==d.state||"spawn"!==d.intent.mode||null!==d.path||!d.conversationId)return null;let e=a.now??new Date().toISOString(),f=b.rollbacks[c]??null,g=f?null:[...b.revocations].reverse().find(a=>a.project===c&&a.successorConversationId===d.conversationId)?.conversationId??null,h=f??(g?a.restorableSeat?.({conversationId:g,stillborn:d})??null:null),i=!!(h?.conversationId&&a.resolvable&&!a.resolvable(h.conversationId)),j=i?null:h,k=null;j?.conversationId?(k={...j,project:c,seatEpoch:b.nextSeatEpoch,state:"active",activatedAt:e},b.nextSeatEpoch+=1,b.seats[c]=k):delete b.seats[c],b.revocations.push({project:c,conversationId:d.conversationId,seatEpoch:d.seatEpoch,revokedAt:e,successorConversationId:k?.conversationId??null,triggeredBy:d.triggeredBy??null}),delete b.rollbacks[c];let l=i?`${a.error}; the predecessor ${h.conversationId} it would have been rolled back to is no longer resolvable either, so the project is left undesignated`:a.error,m=u(b,{seat:{...d,intent:{...d.intent,error:l.slice(0,500)}},reason:"terminal_error",terminalizedAt:e});return C(b),{terminalized:m,restored:k}})}function J(a){return(0,j.oV)(()=>{let b=x(),c=p(a.project),d=b.seats[c];if(!d||d.intent.clientRequestId!==a.clientRequestId||d.conversationId!==a.conversationId)return null;if(d.path===a.path&&!b.rollbacks[c])return d;let e={...d,path:a.path};return b.seats[c]=e,delete b.rollbacks[c],C(b),e})}function K(){return Object.values(x().seats)}function L(){let a=w();return null===a?null:Object.values(a.seats)}function M(a){let b=w();if(null===b)return null;let c=p(a);return{active:b.seats[c]??null,pending:b.pending[c]??null}}function N(){return Object.values(B().normalized.seats)}function O(a){0!==a.length&&(0,j.oV)(()=>{let b=B();if(!b.raw||0===Object.keys(b.normalized.seats).length)return;let c=new Map(a.map(a=>[a.legacyPath,a.sharedPath])),d=z(b.raw.seats,"seats"),e=!1;for(let a of Object.values(d)){if(!a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.path)continue;let b=c.get(a.path);b&&(a.path=b,e=!0)}e&&r(o(),b.raw)})}function P(){return x().revocations}function Q(a=a=>a){let b=w();if(null===b)return null;let c=new Map,d=b=>{if(!b.conversationId)return;let d=a(b.conversationId);c.set(d,Math.max(c.get(d)??0,b.seatEpoch))};for(let a of Object.values(b.seats))d(a);for(let a of Object.values(b.pending))null===a.intent.error&&d(a);let e=new Set;for(let d of b.revocations){let b=a(d.conversationId);d.seatEpoch>=(c.get(b)??0)&&e.add(b)}return e}}};
|