commandmate 0.25.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +141 -141
  3. package/.next/app-path-routes-manifest.json +28 -28
  4. package/.next/build-manifest.json +2 -2
  5. package/.next/prerender-manifest.json +12 -12
  6. package/.next/required-server-files.json +1 -1
  7. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  8. package/.next/server/app/api/app/update/route_client-reference-manifest.js +1 -1
  9. package/.next/server/app/api/app/update-check/route.js +1 -1
  10. package/.next/server/app/api/app/update-check/route_client-reference-manifest.js +1 -1
  11. package/.next/server/app/api/assistant/conversation/route_client-reference-manifest.js +1 -1
  12. package/.next/server/app/api/assistant/current-output/route_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/assistant/messages/route_client-reference-manifest.js +1 -1
  14. package/.next/server/app/api/assistant/session/route_client-reference-manifest.js +1 -1
  15. package/.next/server/app/api/assistant/start/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/assistant/terminal/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/assistant/tools/route_client-reference-manifest.js +1 -1
  18. package/.next/server/app/api/auth/login/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/auth/logout/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/auth/status/route_client-reference-manifest.js +1 -1
  21. package/.next/server/app/api/daily-summary/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/daily-summary/status/route_client-reference-manifest.js +1 -1
  23. package/.next/server/app/api/external-apps/[id]/health/route_client-reference-manifest.js +1 -1
  24. package/.next/server/app/api/external-apps/[id]/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/external-apps/route_client-reference-manifest.js +1 -1
  26. package/.next/server/app/api/fs/browse/route_client-reference-manifest.js +1 -1
  27. package/.next/server/app/api/fs/recent-paths/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/hooks/agent-event/route_client-reference-manifest.js +1 -1
  29. package/.next/server/app/api/hooks/claude-done/route_client-reference-manifest.js +1 -1
  30. package/.next/server/app/api/hooks/permission-request/route.js +1 -1
  31. package/.next/server/app/api/hooks/permission-request/route_client-reference-manifest.js +1 -1
  32. package/.next/server/app/api/metrics/vibe/route_client-reference-manifest.js +1 -1
  33. package/.next/server/app/api/ollama/models/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/push/escalation/route_client-reference-manifest.js +1 -1
  35. package/.next/server/app/api/push/subscriptions/route_client-reference-manifest.js +1 -1
  36. package/.next/server/app/api/push/vapid/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/repositories/[id]/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/repositories/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  39. package/.next/server/app/api/repositories/[id]/todos/route_client-reference-manifest.js +1 -1
  40. package/.next/server/app/api/repositories/clone/[jobId]/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/repositories/clone/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/repositories/excluded/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/repositories/restore/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/repositories/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/api/repositories/scan/route_client-reference-manifest.js +1 -1
  46. package/.next/server/app/api/repositories/sync/route_client-reference-manifest.js +1 -1
  47. package/.next/server/app/api/repositories/validate-path/route_client-reference-manifest.js +1 -1
  48. package/.next/server/app/api/sidebar/group-order/route_client-reference-manifest.js +1 -1
  49. package/.next/server/app/api/skills/[id]/route_client-reference-manifest.js +1 -1
  50. package/.next/server/app/api/skills/installations/route_client-reference-manifest.js +1 -1
  51. package/.next/server/app/api/skills/operations/route_client-reference-manifest.js +1 -1
  52. package/.next/server/app/api/skills/reindex/route_client-reference-manifest.js +1 -1
  53. package/.next/server/app/api/skills/route_client-reference-manifest.js +1 -1
  54. package/.next/server/app/api/slash-commands/route_client-reference-manifest.js +1 -1
  55. package/.next/server/app/api/tasks/[taskId]/cancel/route_client-reference-manifest.js +1 -1
  56. package/.next/server/app/api/tasks/[taskId]/route_client-reference-manifest.js +1 -1
  57. package/.next/server/app/api/templates/[id]/route_client-reference-manifest.js +1 -1
  58. package/.next/server/app/api/templates/route_client-reference-manifest.js +1 -1
  59. package/.next/server/app/api/todos/route_client-reference-manifest.js +1 -1
  60. package/.next/server/app/api/verification/runs/[runId]/route_client-reference-manifest.js +1 -1
  61. package/.next/server/app/api/verification/runs/route_client-reference-manifest.js +1 -1
  62. package/.next/server/app/api/worktrees/[id]/auto-yes/route_client-reference-manifest.js +1 -1
  63. package/.next/server/app/api/worktrees/[id]/capture/route_client-reference-manifest.js +1 -1
  64. package/.next/server/app/api/worktrees/[id]/cli-tool/route_client-reference-manifest.js +1 -1
  65. package/.next/server/app/api/worktrees/[id]/cmate/schedules/route_client-reference-manifest.js +1 -1
  66. package/.next/server/app/api/worktrees/[id]/current-output/route.js +1 -1
  67. package/.next/server/app/api/worktrees/[id]/current-output/route_client-reference-manifest.js +1 -1
  68. package/.next/server/app/api/worktrees/[id]/execution-logs/[logId]/route_client-reference-manifest.js +1 -1
  69. package/.next/server/app/api/worktrees/[id]/execution-logs/route_client-reference-manifest.js +1 -1
  70. package/.next/server/app/api/worktrees/[id]/files/[...path]/route_client-reference-manifest.js +1 -1
  71. package/.next/server/app/api/worktrees/[id]/git/branch/create/route_client-reference-manifest.js +1 -1
  72. package/.next/server/app/api/worktrees/[id]/git/branch/delete/route_client-reference-manifest.js +1 -1
  73. package/.next/server/app/api/worktrees/[id]/git/branches/route_client-reference-manifest.js +1 -1
  74. package/.next/server/app/api/worktrees/[id]/git/checkout/route_client-reference-manifest.js +1 -1
  75. package/.next/server/app/api/worktrees/[id]/git/commit/route_client-reference-manifest.js +1 -1
  76. package/.next/server/app/api/worktrees/[id]/git/diff/route_client-reference-manifest.js +1 -1
  77. package/.next/server/app/api/worktrees/[id]/git/fetch/route_client-reference-manifest.js +1 -1
  78. package/.next/server/app/api/worktrees/[id]/git/log/route_client-reference-manifest.js +1 -1
  79. package/.next/server/app/api/worktrees/[id]/git/pull/route_client-reference-manifest.js +1 -1
  80. package/.next/server/app/api/worktrees/[id]/git/push/route_client-reference-manifest.js +1 -1
  81. package/.next/server/app/api/worktrees/[id]/git/reset/route_client-reference-manifest.js +1 -1
  82. package/.next/server/app/api/worktrees/[id]/git/revert/route_client-reference-manifest.js +1 -1
  83. package/.next/server/app/api/worktrees/[id]/git/show/[commitHash]/route_client-reference-manifest.js +1 -1
  84. package/.next/server/app/api/worktrees/[id]/git/stage/route_client-reference-manifest.js +1 -1
  85. package/.next/server/app/api/worktrees/[id]/git/staged/route_client-reference-manifest.js +1 -1
  86. package/.next/server/app/api/worktrees/[id]/git/stash/[index]/route_client-reference-manifest.js +1 -1
  87. package/.next/server/app/api/worktrees/[id]/git/stash/apply/route_client-reference-manifest.js +1 -1
  88. package/.next/server/app/api/worktrees/[id]/git/stash/pop/route_client-reference-manifest.js +1 -1
  89. package/.next/server/app/api/worktrees/[id]/git/stash/push/route_client-reference-manifest.js +1 -1
  90. package/.next/server/app/api/worktrees/[id]/git/stash/route_client-reference-manifest.js +1 -1
  91. package/.next/server/app/api/worktrees/[id]/git/status/route_client-reference-manifest.js +1 -1
  92. package/.next/server/app/api/worktrees/[id]/git/unstage/route_client-reference-manifest.js +1 -1
  93. package/.next/server/app/api/worktrees/[id]/git/working-diff/route_client-reference-manifest.js +1 -1
  94. package/.next/server/app/api/worktrees/[id]/interrupt/route_client-reference-manifest.js +1 -1
  95. package/.next/server/app/api/worktrees/[id]/kill-session/route_client-reference-manifest.js +1 -1
  96. package/.next/server/app/api/worktrees/[id]/logs/[filename]/route_client-reference-manifest.js +1 -1
  97. package/.next/server/app/api/worktrees/[id]/logs/route_client-reference-manifest.js +1 -1
  98. package/.next/server/app/api/worktrees/[id]/marp-render/route_client-reference-manifest.js +1 -1
  99. package/.next/server/app/api/worktrees/[id]/memos/[memoId]/route_client-reference-manifest.js +1 -1
  100. package/.next/server/app/api/worktrees/[id]/memos/route_client-reference-manifest.js +1 -1
  101. package/.next/server/app/api/worktrees/[id]/messages/route_client-reference-manifest.js +1 -1
  102. package/.next/server/app/api/worktrees/[id]/prompt-response/route_client-reference-manifest.js +1 -1
  103. package/.next/server/app/api/worktrees/[id]/respond/route_client-reference-manifest.js +1 -1
  104. package/.next/server/app/api/worktrees/[id]/route_client-reference-manifest.js +1 -1
  105. package/.next/server/app/api/worktrees/[id]/schedules/[scheduleId]/route_client-reference-manifest.js +1 -1
  106. package/.next/server/app/api/worktrees/[id]/schedules/active/route_client-reference-manifest.js +1 -1
  107. package/.next/server/app/api/worktrees/[id]/schedules/route_client-reference-manifest.js +1 -1
  108. package/.next/server/app/api/worktrees/[id]/search/route_client-reference-manifest.js +1 -1
  109. package/.next/server/app/api/worktrees/[id]/send/route_client-reference-manifest.js +1 -1
  110. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/git-workflow/route_client-reference-manifest.js +1 -1
  111. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/install/route_client-reference-manifest.js +1 -1
  112. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/plan/route_client-reference-manifest.js +1 -1
  113. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall/route_client-reference-manifest.js +1 -1
  114. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/uninstall-plan/route_client-reference-manifest.js +1 -1
  115. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update/route_client-reference-manifest.js +1 -1
  116. package/.next/server/app/api/worktrees/[id]/skills/[skillId]/update-plan/route_client-reference-manifest.js +1 -1
  117. package/.next/server/app/api/worktrees/[id]/skills/route_client-reference-manifest.js +1 -1
  118. package/.next/server/app/api/worktrees/[id]/slash-commands/route_client-reference-manifest.js +1 -1
  119. package/.next/server/app/api/worktrees/[id]/special-keys/route_client-reference-manifest.js +1 -1
  120. package/.next/server/app/api/worktrees/[id]/start-polling/route_client-reference-manifest.js +1 -1
  121. package/.next/server/app/api/worktrees/[id]/tasks/route_client-reference-manifest.js +1 -1
  122. package/.next/server/app/api/worktrees/[id]/terminal/route_client-reference-manifest.js +1 -1
  123. package/.next/server/app/api/worktrees/[id]/timers/history/route_client-reference-manifest.js +1 -1
  124. package/.next/server/app/api/worktrees/[id]/timers/route_client-reference-manifest.js +1 -1
  125. package/.next/server/app/api/worktrees/[id]/todos/[todoId]/route_client-reference-manifest.js +1 -1
  126. package/.next/server/app/api/worktrees/[id]/todos/route_client-reference-manifest.js +1 -1
  127. package/.next/server/app/api/worktrees/[id]/tree/[...path]/route_client-reference-manifest.js +1 -1
  128. package/.next/server/app/api/worktrees/[id]/tree/route_client-reference-manifest.js +1 -1
  129. package/.next/server/app/api/worktrees/[id]/upload/[...path]/route_client-reference-manifest.js +1 -1
  130. package/.next/server/app/api/worktrees/[id]/verify/route_client-reference-manifest.js +1 -1
  131. package/.next/server/app/api/worktrees/[id]/verify/runs/[runId]/route_client-reference-manifest.js +1 -1
  132. package/.next/server/app/api/worktrees/[id]/verify/runs/route_client-reference-manifest.js +1 -1
  133. package/.next/server/app/api/worktrees/[id]/viewed/route_client-reference-manifest.js +1 -1
  134. package/.next/server/app/api/worktrees/route_client-reference-manifest.js +1 -1
  135. package/.next/server/app/chat/page_client-reference-manifest.js +1 -1
  136. package/.next/server/app/login/page_client-reference-manifest.js +1 -1
  137. package/.next/server/app/manifest.webmanifest/route_client-reference-manifest.js +1 -1
  138. package/.next/server/app/more/page_client-reference-manifest.js +1 -1
  139. package/.next/server/app/offline/page_client-reference-manifest.js +1 -1
  140. package/.next/server/app/page_client-reference-manifest.js +1 -1
  141. package/.next/server/app/proxy/[...path]/route_client-reference-manifest.js +1 -1
  142. package/.next/server/app/repositories/page_client-reference-manifest.js +1 -1
  143. package/.next/server/app/review/page_client-reference-manifest.js +1 -1
  144. package/.next/server/app/sessions/page_client-reference-manifest.js +1 -1
  145. package/.next/server/app/skills/[skillId]/page_client-reference-manifest.js +1 -1
  146. package/.next/server/app/skills/installed/page_client-reference-manifest.js +1 -1
  147. package/.next/server/app/skills/page_client-reference-manifest.js +1 -1
  148. package/.next/server/app/worktrees/[id]/files/[...path]/page_client-reference-manifest.js +1 -1
  149. package/.next/server/app/worktrees/[id]/page.js +1 -1
  150. package/.next/server/app/worktrees/[id]/page_client-reference-manifest.js +1 -1
  151. package/.next/server/app/worktrees/[id]/terminal/page_client-reference-manifest.js +1 -1
  152. package/.next/server/app-paths-manifest.json +28 -28
  153. package/.next/server/chunks/3241.js +1 -1
  154. package/.next/server/chunks/4455.js +1 -1
  155. package/.next/server/chunks/5959.js +4 -4
  156. package/.next/server/chunks/6130.js +1 -1
  157. package/.next/server/chunks/6274.js +12 -9
  158. package/.next/server/chunks/7458.js +6 -6
  159. package/.next/server/chunks/9373.js +4 -3
  160. package/.next/server/middleware-manifest.json +5 -5
  161. package/.next/server/pages/500.html +1 -1
  162. package/.next/server/pages-manifest.json +1 -1
  163. package/.next/server/server-reference-manifest.json +1 -1
  164. package/.next/static/chunks/{6381-51f9c4a128aadc0b.js → 6381-0e097c0286155883.js} +1 -1
  165. package/.next/static/chunks/app/worktrees/[id]/{page-207c69540fd856ef.js → page-fdfca039b7f5837e.js} +1 -1
  166. package/.next/trace +12 -12
  167. package/dist/cli/commands/task.d.ts.map +1 -1
  168. package/dist/cli/commands/task.js +2 -1
  169. package/dist/cli/commands/verify.d.ts +14 -0
  170. package/dist/cli/commands/verify.d.ts.map +1 -1
  171. package/dist/cli/commands/verify.js +109 -3
  172. package/dist/cli/commands/wait.d.ts +2 -0
  173. package/dist/cli/commands/wait.d.ts.map +1 -1
  174. package/dist/cli/commands/wait.js +184 -4
  175. package/dist/cli/types/api-responses.d.ts +172 -0
  176. package/dist/cli/types/api-responses.d.ts.map +1 -1
  177. package/dist/cli/types/index.d.ts +31 -0
  178. package/dist/cli/types/index.d.ts.map +1 -1
  179. package/dist/cli/types/index.js +26 -0
  180. package/dist/cli/utils/verify-runner.d.ts +36 -1
  181. package/dist/cli/utils/verify-runner.d.ts.map +1 -1
  182. package/dist/cli/utils/verify-runner.js +114 -6
  183. package/dist/server/src/lib/auto-yes-state.js +108 -3
  184. package/dist/server/src/lib/cli-tools/antigravity.js +8 -4
  185. package/dist/server/src/lib/cli-tools/codex.js +5 -1
  186. package/dist/server/src/lib/cli-tools/copilot.js +5 -1
  187. package/dist/server/src/lib/cli-tools/gemini.js +15 -15
  188. package/dist/server/src/lib/cli-tools/opencode.js +9 -3
  189. package/dist/server/src/lib/detection/upstream-faults.js +120 -0
  190. package/dist/server/src/lib/hooks/permission-decision-service.js +13 -5
  191. package/dist/server/src/lib/hooks/sources/antigravity/hooks-config.js +18 -11
  192. package/dist/server/src/lib/hooks/sources/antigravity/source.js +10 -9
  193. package/dist/server/src/lib/hooks/sources/claude/source.js +5 -2
  194. package/dist/server/src/lib/hooks/sources/codex/hooks-config.js +26 -18
  195. package/dist/server/src/lib/hooks/sources/codex/source.js +6 -9
  196. package/dist/server/src/lib/hooks/sources/copilot/hook-settings.js +22 -12
  197. package/dist/server/src/lib/hooks/sources/copilot/source.js +1 -1
  198. package/dist/server/src/lib/hooks/sources/define-source.js +6 -4
  199. package/dist/server/src/lib/hooks/sources/gemini/settings-generator.js +14 -8
  200. package/dist/server/src/lib/hooks/sources/gemini/source.js +29 -29
  201. package/dist/server/src/lib/hooks/sources/index.js +4 -1
  202. package/dist/server/src/lib/hooks/sources/launch-command.js +61 -0
  203. package/dist/server/src/lib/hooks/sources/legacy-relay.js +2 -1
  204. package/dist/server/src/lib/hooks/sources/opencode/source.js +10 -7
  205. package/dist/server/src/lib/polling/prompt-dedup-state.js +95 -0
  206. package/dist/server/src/lib/polling/response-checker.js +12 -0
  207. package/dist/server/src/lib/polling/response-poller-core.js +11 -1
  208. package/dist/server/src/lib/session/agent-session-lifecycle.js +28 -7
  209. package/dist/server/src/lib/session/claude-session.js +5 -1
  210. package/dist/server/src/lib/session/current-output-builder.js +34 -0
  211. package/dist/server/src/lib/verification/env-snapshot.js +21 -3
  212. package/dist/server/src/lib/verification/gate-runner.js +258 -7
  213. package/dist/server/src/lib/verification/machine-lock.js +204 -0
  214. package/dist/server/src/lib/verification/scope-gate.js +126 -13
  215. package/dist/server/src/lib/verification/verify-config.js +85 -3
  216. package/dist/server/src/lib/verification/worktree-index.js +140 -0
  217. package/package.json +1 -1
  218. /package/.next/static/{ehkNc5xDMDkXlua08Bwq0 → wyFLOpmKpr45BHZ4svYpE}/_buildManifest.js +0 -0
  219. /package/.next/static/{ehkNc5xDMDkXlua08Bwq0 → wyFLOpmKpr45BHZ4svYpE}/_ssgManifest.js +0 -0
