@tt-a1i/hive 2.0.2 → 2.1.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 (147) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/README.en.md +15 -6
  3. package/README.md +26 -4
  4. package/dist/src/cli/hive.d.ts +4 -0
  5. package/dist/src/cli/hive.js +25 -3
  6. package/dist/src/cli/team.d.ts +8 -1
  7. package/dist/src/cli/team.js +111 -11
  8. package/dist/src/server/action-center-summary.d.ts +193 -0
  9. package/dist/src/server/action-center-summary.js +188 -0
  10. package/dist/src/server/agent-command-resolver.d.ts +6 -0
  11. package/dist/src/server/agent-command-resolver.js +16 -0
  12. package/dist/src/server/agent-manager.js +11 -1
  13. package/dist/src/server/agent-run-starter.js +47 -6
  14. package/dist/src/server/agent-runtime-types.d.ts +4 -0
  15. package/dist/src/server/agent-startup-instructions.d.ts +4 -0
  16. package/dist/src/server/agent-startup-instructions.js +35 -9
  17. package/dist/src/server/agent-stdin-dispatcher.js +17 -9
  18. package/dist/src/server/diagnostics-support-bundle.d.ts +288 -0
  19. package/dist/src/server/diagnostics-support-bundle.js +179 -0
  20. package/dist/src/server/dispatch-ledger-store.d.ts +4 -1
  21. package/dist/src/server/dispatch-ledger-store.js +46 -6
  22. package/dist/src/server/hive-envelope-escape.d.ts +2 -0
  23. package/dist/src/server/hive-envelope-escape.js +2 -0
  24. package/dist/src/server/hive-team-guidance.d.ts +1 -1
  25. package/dist/src/server/hive-team-guidance.js +67 -25
  26. package/dist/src/server/message-log-store.d.ts +1 -1
  27. package/dist/src/server/post-start-input-writer.js +12 -4
  28. package/dist/src/server/preset-launch-support.d.ts +2 -0
  29. package/dist/src/server/preset-launch-support.js +65 -2
  30. package/dist/src/server/protocol-event-stats.d.ts +39 -0
  31. package/dist/src/server/protocol-event-stats.js +84 -0
  32. package/dist/src/server/recovery-summary.js +19 -14
  33. package/dist/src/server/role-template-store.d.ts +1 -1
  34. package/dist/src/server/role-templates.d.ts +1 -0
  35. package/dist/src/server/role-templates.js +43 -29
  36. package/dist/src/server/routes-action-center.d.ts +2 -0
  37. package/dist/src/server/routes-action-center.js +37 -0
  38. package/dist/src/server/routes-diagnostics.d.ts +2 -0
  39. package/dist/src/server/routes-diagnostics.js +17 -0
  40. package/dist/src/server/routes-scenarios.d.ts +25 -0
  41. package/dist/src/server/routes-scenarios.js +89 -0
  42. package/dist/src/server/routes-settings.js +2 -11
  43. package/dist/src/server/routes-team-memory.js +52 -0
  44. package/dist/src/server/routes-team.js +40 -20
  45. package/dist/src/server/routes-workspace-memory-dreams.js +8 -0
  46. package/dist/src/server/routes-workspace-uploads.d.ts +2 -0
  47. package/dist/src/server/routes-workspace-uploads.js +154 -0
  48. package/dist/src/server/routes-workspaces.js +29 -3
  49. package/dist/src/server/routes.js +8 -0
  50. package/dist/src/server/runtime-message-builders.d.ts +0 -1
  51. package/dist/src/server/runtime-message-builders.js +0 -8
  52. package/dist/src/server/runtime-store-contract.d.ts +15 -0
  53. package/dist/src/server/runtime-store-dream.d.ts +14 -1
  54. package/dist/src/server/runtime-store-dream.js +49 -1
  55. package/dist/src/server/runtime-store-helpers.d.ts +7 -0
  56. package/dist/src/server/runtime-store-helpers.js +85 -22
  57. package/dist/src/server/runtime-store-worker-mutations.d.ts +11 -0
  58. package/dist/src/server/runtime-store-worker-mutations.js +46 -0
  59. package/dist/src/server/runtime-store-workflows.js +10 -6
  60. package/dist/src/server/runtime-store.js +34 -42
  61. package/dist/src/server/scenario-presets.d.ts +25 -0
  62. package/dist/src/server/scenario-presets.js +35 -0
  63. package/dist/src/server/sentinel-heartbeat.d.ts +30 -0
  64. package/dist/src/server/sentinel-heartbeat.js +145 -0
  65. package/dist/src/server/spawn-cli-resolver.d.ts +37 -0
  66. package/dist/src/server/spawn-cli-resolver.js +70 -0
  67. package/dist/src/server/spawn-worker-defaults.d.ts +13 -0
  68. package/dist/src/server/spawn-worker-defaults.js +45 -0
  69. package/dist/src/server/sqlite-schema-v32.d.ts +2 -0
  70. package/dist/src/server/sqlite-schema-v32.js +17 -0
  71. package/dist/src/server/sqlite-schema-v33.d.ts +3 -0
  72. package/dist/src/server/sqlite-schema-v33.js +18 -0
  73. package/dist/src/server/sqlite-schema-v34.d.ts +11 -0
  74. package/dist/src/server/sqlite-schema-v34.js +19 -0
  75. package/dist/src/server/sqlite-schema-v35.d.ts +3 -0
  76. package/dist/src/server/sqlite-schema-v35.js +23 -0
  77. package/dist/src/server/sqlite-schema.d.ts +1 -1
  78. package/dist/src/server/sqlite-schema.js +35 -1
  79. package/dist/src/server/system-message.d.ts +5 -2
  80. package/dist/src/server/system-message.js +5 -2
  81. package/dist/src/server/tasks-file-watcher.d.ts +8 -0
  82. package/dist/src/server/tasks-file-watcher.js +31 -2
  83. package/dist/src/server/team-authz.d.ts +9 -1
  84. package/dist/src/server/team-authz.js +24 -0
  85. package/dist/src/server/team-list-serializer.d.ts +2 -2
  86. package/dist/src/server/team-list-serializer.js +2 -1
  87. package/dist/src/server/team-memory-digest.js +4 -4
  88. package/dist/src/server/team-memory-dream-applier.js +24 -3
  89. package/dist/src/server/team-memory-dream-prompt.d.ts +13 -0
  90. package/dist/src/server/team-memory-dream-prompt.js +91 -0
  91. package/dist/src/server/team-memory-dream-run-store.d.ts +2 -0
  92. package/dist/src/server/team-memory-dream-run-store.js +14 -4
  93. package/dist/src/server/team-memory-dream-runner.d.ts +2 -21
  94. package/dist/src/server/team-memory-dream-runner.js +3 -148
  95. package/dist/src/server/team-memory-dream-store.d.ts +1 -1
  96. package/dist/src/server/team-memory-dream-store.js +1 -1
  97. package/dist/src/server/team-operations.d.ts +18 -2
  98. package/dist/src/server/team-operations.js +222 -33
  99. package/dist/src/server/team-recap.d.ts +10 -0
  100. package/dist/src/server/team-recap.js +73 -0
  101. package/dist/src/server/terminal-input-profile.js +88 -9
  102. package/dist/src/server/upload-limits.d.ts +2 -0
  103. package/dist/src/server/upload-limits.js +2 -0
  104. package/dist/src/server/workflow-cli-policy.d.ts +7 -2
  105. package/dist/src/server/workflow-cli-policy.js +15 -3
  106. package/dist/src/server/workflow-run-store.d.ts +1 -0
  107. package/dist/src/server/workflow-run-store.js +11 -1
  108. package/dist/src/server/workflow-runner.d.ts +4 -1
  109. package/dist/src/server/workflow-runner.js +418 -118
  110. package/dist/src/server/workflow-script-loader.d.ts +3 -2
  111. package/dist/src/server/workflow-script-loader.js +161 -0
  112. package/dist/src/server/workspace-store-contract.d.ts +2 -0
  113. package/dist/src/server/workspace-store.d.ts +1 -1
  114. package/dist/src/server/workspace-store.js +40 -30
  115. package/dist/src/server/workspace-upload-store.d.ts +40 -0
  116. package/dist/src/server/workspace-upload-store.js +295 -0
  117. package/dist/src/shared/scenario-presets.d.ts +32 -0
  118. package/dist/src/shared/scenario-presets.js +69 -0
  119. package/dist/src/shared/types.d.ts +12 -1
  120. package/package.json +1 -1
  121. package/web/dist/assets/AddWorkerDialog-CTOsPurT.js +2 -0
  122. package/web/dist/assets/AddWorkspaceFlow-D_fSv-cO.js +1 -0
  123. package/web/dist/assets/FirstRunWizard-C24MUssx.js +1 -0
  124. package/web/dist/assets/{MarketplaceDrawer-Dd8WIA8T.js → MarketplaceDrawer-7gVUjgAx.js} +11 -11
  125. package/web/dist/assets/TaskGraphDrawer-Beh95yUu.js +1 -0
  126. package/web/dist/assets/WhatsNewDialog-vnShQWjg.js +1 -0
  127. package/web/dist/assets/WorkerModal-DcxIBPlu.js +1 -0
  128. package/web/dist/assets/{WorkflowsDrawer-Bjf4olbR.js → WorkflowsDrawer-C8csID1I.js} +1 -1
  129. package/web/dist/assets/WorkspaceMemoryDrawer-C_Aq9-o6.js +1 -0
  130. package/web/dist/assets/{WorkspaceTaskDrawer-BIWwISvA.js → WorkspaceTaskDrawer-CIMYzlpt.js} +1 -1
  131. package/web/dist/assets/index-3Hc1oXlt.css +1 -0
  132. package/web/dist/assets/index-D9zUE0W6.js +79 -0
  133. package/web/dist/assets/{search-Bk2HQvO7.js → search-BRQbevR2.js} +1 -1
  134. package/web/dist/assets/{square-terminal-D93m9hfY.js → square-terminal-Co4pmGzn.js} +1 -1
  135. package/web/dist/index.html +2 -2
  136. package/web/dist/sw.js +1 -1
  137. package/dist/src/server/env-sync-message.d.ts +0 -9
  138. package/dist/src/server/env-sync-message.js +0 -29
  139. package/web/dist/assets/AddWorkerDialog-CbV75qUX.js +0 -2
  140. package/web/dist/assets/AddWorkspaceFlow-CwV-7wPx.js +0 -1
  141. package/web/dist/assets/FirstRunWizard-a6PWIK3x.js +0 -1
  142. package/web/dist/assets/TaskGraphDrawer-Bk5WFIk_.js +0 -1
  143. package/web/dist/assets/WhatsNewDialog-C2VZaip0.js +0 -1
  144. package/web/dist/assets/WorkerModal-DucW-9YT.js +0 -1
  145. package/web/dist/assets/WorkspaceMemoryDrawer-DglCy_5f.js +0 -1
  146. package/web/dist/assets/index-BAiLYajK.css +0 -1
  147. package/web/dist/assets/index-BV2k9Dts.js +0 -73
@@ -1 +1 @@
1
- import{c}from"./index-BV2k9Dts.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
1
+ import{c}from"./index-D9zUE0W6.js";const e=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],o=c("search",e);export{o as S};
@@ -1 +1 @@
1
- import{c as e}from"./index-BV2k9Dts.js";const r=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],a=e("square-terminal",r);export{a as S};
1
+ import{c as e}from"./index-D9zUE0W6.js";const r=[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]],a=e("square-terminal",r);export{a as S};
@@ -32,8 +32,8 @@
32
32
  href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=DM+Mono:wght@400;500&display=swap"
33
33
  rel="stylesheet"
34
34
  />
