commandmate 0.34.0 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +178 -165
- package/.next/app-path-routes-manifest.json +29 -29
- package/.next/build-manifest.json +2 -2
- package/.next/prerender-manifest.json +9 -9
- package/.next/required-server-files.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/versions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/app/update-check/route.js +1 -1
- package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/conversation/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/current-output/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/messages/route.js +1 -1
- package/.next/server/app/api/assistant/messages/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/session/route.js +1 -1
- package/.next/server/app/api/assistant/session/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/start/route.js +1 -1
- package/.next/server/app/api/assistant/start/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/terminal/route.js +1 -1
- package/.next/server/app/api/assistant/terminal/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/assistant/tools/route.js.nft.json +1 -1
- package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/capabilities/route.js +1 -1
- package/.next/server/app/api/capabilities/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/agent-event/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route.js +1 -1
- package/.next/server/app/api/hooks/claude-done/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/hooks/permission-request/route.js.nft.json +1 -1
- package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/[relayId]/cancel/route.js +1 -1
- package/.next/server/app/api/relays/[relayId]/cancel/route.js.nft.json +1 -1
- package/.next/server/app/api/relays/[relayId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/relays/route.js +1 -1
- package/.next/server/app/api/relays/route.js.nft.json +1 -1
- package/.next/server/app/api/relays/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/remote/pair/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route.js +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/clone/route.js +1 -1
- package/.next/server/app/api/repositories/clone/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/restore/route.js +1 -1
- package/.next/server/app/api/repositories/restore/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/route.js +1 -1
- package/.next/server/app/api/repositories/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/scan/route.js +1 -1
- package/.next/server/app/api/repositories/scan/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/sync/route.js +1 -1
- package/.next/server/app/api/repositories/sync/route.js.nft.json +1 -1
- package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-agents/route.js.nft.json +1 -1
- package/.next/server/app/api/settings/default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/settings/default-surface-mode/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/clear-composer/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-reference/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/env/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/notes/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/instances/opencode/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/diff/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/session/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/opencode/share/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/resolve-target/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route.js +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/config/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/cancel/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/apply-default-agents/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/worktrees/route.js +1 -1
- package/.next/server/app/api/worktrees/route.js.nft.json +1 -1
- package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
- package/.next/server/app/chat/page.js +2 -2
- package/.next/server/app/chat/page.js.nft.json +1 -1
- package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
- package/.next/server/app/login/page_client-reference-manifest.js +1 -1
- package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
- package/.next/server/app/more/page.js +2 -2
- package/.next/server/app/more/page.js.nft.json +1 -1
- package/.next/server/app/more/page_client-reference-manifest.js +1 -1
- package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +1 -1
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/repositories/page.js +2 -2
- package/.next/server/app/repositories/page.js.nft.json +1 -1
- package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
- package/.next/server/app/review/page.js +1 -1
- package/.next/server/app/review/page.js.nft.json +1 -1
- package/.next/server/app/review/page_client-reference-manifest.js +1 -1
- package/.next/server/app/sessions/page.js +1 -1
- package/.next/server/app/sessions/page.js.nft.json +1 -1
- package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/[skillId]/page.js +2 -2
- package/.next/server/app/skills/[skillId]/page.js.nft.json +1 -1
- package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/installed/page.js +2 -2
- package/.next/server/app/skills/installed/page.js.nft.json +1 -1
- package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
- package/.next/server/app/skills/page.js +1 -1
- package/.next/server/app/skills/page.js.nft.json +1 -1
- package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/page.js +11 -11
- package/.next/server/app/worktrees/[id]/page.js.nft.json +1 -1
- package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +29 -29
- package/.next/server/chunks/1210.js +1 -1
- package/.next/server/chunks/{6286.js → 1467.js} +6 -6
- package/.next/server/chunks/1886.js +1 -1
- package/.next/server/chunks/2980.js +1 -1
- package/.next/server/chunks/3077.js +1 -1
- package/.next/server/chunks/3241.js +1 -1
- package/.next/server/chunks/3323.js +1 -1
- package/.next/server/chunks/434.js +1 -0
- package/.next/server/chunks/4443.js +1 -1
- package/.next/server/chunks/450.js +1 -1
- package/.next/server/chunks/6130.js +1 -1
- package/.next/server/chunks/650.js +1 -1
- package/.next/server/chunks/6677.js +3 -3
- package/.next/server/chunks/7075.js +1 -1
- package/.next/server/chunks/7506.js +1 -1
- package/.next/server/chunks/7905.js +1 -1
- package/.next/server/chunks/8728.js +8 -0
- package/.next/server/chunks/8807.js +10 -10
- package/.next/server/chunks/8918.js +5 -5
- package/.next/server/chunks/9123.js +2 -2
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/pages/500.html +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/server/src/middleware.js +1 -1
- package/.next/server/src/middleware.js.map +1 -1
- package/.next/static/chunks/2407-b9001cc6041876e1.js +1 -0
- package/.next/static/chunks/{4322-dfd5a7119b5ba4fc.js → 4322-59a7dbd77a7763cc.js} +1 -1
- package/.next/static/chunks/4388-410b1d8ed0d8d98b.js +1 -0
- package/.next/static/chunks/4718-56ebb6e55073ed5e.js +1 -0
- package/.next/static/chunks/{2652-18b8fea64413467e.js → 4809-145884b958e7d9a6.js} +1 -1
- package/.next/static/chunks/app/chat/{page-e60d07c4c79602f0.js → page-609c9a0f5ce44799.js} +1 -1
- package/.next/static/chunks/app/error-c1dc1038d0a84a33.js +1 -0
- package/.next/static/chunks/app/global-error-49f765ecb7fd6527.js +1 -0
- package/.next/static/chunks/app/{layout-4c2f21e3f653ee4c.js → layout-114dc6e93e332392.js} +1 -1
- package/.next/static/chunks/app/more/{page-fc94f86aa881489e.js → page-7c5380e4a7561935.js} +1 -1
- package/.next/static/chunks/app/{page-26a42881c8648cd3.js → page-a4f03c188610c6c8.js} +1 -1
- package/.next/static/chunks/app/repositories/{page-2576158c8420fda0.js → page-a15efb4ce1d1721e.js} +1 -1
- package/.next/static/chunks/app/review/{page-35b99baaf3c93b38.js → page-90ac618489676cbc.js} +1 -1
- package/.next/static/chunks/app/sessions/{page-a3ab6f122ec60d5a.js → page-6486d9a643c1dc6f.js} +1 -1
- package/.next/static/chunks/app/skills/[skillId]/{page-06799157652e8fa9.js → page-844872df04f52943.js} +1 -1
- package/.next/static/chunks/app/skills/installed/{page-2f3987e3a131c8d0.js → page-566dfde26d7e63ba.js} +1 -1
- package/.next/static/chunks/app/skills/{page-e70bfcf5ed4e4865.js → page-7859540e8092aace.js} +1 -1
- package/.next/static/chunks/app/worktrees/[id]/page-3a58ae66e203f935.js +1 -0
- package/.next/trace +14 -13
- package/README.md +141 -24
- package/dist/cli/commands/remote.d.ts +93 -3
- package/dist/cli/commands/remote.d.ts.map +1 -1
- package/dist/cli/commands/remote.js +232 -9
- package/dist/cli/types/index.d.ts +9 -0
- package/dist/cli/types/index.d.ts.map +1 -1
- package/dist/cli/utils/api-client.d.ts.map +1 -1
- package/dist/cli/utils/api-client.js +11 -1
- package/dist/cli/utils/remote-state.d.ts +32 -0
- package/dist/cli/utils/remote-state.d.ts.map +1 -1
- package/dist/cli/utils/remote-state.js +12 -0
- package/dist/lib/detection/tools/verified-against.d.ts +20 -0
- package/dist/lib/detection/tools/verified-against.d.ts.map +1 -1
- package/dist/lib/detection/tools/verified-against.js +20 -0
- package/dist/server/server.js +204 -16
- package/dist/server/src/config/websocket-config.js +67 -0
- package/dist/server/src/lib/auto-yes-poller.js +40 -7
- package/dist/server/src/lib/db/agent-instances-db.js +11 -0
- package/dist/server/src/lib/detection/selection-shape.js +361 -3
- package/dist/server/src/lib/detection/tools/command-code/detect.js +96 -0
- package/dist/server/src/lib/detection/tools/command-code/dialog.js +314 -0
- package/dist/server/src/lib/detection/tools/verified-against.js +20 -0
- package/dist/server/src/lib/hooks/sources/opencode/ports.js +6 -0
- package/dist/server/src/lib/polling/response-checker.js +48 -2
- package/dist/server/src/lib/relay/relay-session-ref.js +15 -8
- package/dist/server/src/lib/ws-server.js +185 -6
- package/package.json +1 -1
- package/public/sw.js +12 -0
- package/.next/server/chunks/1049.js +0 -1
- package/.next/server/chunks/595.js +0 -8
- package/.next/static/chunks/4718-2d9f0397a8f931c4.js +0 -1
- package/.next/static/chunks/8361-0142beb59be2abf3.js +0 -1
- package/.next/static/chunks/app/error-27ab04bce6545dae.js +0 -1
- package/.next/static/chunks/app/global-error-7b761b8e181ffc1f.js +0 -1
- package/.next/static/chunks/app/worktrees/[id]/page-a39ec2a0732d11a6.js +0 -1
- /package/.next/static/{gniPBCKoXtbIOQey8kNcx → 0vChXhzA5YWj3f0D6A-Cn}/_buildManifest.js +0 -0
- /package/.next/static/{gniPBCKoXtbIOQey8kNcx → 0vChXhzA5YWj3f0D6A-Cn}/_ssgManifest.js +0 -0
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* Issue #331: WebSocket authentication via Cookie header
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.__internal = exports.WORKTREE_RENAMED_EVENT_TYPE = void 0;
|
|
8
|
+
exports.__internal = exports.WORKTREE_RENAMED_EVENT_TYPE = exports.REMOTE_ONLY_AUTH_SCOPE = exports.CM_INGRESS_HEADER = void 0;
|
|
9
|
+
exports.stampIngress = stampIngress;
|
|
10
|
+
exports.isIngressAuthExempt = isIngressAuthExempt;
|
|
9
11
|
exports.handleProxyUpgrade = handleProxyUpgrade;
|
|
10
12
|
exports.setupWebSocket = setupWebSocket;
|
|
11
13
|
exports.broadcast = broadcast;
|
|
@@ -38,6 +40,7 @@ const waiting_broadcast_1 = require("../lib/realtime/waiting-broadcast");
|
|
|
38
40
|
// build has two instances of it (`dist/server` + a `.next/server/chunks` copy).
|
|
39
41
|
// The registry is how a route handler's copy reaches the one holding sockets.
|
|
40
42
|
const publisher_registry_1 = require("../lib/realtime/publisher-registry");
|
|
43
|
+
const websocket_config_1 = require("../config/websocket-config");
|
|
41
44
|
const logger_1 = require("../lib/logger");
|
|
42
45
|
const logger = (0, logger_1.createLogger)('ws-server');
|
|
43
46
|
// Global state
|
|
@@ -52,6 +55,14 @@ const rooms = new Map();
|
|
|
52
55
|
* bare "clear the registry" would let a torn-down instance silence a newer one.
|
|
53
56
|
*/
|
|
54
57
|
let publisherHandle = null;
|
|
58
|
+
/**
|
|
59
|
+
* Issue #2502: the heartbeat sweep's interval, or null while no server is up.
|
|
60
|
+
*
|
|
61
|
+
* Module-scoped like `wss` and torn down with it — a timer that outlived
|
|
62
|
+
* `closeWebSocket` would go on pinging a `clients` map nobody reads, and CI
|
|
63
|
+
* shares one process across the whole suite.
|
|
64
|
+
*/
|
|
65
|
+
let heartbeatTimer = null;
|
|
55
66
|
const MAX_TERMINAL_INPUT_LENGTH = 4096;
|
|
56
67
|
const MAX_TERMINAL_SUBSCRIBERS_PER_SESSION = 4;
|
|
57
68
|
const TERMINAL_FALLBACK_CAPTURE_LINES = -200;
|
|
@@ -61,6 +72,59 @@ const TERMINAL_FALLBACK_CAPTURE_LINES = -200;
|
|
|
61
72
|
* Issue #671.
|
|
62
73
|
*/
|
|
63
74
|
const PROXY_ALLOWED_HOSTS = new Set(['localhost', '127.0.0.1']);
|
|
75
|
+
/**
|
|
76
|
+
* The header `server.ts` overwrites on every request and upgrade.
|
|
77
|
+
*
|
|
78
|
+
* Written out as a literal in `server.ts` would be a second spelling of the same
|
|
79
|
+
* name, so it lives here and `server.ts` imports it — that file already imports
|
|
80
|
+
* this module at eval time (`setupWebSocket`), which is why this is the one
|
|
81
|
+
* place the constant can live without adding a module graph to `server.ts`'s
|
|
82
|
+
* eval-time graph (see the `x-cm-raw-url` comment there for what that costs).
|
|
83
|
+
* `middleware.ts` cannot import it: it runs on the Edge runtime and this module
|
|
84
|
+
* is Node-only, so it inlines the same literal under the C001 rule that already
|
|
85
|
+
* duplicates the auth constants.
|
|
86
|
+
*/
|
|
87
|
+
exports.CM_INGRESS_HEADER = 'x-cm-ingress';
|
|
88
|
+
/**
|
|
89
|
+
* Value of `CM_AUTH_SCOPE` that exempts the local listener from authentication.
|
|
90
|
+
*
|
|
91
|
+
* Any other value — absent, misspelt, `all` — leaves every listener
|
|
92
|
+
* authenticated, which is the pre-#2489 behaviour and the fail-closed default.
|
|
93
|
+
*/
|
|
94
|
+
exports.REMOTE_ONLY_AUTH_SCOPE = 'remote-only';
|
|
95
|
+
/**
|
|
96
|
+
* Stamp the listener identity onto a request, discarding whatever the client
|
|
97
|
+
* sent under the same name.
|
|
98
|
+
*
|
|
99
|
+
* A plain assignment, not a merge: Node joins a repeated unknown header into
|
|
100
|
+
* one comma-separated string, and assigning replaces that string wholesale.
|
|
101
|
+
* Called for EVERY request on EVERY listener — a listener that forgot to stamp
|
|
102
|
+
* would leave the caller's own value in place, which is the one way this scheme
|
|
103
|
+
* can fail open.
|
|
104
|
+
*
|
|
105
|
+
* @param headers - The mutable `req.headers` of an incoming request or upgrade
|
|
106
|
+
* @param ingress - The listener the request arrived on
|
|
107
|
+
*/
|
|
108
|
+
function stampIngress(headers, ingress) {
|
|
109
|
+
headers[exports.CM_INGRESS_HEADER] = ingress;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Whether this request may skip authentication because of where it arrived.
|
|
113
|
+
*
|
|
114
|
+
* Fail-closed on both halves: the scope has to be exactly `remote-only`, and
|
|
115
|
+
* the stamp has to be exactly `local`. An unstamped request (no listener
|
|
116
|
+
* claimed it), an array value (a repeated header that somehow survived) and an
|
|
117
|
+
* unknown value all authenticate.
|
|
118
|
+
*
|
|
119
|
+
* @param headers - Request headers, after `server.ts` has stamped them
|
|
120
|
+
* @param env - Environment to read `CM_AUTH_SCOPE` from; defaults to the process's
|
|
121
|
+
* @returns true when the request came in on the local listener of a `remote-only` server
|
|
122
|
+
*/
|
|
123
|
+
function isIngressAuthExempt(headers, env = process.env) {
|
|
124
|
+
if (env.CM_AUTH_SCOPE !== exports.REMOTE_ONLY_AUTH_SCOPE)
|
|
125
|
+
return false;
|
|
126
|
+
return headers[exports.CM_INGRESS_HEADER] === 'local';
|
|
127
|
+
}
|
|
64
128
|
/**
|
|
65
129
|
* Write a minimal HTTP error response to a raw upgrade socket and destroy it.
|
|
66
130
|
* Used for 4xx / 5xx rejections in the /proxy/<prefix> upgrade branch.
|
|
@@ -234,11 +298,85 @@ function isExpectedWebSocketError(error) {
|
|
|
234
298
|
error.message?.includes('ECONNRESET') ||
|
|
235
299
|
error.message?.includes('EPIPE'));
|
|
236
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* One heartbeat sweep over every connected client (Issue #2502).
|
|
303
|
+
*
|
|
304
|
+
* The `ws` library's standard liveness recipe, with one addition. The recipe:
|
|
305
|
+
* a connection that has not ponged since the previous sweep is gone — the peer
|
|
306
|
+
* crashed, or the path between us is half-open — so `terminate()` it rather
|
|
307
|
+
* than `close()` it. A close handshake needs a live peer to answer, which is
|
|
308
|
+
* exactly what is in question, so `close()` on a dead path just parks the
|
|
309
|
+
* socket in CLOSING until the OS TCP timeout fires, minutes later, with the
|
|
310
|
+
* room membership and any terminal subscription still held open the whole time.
|
|
311
|
+
*
|
|
312
|
+
* The addition is the application-level beat. A browser answers protocol pings
|
|
313
|
+
* for free but exposes neither the ping nor its own pong to page JavaScript, so
|
|
314
|
+
* the ping alone only ever teaches the SERVER that a client is gone. The extra
|
|
315
|
+
* frame is what lets the tab reach the same conclusion about us
|
|
316
|
+
* (`useWebSocket`'s liveness check).
|
|
317
|
+
*
|
|
318
|
+
* Exported through `__internal` so the behaviour can be tested without waiting
|
|
319
|
+
* {@link WS_SERVER_HEARTBEAT_INTERVAL_MS} for a real interval to fire.
|
|
320
|
+
*/
|
|
321
|
+
function runHeartbeatSweep() {
|
|
322
|
+
clients.forEach((clientInfo, ws) => {
|
|
323
|
+
if (!clientInfo.isAlive) {
|
|
324
|
+
logger.warn('heartbeat:terminate', { rooms: clientInfo.worktreeIds.size });
|
|
325
|
+
try {
|
|
326
|
+
ws.terminate();
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
// Already destroyed; the disconnect bookkeeping below still has to run.
|
|
330
|
+
}
|
|
331
|
+
// `terminate()` emits 'close' and that handler cleans up too, but this is
|
|
332
|
+
// not belt-and-braces: on an already-destroyed socket no event fires at
|
|
333
|
+
// all, and `handleDisconnect` is idempotent (it returns early for a ws it
|
|
334
|
+
// no longer knows). Deleting the current key mid-`forEach` is defined
|
|
335
|
+
// behaviour for a Map.
|
|
336
|
+
handleDisconnect(ws);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
clientInfo.isAlive = false;
|
|
340
|
+
try {
|
|
341
|
+
ws.ping();
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
logger.error('heartbeat:ping-failed', {
|
|
345
|
+
error: error instanceof Error ? error.message : String(error),
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
if (ws.readyState !== ws_1.WebSocket.OPEN)
|
|
349
|
+
return;
|
|
350
|
+
try {
|
|
351
|
+
ws.send(JSON.stringify({ type: websocket_config_1.WS_HEARTBEAT_MESSAGE_TYPE, at: Date.now() }));
|
|
352
|
+
}
|
|
353
|
+
catch {
|
|
354
|
+
// Best-effort: a failing send means the socket is already going away, and
|
|
355
|
+
// the next sweep terminates it.
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
/** Start the heartbeat sweep, replacing any previous one. */
|
|
360
|
+
function startHeartbeat() {
|
|
361
|
+
stopHeartbeat();
|
|
362
|
+
heartbeatTimer = setInterval(runHeartbeatSweep, websocket_config_1.WS_SERVER_HEARTBEAT_INTERVAL_MS);
|
|
363
|
+
// Never the reason the process stays alive: `commandmate stop` and the CLI's
|
|
364
|
+
// short-lived server should not have to wait out a 30s tick.
|
|
365
|
+
heartbeatTimer.unref?.();
|
|
366
|
+
}
|
|
367
|
+
/** Stop the heartbeat sweep. Safe to call when none is running. */
|
|
368
|
+
function stopHeartbeat() {
|
|
369
|
+
if (heartbeatTimer !== null) {
|
|
370
|
+
clearInterval(heartbeatTimer);
|
|
371
|
+
heartbeatTimer = null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
237
374
|
/**
|
|
238
375
|
* Setup WebSocket server on HTTP or HTTPS server
|
|
239
376
|
* Issue #331: Added auth check on WebSocket upgrade
|
|
240
377
|
*
|
|
241
378
|
* @param server - HTTP or HTTPS server instance
|
|
379
|
+
* @param options - Extra listeners to serve the same WebSocket from (Issue #2489)
|
|
242
380
|
*
|
|
243
381
|
* @example
|
|
244
382
|
* ```typescript
|
|
@@ -247,7 +385,7 @@ function isExpectedWebSocketError(error) {
|
|
|
247
385
|
* server.listen(3000);
|
|
248
386
|
* ```
|
|
249
387
|
*/
|
|
250
|
-
function setupWebSocket(server) {
|
|
388
|
+
function setupWebSocket(server, options) {
|
|
251
389
|
wss = new ws_1.WebSocketServer({ noServer: true });
|
|
252
390
|
// Issue #2220: this instance now owns the sockets, so publish the capability
|
|
253
391
|
// the other module instances have to borrow. Registered before anything can
|
|
@@ -261,8 +399,11 @@ function setupWebSocket(server) {
|
|
|
261
399
|
// — and so the closure it registers is the one holding *this* bundle's `rooms`
|
|
262
400
|
// map, which is what a broadcast has to reach.
|
|
263
401
|
(0, waiting_broadcast_1.startWaitingStatusBroadcast)(handleBroadcast);
|
|
402
|
+
// Issue #2502: and the liveness sweep, for the same lifetime reason — it has
|
|
403
|
+
// to die with this `wss`, not with the process.
|
|
404
|
+
startHeartbeat();
|
|
264
405
|
// Handle upgrade requests - only accept app WebSocket connections, not Next.js HMR
|
|
265
|
-
|
|
406
|
+
const handleUpgrade = (request, socket, head) => {
|
|
266
407
|
const pathname = request.url || '/';
|
|
267
408
|
// Let Next.js handle its own HMR WebSocket connections in development.
|
|
268
409
|
// In production there are no /_next/ WebSocket connections (no HMR).
|
|
@@ -292,7 +433,13 @@ function setupWebSocket(server) {
|
|
|
292
433
|
}
|
|
293
434
|
}
|
|
294
435
|
// Issue #331: WebSocket authentication via Cookie header
|
|
295
|
-
|
|
436
|
+
//
|
|
437
|
+
// Issue #2489: `isIngressAuthExempt` is the ONLY thing that can skip this,
|
|
438
|
+
// and it reads the same stamped header `middleware.ts` reads. HTTP and WS
|
|
439
|
+
// have to agree here: a phone drives the terminal over this socket, so a WS
|
|
440
|
+
// path that exempted more than the HTTP path would hand the tunnel a live
|
|
441
|
+
// shell while the screen behind it still asked for a password.
|
|
442
|
+
if ((0, auth_1.isAuthEnabled)() && !isIngressAuthExempt(request.headers)) {
|
|
296
443
|
const cookieHeader = request.headers.cookie || '';
|
|
297
444
|
const cookies = (0, auth_1.parseCookies)(cookieHeader);
|
|
298
445
|
const token = cookies[auth_1.AUTH_COOKIE_NAME];
|
|
@@ -334,7 +481,14 @@ function setupWebSocket(server) {
|
|
|
334
481
|
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
335
482
|
wss.emit('connection', ws, request);
|
|
336
483
|
});
|
|
337
|
-
}
|
|
484
|
+
};
|
|
485
|
+
// Issue #2489: every listener gets the same handler, and therefore the same
|
|
486
|
+
// auth decision. `server.ts` has already stamped `x-cm-ingress` by the time
|
|
487
|
+
// this runs (its stamping listener is registered first, and listeners fire in
|
|
488
|
+
// registration order), so the handler never has to know which socket it is on.
|
|
489
|
+
for (const target of [server, ...(options?.additionalServers ?? [])]) {
|
|
490
|
+
target.on('upgrade', handleUpgrade);
|
|
491
|
+
}
|
|
338
492
|
// Handle WebSocket server errors (e.g., invalid frames from clients)
|
|
339
493
|
wss.on('error', (error) => {
|
|
340
494
|
logger.error('server:error', { error: error.message });
|
|
@@ -346,8 +500,17 @@ function setupWebSocket(server) {
|
|
|
346
500
|
ws,
|
|
347
501
|
worktreeIds: new Set(),
|
|
348
502
|
terminalSubscription: null,
|
|
503
|
+
isAlive: true,
|
|
349
504
|
};
|
|
350
505
|
clients.set(ws, clientInfo);
|
|
506
|
+
// Issue #2502: the other half of the liveness recipe. Browsers answer a
|
|
507
|
+
// protocol ping automatically, so a client needs no code for this to work —
|
|
508
|
+
// silence here is evidence about the path, not about the page.
|
|
509
|
+
ws.on('pong', () => {
|
|
510
|
+
const info = clients.get(ws);
|
|
511
|
+
if (info)
|
|
512
|
+
info.isAlive = true;
|
|
513
|
+
});
|
|
351
514
|
// Issue #573: Removed _socket direct access (as unknown as pattern).
|
|
352
515
|
// ws.on('error') handler below covers socket-level errors because the ws library
|
|
353
516
|
// internally propagates underlying socket errors to the WebSocket 'error' event
|
|
@@ -1036,6 +1199,10 @@ function closeWebSocket() {
|
|
|
1036
1199
|
if (wasOwner || (0, publisher_registry_1.getRoomPublisher)() === null) {
|
|
1037
1200
|
(0, waiting_broadcast_1.stopWaitingStatusBroadcast)();
|
|
1038
1201
|
}
|
|
1202
|
+
// Issue #2502: unconditionally — unlike the waiting-edge subscription this is
|
|
1203
|
+
// a plain module-local timer, not a `globalThis` slot, so a superseded
|
|
1204
|
+
// instance clearing it cannot reach a live server's sweep.
|
|
1205
|
+
stopHeartbeat();
|
|
1039
1206
|
if (wss) {
|
|
1040
1207
|
// Close all client connections
|
|
1041
1208
|
clients.forEach((clientInfo) => {
|
|
@@ -1052,6 +1219,9 @@ function closeWebSocket() {
|
|
|
1052
1219
|
}
|
|
1053
1220
|
exports.__internal = {
|
|
1054
1221
|
handleMessage,
|
|
1222
|
+
runHeartbeatSweep,
|
|
1223
|
+
startHeartbeat,
|
|
1224
|
+
stopHeartbeat,
|
|
1055
1225
|
handleClientVersion,
|
|
1056
1226
|
handleProxyUpgrade,
|
|
1057
1227
|
handleTerminalSubscribe,
|
|
@@ -1059,17 +1229,26 @@ exports.__internal = {
|
|
|
1059
1229
|
handleTerminalResize,
|
|
1060
1230
|
handleTerminalUnsubscribe,
|
|
1061
1231
|
handleDisconnect,
|
|
1062
|
-
registerClientForTest(ws) {
|
|
1232
|
+
registerClientForTest(ws, isAlive = true) {
|
|
1063
1233
|
clients.set(ws, {
|
|
1064
1234
|
ws,
|
|
1065
1235
|
worktreeIds: new Set(),
|
|
1066
1236
|
terminalSubscription: null,
|
|
1237
|
+
isAlive,
|
|
1067
1238
|
});
|
|
1068
1239
|
},
|
|
1069
1240
|
getClientInfoForTest(ws) {
|
|
1070
1241
|
return clients.get(ws);
|
|
1071
1242
|
},
|
|
1243
|
+
/**
|
|
1244
|
+
* Every live client, for tests that hold the *client* end of a real socket and
|
|
1245
|
+
* therefore have no handle on the server-side `WebSocket` to look up by.
|
|
1246
|
+
*/
|
|
1247
|
+
listClientsForTest() {
|
|
1248
|
+
return Array.from(clients.values());
|
|
1249
|
+
},
|
|
1072
1250
|
resetStateForTest() {
|
|
1251
|
+
stopHeartbeat();
|
|
1073
1252
|
clients.clear();
|
|
1074
1253
|
rooms.clear();
|
|
1075
1254
|
},
|
package/package.json
CHANGED
package/public/sw.js
CHANGED
|
@@ -26,6 +26,18 @@ const OFFLINE_URL = '/offline';
|
|
|
26
26
|
const PRECACHE_URLS = [OFFLINE_URL];
|
|
27
27
|
|
|
28
28
|
// Denylist — never cached (mirror of EXCLUDED_PATH_PREFIXES).
|
|
29
|
+
//
|
|
30
|
+
// `/api` is load-bearing and is not a default anyone forgot to revisit: Issue
|
|
31
|
+
// #2504 asked for two of its GETs to be served from cache while revalidating,
|
|
32
|
+
// and was closed wontfix. The short reason is that a cache read in this file
|
|
33
|
+
// cannot be authenticated — the auth cookie is httpOnly and invisible here, the
|
|
34
|
+
// server sends no `Vary: Cookie`, and the token is one server-wide secret, so
|
|
35
|
+
// there is no identity to key a cache on. Whatever lands in the Cache API is
|
|
36
|
+
// readable by anyone who can open this origin in this browser profile.
|
|
37
|
+
// Note also that `matchesPrefix` below is a PREFIX match: `/api/worktrees` is
|
|
38
|
+
// 36 routes, among them current-output, files, env, messages and terminal.
|
|
39
|
+
// The rest of the reasoning is in src/lib/pwa/cache-policy.ts; the full argument
|
|
40
|
+
// is the design policy filed on Issue #2504.
|
|
29
41
|
const EXCLUDED_PATH_PREFIXES = ['/api', '/login', '/proxy'];
|
|
30
42
|
// Allowlist — cache-first (mirror of STATIC_CACHE_PREFIXES / STATIC_CACHE_EXACT).
|
|
31
43
|
const STATIC_CACHE_PREFIXES = ['/_next/static/', '/icons/'];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";exports.id=1049,exports.ids=[964,1049,8583],exports.modules={3421:(a,b,c)=>{Object.defineProperty(b,"I",{enumerable:!0,get:function(){return g}});let d=c(71237),e=c(55088),f=c(17679);async function g(a,b,c,g){if((0,d.isNodeNextResponse)(b)){var h;b.statusCode=c.status,b.statusMessage=c.statusText;let d=["set-cookie","www-authenticate","proxy-authenticate","vary"];null==(h=c.headers)||h.forEach((a,c)=>{if("x-middleware-set-cookie"!==c.toLowerCase())if("set-cookie"===c.toLowerCase())for(let d of(0,f.splitCookiesString)(a))b.appendHeader(c,d);else{let e=void 0!==b.getHeader(c);(d.includes(c.toLowerCase())||!e)&&b.appendHeader(c,a)}});let{originalResponse:i}=b;c.body&&"HEAD"!==a.method?await (0,e.pipeToNodeResponse)(c.body,i,g):i.end()}}},7329:(a,b,c)=>{c.d(b,{Hv:()=>m,W3:()=>k,uK:()=>l});var d=c(90787),e=c(52660),f=c(18201),g=c(23854),h=c(49798),i=c(67164);let j=(0,c(72626).h)("relay-service");function k(a,b){for(let c of[b.from.worktreeId,b.to.worktreeId])if(!(0,h.r)(a,c))return{ok:!1,refusal:{code:"RELAY_WORKTREE_NOT_FOUND",message:`Worktree '${c}' not found`,worktreeId:c}};let c=(0,g.$G)({from:b.from,to:b.to,parentHops:function(a,b){try{let g=(0,h.S)(a,b),i=(0,e.getMessages)(a,b.worktreeId,{limit:5,limitUnit:"pairs",cliToolId:g.cliToolId,instanceId:b.instanceId,matchResolvedInstance:!0}).filter(a=>"user"===a.role),j=i.findIndex(a=>"relay"===a.messageType);if(-1===j)return null;let k=i[j];for(let a=0;a<j;a+=1){var c;if(c=i[a],c.timestamp.getTime()<k.timestamp.getTime()||(0,f.pk)(c.content)!==(0,f.pk)(k.content))return null}let l=(0,e.parseRelayRequestId)(k.requestId);if(!l)return null;return(0,d.Ip)(a,l)?.hops??null}catch(a){return j.warn("relay-parent-lookup-failed",{worktreeId:b.worktreeId,instanceId:b.instanceId,error:a instanceof Error?a.message:String(a)}),null}}(a,b.from),allowRelayChain:!0===b.allowRelayChain,openBetween:(0,d.Oz)(a,b.from,b.to)});if((0,g.Qe)(c))return{ok:!1,refusal:c};let k=b.now??Date.now(),l=(0,d.CR)(a,{from:b.from,to:b.to,hops:c.hops,expiresAt:k+(0,g.AL)(b.ttlMs),now:k});return j.info("relay-opened",{relayId:l.id,from:`${l.from.worktreeId}/${l.from.instanceId}`,to:`${l.to.worktreeId}/${l.to.instanceId}`,hops:l.hops}),(0,i._)(a,l.id,"requested",(0,h.S)(a,l.from),(0,h.S)(a,l.to),k),{ok:!0,relay:l}}function l(a,b,c=Date.now()){let e=(0,d.Ip)(a,b);return e?(0,d.m_)(a,b,c)?(j.info("relay-cancelled",{relayId:b}),{ok:!0,relay:(0,d.Ip)(a,b)??e}):{ok:!1,reason:"already_closed",relay:e}:{ok:!1,reason:"not_found",relay:null}}function m(a,b){return(0,d.M4)(a,b)}},18201:(a,b,c)=>{c.d(b,{Ce:()=>g,pk:()=>e});let d=(0,c(72626).h)("lib/history/user-turn-recorder");function e(a){return a.replace(/\r\n?/g,"\n").split("\n").map(a=>a.replace(/[ \t ]+$/u,"")).join("\n").trim()}function f(a){return{worktreeId:a.worktreeId,cliToolId:a.cliToolId,instanceId:a.instanceId??a.cliToolId}}async function g(a,b,h,i,j={}){let k=a.instanceId??a.cliToolId,l=e(h);if(0===b.length||0===l.length)return{outcome:"skipped",messageId:null,timestampMs:null};try{let[{getDbInstance:g},m,{broadcastMessage:n}]=await Promise.all([Promise.resolve().then(c.bind(c,88807)),Promise.resolve().then(c.bind(c,52660)),Promise.resolve().then(c.bind(c,49640))]),o=g(),p=m.findMessageByRequestId(o,a.worktreeId,b);if(p)return{outcome:"already-recorded",messageId:p.id,timestampMs:p.timestamp.getTime()};let q=i>0?i:Date.now(),r=function(a,b,c,g,h,i,j,k){var l,m,n;let o=Math.min(j-12e4,k.adoptionFromMs??1/0),p=(l=a.findUnkeyedUserMessages(b,{worktreeId:c.worktreeId,cliToolId:c.cliToolId,instanceId:g,fromMs:o,toMs:j+12e4,includeRelayDelivered:!0}),m=i,n=j,l.filter(a=>e(a.content)===m).sort((a,b)=>Math.abs(a.timestamp.getTime()-n)-Math.abs(b.timestamp.getTime()-n)));for(let e of p)if(!e.requestId&&a.setMessageRequestId(b,e.id,h))return d.info("user-turn-adopted",{...f(c),requestId:h,messageId:e.id,driftMs:e.timestamp.getTime()-j}),{outcome:"adopted",messageId:e.id,timestampMs:e.timestamp.getTime()};let q=p.find(a=>a.requestId);return q?(d.info("user-turn-already-relayed",{...f(c),requestId:h,messageId:q.id,relayRequestId:q.requestId??null,driftMs:q.timestamp.getTime()-j}),{outcome:"already-recorded",messageId:q.id,timestampMs:q.timestamp.getTime()}):null}(m,o,a,k,b,l,q,j);if(r)return r;let s=m.createMessage(o,{worktreeId:a.worktreeId,role:"user",content:h,messageType:"normal",timestamp:new Date(q),cliToolId:a.cliToolId,instanceId:k,requestId:b});return n("message",{worktreeId:a.worktreeId,message:s}),d.info("user-turn-recorded",{...f(a),requestId:b,contentLength:h.length}),{outcome:"inserted",messageId:s.id,timestampMs:q}}catch(c){return d.error("user-turn-record-failed",{...f(a),requestId:b,error:c instanceof Error?c.message:String(c)}),{outcome:"failed",messageId:null,timestampMs:null}}}},40964:(a,b,c)=>{c.d(b,{m:()=>g});var d=c(15194);let e=/^[a-zA-Z0-9_-]+$/;function f(a){if(!e.test(a))throw Error(`Invalid session name format: ${a}`)}function g(a,b,c){let e=`mcbd-${a}-${b}`;if(!c||c===a)return f(e),e;let g=(0,d.pL)(c,a),h=g?`${e}-${g}`:e;return f(h),h}},95736:(a,b,c)=>{a.exports=c(44870)}};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
exports.id=595,exports.ids=[595],exports.modules={3453:(a,b,c)=>{"use strict";c.d(b,{Rh:()=>r,T1:()=>o,Z2:()=>m,c$:()=>n,nu:()=>q});var d=c(72626),e=c(80438);let f=(0,d.h)("ip-restriction"),g="::ffff:",h=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,i=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/,j=process.env.CM_ALLOWED_IPS?.trim()||"",k=process.env.CM_TRUST_PROXY?.trim()||"";""!==k&&"true"!==k&&"false"!==k&&(0,e.h)(f,"trust-proxy-unexpected",{value:k});let l="true"===k;function m(a){return a?a.toLowerCase().startsWith(g)?a.substring(g.length):a:""}function n(a,b){if(0===b.length)return!1;let c=function(a){let b=a.match(h);if(!b)return null;let c=[parseInt(b[1],10),parseInt(b[2],10),parseInt(b[3],10),parseInt(b[4],10)];for(let a of c)if(a<0||a>255)return null;return(c[0]<<24|c[1]<<16|c[2]<<8|c[3])>>>0}(m(a));if(null===c)return!1;for(let a of b)if((c&a.mask)>>>0===a.network)return!0;return!1}function o(a){if(l){let b=a.get("x-forwarded-for");if(b){let a=b.split(",")[0].trim();if(a)return a}}return a.get("x-real-ip")||null}let p=j.length>0?function(a){let b=a.trim();if(0===b.length)return[];let c=b.split(",").map(a=>a.trim()).filter(a=>a.length>0);if(c.length>256)throw Error(`CM_ALLOWED_IPS: too many entries (${c.length}). Maximum is 256.`);let d=[];for(let a of c){if(a.length>18)throw Error(`CM_ALLOWED_IPS: entry "${a}" exceeds maximum length of 18 characters.`);let b=a.match(i);if(b){let c=[parseInt(b[1],10),parseInt(b[2],10),parseInt(b[3],10),parseInt(b[4],10)],e=parseInt(b[5],10);for(let b of c)if(b<0||b>255)throw Error(`CM_ALLOWED_IPS: invalid octet in "${a}". Octets must be 0-255.`);if(e<0||e>32)throw Error(`CM_ALLOWED_IPS: invalid prefix length in "${a}". Must be 0-32.`);let f=(c[0]<<24|c[1]<<16|c[2]<<8|c[3])>>>0,g=0===e?0:0xffffffff<<32-e>>>0;d.push({network:(f&g)>>>0,mask:g});continue}let c=a.match(h);if(c){let b=[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10),parseInt(c[4],10)];for(let c of b)if(c<0||c>255)throw Error(`CM_ALLOWED_IPS: invalid octet in "${a}". Octets must be 0-255.`);let e=(b[0]<<24|b[1]<<16|b[2]<<8|b[3])>>>0;d.push({network:e,mask:0xffffffff});continue}throw Error(`CM_ALLOWED_IPS: invalid entry "${a}". Expected IPv4 address or CIDR notation.`)}return d}(j):[];function q(){return p}function r(){return j.length>0}},7015:(a,b,c)=>{"use strict";c.d(b,{Ds:()=>g});var d=c(81719);class e{constructor(a,b=3e4){this.cache=new Map,this.allAppsCache=null,this.lastRefresh=0,this.db=a,this.ttl=b}getTTL(){return this.ttl}isStale(){return Date.now()-this.lastRefresh>this.ttl}async refresh(){let a=(0,d.$i)(this.db);for(let b of(this.cache.clear(),a))this.cache.set(b.pathPrefix,b);this.allAppsCache=a,this.lastRefresh=Date.now()}async getByPathPrefix(a){return this.isStale()&&await this.refresh(),this.cache.get(a)??null}async getAll(){return this.isStale()&&await this.refresh(),this.allAppsCache??[]}invalidate(){this.cache.clear(),this.allAppsCache=null,this.lastRefresh=0}invalidateByIssueNo(a){this.invalidate()}}let f=null;function g(a){if(!f){if(!a)throw Error("Database instance required to initialize cache");f=new e(a)}return f}},23854:(a,b,c)=>{"use strict";c.d(b,{$G:()=>f,AL:()=>h,DZ:()=>d,Qe:()=>g,ie:()=>e});let d=4e3,e=15e3;function f(a){var b,c;if(b=a.from,c=a.to,b.worktreeId===c.worktreeId&&b.instanceId===c.instanceId)return{code:"RELAY_SELF_TARGET",message:"A session cannot relay a reply to itself. --reply-to must name a different worktree or a different agent instance."};let d=null===a.parentHops?1:a.parentHops+1;return null===a.parentHops||a.allowRelayChain?d>3?{code:"RELAY_HOPS_EXCEEDED",message:`Relay chains stop at 3 hops; this one would be ${d}. Report the reply to whoever asked instead of forwarding it again.`}:a.openBetween>=1?{code:"RELAY_DUPLICATE_PENDING",message:"There is already an open relay between these two sessions. Wait for it, or withdraw it with `commandmate relays cancel <id>`."}:{ok:!0,hops:d}:{code:"RELAY_CHAIN_BLOCKED",message:"The last message this session was given arrived over a relay, so opening another one would chain two deliveries together. Pass --allow-relay-chain if that is what you mean."}}function g(a){return"code"in a}function h(a){return void 0!==a&&Number.isFinite(a)?Math.min(6048e5,Math.max(6e4,Math.trunc(a))):864e5}},26838:(a,b,c)=>{"use strict";c.d(b,{E2:()=>o,Mj:()=>m,Sw:()=>l,lX:()=>p});var d=c(29021),e=c(33873),f=c(54325),g=c(90164);let h=/^v?\d+\.\d+\.\d+$/,i=/^[a-zA-Z0-9.\-\s_v]+$/,j=[".next","required-server-files.json"],k=globalThis.__versionCheckCache??(globalThis.__versionCheckCache={result:null,fetchedAt:0,rateLimitResetAt:null});function l(){return function(){try{let a=(0,d.readFileSync)((0,e.join)(process.cwd(),"package.json"),"utf-8"),b=JSON.parse(a);if("commandmate"===b.name&&"string"==typeof b.version&&b.version.length>0)return b.version;return null}catch{return null}}()??"0.34.0"}function m(){return l()}let n=null;function o(a){let b=n??=function(){{let a=function(){try{let a=(0,d.readFileSync)((0,e.join)(process.cwd(),...j),"utf-8"),b=JSON.parse(a),c=b.config?.env?.NEXT_PUBLIC_APP_VERSION;if("string"==typeof c&&c.length>0)return c;return null}catch{return null}}();if(a)return a}return"0.34.0"}();return(0,f.LE)(b,a)?{serverVersion:b,clientVersion:a}:null}async function p(){try{var a,b,c;if(null!==k.result&&Date.now()-k.fetchedAt<36e5||k.rateLimitResetAt&&(!(Date.now()>=k.rateLimitResetAt)||(k.rateLimitResetAt=null,0)))return k.result;let d=await fetch("https://api.github.com/repos/Kewton/CommandMate/releases/latest",{headers:{Accept:"application/vnd.github+json","User-Agent":`CommandMate/${m()}`},cache:"no-store",signal:AbortSignal.timeout(5e3)});if(403===d.status)return function(a){let b=a.headers.get("X-RateLimit-Reset");b?k.rateLimitResetAt=1e3*parseInt(b,10):k.rateLimitResetAt=Date.now()+36e5}(d),k.result;if(!d.ok)return k.result;let e=await d.json(),f=m(),j=e.tag_name.replace(/^v/,""),l={hasUpdate:function(a,b){if(!h.test(a)||!h.test(b))return!1;let c=a=>a.replace(/^v/,"").split(".").map(Number),[d,e,f]=c(a),[g,i,j]=c(b);return g!==d?g>d:i!==e?i>e:j>f}(f,e.tag_name),currentVersion:f,latestVersion:j,releaseUrl:(a=e.html_url).startsWith(g.Dk)?a:null,releaseName:(b=e.name,c=e.tag_name,i.test(b)&&b.length<=128?b:c),publishedAt:e.published_at};return k.result=l,k.fetchedAt=Date.now(),l}catch{return k.result}}},39727:()=>{},43925:(a,b,c)=>{"use strict";c.d(b,{PJ:()=>i,dz:()=>j,vQ:()=>g});var d=c(57836),e=c(23854);let f=(0,c(72626).h)("relay-triggers");function g(a,b,d,e){let g={worktreeId:a,cliToolId:b,instanceId:d??b};(async()=>{try{let{notifyRelayTurnCompleted:a}=await Promise.all([c.e(1634),c.e(9130),c.e(4443),c.e(8800),c.e(7905),c.e(1886),c.e(6337),c.e(3323),c.e(8918),c.e(650),c.e(6677),c.e(3077),c.e(1210)]).then(c.bind(c,71210));await a(g,{settled:e})}catch(c){f.warn("relay-turn-trigger-failed",{worktreeId:a,cliToolId:b,instanceId:g.instanceId,error:c instanceof Error?c.message:String(c)})}})()}async function h(){try{let{runRelayMaintenanceTick:a}=await Promise.all([c.e(1634),c.e(9130),c.e(4443),c.e(8800),c.e(7905),c.e(1886),c.e(6337),c.e(3323),c.e(8918),c.e(650),c.e(6677),c.e(3077),c.e(1210)]).then(c.bind(c,71210));await a()}catch(a){f.warn("relay-maintenance-failed",{error:a instanceof Error?a.message:String(a)})}}function i(){j(),globalThis.__relayTriggersUnsubscribe=(0,d.wN)(a=>{a.waiting&&"prompt"===a.kind&&function(a,b,d){let e={worktreeId:a,cliToolId:b,instanceId:d??b};(async()=>{try{let{notifyRelayPromptWaiting:a}=await Promise.all([c.e(1634),c.e(9130),c.e(4443),c.e(8800),c.e(7905),c.e(1886),c.e(6337),c.e(3323),c.e(8918),c.e(650),c.e(6677),c.e(3077),c.e(1210)]).then(c.bind(c,71210));a(e)}catch(c){f.warn("relay-prompt-trigger-failed",{worktreeId:a,cliToolId:b,instanceId:e.instanceId,error:c instanceof Error?c.message:String(c)})}})()}(a.worktreeId,a.cliToolId,a.instanceId)});let a=setInterval(()=>void h(),e.ie);a.unref?.(),globalThis.__relayMaintenanceTimer=a}function j(){let a=globalThis.__relayTriggersUnsubscribe;a&&(a(),globalThis.__relayTriggersUnsubscribe=void 0),globalThis.__relayMaintenanceTimer&&(clearInterval(globalThis.__relayMaintenanceTimer),globalThis.__relayMaintenanceTimer=void 0)}},47990:()=>{},49640:(a,b,c)=>{"use strict";c.r(b),c.d(b,{WORKTREE_RENAMED_EVENT_TYPE:()=>aj,__internal:()=>ap,broadcast:()=>ag,broadcastMessage:()=>ai,cleanupRooms:()=>am,closeWebSocket:()=>ao,handleProxyUpgrade:()=>T,hasRoomSubscribers:()=>ah,migrateWorktreeRooms:()=>ak,setupWebSocket:()=>U});var d=c(81503),e=c(91645),f=c(88081),g=c(3453),h=c(15194),i=c(40964),j=c(88807),k=c(56791);let l={capturePaneCalls:0,activeControlSessions:0,subscriberCount:0,cleanupCount:0,firstOutputLatencyCount:0,firstOutputLatencyTotalMs:0,firstOutputLatencyLastMs:null,firstOutputLatencyMinMs:null,firstOutputLatencyMaxMs:null};var m=c(79892),n=c(72626),o=c(79646);class p{push(a){if(0===a.length)return[];let b=(this.remainder+a).split("\n");this.remainder=b.pop()??"";let c=[];for(let a of b){let b=a.endsWith("\r")?a.slice(0,-1):a,d=this.parseLine(b);d&&c.push(d)}return c}flush(){if(0===this.remainder.length)return[];let a=this.parseLine(this.remainder);return this.remainder="",a?[a]:[]}parseLine(a){return 0===a.length?{type:"output",data:"\n"}:a.startsWith("%output ")?{type:"output",data:`${a.slice(8)}
|
|
2
|
-
`}:"%exit"===a||a.startsWith("%exit ")?{type:"exit",exitCode:null}:a.startsWith("%error ")?{type:"error",error:Error(a.slice(7))}:a.startsWith("%")?null:{type:"output",data:`${a}
|
|
3
|
-
`}}constructor(){this.remainder=""}}let q=(0,n.h)("tmux-control-client");class r{constructor(a={}){this.parser=new p,this.handlers=new Set,this.child=null,this.sessionName=null,this.idleTimer=null,this.started=!1,this.spawnProcess=a.spawnProcess??((a,b,c)=>(0,o.spawn)(a,b,c)),this.tmuxBinary=a.tmuxBinary??"tmux",this.idleTimeoutMs=a.idleTimeoutMs??3e4}start(a){this.started||(this.sessionName=a,this.child=this.spawnProcess(this.tmuxBinary,["-C","attach-session","-t",(0,m.lA)(a)],{stdio:"pipe"}),this.started=!0,this.child.stdout.setEncoding("utf8"),this.child.stdout.on("data",a=>{this.touch();let b="string"==typeof a?a:a.toString("utf8");for(let a of this.parser.push(b))this.emit(a)}),this.child.stderr.setEncoding("utf8"),this.child.stderr.on("data",a=>{let b="string"==typeof a?a:a.toString("utf8");this.emit({type:"error",error:Error(b.trim()||"tmux control stderr")})}),this.child.on("close",a=>{for(let a of this.parser.flush())this.emit(a);this.emit({type:"exit",exitCode:a}),this.stop()}),this.child.on("error",a=>{this.emit({type:"error",error:a}),this.stop()}),this.resetIdleTimer(),q.debug("start",{sessionName:a}))}onEvent(a){return this.handlers.add(a),()=>{this.handlers.delete(a)}}sendInput(a){if(!this.child?.stdin.writable)throw Error("Tmux control client is not writable");this.touch(),this.child.stdin.write(a)}resize(a,b){if(!this.child?.stdin.writable)throw Error("Tmux control client is not writable");this.touch(),this.child.stdin.write(`refresh-client -C ${a}x${b}
|
|
4
|
-
`)}stop(){this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null),this.child&&(this.child.removeAllListeners(),this.child.stdout.removeAllListeners(),this.child.stderr.removeAllListeners(),this.child.kill(),this.child=null),this.started=!1}isStarted(){return this.started}setSessionName(a){this.sessionName=a}emit(a){for(let b of this.handlers)b(a)}touch(){this.resetIdleTimer()}resetIdleTimer(){this.idleTimeoutMs<=0||(this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{q.debug("idle-timeout",{sessionName:this.sessionName}),this.stop()},this.idleTimeoutMs))}}let s=(0,n.h)("tmux-control-registry");class t{constructor(a={}){this.entries=new Map,this.handlers=new Map,this.idleTimeoutMs=a.idleTimeoutMs??15e3,this.createClient=a.createClient??(()=>new r(a))}subscribe(a,b,c){let d=this.ensureEntry(a);d.subscribers.add(b),this.cancelIdleCleanup(d),this.updateMetrics();let e=this.handlers.get(a);return e||(e=new Set,this.handlers.set(a,e)),e.add(c),()=>{e?.delete(c),this.unsubscribe(a,b)}}sendInput(a,b){let c=this.entries.get(a);if(!c)throw Error(`No control client registered for ${a}`);c.client.sendInput(b)}resize(a,b,c){let d=this.entries.get(a);if(!d)throw Error(`No control client registered for ${a}`);d.client.resize(b,c)}hasSession(a){return this.entries.has(a)}getSubscriberCount(a){return this.entries.get(a)?.subscribers.size??0}getTotalSubscriberCount(){let a=0;for(let b of this.entries.values())a+=b.subscribers.size;return a}getSessionCount(){return this.entries.size}shutdown(){for(let[a,b]of this.entries)this.teardownEntry(a,b);this.entries.clear(),this.handlers.clear(),this.updateMetrics()}renameSession(a,b){if(a===b)return!1;let c=this.entries.get(a);if(!c)return!1;if(this.entries.has(b))return s.warn("rename:destination-occupied",{oldName:a,newName:b}),!1;this.entries.delete(a),c.sessionName=b,this.entries.set(b,c),c.client.setSessionName(b);let d=this.handlers.get(a);return d&&(this.handlers.delete(a),this.handlers.set(b,d)),s.debug("rename",{oldName:a,newName:b}),!0}ensureEntry(a){let b=this.entries.get(a);if(b)return b;let c=this.createClient(a);c.start(a);let d={client:c,subscribers:new Set,unsubscribeClientEvent:()=>{},idleTimer:null,sessionName:a};return d.unsubscribeClientEvent=c.onEvent(a=>{let b=this.handlers.get(d.sessionName);if(b)for(let c of b)c(a);("exit"===a.type||"error"===a.type)&&this.deleteEntry(d.sessionName)}),this.entries.set(a,d),this.updateMetrics(),d}unsubscribe(a,b){let c=this.entries.get(a);c&&(c.subscribers.delete(b),this.updateMetrics(),0===c.subscribers.size&&this.scheduleIdleCleanup(a,c))}scheduleIdleCleanup(a,b){if(this.idleTimeoutMs<=0)return void this.deleteEntry(a);this.cancelIdleCleanup(b),b.idleTimer=setTimeout(()=>{s.debug("idle-cleanup",{sessionName:b.sessionName}),this.deleteEntry(b.sessionName)},this.idleTimeoutMs)}cancelIdleCleanup(a){a.idleTimer&&(clearTimeout(a.idleTimer),a.idleTimer=null)}deleteEntry(a){let b=this.entries.get(a);b&&(this.teardownEntry(a,b),this.entries.delete(a),this.handlers.delete(a),this.updateMetrics())}teardownEntry(a,b){this.cancelIdleCleanup(b),b.unsubscribeClientEvent(),b.client.stop(),l.cleanupCount+=1}updateMetrics(){l.activeControlSessions=Math.max(0,this.getSessionCount()),l.subscriberCount=Math.max(0,this.getTotalSubscriberCount())}}let u=null,v={streamingOutput:!0,explicitResize:!0,snapshotFallback:!0};class w{constructor(a={}){this.registry=a.registry??(u||(u=new t),u)}async ensureSession(a,b){await (0,m.N)(a)||await (0,m.jw)(a,b)}async sessionExists(a){return(0,m.N)(a)}async sendInput(a,b){if(this.registry.hasSession(a))return void this.registry.sendInput(a,b);await (0,m.V1)(a,b)}async sendSpecialKey(a,b){if("Escape"!==b&&"C-c"!==b&&"C-d"!==b&&"C-m"!==b&&"Enter"!==b)throw Error(`Unsupported special key for ControlModeTmuxTransport: ${b}`);await (0,m.ds)(a,b)}async resize(a,b,c){this.registry.resize(a,b,c)}async captureSnapshot(a,b){return l.capturePaneCalls+=1,(0,m.Xg)(a,b)}async subscribe(a,b){let c=`sub-${Date.now()}-${Math.random().toString(36).slice(2,10)}`,d=this.registry.subscribe(a,c,a=>{"output"===a.type?b.onOutput(a.data):"exit"===a.type?b.onExit?.({exitCode:a.exitCode}):b.onError(a.error)});return{async unsubscribe(){d()}}}getCapabilities(){return v}getSubscriberCount(a){return this.registry.getSubscriberCount(a)}renameSession(a,b){return this.registry.renameSession(a,b)}async killSession(a){return(0,m.fY)(a)}}let x=null;function y(){return x||(x=new w),x}var z=c(7015),A=c(26838),B=c(54325),C=c(52660),D=c(55233),E=c(48083);let F=(0,n.h)("model-change-broadcast");function G(){let a=globalThis.__modelChangeBroadcastUnsubscribe;a&&(a(),globalThis.__modelChangeBroadcastUnsubscribe=void 0)}var H=c(43925),I=c(57836);function J(){let a=globalThis.__waitingStatusBroadcastUnsubscribe;a&&(a(),globalThis.__waitingStatusBroadcastUnsubscribe=void 0),G(),(0,H.dz)()}let K=(0,n.h)("publisher-registry");function L(){return globalThis.__realtimeRoomPublisher?.publisher??null}let M=(0,n.h)("ws-server"),N=null,O=new Map,P=new Map,Q=null,R=new Set(["localhost","127.0.0.1"]);function S(a,b){try{a.write(`HTTP/1.1 ${b}\r
|
|
5
|
-
Content-Length: 0\r
|
|
6
|
-
Connection: close\r
|
|
7
|
-
\r
|
|
8
|
-
`)}catch{}a.destroy()}async function T(a,b,c,d){let e,f=(a.url||"/").split("?")[0].split("/")[2]||"";if(!f)return void S(b,"400 Bad Request");try{let a=d.getDb(),b=d.getCache(a);e=await b.getByPathPrefix(f)}catch(a){M.error("ws-proxy:cache-error",{pathPrefix:f,error:a instanceof Error?a.message:String(a)}),!b.destroyed&&b.writable&&S(b,"502 Bad Gateway");return}if(b.destroyed||!b.writable)return;if(!e)return void S(b,"404 Not Found");if(!e.enabled)return void S(b,"503 Service Unavailable");if(!e.websocketEnabled)return void S(b,"403 Forbidden");if(!R.has(e.targetHost)){M.warn("ws-proxy:ssrf-blocked",{pathPrefix:f}),S(b,"403 Forbidden");return}let g=d.netConnect({host:e.targetHost,port:e.targetPort}),h=!1,i=!1,j=()=>{if(!i){i=!0;try{g.destroy()}catch{}try{b.destroy()}catch{}}};g.on("connect",()=>{h=!0;try{let b=function(a){let b=a.method||"GET",c=a.url||"/",d=a.httpVersion||"1.1",e=[`${b} ${c} HTTP/${d}`];for(let[b,c]of Object.entries(a.headers))if(void 0!==c)if(Array.isArray(c))for(let a of c)e.push(`${b}: ${a}`);else e.push(`${b}: ${c}`);return e.join("\r\n")+"\r\n\r\n"}(a);g.write(b)}catch(a){M.error("ws-proxy:upstream-write-error",{pathPrefix:f,error:a instanceof Error?a.message:String(a)}),j();return}b.pipe(g),g.pipe(b)}),g.on("error",a=>{M.error("ws-proxy:upstream-error",{pathPrefix:f,error:a.message}),h||b.destroyed||!b.writable?j():S(b,"502 Bad Gateway")}),g.on("close",()=>{j()}),b.on("error",a=>{M.error("ws-proxy:client-error",{pathPrefix:f,error:a.message}),j()}),b.on("close",()=>{j()})}function U(a){N=new d.zu({noServer:!0}),Q=function(a){let b=(globalThis.__realtimeRoomPublisherGeneration??0)+1;return globalThis.__realtimeRoomPublisherGeneration=b,globalThis.__realtimeRoomPublisher={generation:b,publisher:a},globalThis.__realtimeUnroutedPublish=void 0,{token:b,unregister:()=>(function(a){let b=globalThis.__realtimeRoomPublisher;return!!b&&b.generation===a&&(globalThis.__realtimeRoomPublisher=void 0,!0)})(b)}}(ad),function(a){J();let b=(0,I.wN)(b=>{a(b.worktreeId,{type:"session_status_changed",worktreeId:b.worktreeId,cliTool:b.cliToolId,instance:b.instanceId??b.cliToolId,isWaitingForResponse:b.waiting,waitingKind:b.kind??null,waitingSince:b.since})});globalThis.__waitingStatusBroadcastUnsubscribe=b,function(a){G();let b=(0,E.onAgentModelChange)(b=>{F.info("model-changed",{worktreeId:b.worktreeId,cliToolId:b.cliToolId,instanceId:b.instanceId,from:b.from,to:b.to,source:b.source});let c=function(a){try{let b=(0,j.getDbInstance)(),c=(0,D.dV)(b),d=(0,C.createModelChangeMessage)(b,{worktreeId:a.worktreeId,cliToolId:a.cliToolId,instanceId:a.instanceId,content:(0,D.DH)(c,a.from,a.to),at:a.at});return{type:"message",worktreeId:a.worktreeId,message:d}}catch(b){return F.warn("model-change-history-failed",{worktreeId:a.worktreeId,instanceId:a.instanceId,error:b instanceof Error?b.message:String(b)}),null}}(b);try{c&&a(b.worktreeId,c),a(b.worktreeId,{type:B.T4,worktreeId:b.worktreeId,cliTool:b.cliToolId,instance:b.instanceId,from:b.from,to:b.to,source:b.source,at:b.at})}catch(a){F.warn("model-change-broadcast-failed",{worktreeId:b.worktreeId,instanceId:b.instanceId,error:a instanceof Error?a.message:String(a)})}(0,D.b3)(b)});globalThis.__modelChangeBroadcastUnsubscribe=b}(a),(0,H.PJ)()}(X),a.on("upgrade",(a,b,c)=>{let d=a.url||"/";if(d.startsWith("/_next/")){b.write("HTTP/1.1 426 Upgrade Required\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"),b.destroy();return}if((0,g.Rh)()){let c=(0,g.Z2)(a.socket.remoteAddress||"");if(!(0,g.c$)(c,(0,g.nu)())){let a=c.substring(0,45);M.warn("websocket:denied",{ip:a}),b.write("HTTP/1.1 403 Forbidden\r\n\r\n"),b.destroy();return}}if((0,f.y2)()){let c=a.headers.cookie||"",d=(0,f.JT)(c)[f.aq];if(!d||!(0,f.nr)(d)){b.write("HTTP/1.1 401 Unauthorized\r\nContent-Length: 0\r\nConnection: close\r\n\r\n"),b.destroy();return}}if(d.startsWith("/proxy/"))return void(async()=>{try{await T(a,b,c,{getDb:()=>(0,j.getDbInstance)(),getCache:a=>(0,z.Ds)(a),netConnect:a=>(0,e.connect)(a)})}catch(a){if(M.error("ws-proxy:unhandled-error",{error:a instanceof Error?a.message:String(a)}),!b.destroyed&&b.writable){try{b.write("HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\nConnection: close\r\n\r\n")}catch{}b.destroy()}}})();N.handleUpgrade(a,b,c,b=>{N.emit("connection",b,a)})}),N.on("error",a=>{M.error("server:error",{error:a.message})}),N.on("connection",a=>{let b={ws:a,worktreeIds:new Set,terminalSubscription:null};O.set(a,b),a.on("message",b=>{try{let c=JSON.parse(b.toString());V(a,c)}catch(a){M.error("message:parse-failed",{error:a instanceof Error?a.message:String(a)})}}),a.on("close",()=>{Y(a)}),a.on("error",b=>{"WS_ERR_INVALID_CLOSE_CODE"===b.code||b.message?.includes("Invalid WebSocket frame")||b.message?.includes("write after end")||b.message?.includes("ECONNRESET")||b.message?.includes("EPIPE")||M.error("websocket:error",{error:b.message});try{a.terminate()}catch{}Y(a)})})}function V(a,b){switch(b.type){case"subscribe":if(!b.worktreeId)return;var c=a,d=b.worktreeId;let e=O.get(c);e&&(e.worktreeIds.add(d),P.has(d)||P.set(d,new Set),P.get(d).add(c));break;case"unsubscribe":if(!b.worktreeId)return;!function(a,b){let c=O.get(a);if(!c)return;c.worktreeIds.delete(b);let d=P.get(b);d&&(d.delete(a),0===d.size&&P.delete(b))}(a,b.worktreeId);break;case"broadcast":if(!b.worktreeId)return;X(b.worktreeId,b.data);break;case B.ST:W(a,b);break;case"terminal_subscribe":$(a,b);break;case"terminal_input":_(a,b);break;case"terminal_resize":aa(a,b);break;case"terminal_unsubscribe":ab(a);break;default:M.warn("message:unknown-type")}}function W(a,b){let c="string"==typeof b.version?b.version:"";if(!c)return;let e=(0,A.E2)(c);if(e&&a.readyState===d.kb.OPEN)try{a.send(JSON.stringify({type:B.Oo,serverVersion:e.serverVersion,clientVersion:e.clientVersion}))}catch(a){M.error("version:notify-failed",{error:a instanceof Error?a.message:String(a)})}}function X(a,b){let c=P.get(a);if(c&&0!==c.size)try{let e=JSON.stringify({type:"broadcast",worktreeId:a,data:b});c.forEach(a=>{if(a.readyState===d.kb.OPEN)try{a.send(e)}catch(a){M.error("broadcast:send-failed",{error:a instanceof Error?a.message:String(a)})}})}catch(b){M.error("broadcast:failed",{worktreeId:a,error:b instanceof Error?b.message:String(b)});try{let b=JSON.stringify({type:"broadcast",worktreeId:a,data:{error:"Message encoding error"}});c.forEach(a=>{if(a.readyState===d.kb.OPEN)try{a.send(b)}catch{}})}catch(a){M.error("fallback:send-failed",{error:a instanceof Error?a.message:String(a)})}}}function Y(a){let b=O.get(a);b&&(b.worktreeIds.forEach(b=>{let c=P.get(b);c&&(c.delete(a),0===c.size&&P.delete(b))}),b.terminalSubscription&&(b.terminalSubscription.unsubscribe(),b.terminalSubscription=null),O.delete(a))}function Z(a,b){a.readyState===d.kb.OPEN&&a.send(JSON.stringify(b))}async function $(a,b){let c=O.get(a);if(!c)return void Z(a,{type:"terminal_error",error:"Unauthorized WebSocket client"});if("true"!==process.env.TMUX_CONTROL_MODE_ENABLED)return void Z(a,{type:"terminal_error",error:"Tmux control mode is disabled"});let{worktreeId:d,cliToolId:e}=b;if(!d||!e||!(0,h.hR)(e))return void Z(a,{type:"terminal_error",error:"Invalid terminal subscription parameters"});let f=(0,j.getDbInstance)();if(!(0,k.getWorktreeById)(f,d))return void Z(a,{type:"terminal_error",error:"Worktree not found"});c.terminalSubscription&&(await c.terminalSubscription.unsubscribe(),c.terminalSubscription=null);let g=(0,i.m)(e,d),m=y();if(m.getSubscriberCount(g)>=4)return void Z(a,{type:"terminal_error",error:"Terminal subscriber limit reached"});let n=!1,o=Date.now(),p=await m.subscribe(g,{onOutput:b=>{if(!n){n=!0;let a=Math.max(0,Math.round(Date.now()-o));l.firstOutputLatencyCount+=1,l.firstOutputLatencyTotalMs+=a,l.firstOutputLatencyLastMs=a,l.firstOutputLatencyMinMs=null===l.firstOutputLatencyMinMs?a:Math.min(l.firstOutputLatencyMinMs,a),l.firstOutputLatencyMaxMs=null===l.firstOutputLatencyMaxMs?a:Math.max(l.firstOutputLatencyMaxMs,a)}Z(a,{type:"terminal_output",data:b})},onExit:({exitCode:b})=>{Z(a,{type:"terminal_exit",exitCode:b})},onError:b=>{(async()=>{try{let b=await m.captureSnapshot(g,{startLine:-200});b.length>0&&Z(a,{type:"terminal_output",data:b,fallback:!0})}catch{}Z(a,{type:"terminal_error",error:b.message,fallback:!0})})()}});c.terminalSubscription={worktreeId:d,cliToolId:e,sessionName:g,startedAt:o,unsubscribe:p.unsubscribe},Z(a,{type:"terminal_status",connected:!0,worktreeId:d,cliToolId:e})}async function _(a,b){let c=O.get(a),d=c?.terminalSubscription;if(!d)return void Z(a,{type:"terminal_error",error:"No active terminal subscription"});let e="string"==typeof b.data?b.data:"";if(0===e.length||e.length>4096)return void Z(a,{type:"terminal_error",error:"Invalid terminal input"});try{await y().sendInput(d.sessionName,e)}catch(b){Z(a,{type:"terminal_error",error:b instanceof Error?b.message:"Failed to send terminal input"})}}async function aa(a,b){let c=O.get(a),d=c?.terminalSubscription;if(d){if("number"!=typeof b.cols||!Number.isInteger(b.cols)||b.cols<20||b.cols>500||"number"!=typeof b.rows||!Number.isInteger(b.rows)||b.rows<5||b.rows>200)return void Z(a,{type:"terminal_error",error:"Invalid terminal resize payload"});try{await y().resize(d.sessionName,b.cols,b.rows)}catch(b){Z(a,{type:"terminal_error",error:b instanceof Error?b.message:"Failed to resize terminal"})}}}async function ab(a){let b=O.get(a);if(b?.terminalSubscription){try{await b.terminalSubscription.unsubscribe()}catch{}b.terminalSubscription=null,Z(a,{type:"terminal_status",connected:!1})}}function ac(a){let b=P.get(a);return!!b&&b.size>0}let ad={publish:X,hasSubscribers:ac,cleanupRooms:an,migrateRooms:al};function ae(){let a=L();return a&&a!==ad?a:null}function af(a,b){null===L()&&0===P.size&&function(a,b,c=Date.now()){let d=globalThis.__realtimeUnroutedPublish??={total:0,suppressed:0,lastWarnedAt:null,operations:{}};if(d.total+=1,d.operations[a]=(d.operations[a]??0)+1,null!==d.lastWarnedAt&&c-d.lastWarnedAt<6e4){d.suppressed+=1;return}let e=d.suppressed;d.suppressed=0,d.lastWarnedAt=c,K.warn("realtime:no-room-publisher",{operation:a,worktreeId:b,total:d.total,suppressedSinceLastWarning:e,operations:{...d.operations}})}(a,b)}function ag(a,b){let c=ae();if(c)return void c.publish(a,b);af("broadcast",a),X(a,b)}function ah(a){let b=ae();return b?b.hasSubscribers(a):(af("hasRoomSubscribers",a),ac(a))}function ai(a,b){b.worktreeId?ag(b.worktreeId,{type:a,...b}):M.warn("broadcast:missing-worktree-id")}let aj="worktree_renamed";function ak(a){let b=ae();return b?b.migrateRooms(a):al(a)}function al(a){let b=new Map;for(let{oldId:c,newId:d}of a)c&&d&&c!==d&&b.set(c,d);if(0===b.size)return[];let c=[];for(let[a,d]of b){let b=P.get(a);b&&0!==b.size&&(P.delete(a),c.push({oldId:a,newId:d,sockets:b}))}let d=[];for(let{oldId:a,newId:b,sockets:e}of c){let c=P.get(b)??new Set;for(let d of e){c.add(d);let e=O.get(d);e&&(e.worktreeIds.delete(a),e.worktreeIds.add(b)),Z(d,{type:aj,worktreeId:b,previousWorktreeId:a})}P.set(b,c),d.push({oldId:a,newId:b,subscribers:e.size})}for(let a of O.values()){let c=a.terminalSubscription;if(!c)continue;let d=b.get(c.worktreeId);if(d)try{if(!(0,h.hR)(c.cliToolId))continue;c.sessionName=(0,i.m)(c.cliToolId,d),c.worktreeId=d}catch(a){M.warn("terminal:rename-failed",{worktreeId:c.worktreeId,newId:d,error:a instanceof Error?a.message:String(a)})}}return d.length>0&&M.info("rooms:migrated",{count:d.length}),d}function am(a){let b=ae();if(b)return void b.cleanupRooms(a);an(a)}function an(a){for(let b of a){let a=P.get(b);a&&(a.forEach(a=>{let c=O.get(a);c&&c.worktreeIds.delete(b)}),P.delete(b))}}function ao(){let a=null!==Q&&Q.unregister();Q=null,(a||null===L())&&J(),N&&(O.forEach(a=>{a.ws.close()}),O.clear(),P.clear(),N.close(),N=null)}let ap={handleMessage:V,handleClientVersion:W,handleProxyUpgrade:T,handleTerminalSubscribe:$,handleTerminalInput:_,handleTerminalResize:aa,handleTerminalUnsubscribe:ab,handleDisconnect:Y,registerClientForTest(a){O.set(a,{ws:a,worktreeIds:new Set,terminalSubscription:null})},getClientInfoForTest:a=>O.get(a),resetStateForTest(){O.clear(),P.clear()}}},54036:(a,b,c)=>{"use strict";c.d(b,{aq:()=>d,gu:()=>f,kr:()=>h});let d="cm_auth_token",e=/^[0-9a-f]{64}$/;function f(a){return!!a&&e.test(a)}let g=2592e6;function h(){let a=process.env.CM_AUTH_EXPIRE,b=Date.now();if(a)try{return b+function(a){let b=a.match(/^(\d+)([hdm])$/);if(!b)throw Error(`Invalid duration format: "${a}". Use Nh, Nd, or Nm (e.g., "24h", "7d", "90m")`);let c=parseInt(b[1],10),d=b[2],e={h:36e5,d:864e5,m:6e4}[d];if(void 0===e)throw Error(`Invalid duration unit: "${d}"`);let f=c*e;if(f<36e5)throw Error(`Duration too short: minimum is 1h (60m). Got: "${a}"`);if(f>g)throw Error(`Duration too long: maximum is 30d (720h). Got: "${a}"`);return f}(a)}catch{return b+864e5}return process.env.CM_AUTH_TOKEN_HASH?b+864e5:null}},55233:(a,b,c)=>{"use strict";c.d(b,{DH:()=>o,b3:()=>q,dV:()=>p});var d=c(25754),e=c(88807),f=c(43167),g=c(73753),h=c(72626),i=c(72119),j=c(52445),k=c(61191),l=c(27519);let m=(0,h.h)("push/model-change-notifier"),n={en:i.agentModel.changed,ja:j.agentModel.changed};function o(a,b,c){return n[(0,k.resolvePushLocale)(a)].replace("{from}",b).replace("{to}",c)}function p(a){try{let b=(0,f.Se)(a),c=null;for(let a of b){let b=a.updatedAt.getTime();(null===c||b>c.updatedAt)&&(c={updatedAt:b,locale:a.locale})}return(0,k.resolvePushLocale)(c?.locale??d.Xn)}catch{return d.Xn}}async function q(a){if(!(0,l.lU)())return m.debug("model-change-push-suppressed",{worktreeId:a.worktreeId,instanceId:a.instanceId,reason:"unconfigured"}),"unconfigured";try{await (0,k.notifyPushSubscribers)({worktreeId:a.worktreeId,worktreeName:function(a){try{return(0,g.getWorktreeById)((0,e.getDbInstance)(),a)?.name??a}catch{return a}}(a.worktreeId),kind:"failure",agentName:a.instanceId,instanceId:a.instanceId,modelChange:{from:a.from,to:a.to,body:function(a,b){let c={};for(let e of d.dI)c[e]=o(e,a,b);return c}(a.from,a.to)}},a.at),m.info("model-change-push-raised",{worktreeId:a.worktreeId,instanceId:a.instanceId,from:a.from,to:a.to,source:a.source})}catch(b){m.warn("model-change-push-failed",{worktreeId:a.worktreeId,instanceId:a.instanceId,error:b instanceof Error?b.message:String(b)})}return null}},57836:(a,b,c)=>{"use strict";c.d(b,{Jp:()=>k,Te:()=>l,hd:()=>j,wN:()=>h});var d=c(24455);let e=(0,c(72626).h)("waiting-episode-state"),f=globalThis.__sessionWaitingEpisodes??(globalThis.__sessionWaitingEpisodes=new Map),g=globalThis.__sessionWaitingTransitionListeners??(globalThis.__sessionWaitingTransitionListeners=new Set);function h(a){return g.add(a),()=>{g.delete(a)}}function i(a){for(let b of g)try{b(a)}catch(b){e.error("waiting-transition-listener-failed",{worktreeId:a.worktreeId,cliToolId:a.cliToolId,instanceId:a.instanceId??a.cliToolId,waiting:a.waiting,error:b instanceof Error?b.message:String(b)})}}function j({worktreeId:a,cliToolId:b,instanceId:c,waiting:e,kind:g=null,structuredSince:h=null,now:j=Date.now()}){let k=(0,d.v7)(a,b,c),l=f.get(k);if(!e)return void 0===l||(f.delete(k),i({worktreeId:a,cliToolId:b,instanceId:c,waiting:!1,since:null,kind:null,at:j})),null;if(void 0!==l)return l.kind=g,l.since;let m=h??j;return f.set(k,{since:m,kind:g}),i({worktreeId:a,cliToolId:b,instanceId:c,waiting:!0,since:m,kind:g,at:j}),m}function k(a,b,c){return f.get((0,d.v7)(a,b,c))??null}function l(a){let b=`${a}${d.CS}`;for(let a of f.keys())if(a.startsWith(b))return!0;return!1}},88081:(a,b,c)=>{"use strict";c.d(b,{JT:()=>m,QK:()=>k,aq:()=>f.aq,nr:()=>l,r0:()=>p,sO:()=>h,x:()=>q,y2:()=>n,zr:()=>o});var d=c(55511),e=c.n(d),f=c(54036);let g={maxAttempts:5,lockoutDuration:9e5,cleanupInterval:36e5},h=86400,i=(()=>{let a=process.env.CM_AUTH_TOKEN_HASH||void 0;return a?(0,f.gu)(a)?a:void console.error("[auth] CM_AUTH_TOKEN_HASH is not a valid SHA-256 hash"):void 0})(),j=(0,f.kr)();function k(a){return e().createHash("sha256").update(a).digest("hex")}function l(a){if(!i||!a||"string"!=typeof a||null!==j&&Date.now()>j)return!1;let b=k(a),c=Buffer.from(b,"hex"),d=Buffer.from(i,"hex");return c.length===d.length&&e().timingSafeEqual(c,d)}function m(a){let b={};if(!a)return b;for(let c of a.split(";")){let a=c.indexOf("=");if(-1===a)continue;let d=c.substring(0,a).trim(),e=c.substring(a+1).trim();d&&(b[d]=e)}return b}function n(){return!!i}function o(){if(null===j)return 0;let a=j-Date.now();return a<=0?0:Math.floor(a/1e3)}function p(a){return{httpOnly:!0,sameSite:"strict",secure:!!process.env.CM_HTTPS_CERT,maxAge:a,path:"/"}}function q(){let a=new Map,b=setInterval(()=>{let b=Date.now();for(let[c,d]of a){let e=null===d.lockedUntil||b>d.lockedUntil,f=b-d.lastAttempt>g.lockoutDuration;e&&f&&a.delete(c)}},g.cleanupInterval);return b.unref&&b.unref(),{checkLimit(b){let c=a.get(b);if(!c)return{allowed:!0};if(null!==c.lockedUntil){let a=Date.now();if(a<c.lockedUntil)return{allowed:!1,retryAfter:Math.ceil((c.lockedUntil-a)/1e3)};c.attempts=0,c.lockedUntil=null}return{allowed:!0}},recordFailure(b){let c=Date.now(),d=a.get(b)||{attempts:0,lockedUntil:null,lastAttempt:c};d.attempts++,d.lastAttempt=c,d.attempts>=g.maxAttempts&&(d.lockedUntil=c+g.lockoutDuration),a.set(b,d)},recordSuccess(b){a.delete(b)},destroy(){clearInterval(b),a.clear()}}}},90164:(a,b,c)=>{"use strict";c.d(b,{Dk:()=>e,kD:()=>f});let d="https://github.com/Kewton/CommandMate",e=`${d}/releases/`,f=`${d}/blob/main/docs/security-guide.md`}};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4718],{2317:(e,t,r)=>{r.d(t,{V:()=>i});var n=r(12115);function o(){try{let e="__localStorage_test__";return window.localStorage.setItem(e,"test"),window.localStorage.removeItem(e),!0}catch(e){return!1}}function i(e){let{key:t,defaultValue:r,validate:i,serialize:a=JSON.stringify,deserialize:s=JSON.parse}=e,l=(0,n.useRef)(r),c=(0,n.useRef)(i),u=(0,n.useRef)(a),d=(0,n.useRef)(s);l.current=r,c.current=i,u.current=a,d.current=s;let[f,p]=(0,n.useState)(!1),[g,m]=(0,n.useState)(r),y=(0,n.useCallback)(()=>{if(!o())return l.current;try{let e=window.localStorage.getItem(t);if(null===e)return l.current;let r=d.current(e);if(c.current)return c.current(r)?r:l.current;return r}catch(e){return l.current}},[t]),h=(0,n.useCallback)(e=>{if(o())try{let r=u.current(e);window.localStorage.setItem(t,r)}catch(e){}},[t]),w=(0,n.useCallback)(e=>{m(t=>{let r="function"==typeof e?e(t):e;return h(r),r})},[h]),b=(0,n.useCallback)(()=>{if(o())try{window.localStorage.removeItem(t)}catch(e){}m(l.current)},[t]);return(0,n.useEffect)(()=>{p(o()),m(y())},[y]),{value:g,setValue:w,removeValue:b,isAvailable:f}}},7636:(e,t,r)=>{r.d(t,{BN:()=>C,EN:()=>a,LV:()=>p,PB:()=>l,Si:()=>i,UZ:()=>d,Xn:()=>b,ZC:()=>T,ZD:()=>E,_s:()=>S,fs:()=>k,j:()=>w,m3:()=>s,nO:()=>g,s6:()=>f,zD:()=>h});var n=r(38606);let o=["updatedAt","repositoryName","branchName","status","lastSent"],i=e=>o.includes(e),a=["always","collapsed","hidden"],s=e=>a.includes(e),l="collapsed",c={waiting:0,ready:1,running:2,generating:3,idle:4},u=["waiting","running","generating","ready","idle"];function d(e){let t=new Set;for(let r of e)!1===r.visible&&t.add(r.path);return t}function f(e,t){return 0===t.size?e.slice():e.filter(e=>{let r=e.repositoryPath;return!r||!t.has(r)})}function p(e){let t=function(e){let t=5381;for(let r=0;r<e.length;r++)t=(t<<5)+t+e.charCodeAt(r)|0;return Math.abs(t)}(e)%360;return"hsl(".concat(t,", ").concat(65,"%, ").concat(60,"%)")}function g(e,t){if(!e&&!t)return 0;if(!e)return 1;if(!t)return -1;let r=e instanceof Date?e.getTime():new Date(e).getTime();return(t instanceof Date?t.getTime():new Date(t).getTime())-r}function m(e){return e.cliStatus&&Object.keys(e.cliStatus).length>0?(0,n.A7)(e.cliStatus):e.status}function y(e){return"waiting"===m(e)}function h(e){let t=new Set(e.map(m));for(let e of u)if(t.has(e))return e;return"idle"}function w(e){let t=0;for(let r of e)y(r)&&t++;return t}function b(e,t,r){let n=[...e],o="status"!==t;return n.sort((e,n)=>{if(o){let t=Number(y(n))-Number(y(e));if(0!==t)return t}let i=0;switch(t){case"updatedAt":{let t=e=>e?e instanceof Date?e.getTime():new Date(e).getTime():0,r=t(e.lastActivity);i=t(n.lastActivity)-r;break}case"repositoryName":{let t=e.repositoryName.toLowerCase(),r=n.repositoryName.toLowerCase();i=t.localeCompare(r);break}case"branchName":{let t=e.name.toLowerCase(),r=n.name.toLowerCase();i=t.localeCompare(r);break}case"status":i=c[e.status]-c[n.status];break;case"lastSent":{let t=g(e.lastActivity,n.lastActivity);if(!e.lastActivity&&!n.lastActivity){i=0;break}if(!e.lastActivity)return 1;if(!n.lastActivity)return -1;i=t;break}default:i=0}return("updatedAt"===t||"lastSent"===t?"desc"===r:"asc"===r)?i:-i}),n}function S(e,t,r){let n=new Map;for(let t of e){let e=t.repositoryName;n.has(e)||n.set(e,[]),n.get(e).push(t)}return[...n.keys()].sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).map(e=>({repositoryName:e,branches:b(n.get(e),t,r)}))}let v="mcbd-sidebar-group-order-cache";function E(){try{let e=localStorage.getItem(v);if(!e)return[];let t=function(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.filter(e=>"string"==typeof e).slice(0,500)}catch(e){return[]}}(e);return t.length,t}catch(e){return[]}}function T(e){try{localStorage.setItem(v,JSON.stringify(e))}catch(e){}}function C(e,t){if(0===t.length)return e.slice();let r=new Map(t.map((e,t)=>[e,t]));return e.slice().sort((e,t)=>{let n=r.has(e.repositoryName)?r.get(e.repositoryName):1/0,o=r.has(t.repositoryName)?r.get(t.repositoryName):1/0;return n===o?e.repositoryName.localeCompare(t.repositoryName):n-o})}function k(e,t){return"hidden"!==e&&("always"===e||!t)}},22592:(e,t,r)=>{r.d(t,{Ps:()=>d,W5:()=>u});var n=r(95155),o=r(12115),i=r(38218),a=r(68704);let s="data-pc-size",l={size:a.r5,setSize:()=>{},isMobile:!1,factor:a.d8[a.r5].factor,isAvailable:!1},c=(0,o.createContext)(l);function u(e){let{children:t}=e,{size:r,setSize:l,isAvailable:u}=(0,a.of)(),d=(0,i.a)();(0,o.useEffect)(()=>{if("undefined"==typeof document)return;let e=document.documentElement;return d?void e.removeAttribute(s):(e.setAttribute(s,r),()=>{e.removeAttribute(s)})},[r,d]);let f=(0,o.useMemo)(()=>({size:r,setSize:l,isMobile:d,factor:a.d8[r].factor,isAvailable:u}),[r,l,d,u]);return(0,n.jsx)(c.Provider,{value:f,children:t})}function d(){return(0,o.useContext)(c)}},24373:(e,t,r)=>{r.d(t,{Kg:()=>i,Lv:()=>a});var n=r(12115),o=r(66966);function i(e){let t=0;for(let r of e)!0===r.isWaitingForResponse&&t++;return t}function a(){let e=(0,o.rC)(),t=null==e?void 0:e.worktrees;return(0,n.useMemo)(()=>{let e=t?t.filter(e=>!0===e.isWaitingForResponse):[];return{count:e.length,worktrees:e}},[t])}r(44308)},32916:(e,t,r)=>{r.d(t,{GB:()=>u,VF:()=>d,pT:()=>f});var n=r(95155),o=r(12115),i=r(7636);let a="updatedAt",s=(0,o.createContext)(null);function l(e,t,r,n){let i=(0,o.useRef)(!0);(0,o.useEffect)(()=>{try{let t=localStorage.getItem(e);t&&n(t)}catch(e){}},[]),(0,o.useEffect)(()=>{if(i.current){i.current=!1;return}try{localStorage.setItem(e,r())}catch(e){}},[t])}function c(e,t){switch(t.type){case"TOGGLE":return{...e,isOpen:!e.isOpen};case"SET_WIDTH":return{...e,width:t.width};case"OPEN_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!0};case"CLOSE_MOBILE_DRAWER":return{...e,isMobileDrawerOpen:!1};case"SET_SORT_KEY":return{...e,sortKey:t.sortKey};case"SET_SORT_DIRECTION":return{...e,sortDirection:t.sortDirection};case"LOAD_SORT_SETTINGS":return{...e,sortKey:t.sortKey,sortDirection:t.sortDirection};case"SET_VIEW_MODE":return{...e,viewMode:t.viewMode};case"SET_OPEN":return e.isOpen===t.isOpen?e:{...e,isOpen:t.isOpen};case"SET_REPOSITORY_ORDER":return{...e,repositoryOrder:t.repositoryOrder};case"SET_REPO_TAB_BAR_MODE":return{...e,repoTabBarMode:t.repoTabBarMode};default:return e}}function u(e){let{children:t,initialOpen:r=!0,initialWidth:u=224}=e,[d,f]=(0,o.useReducer)(c,{isOpen:r,width:u,isMobileDrawerOpen:!1,sortKey:a,sortDirection:"desc",viewMode:"grouped",repositoryOrder:(0,i.ZD)(),repoTabBarMode:i.PB});l("mcbd-sidebar-sort","".concat(d.sortKey,":").concat(d.sortDirection),()=>JSON.stringify({sortKey:d.sortKey,sortDirection:d.sortDirection}),e=>{try{let t=JSON.parse(e),r=t.sortDirection,n=(0,i.Si)(t.sortKey)?t.sortKey:a;n&&("asc"===r||"desc"===r)&&f({type:"LOAD_SORT_SETTINGS",sortKey:n,sortDirection:r})}catch(e){}}),l("mcbd-sidebar-view-mode",d.viewMode,()=>d.viewMode,e=>{("grouped"===e||"flat"===e)&&f({type:"SET_VIEW_MODE",viewMode:e})}),l("mcbd-sidebar-width",d.width,()=>String(d.width),e=>{let t=Number(e);!isNaN(t)&&t>0&&f({type:"SET_WIDTH",width:288===t?224:t})}),l("mcbd-sidebar-open",d.isOpen,()=>String(d.isOpen),e=>{("true"===e||"false"===e)&&f({type:"SET_OPEN",isOpen:"true"===e})}),l("mcbd-repo-tab-bar-mode",d.repoTabBarMode,()=>d.repoTabBarMode,e=>{(0,i.m3)(e)&&f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})});let p=(0,o.useCallback)(()=>{f({type:"TOGGLE"})},[]),g=(0,o.useCallback)(e=>{f({type:"SET_WIDTH",width:e})},[]),m=(0,o.useCallback)(()=>{f({type:"OPEN_MOBILE_DRAWER"})},[]),y=(0,o.useCallback)(()=>{f({type:"CLOSE_MOBILE_DRAWER"})},[]),h=(0,o.useCallback)(e=>{f({type:"SET_SORT_KEY",sortKey:e})},[]),w=(0,o.useCallback)(e=>{f({type:"SET_SORT_DIRECTION",sortDirection:e})},[]),b=(0,o.useCallback)(e=>{f({type:"SET_VIEW_MODE",viewMode:e})},[]),S=(0,o.useCallback)(e=>{f({type:"SET_REPOSITORY_ORDER",repositoryOrder:e}),(0,i.ZC)(e)},[]),v=(0,o.useCallback)(e=>{f({type:"SET_REPO_TAB_BAR_MODE",repoTabBarMode:e})},[]),E=(0,o.useMemo)(()=>({isOpen:d.isOpen,width:d.width,isMobileDrawerOpen:d.isMobileDrawerOpen,sortKey:d.sortKey,sortDirection:d.sortDirection,toggle:p,setWidth:g,openMobileDrawer:m,closeMobileDrawer:y,setSortKey:h,setSortDirection:w,viewMode:d.viewMode,setViewMode:b,repositoryOrder:d.repositoryOrder,setRepositoryOrder:S,repoTabBarMode:d.repoTabBarMode,setRepoTabBarMode:v}),[d.isOpen,d.width,d.isMobileDrawerOpen,d.sortKey,d.sortDirection,d.viewMode,d.repositoryOrder,d.repoTabBarMode,p,g,m,y,h,w,b,S,v]);return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useSidebarContext must be used within a SidebarProvider");return e}function f(){return(0,o.useContext)(s)}},38218:(e,t,r)=>{r.d(t,{D:()=>i,a:()=>a});var n=r(12115);let o=n.useLayoutEffect,i=768;function a(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{breakpoint:t=i}=e,[r,a]=(0,n.useState)(!1);return o(()=>{let e=window.matchMedia("(max-width: ".concat(t-1,"px)"));a(e.matches);let r=e=>{a(e.matches)};return e.addEventListener("change",r),()=>{e.removeEventListener("change",r)}},[t]),r}},38606:(e,t,r)=>{r.d(t,{A7:()=>c,kA:()=>i,f_:()=>f,dw:()=>u,XK:()=>p});var n=r(54014),o=r(55449);function i(e){return e?e.isWaitingForResponse?"waiting":e.isProcessing?"running":e.isRunning?"ready":"idle":"idle"}let a={start:"nextAction.start",sendMessage:"nextAction.sendMessage",approveReject:"nextAction.approveReject",replyToPrompt:"nextAction.replyToPrompt",checkStalled:"nextAction.checkStalled",running:"nextAction.running"};Object.values(a);let s="exited",l={idle:null,ready:"ready",running:"running",generating:"running",waiting:"waiting"};function c(e){if(!e)return"idle";let t=Object.values(e).filter(e=>void 0!==e);return 0===t.length?"idle":t.includes("waiting")?"waiting":t.includes("running")?"running":t.includes("generating")?"generating":t.includes("ready")?"ready":"idle"}function u(e,t,r){return e?Object.entries(e).map(e=>{var o;let[i,a]=e,s=null!=(o=null==t?void 0:t[i])?o:(0,n.f_)(i,i),l=null==r?void 0:r(i);return"".concat(s,": ").concat(null!=a?a:"idle").concat(l?" (".concat(l,")"):"")}).join(", "):""}let d=["prompt","menu","unclassified"];function f(e){var t,r,n;let o=Object.values(null!=(r=null!=(t=e.sessionStatusByInstance)?t:e.sessionStatusByCli)?r:{}).filter(e=>void 0!==e),i=!1,a=new Set;for(let e of o)e.awaitingInstruction&&(i=!0),e.waitingKind&&a.add(e.waitingKind);return{waitingKind:null!=(n=d.find(e=>a.has(e)))?n:null,awaitingInstruction:i}}function p(e){var t,r,u,d,p,g;let m=i(void 0!==e.isSessionRunning?{isRunning:null!=(t=e.isSessionRunning)&&t,isWaitingForResponse:null!=(r=e.isWaitingForResponse)&&r,isProcessing:null!=(u=e.isProcessing)&&u}:void 0),y=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),{cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b}=function(e){var t,r,a,l,c,u;let d={},f={},p=[],g=e.sessionStatusByInstance;if(!g){for(let c of null!=(t=e.selectedAgents)?t:(0,o.sA)())d[c]=i(null==(r=e.sessionStatusByCli)?void 0:r[c]),f[c]=(0,n.oo)(c),(null==(l=e.sessionStatusByCli)||null==(a=l[c])?void 0:a.sessionStatusReason)===s&&p.push(c);return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}let m=e.agentInstances&&e.agentInstances.length>0?e.agentInstances:(0,n.lu)(null!=(c=e.selectedAgents)?c:(0,o.sA)()),y=new Set;for(let e of m)y.add(e.id),d[e.id]=i(g[e.id]),f[e.id]=(0,n.sw)(e),(null==(u=g[e.id])?void 0:u.sessionStatusReason)===s&&p.push(e.id);for(let[e,t]of Object.entries(g)){if(y.has(e))continue;let r=i(t);"idle"!==r&&(d[e]=r,f[e]=function(e){let t=n.XH.find(t=>e.startsWith("".concat(t,"-")));if(t){let r=e.slice(t.length+1);return"".concat((0,n.oo)(t)," ").concat(r)}return(0,n.f_)(e,e)}(e))}return{cliStatus:d,cliStatusLabels:f,exitedInstanceIds:p}}(e),S=c(h),{waitingKind:v,awaitingInstruction:E}=f(e);return{id:e.id,name:e.name,repositoryName:null!=(d=e.repositoryDisplayName)?d:e.repositoryName,status:m,hasUnread:y,lastActivity:e.updatedAt,description:e.description,cliStatus:h,cliStatusLabels:w,exitedInstanceIds:b,worktreePath:e.path,waitingKind:v,awaitingInstruction:E,nextActionKey:(p=l[S],g="waiting"===S?"approval":null,p&&"idle"!==p?"ready"===p?a.sendMessage:"waiting"===p&&"approval"===g?a.approveReject:"waiting"===p?a.replyToPrompt:(0,a.running):a.start)}}},39649:(e,t,r)=>{r.d(t,{$f:()=>d,H8:()=>u});var n=r(95155),o=r(12115),i=r(80344);let a={PROCESSING:2e3,SESSION_RUNNING:5e3,IDLE:1e4},s=(0,o.createContext)(null),l={selectedWorktreeId:null,worktrees:[],repositories:[],selectedWorktreeDetail:null,isLoading:!0,isLoadingDetail:!1,error:null};function c(e,t){switch(t.type){case"SET_WORKTREES":return{...e,worktrees:t.worktrees,isLoading:!1};case"SET_REPOSITORIES":return{...e,repositories:t.repositories};case"SELECT_WORKTREE":{var r;let n=null!=(r=e.worktrees.find(e=>e.id===t.id))?r:null;return{...e,selectedWorktreeId:t.id,selectedWorktreeDetail:null!=n?n:e.selectedWorktreeDetail,isLoadingDetail:null===n}}case"SET_WORKTREE_DETAIL":return{...e,selectedWorktreeDetail:t.detail};case"SET_LOADING":return{...e,isLoading:t.isLoading};case"SET_LOADING_DETAIL":return{...e,isLoadingDetail:t.isLoadingDetail};case"SET_ERROR":return{...e,error:t.error,isLoading:!1};default:return e}}function u(e){let{children:t,externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p}=e,g=void 0!==r,[m,y]=(0,o.useReducer)(c,l);(0,o.useEffect)(()=>{g&&r&&y({type:"SET_WORKTREES",worktrees:r})},[g,r]),(0,o.useEffect)(()=>{g&&u&&y({type:"SET_REPOSITORIES",repositories:u})},[g,u]);let h=(0,o.useCallback)(async()=>{if(!g){y({type:"SET_LOADING",isLoading:!0}),y({type:"SET_ERROR",error:null});try{var e;let t=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:t.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(e=t.repositories)?e:[]})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktrees"})}}},[g]),w=(0,o.useCallback)(async e=>{y({type:"SELECT_WORKTREE",id:e}),y({type:"SET_ERROR",error:null});try{i.y.markAsViewed(e).catch(e=>{console.warn("[WorktreeSelectionContext] Failed to mark as viewed:",e)});let t=await i.y.getById(e);y({type:"SET_WORKTREE_DETAIL",detail:t})}catch(e){y({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktree detail"})}finally{y({type:"SET_LOADING_DETAIL",isLoadingDetail:!1})}},[]),b=(0,o.useCallback)(async()=>{if(g&&p)return void await p();await h()},[g,p,h]);(0,o.useEffect)(()=>{g||h()},[h,g]),(0,o.useEffect)(()=>{if(g)return;let e=null,t=!0,r=async()=>{if(t)try{var n,o;let s=await i.y.getAll();y({type:"SET_WORKTREES",worktrees:s.worktrees}),y({type:"SET_REPOSITORIES",repositories:null!=(n=s.repositories)?n:[]});let l=(o=s.worktrees).some(e=>e.isProcessing||e.isWaitingForResponse)?a.PROCESSING:o.some(e=>e.isSessionRunning)?a.SESSION_RUNNING:a.IDLE;t&&(e=setTimeout(r,l))}catch(n){if(n instanceof i.hD&&401===n.status)return;console.error("[WorktreeSelectionContext] Polling error:",n),t&&(e=setTimeout(r,a.SESSION_RUNNING))}};return r(),()=>{t=!1,e&&clearTimeout(e)}},[g]);let S=g&&void 0!==d?d:m.isLoading,v=g&&f?f.message:null,E={selectedWorktreeId:m.selectedWorktreeId,worktrees:m.worktrees,repositories:m.repositories,selectedWorktreeDetail:m.selectedWorktreeDetail,isLoading:S,isLoadingDetail:m.isLoadingDetail,error:null!=v?v:m.error,selectWorktree:w,refreshWorktrees:b};return(0,n.jsx)(s.Provider,{value:E,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useWorktreeSelection must be used within a WorktreeSelectionProvider");return e}},44308:(e,t,r)=>{r.d(t,{$h:()=>d,DR:()=>o,IH:()=>c,Iu:()=>n,Nb:()=>f,SD:()=>i,_d:()=>l,bm:()=>p,ks:()=>s,t7:()=>u,z7:()=>a});let n=7e3,o=["in_review","approval","stalled"],i="in_review",a="filter",s="/review?".concat(a,"=approval");function l(e){return e&&o.includes(e)?e:null}let c=["claude","codex","copilot","antigravity","opencode"],u=1e3,d=5,f=100,p=1e3},52703:(e,t,r)=>{r.d(t,{Oo:()=>o,ST:()=>n,T4:()=>s,dz:()=>a,rz:()=>i,zS:()=>l});let n="client_version",o="version_mismatch",i="chat_turn_progress",a="messages_invalidated",s="model_changed";function l(e){let t;try{t=JSON.parse(e)}catch(e){return null}if(!t||"object"!=typeof t)return null;let r=t;if("broadcast"===r.type){let e=r.data;return e&&"object"==typeof e?"string"!=typeof e.type?null:(void 0===e.worktreeId&&"string"==typeof r.worktreeId&&(e.worktreeId=r.worktreeId),e):null}return"string"==typeof r.type?r:null}},54014:(e,t,r)=>{r.d(t,{Ab:()=>o,NL:()=>y,O6:()=>p,XH:()=>n,f_:()=>d,hR:()=>c,lu:()=>g,n6:()=>s,oo:()=>u,pQ:()=>i,sw:()=>f,vz:()=>m});let n=["claude","codex","gemini","vibe-local","opencode","copilot","antigravity","command-code"],o=10,i=50,a=/^[a-zA-Z0-9_-]+$/;function s(e){return"string"==typeof e&&e.length>0&&e.length<=64&&a.test(e)}let l={claude:"Claude",codex:"Codex",gemini:"Gemini","vibe-local":"Vibe Local",opencode:"OpenCode",copilot:"Copilot",antigravity:"Antigravity","command-code":"Command Code"};function c(e){return n.includes(e)}function u(e){var t;return null!=(t=l[e])?t:e}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Assistant";return e&&c(e)?u(e):t}function f(e){let t=e.alias;return"string"==typeof t&&t.trim().length>0?t:u(e.cliTool)}function p(e,t,r){let n=e.find(e=>e.id===t);return n?f(n):u(r)}function g(e){return e.map((e,t)=>({id:e,cliTool:e,alias:u(e),order:t}))}let m=128,y=2097152},55449:(e,t,r)=>{r.d(t,{IK:()=>l,qD:()=>d,sA:()=>s,zk:()=>o});var n=r(63001);let o="/api/settings/default-agents",i=n.fJ,a=new Set;function s(){return i}function l(e){if(!Array.isArray(e))return!1;let t=(0,n.Lt)(e);if(!t.valid)return!1;let r=t.value;if(r.length===i.length&&r.every((e,t)=>e===i[t]))return!1;for(let e of(i=r,a))e();return!0}let c=null,u=!1;async function d(){return u?i:c||("function"!=typeof fetch?i:c=(async()=>{try{let e=await fetch(o);if(e.ok){let t=await e.json();l(null==t?void 0:t.defaultSelectedAgents),u=!0}}catch(e){}finally{c=null}return i})())}},63001:(e,t,r)=>{r.d(t,{Lt:()=>s,Wj:()=>i,eu:()=>o,fJ:()=>a});var n=r(54014);let o=2,i=6,a=["claude","codex","antigravity"];function s(e){return e.length<o||e.length>i?{valid:!1,error:"Must be ".concat(o,"-").concat(i," elements")}:e.every(e=>"string"==typeof e&&n.XH.includes(e))?new Set(e).size!==e.length?{valid:!1,error:"Duplicate tool IDs not allowed"}:{valid:!0,value:e}:{valid:!1,error:"Invalid CLI tool ID"}}},63365:(e,t,r)=>{r.d(t,{tS:()=>u,xM:()=>d,T3:()=>f});var n=r(95155),o=r(12115),i=r(52703);function a(){return"undefined"!=typeof globalThis&&"function"==typeof globalThis.WebSocket?globalThis.WebSocket:null}let s=()=>{},l={status:"disconnected",connected:!1,subscribe:s,unsubscribe:s,addListener:()=>s},c=(0,o.createContext)(null);function u(e){let{children:t,enabled:r=!0}=e,s=(0,o.useRef)(new Set),l=(0,o.useRef)(new Map),{status:u,subscribe:d,unsubscribe:f}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{onEvent:t,onStatusChange:r,autoReconnect:n=!0,reconnectBaseDelay:s=1e3,reconnectMaxDelay:l=3e4,enabled:c=!0}=e,[u,d]=(0,o.useState)("disconnected"),f=(0,o.useRef)(null),p=(0,o.useRef)(null),g=(0,o.useRef)(0),m=(0,o.useRef)(new Set),y=(0,o.useRef)(!1),h=(0,o.useRef)(t);h.current=t;let w=(0,o.useRef)(r);w.current=r;let b=(0,o.useCallback)(e=>{var t;d(e),null==(t=w.current)||t.call(w,e)},[]),S=(0,o.useCallback)(()=>{null!==p.current&&(clearTimeout(p.current),p.current=null)},[]),v=(0,o.useCallback)(()=>{if(!c)return;let e=a();if(!e||f.current&&(f.current.readyState===e.OPEN||f.current.readyState===e.CONNECTING))return;S(),y.current=!1,b("connecting");let t="https:"===window.location.protocol?"wss:":"ws:",r=new e("".concat(t,"//").concat(window.location.host));f.current=r,r.onopen=()=>{g.current=0,b("connected");try{r.send(JSON.stringify({type:i.ST,version:"0.34.0"}))}catch(e){}m.current.forEach(e=>{try{r.send(JSON.stringify({type:"subscribe",worktreeId:e}))}catch(e){}})},r.onmessage=e=>{var t;let r="string"==typeof e.data?e.data:String(e.data),n=(0,i.zS)(r);n&&(null==(t=h.current)||t.call(h,n))},r.onerror=()=>{b("error")},r.onclose=()=>{var e;if(f.current=null,b("disconnected"),y.current||!n||"undefined"!=typeof document&&"hidden"===document.visibilityState)return;let t=(e=g.current,Math.min(s*2**Math.max(0,e),l));g.current+=1,p.current=setTimeout(()=>{p.current=null,v()},t)}},[c,n,s,l,b,S]),E=(0,o.useCallback)(()=>{if(S(),y.current=!0,f.current){try{f.current.close(1e3,"Client disconnect")}catch(e){}f.current=null}},[S]),T=(0,o.useCallback)(e=>{let t=f.current,r=a();if(t&&r&&t.readyState===r.OPEN)try{t.send(JSON.stringify(e))}catch(e){}},[]),C=(0,o.useCallback)(e=>{m.current.has(e)||(m.current.add(e),T({type:"subscribe",worktreeId:e}))},[T]),k=(0,o.useCallback)(e=>{m.current.has(e)&&(m.current.delete(e),T({type:"unsubscribe",worktreeId:e}))},[T]);return(0,o.useEffect)(()=>{if(c)return v(),()=>{E()}},[c,v,E]),(0,o.useEffect)(()=>{if(!c||"undefined"==typeof document)return;let e=()=>{"visible"===document.visibilityState&&(f.current||(g.current=0,v()))};return document.addEventListener("visibilitychange",e),()=>document.removeEventListener("visibilitychange",e)},[c,v]),{status:u,subscribe:C,unsubscribe:k,send:T}}({enabled:r,onEvent:(0,o.useCallback)(e=>{s.current.forEach(t=>{try{t(e)}catch(e){}})},[])}),p=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;r.set(e,n+1),0===n&&d(e)},[d]),g=(0,o.useCallback)(e=>{var t;let r=l.current,n=null!=(t=r.get(e))?t:0;n<=1?(r.delete(e),f(e)):r.set(e,n-1)},[f]),m=(0,o.useCallback)(e=>(s.current.add(e),()=>{s.current.delete(e)}),[]),y=(0,o.useMemo)(()=>({status:u,connected:"connected"===u,subscribe:p,unsubscribe:g,addListener:m}),[u,p,g,m]);return(0,n.jsx)(c.Provider,{value:y,children:t})}function d(){var e;return null!=(e=(0,o.useContext)(c))?e:l}function f(e){let{addListener:t}=d(),r=(0,o.useRef)(e);r.current=e,(0,o.useEffect)(()=>t(e=>r.current(e)),[t])}},65380:(e,t,r)=>{r.d(t,{H:()=>s,O:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)(!1);function a(e){let{children:t,authEnabled:r}=e;return(0,n.jsx)(i.Provider,{value:r,children:t})}function s(){return(0,o.useContext)(i)}},66966:(e,t,r)=>{r.d(t,{g7:()=>u,rC:()=>f,Fn:()=>d});var n=r(95155),o=r(12115),i=r(80344),a=r(63365);let s=[2e3,5e3,1e4];var l=r(39649);let c=(0,o.createContext)(null);function u(e){let{children:t}=e,{worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)([]),[l,c]=(0,o.useState)(!0),[u,d]=(0,o.useState)(null),f=(0,o.useRef)(null),p=(0,o.useRef)([]),g=(0,o.useRef)(null),m=(0,o.useRef)(0),y=(0,o.useRef)(null),h=(0,o.useRef)(async()=>{}),w=(0,o.useCallback)(()=>{null!==y.current&&(clearTimeout(y.current),y.current=null)},[]),{connected:b,subscribe:S,unsubscribe:v,addListener:E}=(0,a.xM)(),T=(0,o.useRef)(b);T.current=b;let C=(0,o.useCallback)(async()=>{try{var e,r;d(null);let a=await fetch("/api/worktrees"),s=(0,i.O0)(a);if(s)throw s;if(!a.ok)throw Error("Failed to fetch worktrees: ".concat(a.status));let l=(0,i.xd)(a);if(l)throw l;let c=await a.json(),u=null!=(e=c.worktrees)?e:[],f=null!=(r=c.repositories)?r:[];(0,o.startTransition)(()=>{t(u),n(f)}),p.current=u,m.current=0,w()}catch(r){let e=r instanceof Error?r:Error(String(r));console.error("[useWorktreesCache] Failed to fetch worktrees:",e),d(e);let t=m.current;0===p.current.length&&t<s.length&&(m.current=t+1,w(),y.current=setTimeout(()=>{y.current=null,h.current()},s[t]))}finally{c(!1)}},[w]);h.current=C,(0,o.useEffect)(()=>{C()},[C]),(0,o.useEffect)(()=>w,[w]);let k=(0,o.useCallback)(()=>p.current.some(e=>!0===e.isSessionRunning),[]),O=(0,o.useCallback)(()=>{let e=k();return T.current?e?2e4:6e4:e?5e3:3e4},[k]),R=(0,o.useCallback)(()=>{null!==f.current&&(clearInterval(f.current),f.current=null),g.current=null},[]),x=(0,o.useCallback)(()=>{R();let e=O();g.current=e,f.current=setInterval(()=>{C()},e)},[O,C,R]);(0,o.useEffect)(()=>{let e=()=>{document.hidden?R():(C(),x())},t=setTimeout(()=>{x()},0);return document.addEventListener("visibilitychange",e),()=>{clearTimeout(t),R(),document.removeEventListener("visibilitychange",e)}},[C,x,R]),(0,o.useEffect)(()=>{if(p.current=e,"undefined"!=typeof document&&document.hidden||null===g.current)return;let t=O();g.current!==t&&x()},[e,b,O,x]);let N=e.map(e=>e.id).sort().join(" ");return(0,o.useEffect)(()=>{let e=N.length>0?N.split(" "):[];return e.forEach(e=>S(e)),()=>{e.forEach(e=>v(e))}},[N,S,v]),(0,o.useEffect)(()=>E(e=>{if("session_status_changed"===e.type&&"string"==typeof e.worktreeId){let i=e.worktreeId,a=e.isWaitingForResponse;if("boolean"==typeof a){var r,n;let s=null!=(r=e.instance)?r:null,l=null!=(n=e.waitingKind)?n:null;(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>{if(e.id!==i)return e;let r=function(e,t){var r,n,o;let i,a=null!=(n=t.instance)?n:null,s=a?null==(r=e.sessionStatusByInstance)?void 0:r[a]:void 0,l=e.sessionStatusByInstance;if(a&&s&&s.isWaitingForResponse!==t.waiting&&(l={...e.sessionStatusByInstance,[a]:{...s,isWaitingForResponse:t.waiting,waitingKind:null!=(o=t.waitingKind)?o:null}}),t.waiting)i=!0;else{let e=l?Object.values(l):[];i=e.length>0&&e.some(e=>(null==e?void 0:e.isWaitingForResponse)===!0)}return l===e.sessionStatusByInstance&&i===e.isWaitingForResponse?e:{...e,sessionStatusByInstance:l,isWaitingForResponse:i}}(e,{waiting:a,instance:s,waitingKind:l});return r!==e&&(t=!0),r});return t?r:e})});return}let s=e.isRunning;if("boolean"==typeof s){if((null!=e.cliTool||null!=e.instance)&&!1===s)return void C();(0,o.startTransition)(()=>{t(e=>{let t=!1,r=e.map(e=>e.id===i&&e.isSessionRunning!==s?(t=!0,{...e,isSessionRunning:s}):e);return t?r:e})})}}else("message"===e.type||"message_updated"===e.type)&&C()}),[E,C]),{worktrees:e,repositories:r,isLoading:l,error:u,refresh:C}}(),g=(0,o.useMemo)(()=>({worktrees:r,repositories:u,isLoading:d,error:f,refresh:p}),[r,u,d,f,p]);return(0,n.jsx)(c.Provider,{value:g,children:(0,n.jsx)(l.H8,{externalWorktrees:r,externalRepositories:u,externalIsLoading:d,externalError:f,externalRefresh:p,children:t})})}function d(){let e=(0,o.useContext)(c);if(null===e)throw Error("useWorktreesCacheContext must be used within a WorktreesCacheProvider");return e}function f(){return(0,o.useContext)(c)}},68704:(e,t,r)=>{r.d(t,{Uf:()=>i,d8:()=>a,fM:()=>s,of:()=>c,r5:()=>o,rq:()=>l});var n=r(2317);let o="medium",i=["large","medium","small","xsmall"],a={large:{value:"large",rootFontSizePx:18,factor:1.125,terminalFontSize:16},medium:{value:"medium",rootFontSizePx:16,factor:1,terminalFontSize:14},small:{value:"small",rootFontSizePx:14,factor:.875,terminalFontSize:12},xsmall:{value:"xsmall",rootFontSizePx:12.5,factor:.78,terminalFontSize:11}};function s(e){return"string"==typeof e&&Object.prototype.hasOwnProperty.call(a,e)}function l(e){return a[e].terminalFontSize}function c(){let{value:e,setValue:t,isAvailable:r}=(0,n.V)({key:"mcbd-pc-display-size",defaultValue:o,validate:s});return{size:e,setSize:t,isAvailable:r}}},70628:(e,t,r)=>{r.d(t,{K:()=>s,S:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},77016:(e,t,r)=>{r.d(t,{W:()=>w,n:()=>b});var n=r(95155),o=r(12115),i=r(18955),a=r(52056),s=r(89559),l=r(65229),c=r(59854),u=r(63365),d=r(52703);let f=0,p=new Set;function g(){for(let e of p)e()}function m(e){return p.add(e),()=>{p.delete(e)}}function y(){return f>0}function h(){return!1}function w(){return(0,o.useSyncExternalStore)(m,y,h)}function b(){let e=(0,i.c)("common"),[t,r]=(0,o.useState)(null),[p,m]=(0,o.useState)(null),y=(0,o.useCallback)(e=>{if(e.type!==d.Oo)return;let{serverVersion:t,clientVersion:n}=e;"string"==typeof t&&"string"==typeof n&&t&&n&&t!==p&&r({serverVersion:t,clientVersion:n})},[p]);(0,u.T3)(y);let h=null!==t;(0,o.useEffect)(()=>{if(h)return f+=1,g(),()=>{f-=1,g()}},[h]);let w=(0,o.useCallback)(()=>{window.location.reload()},[]),b=(0,o.useCallback)(()=>{r(e=>(e&&m(e.serverVersion),null))},[]);return t?(0,n.jsxs)("div",{"data-testid":"version-mismatch-banner",role:"alert","aria-live":"assertive",className:"fixed top-3 left-1/2 -translate-x-1/2 flex items-start gap-3 max-w-[92vw] rounded-lg border border-warning-border bg-warning-subtle px-4 py-3 text-warning-foreground shadow-lg",style:{zIndex:c.M.TOAST},children:[(0,n.jsx)(a.A,{className:"h-5 w-5 shrink-0 mt-0.5","aria-hidden":"true"}),(0,n.jsxs)("div",{className:"flex flex-col gap-0.5 text-sm",children:[(0,n.jsx)("span",{className:"font-semibold",children:e("versionMismatch.title")}),(0,n.jsx)("span",{children:e("versionMismatch.description",{serverVersion:t.serverVersion,clientVersion:t.clientVersion})})]}),(0,n.jsxs)("button",{type:"button","data-testid":"version-mismatch-reload",onClick:w,className:"shrink-0 inline-flex items-center gap-1.5 rounded-md border border-warning-border px-3 py-1.5 text-sm font-medium hover:opacity-80 focus:outline-none focus:ring-2 focus:ring-offset-2",children:[(0,n.jsx)(s.A,{className:"h-4 w-4","aria-hidden":"true"}),e("versionMismatch.reload")]}),(0,n.jsx)("button",{type:"button","data-testid":"version-mismatch-dismiss",onClick:b,"aria-label":e("versionMismatch.dismiss"),className:"shrink-0 hover:opacity-70 focus:outline-none focus:ring-2 focus:ring-offset-2",children:(0,n.jsx)(l.A,{className:"h-4 w-4","aria-hidden":"true"})})]}):null}},80344:(e,t,r)=>{r.d(t,{$T:()=>d,GQ:()=>p,O0:()=>i,Rx:()=>c,gC:()=>u,hD:()=>n,hS:()=>f,xd:()=>a,y:()=>l});class n extends Error{constructor(e,t,r){super(e),this.status=t,this.data=r,this.name="ApiError"}}async function o(e,t,r){if(!(e.headers.get("content-type")||"").includes("application/json"))return t;try{return await e.json()}catch(e){return t}}function i(e){var t;return e.redirected&&(null!=(t=e.url)?t:"").includes("/login")?new n("Authentication required",401):null}function a(e){return e.headers?(e.headers.get("content-type")||"").includes("application/json")?null:new n("Unexpected response format",e.status):null}async function s(e,t){try{let r=new Headers(null==t?void 0:t.headers);r.set("Content-Type","application/json");let s=await fetch(e,{...t,headers:r}),l=i(s);if(l)throw l;if(!s.ok){let e=await o(s,{},"error-body");throw new n(e.error||"HTTP error ".concat(s.status),s.status,e)}let c=a(s);if(c)throw c;return s.json()}catch(e){if(e instanceof n)throw e;throw new n(e instanceof Error?e.message:"Unknown error",0,e)}}let l={getAll:async()=>s("/api/worktrees"),getById:async e=>s("/api/worktrees/".concat(e)),updateDescription:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({description:t})}),updateLink:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({link:t})}),toggleFavorite:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({favorite:t})}),updateStatus:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({status:t})}),updateCliTool:async(e,t)=>s("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({cliToolId:t})}),markAsViewed:async e=>s("/api/worktrees/".concat(e,"/viewed"),{method:"PATCH"}),async getMessages(e,t,r,n){let o=new URLSearchParams;return t&&o.append("cliTool",t),r&&o.append("includeArchived","true"),"number"==typeof n&&Number.isFinite(n)&&o.append("limit",String(n)),s("/api/worktrees/".concat(e,"/messages").concat(o.toString()?"?".concat(o.toString()):""))},async sendMessage(e,t,r){var n;let o={content:t};return(null==r?void 0:r.cliToolId)&&(o.cliToolId=r.cliToolId),(null==r?void 0:r.instanceId)&&(o.instanceId=r.instanceId),(null==r?void 0:r.imagePath)&&(o.imagePath=r.imagePath),null===(n=await s("/api/worktrees/".concat(e,"/send"),{method:"POST",body:JSON.stringify(o)}))||"object"!=typeof n||n.timestamp instanceof Date?n:{...n,timestamp:new Date(n.timestamp)}},async uploadImageFile(e,t){let r=Date.now(),n="".concat(r,"-").concat(t.name),i=".commandmate/attachments",a=new FormData;a.append("file",new File([t],n,{type:t.type}));let s=await fetch("/api/worktrees/".concat(e,"/upload/").concat(i),{method:"POST",body:a});if(!s.ok){var l;let e=await o(s,{},"error-body");throw Error((null==e||null==(l=e.error)?void 0:l.message)||"Upload failed (HTTP ".concat(s.status,")"))}return{path:(await o(s,{},"response-body")).path||"".concat(i,"/").concat(n)}},getLogs:async e=>s("/api/worktrees/".concat(e,"/logs")),async getLogFile(e,t,r){let n=(null==r?void 0:r.sanitize)?"?sanitize=true":"";return s("/api/worktrees/".concat(e,"/logs/").concat(t).concat(n))},async killSession(e,t,r){let n=new URLSearchParams;t&&n.set("cliTool",t),r&&n.set("instance",r);let o=n.toString();return s("/api/worktrees/".concat(e,"/kill-session").concat(o?"?".concat(o):""),{method:"POST"})}},c={scan:async e=>s("/api/repositories/scan",{method:"POST",body:JSON.stringify({repositoryPath:e})}),sync:async()=>s("/api/repositories/sync",{method:"POST"}),delete:async e=>s("/api/repositories",{method:"DELETE",body:JSON.stringify({repositoryPath:e})}),async clone(e,t){var r;return s("/api/repositories/clone",{method:"POST",body:JSON.stringify({cloneUrl:e,fork:null!=(r=null==t?void 0:t.fork)&&r})})},getCloneStatus:async e=>s("/api/repositories/clone/".concat(e)),getExcluded:async()=>s("/api/repositories/excluded"),restore:async e=>s("/api/repositories/restore",{method:"PUT",body:JSON.stringify({repositoryPath:e})}),list:async()=>s("/api/repositories"),updateDisplayName:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({displayName:t})}),updateVisibility:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({visible:t})}),updateEnabled:async(e,t)=>s("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({enabled:t})}),validatePath:async e=>s("/api/repositories/validate-path",{method:"POST",body:JSON.stringify({repositoryPath:e})})},u={async browse(e){let t=e?"?path=".concat(encodeURIComponent(e)):"";return s("/api/fs/browse".concat(t))},addRecentPath:async e=>s("/api/fs/recent-paths",{method:"POST",body:JSON.stringify({path:e})})},d={getAll:async e=>(await s("/api/worktrees/".concat(e,"/memos"))).memos,create:async(e,t)=>(await s("/api/worktrees/".concat(e,"/memos"),{method:"POST",body:JSON.stringify(t||{})})).memo,update:async(e,t,r)=>(await s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"PUT",body:JSON.stringify(r)})).memo,delete:async(e,t)=>s("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"DELETE"}),async reorder(e,t){await s("/api/worktrees/".concat(e,"/memos"),{method:"PATCH",body:JSON.stringify({memoIds:t})})}};function f(e){return e instanceof n||e instanceof Error?e.message:"An unknown error occurred"}let p={checkForUpdate:async()=>s("/api/app/update-check",{method:"GET"}),startUpdate:async()=>s("/api/app/update",{method:"POST"}),async ping(){try{return(await fetch("/api/auth/status",{cache:"no-store"})).ok}catch(e){return!1}}}},89275:(e,t,r)=>{r.d(t,{Bo:()=>u,Hq:()=>l});var n=r(95155),o=r(12115),i=r(20063);let a={startTransition:e=>e()},s=(0,o.createContext)(null);function l(){var e;let t=(0,i.useRouter)(),{startTransition:r}=null!=(e=(0,o.useContext)(s))?e:a;return(0,o.useMemo)(()=>({push:e=>r(()=>t.push(e)),replace:e=>r(()=>t.replace(e))}),[t,r])}function c(e){let{onCommit:t}=e,r=(0,i.usePathname)(),n=(0,o.useRef)(!1);return(0,o.useEffect)(()=>{if(!n.current){n.current=!0;return}t()},[r,t]),null}function u(e){let{children:t}=e,r=(0,o.useRef)(null),i=(0,o.useCallback)(()=>{var e;null==(e=r.current)||e.call(r)},[]),a=(0,o.useCallback)(e=>{var t;t=()=>new Promise(t=>{let n=!1,o=()=>{n||(n=!0,t())};r.current=o,e(),window.setTimeout(o,500)}),"undefined"==typeof document||"function"!=typeof document.startViewTransition||"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?t():document.startViewTransition(t)},[]),l=(0,o.useMemo)(()=>({startTransition:a}),[a]);return(0,n.jsxs)(s.Provider,{value:l,children:[(0,n.jsx)(c,{onCommit:i}),t]})}},92614:(e,t,r)=>{r.d(t,{C:()=>s,E:()=>a});var n=r(95155),o=r(12115);let i=(0,o.createContext)({open:!1,setOpen:()=>{},toggle:()=>{}});function a(e){let{children:t}=e,[r,a]=(0,o.useState)(!1),s=(0,o.useCallback)(()=>a(e=>!e),[]),l=(0,o.useMemo)(()=>({open:r,setOpen:a,toggle:s}),[r,s]);return(0,n.jsx)(i.Provider,{value:l,children:t})}function s(){return(0,o.useContext)(i)}},94442:(e,t,r)=>{r.d(t,{dj:()=>v,tE:()=>S});var n=r(95155),o=r(12115),i=r(47650),a=r(18955),s=r(42529),l=r(78874),c=r(52056),u=r(23327),d=r(65229),f=r(59854),p=r(9900),g=r(9286);function m(e){let{type:t,iconColor:r}=e,o="h-5 w-5 ".concat(r);switch(t){case"success":return(0,n.jsx)(s.A,{className:o,"data-testid":"toast-icon-success"});case"error":return(0,n.jsx)(l.A,{className:o,"data-testid":"toast-icon-error"});case"warning":return(0,n.jsx)(c.A,{className:o,"data-testid":"toast-icon-warning"});default:return(0,n.jsx)(u.A,{className:o,"data-testid":"toast-icon-info"})}}function y(e){let{id:t,message:r,type:i,onClose:s,duration:l=3e3,onClick:c}=e,u=(0,a.c)("common"),f=(0,o.useRef)(null),y=function(e){switch(e){case"success":return{bgColor:"bg-success-subtle",borderColor:"border-success-border",textColor:"text-success-foreground",iconColor:"text-success-foreground"};case"error":return{bgColor:"bg-danger-subtle",borderColor:"border-danger-border",textColor:"text-danger-foreground",iconColor:"text-danger-foreground"};case"warning":return{bgColor:"bg-warning-subtle",borderColor:"border-warning-border",textColor:"text-warning-foreground",iconColor:"text-warning-foreground"};default:return{bgColor:"bg-info-subtle",borderColor:"border-info-border",textColor:"text-info-foreground",iconColor:"text-info-foreground"}}}(i),[h,w]=(0,o.useState)(!0),{shouldRender:b,isExiting:S}=(0,g.O)(h,p.Ys),v=(0,o.useRef)(s);v.current=s,(0,o.useEffect)(()=>{b||v.current(t)},[b,t]),(0,o.useEffect)(()=>(l>0&&(f.current=setTimeout(()=>{w(!1)},l)),()=>{f.current&&clearTimeout(f.current)}),[l]);let E=(0,o.useCallback)(()=>{f.current&&clearTimeout(f.current),w(!1)},[]);return(0,n.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(y.bgColor,"\n ").concat(y.borderColor,"\n ").concat(y.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n ").concat(S?"animate-out fade-out-0 slide-out-to-right-full duration-200 fill-mode-forwards pointer-events-none":"animate-slide-in","\n "),children:[(0,n.jsx)(m,{type:i,iconColor:y.iconColor}),c?(0,n.jsx)("button",{type:"button","data-testid":"toast-action-button",onClick:()=>{c(),E()},className:"flex-1 text-left text-sm font-medium underline-offset-2 hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-ring rounded-sm",children:r}):(0,n.jsx)("p",{className:"flex-1 text-sm font-medium",children:r}),(0,n.jsx)("button",{"data-testid":"toast-close-button",onClick:E,"aria-label":u("closeNotification"),className:"\n ".concat(y.textColor,"\n hover:opacity-70\n focus:outline-none focus:ring-2 focus:ring-offset-2\n transition-opacity\n "),children:(0,n.jsx)(d.A,{className:"h-4 w-4"})})]})}function h(e){let{toasts:t,onClose:r}=e,[a,s]=(0,o.useState)(!1);(0,o.useEffect)(()=>{s(!0)},[]);let l=(0,n.jsx)("div",{"data-testid":"toast-container","aria-live":"polite",className:"fixed bottom-4 right-4 flex flex-col gap-2",style:{zIndex:f.M.TOAST},children:t.map(e=>(0,n.jsx)(y,{id:e.id,message:e.message,type:e.type,onClose:r,duration:e.duration,onClick:e.onClick},e.id))});return a?(0,i.createPortal)(l,document.body):null}function w(){let[e,t]=(0,o.useState)([]),r=(0,o.useRef)(0),n=(0,o.useCallback)(function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3e3,i=arguments.length>3?arguments[3]:void 0,a="toast-".concat(++r.current,"-").concat(Date.now()),s={id:a,message:e,type:n,duration:o,...(null==i?void 0:i.onClick)?{onClick:i.onClick}:{}};return t(e=>[...e,s]),a},[]),i=(0,o.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),a=(0,o.useCallback)(()=>{t([])},[]);return(0,o.useMemo)(()=>({toasts:e,showToast:n,removeToast:i,clearToasts:a}),[e,n,i,a])}let b=(0,o.createContext)(null);function S(e){let{children:t}=e,r=w();return(0,n.jsxs)(b.Provider,{value:r,children:[t,(0,n.jsx)(h,{toasts:r.toasts,onClose:r.removeToast})]})}function v(){let e=(0,o.useContext)(b),t=w();return null!=e?e:t}}}]);
|