@@ -1,8 +1,9 @@
1
1
  "use strict";exports.id=9373,exports.ids=[9373],exports.modules={11501:(a,b,c)=>{c.d(b,{Ky:()=>j,RR:()=>l,cI:()=>k,ct:()=>m,fc:()=>i});var d=c(90384);let e=`${d.uz}(commit または未 commit の変更が存在すること)`,f=`${d.uz}(commit が存在すること。未 commit の変更は作業証跡として数えない)`,g=`${d.le}(変更ファイルが scope.allow の内側に収まっていること)`,h=`options.requireCommit (${d.aT})`;function i(a,b){let c=[];return b?.options.requireCommit&&c.push(h),a?.success.requireCommit&&c.push("success.requireCommit (task contract)"),{required:c.length>0,sources:c}}function j(a){let b=a.verify.gates;if(!b)return null;let c=[[d.uz,a.success.requireWorkEvidence],[d.le,a.success.requireScopeClean]];return[...c.filter(([a,c])=>c||b.includes(a)).map(([a])=>a),...b.filter(a=>!c.some(([b])=>b===a))]}function k(a){return a.verify.gateDefinitions??[]}function l(a,b){let c=a.verify.gates,e=k(a),f=[];if(!b)return e.length>0&&f.push(`verify.gateDefinitions: declared ${e.map(a=>a.id).join(", ")}, but ${d.aT} is missing or unreadable in this worktree, so no verification run can execute them`),c&&f.push(`verify.gates: declared ${c.join(", ")}, but ${d.aT} is missing or unreadable in this worktree, so the gate ids cannot be resolved`),f;let g=b.gates.map(a=>a.id),h=e.map(a=>a.id).filter(a=>g.includes(a));if(h.length>0&&f.push(`verify.gateDefinitions: gate id(s) ${h.join(", ")} are already declared in ${d.aT}. A contract may add gates, never redefine the repository's own — rename the contract gate.`),c){let a=new Set([d.uz,d.le,...g]),b=new Set(e.map(a=>a.id)),h=c.filter(c=>!a.has(c)&&!b.has(c));if(h.length>0){let c=[`Declared in ${d.aT}: ${[...a].join(", ")}`];b.size>0&&c.push(`in verify.gateDefinitions: ${[...b].join(", ")}`),f.push(`verify.gates: unknown gate id(s) ${h.join(", ")}. ${c.join("; ")}`)}}return f}function m(a,b){let c=["## 実行契約"];c.push(a.scope.allow.length>0?`- 変更してよいのは次のパスのみ: ${a.scope.allow.join(", ")}`:"- 変更パスの制限: なし(scope.allow が未宣言)"),a.scope.deny.length>0&&c.push(`- 変更してはならないパス: ${a.scope.deny.join(", ")}`),c.push(i(a,b).required?"- 作業完了後は必ず commit すること(未 commit の作業は未完了とみなされる)":"- 作業完了後は commit すること(ただし work-evidence は未 commit の変更も作業証跡として認めるため、commit の有無そのものは検査されない)");let h=function(a,b){if(!b)return[];let c=i(a,b).required?f:e,h=new Map([[d.uz,c],[d.le,g]]),l=[...b.gates,...k(a)],m=j(a);if(!m){let b=[c];return a.success.requireScopeClean&&b.push(g),[...b,...l.map(a=>a.command)]}let n=new Map(l.map(a=>[a.id,a.command]));return m.map(a=>h.get(a)??n.get(a))}(a,b);return c.push(h.length>0?`- 完了条件: 次の検証コマンドがすべて成功すること: ${h.join(" / ")}`:`- 完了条件: ${d.aT} に検証ゲートが宣言されていないため、検証コマンドは無い`),`${c.join("\n")}
2
2
 
3
3
  ## タスク
4
- ${a.goal}`}},74985:(a,b,c)=>{c.d(b,{Uq:()=>i,uT:()=>n});var d=c(33873),e=c(15194),f=c(77142),g=c(90384);let h=`options.requireEnvClean (${g.aT})`;function i(a,b){let c=[];return b?.options.requireEnvClean&&c.push(h),a&&!0===a.success.requireEnvClean&&c.push("success.requireEnvClean (task contract)"),{required:c.length>0,sources:c}}let j=[...e.XH].sort((a,b)=>b.length-a.length);function k(a,b,c){switch(a){case"tmux-sessions":return function(a,b){if(!a.startsWith(f.HL))return"unattributed";let c=a.slice(f.HL.length),d=j.find(a=>c.startsWith(`${a}-`));if(!d)return"unattributed";let e=c.slice(d.length+1);return e===b||e.startsWith(`${b}-`)?"self":"other"}(b.key,c.worktreeId);case"listeners":return function(a,b){if(!a)return"unattributed";let c=(0,d.resolve)(b),e=(0,d.resolve)(a);if(e===c||e.startsWith(c+d.sep))return"self";let f=(0,d.dirname)(c);return e!==f&&e.startsWith(f+d.sep)?"other":"unattributed"}(b.anchor,c.worktreePath);default:return"unattributed"}}function l(a,b){return{key:a.key,detail:a.detail,owner:b}}function m(a,b){let c=b.slice(0,25),d=b.length-c.length,e=c.map(b=>{let c=b.detail?` ${b.detail}`:"";return` ${a} ${b.key}${c} [${b.owner}]`});return d>0&&e.push(` ... and ${d} more`),e}async function n(a){let b,c=Date.now(),d=(a,b,d)=>({status:a,exitCode:d,startedAt:c,durationMs:Date.now()-c,logTail:b});if(!a.baseline)return d("error",function(a,b){let c=a?`task ${a}`:"this run",d=b.length>0?b.join(" and "):"nothing";return`${g.Q5}: UNKNOWN — no baseline snapshot exists for ${c}, so nothing can be compared. This is NOT "the environment is unchanged": no measurement was taken. A baseline is recorded when the task is created (\`send --contract\`) and only while the gate is switched on (currently: ${d}). Switch it on, then re-send the task.`}(a.taskId,a.sources),null);let e=a.capture??(()=>(0,f._8)({worktreeId:a.worktreeId}));try{b=await e()}catch(a){return d("error",`${g.Q5}: UNKNOWN — the current snapshot could not be taken: ${a instanceof Error?a.message:String(a)}`,null)}let h=function(a,b,c){let d=f.I1.map(d=>{let e=a.probes[d],f=b.probes[d];if(!e||"ok"!==e.status)return{probeId:d,status:"unknown",reason:`baseline probe unavailable: ${e?.reason??"not recorded"}`,added:[],ignoredAdded:[],removed:[]};if(!f||"ok"!==f.status)return{probeId:d,status:"unknown",reason:`current probe unavailable: ${f?.reason??"not recorded"}`,added:[],ignoredAdded:[],removed:[]};let g=new Set(e.entries.map(a=>a.key)),h=new Set(f.entries.map(a=>a.key)),i=[],j=[];for(let a of f.entries){if(g.has(a.key))continue;let b=k(d,a,c);("other"===b?j:i).push(l(a,b))}let m=e.entries.filter(a=>!h.has(a.key)).map(a=>l(a,k(d,a,c)));return{probeId:d,status:i.length+m.length>0?"violated":"clean",reason:null,added:i,ignoredAdded:j,removed:m}});return{status:d.some(a=>"violated"===a.status)?"violated":d.some(a=>"unknown"===a.status)?"unknown":"clean",probes:d}}(a.baseline,b,a),i=`${g.Q5}: baseline=${new Date(a.baseline.capturedAt).toISOString()} status=${h.status}`,j=`${i}
4
+ ${a.goal}`}},49987:(a,b,c)=>{c.d(b,{H:()=>l,Iq:()=>i,M:()=>k,xL:()=>n});var d=c(29021),e=c(21820),f=c(33873),g=c(55511);let h=(0,c(72626).h)("lib/verification/machine-lock"),i="locks",j="owner";function k(a,b){return(0,f.join)(b,`${a}.lock`)}function l(a=process.env){let b=a.CM_VERIFY_LOCK_ROOT;return b&&""!==b.trim()?b:(0,f.join)((0,e.homedir)(),".commandmate",i)}function m(a){try{let b=JSON.parse((0,d.readFileSync)((0,f.join)(a,j),"utf8"));if("number"!=typeof b.pid||"string"!=typeof b.token)return null;return{pid:b.pid,host:"string"==typeof b.host?b.host:"",token:b.token,acquiredAt:"number"==typeof b.acquiredAt?b.acquiredAt:0}}catch{return null}}async function n(a,b){let c=b.root??l(),i=b.pollIntervalMs??250,n=k(a,c),o=Date.now(),p=o+Math.max(0,b.timeoutMs),q=(0,g.randomUUID)();(0,d.mkdirSync)(c,{recursive:!0});let r=new Set;for(;;){if(function(a,b){try{(0,d.mkdirSync)(a)}catch(a){if("EEXIST"===a.code)return!1;throw a}return(0,d.writeFileSync)((0,f.join)(a,j),JSON.stringify(b),{encoding:"utf8"}),!0}(n,{pid:process.pid,host:(0,e.hostname)(),token:q,acquiredAt:Date.now()}))return{acquired:!0,waitedMs:Date.now()-o,handle:{name:a,path:n,release:()=>{let a=m(n);if(!a||a.token===q)try{(0,d.rmSync)(n,{recursive:!0,force:!0})}catch(a){h.warn("machine-lock-release-failed",{lockPath:n,error:a instanceof Error?a.message:String(a)})}}}};let b=m(n);if(b&&!r.has(b.token)&&function(a){if(a.host!==(0,e.hostname)())return!1;try{return process.kill(a.pid,0),!1}catch(a){return"ESRCH"===a.code}}(b)){r.add(b.token);let a=m(n);if(a&&a.token===b.token)try{(0,d.rmSync)(n,{recursive:!0,force:!0}),h.warn("machine-lock-broken-stale",{lockPath:n,pid:b.pid})}catch{}continue}let c=Date.now();if(c>=p)return{acquired:!1,waitedMs:c-o,heldBy:b?`pid ${b.pid} on ${b.host||"unknown host"}`:null};await function(a){return new Promise(b=>setTimeout(b,a))}(Math.min(i,p-c))}}},53604:(a,b,c)=>{c.d(b,{Cr:()=>k,L8:()=>i});var d=c(55511),e=c(29021),f=c(21820),g=c(33873);let h=(0,c(72626).h)("lib/verification/worktree-index"),i="worktree-index";function j(a,b){try{return(0,e.readFileSync)((0,g.join)(a,b),"utf8").trim()}catch{return null}}function k(a,b={}){let c=b.root??function(a=process.env){let b=a.CM_VERIFY_WORKTREE_INDEX_ROOT;return b&&""!==b.trim()?b:(0,g.join)((0,f.homedir)(),".commandmate",i)}();try{(0,e.mkdirSync)(c,{recursive:!0});let b=new Set;for(let d of(0,e.readdirSync)(c))if(/^\d+$/.test(d)){if(j(c,d)===a)return Number(d);b.add(Number(d))}for(let d=0;d<1024;d++)if(!b.has(d)&&function(a,b,c){try{return(0,e.writeFileSync)((0,g.join)(a,String(b)),`${c}
5
+ `,{encoding:"utf8",flag:"wx"}),!0}catch(d){if("EEXIST"!==d.code)throw d;return j(a,String(b))===c}}(c,d,a))return d;h.warn("worktree-index-exhausted",{worktreeId:a,root:c})}catch(b){h.warn("worktree-index-unavailable",{worktreeId:a,root:c,error:b instanceof Error?b.message:String(b)})}return Number.parseInt((0,d.createHash)("sha256").update(a).digest("hex").slice(0,8),16)%1024}},74985:(a,b,c)=>{c.d(b,{Uq:()=>i,uT:()=>n});var d=c(33873),e=c(15194),f=c(77142),g=c(90384);let h=`options.requireEnvClean (${g.aT})`;function i(a,b){let c=[];return b?.options.requireEnvClean&&c.push(h),a&&!0===a.success.requireEnvClean&&c.push("success.requireEnvClean (task contract)"),{required:c.length>0,sources:c}}let j=[...e.XH].sort((a,b)=>b.length-a.length);function k(a,b,c){switch(a){case"tmux-sessions":return function(a,b){if(!a.startsWith(f.HL))return"unattributed";let c=a.slice(f.HL.length),d=j.find(a=>c.startsWith(`${a}-`));if(!d)return"unattributed";let e=c.slice(d.length+1);return e===b||e.startsWith(`${b}-`)?"self":"other"}(b.key,c.worktreeId);case"listeners":return function(a,b){if(!a)return"unattributed";let c=(0,d.resolve)(b),e=(0,d.resolve)(a);if(e===c||e.startsWith(c+d.sep))return"self";let f=(0,d.dirname)(c);return e!==f&&e.startsWith(f+d.sep)?"other":"unattributed"}(b.anchor,c.worktreePath);default:return"unattributed"}}function l(a,b){return{key:a.key,detail:a.detail,owner:b}}function m(a,b){let c=b.slice(0,25),d=b.length-c.length,e=c.map(b=>{let c=b.detail?` ${b.detail}`:"";return` ${a} ${b.key}${c} [${b.owner}]`});return d>0&&e.push(` ... and ${d} more`),e}async function n(a){let b,c=Date.now(),d=(a,b,d)=>({status:a,exitCode:d,startedAt:c,durationMs:Date.now()-c,logTail:b});if(!a.baseline)return d("error",function(a,b){let c=a?`task ${a}`:"this run",d=b.length>0?b.join(" and "):"nothing";return`${g.Q5}: UNKNOWN — no baseline snapshot exists for ${c}, so nothing can be compared. This is NOT "the environment is unchanged": no measurement was taken. A baseline is recorded when the task is created (\`send --contract\`) and only while the gate is switched on (currently: ${d}). Switch it on, then re-send the task.`}(a.taskId,a.sources),null);let e=a.capture??(()=>(0,f._8)({worktreeId:a.worktreeId}));try{b=await e()}catch(a){return d("error",`${g.Q5}: UNKNOWN — the current snapshot could not be taken: ${a instanceof Error?a.message:String(a)}`,null)}let h=function(a,b,c){let d=f.I1.map(d=>{let e=a.probes[d],f=b.probes[d];if(!e||"ok"!==e.status)return{probeId:d,status:"unknown",reason:`baseline probe unavailable: ${e?.reason??"not recorded"}`,added:[],ignoredAdded:[],removed:[]};if(!f||"ok"!==f.status)return{probeId:d,status:"unknown",reason:`current probe unavailable: ${f?.reason??"not recorded"}`,added:[],ignoredAdded:[],removed:[]};let g=new Set(e.entries.map(a=>a.key)),h=new Set(f.entries.map(a=>a.key)),i=[],j=[];for(let a of f.entries){if(g.has(a.key))continue;let b=k(d,a,c);("other"===b?j:i).push(l(a,b))}let m=e.entries.filter(a=>!h.has(a.key)).map(a=>l(a,k(d,a,c)));return{probeId:d,status:i.length+m.length>0?"violated":"clean",reason:null,added:i,ignoredAdded:j,removed:m}});return{status:d.some(a=>"violated"===a.status)?"violated":d.some(a=>"unknown"===a.status)?"unknown":"clean",probes:d}}(a.baseline,b,a),i=`${g.Q5}: baseline=${new Date(a.baseline.capturedAt).toISOString()} status=${h.status}`,j=`${i}
5
6
  ${function(a){let b=[];for(let c of a.probes){let a=f.J6[c.probeId];if("unknown"===c.status){b.push(` ${c.probeId} UNKNOWN (${a}): ${c.reason??"no reason recorded"}`);continue}if("clean"===c.status){let d=c.ignoredAdded.length>0?` (${c.ignoredAdded.length} addition(s) attributed to another worktree)`:"";b.push(` ${c.probeId} clean (${a})${d}`);continue}for(let d of(b.push(` ${c.probeId} VIOLATED (${a}): +${c.added.length} -${c.removed.length}`),b.push(...m("+",c.added)),b.push(...m("-",c.removed)),c.ignoredAdded))b.push(` \xb7 ${d.key} (ignored: belongs to another worktree)`)}return b.join("\n")}(h)}`;return"clean"===h.status?d("passed",j,0):"unknown"===h.status?d("error",`${j}
6
7
  UNKNOWN is not a pass: at least one probe could not be compared, so the environment was not measured.`,null):d("failed",`${j}
7
- Anything listed under "+" was started or created during this task and left behind — stop it by PID and remove it. Anything under "-" existed when the task started and is now gone — it was killed or deleted; restart or restore it. Never stop a process by pattern (\`pkill -f\`): it takes every process whose command line matches, which is how the production server was stopped in #1739.`,1)}},77142:(a,b,c)=>{c.d(b,{HL:()=>r,I1:()=>j,J6:()=>k,_8:()=>w,dV:()=>A,g9:()=>B});var d=c(79646),e=c(29021),f=c(21820),g=c(33873),h=c(87447);let i=(0,c(72626).h)("lib/verification/env-snapshot"),j=["listeners","tmux-sessions","home-entries","commandmate-entries"],k={listeners:"CommandMate TCP listeners","tmux-sessions":"mcbd-* tmux sessions","home-entries":"$HOME entries","commandmate-entries":"~/.commandmate entries"},l={run:function(a,b){return new Promise(c=>{(0,d.execFile)(a,b,{timeout:5e3,maxBuffer:4194304,encoding:"utf8"},(b,d,e)=>b?"number"!=typeof b.code||b.killed?void c({code:null,stdout:d,stderr:e,failure:b.killed?`${a} exceeded 5000ms and was terminated`:`${a} could not be run: ${b.message}`}):void c({code:b.code,stdout:d,stderr:e,failure:null}):void c({code:0,stdout:d,stderr:e,failure:null}))})},readDir:a=>(0,e.readdirSync)(a),homeDir:()=>(0,f.homedir)()},m=/commandmate|dist\/server\/server\.js|next-server|next (dev|start)|server\.ts/i;function n(a){let b=[],c=null;for(let d of a.split("\n")){if(""===d)continue;let a=d[0],e=d.slice(1);if("p"===a){let a=Number(e);if(!Number.isInteger(a)){c=null;continue}c={pid:a,fields:new Map},b.push(c);continue}if(!c)continue;let f=c.fields.get(a);f?f.push(e):c.fields.set(a,[e])}return b}function o(a){return{status:"unavailable",entries:[],reason:a}}function p(a){let b=new Map;for(let c of a)b.has(c.key)||b.set(c.key,c);return{status:"ok",entries:[...b.values()].sort((a,b)=>a.key<b.key?-1:+(a.key>b.key)),reason:null}}async function q(a){let b=await a.run("lsof",["-nP","-iTCP","-sTCP:LISTEN","-F","pcn"]);if(null!==b.failure)return o(b.failure);if(0!==b.code&&1!==b.code)return o(`lsof exited ${b.code}: ${b.stderr.trim()||"no diagnostic output"}`);let c=n(b.stdout);if(0===c.length)return p([]);let d=await a.run("ps",["-A","-o","pid=,command="]);if(null!==d.failure||0!==d.code)return o(d.failure??`ps exited ${d.code}: ${d.stderr.trim()||"no diagnostic output"}`);let e=function(a){let b=new Map;for(let c of a.split("\n")){let a=/^\s*(\d+)\s+(.*)$/.exec(c);a&&b.set(Number(a[1]),a[2].trim())}return b}(d.stdout),f=c.filter(a=>{let b=e.get(a.pid);return void 0!==b&&m.test(b)});if(0===f.length)return p([]);let g=new Map,h=f.map(a=>String(a.pid)),i=await a.run("lsof",["-a","-d","cwd","-p",h.join(","),"-F","pn"]);if(null===i.failure&&(0===i.code||1===i.code))for(let a of n(i.stdout)){let[b]=a.fields.get("n")??[];b&&g.set(a.pid,b)}let j=[];for(let a of f){let b=a.fields.get("c")?.[0]??"unknown";for(let c of a.fields.get("n")??[]){let d=function(a){let b=a.lastIndexOf(":");if(b<0)return null;let c=a.slice(b+1);return/^\d+$/.test(c)?c:null}(c);d&&j.push({key:`tcp/${d}`,detail:`${b} pid=${a.pid}`,anchor:g.get(a.pid)??null})}}return p(j)}let r="mcbd-";async function s(a){let b=await a.run("tmux",["list-sessions","-F","#{session_name}"]);return null!==b.failure?o(b.failure):0!==b.code?/no server running|error connecting to|no sessions/i.test(b.stderr)?p([]):o(`tmux list-sessions exited ${b.code}: ${b.stderr.trim()||"no diagnostic output"}`):p(b.stdout.split("\n").map(a=>a.trim()).filter(a=>a.startsWith(r)).map(a=>({key:a,detail:null,anchor:null})))}let t=[/-wal$/,/-shm$/,/-journal$/,/^\.DS_Store$/],u="env-snapshots";function v(a,b,{missingIsEmpty:c}){let d;try{d=a.readDir(b)}catch(d){let a=d.code;if(c&&"ENOENT"===a)return p([]);return o(`could not list ${b}: ${d.message}`)}return p(d.filter(a=>!(a===u||t.some(b=>b.test(a)))).map(a=>({key:a,detail:null,anchor:null})))}async function w(a){let b=a.deps??l,[c,d]=await Promise.all([q(b).catch(a=>o(`listeners probe threw: ${a.message}`)),s(b).catch(a=>o(`tmux probe threw: ${a.message}`))]);return{version:1,capturedAt:a.now??Date.now(),worktreeId:a.worktreeId,probes:{listeners:c,"tmux-sessions":d,"home-entries":v(b,b.homeDir(),{missingIsEmpty:!1}),"commandmate-entries":v(b,(0,g.join)(b.homeDir(),".commandmate"),{missingIsEmpty:!0})}}}function x(){return(0,g.join)((0,g.dirname)((0,h._$)().CM_DB_PATH),u)}let y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function z(a,b){return y.test(b)?(0,g.join)(a,`${b}.json`):null}function A(a,b,c=x()){let d=z(c,a);if(!d)return i.warn("env-snapshot-rejected-task-id",{taskId:a}),!1;try{return(0,e.mkdirSync)(c,{recursive:!0,mode:448}),(0,e.writeFileSync)(d,JSON.stringify(b),{encoding:"utf8",mode:384}),!function(a,b){let c;try{c=(0,e.readdirSync)(a)}catch{return}for(let d of c){if(!d.endsWith(".json"))continue;let c=(0,g.join)(a,d);try{b-(0,e.statSync)(c).mtimeMs>2592e6&&(0,e.rmSync)(c,{force:!0})}catch{}}}(c,b.capturedAt),!0}catch(b){return i.warn("env-snapshot-write-failed",{taskId:a,error:b instanceof Error?b.message:String(b)}),!1}}function B(a,b=x()){let c=z(b,a);if(!c)return null;try{let a=JSON.parse((0,e.readFileSync)(c,"utf8"));if(!function(a){if("object"!=typeof a||null===a||1!==a.version||"number"!=typeof a.capturedAt)return!1;let b=a.probes;return"object"==typeof b&&null!==b&&j.every(a=>{var c;return"object"==typeof(c=b[a])&&null!==c&&("ok"===c.status||"unavailable"===c.status)&&Array.isArray(c.entries)})}(a))return null;return a}catch{return null}}},90384:(a,b,c)=>{c.d(b,{D:()=>l,Q5:()=>i,UL:()=>v,Yp:()=>p,aT:()=>k,le:()=>h,uz:()=>g,yR:()=>w});var d=c(29021),e=c(33873),f=c(4689);let g="work-evidence",h="scope",i="env-clean",j=[g,h,i],k=".commandmate/verify.yaml",l=/^[a-z0-9][a-z0-9-]{0,31}$/,m=["version","gates","options"],n=["id","command","timeoutSec"],o=["baseRef","skipInPrimaryCheckout","maxLogTailBytes","requireCommit","requireEnvClean"];class p extends Error{constructor(a){super(`invalid verify config:
8
- ${a.map(a=>` - ${a}`).join("\n")}`),this.name="VerifyConfigError",this.issues=a}}function q(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function r(a){return"number"==typeof a?Number.isInteger(a)?a:null:"string"==typeof a&&/^-?\d+$/.test(a)?Number(a):null}function s(a){return"boolean"==typeof a?a:"true"===a||"false"!==a&&null}function t(a){return void 0===a?"nothing":null===a?"null":"string"==typeof a?JSON.stringify(a):Array.isArray(a)?"a list":"object"==typeof a?"a mapping":String(a)}function u(a,b,c,d){for(let e of Object.keys(a))b.includes(e)||d.push(`${c}: unknown key "${e}" (v1 is a closed set)`)}function v(a,b,c){if(!Array.isArray(a))return c.push(`${b}: must be a list (got ${t(a)})`),[];let d=[],e=new Set;return a.forEach((a,f)=>{!function(a,b,c,d,e){let f=e.length;if(!q(a))return e.push(`${b}: must be a mapping (got ${t(a)})`);u(a,n,b,e),"string"!=typeof a.id||""===a.id?e.push(`${b}.id: required, must be a non-empty string (got ${t(a.id)})`):l.test(a.id)?j.includes(a.id)?e.push(`${b}.id: "${a.id}" is reserved for a built-in gate`):c.has(a.id)?e.push(`${b}.id: duplicate gate id "${a.id}"`):c.add(a.id):e.push(`${b}.id: "${a.id}" must match ${l.source}`),("string"!=typeof a.command||""===a.command.trim())&&e.push(`${b}.command: required, must be a non-empty string (got ${t(a.command)})`);let g=600;if(void 0!==a.timeoutSec){let c=r(a.timeoutSec);null===c?e.push(`${b}.timeoutSec: must be an integer (got ${t(a.timeoutSec)})`):c<1||c>7200?e.push(`${b}.timeoutSec: must be 1..7200 (got ${c})`):g=c}e.length===f&&d.push({id:a.id,command:a.command,timeoutSec:g})}(a,`${b}[${f}]`,e,d,c)}),d}function w(a){let b,c=(0,e.join)(a,k);try{b=(0,d.readFileSync)(c,"utf8")}catch(a){if("ENOENT"===a.code)return null;throw new p([`${c}: ${a.message}`])}return function(a,b){var c;let d;try{d=(0,f.qg)(a)}catch(a){throw new p([`${b}: YAML parse error: ${a.message}`])}if(!q(d))throw new p([`${b}: expected a YAML mapping at the top level (got ${t(d)})`]);let e=[];u(d,m,"top level",e),"version"in d?1!==r(d.version)&&e.push(`version: must be 1 (got ${t(d.version)})`):e.push('version: required, v1 configs must declare "version: 1"');let g=(c=d.gates,null==c?(e.push("gates: required, at least one gate must be defined"),[]):Array.isArray(c)&&0===c.length?(e.push("gates: at least one gate must be defined"),[]):v(c,"gates",e)),h=function(a,b){let c={baseRef:null,skipInPrimaryCheckout:!0,maxLogTailBytes:8192,requireCommit:!1,requireEnvClean:!1};if(null==a)return c;if(!q(a))return b.push(`options: must be a mapping (got ${t(a)})`),c;if(u(a,o,"options",b),void 0!==a.baseRef&&("string"!=typeof a.baseRef||""===a.baseRef.trim()?b.push(`options.baseRef: must be a non-empty string (got ${t(a.baseRef)})`):c.baseRef=a.baseRef),void 0!==a.skipInPrimaryCheckout){let d=s(a.skipInPrimaryCheckout);null===d?b.push(`options.skipInPrimaryCheckout: must be true or false (got ${t(a.skipInPrimaryCheckout)})`):c.skipInPrimaryCheckout=d}if(void 0!==a.requireCommit){let d=s(a.requireCommit);null===d?b.push(`options.requireCommit: must be true or false (got ${t(a.requireCommit)})`):c.requireCommit=d}if(void 0!==a.requireEnvClean){let d=s(a.requireEnvClean);null===d?b.push(`options.requireEnvClean: must be true or false (got ${t(a.requireEnvClean)})`):c.requireEnvClean=d}if(void 0!==a.maxLogTailBytes){let d=r(a.maxLogTailBytes);null===d?b.push(`options.maxLogTailBytes: must be an integer (got ${t(a.maxLogTailBytes)})`):d<0||d>1048576?b.push(`options.maxLogTailBytes: must be 0..1048576 (got ${d})`):c.maxLogTailBytes=d}return c}(d.options,e);if(e.length>0)throw new p(e);return{version:1,gates:g,options:h}}(b,c)}}};
8
+ Anything listed under "+" was started or created during this task and left behind — stop it by PID and remove it. Anything under "-" existed when the task started and is now gone — it was killed or deleted; restart or restore it. Never stop a process by pattern (\`pkill -f\`): it takes every process whose command line matches, which is how the production server was stopped in #1739.`,1)}},77142:(a,b,c)=>{c.d(b,{HL:()=>u,I1:()=>m,J6:()=>n,_8:()=>A,dV:()=>E,g9:()=>F});var d=c(79646),e=c(29021),f=c(21820),g=c(33873),h=c(87447),i=c(72626),j=c(49987),k=c(53604);let l=(0,i.h)("lib/verification/env-snapshot"),m=["listeners","tmux-sessions","home-entries","commandmate-entries"],n={listeners:"CommandMate TCP listeners","tmux-sessions":"mcbd-* tmux sessions","home-entries":"$HOME entries","commandmate-entries":"~/.commandmate entries"},o={run:function(a,b){return new Promise(c=>{(0,d.execFile)(a,b,{timeout:5e3,maxBuffer:4194304,encoding:"utf8"},(b,d,e)=>b?"number"!=typeof b.code||b.killed?void c({code:null,stdout:d,stderr:e,failure:b.killed?`${a} exceeded 5000ms and was terminated`:`${a} could not be run: ${b.message}`}):void c({code:b.code,stdout:d,stderr:e,failure:null}):void c({code:0,stdout:d,stderr:e,failure:null}))})},readDir:a=>(0,e.readdirSync)(a),homeDir:()=>(0,f.homedir)()},p=/commandmate|dist\/server\/server\.js|next-server|next (dev|start)|server\.ts/i;function q(a){let b=[],c=null;for(let d of a.split("\n")){if(""===d)continue;let a=d[0],e=d.slice(1);if("p"===a){let a=Number(e);if(!Number.isInteger(a)){c=null;continue}c={pid:a,fields:new Map},b.push(c);continue}if(!c)continue;let f=c.fields.get(a);f?f.push(e):c.fields.set(a,[e])}return b}function r(a){return{status:"unavailable",entries:[],reason:a}}function s(a){let b=new Map;for(let c of a)b.has(c.key)||b.set(c.key,c);return{status:"ok",entries:[...b.values()].sort((a,b)=>a.key<b.key?-1:+(a.key>b.key)),reason:null}}async function t(a){let b=await a.run("lsof",["-nP","-iTCP","-sTCP:LISTEN","-F","pcn"]);if(null!==b.failure)return r(b.failure);if(0!==b.code&&1!==b.code)return r(`lsof exited ${b.code}: ${b.stderr.trim()||"no diagnostic output"}`);let c=q(b.stdout);if(0===c.length)return s([]);let d=await a.run("ps",["-A","-o","pid=,command="]);if(null!==d.failure||0!==d.code)return r(d.failure??`ps exited ${d.code}: ${d.stderr.trim()||"no diagnostic output"}`);let e=function(a){let b=new Map;for(let c of a.split("\n")){let a=/^\s*(\d+)\s+(.*)$/.exec(c);a&&b.set(Number(a[1]),a[2].trim())}return b}(d.stdout),f=c.filter(a=>{let b=e.get(a.pid);return void 0!==b&&p.test(b)});if(0===f.length)return s([]);let g=new Map,h=f.map(a=>String(a.pid)),i=await a.run("lsof",["-a","-d","cwd","-p",h.join(","),"-F","pn"]);if(null===i.failure&&(0===i.code||1===i.code))for(let a of q(i.stdout)){let[b]=a.fields.get("n")??[];b&&g.set(a.pid,b)}let j=[];for(let a of f){let b=a.fields.get("c")?.[0]??"unknown";for(let c of a.fields.get("n")??[]){let d=function(a){let b=a.lastIndexOf(":");if(b<0)return null;let c=a.slice(b+1);return/^\d+$/.test(c)?c:null}(c);d&&j.push({key:`tcp/${d}`,detail:`${b} pid=${a.pid}`,anchor:g.get(a.pid)??null})}}return s(j)}let u="mcbd-";async function v(a){let b=await a.run("tmux",["list-sessions","-F","#{session_name}"]);return null!==b.failure?r(b.failure):0!==b.code?/no server running|error connecting to|no sessions/i.test(b.stderr)?s([]):r(`tmux list-sessions exited ${b.code}: ${b.stderr.trim()||"no diagnostic output"}`):s(b.stdout.split("\n").map(a=>a.trim()).filter(a=>a.startsWith(u)).map(a=>({key:a,detail:null,anchor:null})))}let w=[/-wal$/,/-shm$/,/-journal$/,/^\.DS_Store$/],x="env-snapshots",y=[j.Iq,k.L8];function z(a,b,{missingIsEmpty:c,alsoIgnored:d=[]}){let e;try{e=a.readDir(b)}catch(d){let a=d.code;if(c&&"ENOENT"===a)return s([]);return r(`could not list ${b}: ${d.message}`)}return s(e.filter(a=>!(a===x||w.some(b=>b.test(a)))&&!d.includes(a)).map(a=>({key:a,detail:null,anchor:null})))}async function A(a){let b=a.deps??o,[c,d]=await Promise.all([t(b).catch(a=>r(`listeners probe threw: ${a.message}`)),v(b).catch(a=>r(`tmux probe threw: ${a.message}`))]);return{version:1,capturedAt:a.now??Date.now(),worktreeId:a.worktreeId,probes:{listeners:c,"tmux-sessions":d,"home-entries":z(b,b.homeDir(),{missingIsEmpty:!1}),"commandmate-entries":z(b,(0,g.join)(b.homeDir(),".commandmate"),{missingIsEmpty:!0,alsoIgnored:y})}}}function B(){return(0,g.join)((0,g.dirname)((0,h._$)().CM_DB_PATH),x)}let C=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function D(a,b){return C.test(b)?(0,g.join)(a,`${b}.json`):null}function E(a,b,c=B()){let d=D(c,a);if(!d)return l.warn("env-snapshot-rejected-task-id",{taskId:a}),!1;try{return(0,e.mkdirSync)(c,{recursive:!0,mode:448}),(0,e.writeFileSync)(d,JSON.stringify(b),{encoding:"utf8",mode:384}),!function(a,b){let c;try{c=(0,e.readdirSync)(a)}catch{return}for(let d of c){if(!d.endsWith(".json"))continue;let c=(0,g.join)(a,d);try{b-(0,e.statSync)(c).mtimeMs>2592e6&&(0,e.rmSync)(c,{force:!0})}catch{}}}(c,b.capturedAt),!0}catch(b){return l.warn("env-snapshot-write-failed",{taskId:a,error:b instanceof Error?b.message:String(b)}),!1}}function F(a,b=B()){let c=D(b,a);if(!c)return null;try{let a=JSON.parse((0,e.readFileSync)(c,"utf8"));if(!function(a){if("object"!=typeof a||null===a||1!==a.version||"number"!=typeof a.capturedAt)return!1;let b=a.probes;return"object"==typeof b&&null!==b&&m.every(a=>{var c;return"object"==typeof(c=b[a])&&null!==c&&("ok"===c.status||"unavailable"===c.status)&&Array.isArray(c.entries)})}(a))return null;return a}catch{return null}}},90384:(a,b,c)=>{c.d(b,{D:()=>l,Q5:()=>i,UL:()=>w,Yp:()=>q,aT:()=>k,le:()=>h,uz:()=>g,yR:()=>x});var d=c(29021),e=c(33873),f=c(4689);let g="work-evidence",h="scope",i="env-clean",j=[g,h,i],k=".commandmate/verify.yaml",l=/^[a-z0-9][a-z0-9-]{0,31}$/,m=/^[A-Za-z0-9_.-]+$/,n=["version","gates","options"],o=["id","command","timeoutSec","mutex","retryOnFail","flakyIsPass"],p=["baseRef","skipInPrimaryCheckout","maxLogTailBytes","requireCommit","requireEnvClean"];class q extends Error{constructor(a){super(`invalid verify config:
9
+ ${a.map(a=>` - ${a}`).join("\n")}`),this.name="VerifyConfigError",this.issues=a}}function r(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function s(a){return"number"==typeof a?Number.isInteger(a)?a:null:"string"==typeof a&&/^-?\d+$/.test(a)?Number(a):null}function t(a){return"boolean"==typeof a?a:"true"===a||"false"!==a&&null}function u(a){return void 0===a?"nothing":null===a?"null":"string"==typeof a?JSON.stringify(a):Array.isArray(a)?"a list":"object"==typeof a?"a mapping":String(a)}function v(a,b,c,d){for(let e of Object.keys(a))b.includes(e)||d.push(`${c}: unknown key "${e}" (v1 is a closed set)`)}function w(a,b,c){if(!Array.isArray(a))return c.push(`${b}: must be a list (got ${u(a)})`),[];let d=[],e=new Set;return a.forEach((a,f)=>{!function(a,b,c,d,e){let f,g,h,i=e.length;if(!r(a))return e.push(`${b}: must be a mapping (got ${u(a)})`);v(a,o,b,e),"string"!=typeof a.id||""===a.id?e.push(`${b}.id: required, must be a non-empty string (got ${u(a.id)})`):l.test(a.id)?j.includes(a.id)?e.push(`${b}.id: "${a.id}" is reserved for a built-in gate`):c.has(a.id)?e.push(`${b}.id: duplicate gate id "${a.id}"`):c.add(a.id):e.push(`${b}.id: "${a.id}" must match ${l.source}`),("string"!=typeof a.command||""===a.command.trim())&&e.push(`${b}.command: required, must be a non-empty string (got ${u(a.command)})`);let k=600;if(void 0!==a.timeoutSec){let c=s(a.timeoutSec);null===c?e.push(`${b}.timeoutSec: must be an integer (got ${u(a.timeoutSec)})`):c<1||c>7200?e.push(`${b}.timeoutSec: must be 1..7200 (got ${c})`):k=c}if(void 0!==a.mutex&&("string"!=typeof a.mutex||""===a.mutex?e.push(`${b}.mutex: must be a non-empty string (got ${u(a.mutex)})`):a.mutex.length>64?e.push(`${b}.mutex: must be at most 64 characters (got ${a.mutex.length})`):m.test(a.mutex)?f=a.mutex:e.push(`${b}.mutex: "${a.mutex}" must match ${m.source}`)),void 0!==a.retryOnFail){let c=s(a.retryOnFail);null===c?e.push(`${b}.retryOnFail: must be an integer (got ${u(a.retryOnFail)})`):c<0||c>1?e.push(`${b}.retryOnFail: must be 0 or 1 (got ${c})`):g=c}if(void 0!==a.flakyIsPass){let c=t(a.flakyIsPass);null===c?e.push(`${b}.flakyIsPass: must be true or false (got ${u(a.flakyIsPass)})`):c&&1!==g?e.push(`${b}.flakyIsPass: true requires retryOnFail: 1 (without a retry a gate can never be FLAKY)`):h=c}if(e.length===i){let b={id:a.id,command:a.command,timeoutSec:k};void 0!==f&&(b.mutex=f),void 0!==g&&(b.retryOnFail=g),void 0!==h&&(b.flakyIsPass=h),d.push(b)}}(a,`${b}[${f}]`,e,d,c)}),d}function x(a){let b,c=(0,e.join)(a,k);try{b=(0,d.readFileSync)(c,"utf8")}catch(a){if("ENOENT"===a.code)return null;throw new q([`${c}: ${a.message}`])}return function(a,b){var c;let d;try{d=(0,f.qg)(a)}catch(a){throw new q([`${b}: YAML parse error: ${a.message}`])}if(!r(d))throw new q([`${b}: expected a YAML mapping at the top level (got ${u(d)})`]);let e=[];v(d,n,"top level",e),"version"in d?1!==s(d.version)&&e.push(`version: must be 1 (got ${u(d.version)})`):e.push('version: required, v1 configs must declare "version: 1"');let g=(c=d.gates,null==c?(e.push("gates: required, at least one gate must be defined"),[]):Array.isArray(c)&&0===c.length?(e.push("gates: at least one gate must be defined"),[]):w(c,"gates",e)),h=function(a,b){let c={baseRef:null,skipInPrimaryCheckout:!0,maxLogTailBytes:8192,requireCommit:!1,requireEnvClean:!1};if(null==a)return c;if(!r(a))return b.push(`options: must be a mapping (got ${u(a)})`),c;if(v(a,p,"options",b),void 0!==a.baseRef&&("string"!=typeof a.baseRef||""===a.baseRef.trim()?b.push(`options.baseRef: must be a non-empty string (got ${u(a.baseRef)})`):c.baseRef=a.baseRef),void 0!==a.skipInPrimaryCheckout){let d=t(a.skipInPrimaryCheckout);null===d?b.push(`options.skipInPrimaryCheckout: must be true or false (got ${u(a.skipInPrimaryCheckout)})`):c.skipInPrimaryCheckout=d}if(void 0!==a.requireCommit){let d=t(a.requireCommit);null===d?b.push(`options.requireCommit: must be true or false (got ${u(a.requireCommit)})`):c.requireCommit=d}if(void 0!==a.requireEnvClean){let d=t(a.requireEnvClean);null===d?b.push(`options.requireEnvClean: must be true or false (got ${u(a.requireEnvClean)})`):c.requireEnvClean=d}if(void 0!==a.maxLogTailBytes){let d=s(a.maxLogTailBytes);null===d?b.push(`options.maxLogTailBytes: must be an integer (got ${u(a.maxLogTailBytes)})`):d<0||d>1048576?b.push(`options.maxLogTailBytes: must be 0..1048576 (got ${d})`):c.maxLogTailBytes=d}return c}(d.options,e);if(e.length>0)throw new q(e);return{version:1,gates:g,options:h}}(b,c)}}};
@@ -17,11 +17,11 @@
17
17
  "wasm": [],