35
- <script type="module" crossorigin src="/assets/index-BV2k9Dts.js"></script>
36
- <link rel="stylesheet" crossorigin href="/assets/index-BAiLYajK.css">
35
+ <script type="module" crossorigin src="/assets/index-D9zUE0W6.js"></script>
36
+ <link rel="stylesheet" crossorigin href="/assets/index-3Hc1oXlt.css">
37
37
  </head>
38
38
  <body>
39
39
  <div id="root"></div>
package/web/dist/sw.js CHANGED
@@ -7,7 +7,7 @@
7
7
  // generation must be able to resolve its lazy-loaded hashed chunks, and
8
8
  // storage growth is bounded by Hive's release cadence.
9
9
 
10
- const VERSION = '2.0.2'
10
+ const VERSION = '2.1.1'
11
11
  const SHELL_CACHE = `hive-cache-v${VERSION}-shell`
12
12
  const ASSETS_CACHE = `hive-cache-v${VERSION}-assets`
13
13
  const STATIC_CACHE = `hive-cache-v${VERSION}-static`
@@ -1,9 +0,0 @@
1
- import type { AgentSummary, WorkspaceSummary } from '../shared/types.js';
2
- import type { RecoveryMessage } from './message-log-store.js';
3
- export declare const buildEnvSyncMessage: ({ agent, tasksContent, workers, workspace, restartWindowMessages, }: {
4
- agent: AgentSummary;
5
- tasksContent: string;
6
- workers: AgentSummary[];
7
- workspace: WorkspaceSummary;
8
- restartWindowMessages: RecoveryMessage[];
9
- }) => string;
@@ -1,29 +0,0 @@
1
- import { getHiveTeamRules } from './hive-team-guidance.js';
2
- import { wrapSystemMessage } from './system-message.js';
3
- import { TASKS_RELATIVE_PATH } from './tasks-file.js';
4
- const TASKS_HEAD_LIMIT = 1024;
5
- const formatWorkers = (workers) => {
6
- if (workers.length === 0)
7
- return ['- (no other workers)'];
8
- return workers.map((worker) => `- ${worker.name} (${worker.role}, ${worker.status}, pending_task_count: ${worker.pendingTaskCount})`);
9
- };
10
- const formatRestartWindow = (messages) => {
11
- const sends = messages.filter((message) => {
12
- return message.type === 'send';
13
- });
14
- if (sends.length === 0)
15
- return ['- no new dispatches during the restart'];
16
- return sends.slice(-5).map((message) => `- send -> ${message.to}: ${message.text}`);
17
- };
18
- export const buildEnvSyncMessage = ({ agent, tasksContent, workers, workspace, restartWindowMessages, }) => wrapSystemMessage([
19
- 'Hive just restarted you. Environment changes during the restart:',
20
- `- Current workspace: ${workspace.name}`,
21
- '- Existing workers:',
22
- ...formatWorkers(workers),
23
- `- Current ${TASKS_RELATIVE_PATH} contents:`,
24
- tasksContent.slice(0, TASKS_HEAD_LIMIT) || '(empty)',
25
- ...formatRestartWindow(restartWindowMessages),
26
- agent.role === 'orchestrator' ? '- Hive worker dispatch rules:' : '- Hive worker boundaries:',
27
- ...getHiveTeamRules(agent).map((rule) => ` - ${rule}`),
28
- `Continue. If unsure, run team list / Read ${TASKS_RELATIVE_PATH} to self-check, or ask the user.`,
29
- ].join('\n'));
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-Dd8WIA8T.js","assets/index-BV2k9Dts.js","assets/index-BAiLYajK.css","assets/search-Bk2HQvO7.js"])))=>i.map(i=>d[i]);
2
- import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ac as ee,ad as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,$ as de,z as ce,X as me,T as xe,ae as ue}from"./index-BV2k9Dts.js";import{S as pe}from"./search-Bk2HQvO7.js";import{S as he}from"./square-terminal-D93m9hfY.js";const fe=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],be=z("bookmark-plus",fe);const ge=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ve=z("dices",ge);const ke=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[b,x]=d.useState(!1),[m,u]=d.useState(""),[g,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!b)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[b]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":b,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),b?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===c;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{s(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:g!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:g?o("addWorker.templateDeleteConfirm",{name:g.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!g||a)return;const r=g.id;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:b,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:g}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=g==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(be,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:l=>n(l.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:b||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:b})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(he,{size:13})});return e.jsxs("button",{type:"button",onClick:b,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(te,{commandPresetId:s,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),b=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:n("addWorker.startupCommand")}),b?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:x})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:m=>t(m.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-Dd8WIA8T.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:b,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:g,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,$]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,A=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):A?.available===!1&&!T?i("addWorker.unavailable",{name:A.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(me,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),$(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:b,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:g,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>$(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
@@ -1 +0,0 @@
1
- import{c as I,u as R,r as c,j as e,C as W,x as oe,_ as pe,R as H,P as Z,O as G,k as K,m as X,$ as te,b as B,a0 as Ne,a1 as Ce,i as _e,z as Pe,X as Se,a2 as ue,a3 as Ee,a4 as ze,a5 as Re}from"./index-BV2k9Dts.js";const $e=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Me=I("arrow-up",$e);const De=[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]],Le=I("folder-search",De);const Ie=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Y=I("folder",Ie);const Ae=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],me=I("git-branch",Ae);const Oe=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],Fe=I("hard-drive",Oe);const Be=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],J=I("sliders-vertical",Be),xe=t=>{const s=t.trim();if(s.length<2)return s;const n=s[0],r=s[s.length-1];return(n==='"'||n==="'")&&n===r?s.slice(1,-1):s},We={claude:"/cli-icons/claude.png",codex:"/cli-icons/codex.png",opencode:"/cli-icons/opencode.svg",gemini:"/cli-icons/gemini.png",hermes:"/cli-icons/hermes.png",qwen:"/cli-icons/qwen.png",agy:"/cli-icons/agy.png",cursor:"/cli-icons/cursor.ico",grok:"/cli-icons/grok.ico"},ce=({id:t,className:s})=>{const[n,r]=c.useState(!1),l=We[t];return l&&!n?e.jsx("img",{src:l,alt:"",onError:()=>r(!0),className:`${s} object-contain rounded-xs ${t==="opencode"?"bg-[#ebebeb] p-[1px]":""}`}):e.jsx(pe,{size:14,className:s})},he=({error:t,onChange:s,presets:n,value:r})=>{const{t:l}=R(),[i,o]=c.useState(!1),u=c.useRef(null),h=n.find(p=>p.id===r),a=r==="",g=h?[h.command,...h.args].join(" ").trim():l(a?"workspace.preset.genericPreview":"workspace.preset.loading"),d=h?.displayName??(a?l("workspace.preset.generic"):"Claude Code (CC)"),k=n.length===0&&!a;return c.useEffect(()=>{if(!i)return;const p=x=>{u.current?.contains(x.target)||o(!1)},m=x=>{x.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",m)}},[i]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:l("workspace.preset.label")}),e.jsxs("div",{ref:u,className:"cli-select group relative",children:[e.jsx(ce,{id:r,className:"cli-select__leading w-3.5 h-3.5"}),e.jsx("button",{type:"button","aria-haspopup":"listbox","aria-expanded":i,"aria-disabled":k||void 0,className:"cli-select__field cli-select__field--button text-left","data-testid":"workspace-command-preset","data-value":r,disabled:k,onClick:()=>o(p=>!p),children:d}),e.jsx(W,{size:14,"aria-hidden":!0,className:"cli-select__trailing"}),i&&n.length>0?e.jsxs("div",{role:"listbox","aria-label":l("workspace.preset.optionsAria"),className:"cli-select__menu","data-testid":"workspace-command-preset-menu",children:[n.map(p=>{const m=p.id===r,x=p.available===!1;return e.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-testid":`workspace-command-preset-option-${p.id}`,className:"cli-select__option",onClick:()=>{s(p.id),o(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:m?1:0}}),e.jsx(ce,{id:p.id,className:"w-3.5 h-3.5 text-ter shrink-0"}),e.jsxs("span",{children:[p.displayName,x?l("workspace.preset.notFoundSuffix"):""]})]},p.id)}),e.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":"workspace-command-preset-option-generic",className:"cli-select__option",onClick:()=>{s(""),o(!1)},children:[e.jsx(oe,{size:12,"aria-hidden":!0,className:"cli-select__check",style:{opacity:a?1:0}}),e.jsx(pe,{size:14,className:"text-ter shrink-0"}),e.jsx("span",{children:l("workspace.preset.generic")})]})]}):null]}),e.jsxs("div",{className:"mono flex items-center gap-1.5 truncate text-xs text-ter",title:g,children:[e.jsx("span",{className:"text-sec",children:"$"}),e.jsx("span",{className:"truncate",children:g})]}),t?e.jsx("span",{className:"text-xs",style:{color:"var(--status-red)"},children:t}):null]})},V=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),U=({children:t})=>e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:t}),Te=({probe:t,pasteFallbackDefault:s=!1,commandPresetError:n,commandPresetId:r,commandPresets:l,onCancel:i,onCommandPresetChange:o,onCreate:u,onOpenServerBrowse:h})=>{const{t:a}=R(),g=t?.path??"",d=t?.suggested_name??V(g),[k,p]=c.useState(d),[m,x]=c.useState(""),[w,C]=c.useState(s),[N,_]=c.useState(!1),[E,b]=c.useState("");c.useEffect(()=>{p(t?.suggested_name??V(t?.path??""))},[t?.path,t?.suggested_name]);const j=xe(m),f=V(j),P=w&&j.length>0?j:t?.path??"",S=E.trim(),A=l.find(y=>y.id===r),z=l.length===0&&!n,O=!r&&S.length===0,D=A?.available===!1&&S.length===0,Q=O?a("workspace.preset.genericRequiresStartup"):D?a("workspace.preset.notInstalled",{name:A.displayName}):null,F=k.trim().length>0&&P.length>0&&!z&&!O&&!D,ee=()=>{F&&u({commandPresetId:r||null,name:k.trim(),path:P,...S?{startupCommand:S}:{}})};return c.useEffect(()=>{w&&j.length>0&&p(f)},[w,j,f]),e.jsx(H,{open:!0,onOpenChange:y=>!y&&i(),children:e.jsxs(Z,{children:[e.jsx(G,{"data-testid":"confirm-workspace-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(K,{"data-testid":"confirm-workspace-dialog",className:"dialog-scale-pop elev-2 pointer-events-auto flex w-[480px] max-w-full flex-col rounded-lg border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Y,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(X,{className:"text-lg font-semibold text-pri",children:a("workspace.confirm.title")}),e.jsx(te,{className:"text-xs text-ter",children:a("workspace.confirm.description")})]})]}),e.jsxs("div",{className:"flex flex-col gap-4 px-5 py-4",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(U,{children:a("workspace.field.path")}),e.jsx("input",{type:"hidden",value:t?.path??"","data-testid":"confirm-workspace-path",readOnly:!0}),e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("span",{className:"block truncate font-mono text-sm text-pri",title:t?.path??"",children:t?.path||a("workspace.field.pathEmptyPlaceholder")})}),t?.is_git_repository?e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 rounded px-2 py-0.5 text-xs font-medium",style:{background:"color-mix(in oklab, var(--status-blue) 12%, transparent)",color:"var(--status-blue)",border:"1px solid color-mix(in oklab, var(--status-blue) 25%, transparent)"},"data-testid":"confirm-workspace-git-badge",children:[e.jsx(me,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"truncate max-w-[90px]",children:t.current_branch??a("workspace.git.detached")})]}):null]}),t?.ok&&!t?.is_git_repository&&e.jsx("span",{className:"text-xs text-ter pl-1",children:a("workspace.git.none")})]}),e.jsxs("label",{className:"flex flex-col gap-2",children:[e.jsx(U,{children:a("workspace.field.name")}),e.jsx("input",{value:k,onChange:y=>p(y.target.value),placeholder:V(t?.path??"")||a("workspace.field.nameDefaultPlaceholder"),className:"input","data-testid":"confirm-workspace-name"})]}),e.jsx(he,{error:n??Q,onChange:o,presets:l,value:r}),e.jsxs("div",{className:"mt-2 rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>_(y=>!y),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-startup-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(J,{size:12,"aria-hidden":!0,className:"text-ter"}),a("workspace.advanced.startup")]}),N?e.jsx(W,{size:14,"aria-hidden":!0}):e.jsx(B,{size:14,"aria-hidden":!0})]}),N?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(U,{children:a("workspace.field.startup")}),e.jsx("input",{type:"text",value:E,onChange:y=>b(y.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-startup-command"}),e.jsx("span",{className:"text-[11px] text-ter normal-case tracking-normal leading-relaxed",children:a("workspace.startup.hint")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>C(y=>!y),className:"flex w-full items-center justify-between px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer","data-testid":"confirm-workspace-paste-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(J,{size:12,"aria-hidden":!0,className:"text-ter"}),a("workspace.advanced.pastePath")]}),w?e.jsx(W,{size:14,"aria-hidden":!0}):e.jsx(B,{size:14,"aria-hidden":!0})]}),w?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3.5 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx(U,{children:a("workspace.field.absolutePath")}),e.jsx("input",{type:"text",value:m,onChange:y=>x(y.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm","data-testid":"confirm-workspace-paste-path"})]}):null]}),e.jsxs("button",{type:"button",onClick:h,className:"flex items-center justify-between w-full rounded-lg border border-dashed px-3.5 py-2.5 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 hover:text-pri transition-all cursor-pointer",style:{borderColor:"var(--border)"},"data-testid":"confirm-workspace-browse-toggle",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Y,{size:12,"aria-hidden":!0,className:"text-ter"}),a("workspace.advanced.browse")]}),e.jsx(B,{size:14,"aria-hidden":!0})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:i,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:ee,disabled:!F,"data-testid":"confirm-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},L="hive://windows-drives",qe=({entries:t,error:s,loading:n,onNavigate:r,onSelect:l,selected:i})=>{const{t:o}=R();return e.jsx("div",{className:"scroll-y min-h-[200px] flex-1 border-t border-b",style:{borderColor:"var(--border)"},"data-testid":"fs-entry-list",children:n?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:o("common.loading")}):s?e.jsx("p",{className:"p-4 text-center text-xs",style:{color:"var(--status-red)"},"data-testid":"fs-browse-error",children:s}):t.length===0?e.jsx("p",{className:"p-4 text-center text-xs text-ter",children:o("workspace.browse.empty")}):e.jsx("ul",{children:t.map(u=>{const h=i===u.path;return e.jsxs("li",{className:"flex items-center gap-0",children:[e.jsxs("button",{type:"button","data-testid":`fs-entry-${u.name}`,onClick:()=>l(u.path),onDoubleClick:()=>r(u.path),className:"flex flex-1 items-center gap-2 px-3 py-2 text-left text-xs hover:bg-3",style:h?{background:"var(--bg-3)",color:"var(--text-primary)"}:{color:"var(--text-primary)"},children:[e.jsx("span",{"aria-hidden":!0,className:"inline-flex items-center text-sec",children:u.is_git_repository?e.jsx(me,{size:14}):e.jsx(Y,{size:14})}),e.jsx("span",{className:"mono flex-1 truncate",children:u.name}),u.is_git_repository?e.jsx("span",{className:"text-xs uppercase tracking-wider",style:{color:"var(--accent)"},children:o("workspace.browse.gitBadge")}):null]}),e.jsx("button",{type:"button","data-testid":`fs-entry-open-${u.name}`,onClick:()=>r(u.path),"aria-label":o("workspace.browse.openAria",{name:u.name}),className:"px-3 py-2 text-xs text-ter hover:text-pri",children:"→"})]},u.path)})})})},Ve=({probe:t,suggestedName:s,onSuggestedNameChange:n})=>{const{t:r}=R(),l=!!t&&t.ok&&t.is_dir;return e.jsxs("div",{className:"flex flex-col gap-2 rounded border p-3 text-xs",style:{background:"var(--bg-1)",borderColor:"var(--border)"},"data-testid":"fs-selection-preview",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-ter uppercase tracking-wider text-xs",children:r("workspace.browse.selected")}),t?.is_git_repository?e.jsx("span",{className:"role-badge role-badge--coder","data-testid":"fs-preview-git-badge",children:r("workspace.git.short",{branch:t.current_branch??r("workspace.git.detached")})}):l?e.jsx("span",{className:"text-ter text-xs",children:r("workspace.git.noneShort")}):null]}),e.jsx("span",{className:"mono truncate text-pri","data-testid":"fs-preview-path",children:t?.path??"—"}),e.jsxs("label",{className:"mt-1 flex flex-col gap-1 text-ter",children:[e.jsx("span",{className:"text-xs uppercase tracking-wider",children:r("workspace.field.name")}),e.jsx("input",{type:"text",value:s,onChange:i=>n(i.target.value),disabled:!l,autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,className:"mono rounded border px-2 py-1 text-sm text-pri disabled:opacity-50 max-md:text-base",style:{background:"var(--bg-0)",borderColor:"var(--border)"},"data-testid":"fs-preview-name-input"})]})]})},fe=t=>{const s=t.lastIndexOf("\\"),n=t.lastIndexOf("/");return s>=0&&s>n?"\\":n>=0?"/":/^[A-Za-z]:/u.test(t)?"\\":"/"},Ue=(t,s)=>{if(t===L)return s;const r=t.replace(/[\\/]+$/,"").split(/[\\/]/).filter(Boolean),l=r[r.length-1];return l?`~ (${l})`:t},T=t=>t.replace(/[\\/]+$/u,"")||t,le=t=>/^[A-Za-z]:($|[\\/])/u.test(t),ie=t=>/^\\\\[^\\/]+[\\/][^\\/]+/u.test(t),be=(t,s)=>le(t)&&le(s)||ie(t)&&ie(s),He=t=>{const s=/^(?:\\\\|\/\/)(?<server>[^\\/]+)[\\/](?<share>[^\\/]+)[\\/]*(?<rest>.*)$/u.exec(t);if(!s?.groups)return null;const{server:n,share:r,rest:l}=s.groups,i=`\\\\${n}\\${r}\\`;return{label:`\\\\${n}\\${r}`,rest:l,root:i}},Ze=(t,s)=>{const n=T(t),r=T(s);return be(n,r)?n.toLowerCase()===r.toLowerCase():n===r},Ge=(t,s)=>{const n=T(t),r=T(s);if(r==="/"||r==="\\")return n.startsWith(r);const l=be(n,r),i=l?n.toLowerCase():n,o=l?r.toLowerCase():r;if(i===o)return!0;if(!i.startsWith(o))return!1;const u=i[o.length];return u==="/"||u==="\\"},Ke=(t,s,n="This PC")=>{if(!s||!t)return[];const r=[{label:Ue(s,n),path:s}];if(Ze(t,s))return r;if(s===L){const a=He(t);if(a){r.push({label:a.label,path:a.root});const x=a.rest.split(/[\\/]/).filter(Boolean);let w=a.root.replace(/[\\/]+$/,"");for(const C of x)w=`${w}\\${C}`,r.push({label:C,path:w});return r}const g=/^(?<drive>[A-Za-z]:)[\\/]*(?<rest>.*)$/u.exec(t),d=g?.groups?.drive;if(!d)return r;const k=`${d}\\`;r.push({label:d,path:k});const p=(g.groups?.rest??"").split(/[\\/]/).filter(Boolean);let m=k.replace(/[\\/]+$/,"");for(const x of p)m=`${m}\\${x}`,r.push({label:x,path:m});return r}const l=T(s),i=Ge(t,l)?t.slice(l.length).replace(/^[\\/]+/,""):"";if(!i)return r;const o=fe(l),u=i.split(/[\\/]/).filter(Boolean);let h=l;for(const a of u)h=`${h}${o}${a}`,r.push({label:a,path:h});return r},de={current_path:"",entries:[],error:null,ok:!1,parent_path:null,root_path:""},Xe=t=>{const[s,n]=c.useState(de),[r,l]=c.useState(!1),[i,o]=c.useState(null),[u,h]=c.useState(null),a=c.useRef(0),g=c.useRef(0),d=c.useCallback(()=>{g.current++,o(null),h(null)},[]),k=c.useCallback(async m=>{const x=++a.current;l(!0);try{const w=await Ne(m);if(a.current!==x)return;n(w),w.ok?o(w.current_path):d()}catch{}finally{a.current===x&&l(!1)}},[d]);c.useEffect(()=>{if(!t){a.current++,n(de),d();return}k("")},[d,t,k]),c.useEffect(()=>{if(!i){h(null);return}const m=++g.current;Ce(i).then(x=>{g.current===m&&h(x)}).catch(x=>{console.debug("[hive] discarded:fsBrowser.probe (likely stale token)",x)})},[i]);const p=c.useCallback(m=>{o(m)},[]);return{browse:s,loading:r,navigate:k,probe:u,selectEntry:p,selected:i}},Ye=t=>(t.split(/[\\/]/).filter(Boolean).pop()??"").replace(/:$/u,""),ge=({commandPresetError:t,commandPresetId:s,commandPresets:n,onClose:r,onCommandPresetChange:l,onCreate:i,open:o,initialAdvanced:u=!1,manualHint:h})=>{const{t:a}=R(),g=_e(),{browse:d,loading:k,navigate:p,probe:m,selectEntry:x,selected:w}=Xe(o),[C,N]=c.useState(""),[_,E]=c.useState(u),[b,j]=c.useState(""),[f,P]=c.useState(!1),[S,A]=c.useState(""),z=xe(b),O=Ye(z);if(c.useEffect(()=>{o||(N(""),E(u),j(""),P(!1),A(""))},[o,u]),c.useEffect(()=>{m?.suggested_name&&N(m.suggested_name)},[m?.suggested_name]),c.useEffect(()=>{_&&z.length>0&&N(O)},[_,O,z]),!o)return null;const D=a("workspace.browse.drivesRoot"),Q=d.root_path===L?D:d.root_path,F=Ke(d.current_path,d.root_path,D),ee=d.root_path===L&&d.current_path!==L,y=fe(d.current_path||d.root_path),se=n.find(v=>v.id===s),q=S.trim(),ke=n.length===0&&!t,re=!s&&q.length===0,ae=se?.available===!1&&q.length===0,ve=re?a("workspace.preset.genericRequiresStartup"):ae?a("workspace.preset.notInstalled",{name:se.displayName}):null,we=C.trim().length>0&&(m?.is_dir===!0||_&&z.length>0)&&!ke&&!re&&!ae,je=()=>{const v=_&&z.length>0?z:m?.path??"";v&&i({commandPresetId:s||null,name:C.trim(),path:v,...q?{startupCommand:q}:{}})};return e.jsx(H,{open:!0,onOpenChange:v=>!v&&r(),children:e.jsxs(Z,{children:[e.jsx(G,{"data-testid":"server-browse-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center max-md:items-end max-md:p-0 p-4",children:e.jsxs(K,{"data-testid":"add-workspace-dialog","data-mobile":g||void 0,className:`${g?"dialog-slide-up":"dialog-scale-pop"} elev-2 pointer-events-auto flex w-[760px] max-w-[calc(100vw-32px)] flex-col rounded-lg border max-md:w-full max-md:max-w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{height:g?"85dvh":"min(600px, calc(100vh - 64px))",background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-3 border-b px-5 py-4",style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--accent) 12%, transparent)",color:"var(--accent)"},children:e.jsx(Y,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(X,{className:"text-lg font-semibold text-pri",children:a("workspace.browse.title")}),e.jsx(te,{className:"mono truncate text-xs text-ter","data-testid":"fs-root-path",children:d.root_path?a("workspace.browse.root",{path:Q}):a("workspace.browse.rootLoading")})]}),e.jsx(Pe,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":a("common.closeDialog"),className:"flex h-7 w-7 items-center justify-center rounded text-sec hover:bg-3 hover:text-pri",children:e.jsx(Se,{size:14,"aria-hidden":!0})})})]}),e.jsxs("nav",{className:"flex shrink-0 items-center gap-1 border-b px-4 py-2 text-xs",style:{borderColor:"var(--border)"},"aria-label":a("workspace.browse.breadcrumb"),"data-testid":"fs-breadcrumb",children:[e.jsxs("button",{type:"button",onClick:()=>d.parent_path?p(d.parent_path):null,disabled:!d.parent_path,"aria-label":a("workspace.browse.parentAria"),className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri disabled:opacity-40",children:[e.jsx(Me,{size:12,"aria-hidden":!0})," ",a("workspace.browse.up")]}),ee?e.jsxs("button",{type:"button",onClick:()=>p(L),"aria-label":a("workspace.browse.drivesAria"),"data-testid":"fs-browse-drives",className:"flex items-center gap-1 rounded px-2 py-0.5 text-sec hover:bg-3 hover:text-pri",children:[e.jsx(Fe,{size:12,"aria-hidden":!0})," ",D]}):null,e.jsx("div",{className:"mx-2 h-4 w-px",style:{background:"var(--border)"}}),F.map((v,ne)=>{const ye=ne===F.length-1;return e.jsxs("span",{className:"flex items-center gap-0.5",children:[ne>0?e.jsx("span",{className:"text-ter",children:y}):null,ye?e.jsx("span",{className:"px-1 py-0.5 font-medium text-pri",children:v.label}):e.jsx("button",{type:"button",onClick:()=>p(v.path),className:"rounded px-1 py-0.5 text-sec hover:bg-3 hover:text-pri",children:v.label})]},v.path)})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 max-md:flex-col",children:[e.jsx("div",{className:"flex min-h-0 flex-1 flex-col max-md:min-h-[40%]",children:e.jsx(qe,{entries:d.entries,error:d.ok?null:d.error,loading:k,onNavigate:p,onSelect:x,selected:w})}),e.jsxs("div",{className:"flex w-[280px] shrink-0 flex-col gap-3 border-l p-4 max-md:w-full max-md:border-l-0 max-md:border-t max-md:max-h-[45%] max-md:overflow-y-auto",style:{borderColor:"var(--border)"},children:[e.jsx(Ve,{onSuggestedNameChange:N,probe:m,suggestedName:C}),e.jsx(he,{error:t??ve,onChange:l,presets:n,value:s}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>P(v=>!v),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:12,"aria-hidden":!0,className:"text-ter"}),a("workspace.advanced.startup")]}),f?e.jsx(W,{size:14,"aria-hidden":!0}):e.jsx(B,{size:14,"aria-hidden":!0})]}),f?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:a("workspace.field.startup")}),e.jsx("input",{type:"text",value:S,onChange:v=>A(v.target.value),placeholder:a("workspace.field.startupPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"text","data-testid":"fs-startup-command"}),e.jsx("span",{className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:a("workspace.startup.hintShort")})]}):null]}),e.jsxs("div",{className:"rounded-lg border overflow-hidden transition-all",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsxs("button",{type:"button",onClick:()=>E(v=>!v),className:"flex w-full items-center justify-between px-3 py-2 text-left text-xs font-semibold uppercase tracking-wider text-sec hover:bg-3 transition-colors cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(J,{size:12,"aria-hidden":!0,className:"text-ter"}),a("workspace.advanced.pastePath")]}),_?e.jsx(W,{size:14,"aria-hidden":!0}):e.jsx(B,{size:14,"aria-hidden":!0})]}),_?e.jsxs("div",{className:"flex flex-col gap-2 border-t p-3 transition-all",style:{background:"var(--bg-2)",borderColor:"var(--border)"},children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-ter",children:a("workspace.field.absolutePath")}),h?e.jsx("span",{"data-testid":"fs-manual-hint",className:"text-xs normal-case tracking-normal text-ter leading-relaxed",children:h}):null,e.jsx("input",{type:"text",value:b,onChange:v=>j(v.target.value),placeholder:a("workspace.field.absolutePathPlaceholder"),className:"input mono text-sm max-md:text-base",autoCapitalize:"none",autoCorrect:"off",spellCheck:!1,inputMode:"url","data-testid":"fs-manual-path"})]}):null]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3",style:{borderColor:"var(--border)"},children:[e.jsx("button",{type:"button",onClick:r,className:"icon-btn",children:a("common.cancel")}),e.jsx("button",{type:"button",onClick:je,disabled:!we,"data-testid":"add-workspace-create",className:"icon-btn icon-btn--primary",children:a("workspace.confirm.create")})]})]})})]})})},$="claude",Je=t=>t.some(s=>s.id===$&&s.available)?$:t.find(s=>s.available)?.id??t[0]?.id??$,Qe=(t=typeof navigator>"u"?void 0:navigator)=>{if(!t)return!1;const s=[t.userAgentData?.platform,t.platform,t.userAgent].filter(n=>typeof n=="string"&&n.length>0).join(" ");return/\bWindows?\b|\bWin(?:32|64|CE)\b|Windows NT/i.test(s)},et=({trigger:t,onClose:s,onCreate:n})=>{const{t:r}=R(),l=c.useRef(r);c.useEffect(()=>{l.current=r},[r]);const[i,o]=c.useState({kind:"idle"}),[u,h]=c.useState([]),[a,g]=c.useState($),[d,k]=c.useState(null),p=c.useRef({error:null,id:$,presets:[]}),m=c.useRef(s);c.useEffect(()=>{m.current=s},[s]),c.useEffect(()=>{if(t===0)return;let b=!1;k(null);const j=ue().then(f=>{if(b)return;const P=f.some(S=>S.id===p.current.id&&S.available)?p.current.id:Je(f);p.current={error:null,id:P,presets:f},h(f),g(P)}).catch(()=>{if(b)return;const f=l.current("workspace.preset.loadFailed");p.current={error:f,id:$,presets:[]},h([]),g($),k(f)});return Qe()?(o({kind:"browse"}),()=>{b=!0}):(o({kind:"picking"}),Ee().then(async f=>{if(await j,!b){if(f.canceled){if(f.error){o({kind:"error",message:f.error});return}o({kind:"idle"}),m.current();return}if(!f.supported){o({kind:"confirm",probe:null,pasteDefault:!0});return}if(!f.probe?.ok||!f.probe.is_dir){o({kind:"error",message:f.error??l.current("workspace.error.outsideSandbox")});return}o({kind:"confirm",probe:f.probe,pasteDefault:!1})}}).catch(f=>{if(b)return;const P=f instanceof Error?f.message:l.current("workspace.error.pickerFailed");o({kind:"error",message:P})}),()=>{b=!0})},[t]);const x=()=>{o({kind:"idle"}),s()},w=b=>{Promise.resolve(n(b)).then(()=>o({kind:"idle"})).catch(j=>{const f=j instanceof Error?j.message:r("workspace.error.createFailed");o({kind:"error",title:r("workspace.error.createTitle"),message:f})})},C=b=>{p.current={...p.current,id:b},g(b)},N=u.length>0||d?u:p.current.presets,_=a===""?"":N.length>0&&!N.some(b=>b.id===a&&b.available)?p.current.id:a,E=d??p.current.error;if(i.kind==="idle")return null;if(i.kind==="picking"){const b=()=>o({kind:"idle"});return e.jsx(H,{open:!0,onOpenChange:j=>!j&&b(),children:e.jsxs(Z,{children:[e.jsx(G,{className:"app-overlay fixed inset-0 z-40"}),e.jsxs(K,{"data-testid":"add-workspace-picking","aria-describedby":void 0,className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx(X,{className:"sr-only",children:r("workspace.picking.title")}),e.jsxs("div",{"data-testid":"add-workspace-picking-panel",className:"dialog-scale-pop elev-2 flex items-center gap-3 rounded-lg border px-5 py-4",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(Le,{size:18,"aria-hidden":!0,className:"animate-pulse",style:{color:"var(--accent)"}}),e.jsx("span",{className:"text-sm text-pri",children:r("workspace.picking.message")})]})]})]})})}return i.kind==="error"?e.jsx(H,{open:!0,onOpenChange:b=>!b&&x(),children:e.jsxs(Z,{children:[e.jsx(G,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(K,{"data-testid":"add-workspace-error",className:"dialog-scale-pop elev-2 pointer-events-auto w-[440px] max-w-[calc(100vw-32px)] rounded-lg border p-5",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded",style:{background:"color-mix(in oklab, var(--status-red) 14%, transparent)",color:"var(--status-red)"},children:e.jsx(ze,{size:18,"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(X,{className:"text-lg font-semibold text-pri",children:i.title??r("workspace.error.pickerFailed")}),e.jsx(te,{className:"mt-1.5 break-words text-sm text-ter",children:i.message})]})]}),e.jsxs("div",{className:"mt-5 flex justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:x,className:"icon-btn",children:r("common.close")}),e.jsx("button",{type:"button",onClick:()=>o({kind:"confirm",probe:null,pasteDefault:!0}),className:"icon-btn icon-btn--primary",children:r("workspace.error.pastePathInstead")})]})]})})]})}):i.kind==="browse"?e.jsx(ge,{commandPresetError:E,commandPresetId:_,commandPresets:N,onClose:x,onCommandPresetChange:C,onCreate:w,open:!0}):e.jsx(Te,{commandPresetError:E,commandPresetId:_,commandPresets:N,pasteFallbackDefault:i.pasteDefault,probe:i.probe,onCancel:x,onCommandPresetChange:C,onCreate:w,onOpenServerBrowse:()=>o({kind:"browse"})})},M="claude",tt=t=>t.some(s=>s.id===M&&s.available)?M:t.find(s=>s.available)?.id??t[0]?.id??M,st=t=>{const{t:s}=R(),n=c.useRef(s);c.useEffect(()=>{n.current=s},[s]);const[r,l]=c.useState([]),[i,o]=c.useState(M),[u,h]=c.useState(null),a=c.useRef(M);return c.useEffect(()=>{if(!t)return;let d=!1;return h(null),ue().then(k=>{if(d)return;const m=k.some(x=>x.id===a.current&&x.available)?a.current:tt(k);a.current=m,l(k),o(m)}).catch(()=>{d||(a.current=M,l([]),o(M),h(n.current("workspace.preset.loadFailed")))}),()=>{d=!0}},[t]),{commandPresets:r,commandPresetId:i,commandPresetError:u,onCommandPresetChange:d=>{a.current=d,o(d)}}},rt=({trigger:t,onClose:s,onCreate:n})=>{const{t:r}=R(),[l,i]=c.useState(!1),o=c.useRef(0);c.useEffect(()=>{t>0&&t!==o.current&&i(!0)},[t]);const u=st(l),h=()=>{o.current=t,i(!1),s()},a=g=>{Promise.resolve(n(g)).then(()=>{o.current=t,i(!1)})};return l?e.jsx(ge,{open:!0,initialAdvanced:!0,manualHint:r("workspace.add.manualHint"),commandPresetError:u.commandPresetError,commandPresetId:u.commandPresetId,commandPresets:u.commandPresets,onClose:h,onCommandPresetChange:u.onCommandPresetChange,onCreate:a}):null},nt=({trigger:t,onClose:s,onCreate:n})=>{const{mode:r}=Re();return r==="mobile"?e.jsx(rt,{trigger:t,onClose:s,onCreate:n}):e.jsx(et,{trigger:t,onClose:s,onCreate:n})};export{nt as AddWorkspaceFlow};
@@ -1 +0,0 @@
1
- import{u as f,r as h,j as e,R as j,P as b,O as N,k as v,$ as g,m as c}from"./index-BV2k9Dts.js";const y=({open:o,onClose:r,onAddWorkspace:d,onTryDemo:x})=>{const{t:s}=f(),[l,n]=h.useState(0),m=t=>{t||(n(0),r())},i=(t=!0)=>{n(0),r(t)},a=l===2;return e.jsx(j,{open:o,onOpenChange:m,children:e.jsxs(b,{children:[e.jsx(N,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(v,{"aria-label":s("firstRun.title"),className:"dialog-scale-pop elev-2 pointer-events-auto w-[480px] max-w-[calc(100vw-32px)] rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsx(g,{className:"sr-only",children:s("firstRun.step",{current:l+1,total:3})}),e.jsxs("div",{className:"min-h-[200px]",children:[l===0&&e.jsxs("div",{className:"flex flex-col items-center gap-4 py-4 text-center",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-14 w-14 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx("img",{alt:"",className:"h-10 w-10 object-contain","data-testid":"first-run-logo",draggable:!1,src:"/logo.png"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-xl font-semibold text-pri",children:s("firstRun.title")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.desc")}),e.jsx("p",{className:"text-xs text-ter",children:s("firstRun.subtitle")})]})]}),l>0&&e.jsx(c,{className:"sr-only",children:s("firstRun.title")}),l===1&&e.jsxs("div",{className:"flex flex-col gap-4 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.howItWorks")}),e.jsx("ol",{className:"flex flex-col gap-3",children:[{n:1,title:s("firstRun.slide1Title"),desc:s("firstRun.slide1Desc")},{n:2,title:s("firstRun.slide2Title"),desc:s("firstRun.slide2Desc")},{n:3,title:s("firstRun.slide3Title"),desc:s("firstRun.slide3Desc")}].map(({n:t,title:u,desc:p})=>e.jsxs("li",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-xs font-medium",style:{background:"var(--bg-elevated)",border:"1px solid var(--border-bright)",color:"var(--accent)"},children:t}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-pri",children:u}),e.jsx("div",{className:"text-xs text-sec",children:p})]})]},t))})]}),l===2&&e.jsxs("div",{className:"flex flex-col gap-3 py-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-pri",children:s("firstRun.getStarted")}),e.jsx("p",{className:"text-sm text-sec",children:s("firstRun.optionDesc")}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{d(),i(!1)},className:"icon-btn icon-btn--primary w-full justify-center",children:s("firstRun.addWorkspace")}),e.jsx("button",{type:"button",onClick:()=>{x(),i(!0)},className:"icon-btn w-full justify-center",children:s("firstRun.tryDemo")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-sec underline hover:text-pri mt-1",children:s("firstRun.skipForNow")})]})]})]}),e.jsxs("div",{className:"mt-5 flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-ter",children:s("firstRun.step",{current:l+1,total:3})}),e.jsxs("div",{className:"flex items-center gap-2",children:[l>0&&!a&&e.jsx("button",{type:"button",onClick:()=>n(t=>t-1),className:"icon-btn",children:s("firstRun.back")}),!a&&e.jsx("button",{type:"button",onClick:()=>n(t=>t+1),className:"icon-btn icon-btn--primary",children:s("firstRun.next")}),e.jsx("button",{type:"button",onClick:()=>i(),className:"text-xs text-ter underline hover:text-sec",children:s("firstRun.skip")})]})]})]})})]})})};export{y as FirstRunWizard};
@@ -1 +0,0 @@
1
- import{c as E,j as e,u as L,a4 as le,a6 as re,i as ie,R as oe,P as ce,O as de,k as ue,r as f,a7 as pe,a8 as he,T as S,X as xe,E as me,C as Q,b as W,a9 as F,d as ke,aa as fe,x as ge,y as be,ab as je,t as ye}from"./index-BV2k9Dts.js";const we=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],I=E("at-sign",we);const ve=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ne=E("circle",ve);const _e=[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],U=E("corner-down-right",_e);const Te=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Ce=E("file-code",Te);const $e=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ee=E("file-text",$e);const ze=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Se=E("save",ze),H=t=>{const n=[];let l="",a=0;const c=()=>{l&&(n.push(l),l="")};let r=0;for(;r<t.length;){const i=t.slice(r),o=i.match(/^\*\*([^*]+?)\*\*/);if(o?.[1]){c(),n.push(e.jsx("strong",{children:H(o[1])},a++)),r+=o[0].length;continue}const s=i.match(/^`([^`]+?)`/);if(s?.[1]){c(),n.push(e.jsx("code",{className:"mono",children:s[1]},a++)),r+=s[0].length;continue}const u=i.match(/^\*([^*]+?)\*/);if(u?.[1]){c(),n.push(e.jsx("em",{children:H(u[1])},a++)),r+=u[0].length;continue}l+=t[r],r+=1}return c(),n},Ee=({content:t,hasConflict:n,onContentChange:l,onKeepLocal:a,onReload:c,onSave:r})=>{const{t:i}=L(),o=s=>{s.preventDefault(),r()};return e.jsxs("form",{onSubmit:o,className:"flex h-full flex-col gap-3",children:[e.jsxs("label",{className:"flex min-h-0 flex-1 flex-col gap-2 text-xs text-sec",children:[e.jsxs("span",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"font-medium text-sec",children:i("tasks.raw.label")}),e.jsx("span",{className:"mono text-xs text-ter",children:i("tasks.raw.lineCount",{count:t.split(/\r?\n/).length})})]}),e.jsx("textarea",{"aria-label":i("tasks.raw.label"),value:t,onChange:s=>l(s.target.value),className:"mono min-h-[360px] flex-1 resize-none rounded border p-3 text-sm text-pri outline-none focus:border-[var(--accent)]",style:{background:"var(--bg-0)",borderColor:"var(--border)"}})]}),n?e.jsxs("div",{className:"flex items-start gap-2 rounded border p-3 text-xs",style:{borderColor:"var(--status-orange)",color:"var(--status-orange)"},children:[e.jsx(le,{className:"mt-0.5 shrink-0",size:16}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-medium",children:i("tasks.raw.conflictTitle")}),e.jsx("p",{className:"mt-1 text-ter",children:i("tasks.raw.conflictDescription")})]}),e.jsxs("div",{className:"flex shrink-0 gap-2",children:[e.jsxs("button",{type:"button",onClick:c,className:"icon-btn",children:[e.jsx(re,{size:14}),i("tasks.raw.reload")]}),e.jsx("button",{type:"button",onClick:a,className:"icon-btn",children:i("tasks.raw.keepLocal")})]})]}):null,e.jsx("div",{className:"flex justify-end border-t pt-3",style:{borderColor:"var(--border)"},children:e.jsxs("button",{type:"submit",className:"icon-btn icon-btn--primary",children:[e.jsx(Se,{size:14}),i("tasks.raw.save")]})})]})},O=["#a78bfa","#60a5fa","#5eead4","#86efac","#fde047","#fb923c","#f9a8d4","#fca5a5"],te=t=>{let n=0;for(let l=0;l<t.length;l+=1)n=n*31+t.charCodeAt(l)>>>0;return O[n%O.length]??O[0]},Me=[{pattern:/^(done|completed?|finished?|ok|success|完成|已完成|搞定)$/i,tone:"green"},{pattern:/^(working|running|in[-_ ]?progress|dispatching|dispatched|进行中|派单中?|执行中|处理中)$/i,tone:"orange"},{pattern:/^(blocked|failed|error|errored|阻塞|失败|出错)$/i,tone:"red"},{pattern:/^(queued|waiting|pending|todo|open|idle|待办|等待中?|队列中|未开始)$/i,tone:"neutral"}],q=new Set(["owner","assignee","负责","负责人","执行人"]),G=new Set(["status","状态"]),X=new Set(["报告","report","文件","file","path","日志","log","产物"]),De=/^(.*?)\s*\(([^()]+)\)\s*$/,Re=/\s*[·,,;;]\s*/,Le=/^([^::]+)[::]\s*(.+)$/,Ae=t=>{for(const{pattern:n,tone:l}of Me)if(n.test(t))return l;return"neutral"},Pe=t=>t.includes("/")||/^[A-Za-z]:\\/.test(t)||(t.match(/\\/g)?.length??0)>=2?!0:/^[A-Za-z0-9._-]+\.[A-Za-z0-9]+$/.test(t),Ie=t=>{const n=t.match(De);if(!n)return{title:t,meta:[]};const[,l="",a=""]=n;if(!a.trim())return{title:t,meta:[]};const c=a.split(Re).filter(Boolean),r=[];for(const i of c){const o=i.match(Le);if(!o){r.push({kind:"note",value:i.trim()});continue}const s=(o[1]??"").trim(),u=(o[2]??"").trim(),d=s.toLowerCase();q.has(d)||q.has(s)?r.push({kind:"owner",value:u}):G.has(d)||G.has(s)?r.push({kind:"status",value:u,tone:Ae(u)}):X.has(d)||X.has(s)||Pe(u)?r.push({kind:"path",label:s,value:u}):r.push({kind:"note",value:`${s}: ${u}`})}return{title:l.trim(),meta:r}},Y=3,Ke=({item:t,handlers:n})=>{if(t.kind==="status")return e.jsx("span",{className:`pill pill--${t.tone}`,"data-testid":"task-meta-status",children:t.value});if(t.kind==="owner"){const a={"--owner-tone":te(t.value)};return n.onSelectOwner?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":"task-meta-owner","data-owner":t.value,onClick:c=>{c.stopPropagation(),n.onSelectOwner?.(t.value)},style:a,children:[e.jsx(I,{size:10,"aria-hidden":!0}),t.value]}):e.jsxs("span",{className:"task-owner","data-testid":"task-meta-owner","data-owner":t.value,style:a,children:[e.jsx(I,{size:10,"aria-hidden":!0}),t.value]})}return t.kind==="path"?e.jsxs("span",{className:"pill pill--neutral mono inline-flex items-center gap-1","data-testid":"task-meta-path",title:`${t.label}: ${t.value}`,children:[e.jsx(ee,{size:10,"aria-hidden":!0}),t.value]}):e.jsx("span",{className:"text-xs text-ter","data-testid":"task-meta-note",children:t.value})},Z=({initial:t,onSubmit:n,onCancel:l,placeholder:a})=>{const[c,r]=f.useState(t),i=()=>{const s=c.trim();if(!s){l();return}n(s)},o=s=>{s.key==="Enter"?(s.preventDefault(),i()):s.key==="Escape"&&(s.preventDefault(),l())};return e.jsx("input",{type:"text",autoFocus:!0,value:c,placeholder:a,onChange:s=>r(s.target.value),onKeyDown:o,onBlur:i,"data-testid":"task-inline-input",className:"task-row__input"})},V=({task:t,handlers:n,depth:l})=>{const{t:a}=L(),c=t.checked?ke:Ne,{title:r,meta:i}=Ie(t.text),[o,s]=f.useState(!1),[u,d]=f.useState(!1),[g,M]=f.useState(!1),[y,v]=f.useState(!1),m=f.useRef(null);f.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const{onToggle:p,onUpdateText:w,onDelete:_,onAppendSubtask:D,onCopyLine:T,onSelectOwner:k,writeDisabled:b=!1}=n,C=!!w&&!b,N=!!_&&!b,A=!!D&&!b,$=!!T,R=!o&&!u&&(C||N||A||$),z=t.children.length,x=fe(t),P=l+1>=Y,K=z>0,se=g?a("tasks.aria.expandSubtasks",{count:z}):a("tasks.aria.collapseSubtasks",{count:z}),ae=k?{onSelectOwner:k}:{};return e.jsxs("li",{className:"task-node","data-testid":`task-line-${t.line}`,children:[e.jsxs("div",{className:"task-row group",children:[l>=Y?e.jsx("span",{"aria-hidden":!0,className:"task-row__deep-marker",children:"▸"}):null,e.jsxs("label",{className:"task-row__checkbox-cell",children:[e.jsx("input",{type:"checkbox",checked:t.checked,disabled:b,onChange:()=>{b||p(t.line)},className:"sr-only","data-testid":`task-checkbox-${t.line}`,"aria-label":t.text||`task-line-${t.line}`}),e.jsx("span",{className:`task-row__indicator ${t.checked?"task-status-done":"task-status-open"}`,"aria-hidden":!0,children:e.jsx(c,{size:14})})]}),e.jsx("span",{className:"min-w-0 flex-1",children:o?e.jsx(Z,{initial:t.text,placeholder:a("tasks.placeholder.editTask"),onSubmit:h=>{s(!1),w?.(t.line,h)},onCancel:()=>s(!1)}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("span",{className:`task-row__title min-w-0 flex-1 ${t.checked?"text-ter line-through":"text-pri"}`,children:H(r)}),K?e.jsx("button",{type:"button",className:"task-row__collapse",onClick:h=>{h.stopPropagation(),M(j=>!j)},"data-testid":`task-collapse-${t.line}`,"aria-expanded":!g,"aria-label":se,children:g?e.jsx(W,{size:12,"aria-hidden":!0}):e.jsx(Q,{size:12,"aria-hidden":!0})}):null,x?e.jsxs("span",{className:"task-child-count mono","data-testid":`task-progress-${t.line}`,title:a("tasks.progress.subtaskTitle",{done:x.done,total:x.total}),children:[x.done,"/",x.total]}):null]}),i.length>0||t.mentions.length>0?e.jsxs("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:[i.map(h=>e.jsx(Ke,{item:h,handlers:ae},`${t.line}-meta-${h.kind}-${"label"in h?h.label:""}-${h.value}`)),t.mentions.map(h=>{const j=h.replace(/^@/,""),B={"--owner-tone":te(j)};return k?e.jsxs("button",{type:"button",className:"task-owner task-owner--clickable","data-testid":`task-mention-${j}`,"data-owner":j,onClick:ne=>{ne.stopPropagation(),k(j)},style:B,children:[e.jsx(I,{size:10,"aria-hidden":!0}),j]},`${t.line}-mention-${h}`):e.jsxs("span",{className:"task-owner","data-testid":`task-mention-${j}`,"data-owner":j,style:B,children:[e.jsx(I,{size:10,"aria-hidden":!0}),j]},`${t.line}-mention-${h}`)})]}):null]})}),R?e.jsxs("div",{className:"task-row__actions pointer-coarse:opacity-100",children:[$?e.jsx(S,{label:a(y?"tasks.action.copied":"tasks.action.copyLine"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{T?.(t.line),v(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{v(!1),m.current=null},1500)},"data-testid":`task-copy-${t.line}`,"aria-label":a(y?"tasks.aria.copiedTaskLine":"tasks.aria.copyTaskLine"),children:y?e.jsx(ge,{size:12}):e.jsx(be,{size:12})})}):null,C?e.jsx(S,{label:a("tasks.action.edit"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>s(!0),"data-testid":`task-edit-${t.line}`,"aria-label":a("tasks.aria.editTask"),children:e.jsx(je,{size:12})})}):null,A?e.jsx(S,{label:a("tasks.action.addSubtask"),children:e.jsx("button",{type:"button",className:"task-row__action pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>{M(!1),d(!0)},"data-testid":`task-add-subtask-${t.line}`,"aria-label":a("tasks.aria.addSubtask"),children:e.jsx(U,{size:12})})}):null,N?e.jsx(S,{label:a("tasks.action.delete"),children:e.jsx("button",{type:"button",className:"task-row__action task-row__action--danger pointer-coarse:h-10 pointer-coarse:w-10",onClick:()=>_?.(t.line),"data-testid":`task-delete-${t.line}`,"aria-label":a("tasks.aria.deleteTask"),children:e.jsx(ye,{size:12})})}):null]}):null]}),z>0&&!g||u?e.jsxs("ul",{className:`task-children${P?" task-children--deep":""}`,"data-testid":`task-children-${t.line}`,children:[g?null:t.children.map(h=>e.jsx(V,{depth:l+1,handlers:n,task:h},h.line)),u?e.jsx("li",{className:"task-node",children:e.jsxs("div",{className:"task-row task-row--child-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-row__indicator task-status-open",children:e.jsx(U,{size:12})}),e.jsx(Z,{initial:"",placeholder:a("tasks.placeholder.newSubtask"),onSubmit:h=>{d(!1),D?.(t.line,h)},onCancel:()=>d(!1)})]})}):null]}):null]})},J=({onSubmit:t,disabled:n=!1,variant:l="ghost"})=>{const{t:a}=L(),[c,r]=f.useState(!1),[i,o]=f.useState(""),s=()=>{const d=i.trim();if(!d){r(!1);return}t(d),o("")},u=d=>{d.key==="Enter"?(d.preventDefault(),s()):d.key==="Escape"&&(d.preventDefault(),o(""),r(!1))};return c?e.jsxs("div",{className:"task-add-input",children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-input__icon",children:e.jsx(F,{size:12})}),e.jsx("input",{type:"text",autoFocus:!0,value:i,placeholder:a("tasks.placeholder.newTask"),onChange:d=>o(d.target.value),onKeyDown:u,onBlur:s,"data-testid":"task-add-input",className:"task-add-input__field"})]}):e.jsxs("button",{type:"button",onClick:()=>r(!0),disabled:n,"data-testid":"task-add-toggle",className:`task-add-toggle${l==="primary"?" task-add-toggle--primary":""}`,children:[e.jsx("span",{"aria-hidden":!0,className:"task-add-toggle__icon",children:e.jsx(F,{size:12})}),e.jsx("span",{children:a("tasks.button.addTask")})]})},Oe=t=>{let n=0,l=0;const a=[],c=[],r=o=>{n+=1,o.checked&&(l+=1);for(const s of o.children)r(s)};for(const o of t)o.checked?c.push(o):a.push(o),r(o);const i=n===0?0:Math.round(l/n*100);return{completedTasks:l,completionPercent:i,doneRoots:c,openRoots:a,totalTasks:n}},He=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,workspacePath:M,knownWorkerNames:y,onSelectOwner:v,connectionStale:m=!1})=>{const{t:p}=L(),[w,_]=f.useState(!1),T={onToggle:o,onCopyLine:x=>{const P=t.split(/\r?\n/)[x];typeof P=="string"&&navigator.clipboard?.writeText(P).catch(K=>{console.error("[hive] swallowed:tasks.copyLine",K)})},...d&&!m?{onUpdateText:d}:{},...g&&!m?{onDelete:g}:{},...u&&!m?{onAppendSubtask:u}:{},...v?{onSelectOwner:v}:{},...m?{writeDisabled:!0}:{}},k=f.useMemo(()=>pe(t,y?{knownWorkerNames:y}:{}),[t,y]),{completedTasks:b,completionPercent:C,doneRoots:N,openRoots:A,totalTasks:$}=f.useMemo(()=>Oe(k),[k]),[R,z]=f.useState(N.length<=3);return e.jsxs("div",{className:"flex h-full min-h-0 flex-col","data-testid":"task-graph-content",children:[e.jsxs("header",{className:"task-drawer__header",children:[e.jsx("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md",style:{background:"color-mix(in oklab, var(--accent) 14%, transparent)",color:"var(--accent)"},children:e.jsx(he,{size:16,"aria-hidden":!0})}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5",children:[e.jsx("span",{className:"text-[13px] font-semibold text-pri leading-tight",children:p("tasks.title.todo")}),$>0?e.jsx("span",{className:"rounded-full px-1.5 py-0.5 text-[10px] font-medium tabular-nums",style:{background:C===100?"color-mix(in oklab, var(--status-green) 18%, transparent)":"var(--bg-3)",color:C===100?"var(--status-green)":"var(--text-secondary)"},"data-testid":"task-graph-summary",children:e.jsxs("span",{"data-testid":"task-progress-text",children:[b,"/",$]})}):null]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(S,{label:p(w?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx("button",{type:"button",onClick:()=>_(x=>!x),"data-testid":"task-raw-toggle",className:"icon-btn pointer-coarse:min-h-10","aria-label":p(w?"tasks.action.backToList":"tasks.action.viewSource"),children:e.jsx(Ce,{size:14})})}),l?e.jsx(S,{label:p("tasks.action.closeTodo"),children:e.jsx("button",{type:"button",onClick:l,"aria-label":p("tasks.action.closeTodo"),className:"icon-btn pointer-coarse:min-h-10",children:e.jsx(xe,{size:14})})}):null]})]}),!w&&$>0?e.jsx("div",{"aria-label":p("tasks.aria.progress"),"aria-valuemax":100,"aria-valuemin":0,"aria-valuenow":C,className:"task-progress-thin task-drawer__progress","data-testid":"task-progress-bar",role:"progressbar",children:e.jsx("span",{style:{width:`${C}%`}})}):null,e.jsx("div",{className:"scroll-y flex-1 px-3 py-2.5 text-sm",children:w?e.jsx(Ee,{content:t,hasConflict:n,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i}):k.length===0?e.jsx("div",{className:"flex h-full items-center justify-center",children:e.jsx(me,{icon:e.jsx(ee,{size:20}),title:p("tasks.empty.title"),description:p("tasks.empty.description"),...s?{action:e.jsx(J,{variant:"primary",disabled:m,onSubmit:s})}:{}})}):e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("ul",{className:"task-list","data-testid":"task-graph-list",children:[A.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line)),s?e.jsx("li",{children:e.jsx(J,{disabled:m,onSubmit:s})}):null]}),N.length>0?e.jsxs("div",{className:"mt-2",children:[e.jsxs("button",{type:"button",onClick:()=>z(x=>!x),"aria-expanded":R,"data-testid":"task-completed-toggle",className:"task-completed-toggle pointer-coarse:min-h-10",children:[R?e.jsx(Q,{size:11,"aria-hidden":!0}):e.jsx(W,{size:11,"aria-hidden":!0}),e.jsx("span",{children:p("tasks.completed.toggle",{count:N.length})}),e.jsx("span",{className:"ml-auto rounded-full px-1.5 py-0.5 text-[9px] tabular-nums",style:{background:"var(--bg-3)",color:"var(--text-tertiary)"},children:N.length})]}),R?e.jsx("ul",{className:"task-list mt-1","data-testid":"task-completed-list",children:N.map(x=>e.jsx(V,{depth:0,handlers:T,task:x},x.line))}):null]}):null]})})]})},Be=({content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,onAppendTask:s,onAppendSubtask:u,onUpdateTaskText:d,onDeleteTask:g,open:M,workspacePath:y,knownWorkerNames:v,onSelectOwner:m,connectionStale:p=!1})=>{const{t:w}=L(),_=ie(),D=k=>{if(k.key!=="Escape")return;const b=k.target?.tagName;b==="INPUT"||b==="TEXTAREA"||(k.preventDefault(),l())},T=`dialog-scale-pop elev-2 task-dialog__content pointer-events-auto flex flex-col rounded-lg border${p?" task-dialog--stale":""}`;return e.jsx(oe,{open:M,onOpenChange:k=>!k&&l(),children:e.jsxs(ce,{children:[e.jsx(de,{"data-testid":"task-graph-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsx(ue,{"aria-label":w("tasks.aria.drawer"),"data-testid":"task-graph-drawer","data-connection-stale":p||void 0,"data-mobile":_||void 0,onEscapeKeyDown:k=>k.preventDefault(),onKeyDown:D,className:T,style:_?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 64px))",width:"min(640px, calc(100vw - 48px))"},children:e.jsx(He,{content:t,hasConflict:n,onClose:l,onContentChange:a,onKeepLocal:c,onReload:r,onSave:i,onToggleTaskLine:o,workspacePath:y,...s?{onAppendTask:s}:{},...u?{onAppendSubtask:u}:{},...d?{onUpdateTaskText:d}:{},...g?{onDeleteTask:g}:{},...v?{knownWorkerNames:v}:{},...m?{onSelectOwner:m}:{},...p?{connectionStale:p}:{}})})})]})})};export{He as TaskGraphContent,Be as TaskGraphDrawer};
@@ -1 +0,0 @@
1
- import{u as x,j as e,R as d,P as m,O as p,k as h,H as j,m as v,$ as f}from"./index-BV2k9Dts.js";const N=({open:n,entries:r,onClose:t})=>{const{t:a,language:i}=x(),c=s=>{s||t()};return e.jsx(d,{open:n,onOpenChange:c,children:e.jsxs(m,{children:[e.jsx(p,{className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(h,{"aria-label":a("whatsNew.title"),className:"dialog-scale-pop elev-2 pointer-events-auto flex max-h-[calc(100vh-64px)] w-[480px] max-w-[calc(100vw-32px)] flex-col rounded-lg border p-6",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{"aria-hidden":!0,className:"flex h-10 w-10 items-center justify-center rounded-lg",style:{background:"color-mix(in oklab, var(--accent) 15%, transparent)",color:"var(--accent)",border:"1px solid color-mix(in oklab, var(--accent) 30%, transparent)"},children:e.jsx(j,{size:20})}),e.jsxs("div",{children:[e.jsx(v,{className:"text-lg font-semibold text-pri",children:a("whatsNew.title")}),e.jsx(f,{className:"text-xs text-ter",children:a("whatsNew.subtitle")})]})]}),e.jsx("div",{className:"-mr-2 mt-4 flex flex-col gap-5 overflow-y-auto pr-2",children:r.map(s=>{const o=i==="zh"?s.zh:s.en;return e.jsxs("section",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-pri",children:a("whatsNew.versionLabel",{version:s.version})}),e.jsx("span",{className:"text-xs text-ter",children:s.date})]}),e.jsx("ul",{className:"flex flex-col gap-1.5",children:o.map(l=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-sec",children:[e.jsx("span",{"aria-hidden":!0,className:"mt-1.5 h-1 w-1 shrink-0 rounded-full bg-accent"}),e.jsx("span",{children:l})]},l))})]},s.version)})}),e.jsx("div",{className:"mt-5 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"icon-btn icon-btn--primary justify-center",children:a("whatsNew.gotIt")})})]})})]})})};export{N as WhatsNewDialog};
@@ -1 +0,0 @@
1
- import{r as d,u as j,i as k,af as f,j as e,R,P as N,O as M,k as C,m as E,$ as S,a4 as L,T as D,z as I,X as O,ag as W,q as A,ah as T,ai as P}from"./index-BV2k9Dts.js";const _=t=>{switch(t){case"coder":return{badgeClass:"role-badge--coder",label:"Coder"};case"tester":return{badgeClass:"role-badge--tester",label:"Tester"};case"reviewer":return{badgeClass:"role-badge--reviewer",label:"Reviewer"};case"custom":return{badgeClass:"role-badge--custom",label:"Custom"};default:return{badgeClass:"role-badge--custom",label:String(t)}}},y="hive.worker-modal.width",u=480,$=.5,x=t=>{const n=typeof window<"u"?window.innerWidth-24:1200;return Math.min(Math.max(t,u),Math.max(u,n))},g=()=>typeof window>"u"?u:x(Math.round(window.innerWidth*$)),F=()=>{try{const t=localStorage.getItem(y);if(!t)return g();const n=Number.parseInt(t,10);return Number.isFinite(n)?x(n):g()}catch{return g()}},K=()=>{const[t,n]=d.useState(()=>F()),[m,c]=d.useState(!1);d.useEffect(()=>{try{localStorage.setItem(y,String(Math.round(t)))}catch{}},[t]),d.useEffect(()=>{const a=()=>{n(r=>x(r))};return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]);const h=d.useCallback(a=>r=>{r.preventDefault();const s=r.clientX,p=t;c(!0);const b=document.body.style.cursor,v=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";const o=i=>{const w=i.clientX-s,z=a==="left"?p-2*w:p+2*w;n(x(z))},l=()=>{c(!1),document.body.style.cursor=b,document.body.style.userSelect=v,document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",l),document.removeEventListener("pointercancel",l)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",l),document.addEventListener("pointercancel",l)},[t]);return{width:t,resizing:m,beginResize:h}},U=({onClose:t,onStart:n,runId:m,startError:c,starting:h,worker:a})=>{const{t:r}=j(),s=k(),p=_(a.role),b=!!m,v=T(b),o=K();d.useLayoutEffect(()=>{if(!s)return;const i=P();return f(!0),()=>f(i)},[s]);const l=i=>{i||t()};return e.jsx(R,{open:!0,onOpenChange:l,children:e.jsxs(N,{children:[e.jsx(M,{"data-testid":"worker-modal-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center",children:e.jsxs(C,{"data-testid":"worker-modal","aria-label":r("worker.detail",{name:a.name}),className:"dialog-scale-pop pointer-events-auto relative flex h-screen max-h-screen max-w-full flex-col overflow-hidden","data-mobile":s||void 0,onEscapeKeyDown:i=>i.preventDefault(),style:s?{background:"var(--bg-1)"}:{background:"var(--bg-1)",width:`${o.width}px`},children:[s?null:e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--left",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("left")}),e.jsx("div",{role:"separator","aria-orientation":"vertical","aria-label":r("worker.widthResize"),"aria-valuemin":u,"aria-valuenow":Math.round(o.width),className:"modal-resize-handle modal-resize-handle--right",tabIndex:-1,"data-resizing":o.resizing||void 0,onPointerDown:o.beginResize("right")})]}),e.jsx(E,{className:"sr-only",children:a.name}),e.jsxs(S,{className:"sr-only",children:[p.label," agent — status ",v.label]}),c?e.jsxs("div",{role:"alert",className:"flex shrink-0 items-center gap-2 border-b px-4 py-2 text-xs",style:{background:"color-mix(in oklab, var(--status-red) 10%, transparent)",borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--status-red)"},children:[e.jsx(L,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"break-words",children:c})]}):null,e.jsxs("div",{className:`relative flex min-h-0 flex-1 flex-col${s?"":" p-3"}`,"data-testid":"worker-modal-terminal-slot",children:[e.jsx(D,{label:r("common.close"),children:e.jsx(I,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":"Close worker detail","data-testid":"worker-modal-close",className:`float-action absolute z-10 ${s?"top-2 right-2":"top-4 right-4"}`,style:s?{minHeight:44,minWidth:44}:void 0,children:e.jsx(O,{size:s?16:14,"aria-hidden":!0})})})}),e.jsx("div",{className:`flex min-h-0 flex-1${s?"":" rounded-lg border"}`,style:{background:"var(--bg-crust)",borderColor:"var(--border)"},children:b?e.jsx("div",{id:`worker-pty-${m}`,className:"flex h-full w-full","data-pty-slot":"worker"}):e.jsxs("div",{className:"m-auto flex max-w-[400px] flex-col items-center gap-3 px-6 text-center",children:[e.jsx(W,{commandPresetId:a.commandPresetId,workerRole:a.role,size:48}),e.jsx("div",{className:"text-sm text-pri",children:a.name}),e.jsxs("div",{className:"text-xs text-ter",children:[a.status==="stopped"?r("worker.terminalStopped"):r("worker.terminalNotStarted"),r("worker.startAgent")]}),e.jsxs("button",{type:"button",onClick:()=>n(a),disabled:h,className:"icon-btn icon-btn--primary","data-testid":"worker-start-empty",children:[e.jsx(A,{size:12,"aria-hidden":!0})," ",r(h?"common.starting":"common.start")]})]})})]})]})})]})})};export{U as WorkerModal};
@@ -1 +0,0 @@
1
- import{c as b,i as te,u as W,r as c,D as ae,F as re,G as ne,j as e,R as ie,P as le,O as oe,k as ce,m as de,T as g,X as me,L as k,H as V,E as H,J as K,K as pe,N as xe,Q as he,U as ue,V as Q,Y as be}from"./index-BV2k9Dts.js";import{S as fe}from"./search-Bk2HQvO7.js";const ye=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],ge=b("archive",ye);const je=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],ve=b("eye-off",je);const Ne=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],we=b("eye",Ne);const ke=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89",key:"znwnzq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11",key:"c9qhm2"}]],Se=b("pin-off",ke);const Ce=[["path",{d:"M12 17v5",key:"bb1du9"}],["path",{d:"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z",key:"1nkz8b"}]],$e=b("pin",Ce);const Me=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Te=b("settings-2",Me),G={decision:"memory.kind.decision",fact:"memory.kind.fact",pitfall:"memory.kind.pitfall",preference:"memory.kind.preference",procedure_ref:"memory.kind.procedure_ref"},_e=new Intl.DateTimeFormat(void 0,{day:"2-digit",hour:"2-digit",minute:"2-digit",month:"short"}),S=(r,s)=>r?_e.format(new Date(r)):s("common.never"),I=(r,s=140)=>{const a=r.trim();return a.length<=s?a:`${a.slice(0,s-1)}…`},Ee=r=>{const s=r.sources[0];return s?.actorNameSnapshot?`${r.source} · ${s.actorNameSnapshot}`:r.source},ze=r=>r==="dreams"?null:r,De=({busy:r,memory:s,onArchive:a,onToggleDisabled:p,onTogglePinned:n})=>{const[i,d]=c.useState(!1),{t:o}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`memory-row-${s.id}`,"data-pinned":s.pinned,"data-disabled":s.disabled,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>d(m=>!m),"aria-expanded":i,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${s.kind}`,children:o(G[s.kind])}),s.pinned?e.jsx("span",{className:"font-medium text-accent",children:o("memory.pinned")}):null,s.disabled?e.jsx("span",{className:"text-ter",children:o("memory.disabled")}):null,e.jsx("span",{className:"text-ter",children:Ee(s)})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:i?s.body:I(s.body)}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-1 text-[11px] text-ter",children:[s.tags.map(m=>e.jsx("span",{className:"rounded border px-1.5 py-0.5",style:{borderColor:"var(--border)"},children:m},m)),e.jsx("span",{children:o("memory.updated",{time:S(s.updatedAt,o)})}),e.jsx("span",{children:o("memory.injected",{time:S(s.lastInjectedAt,o)})})]})]}),e.jsx("div",{className:"flex shrink-0 items-center gap-1 drawer-card__actions",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(g,{label:s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>n(s),"aria-label":s.pinned?o("memory.unpinTooltip"):o("memory.pinTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.pinned?e.jsx(Se,{size:13}):e.jsx($e,{size:13})})}),e.jsx(g,{label:s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>p(s),"aria-label":s.disabled?o("memory.enableTooltip"):o("memory.disableTooltip"),className:"icon-btn pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:s.disabled?e.jsx(we,{size:13}):e.jsx(ve,{size:13})})}),e.jsx(g,{label:o("memory.archiveButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>a(s),"aria-label":o("memory.archiveButton"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:e.jsx(ge,{size:13})})})]}):null})]}),i?e.jsxs("div",{className:"drawer-card__expanded",children:[e.jsx("h4",{className:"drawer-section-label",children:o("memory.sources")}),s.sources.length===0?e.jsx("p",{className:"text-ter",children:o("memory.noSources")}):e.jsx("ul",{className:"space-y-2",children:s.sources.map(m=>e.jsxs("li",{className:"break-words",children:[e.jsxs("div",{className:"text-ter",children:[m.sourceType,m.actorNameSnapshot?` · ${m.actorNameSnapshot}`:"",m.actorRoleSnapshot?` · ${m.actorRoleSnapshot}`:""]}),m.excerpt?e.jsx("p",{className:"mt-0.5",children:m.excerpt}):null]},m.id))})]}):null]})},U=({label:r,checked:s,disabled:a,onChange:p})=>e.jsxs("label",{className:"drawer-settings-row",children:[e.jsx("span",{className:"text-sec",children:r}),e.jsx("input",{type:"checkbox",checked:s,disabled:a,onChange:n=>p(n.currentTarget.checked),className:"h-4 w-4 accent-[var(--accent)]"})]}),Re=(r,s)=>r.report?[`${r.report.added.length} ${s("memory.reportAdded")}`,`${r.report.rewritten.length} ${s("memory.reportRewritten")}`,`${r.report.archived.length} ${s("memory.reportArchived")}`,`${r.report.merged.length} ${s("memory.reportMerged")}`].join(" · "):r.error?`${s("common.error")} · ${I(r.error,90)}`:s("memory.noReport"),Ae=(r,s)=>r.inputSeqFrom===null||r.inputSeqTo===null?s("memory.noInput"):`${s("memory.seq")} ${r.inputSeqFrom}-${r.inputSeqTo}`,Pe=({busy:r,onRevert:s,run:a})=>{const[p,n]=c.useState(!1),{t:i}=W();return e.jsxs("li",{className:"drawer-card p-3","data-testid":`dream-run-${a.id}`,"data-dream-status":a.status,children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>n(d=>!d),"aria-expanded":p,className:"min-w-0 flex-1 text-left focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-[var(--accent)]",children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-2 text-[11px]",children:[e.jsx("span",{className:`drawer-status-badge drawer-status-badge--${a.status}`,children:i(`memory.status.${a.status}`)}),e.jsx("span",{className:"text-ter",children:i(`memory.trigger.${a.trigger}`)}),e.jsx("span",{className:"text-ter",children:Ae(a,i)}),e.jsx("span",{className:"text-ter",children:i("memory.started",{time:S(a.startedAt,i)})})]}),e.jsx("p",{className:"break-words text-sm text-pri leading-snug",children:Re(a,i)}),a.finishedAt?e.jsx("p",{className:"mt-1 text-[11px] text-ter",children:i("memory.finished",{time:S(a.finishedAt,i)})}):null]}),a.status==="completed"?e.jsx("div",{className:"drawer-card__actions",children:e.jsx(g,{label:i("memory.revertButton"),children:e.jsx("button",{type:"button",disabled:r,onClick:()=>s(a),"aria-label":i("memory.revertTooltip"),className:"icon-btn icon-btn--danger pointer-coarse:min-h-10 pointer-coarse:min-w-10",children:r?e.jsx(k,{size:13,className:"animate-spin"}):e.jsx(he,{size:13})})})}):null]}),p&&a.report?e.jsxs("div",{className:"drawer-card__expanded space-y-3",children:[a.report.added.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-green",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-added flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-green"}),i("memory.diff.added")]}),e.jsx("ul",{className:"space-y-1.5 mt-1.5",children:a.report.added.map(d=>e.jsxs("li",{className:"break-words text-[11px] text-pri flex items-start gap-1",children:[e.jsx("span",{className:"text-status-green select-none font-semibold mr-1",children:"+"}),e.jsxs("span",{className:"flex-1",children:[e.jsx("span",{className:`drawer-kind-badge drawer-kind-badge--${d.kind} scale-90 origin-left inline-block mr-1`,children:i(G[d.kind])}),d.body]})]},d.id))})]}):null,a.report.rewritten.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-[#f59e0b]",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-rewritten flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#f59e0b]"}),i("memory.diff.rewritten")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.rewritten.map(d=>d.id).join(", ")})]}):null,a.report.archived.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-status-red",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-archived flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-red"}),i("memory.diff.archived")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.archived.map(d=>d.id).join(", ")})]}):null,a.report.merged.length>0?e.jsxs("div",{className:"dream-diff-block border-l-2 border-l-purple-500",children:[e.jsxs("h4",{className:"dream-diff-title dream-diff-merged flex items-center gap-1.5 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-500"}),i("memory.diff.merged")]}),e.jsx("p",{className:"mt-1.5 text-[11px] text-sec leading-relaxed pl-3 break-all",children:a.report.merged.map(d=>d.into).join(", ")})]}):null]}):null,p&&a.error?e.jsx("p",{className:"drawer-card__error",children:a.error}):null]})},Le=({open:r,onClose:s,workspaceId:a})=>{const p=te(),{t:n}=W(),[i,d]=c.useState("active"),[o,m]=c.useState(""),[j,C]=c.useState([]),[v,$]=c.useState([]),[M,N]=c.useState(null),[q,T]=c.useState(!1),[L,x]=c.useState(null),[J,B]=c.useState(null),[_,w]=c.useState(null),[E,z]=c.useState(null),[D,R]=c.useState(null),[A,F]=c.useState(!1),f=c.useRef(0),X=c.useMemo(()=>[{id:"active",label:n("memory.tabActive")},{id:"archived",label:n("memory.tabArchived")},{id:"dreams",label:n("memory.tabDreams")}],[n]),u=ze(i),y=c.useCallback(async()=>{const t=f.current+1;if(f.current=t,!a||!r){C([]),$([]),N(null),T(!1);return}T(!0),x(null),C([]),$([]),N(null);try{const[l,h,se]=await Promise.all([ae(a),u?re(a,{query:o,status:u}):Promise.resolve([]),u?Promise.resolve([]):ne(a,{limit:20})]);if(f.current!==t)return;N(l),C(h),$(se)}catch(l){f.current===t&&x(l instanceof Error?l.message:String(l))}finally{f.current===t&&T(!1)}},[r,o,u,a]);c.useEffect(()=>{y()},[y]);const P=async(t,l)=>{if(a){B(t.id),x(null);try{await l(a),await y()}catch(h){x(h instanceof Error?h.message:String(h))}finally{B(null)}}},Y=c.useMemo(()=>({current:u?j.length:v.length}),[v.length,j.length,u]),O=async t=>{if(!(!a||A)){F(!0),x(null);try{N(await xe(a,t))}catch(l){x(l instanceof Error?l.message:String(l))}finally{F(!1)}}},Z=async()=>{if(a){w("run-now"),x(null);try{await pe(a),await y()}catch(t){x(t instanceof Error?t.message:String(t))}finally{w(null)}}},ee=async t=>{if(a){w(t.id),x(null);try{await ue(a,t.id),await y()}catch(l){x(l instanceof Error?l.message:String(l))}finally{w(null)}}};return e.jsxs(e.Fragment,{children:[e.jsx(ie,{open:r,onOpenChange:t=>!t&&s(),children:e.jsxs(le,{children:[e.jsx(oe,{"data-testid":"memory-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4",children:e.jsxs(ce,{"data-testid":"memory-drawer","aria-label":n("memory.title"),"data-mobile":p||void 0,className:"dialog-scale-pop elev-2 pointer-events-auto flex flex-col rounded-lg border",style:p?{background:"var(--bg-1)",borderColor:"var(--border-bright)"}:{background:"var(--bg-1)",borderColor:"var(--border-bright)",height:"min(720px, calc(100vh - 48px))",width:"min(780px, calc(100vw - 48px))"},children:[e.jsxs("header",{className:"flex items-center justify-between border-b px-4 py-2",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx(de,{className:"text-base font-semibold text-pri",children:n("memory.title")}),e.jsx("p",{className:"text-xs text-ter",children:n("memory.subtitle")})]}),e.jsx(g,{label:n("common.close"),children:e.jsx("button",{type:"button",onClick:s,"aria-label":n("common.close"),className:"icon-btn pointer-coarse:min-h-11 pointer-coarse:min-w-11",children:e.jsx(me,{size:14})})})]}),e.jsxs("div",{className:`flex gap-2 border-b px-4 py-2 ${p?"flex-col items-stretch":"items-center gap-2"}`,style:{borderColor:"var(--border)"},children:[e.jsx("div",{className:"drawer-tabs",style:p?{width:"100%",justifyContent:"flex-start"}:void 0,children:X.map(t=>e.jsx("button",{type:"button",onClick:()=>d(t.id),"aria-pressed":i===t.id,className:`drawer-tab pointer-coarse:min-h-10 ${i===t.id?"drawer-tab--active":""}`,children:t.label},t.id))}),u?e.jsxs("label",{className:"drawer-search",style:p?{width:"100%",maxWidth:"none"}:{marginLeft:"auto"},children:[e.jsx("span",{className:"sr-only",children:n("memory.searchPlaceholder")}),e.jsx(fe,{size:14,className:"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-ter"}),e.jsx("input",{value:o,onChange:t=>m(t.currentTarget.value),placeholder:n("memory.searchPlaceholder"),name:"memory-search",autoComplete:"off",className:"h-8 w-full rounded-md border bg-transparent pl-8 pr-3 text-xs text-pri outline-none transition-colors placeholder:text-ter focus-visible:border-[var(--accent)]",style:{borderColor:"var(--border-bright)"}})]}):null]}),e.jsxs("div",{className:"scroll-y min-h-0 flex-1 px-4 py-3",children:[L?e.jsx("div",{className:"mb-3 rounded-md border px-3 py-2 text-xs",style:{borderColor:"color-mix(in oklab, var(--status-red) 30%, var(--border))",color:"var(--text-error)",background:"color-mix(in oklab, var(--status-red) 8%, transparent)"},children:L}):null,e.jsxs("section",{className:"drawer-section",children:[e.jsxs("div",{className:"drawer-section__header",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Te,{size:14,className:"text-sec"}),e.jsxs("span",{className:"font-medium text-sec",children:[Y.current," ",n(u?"memory.entries":"memory.runs")]})]}),i==="dreams"?e.jsxs("button",{type:"button",onClick:Z,disabled:_!==null,className:"drawer-action-btn pointer-coarse:min-h-10",children:[_==="run-now"?e.jsx(k,{size:14,className:"animate-spin"}):e.jsx(V,{size:14}),n("memory.runNow")]}):null]}),M?e.jsxs("div",{className:"mt-2 grid gap-2 sm:grid-cols-2",children:[e.jsx(U,{label:n("memory.injection"),checked:M.enabled,disabled:A,onChange:t=>O({enabled:t})}),e.jsx(U,{label:n("memory.dreamProcessing"),checked:M.dreamEnabled,disabled:A,onChange:t=>O({dreamEnabled:t})})]}):null]}),i==="dreams"?q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):v.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{icon:e.jsx(V,{size:20}),title:n("memory.emptyDreams"),description:n("memory.emptyDreamsDesc")})}):e.jsx("ul",{className:"space-y-2",children:v.map(t=>e.jsx(Pe,{run:t,busy:_===t.id,onRevert:R},t.id))}):q?e.jsxs("div",{className:"flex h-[320px] items-center justify-center text-ter",children:[e.jsx(k,{size:18,className:"animate-spin"}),e.jsx("span",{className:"ml-2 text-sm",children:n("common.loading")})]}):j.length===0?e.jsx("div",{className:"flex h-[320px] items-center justify-center",children:e.jsx(H,{title:n("memory.emptyActive"),description:n("memory.emptyActiveDesc")})}):e.jsx("ul",{className:"space-y-2",children:j.map(t=>e.jsx(De,{memory:t,busy:J===t.id,onArchive:z,onToggleDisabled:l=>P(l,h=>Q(h,l.id,{disabled:!l.disabled})),onTogglePinned:l=>P(l,h=>Q(h,l.id,{pinned:!l.pinned}))},t.id))})]})]})})]})}),e.jsx(K,{open:E!==null,onOpenChange:t=>{t||z(null)},title:n("memory.archiveTitle"),description:n("memory.archiveDesc"),confirmLabel:n("memory.archiveButton"),confirmKind:"danger",onConfirm:()=>{if(!E)return;const t=E;z(null),P(t,l=>be(l,t.id))}}),e.jsx(K,{open:D!==null,onOpenChange:t=>{t||R(null)},title:n("memory.revertTitle"),description:n("memory.revertDesc"),confirmLabel:n("memory.revertButton"),confirmKind:"danger",onConfirm:()=>{if(!D)return;const t=D;R(null),ee(t)}})]})};export{Le as WorkspaceMemoryDrawer};