18
18
  "assets": [],
19
19
  "env": {
20
- "__NEXT_BUILD_ID": "ehkNc5xDMDkXlua08Bwq0",
21
- "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "lqIPyiFpzU8Pa78MjP2JZYeiHFYrfYULKHk0AIPD+6o=",
22
- "__NEXT_PREVIEW_MODE_ID": "96e5918eb1a47a4f975369c1536feb0c",
23
- "__NEXT_PREVIEW_MODE_SIGNING_KEY": "e4f7a7c795d0e11e6d2676e24379472a2885d5da95c3a254e7d47ec334022e9f",
24
- "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "a1957c50258f79ccb7e757346a603cd730220a3e6684713312ac196838978734"
20
+ "__NEXT_BUILD_ID": "wyFLOpmKpr45BHZ4svYpE",
21
+ "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY": "/bHE4VPfeqVSBprjiO5UGkI0cw2OpZ4HWQ6lj4Y9ank=",
22
+ "__NEXT_PREVIEW_MODE_ID": "c3740961b5f86557327cb6fdcd585365",
23
+ "__NEXT_PREVIEW_MODE_SIGNING_KEY": "83311b74f9c7ff905ea4dfe698a083b45253b6a73daa99d1e8eaa402064b1d3a",
24
+ "__NEXT_PREVIEW_MODE_ENCRYPTION_KEY": "a33387561d428c125fa7088a12b8497a4df3b8e1c6251b0bcb8dc056471a03d4"
25
25
  }
26
26
  }
27
27
  },
@@ -1 +1 @@
1
- <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-9d892a9ff07c289d.js" defer=""></script><script src="/_next/static/chunks/framework-eaf13c96191cb608.js" defer=""></script><script src="/_next/static/chunks/main-6092074a0dc78280.js" defer=""></script><script src="/_next/static/chunks/pages/_app-4b3fb5e477a0267f.js" defer=""></script><script src="/_next/static/chunks/pages/_error-c970d8b55ace1b48.js" defer=""></script><script src="/_next/static/ehkNc5xDMDkXlua08Bwq0/_buildManifest.js" defer=""></script><script src="/_next/static/ehkNc5xDMDkXlua08Bwq0/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"ehkNc5xDMDkXlua08Bwq0","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
1
+ <!DOCTYPE html><html><head><meta charSet="utf-8" data-next-head=""/><meta name="viewport" content="width=device-width" data-next-head=""/><title data-next-head="">500: Internal Server Error</title><noscript data-n-css=""></noscript><script defer="" noModule="" src="/_next/static/chunks/polyfills-42372ed130431b0a.js"></script><script src="/_next/static/chunks/webpack-9d892a9ff07c289d.js" defer=""></script><script src="/_next/static/chunks/framework-eaf13c96191cb608.js" defer=""></script><script src="/_next/static/chunks/main-6092074a0dc78280.js" defer=""></script><script src="/_next/static/chunks/pages/_app-4b3fb5e477a0267f.js" defer=""></script><script src="/_next/static/chunks/pages/_error-c970d8b55ace1b48.js" defer=""></script><script src="/_next/static/wyFLOpmKpr45BHZ4svYpE/_buildManifest.js" defer=""></script><script src="/_next/static/wyFLOpmKpr45BHZ4svYpE/_ssgManifest.js" defer=""></script></head><body><div id="__next"><div style="font-family:system-ui,&quot;Segoe UI&quot;,Roboto,Helvetica,Arial,sans-serif,&quot;Apple Color Emoji&quot;,&quot;Segoe UI Emoji&quot;;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div style="line-height:48px"><style>body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}</style><h1 class="next-error-h1" style="display:inline-block;margin:0 20px 0 0;padding-right:23px;font-size:24px;font-weight:500;vertical-align:top">500</h1><div style="display:inline-block"><h2 style="font-size:14px;font-weight:400;line-height:28px">Internal Server Error<!-- -->.</h2></div></div></div></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"statusCode":500}},"page":"/_error","query":{},"buildId":"wyFLOpmKpr45BHZ4svYpE","nextExport":true,"isFallback":false,"gip":true,"scriptLoader":[]}</script></body></html>
@@ -1,5 +1,5 @@
1
1
  {
2
- "/_error": "pages/_error.js",
3
2
  "/_app": "pages/_app.js",
3
+ "/_error": "pages/_error.js",
4
4
  "/_document": "pages/_document.js"
5
5
  }
@@ -1 +1 @@
1
- {"node":{},"edge":{},"encryptionKey":"lqIPyiFpzU8Pa78MjP2JZYeiHFYrfYULKHk0AIPD+6o="}
1
+ {"node":{},"edge":{},"encryptionKey":"/bHE4VPfeqVSBprjiO5UGkI0cw2OpZ4HWQ6lj4Y9ank="}
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6381],{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,y]=(0,n.useState)(r),m=(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]),w=(0,n.useCallback)(e=>{if(o())try{let r=u.current(e);window.localStorage.setItem(t,r)}catch(e){}},[t]),h=(0,n.useCallback)(e=>{y(t=>{let r="function"==typeof e?e(t):e;return w(r),r})},[w]),S=(0,n.useCallback)(()=>{if(o())try{window.localStorage.removeItem(t)}catch(e){}y(l.current)},[t]);return(0,n.useEffect)(()=>{p(o()),y(m())},[m]),{value:g,setValue:h,removeValue:S,isAvailable:f}}},7636:(e,t,r)=>{r.d(t,{LV:()=>c,Si:()=>i,UZ:()=>s,Xn:()=>f,_s:()=>p,nO:()=>u,s6:()=>l});var n=r(38606);let o=["updatedAt","repositoryName","branchName","status","lastSent"],i=e=>o.includes(e),a={waiting:0,ready:1,running:2,generating:3,idle:4};function s(e){let t=new Set;for(let r of e)!1===r.visible&&t.add(r.path);return t}function l(e,t){return 0===t.size?e.slice():e.filter(e=>{let r=e.repositoryPath;return!r||!t.has(r)})}function c(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 u(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 d(e){return"waiting"===(e.cliStatus&&Object.keys(e.cliStatus).length>0?(0,n.A7)(e.cliStatus):e.status)}function f(e,t,r){let n=[...e],o="status"!==t;return n.sort((e,n)=>{if(o){let t=Number(d(n))-Number(d(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=a[e.status]-a[n.status];break;case"lastSent":{let t=u(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 p(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:f(n.get(e),t,r)}))}},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});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};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"});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})});let p=(0,o.useCallback)(()=>{f({type:"TOGGLE"})},[]),g=(0,o.useCallback)(e=>{f({type:"SET_WIDTH",width:e})},[]),y=(0,o.useCallback)(()=>{f({type:"OPEN_MOBILE_DRAWER"})},[]),m=(0,o.useCallback)(()=>{f({type:"CLOSE_MOBILE_DRAWER"})},[]),w=(0,o.useCallback)(e=>{f({type:"SET_SORT_KEY",sortKey:e})},[]),h=(0,o.useCallback)(e=>{f({type:"SET_SORT_DIRECTION",sortDirection:e})},[]),S=(0,o.useCallback)(e=>{f({type:"SET_VIEW_MODE",viewMode:e})},[]),b=(0,o.useMemo)(()=>({isOpen:d.isOpen,width:d.width,isMobileDrawerOpen:d.isMobileDrawerOpen,sortKey:d.sortKey,sortDirection:d.sortDirection,toggle:p,setWidth:g,openMobileDrawer:y,closeMobileDrawer:m,setSortKey:w,setSortDirection:h,viewMode:d.viewMode,setViewMode:S}),[d.isOpen,d.width,d.isMobileDrawerOpen,d.sortKey,d.sortDirection,d.viewMode,p,g,y,m,w,h,S]);return(0,n.jsx)(s.Provider,{value:b,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useSidebarContext must be used within a SidebarProvider");return e}},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:()=>l,kA:()=>i,f_:()=>d,dw:()=>c,XK:()=>f});var n=r(54014),o=r(63001);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={idle:null,ready:"ready",running:"running",generating:"running",waiting:"waiting"};function l(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 c(e,t){return e?Object.entries(e).map(e=>{var r;let[o,i]=e;return"".concat(null!=(r=null==t?void 0:t[o])?r:(0,n.f_)(o,o),": ").concat(null!=i?i:"idle")}).join(", "):""}let u=["prompt","menu","unclassified"];function d(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=u.find(e=>a.has(e)))?n:null,awaitingInstruction:i}}function f(e){var t,r,c,u,f,p;let g=i(void 0!==e.isSessionRunning?{isRunning:null!=(t=e.isSessionRunning)&&t,isWaitingForResponse:null!=(r=e.isWaitingForResponse)&&r,isProcessing:null!=(c=e.isProcessing)&&c}:void 0),y=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),{cliStatus:m,cliStatusLabels:w}=function(e){var t,r,a;let s={},l={},c=e.sessionStatusByInstance;if(!c){for(let a of null!=(t=e.selectedAgents)?t:o.fJ)s[a]=i(null==(r=e.sessionStatusByCli)?void 0:r[a]),l[a]=(0,n.oo)(a);return{cliStatus:s,cliStatusLabels:l}}let u=e.agentInstances&&e.agentInstances.length>0?e.agentInstances:(0,n.lu)(null!=(a=e.selectedAgents)?a:o.fJ),d=new Set;for(let e of u)d.add(e.id),s[e.id]=i(c[e.id]),l[e.id]=(0,n.sw)(e);for(let[e,t]of Object.entries(c)){if(d.has(e))continue;let r=i(t);"idle"!==r&&(s[e]=r,l[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:s,cliStatusLabels:l}}(e),h=l(m),{waitingKind:S,awaitingInstruction:b}=d(e);return{id:e.id,name:e.name,repositoryName:null!=(u=e.repositoryDisplayName)?u:e.repositoryName,status:g,hasUnread:y,lastActivity:e.updatedAt,description:e.description,cliStatus:m,cliStatusLabels:w,worktreePath:e.path,waitingKind:S,awaitingInstruction:b,nextActionKey:(f=s[h],p="waiting"===h?"approval":null,f&&"idle"!==f?"ready"===f?a.sendMessage:"waiting"===f&&"approval"===p?a.approveReject:"waiting"===f?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}=e,d=void 0!==r,[f,p]=(0,o.useReducer)(c,l);(0,o.useEffect)(()=>{d&&r&&p({type:"SET_WORKTREES",worktrees:r})},[d,r]),(0,o.useEffect)(()=>{d&&u&&p({type:"SET_REPOSITORIES",repositories:u})},[d,u]);let g=(0,o.useCallback)(async()=>{if(!d){p({type:"SET_LOADING",isLoading:!0}),p({type:"SET_ERROR",error:null});try{var e;let t=await i.y.getAll();p({type:"SET_WORKTREES",worktrees:t.worktrees}),p({type:"SET_REPOSITORIES",repositories:null!=(e=t.repositories)?e:[]})}catch(e){p({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktrees"})}}},[d]),y=(0,o.useCallback)(async e=>{p({type:"SELECT_WORKTREE",id:e}),p({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);p({type:"SET_WORKTREE_DETAIL",detail:t})}catch(e){p({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktree detail"})}finally{p({type:"SET_LOADING_DETAIL",isLoadingDetail:!1})}},[]),m=(0,o.useCallback)(async()=>{await g()},[g]);(0,o.useEffect)(()=>{d||g()},[g,d]),(0,o.useEffect)(()=>{if(d)return;let e=null,t=!0,r=async()=>{if(t)try{var n,o;let s=await i.y.getAll();p({type:"SET_WORKTREES",worktrees:s.worktrees}),p({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)}},[d]);let w={selectedWorktreeId:f.selectedWorktreeId,worktrees:f.worktrees,repositories:f.repositories,selectedWorktreeDetail:f.selectedWorktreeDetail,isLoadingDetail:f.isLoadingDetail,error:f.error,selectWorktree:y,refreshWorktrees:m};return(0,n.jsx)(s.Provider,{value:w,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"],u=1e3,d=5,f=100,p=1e3},52703:(e,t,r)=>{r.d(t,{Oo:()=>o,ST:()=>n,zS:()=>i});let n="client_version",o="version_mismatch";function i(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:()=>m,O6:()=>p,XH:()=>n,f_:()=>d,hR:()=>c,lu:()=>g,n6:()=>s,oo:()=>u,pQ:()=>i,sw:()=>f,vz:()=>y});let n=["claude","codex","gemini","vibe-local","opencode","copilot","antigravity"],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"};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 y=128,m=2097152},63001:(e,t,r)=>{r.d(t,{fJ:()=>n}),r(54014);let n=["claude","codex","antigravity"]},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),y=(0,o.useRef)(new Set),m=(0,o.useRef)(!1),w=(0,o.useRef)(t);w.current=t;let h=(0,o.useRef)(r);h.current=r;let S=(0,o.useCallback)(e=>{var t;d(e),null==(t=h.current)||t.call(h,e)},[]),b=(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;b(),m.current=!1,S("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,S("connected");try{r.send(JSON.stringify({type:i.ST,version:"0.25.0"}))}catch(e){}y.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=w.current)||t.call(w,n))},r.onerror=()=>{S("error")},r.onclose=()=>{var e;if(f.current=null,S("disconnected"),m.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,S,b]),E=(0,o.useCallback)(()=>{if(b(),m.current=!0,f.current){try{f.current.close(1e3,"Client disconnect")}catch(e){}f.current=null}},[b]),C=(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){}},[]),k=(0,o.useCallback)(e=>{y.current.has(e)||(y.current.add(e),C({type:"subscribe",worktreeId:e}))},[C]),T=(0,o.useCallback)(e=>{y.current.has(e)&&(y.current.delete(e),C({type:"unsubscribe",worktreeId:e}))},[C]);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:k,unsubscribe:T,send:C}}({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]),y=(0,o.useCallback)(e=>(s.current.add(e),()=>{s.current.delete(e)}),[]),m=(0,o.useMemo)(()=>({status:u,connected:"connected"===u,subscribe:p,unsubscribe:g,addListener:y}),[u,p,g,y]);return(0,n.jsx)(c.Provider,{value:m,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:()=>l,rC:()=>u,Fn:()=>c});var n=r(95155),o=r(12115),i=r(63365),a=r(39649);let s=(0,o.createContext)(null);function l(e){let{children:t}=e,{worktrees:r,repositories:l,isLoading:c,error:u,refresh:d}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)([]),[a,s]=(0,o.useState)(!0),[l,c]=(0,o.useState)(null),u=(0,o.useRef)(null),d=(0,o.useRef)([]),f=(0,o.useRef)(null),{connected:p,subscribe:g,unsubscribe:y,addListener:m}=(0,i.xM)(),w=(0,o.useRef)(p);w.current=p;let h=(0,o.useCallback)(async()=>{try{var e,r;c(null);let i=await fetch("/api/worktrees");if(!i.ok)throw Error("Failed to fetch worktrees: ".concat(i.status));let a=await i.json(),s=null!=(e=a.worktrees)?e:[],l=null!=(r=a.repositories)?r:[];(0,o.startTransition)(()=>{t(s),n(l)}),d.current=s}catch(e){c(e instanceof Error?e:Error(String(e)))}finally{s(!1)}},[]);(0,o.useEffect)(()=>{h()},[h]);let S=(0,o.useCallback)(()=>d.current.some(e=>!0===e.isSessionRunning),[]),b=(0,o.useCallback)(()=>{let e=S();return w.current?e?2e4:6e4:e?5e3:3e4},[S]),v=(0,o.useCallback)(()=>{null!==u.current&&(clearInterval(u.current),u.current=null),f.current=null},[]),E=(0,o.useCallback)(()=>{v();let e=b();f.current=e,u.current=setInterval(()=>{h()},e)},[b,h,v]);(0,o.useEffect)(()=>{let e=()=>{document.hidden?v():(h(),E())},t=setTimeout(()=>{E()},0);return document.addEventListener("visibilitychange",e),()=>{clearTimeout(t),v(),document.removeEventListener("visibilitychange",e)}},[h,E,v]),(0,o.useEffect)(()=>{if(d.current=e,"undefined"!=typeof document&&document.hidden||null===f.current)return;let t=b();f.current!==t&&E()},[e,p,b,E]);let C=e.map(e=>e.id).sort().join(" ");return(0,o.useEffect)(()=>{let e=C.length>0?C.split(" "):[];return e.forEach(e=>g(e)),()=>{e.forEach(e=>y(e))}},[C,g,y]),(0,o.useEffect)(()=>m(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 h();(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)&&h()}),[m,h]),{worktrees:e,repositories:r,isLoading:a,error:l,refresh:h}}(),f=(0,o.useMemo)(()=>({worktrees:r,repositories:l,isLoading:c,error:u,refresh:d}),[r,l,c,u,d]);return(0,n.jsx)(s.Provider,{value:f,children:(0,n.jsx)(a.H8,{externalWorktrees:r,externalRepositories:l,children:t})})}function c(){let e=(0,o.useContext)(s);if(null===e)throw Error("useWorktreesCacheContext must be used within a WorktreesCacheProvider");return e}function u(){return(0,o.useContext)(s)}},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)}},80344:(e,t,r)=>{r.d(t,{$T:()=>c,GQ:()=>d,Rx:()=>s,gC:()=>l,hD:()=>n,hS:()=>u,y:()=>a});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}}async function i(e,t){try{let r=new Headers(null==t?void 0:t.headers);r.set("Content-Type","application/json");let i=await fetch(e,{...t,headers:r}),a=i.headers.get("content-type")||"";if(i.redirected&&i.url.includes("/login"))throw new n("Authentication required",401);if(!i.ok){let e=await o(i,{},"error-body");throw new n(e.error||"HTTP error ".concat(i.status),i.status,e)}if(!a.includes("application/json"))throw new n("Unexpected response format",i.status);return i.json()}catch(e){if(e instanceof n)throw e;throw new n(e instanceof Error?e.message:"Unknown error",0,e)}}let a={getAll:async()=>i("/api/worktrees"),getById:async e=>i("/api/worktrees/".concat(e)),updateDescription:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({description:t})}),updateLink:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({link:t})}),toggleFavorite:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({favorite:t})}),updateStatus:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({status:t})}),updateCliTool:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({cliToolId:t})}),markAsViewed:async e=>i("/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)),i("/api/worktrees/".concat(e,"/messages").concat(o.toString()?"?".concat(o.toString()):""))},async sendMessage(e,t,r){let n={content:t};return(null==r?void 0:r.cliToolId)&&(n.cliToolId=r.cliToolId),(null==r?void 0:r.instanceId)&&(n.instanceId=r.instanceId),(null==r?void 0:r.imagePath)&&(n.imagePath=r.imagePath),i("/api/worktrees/".concat(e,"/send"),{method:"POST",body:JSON.stringify(n)})},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=>i("/api/worktrees/".concat(e,"/logs")),async getLogFile(e,t,r){let n=(null==r?void 0:r.sanitize)?"?sanitize=true":"";return i("/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 i("/api/worktrees/".concat(e,"/kill-session").concat(o?"?".concat(o):""),{method:"POST"})}},s={scan:async e=>i("/api/repositories/scan",{method:"POST",body:JSON.stringify({repositoryPath:e})}),sync:async()=>i("/api/repositories/sync",{method:"POST"}),delete:async e=>i("/api/repositories",{method:"DELETE",body:JSON.stringify({repositoryPath:e})}),async clone(e,t){var r;return i("/api/repositories/clone",{method:"POST",body:JSON.stringify({cloneUrl:e,fork:null!=(r=null==t?void 0:t.fork)&&r})})},getCloneStatus:async e=>i("/api/repositories/clone/".concat(e)),getExcluded:async()=>i("/api/repositories/excluded"),restore:async e=>i("/api/repositories/restore",{method:"PUT",body:JSON.stringify({repositoryPath:e})}),list:async()=>i("/api/repositories"),updateDisplayName:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({displayName:t})}),updateVisibility:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({visible:t})}),updateEnabled:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({enabled:t})}),validatePath:async e=>i("/api/repositories/validate-path",{method:"POST",body:JSON.stringify({repositoryPath:e})})},l={async browse(e){let t=e?"?path=".concat(encodeURIComponent(e)):"";return i("/api/fs/browse".concat(t))},addRecentPath:async e=>i("/api/fs/recent-paths",{method:"POST",body:JSON.stringify({path:e})})},c={getAll:async e=>(await i("/api/worktrees/".concat(e,"/memos"))).memos,create:async(e,t)=>(await i("/api/worktrees/".concat(e,"/memos"),{method:"POST",body:JSON.stringify(t||{})})).memo,update:async(e,t,r)=>(await i("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"PUT",body:JSON.stringify(r)})).memo,delete:async(e,t)=>i("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"DELETE"}),async reorder(e,t){await i("/api/worktrees/".concat(e,"/memos"),{method:"PATCH",body:JSON.stringify({memoIds:t})})}};function u(e){return e instanceof n||e instanceof Error?e.message:"An unknown error occurred"}let d={checkForUpdate:async()=>i("/api/app/update-check",{method:"GET"}),startUpdate:async()=>i("/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:()=>b});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 y(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 m(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),m=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),[w,h]=(0,o.useState)(!0),{shouldRender:S,isExiting:b}=(0,g.O)(w,p.Ys),v=(0,o.useRef)(s);v.current=s,(0,o.useEffect)(()=>{S||v.current(t)},[S,t]),(0,o.useEffect)(()=>(l>0&&(f.current=setTimeout(()=>{h(!1)},l)),()=>{f.current&&clearTimeout(f.current)}),[l]);let E=(0,o.useCallback)(()=>{f.current&&clearTimeout(f.current),h(!1)},[]);return(0,n.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(m.bgColor,"\n ").concat(m.borderColor,"\n ").concat(m.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n ").concat(b?"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)(y,{type:i,iconColor:m.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(m.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 w(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)(m,{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 h(){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 S=(0,o.createContext)(null);function b(e){let{children:t}=e,r=h();return(0,n.jsxs)(S.Provider,{value:r,children:[t,(0,n.jsx)(w,{toasts:r.toasts,onClose:r.removeToast})]})}function v(){let e=(0,o.useContext)(S),t=h();return null!=e?e:t}}}]);
1
+ "use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6381],{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,y]=(0,n.useState)(r),m=(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]),w=(0,n.useCallback)(e=>{if(o())try{let r=u.current(e);window.localStorage.setItem(t,r)}catch(e){}},[t]),h=(0,n.useCallback)(e=>{y(t=>{let r="function"==typeof e?e(t):e;return w(r),r})},[w]),S=(0,n.useCallback)(()=>{if(o())try{window.localStorage.removeItem(t)}catch(e){}y(l.current)},[t]);return(0,n.useEffect)(()=>{p(o()),y(m())},[m]),{value:g,setValue:h,removeValue:S,isAvailable:f}}},7636:(e,t,r)=>{r.d(t,{LV:()=>c,Si:()=>i,UZ:()=>s,Xn:()=>f,_s:()=>p,nO:()=>u,s6:()=>l});var n=r(38606);let o=["updatedAt","repositoryName","branchName","status","lastSent"],i=e=>o.includes(e),a={waiting:0,ready:1,running:2,generating:3,idle:4};function s(e){let t=new Set;for(let r of e)!1===r.visible&&t.add(r.path);return t}function l(e,t){return 0===t.size?e.slice():e.filter(e=>{let r=e.repositoryPath;return!r||!t.has(r)})}function c(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 u(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 d(e){return"waiting"===(e.cliStatus&&Object.keys(e.cliStatus).length>0?(0,n.A7)(e.cliStatus):e.status)}function f(e,t,r){let n=[...e],o="status"!==t;return n.sort((e,n)=>{if(o){let t=Number(d(n))-Number(d(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=a[e.status]-a[n.status];break;case"lastSent":{let t=u(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 p(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:f(n.get(e),t,r)}))}},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});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};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"});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})});let p=(0,o.useCallback)(()=>{f({type:"TOGGLE"})},[]),g=(0,o.useCallback)(e=>{f({type:"SET_WIDTH",width:e})},[]),y=(0,o.useCallback)(()=>{f({type:"OPEN_MOBILE_DRAWER"})},[]),m=(0,o.useCallback)(()=>{f({type:"CLOSE_MOBILE_DRAWER"})},[]),w=(0,o.useCallback)(e=>{f({type:"SET_SORT_KEY",sortKey:e})},[]),h=(0,o.useCallback)(e=>{f({type:"SET_SORT_DIRECTION",sortDirection:e})},[]),S=(0,o.useCallback)(e=>{f({type:"SET_VIEW_MODE",viewMode:e})},[]),b=(0,o.useMemo)(()=>({isOpen:d.isOpen,width:d.width,isMobileDrawerOpen:d.isMobileDrawerOpen,sortKey:d.sortKey,sortDirection:d.sortDirection,toggle:p,setWidth:g,openMobileDrawer:y,closeMobileDrawer:m,setSortKey:w,setSortDirection:h,viewMode:d.viewMode,setViewMode:S}),[d.isOpen,d.width,d.isMobileDrawerOpen,d.sortKey,d.sortDirection,d.viewMode,p,g,y,m,w,h,S]);return(0,n.jsx)(s.Provider,{value:b,children:t})}function d(){let e=(0,o.useContext)(s);if(!e)throw Error("useSidebarContext must be used within a SidebarProvider");return e}},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:()=>l,kA:()=>i,f_:()=>d,dw:()=>c,XK:()=>f});var n=r(54014),o=r(63001);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={idle:null,ready:"ready",running:"running",generating:"running",waiting:"waiting"};function l(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 c(e,t){return e?Object.entries(e).map(e=>{var r;let[o,i]=e;return"".concat(null!=(r=null==t?void 0:t[o])?r:(0,n.f_)(o,o),": ").concat(null!=i?i:"idle")}).join(", "):""}let u=["prompt","menu","unclassified"];function d(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=u.find(e=>a.has(e)))?n:null,awaitingInstruction:i}}function f(e){var t,r,c,u,f,p;let g=i(void 0!==e.isSessionRunning?{isRunning:null!=(t=e.isSessionRunning)&&t,isWaitingForResponse:null!=(r=e.isWaitingForResponse)&&r,isProcessing:null!=(c=e.isProcessing)&&c}:void 0),y=!!e.lastAssistantMessageAt&&(!e.lastViewedAt||new Date(e.lastAssistantMessageAt)>new Date(e.lastViewedAt)),{cliStatus:m,cliStatusLabels:w}=function(e){var t,r,a;let s={},l={},c=e.sessionStatusByInstance;if(!c){for(let a of null!=(t=e.selectedAgents)?t:o.fJ)s[a]=i(null==(r=e.sessionStatusByCli)?void 0:r[a]),l[a]=(0,n.oo)(a);return{cliStatus:s,cliStatusLabels:l}}let u=e.agentInstances&&e.agentInstances.length>0?e.agentInstances:(0,n.lu)(null!=(a=e.selectedAgents)?a:o.fJ),d=new Set;for(let e of u)d.add(e.id),s[e.id]=i(c[e.id]),l[e.id]=(0,n.sw)(e);for(let[e,t]of Object.entries(c)){if(d.has(e))continue;let r=i(t);"idle"!==r&&(s[e]=r,l[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:s,cliStatusLabels:l}}(e),h=l(m),{waitingKind:S,awaitingInstruction:b}=d(e);return{id:e.id,name:e.name,repositoryName:null!=(u=e.repositoryDisplayName)?u:e.repositoryName,status:g,hasUnread:y,lastActivity:e.updatedAt,description:e.description,cliStatus:m,cliStatusLabels:w,worktreePath:e.path,waitingKind:S,awaitingInstruction:b,nextActionKey:(f=s[h],p="waiting"===h?"approval":null,f&&"idle"!==f?"ready"===f?a.sendMessage:"waiting"===f&&"approval"===p?a.approveReject:"waiting"===f?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}=e,d=void 0!==r,[f,p]=(0,o.useReducer)(c,l);(0,o.useEffect)(()=>{d&&r&&p({type:"SET_WORKTREES",worktrees:r})},[d,r]),(0,o.useEffect)(()=>{d&&u&&p({type:"SET_REPOSITORIES",repositories:u})},[d,u]);let g=(0,o.useCallback)(async()=>{if(!d){p({type:"SET_LOADING",isLoading:!0}),p({type:"SET_ERROR",error:null});try{var e;let t=await i.y.getAll();p({type:"SET_WORKTREES",worktrees:t.worktrees}),p({type:"SET_REPOSITORIES",repositories:null!=(e=t.repositories)?e:[]})}catch(e){p({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktrees"})}}},[d]),y=(0,o.useCallback)(async e=>{p({type:"SELECT_WORKTREE",id:e}),p({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);p({type:"SET_WORKTREE_DETAIL",detail:t})}catch(e){p({type:"SET_ERROR",error:e instanceof Error?e.message:"Failed to fetch worktree detail"})}finally{p({type:"SET_LOADING_DETAIL",isLoadingDetail:!1})}},[]),m=(0,o.useCallback)(async()=>{await g()},[g]);(0,o.useEffect)(()=>{d||g()},[g,d]),(0,o.useEffect)(()=>{if(d)return;let e=null,t=!0,r=async()=>{if(t)try{var n,o;let s=await i.y.getAll();p({type:"SET_WORKTREES",worktrees:s.worktrees}),p({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)}},[d]);let w={selectedWorktreeId:f.selectedWorktreeId,worktrees:f.worktrees,repositories:f.repositories,selectedWorktreeDetail:f.selectedWorktreeDetail,isLoadingDetail:f.isLoadingDetail,error:f.error,selectWorktree:y,refreshWorktrees:m};return(0,n.jsx)(s.Provider,{value:w,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"],u=1e3,d=5,f=100,p=1e3},52703:(e,t,r)=>{r.d(t,{Oo:()=>o,ST:()=>n,zS:()=>i});let n="client_version",o="version_mismatch";function i(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:()=>m,O6:()=>p,XH:()=>n,f_:()=>d,hR:()=>c,lu:()=>g,n6:()=>s,oo:()=>u,pQ:()=>i,sw:()=>f,vz:()=>y});let n=["claude","codex","gemini","vibe-local","opencode","copilot","antigravity"],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"};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 y=128,m=2097152},63001:(e,t,r)=>{r.d(t,{fJ:()=>n}),r(54014);let n=["claude","codex","antigravity"]},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),y=(0,o.useRef)(new Set),m=(0,o.useRef)(!1),w=(0,o.useRef)(t);w.current=t;let h=(0,o.useRef)(r);h.current=r;let S=(0,o.useCallback)(e=>{var t;d(e),null==(t=h.current)||t.call(h,e)},[]),b=(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;b(),m.current=!1,S("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,S("connected");try{r.send(JSON.stringify({type:i.ST,version:"0.26.1"}))}catch(e){}y.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=w.current)||t.call(w,n))},r.onerror=()=>{S("error")},r.onclose=()=>{var e;if(f.current=null,S("disconnected"),m.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,S,b]),E=(0,o.useCallback)(()=>{if(b(),m.current=!0,f.current){try{f.current.close(1e3,"Client disconnect")}catch(e){}f.current=null}},[b]),C=(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){}},[]),k=(0,o.useCallback)(e=>{y.current.has(e)||(y.current.add(e),C({type:"subscribe",worktreeId:e}))},[C]),T=(0,o.useCallback)(e=>{y.current.has(e)&&(y.current.delete(e),C({type:"unsubscribe",worktreeId:e}))},[C]);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:k,unsubscribe:T,send:C}}({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]),y=(0,o.useCallback)(e=>(s.current.add(e),()=>{s.current.delete(e)}),[]),m=(0,o.useMemo)(()=>({status:u,connected:"connected"===u,subscribe:p,unsubscribe:g,addListener:y}),[u,p,g,y]);return(0,n.jsx)(c.Provider,{value:m,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:()=>l,rC:()=>u,Fn:()=>c});var n=r(95155),o=r(12115),i=r(63365),a=r(39649);let s=(0,o.createContext)(null);function l(e){let{children:t}=e,{worktrees:r,repositories:l,isLoading:c,error:u,refresh:d}=function(){let[e,t]=(0,o.useState)([]),[r,n]=(0,o.useState)([]),[a,s]=(0,o.useState)(!0),[l,c]=(0,o.useState)(null),u=(0,o.useRef)(null),d=(0,o.useRef)([]),f=(0,o.useRef)(null),{connected:p,subscribe:g,unsubscribe:y,addListener:m}=(0,i.xM)(),w=(0,o.useRef)(p);w.current=p;let h=(0,o.useCallback)(async()=>{try{var e,r;c(null);let i=await fetch("/api/worktrees");if(!i.ok)throw Error("Failed to fetch worktrees: ".concat(i.status));let a=await i.json(),s=null!=(e=a.worktrees)?e:[],l=null!=(r=a.repositories)?r:[];(0,o.startTransition)(()=>{t(s),n(l)}),d.current=s}catch(e){c(e instanceof Error?e:Error(String(e)))}finally{s(!1)}},[]);(0,o.useEffect)(()=>{h()},[h]);let S=(0,o.useCallback)(()=>d.current.some(e=>!0===e.isSessionRunning),[]),b=(0,o.useCallback)(()=>{let e=S();return w.current?e?2e4:6e4:e?5e3:3e4},[S]),v=(0,o.useCallback)(()=>{null!==u.current&&(clearInterval(u.current),u.current=null),f.current=null},[]),E=(0,o.useCallback)(()=>{v();let e=b();f.current=e,u.current=setInterval(()=>{h()},e)},[b,h,v]);(0,o.useEffect)(()=>{let e=()=>{document.hidden?v():(h(),E())},t=setTimeout(()=>{E()},0);return document.addEventListener("visibilitychange",e),()=>{clearTimeout(t),v(),document.removeEventListener("visibilitychange",e)}},[h,E,v]),(0,o.useEffect)(()=>{if(d.current=e,"undefined"!=typeof document&&document.hidden||null===f.current)return;let t=b();f.current!==t&&E()},[e,p,b,E]);let C=e.map(e=>e.id).sort().join(" ");return(0,o.useEffect)(()=>{let e=C.length>0?C.split(" "):[];return e.forEach(e=>g(e)),()=>{e.forEach(e=>y(e))}},[C,g,y]),(0,o.useEffect)(()=>m(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 h();(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)&&h()}),[m,h]),{worktrees:e,repositories:r,isLoading:a,error:l,refresh:h}}(),f=(0,o.useMemo)(()=>({worktrees:r,repositories:l,isLoading:c,error:u,refresh:d}),[r,l,c,u,d]);return(0,n.jsx)(s.Provider,{value:f,children:(0,n.jsx)(a.H8,{externalWorktrees:r,externalRepositories:l,children:t})})}function c(){let e=(0,o.useContext)(s);if(null===e)throw Error("useWorktreesCacheContext must be used within a WorktreesCacheProvider");return e}function u(){return(0,o.useContext)(s)}},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)}},80344:(e,t,r)=>{r.d(t,{$T:()=>c,GQ:()=>d,Rx:()=>s,gC:()=>l,hD:()=>n,hS:()=>u,y:()=>a});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}}async function i(e,t){try{let r=new Headers(null==t?void 0:t.headers);r.set("Content-Type","application/json");let i=await fetch(e,{...t,headers:r}),a=i.headers.get("content-type")||"";if(i.redirected&&i.url.includes("/login"))throw new n("Authentication required",401);if(!i.ok){let e=await o(i,{},"error-body");throw new n(e.error||"HTTP error ".concat(i.status),i.status,e)}if(!a.includes("application/json"))throw new n("Unexpected response format",i.status);return i.json()}catch(e){if(e instanceof n)throw e;throw new n(e instanceof Error?e.message:"Unknown error",0,e)}}let a={getAll:async()=>i("/api/worktrees"),getById:async e=>i("/api/worktrees/".concat(e)),updateDescription:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({description:t})}),updateLink:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({link:t})}),toggleFavorite:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({favorite:t})}),updateStatus:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({status:t})}),updateCliTool:async(e,t)=>i("/api/worktrees/".concat(e),{method:"PATCH",body:JSON.stringify({cliToolId:t})}),markAsViewed:async e=>i("/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)),i("/api/worktrees/".concat(e,"/messages").concat(o.toString()?"?".concat(o.toString()):""))},async sendMessage(e,t,r){let n={content:t};return(null==r?void 0:r.cliToolId)&&(n.cliToolId=r.cliToolId),(null==r?void 0:r.instanceId)&&(n.instanceId=r.instanceId),(null==r?void 0:r.imagePath)&&(n.imagePath=r.imagePath),i("/api/worktrees/".concat(e,"/send"),{method:"POST",body:JSON.stringify(n)})},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=>i("/api/worktrees/".concat(e,"/logs")),async getLogFile(e,t,r){let n=(null==r?void 0:r.sanitize)?"?sanitize=true":"";return i("/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 i("/api/worktrees/".concat(e,"/kill-session").concat(o?"?".concat(o):""),{method:"POST"})}},s={scan:async e=>i("/api/repositories/scan",{method:"POST",body:JSON.stringify({repositoryPath:e})}),sync:async()=>i("/api/repositories/sync",{method:"POST"}),delete:async e=>i("/api/repositories",{method:"DELETE",body:JSON.stringify({repositoryPath:e})}),async clone(e,t){var r;return i("/api/repositories/clone",{method:"POST",body:JSON.stringify({cloneUrl:e,fork:null!=(r=null==t?void 0:t.fork)&&r})})},getCloneStatus:async e=>i("/api/repositories/clone/".concat(e)),getExcluded:async()=>i("/api/repositories/excluded"),restore:async e=>i("/api/repositories/restore",{method:"PUT",body:JSON.stringify({repositoryPath:e})}),list:async()=>i("/api/repositories"),updateDisplayName:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({displayName:t})}),updateVisibility:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({visible:t})}),updateEnabled:async(e,t)=>i("/api/repositories/".concat(encodeURIComponent(e)),{method:"PUT",body:JSON.stringify({enabled:t})}),validatePath:async e=>i("/api/repositories/validate-path",{method:"POST",body:JSON.stringify({repositoryPath:e})})},l={async browse(e){let t=e?"?path=".concat(encodeURIComponent(e)):"";return i("/api/fs/browse".concat(t))},addRecentPath:async e=>i("/api/fs/recent-paths",{method:"POST",body:JSON.stringify({path:e})})},c={getAll:async e=>(await i("/api/worktrees/".concat(e,"/memos"))).memos,create:async(e,t)=>(await i("/api/worktrees/".concat(e,"/memos"),{method:"POST",body:JSON.stringify(t||{})})).memo,update:async(e,t,r)=>(await i("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"PUT",body:JSON.stringify(r)})).memo,delete:async(e,t)=>i("/api/worktrees/".concat(e,"/memos/").concat(t),{method:"DELETE"}),async reorder(e,t){await i("/api/worktrees/".concat(e,"/memos"),{method:"PATCH",body:JSON.stringify({memoIds:t})})}};function u(e){return e instanceof n||e instanceof Error?e.message:"An unknown error occurred"}let d={checkForUpdate:async()=>i("/api/app/update-check",{method:"GET"}),startUpdate:async()=>i("/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:()=>b});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 y(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 m(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),m=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),[w,h]=(0,o.useState)(!0),{shouldRender:S,isExiting:b}=(0,g.O)(w,p.Ys),v=(0,o.useRef)(s);v.current=s,(0,o.useEffect)(()=>{S||v.current(t)},[S,t]),(0,o.useEffect)(()=>(l>0&&(f.current=setTimeout(()=>{h(!1)},l)),()=>{f.current&&clearTimeout(f.current)}),[l]);let E=(0,o.useCallback)(()=>{f.current&&clearTimeout(f.current),h(!1)},[]);return(0,n.jsxs)("div",{"data-testid":"toast-".concat(t),role:"alert",className:"\n ".concat(m.bgColor,"\n ").concat(m.borderColor,"\n ").concat(m.textColor,"\n border rounded-lg shadow-lg p-4 min-w-[300px] max-w-[400px]\n flex items-start gap-3\n ").concat(b?"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)(y,{type:i,iconColor:m.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(m.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 w(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)(m,{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 h(){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 S=(0,o.createContext)(null);function b(e){let{children:t}=e,r=h();return(0,n.jsxs)(S.Provider,{value:r,children:[t,(0,n.jsx)(w,{toasts:r.toasts,onClose:r.removeToast})]})}function v(){let e=(0,o.useContext)(S),t=h();return null!=e?e:t}}}]);