@markus-global/cli 0.12.2 → 0.12.3-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +15 -12
- package/dist/commands/start.js.map +1 -1
- package/dist/markus.mjs +2602 -2594
- package/dist/web-ui/assets/{AsyncState-C4a4KQ04.js → AsyncState-Co9o9Bjm.js} +1 -1
- package/dist/web-ui/assets/ChatComponents-CuWlVFJz.js +12 -0
- package/dist/web-ui/assets/{ContentRenderer-CkTLvnEu.js → ContentRenderer-B9gsL4I6.js} +6 -6
- package/dist/web-ui/assets/DeliverableShareModal-BUdo2qSE.js +1 -0
- package/dist/web-ui/assets/Deliverables-CDBY53C5.js +3 -0
- package/dist/web-ui/assets/MarkdownMessage-C3gog80t.js +4 -0
- package/dist/web-ui/assets/Search-DClPgzaq.js +1 -0
- package/dist/web-ui/assets/SendToChat-A26aOPb3.js +1 -0
- package/dist/web-ui/assets/Settings-BZ8jYVDO.js +8 -0
- package/dist/web-ui/assets/Store-Djm15pAq.js +1 -0
- package/dist/web-ui/assets/{Switch-CZAYoGju.js → Switch-BsePV-zC.js} +1 -1
- package/dist/web-ui/assets/Team-BhwiXwfp.js +85 -0
- package/dist/web-ui/assets/Work-C0v0dHzp.js +142 -0
- package/dist/web-ui/assets/{arc-C7xiSR_L.js → arc-DLLbWPzU.js} +1 -1
- package/dist/web-ui/assets/architectureDiagram-3BPJPVTR-DHB20fXN.js +36 -0
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-Bl9V85eo.js → blockDiagram-GPEHLZMM-hGFNjiSE.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-BgyqGUI_.js → c4Diagram-AAUBKEIU-CpsBleVs.js} +1 -1
- package/dist/web-ui/assets/channel-ehfg-vdK.js +1 -0
- package/dist/web-ui/assets/chatChips-DVIRVTpT.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-2znVHbo8.js → chunk-2J33WTMH-txB49n9B.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BGXPYXO3.js → chunk-4BX2VUAB-ceih3NkH.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-B4GQDwv-.js → chunk-55IACEB6-Bim3xVp2.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-D9WRILj0.js → chunk-727SXJPM-CrMJuX-q.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-DQb0__Jh.js → chunk-AQP2D5EJ-Dx-Cmb2E.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-lEuLc0aj.js → chunk-FMBD7UC4-CQr40Nnm.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Dd5SDfdJ.js → chunk-ND2GUHAM-BwcD6_Y7.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-Ds8u_1wB.js → chunk-QZHKN3VN-Byaq12B1.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-D7qJkeZM.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-D7qJkeZM.js +1 -0
- package/dist/web-ui/assets/cose-bilkent-S5V4N54A-CLXxIaDa.js +1 -0
- package/dist/web-ui/assets/{dagre-BM42HDAG-D1B-Tulw.js → dagre-BM42HDAG-DdXf9urh.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-DITdhssl.js → diagram-2AECGRRQ-smJ2CryU.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-CEQxFHzH.js → diagram-5GNKFQAL-D9J88vfp.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DxCnKGbb.js → diagram-KO2AKTUF-DFW95y1-.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-BOYuGZIr.js → diagram-LMA3HP47-B8RJaXa8.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-BNJgh7s8.js → diagram-OG6HWLK6-CRDK8ZKU.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-CrUr10-f.js → docx-preview-DOe2cigo.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-BuCa252h.js → erDiagram-TEJ5UH35-7cnIAhD9.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-CVvFCkDE.js → flowDiagram-I6XJVG4X-Cdc7tjsm.js} +1 -1
- package/dist/web-ui/assets/ganttDiagram-6RSMTGT7-BVMk6ZGl.js +292 -0
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DkQpA-Z8.js → gitGraphDiagram-PVQCEYII-Bu7IjszT.js} +1 -1
- package/dist/web-ui/assets/index-BY_HjdWI.js +867 -0
- package/dist/web-ui/assets/index-CnyolIne.css +1 -0
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-C_rWcDW7.js → infoDiagram-5YYISTIA-B1PiHzF5.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-C0KnGaRN.js → ishikawaDiagram-YF4QCWOH-Bkz8bgJH.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CuC-5aLM.js → journeyDiagram-JHISSGLW-DnxZwAvG.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-DU1_VSXa.js → kanban-definition-UN3LZRKU-CfmP8vuE.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-Bc0iYQ8k.js → mermaid.core-CVQWE7ug.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BVU3rzyG.js → mindmap-definition-RKZ34NQL-CwURI_4d.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-B7Lis7Cn.js → pieDiagram-4H26LBE5-DhtzkQBJ.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-DFFsDwCW.js → quadrantDiagram-W4KKPZXB-DyCAqF3Q.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-DFMxzahh.js → requirementDiagram-4Y6WPE33-DXlQ98TY.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-CQFj5LUY.js → sankeyDiagram-5OEKKPKP-Cymt2A_C.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DN_1Aiqe.js → sequenceDiagram-3UESZ5HK-UcPHNPcv.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-DmePUv3C.js → stateDiagram-AJRCARHV-4YyVx5n7.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-D-aZF8vI.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-Cm8EYLTZ.js → timeline-definition-PNZ67QCA-B9XFBLaA.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-BhoN_mu0.js → vennDiagram-CIIHVFJN-Cn1fCIU1.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DiYqNtfo.js → wardley-L42UT6IY-CZB5Iwi7.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Bd8vpNb4.js → wardleyDiagram-YWT4CUSO-NHaRrC9h.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-CHboDSbi.js → xychartDiagram-2RQKCTM6-415yqDyz.js} +1 -1
- package/dist/web-ui/index.html +2 -2
- package/docs/design/agent-stop-intent-audit.md +185 -0
- package/docs/design/overview-attention-redesign.md +233 -0
- package/package.json +1 -1
- package/dist/web-ui/assets/CommentInput-jN8Pjpy4.js +0 -1
- package/dist/web-ui/assets/DeliverableShareModal-BjrQLmcX.js +0 -1
- package/dist/web-ui/assets/Deliverables-Cipn4z3F.js +0 -3
- package/dist/web-ui/assets/Notifications-DBYrWqIL.js +0 -1
- package/dist/web-ui/assets/Search-poQncU26.js +0 -1
- package/dist/web-ui/assets/SendToChat-Xk5zlNy3.js +0 -1
- package/dist/web-ui/assets/Settings-DlhRiM77.js +0 -8
- package/dist/web-ui/assets/Store-Dp0MGa-t.js +0 -1
- package/dist/web-ui/assets/Team-D5wmT4Mj.js +0 -84
- package/dist/web-ui/assets/Work-B8VUHTW7.js +0 -142
- package/dist/web-ui/assets/architectureDiagram-3BPJPVTR-BCM1UC9H.js +0 -36
- package/dist/web-ui/assets/channel-xHjc9vd-.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-XGbYdlgY.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-XGbYdlgY.js +0 -1
- package/dist/web-ui/assets/cose-bilkent-S5V4N54A-DZTfdLi_.js +0 -1
- package/dist/web-ui/assets/ganttDiagram-6RSMTGT7-DmTrMDic.js +0 -292
- package/dist/web-ui/assets/index-BEhLix2_.css +0 -1
- package/dist/web-ui/assets/index-CIrsLoqm.js +0 -883
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CFaxbhDx.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as c,j as e}from"./index-
|
|
1
|
+
import{u as c,j as e}from"./index-BY_HjdWI.js";function a(...t){return t.filter(Boolean).join(" ")}function d({className:t}){return e.jsxs("svg",{className:a("animate-spin shrink-0",t??"w-3.5 h-3.5"),viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2.5",opacity:"0.2"}),e.jsx("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function u({label:t,className:r}){const{t:n}=c("common");return e.jsxs("div",{className:a("flex-1 flex flex-col items-center justify-center gap-2.5 py-10 text-fg-tertiary",r),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-5 h-5 text-brand-400"}),e.jsx("span",{className:"text-xs",children:t??n("loading")})]})}function p({rows:t=3,label:r,variant:n="skeleton",className:s}){const{t:i}=c("common");return n==="text"?e.jsxs("div",{className:a("flex items-center gap-2 px-1 py-2 text-xs text-fg-tertiary",s),role:"status","aria-live":"polite",children:[e.jsx(d,{className:"w-3 h-3"}),e.jsx("span",{children:r??i("loading")})]}):e.jsx("div",{className:a("space-y-2.5 p-1",s),role:"status","aria-live":"polite","aria-label":r??i("loading"),children:Array.from({length:t}).map((o,l)=>e.jsxs("div",{className:"animate-pulse space-y-1.5",children:[e.jsx("div",{className:"h-3.5 bg-surface-elevated rounded w-2/3"}),e.jsx("div",{className:"h-2.5 bg-surface-elevated/70 rounded w-1/3"})]},l))})}function f({icon:t,title:r,hint:n,action:s,size:i="md",className:o}){const l=i==="sm"?"py-6":i==="lg"?"py-16":"py-10",x=i==="sm"?"text-xs":"text-sm";return e.jsxs("div",{className:a("flex flex-col items-center justify-center text-center px-4",l,o),children:[t&&e.jsx("div",{className:"mb-2.5 text-fg-muted",children:t}),e.jsx("div",{className:a("font-medium text-fg-secondary",x),children:r}),n&&e.jsx("div",{className:"mt-1 text-xs text-fg-tertiary max-w-xs leading-relaxed",children:n}),s&&e.jsx("button",{onClick:s.onClick,className:a("mt-3 px-3 py-1.5 rounded-md text-xs font-medium transition-colors",s.variant==="secondary"?"border border-border-default text-fg-secondary hover:bg-surface-elevated":"bg-brand-600 hover:bg-brand-500 text-on-brand"),children:s.label})]})}export{f as E,p as L,u as P,d as S};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{u as E,r as x,j as t,a2 as J,a3 as he,k as P,U as qe,a4 as re,n as Oe,P as Be,l as ee,A as Pe}from"./index-BY_HjdWI.js";import{MarkdownMessage as O}from"./MarkdownMessage-C3gog80t.js";import{n as at}from"./chatChips-DVIRVTpT.js";const pe=6e4,Ue=60*pe,ot=24*Ue;function un(e,n){const s=new Date(e).getTime();if(!Number.isFinite(s))return"";const r=Date.now()-s;if(r<pe)return n("common:time.now");const a=Math.floor(r/pe);if(a<60)return n("common:time.minutesAgo",{count:a});const o=Math.floor(r/Ue);return o<24?n("common:time.hoursAgo",{count:o}):n("common:time.daysAgo",{count:Math.floor(r/ot)})}function pn(e,n){if(!e)return"";const s=new Date(e);if(Number.isNaN(s.getTime()))return"";try{return new Intl.DateTimeFormat(n||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(s)}catch{return s.toLocaleString()}}const me={suppressAdjustUntil:0};function Y(e=2500){const n=typeof performance<"u"?performance.now():Date.now();me.suppressAdjustUntil=Math.max(me.suppressAdjustUntil,n+e)}function mn(){return(typeof performance<"u"?performance.now():Date.now())<me.suppressAdjustUntil}const je={shell_execute:{label:"Running command",icon:"⌨"},list_terminals:{label:"Listing terminals",icon:"⌨"},new_terminal:{label:"Opening terminal",icon:"⌨"},select_terminal:{label:"Selecting terminal",icon:"⌨"},close_terminal:{label:"Closing terminal",icon:"⌨"},read_terminal:{label:"Reading terminal",icon:"⌨"},write_terminal:{label:"Writing terminal",icon:"⌨"},exec_terminal:{label:"Running in terminal",icon:"⌨"},file_read:{label:"Reading file",icon:"📄"},file_write:{label:"Writing file",icon:"✏"},file_edit:{label:"Editing file",icon:"✏"},apply_patch:{label:"Applying patch",icon:"🔀"},list_directory:{label:"Listing directory",icon:"📂"},glob_find:{label:"Finding files",icon:"🔍"},grep_search:{label:"Searching code",icon:"🔍"},web_fetch:{label:"Fetching page",icon:"🌐"},web_search:{label:"Searching web",icon:"🔍"},web_extract:{label:"Extracting content",icon:"📑"},create_task:{label:"Creating task",icon:"📌"},task_create:{label:"Creating task",icon:"📌"},create_subtask:{label:"Adding subtask",icon:"📌"},update_task:{label:"Updating task",icon:"✅"},task_update:{label:"Updating task",icon:"✅"},add_task_note:{label:"Adding note",icon:"📝"},task_add_note:{label:"Adding note",icon:"📝"},task_list:{label:"Listing tasks",icon:"📋"},task_get:{label:"Getting task",icon:"📋"},task_note:{label:"Adding note",icon:"📝"},task_assign:{label:"Assigning task",icon:"👥"},task_submit_review:{label:"Submitting for review",icon:"✅"},task_comment:{label:"Commenting task",icon:"💬"},subtask_create:{label:"Adding subtask",icon:"📌"},subtask_complete:{label:"Completing subtask",icon:"✅"},subtask_cancel:{label:"Cancelling subtask",icon:"🚫"},subtask_list:{label:"Listing subtasks",icon:"📋"},requirement_propose:{label:"Proposing requirement",icon:"📋"},requirement_list:{label:"Listing requirements",icon:"📋"},requirement_get:{label:"Getting requirement",icon:"📋"},requirement_update:{label:"Updating requirement",icon:"📋"},requirement_update_status:{label:"Updating req status",icon:"✅"},requirement_resubmit:{label:"Resubmitting requirement",icon:"📋"},requirement_comment:{label:"Commenting requirement",icon:"💬"},list_projects:{label:"Listing projects",icon:"🗂"},get_project:{label:"Getting project",icon:"🗂"},create_project:{label:"Creating project",icon:"🗂"},update_project:{label:"Updating project",icon:"🗂"},deliverable_create:{label:"Creating deliverable",icon:"📦"},deliverable_search:{label:"Searching deliverables",icon:"🔍"},deliverable_list:{label:"Listing deliverables",icon:"📦"},deliverable_update:{label:"Updating deliverable",icon:"📦"},agent_ask_agent:{label:"Asking another agent",icon:"💬"},git_status:{label:"Git status",icon:"🔀"},git_diff:{label:"Git diff",icon:"🔀"},git_log:{label:"Git log",icon:"📜"},git_branch:{label:"Git branch",icon:"🌿"},git_add:{label:"Git add",icon:"➕"},git_commit:{label:"Git commit",icon:"💾"},project_structure:{label:"Project structure",icon:"🗂"},code_stats:{label:"Code stats",icon:"📊"},navigate_page:{label:"Opening page",icon:"🌐"},new_page:{label:"Opening new tab",icon:"🌐"},close_page:{label:"Closing tab",icon:"🌐"},select_page:{label:"Switching tab",icon:"🌐"},list_pages:{label:"Listing tabs",icon:"🌐"},click:{label:"Clicking element",icon:"👆"},hover:{label:"Hovering element",icon:"👆"},fill:{label:"Filling field",icon:"⌨"},fill_form:{label:"Filling form",icon:"⌨"},type_text:{label:"Typing text",icon:"⌨"},press_key:{label:"Pressing key",icon:"⌨"},take_screenshot:{label:"Screenshot",icon:"📸"},take_snapshot:{label:"Page snapshot",icon:"📋"},evaluate_script:{label:"Running script",icon:"⚙"},wait_for:{label:"Waiting",icon:"⏳"},list_console_messages:{label:"Console logs",icon:"🔍"},list_network_requests:{label:"Network requests",icon:"🔍"},lighthouse_audit:{label:"Running audit",icon:"📊"},agent_send_message:{label:"Messaging colleague",icon:"💬"},agent_list_colleagues:{label:"Checking team",icon:"👥"},memory_save:{label:"Saving memory",icon:"💾"},memory_search:{label:"Searching memory",icon:"🔍"},memory_list:{label:"Listing memory",icon:"💾"},memory_update:{label:"Updating memory",icon:"💾"},recall_activity:{label:"Recalling activity",icon:"📜"},notebook_upsert:{label:"Updating notebook",icon:"📝"},kb_search:{label:"Searching knowledge base",icon:"📚"},kb_list:{label:"Listing knowledge base",icon:"📚"},kb_read:{label:"Reading knowledge base",icon:"📚"},notify_user:{label:"Notifying user",icon:"🔔"},request_user_input:{label:"Requesting input",icon:"❓"},request_user_approval:{label:"Requesting approval",icon:"❓"},schedule_wakeup:{label:"Scheduling wakeup",icon:"⏰"},cancel_wakeup:{label:"Cancelling wakeup",icon:"⏰"},set_heartbeat_interval:{label:"Setting heartbeat",icon:"⏱"},discover_tools:{label:"Discovering tools",icon:"🧰"},check_mailbox:{label:"Checking mailbox",icon:"📥"},goal_create:{label:"Creating goal",icon:"🎯"},goal_update:{label:"Updating goal",icon:"🎯"},goal_status:{label:"Goal status",icon:"🎯"},background_exec:{label:"Background command",icon:"⌨"},process:{label:"Managing process",icon:"⚙"},feishu_send_message:{label:"Sending Feishu msg",icon:"✉"},feishu_search_docs:{label:"Searching Feishu",icon:"🔍"},spawn_subagent:{label:"Spawn Subagent",icon:"◎"},spawn_subagents:{label:"Spawn Subagents",icon:"◎"},invoke_coding_tool:{label:"Invoke Coding Tool",icon:"🛠"},coding_tool_apply:{label:"Apply Coding Result",icon:"🔀"},generate_image:{label:"Generating image",icon:"🖼"},text_to_speech:{label:"Generating speech",icon:"🔊"},speech_to_text:{label:"Transcribing audio",icon:"🎙"},generate_video:{label:"Generating video",icon:"🎬"},llm_list_providers:{label:"Listing providers",icon:"⚙"},llm_switch_model:{label:"Switching model",icon:"⚙"},llm_switch_default_provider:{label:"Switching provider",icon:"⚙"},llm_add_provider:{label:"Adding provider",icon:"⚙"},llm_edit_provider:{label:"Editing provider",icon:"⚙"},llm_add_model:{label:"Adding model",icon:"⚙"},llm_get_capability_routing:{label:"Checking capability routing",icon:"⚙"},llm_set_capability_routing:{label:"Setting capability routing",icon:"⚙"},team_list:{label:"Listing teams",icon:"👥"},team_status:{label:"Team status",icon:"👥"},team_start:{label:"Starting team",icon:"👥"},team_stop:{label:"Stopping team",icon:"👥"},team_update:{label:"Updating team",icon:"👥"},agent_start:{label:"Starting agent",icon:"◎"},agent_stop:{label:"Stopping agent",icon:"◎"},agent_update:{label:"Updating agent",icon:"◎"},agent_delegate_task:{label:"Delegating task",icon:"📌"},agent_broadcast_status:{label:"Broadcasting status",icon:"📣"},agent_create_group_chat:{label:"Creating group chat",icon:"💬"},agent_list_group_chats:{label:"Listing group chats",icon:"💬"},agent_send_group_message:{label:"Sending group message",icon:"💬"},delete_project:{label:"Deleting project",icon:"🗂"},project_stats:{label:"Project stats",icon:"📊"},hub_search:{label:"Searching Hub",icon:"🔍"},hub_install:{label:"Installing from Hub",icon:"📦"},package_list:{label:"Listing packages",icon:"📦"},package_install:{label:"Installing package",icon:"📦"},memory_delete:{label:"Deleting memory",icon:"💾"},memory_update_longterm:{label:"Updating long-term memory",icon:"💾"},notebook_clear:{label:"Clearing notebook",icon:"📝"},notebook_read:{label:"Reading notebook",icon:"📝"},recall_context:{label:"Recalling context",icon:"📜"},defer_mailbox_item:{label:"Deferring mailbox item",icon:"📥"},drop_mailbox_item:{label:"Dropping mailbox item",icon:"📥"},prioritize_mailbox_item:{label:"Prioritizing mailbox",icon:"📥"},delegate_message:{label:"Delegating message",icon:"💬"},task_board_health:{label:"Checking task board",icon:"📋"},task_check_duplicates:{label:"Checking duplicates",icon:"📋"},task_cleanup_duplicates:{label:"Cleaning duplicates",icon:"📋"},workflow_list:{label:"Listing workflows",icon:"🔄"},workflow_create:{label:"Creating workflow",icon:"🔄"},workflow_update:{label:"Updating workflow",icon:"🔄"},workflow_delete:{label:"Deleting workflow",icon:"🔄"},workflow_run:{label:"Running workflow",icon:"🔄"},workflow_status:{label:"Workflow status",icon:"🔄"},workflow_cancel:{label:"Cancelling workflow",icon:"🔄"},open_page:{label:"Opening page",icon:"🌐"},resize_page:{label:"Resizing page",icon:"🌐"},drag:{label:"Dragging element",icon:"👆"},upload_file:{label:"Uploading file",icon:"📎"},emulate:{label:"Emulating device",icon:"📱"},handle_dialog:{label:"Handling dialog",icon:"💬"},get_console_message:{label:"Console message",icon:"🔍"},get_network_request:{label:"Network request",icon:"🔍"}},ke={shell_execute:"square-terminal",background_exec:"square-terminal",process:"settings",list_terminals:"square-terminal",new_terminal:"square-terminal",select_terminal:"square-terminal",close_terminal:"square-terminal",read_terminal:"square-terminal",write_terminal:"square-terminal",exec_terminal:"square-terminal",file_read:"file-text",file_write:"edit",file_edit:"edit",apply_patch:"git-branch",list_directory:"folder",glob_find:"search",grep_search:"search",web_fetch:"globe",web_search:"search",web_extract:"file-text",create_task:"clipboard",task_create:"clipboard",create_subtask:"clipboard",update_task:"check-circle",task_update:"check-circle",add_task_note:"edit",task_add_note:"edit",task_note:"edit",task_list:"clipboard",task_get:"clipboard",task_assign:"users",task_submit_review:"check-circle",task_comment:"message-square",subtask_create:"clipboard",subtask_complete:"check-circle",subtask_cancel:"alert-circle",subtask_list:"clipboard",requirement_propose:"clipboard",requirement_list:"clipboard",requirement_get:"clipboard",requirement_update:"clipboard",requirement_update_status:"check-circle",requirement_resubmit:"clipboard",requirement_comment:"message-square",list_projects:"layers",get_project:"layers",create_project:"layers",update_project:"layers",deliverable_create:"package",deliverable_search:"search",deliverable_list:"package",deliverable_update:"edit",git_status:"git-branch",git_diff:"git-branch",git_log:"book-open",git_branch:"git-branch",git_add:"git-branch",git_commit:"save",project_structure:"layers",code_stats:"bar-chart",navigate_page:"globe",new_page:"globe",close_page:"globe",select_page:"globe",list_pages:"globe",click:"target",hover:"target",fill:"terminal",fill_form:"terminal",type_text:"terminal",press_key:"terminal",take_screenshot:"camera",take_snapshot:"camera",evaluate_script:"code",wait_for:"clock",list_console_messages:"terminal",list_network_requests:"globe",lighthouse_audit:"bar-chart",agent_send_message:"message-square",agent_list_colleagues:"users",memory_save:"database",memory_search:"search",memory_list:"database",memory_update:"database",recall_activity:"book-open",notebook_upsert:"edit",kb_search:"book-open",kb_list:"book-open",kb_read:"book-open",notify_user:"megaphone",request_user_input:"message-square",request_user_approval:"check-circle",schedule_wakeup:"clock",cancel_wakeup:"clock",set_heartbeat_interval:"clock",discover_tools:"wrench",check_mailbox:"message-square",goal_create:"target",goal_update:"target",goal_status:"target",feishu_send_message:"message-square",feishu_search_docs:"search",spawn_subagent:"bot",spawn_subagents:"bot",invoke_coding_tool:"wrench",coding_tool_apply:"git-branch",generate_image:"camera",text_to_speech:"headphones",speech_to_text:"headphones",generate_video:"camera",llm_list_providers:"settings",llm_switch_model:"settings",llm_switch_default_provider:"settings",llm_add_provider:"settings",llm_edit_provider:"settings",llm_add_model:"settings",llm_get_capability_routing:"settings",llm_set_capability_routing:"settings",team_list:"users",team_status:"users",team_start:"users",team_stop:"users",team_update:"users",agent_start:"bot",agent_stop:"bot",agent_update:"bot",agent_delegate_task:"clipboard",agent_broadcast_status:"megaphone",agent_create_group_chat:"message-square",agent_list_group_chats:"message-square",agent_send_group_message:"message-square",delete_project:"layers",project_stats:"bar-chart",hub_search:"search",hub_install:"package",package_list:"package",package_install:"package",memory_delete:"database",memory_update_longterm:"database",notebook_clear:"edit",notebook_read:"edit",recall_context:"book-open",defer_mailbox_item:"message-square",drop_mailbox_item:"message-square",prioritize_mailbox_item:"message-square",delegate_message:"message-square",task_board_health:"clipboard",task_check_duplicates:"clipboard",task_cleanup_duplicates:"clipboard",workflow_list:"git-branch",workflow_create:"git-branch",workflow_update:"git-branch",workflow_delete:"git-branch",workflow_run:"git-branch",workflow_status:"git-branch",workflow_cancel:"git-branch",open_page:"globe",resize_page:"globe",drag:"target",upload_file:"file-text",emulate:"settings",handle_dialog:"message-square",get_console_message:"terminal",get_network_request:"globe"};function U(e){const n=e.includes("__")?e.split("__").pop():e,s=je[n]??je[e],r=ke[n]??ke[e]??"settings";return s?{...s,iconName:r,key:n}:{label:n.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:r,key:n}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function it(e){const n=new Date(e);if(isNaN(n.getTime()))return e;const s=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0"),a=String(n.getHours()).padStart(2,"0"),o=String(n.getMinutes()).padStart(2,"0"),i=String(n.getSeconds()).padStart(2,"0");return`${s}-${r} ${a}:${o}:${i}`}function ge(e,n){return e.length<=n?e:e.slice(0,n)+"…"}function _e(e){try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}}function Ke(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,s])=>s!=null).map(([s,r])=>({key:s,value:typeof r=="string"?r:JSON.stringify(r,null,2)}))}function lt(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const n=e.args.command;return typeof n=="string"?n:null}function xe(e){const n=new Set;for(let s=0;s<e.length;s++){const r=e[s];if(r.type==="tool"&&(r.info.status==="done"||r.info.status==="error"))for(let a=s-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===r.info.tool&&!n.has(a)){n.add(a);break}}}return e.filter((s,r)=>!n.has(r))}function be(e){const n=it(e.createdAt),s=e.createdAt,r=e.metadata;switch(e.type){case"text":return r?.isThinking?{type:"thinking",content:e.content,time:n,timestamp:s}:{type:"text",content:e.content,time:n,timestamp:s};case"status":{const a=r?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:n,timestamp:s}}case"error":return{type:"error",content:e.content,time:n,timestamp:s};case"tool_start":return{type:"tool",time:n,timestamp:s,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:r?.arguments,subagentLogs:r?.subagentLogs}};case"tool_end":return{type:"tool",time:n,timestamp:s,key:`ee_${e.seq}`,info:{tool:e.content,status:r?.success===!1?"error":"done",args:r?.arguments,result:r?.result,error:r?.error,durationMs:r?.durationMs,subagentLogs:r?.subagentLogs}};default:return null}}function Fe(e,n){if(e!=="task_create"&&e!=="create_task"||!n)return null;try{const s=JSON.parse(n);if(!s.task)return null;const r=s.task;return{taskId:r.id,title:r.title,description:r.description,assignedAgentId:r.assignedAgentId,priority:r.priority}}catch{return null}}function We(e,n){if(e!=="requirement_propose"||!n)return null;try{const s=JSON.parse(n);if(s.status!=="success"||!s.requirement)return null;const r=s.requirement;return r.status!=="pending"?null:{requirementId:r.id,title:r.title,description:r.description,priority:r.priority}}catch{return null}}function ct(e){const n=[];for(const s of e)if(s.phase!=="output"){if(s.phase==="start"){const r=`${s.tool}_${s.ts}`;n.push({key:r,tool:s.tool,status:"running"})}else for(let r=n.length-1;r>=0;r--)if(n[r].tool===s.tool&&n[r].status==="running"){n[r]={...n[r],status:s.success===!1?"error":"done"};break}}return n}function ze(){return t.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function dt(){return t.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function we({item:e}){const{t:n}=E("common"),s=U(e.tool);return t.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[t.jsx(J,{name:s.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),t.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[n(`execution.tools.${s.key}`,{defaultValue:s.label}),e.status==="running"?"…":""]}),e.status==="running"&&t.jsx(ze,{})]})}function Ne({activities:e,isActive:n,persistent:s}){const{t:r}=E("common"),a=ct(e),[o,i]=x.useState(!1),l=a.length>0,d=l&&a.every(p=>p.status!=="running");if(s&&d){const p=a.filter(_=>_.status==="error").length,k=a.filter(_=>_.status==="done").length;return t.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[t.jsxs("button",{onClick:()=>i(_=>!_),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[t.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"font-medium",children:r("activity.step",{count:k})}),p>0&&t.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",r("activity.failed",{count:p})]}),!o&&t.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(_=>{const b=U(_.tool);return t.jsx(J,{name:b.iconName,size:13,className:`shrink-0 ${_.status==="error"?"text-red-500":"text-green-500"}`},_.key)}),a.length>5&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&t.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((_,b)=>t.jsx(we,{item:_,idx:b,total:a.length},_.key))})]})}if(!l)return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[t.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:r("activity.thinking")}),t.jsx(dt,{})]});const c=a.filter(p=>p.status==="error").length;let u=null;for(let p=a.length-1;p>=0;p--)if(a[p].status==="running"){u=a[p];break}const h=a[a.length-1];let f;if(u){const p=U(u.tool);f=`${r(`execution.tools.${p.key}`,{defaultValue:p.label})}…`}else if(n&&d)f=r("activity.writingResponse");else{const p=U(h.tool);f=r(`execution.tools.${p.key}`,{defaultValue:p.label})}const g=!!u||n&&d;return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{onClick:p=>{p.stopPropagation(),i(k=>!k)},className:"flex items-center gap-1.5 text-xs w-full min-w-0 select-none text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:`truncate font-medium ${g?"activity-text-shimmer":"text-fg-secondary"}`,children:f}),t.jsxs("span",{className:"shrink-0",children:["· ",r("activity.step",{count:a.length})]}),c>0&&t.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",r("activity.failed",{count:c})]}),g&&t.jsx(ze,{})]}),o&&t.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((p,k)=>t.jsx(we,{item:p,idx:k,total:a.length},p.key))})]})}const ut=1920,pt=10*1024*1024,Ce=5,mt=.8;function gt(e,n,s){return new Promise((r,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=n&&l<=n){r(e);return}i>l?(l=Math.round(l*(n/i)),i=n):(i=Math.round(i*(n/l)),l=n);const d=document.createElement("canvas");d.width=i,d.height=l;const c=d.getContext("2d");if(!c){a(new Error("Failed to get canvas context"));return}c.drawImage(o,0,0,i,l),r(d.toDataURL("image/jpeg",s))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function xt({candidates:e,filter:n,anchorRef:s,onSelect:r,selectedIndex:a,onIndexChange:o}){const{t:i}=E("common"),[l,d]=x.useState(null),c=x.useRef(null),u=e.filter(h=>h.name.toLowerCase().includes(n));return x.useEffect(()=>{const h=s.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.top+window.scrollY-4,left:f.left+window.scrollX+8})},[s,n]),x.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const f=s.current;if(!f)return;const g=f.getBoundingClientRect();d({top:g.bottom+window.scrollY+4,left:l.left})}},[l,s]),x.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),x.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:he.createPortal(t.jsxs("div",{ref:c,style:{position:"absolute",top:l.top,left:l.left,transform:"translateY(-100%)"},className:"w-60 bg-surface-overlay border border-border-default rounded-lg shadow-xl z-[9999] max-h-48 overflow-y-auto",children:[t.jsx("div",{className:"px-2.5 py-1.5 text-[10px] text-fg-tertiary font-medium uppercase tracking-wider border-b border-border-default",children:i("commentInput.mentionHeading")}),u.map((h,f)=>t.jsxs("button",{"data-selected":f===a,onMouseDown:g=>{g.preventDefault(),r(h)},onMouseEnter:()=>o(f),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${f===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[t.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${h.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:h.name.slice(0,2).toUpperCase()}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-fg-primary font-medium",children:h.name}),t.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:h.subtitle??h.type})]}),h.type==="agent"&&t.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${h.online?"bg-green-400":"bg-gray-500"}`})]},h.id))]}),document.body)}function ft(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Se=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function gn(e){const n=[];let s;for(Se.lastIndex=0;(s=Se.exec(e))!==null;)n.push(s[1]??s[2]);return n}function xn(e,n,s){const r=[];let a=0;const o=n.map(l=>l.name).sort((l,d)=>d.length-l.length);let i=0;for(;i<e.length;){const l=e.indexOf("@",i);if(l<0){r.push(t.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&r.push(t.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const g=e.indexOf("]",l+2);if(g>l+2){const p=e.slice(l+2,g),k=n.find(_=>_.name.toLowerCase()===p.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&k?"cursor-pointer hover:underline":""}`,onClick:s&&k?_=>s(k,_):void 0,title:k?`${k.name} (${k.role})`:void 0,children:["@",p]},a++)),i=g+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(g=>c.startsWith(g.toLowerCase()));if(u){const g=n.find(p=>p.name.toLowerCase()===u.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&g?"cursor-pointer hover:underline":""}`,onClick:s&&g?p=>s(g,p):void 0,title:g?`${g.name} (${g.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const h=/^([\w\p{L}\p{N}]+)/u,f=d.match(h);if(f){const g=f[1],p=n.find(k=>k.name.toLowerCase()===g.toLowerCase());r.push(t.jsxs("span",{className:`text-brand-500 font-medium ${s&&p?"cursor-pointer hover:underline":""}`,onClick:s&&p?k=>s(p,k):void 0,title:p?`${p.name} (${p.role})`:void 0,children:["@",g]},a++)),i=l+1+g.length;continue}r.push(t.jsx("span",{children:"@"},a++)),i=l+1}return r.length>0?r:[t.jsx("span",{children:e},0)]}function fn({agents:e,humans:n,onSubmit:s,placeholder:r,replyTo:a,onCancelReply:o}){const{t:i}=E("common"),[l,d]=x.useState(""),[c,u]=x.useState(!1),[h,f]=x.useState(null),[g,p]=x.useState(!1),[k,_]=x.useState(""),[b,m]=x.useState([]),[v,j]=x.useState(0),[C,R]=x.useState([]),[z,D]=x.useState(!1),A=x.useRef(null),L=x.useRef(null),B=x.useRef(null),G=x.useMemo(()=>{const y=(n??[]).map(w=>({id:w.id,name:w.name,type:"human",subtitle:w.role}));for(const w of e)y.push({id:w.id,name:w.name,type:"agent",subtitle:w.role,online:w.status==="idle"||w.status==="working"});return y},[e,n]),q=G.filter(y=>y.name.toLowerCase().includes(k)),I=x.useCallback(y=>{const w=Array.from(y).filter(S=>S.type.startsWith("image/"));if(w.length!==0)for(const S of w){if(S.size>pt)continue;const M=new FileReader;M.onload=()=>{const Z=M.result;gt(Z,ut,mt).then($=>{R(de=>de.length>=Ce?de:[...de,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:$,name:S.name}])})},M.readAsDataURL(S)}},[]),oe=x.useCallback(y=>{R(w=>w.filter(S=>S.id!==y))},[]),ie=x.useCallback(y=>{const w=y.clipboardData?.files;if(w&&w.length>0){const S=Array.from(w).filter(M=>M.type.startsWith("image/"));S.length>0&&(y.preventDefault(),I(S))}},[I]),Q=x.useCallback(y=>{y.preventDefault(),D(!1);const w=y.dataTransfer?.files;w&&w.length>0&&I(Array.from(w).filter(S=>S.type.startsWith("image/")))},[I]),le=x.useCallback(y=>{y.preventDefault(),D(!0)},[]),ce=x.useCallback(()=>{D(!1)},[]),H=async()=>{if(!(!l.trim()&&C.length===0)){u(!0),f(null),B.current={content:l,mentions:[...b],images:[...C]};try{await s(l,b,[...C],a?.id),d(""),m([]),R([]),B.current=null,o?.()}catch(y){f(String(y instanceof Error?y.message:y)||i("commentInput.sendFailed"))}u(!1)}},F=async()=>{if(!B.current)return;const{content:y,mentions:w,images:S}=B.current;u(!0),f(null);try{await s(y,w,S),d(""),m([]),R([]),B.current=null}catch(M){f(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},N=x.useCallback(y=>{d(w=>{const S=w.lastIndexOf("@"),M=ft(y.name);return S>=0?w.slice(0,S)+M+" ":w+M+" "}),b.includes(y.id)||m(w=>[...w,y.id]),p(!1),_(""),j(0),A.current?.focus()},[b]),V=y=>{d(y),f(null);const w=y.lastIndexOf("@");if(w>=0&&(w===0||y[w-1]===" ")){const M=y.slice(w+1).toLowerCase();if(G.some($=>$.name.toLowerCase().includes(M))){_(M),p(!0),j(0);return}}p(!1)},X=y=>{if(g&&q.length>0){const w=y.key==="ArrowUp"||y.ctrlKey&&y.key==="p",S=y.key==="ArrowDown"||y.ctrlKey&&y.key==="n",M=y.key==="Enter"||y.key==="Tab",Z=y.key==="Escape";if(w){y.preventDefault(),j($=>($-1+q.length)%q.length);return}if(S){y.preventDefault(),j($=>($+1)%q.length);return}if(M){y.preventDefault();const $=q[v];$&&N($);return}if(Z){y.preventDefault(),p(!1);return}}y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),H())},rt=x.useCallback(()=>{setTimeout(()=>p(!1),200)},[]);return t.jsxs("div",{className:"relative",onDragOver:le,onDragLeave:ce,onDrop:Q,children:[z&&t.jsx("div",{className:"absolute inset-0 z-50 flex items-center justify-center bg-brand-500/10 rounded-lg border-2 border-dashed border-brand-500",children:t.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),g&&t.jsx(xt,{candidates:G,filter:k,anchorRef:A,onSelect:N,selectedIndex:v,onIndexChange:j}),t.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[t.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[t.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),t.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),t.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),b.length>0&&t.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:b.map(y=>{const w=G.find(S=>S.id===y);return t.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${w?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",w?.name??y,t.jsx("button",{onClick:()=>m(S=>S.filter(M=>M!==y)),className:"hover:text-red-400",children:"×"})]},y)})}),t.jsx("textarea",{ref:A,value:l,onChange:y=>V(y.target.value),onKeyDown:X,onBlur:rt,onPaste:ie,placeholder:r??i("commentInput.placeholder"),rows:2,className:"w-full px-2.5 py-2 text-xs bg-transparent text-fg-primary placeholder-fg-tertiary outline-none resize-none"}),C.length>0&&t.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:C.map(y=>t.jsxs("div",{className:"relative group/img shrink-0",children:[t.jsx("img",{src:y.dataUrl,alt:y.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),t.jsx("button",{onClick:()=>oe(y.id),className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-surface-secondary border border-gray-600 rounded-full flex items-center justify-center text-fg-secondary hover:text-red-500 hover:border-red-500 text-[10px] opacity-0 group-hover/img:opacity-100 transition-opacity",title:i("commentInput.removeImage"),children:"×"})]},y.id))}),h&&t.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[t.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:h}),t.jsxs("button",{onClick:F,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),t.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[t.jsx("button",{type:"button",onClick:()=>L.current?.click(),disabled:c||C.length>=Ce,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:t.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),t.jsx("input",{ref:L,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:y=>{y.target.files&&I(y.target.files),y.target.value=""}}),t.jsx("button",{onClick:H,disabled:!l.trim()&&C.length===0||c,className:"px-3 py-1 text-[11px] font-medium bg-brand-500 text-on-brand rounded-md hover:bg-brand-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",children:i(c?"commentInput.sending":"commentInput.submit")})]})]}),l.trim()&&!c&&t.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:t.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),t.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function hn(e){const n={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(n.chips=e.chips),e.images&&e.images.length>0&&(n.images=e.images),e.replyTo&&(n.replyToId=e.replyTo.id,n.replyToSender=e.replyTo.sender,n.replyToText=e.replyTo.text),n}function ht(e,n){return!!e&&n==="agent"}const bt=24e3,yt=200;function bn(e,n,s=bt){const r=(e??"")+n;return r.length<=s?r:r.slice(r.length-s)}function yn(e,n,s=yt){const r=[...e??[],n];return r.length<=s?r:r.slice(r.length-s)}function Ge(e){return!!e.text?.trim()||(e.segments??[]).some(n=>n.type==="text"&&(n.content||n.thinking)||n.type==="tool")}function vn(e,n){return!!(e.sender==="user"||Ge(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||n&&!e.isStopped)}function vt(e,n=8){for(let s=e.length-1;s>=Math.max(0,e.length-n);s--){const r=e[s];if(r.isStreaming&&!r.isStopped)return!0}return!1}function ye(e){if(!e||e.length===0)return e;let n=!1;const s=e.map(r=>r.type==="tool"&&r.status==="running"?(n=!0,{...r,status:"stopped"}):r);return n?s:e}function He(e,n){if(!Ge(e)&&n!=="done")return null;const r={...e,isStreaming:!1,segments:ye(e.segments)};switch(n){case"done":return{...r,isStopped:!1,isError:!1};case"stopped":return{...r,isStopped:!0,isError:!1};case"error":return{...r,isStopped:!0,isError:!0}}}function jn(e){const n=[...e];for(let s=n.length-1;s>=0;s--)if(n[s].sender==="agent"&&!n[s].isStopped&&!n[s].isError){const r=He(n[s],"stopped");r===null?n.splice(s,1):n[s]=r;break}return n}function kn(e,n){if(n){const s=e.findIndex(r=>r.id===n);if(s>=0){const r=e[s],a=ye(r.segments);if(!r.isStreaming&&a===r.segments)return e;const o=[...e];return o[s]={...r,isStreaming:!1,segments:a},o}}return jt(e)}function jt(e){return vt(e)?e.map(n=>n.sender!=="agent"||!n.isStreaming||n.isStopped?n:{...n,isStreaming:!1,segments:ye(n.segments)}):e}function _n(e,n,s){return!n||!s||n===s?e:e.some(r=>r.id===s)?e.filter(r=>r.id!==n):e.map(r=>r.id===n?{...r,id:s}:r)}function wn(e){for(let n=e.length-1;n>=0;n--){const s=e[n];if(s.sender==="agent"&&s.isStreaming)return n}return-1}function Nn(e){if(!e.sendSessionId)return!1;const n=e.liveSessions;return!n||n.size===0?!1:n.has(e.sendSessionId)}function Cn(e){const n=e.liveSessions;return!n||n.size===0||!e.sessionId?!0:!n.has(e.sessionId)&&!n.has(e.placeholderId)}function Sn(e,n="stopped"){for(let s=e.length-1;s>=0;s--){const r=e[s];if(r.sender==="agent"&&r.isStreaming&&!r.isStopped){const a=He(r,n);if(a===null)return e.filter((i,l)=>l!==s);const o=[...e];return o[s]=a,o}}return e}function Tn(e,n){if(e.some(o=>o.id===n.id))return e;const s=n.rawCreatedAt?Date.parse(n.rawCreatedAt):NaN;if(!Number.isFinite(s)||e.length===0)return[...e,n];let r=e.length;for(;r>0;){const o=e[r-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=s)break;r--}if(r===e.length)return[...e,n];const a=e.slice();return a.splice(r,0,n),a}function En(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,thinking:(s.thinking??"")+n}]:[...e,{type:"text",content:"",thinking:n,createdAt:new Date().toISOString()}]}function Mn(e,n){if(!n)return e;const s=e[e.length-1];return s?.type==="text"?[...e.slice(0,-1),{...s,content:s.content+n}]:[...e,{type:"text",content:n,createdAt:new Date().toISOString()}]}const kt=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function ve(e){if(!e.includes("notify_context"))return{cleaned:e};let n;const s=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(s?.[1]){const r=s[1].match(/priority\s*=\s*(\w+)/i);r&&(n=r[1])}return{cleaned:e.replace(kt,"").trimEnd(),priority:n}}const _t=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,wt=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function An(e){return e.replace(_t,"").replace(wt,"")}function Nt(e,n,s){if(e.type!=="tool"){const{cleaned:l}=ve(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const r=s?.type==="tool"&&s.tool===e.tool?s:void 0,a=e.subagentLogs?.length??0,o=r?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:r?.subagentLogs;return{type:"tool",key:`${e.tool}_${n}`,tool:e.tool,status:e.status,args:e.arguments,result:e.result,error:e.error,durationMs:e.durationMs,createdAt:e.createdAt,...i?.length?{subagentLogs:i}:{}}}function Ve(e,n){const s=(n??[]).filter(a=>a.type==="tool");let r=0;return e.map((a,o)=>{const i=a.type==="tool"?s[r++]:void 0;return Nt(a,o,i)})}const te=new Map,Ct=2e3;function Xe(e){if(!e)return"";const n=te.get(e);if(n!==void 0)return n;const s=new Date(e),r=isNaN(s.getTime())?"":s.toLocaleTimeString();return te.size>=Ct&&te.clear(),te.set(e,r),r}function Ln(e){const n={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Xe(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(n.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(n.segments=Ve(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(n.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(n.isError=!0),e.metadata?.emptyReply===!0&&(n.emptyReply=!0,n.isStopped||(n.isError=!0)),e.metadata?.isStreaming&&(n.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(n.isStopped=!0),e.metadata?.images?.length&&(n.images=e.metadata.images),e.metadata?.notifyUser&&(n.isNotification=!0,n.notifyPriority=e.metadata.priority,e.metadata.taskId&&(n.taskId=e.metadata.taskId),e.metadata.requirementId&&(n.requirementId=e.metadata.requirementId)),n.text.includes("<!-- notify_context:")){const{cleaned:s,priority:r}=ve(n.text);n.text=s,r&&!n.notifyPriority&&(n.notifyPriority=r),n.isNotification=!0}if(e.metadata?.activityLog&&(n.isActivityLog=!0,n.activityType=e.metadata.activityType,n.outcome=e.metadata.outcome,n.mailboxItemId=e.metadata.mailboxItemId,n.taskId=e.metadata.taskId,n.requirementId=e.metadata.requirementId,!n.outcome&&n.text.startsWith("[ACTIVITY:"))){const s=n.text.lastIndexOf(" → ");s!==-1&&(n.outcome=n.text.slice(s+3)),n.text=n.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(n.replyToId=e.metadata.replyToId,n.replyToSender=e.metadata.replyToSender,n.replyToText=e.metadata.replyToText,n.text=Ye(n.text,n.replyToSender,n.replyToText)),e.role==="user"){const s=at(e.metadata?.chips);s&&(n.chips=s)}return n}function Ye(e,n,s){if(!e||!n||!s)return e;const r=`> **${n}**: ${s}
|
|
2
|
+
|
|
3
|
+
`;return e.startsWith(r)?e.slice(r.length):e}function Rn(e,n={}){if(n.expectedMessageId)for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.id===n.expectedMessageId&&a.sender==="agent"&&!a.isError)return a}let s=-1;for(let r=e.length-1;r>=0;r--)if(e[r].sender==="user"){s=r;break}for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.sender!=="agent")continue;return a.isStreaming?a:a.isError?void 0:!(a.text?.trim()||(a.segments??[]).some(i=>i.type==="text"&&((i.content??"").trim()||i.thinking)||i.type==="tool"))||n.allowCurrentTurnPartial&&s>=0&&r>s?a:void 0}}function In(e){const n=e?.messageId||e?.streamId;return n?`reattach_${n}`:null}function $n(e,n){const s=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),r=e.senderType==="human"&&(!n||e.senderId===n);let a=e.text;r&&e.replyToId&&e.replyToSender&&e.replyToText&&(a=Ye(a,e.replyToSender,e.replyToText));const o={id:e.id,sender:r?"user":"agent",text:a,time:Xe(e.createdAt),rawCreatedAt:e.createdAt,agentName:r?void 0:e.senderName,agentId:r?void 0:e.senderId,isError:s,replyToId:e.replyToId,replyToSender:e.replyToSender,replyToText:e.replyToText},i=e.metadata;if(i?.images?.length&&(o.images=i.images),i&&e.senderType==="agent"){const l=[];if(i.thinking?.length&&l.push({type:"text",content:"",thinking:i.thinking.join(`
|
|
4
|
+
|
|
5
|
+
`)}),i.toolCalls?.length)for(let d=0;d<i.toolCalls.length;d++){const c=i.toolCalls[d];l.push({type:"tool",key:`${c.tool}_${d}`,tool:c.tool,status:c.status==="error"?"error":"done",args:c.arguments,result:c.result,durationMs:c.durationMs})}l.length>0&&(l.push({type:"text",content:e.text}),o.segments=l)}return o}const ne=new Map,St=2e3;function Dn(e,n,s){const r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),o=n?`${n}|${a}|${e}|${s?.yesterday??""}`:null;if(o){const u=ne.get(o);if(u!==void 0)return u}const i=n?new Date(n):r;if(isNaN(i.getTime()))return e;const l=i.getTime(),d=i.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});let c;return l>=a?c=d:l>=a-864e5?c=`${s?.yesterday??"Yesterday"} ${d}`:c=i.toLocaleDateString(void 0,{month:"short",day:"numeric"})+" "+d,o&&(ne.size>=St&&ne.clear(),ne.set(o,c)),c}function qn(e){if(!e)return"";const n=new Date(e);return isNaN(n.getTime())?"":`${n.getFullYear()}-${n.getMonth()+1}-${n.getDate()}`}function On(e,n){const s=new Date(e);if(isNaN(s.getTime()))return"";const r=new Date,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),o=s.getTime();return o>=a?n?.today??"Today":o>=a-864e5?n?.yesterday??"Yesterday":s.toLocaleDateString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"})}function Bn(e,n){return(n?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()==="n"?"new-conversation":e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key==="Tab"?e.shiftKey?"cycle-session-prev":"cycle-session-next":null}function Pn(e,n,s){if(e.length<=1)return null;const r=n===null?-1:e.indexOf(n),o=((r>=0?r:s===1?-1:0)+s+e.length)%e.length;return e[o]??null}function Un(e,n){let s=0,r=null;return((...a)=>{const o=Date.now(),i=n-(o-s);if(i<=0)return r&&(clearTimeout(r),r=null),s=o,e(...a);r||(r=setTimeout(()=>{s=Date.now(),r=null,e(...a)},i))})}const Tt=10,Et=23,Te={expanded:24,compact:12};function Kn(e){const n=e?Te.compact:Te.expanded;return Tt*Et+n}function Fn(e,n){return e||n}function Wn(e){return e?"justify-end":""}function zn(e,n,s){return e?n.includes(e)?"detail":s?"missing":"loading":"missing"}const Mt={"claude-code":{label:"Claude Code",icon:"🤖",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",icon:"⬡",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",icon:"▶",badgeClass:"bg-blue-500/15 text-blue-500"}},W=["created","context_injected","running"],At=new Set(["completed","failed","cancelled","timeout"]),Ee={created:"Created",context_injected:"Context injected",running:"Running",completed:"Completed",failed:"Failed",cancelled:"Cancelled",timeout:"Timed out"};function Lt(e){return Mt[e]??{label:e.replace(/-/g," ").replace(/\b\w/g,n=>n.toUpperCase()),icon:"⚙",badgeClass:"bg-surface-elevated text-fg-tertiary"}}function Rt(e,n){if(e.cost?.durationMs!=null)return e.cost.durationMs;const s=e.startedAt??e.createdAt,r=new Date(s).getTime();if(!Number.isNaN(r)){if(e.completedAt){const a=new Date(e.completedAt).getTime();return Number.isNaN(a)?void 0:Math.max(0,a-r)}if(e.status==="running"||e.status==="context_injected")return Math.max(0,n-r)}}function It(e){if(e==="completed"||At.has(e))return W.length;const n=W.indexOf(e);return n>=0?n:0}function $t({session:e,className:n}){const s=Lt(e.tool),[r,a]=x.useState(!1),[o,i]=x.useState(()=>Date.now()),l=e.status==="running"||e.status==="context_injected"||e.status==="created",d=e.status==="failed"||e.status==="timeout"||e.result?.success===!1,c=e.status==="completed"||e.result?.success===!0;x.useEffect(()=>{if(!l)return;const p=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(p)},[l]);const u=x.useMemo(()=>Rt(e,o),[e,o]),h=It(e.status),f=e.result?.rawOutput??(c||d?e.result?.summary:void 0),g=l?"border-brand-500/40 bg-brand-500/5":d?"border-red-500/30 bg-red-500/5":c?"border-green-500/30 bg-green-500/5":"border-border-default bg-surface-secondary/30";return t.jsxs("div",{className:`my-2 rounded-lg border ${g} p-3 max-w-2xl transition-colors ${n??""}`,children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-sm mt-0.5",children:s.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${s.badgeClass}`,children:s.label}),t.jsx("span",{className:`text-[10px] font-medium ${l?"text-brand-500":d?"text-red-500":c?"text-green-500":"text-fg-tertiary"}`,children:Ee[e.status]??e.status}),u!=null&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:K(u)}),e.cost?.estimatedCostUsd!=null&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary tabular-nums",children:["$",e.cost.estimatedCostUsd.toFixed(4)]})]}),t.jsx("div",{className:"text-xs text-fg-secondary mt-1 line-clamp-2",children:e.prompt})]}),l&&t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0 mt-0.5",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})]}),t.jsxs("div",{className:"flex items-center gap-1 mt-3 ml-6",children:[W.map((p,k)=>{const _=h>k||h===k&&!l&&c,b=h===k&&l,m=d&&k===W.length-1&&e.status!=="completed";return t.jsxs("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:[t.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${m?"bg-red-500":_?"bg-green-500":b?"bg-brand-500 animate-pulse":"bg-gray-600"}`,title:Ee[p]}),k<W.length-1&&t.jsx("div",{className:`h-px flex-1 ${_?"bg-green-500/50":"bg-border-default/60"}`})]},p)}),t.jsx("div",{className:`w-2 h-2 rounded-full shrink-0 ${d?"bg-red-500":c?"bg-green-500":"bg-gray-600"}`,title:d?"Failed":"Done"})]}),(e.progressMessage||e.progressPercent!=null)&&l&&t.jsxs("div",{className:"mt-2 ml-6 space-y-1",children:[e.progressPercent!=null&&t.jsx("div",{className:"h-1 bg-surface-elevated rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-brand-500 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,e.progressPercent))}%`}})}),e.progressMessage&&t.jsx("div",{className:"text-[11px] text-fg-tertiary font-mono truncate",children:e.progressMessage})]}),e.result&&!l&&t.jsxs("div",{className:"mt-2 ml-6 space-y-1.5",children:[e.result.summary&&t.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px] font-mono",children:[t.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files"]}),t.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["−",e.result.diffStats.deletions]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null)&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[e.cost.inputTokens!=null&&t.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," in"]}),e.cost.inputTokens!=null&&e.cost.outputTokens!=null&&t.jsx("span",{className:"mx-1",children:"·"}),e.cost.outputTokens!=null&&t.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," out"]})]})]}),f&&t.jsxs("div",{className:"mt-2 ml-6 border-t border-border-default/30 pt-2",children:[t.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${r?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-medium uppercase tracking-wider",children:"Raw output"})]}),r&&t.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono",children:f})]})]})}function Dt({label:e}){const{t:n}=E("common");return t.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[t.jsx("span",{className:"activity-text-shimmer",children:e??n("execution.thinking")}),t.jsx("span",{className:"flex gap-0.5",children:[0,150,300].map(s=>t.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${s}ms`,animationDuration:"1s"}},s))})]})}const Me=150;function qt({content:e,className:n}){const[s,r]=x.useState(e),a=x.useRef(0),o=x.useRef(null);x.useEffect(()=>{const l=Date.now(),d=l-a.current;return d>=Me?(a.current=l,r(e)):o.current||(o.current=setTimeout(()=>{a.current=Date.now(),o.current=null,r(e)},Me-d)),()=>{o.current&&(clearTimeout(o.current),o.current=null)}},[e]);const i=x.useMemo(()=>s,[s]);return t.jsxs("div",{className:"bg-surface-elevated/50 rounded-lg px-3 py-2.5 my-1 min-w-0 overflow-hidden",children:[t.jsx(O,{content:i,className:n??"text-sm text-fg-secondary break-words"}),t.jsx("span",{className:"inline-block w-0.5 h-4 bg-brand-400 animate-pulse ml-0.5 align-middle"})]})}const ae=8e3,se=120;function ue({text:e,className:n}){const{t:s}=E("common"),[r,a]=x.useState(!1),o=e.length>ae,i=!o||r?e:`${e.slice(0,ae)}
|
|
6
|
+
…`;return t.jsxs("div",{children:[t.jsx("pre",{className:n,children:i}),o&&t.jsx("button",{type:"button",className:"mt-1 text-[11px] text-brand-500 hover:underline",onClick:l=>{l.stopPropagation(),a(d=>!d)},children:s(r?"showLess":"showMore")})]})}function Ot({info:e,time:n}){const{t:s}=E("common"),r=Ke(e.args),a=e.status==="running",o=e.status!=="error",i=r.length>0||!a&&(!!e.result||!!e.error)||!!e.subagentLogs&&e.subagentLogs.length>0,l=x.useRef(null),d=e.subagentLogs?.length??0,c=e.subagentLogs&&e.subagentLogs.length>se?e.subagentLogs.slice(e.subagentLogs.length-se):e.subagentLogs;return x.useEffect(()=>{!a||!l.current||(l.current.scrollTop=l.current.scrollHeight)},[d,a]),t.jsxs("div",{className:"space-y-3 py-1",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px]",children:[t.jsx("span",{className:`px-1.5 py-0.5 rounded ${a?"bg-brand-500/15 text-brand-500":o?"bg-green-500/15 text-green-600":"bg-surface-overlay text-fg-tertiary"}`,children:s(a?"execution.toolRunning":o?"execution.toolSuccess":"execution.toolFailed")}),n&&t.jsx("span",{className:"text-fg-tertiary tabular-nums",children:n}),e.durationMs!=null&&t.jsx("span",{className:"text-fg-tertiary",children:K(e.durationMs)})]}),r.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:s("execution.arguments")}),t.jsx("div",{className:"space-y-2",children:r.map(({key:u,value:h})=>t.jsxs("div",{children:[t.jsx("div",{className:"text-[11px] text-brand-500 font-medium mb-0.5",children:u}),t.jsx(ue,{text:h,className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]},u))})]}),c&&c.length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:s("execution.subagentExecution")}),t.jsxs("div",{ref:l,className:"bg-surface-elevated/50 rounded-lg px-3 py-2 space-y-1",children:[d>se&&t.jsxs("div",{className:"text-[10px] text-fg-tertiary pb-1",children:["… ",d-se," earlier steps omitted"]}),c.map((u,h)=>{const f=u.eventType==="started"?"▶":u.eventType==="completed"?"✓":u.eventType==="error"?"✗":u.eventType==="tool_start"?"◎":u.eventType==="tool_end"?"●":u.eventType==="thinking"?"·":"→",g=u.eventType==="error"?"text-fg-tertiary":u.eventType==="completed"?"text-green-500":u.eventType==="started"||u.eventType==="tool_start"?"text-brand-500":"text-fg-tertiary";return t.jsxs("div",{className:"flex items-start gap-1.5 text-xs",children:[t.jsx("span",{className:`shrink-0 ${g}`,children:f}),t.jsx("span",{className:`font-mono break-all ${g}`,children:ge(u.content,500)})]},h)}),a&&t.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] text-brand-500 pt-0.5",children:[t.jsxs("svg",{className:"w-3 h-3 animate-spin shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{children:s("execution.toolRunning")})]})]})]}),!a&&e.result&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:s("execution.result")}),t.jsx(ue,{text:_e(e.result),className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]}),!a&&e.error&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-1",children:s("execution.error")}),t.jsx(ue,{text:_e(String(e.error)),className:"text-xs text-fg-secondary bg-surface-elevated/50 border border-border-default rounded-lg px-3 py-2 overflow-x-auto whitespace-pre-wrap break-all font-mono"})]}),!i&&t.jsx("div",{className:"text-xs text-fg-tertiary italic py-2 text-center",children:s("execution.noToolDetail")})]})}const Je={urgent:"text-red-500",high:"text-amber-500",medium:"text-blue-500",low:"text-fg-tertiary"},Ae={pending:"pending",in_progress:"in_progress",completed:"completed",review:"review",blocked:"blocked",failed:"failed",rejected:"rejected",revision:"revision",cancelled:"cancelled",archived:"archived"},T=e=>({borderClass:ee[e].border,bgClass:ee[e].surface,badgeClass:ee[e].chip,textClass:ee[e].text}),Le={pending:{icon:"⏳",labelKey:"execution.card.pendingApproval",...T("attention")},approving:{icon:"⏳",labelKey:"execution.card.approving",...T("attention")},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",...T("attention")},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",...T("active")},completed:{icon:"✅",labelKey:"execution.card.completed",...T("success")},review:{icon:"👀",labelKey:"execution.card.inReview",...T("attention")},blocked:{icon:"🚫",labelKey:"execution.card.blocked",...T("blocked")},failed:{icon:"❌",labelKey:"execution.card.failed",...T("danger")},rejected:{icon:"❌",labelKey:"execution.card.rejected",...T("danger")},revision:{icon:"✏️",labelKey:"execution.card.revision",...T("active")},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",...T("neutral")},archived:{icon:"📦",labelKey:"execution.card.archived",...T("neutral")},loading:{icon:"⏳",labelKey:"execution.card.loading",...T("neutral")}};function Qe({info:e}){const{t:n}=E("common"),[s,r]=x.useState("loading"),[a,o]=x.useState(null);x.useEffect(()=>{let f=!1;return P.tasks.get(e.taskId).then(({task:g})=>{f||r(Ae[g.status]??"pending")}).catch(()=>{f||r("pending")}),()=>{f=!0}},[e.taskId]),x.useEffect(()=>qe.on("task:update",f=>{const g=f.payload;g.taskId===e.taskId&&g.status&&r(Ae[g.status]??"pending")}),[e.taskId]);const i=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{taskId:e.taskId}}))},l=async()=>{o(null),r("approving");try{await P.tasks.approve(e.taskId),r("in_progress"),i()}catch{r("pending")}},d=async()=>{o(null),r("rejecting");try{await P.tasks.reject(e.taskId),r("rejected"),i()}catch{r("pending")}},c=s==="pending"||s==="approving"||s==="rejecting",u=Le[s]??Le.loading,h=()=>Oe.navigate(Be.WORK,{openTask:e.taskId});return t.jsxs("div",{className:`my-2 rounded-lg border ${u.borderClass} ${u.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:h,onKeyDown:f=>f.key==="Enter"&&h(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:u.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${u.badgeClass}`,children:n("execution.taskBadge")}),!c&&s!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${u.textClass}`,children:n(u.labelKey)})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!c&&s!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-2",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:Je[e.priority]??"text-fg-tertiary",children:n(`priority.${e.priority}`,{defaultValue:e.priority})}),t.jsx("span",{className:"opacity-50",children:n("execution.idPrefix",{id:e.taskId.slice(0,8)})})]})]})]}),c&&t.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-border-default/30",children:[t.jsx("button",{onClick:()=>o("approve"),disabled:s!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(s==="approving"?"execution.card.approving":"approve")}),t.jsx("button",{onClick:()=>o("reject"),disabled:s!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(s==="rejecting"?"execution.card.rejecting":"reject")})]}),a==="approve"&&t.jsx(re,{variant:"primary",title:n("execution.card.confirmApproveTaskTitle"),message:n("execution.card.confirmApproveTaskMessage",{title:e.title}),confirmLabel:n("approve"),onConfirm:()=>{l()},onCancel:()=>o(null)}),a==="reject"&&t.jsx(re,{variant:"danger",title:n("execution.card.confirmRejectTaskTitle"),message:n("execution.card.confirmRejectTaskMessage",{title:e.title}),confirmLabel:n("reject"),onConfirm:()=>{d()},onCancel:()=>o(null)})]})}const Re={pending:"pending",in_progress:"in_progress",completed:"completed",rejected:"rejected",cancelled:"cancelled",archived:"archived"},Ie={pending:{icon:"📋",labelKey:"execution.card.pendingApproval",...T("attention")},approving:{icon:"⏳",labelKey:"execution.card.approving",...T("attention")},rejecting:{icon:"⏳",labelKey:"execution.card.rejecting",...T("attention")},in_progress:{icon:"▶",labelKey:"execution.card.inProgress",...T("active")},completed:{icon:"✅",labelKey:"execution.card.completed",...T("success")},rejected:{icon:"❌",labelKey:"execution.card.rejected",...T("danger")},cancelled:{icon:"⊘",labelKey:"execution.card.cancelled",...T("neutral")},archived:{icon:"📦",labelKey:"execution.card.archived",...T("neutral")},loading:{icon:"⏳",labelKey:"execution.card.loading",...T("neutral")}},Bt=["requirement:approved","requirement:rejected","requirement:updated","requirement:completed","requirement:cancelled","requirement:resubmitted"];function Ze({info:e}){const{t:n}=E("common"),[s,r]=x.useState("loading"),[a,o]=x.useState(""),[i,l]=x.useState(!1),[d,c]=x.useState(null);x.useEffect(()=>{let b=!1;return P.requirements.get(e.requirementId).then(({requirement:m})=>{b||r(Re[m.status]??"pending")}).catch(()=>{b||r("pending")}),()=>{b=!0}},[e.requirementId]),x.useEffect(()=>{const b=Bt.map(m=>qe.on(m,v=>{const j=v.payload;j.id===e.requirementId&&j.status&&r(Re[j.status]??"pending")}));return()=>b.forEach(m=>m())},[e.requirementId]);const u=()=>{window.dispatchEvent(new CustomEvent("markus:mark-read-by-ref",{detail:{requirementId:e.requirementId}}))},h=async()=>{c(null),r("approving");try{await P.requirements.approve(e.requirementId),r("in_progress"),u()}catch{r("pending")}},f=async()=>{if(a.trim()){c(null),r("rejecting");try{await P.requirements.reject(e.requirementId,a.trim()),r("rejected"),u()}catch{r("pending")}}},g=()=>{if(!i){l(!0);return}a.trim()&&c("reject")},p=s==="pending"||s==="approving"||s==="rejecting",k=Ie[s]??Ie.loading,_=()=>Oe.navigate(Be.WORK,{openRequirement:e.requirementId});return t.jsxs("div",{className:`my-2 rounded-lg border ${k.borderClass} ${k.bgClass} p-3 max-w-md transition-colors`,children:[t.jsxs("div",{className:"flex items-start gap-2 mb-1 cursor-pointer group",role:"button",tabIndex:0,onClick:_,onKeyDown:b=>b.key==="Enter"&&_(),children:[t.jsx("span",{className:"text-sm mt-0.5",children:k.icon}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded font-medium ${k.badgeClass}`,children:n("execution.reqBadge")}),!p&&s!=="loading"&&t.jsx("span",{className:`text-[10px] font-medium ${k.textClass}`,children:n(k.labelKey)})]}),t.jsx("div",{className:`text-sm font-medium truncate mt-1 group-hover:underline ${!p&&s!=="loading"?"text-fg-secondary":"text-fg-primary"}`,children:e.title}),e.description&&t.jsx("div",{className:"text-xs text-fg-secondary mt-0.5 line-clamp-3",children:e.description}),t.jsxs("div",{className:"flex items-center gap-2 mt-1.5 text-[11px] text-fg-tertiary",children:[e.priority&&t.jsx("span",{className:Je[e.priority]??"text-fg-tertiary",children:n(`priority.${e.priority}`,{defaultValue:e.priority})}),t.jsx("span",{className:"opacity-50",children:n("execution.idPrefix",{id:e.requirementId.slice(0,8)})})]})]})]}),p&&t.jsxs("div",{className:"mt-2 pt-2 border-t border-border-default/30 space-y-2",children:[i&&t.jsx("input",{type:"text",value:a,onChange:b=>o(b.target.value),placeholder:n("execution.rejectionReasonPlaceholder"),className:"w-full px-2 py-1.5 text-xs rounded-md bg-surface-secondary border border-border-default text-fg-primary placeholder:text-fg-tertiary focus:outline-none focus:border-brand-500",onKeyDown:b=>b.key==="Enter"&&g(),autoFocus:!0}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:()=>c("approve"),disabled:s!=="pending",className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-green-600 hover:bg-green-500 text-white transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(s==="approving"?"execution.card.approving":"approve")}),t.jsx("button",{onClick:g,disabled:s!=="pending"||i&&!a.trim(),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded-md bg-surface-elevated hover:bg-surface-overlay text-fg-secondary border border-border-default transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:n(s==="rejecting"?"execution.card.rejecting":"reject")})]})]}),d==="approve"&&t.jsx(re,{variant:"primary",title:n("execution.card.confirmApproveReqTitle"),message:n("execution.card.confirmApproveReqMessage",{title:e.title}),confirmLabel:n("approve"),onConfirm:()=>{h()},onCancel:()=>c(null)}),d==="reject"&&t.jsx(re,{variant:"danger",title:n("execution.card.confirmRejectReqTitle"),message:n("execution.card.confirmRejectReqMessage",{title:e.title}),confirmLabel:n("reject"),onConfirm:()=>{f()},onCancel:()=>c(null)})]})}const Pt={"claude-code":{label:"Claude Code",badgeClass:"bg-orange-500/15 text-orange-500"},codex:{label:"Codex",badgeClass:"bg-emerald-500/15 text-emerald-500"},"cursor-agent":{label:"Cursor",badgeClass:"bg-blue-500/15 text-blue-500"}};function Ut({session:e,info:n,onClose:s}){const r=n.args&&typeof n.args=="object"&&!Array.isArray(n.args)?n.args:{},a=e.status==="running"||e.status==="created"||e.status==="context_injected",o=e.status==="failed"||e.status==="timeout",i=e.status==="completed",l=Pt[e.tool]??{label:e.tool,badgeClass:"bg-surface-elevated text-fg-tertiary"},[d,c]=x.useState(!1);x.useEffect(()=>{const g=p=>{p.key==="Escape"&&s()};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s]);const u=e.cost?.durationMs??n.durationMs,h=typeof r.model=="string"?r.model:void 0,f=typeof r.mode=="string"?r.mode:void 0;return t.jsxs("div",{className:"fixed inset-0 z-[60] flex items-center justify-center",onClick:s,children:[t.jsx("div",{className:"absolute inset-0 bg-black/60"}),t.jsxs("div",{className:"relative bg-surface-secondary border border-border-default rounded-xl shadow-2xl w-[640px] max-w-[92vw] max-h-[80vh] overflow-hidden flex flex-col",onClick:g=>g.stopPropagation(),children:[t.jsxs("div",{className:"px-5 py-3 border-b border-border-default flex items-center justify-between shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`text-xs px-2 py-0.5 rounded font-medium ${l.badgeClass}`,children:l.label}),t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${a?"bg-brand-500/15 text-brand-500":i?"bg-green-500/15 text-green-600":"bg-surface-overlay text-fg-tertiary"}`,children:a?"Running":i?"Completed":o?"Failed":e.status}),u!=null&&t.jsx("span",{className:"text-xs text-fg-tertiary tabular-nums",children:K(u)}),h&&t.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary font-mono",children:h}),f&&t.jsx("span",{className:"text-[10px] bg-surface-elevated px-1.5 py-0.5 rounded text-fg-tertiary",children:f})]}),t.jsx("button",{onClick:s,className:"text-fg-tertiary hover:text-fg-secondary text-lg leading-none ml-2",children:"×"})]}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Prompt"}),t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-40 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.prompt})]}),Object.keys(r).length>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Input Arguments"}),t.jsx("div",{className:"space-y-1.5",children:Object.entries(r).filter(([g])=>g!=="prompt").map(([g,p])=>t.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[t.jsxs("span",{className:"text-brand-500 font-medium shrink-0 font-mono",children:[g,":"]}),t.jsx("span",{className:"text-fg-secondary font-mono break-all",children:typeof p=="string"?p:JSON.stringify(p)})]},g))})]}),e.result&&!a&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Result"}),t.jsxs("div",{className:"space-y-2",children:[e.result.summary&&t.jsx("div",{className:"text-xs text-fg-secondary",children:e.result.summary}),e.result.diffStats&&t.jsxs("div",{className:"flex items-center gap-3 text-xs font-mono",children:[t.jsxs("span",{className:"text-fg-tertiary",children:[e.result.diffStats.filesChanged," files changed"]}),t.jsxs("span",{className:"text-green-500",children:["+",e.result.diffStats.additions]}),t.jsxs("span",{className:"text-red-500",children:["-",e.result.diffStats.deletions]})]}),e.result.modifiedFiles&&e.result.modifiedFiles.length>0&&t.jsxs("div",{children:[t.jsx("div",{className:"text-[10px] text-fg-tertiary mb-1",children:"Modified files:"}),t.jsx("div",{className:"bg-surface-elevated/70 rounded-lg px-3 py-2 max-h-32 overflow-y-auto",children:e.result.modifiedFiles.map((g,p)=>t.jsx("div",{className:"text-[11px] text-fg-secondary font-mono truncate",children:g},p))})]}),e.result.error&&t.jsx("pre",{className:"text-xs text-fg-secondary bg-surface-elevated/50 border border-border-default rounded-lg px-3 py-2 overflow-x-auto max-h-60 overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.error})]})]}),e.cost&&(e.cost.inputTokens!=null||e.cost.outputTokens!=null||e.cost.estimatedCostUsd!=null)&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-[10px] font-semibold text-fg-tertiary uppercase tracking-wider mb-2",children:"Cost"}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-fg-secondary",children:[e.cost.inputTokens!=null&&t.jsxs("span",{children:[e.cost.inputTokens.toLocaleString()," input tokens"]}),e.cost.outputTokens!=null&&t.jsxs("span",{children:[e.cost.outputTokens.toLocaleString()," output tokens"]}),e.cost.estimatedCostUsd!=null&&t.jsxs("span",{className:"font-medium",children:["$",e.cost.estimatedCostUsd.toFixed(4)]}),u!=null&&t.jsx("span",{className:"text-fg-tertiary",children:K(u)})]})]}),e.result?.rawOutput&&t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>c(!d),className:"flex items-center gap-1.5 text-[10px] text-fg-tertiary hover:text-fg-secondary transition-colors",children:[t.jsx("svg",{className:`w-3 h-3 transition-transform ${d?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),t.jsx("span",{className:"font-semibold uppercase tracking-wider",children:"Raw Output"})]}),d&&t.jsx("pre",{className:"mt-2 text-[11px] text-fg-tertiary bg-surface-elevated/70 rounded-lg px-3 py-2 overflow-x-auto max-h-[50vh] overflow-y-auto whitespace-pre-wrap break-all font-mono",children:e.result.rawOutput})]})]})]})]})}function Kt(e){if(e.tool!=="invoke_coding_tool")return null;const n=e.args&&typeof e.args=="object"&&!Array.isArray(e.args)?e.args:{},s=typeof n.tool=="string"?n.tool:"unknown",r=typeof n.prompt=="string"?n.prompt:"",o={running:"running",done:"completed",error:"failed",stopped:"cancelled"}[e.status]??e.status;let i,l;if(e.result)try{const c=JSON.parse(e.result);if(c&&typeof c=="object"){const u=c.result&&typeof c.result=="object"?c.result:c;i={success:u.success??c.success??e.status==="done",summary:u.summary??u.message??c.summary??c.message??"Completed",diffStats:u.diffStats??c.diffStats,modifiedFiles:u.modifiedFiles??c.modifiedFiles,exitCode:u.exitCode??c.exitCode,rawOutput:u.rawOutput??u.output??c.rawOutput??c.output,error:u.error??c.error},u.cost?l=u.cost:c.cost&&(l=c.cost)}}catch{i={success:e.status==="done",summary:e.result.slice(0,500),rawOutput:e.result}}e.durationMs!=null&&(l={...l,durationMs:e.durationMs});let d;if(e.liveOutput&&e.status==="running"){const c=e.liveOutput.trim().split(`
|
|
7
|
+
`);d=c[c.length-1]?.slice(0,200)}return{id:`tc-${s}-${Date.now()}`,tool:s,status:o,prompt:r,progressMessage:d,result:i,cost:l,createdAt:new Date().toISOString()}}function Ft({info:e,time:n,hideApprovalCards:s}){const{t:r}=E("common"),a=U(e.tool),o=e.status!=="running",i=e.status==="stopped",l=e.tool==="spawn_subagent"||e.tool==="spawn_subagents",d=!!(l&&e.subagentLogs&&e.subagentLogs.length>0),[c,u]=x.useState(()=>l&&e.status==="running"),h=x.useRef(!1),f=x.useMemo(()=>Kt(e),[e]),[g,p]=x.useState(!1),k=lt(e),_=x.useRef(null),b=d?e.subagentLogs[e.subagentLogs.length-1].content:"",m=x.useMemo(()=>Ke(e.args).length>0||!!e.result||!!e.error||!!e.subagentLogs&&e.subagentLogs.length>0,[e.args,e.result,e.error,e.subagentLogs]);return x.useEffect(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[e.liveOutput]),x.useEffect(()=>{l&&e.status==="running"&&d&&!h.current&&u(!0)},[l,e.status,d,e.subagentLogs?.length]),f?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"cursor-pointer",onClick:()=>p(!0),children:t.jsx($t,{session:f})}),g&&he.createPortal(t.jsx(Ut,{session:f,info:e,onClose:()=>p(!1)}),document.body)]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative py-0.5 min-w-0",children:[t.jsxs("div",{className:`flex items-center gap-2 min-w-0 rounded ${m?"cursor-pointer hover:bg-surface-elevated/30 transition-colors":""}`,onClick:()=>{m&&(Y(),u(v=>{const j=!v;return l&&e.status==="running"&&(h.current=!j),j}))},children:[t.jsx(J,{name:a.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"||i?"text-fg-tertiary":"text-green-500"}`}),t.jsxs("span",{className:`text-xs leading-snug shrink-0 ${e.status==="running"?"activity-text-shimmer":e.status==="error"||i?"text-fg-tertiary opacity-70":"text-fg-secondary"}`,children:[r(`execution.tools.${a.key}`,{defaultValue:a.label}),e.status==="running"?"…":""]}),m&&t.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${c?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.status==="running"&&t.jsxs("svg",{className:"w-3 h-3 animate-spin shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),e.durationMs!=null&&e.status!=="running"&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:K(e.durationMs)}),k&&t.jsxs("span",{className:"font-mono text-[11px] text-fg-tertiary truncate min-w-0",title:k,children:[t.jsx("span",{className:"select-none opacity-70",children:"$ "}),k.split(`
|
|
8
|
+
`)[0]]}),d&&t.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0 opacity-60",children:r("execution.toolSteps",{count:e.subagentLogs.filter(v=>v.eventType==="tool_end").length})})]}),e.liveOutput&&e.status==="running"&&t.jsx("pre",{ref:_,className:"mt-1 font-mono text-[11px] text-fg-tertiary bg-surface-secondary/60 rounded px-2 py-1.5 overflow-x-hidden whitespace-pre-wrap break-all",children:e.liveOutput.length>ae?e.liveOutput.slice(e.liveOutput.length-ae):e.liveOutput}),!c&&l&&e.status==="running"&&b&&t.jsx("div",{className:"mt-1 ml-[23px] font-mono text-[11px] text-fg-tertiary truncate",title:b,children:b}),c&&m&&t.jsx("div",{className:"mt-1 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-x-hidden",children:t.jsx(Ot,{info:e,time:n})})]}),o&&!s&&(()=>{const v=Fe(e.tool,e.result);if(v)return t.jsx(Qe,{info:v});const j=We(e.tool,e.result);return j?t.jsx(Ze,{info:j}):null})()]})}function Wt({content:e,time:n,defaultExpanded:s}){const{t:r}=E("common"),[a,o]=x.useState(s??!1);return x.useEffect(()=>{s&&o(!0)},[s]),t.jsxs("div",{className:"min-w-0 py-0.5 overflow-hidden",children:[t.jsxs("button",{onClick:()=>{Y(),o(i=>!i)},className:"flex items-center gap-2 text-xs w-full min-w-0",children:[t.jsx(J,{name:"sparkles",size:15,className:"shrink-0 text-violet-400"}),t.jsx("span",{className:`shrink-0 ${s?"activity-text-shimmer":"text-fg-secondary"}`,children:r("execution.thinking")}),t.jsx("svg",{className:`w-3 h-3 shrink-0 text-fg-tertiary transition-transform ${a?"rotate-90":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),a&&n&&t.jsx("span",{className:"ml-auto shrink-0 text-[10px] text-fg-tertiary tabular-nums",children:n})]}),a&&t.jsx("div",{className:"mt-1.5 ml-[23px] border-l-2 border-border-default/60 pl-3 overflow-hidden",children:t.jsx(O,{content:e,className:"text-xs text-fg-tertiary break-words"})})]})}const fe=x.memo(zt);function zt({entry:e,showTime:n,isLast:s,defaultThinkingExpanded:r,hideApprovalCards:a}){const{t:o}=E("common");if(e.type==="tool")return t.jsx(Ft,{info:e.info,showTime:n,time:e.time,isLast:s,hideApprovalCards:a},e.key);if(e.type==="thinking")return t.jsx(Wt,{content:e.content,time:e.time,showTime:n,defaultExpanded:r});if(e.type==="text")return e.content.startsWith("⚠")?t.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:t.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap break-words",children:e.content.replace(/^⚠\s*/,"")})}):t.jsx("div",{className:"min-w-0 pl-[23px] pr-1 overflow-hidden",children:t.jsx(O,{content:e.content,className:"text-sm text-fg-secondary break-words"})});if(e.type==="status"){const i=e.content==="completed"||e.content==="execution_finished",l=e.content==="started",d=e.content==="resumed",c=i?"text-green-600":l?"text-blue-600":d?"text-amber-600":"text-fg-tertiary",u=i?"bg-green-400":l?"bg-blue-400":d?"bg-amber-400":"bg-gray-500";return t.jsxs("div",{className:"flex items-center gap-2 py-0.5 min-w-0",children:[t.jsx("span",{className:"w-[15px] flex justify-center shrink-0",children:t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${u}`})}),t.jsx("span",{className:`text-xs capitalize ${c}`,children:o(`execution.statusKnown.${e.content}`,{defaultValue:e.content})})]})}return e.type==="error"?t.jsxs("div",{className:"flex items-start gap-2 py-0.5 min-w-0",children:[t.jsx(J,{name:"alert-circle",size:15,className:"shrink-0 mt-0.5 text-fg-tertiary"}),t.jsxs("span",{className:"text-xs text-fg-tertiary leading-relaxed break-words min-w-0",children:[t.jsx("span",{className:"font-medium",children:o("execution.errorPrefix")})," ",e.content.replace(/^⚠\s*/,"")]})]}):null}function Gn({entries:e,streamingText:n,isActive:s,onExpand:r,showRounds:a,embedded:o}){const{t:i}=E("common"),l=e.length>0?e[e.length-1]:null,d=e.filter(j=>j.type==="tool_end").length,c=e.filter(j=>j.type==="error").length,u=e.length>0?new Date(e[0].createdAt).getTime():Date.now(),h=l?new Date(l.createdAt).getTime():Date.now(),f=s?Date.now()-u:h-u,g=new Set(e.filter(j=>j.executionRound!=null).map(j=>j.executionRound)),p=g.size>0?Math.max(...g):void 0,k=a&&g.size>1;let _,b,m=null;if(s)if(n)_="✍",b=i("execution.compact.writingResponse"),m=ge(n.split(`
|
|
9
|
+
`).pop()??"",80);else if(l?.type==="tool_start"){const j=U(l.content);_=j.icon,b=`${i(`execution.tools.${j.key}`,{defaultValue:j.label})}...`;const C=l.metadata?.arguments&&typeof l.metadata.arguments=="object"?l.metadata.arguments.command:void 0;C&&(m=`$ ${ge(C.split(`
|
|
10
|
+
`)[0]??"",80)}`)}else if(l?.type==="tool_end"){const j=U(l.content);_=j.icon,b=i(`execution.tools.${j.key}`,{defaultValue:j.label})}else _="💭",b=i("execution.compact.thinking");else if(c>0&&l?.type==="error")_="❌",b=i("execution.compact.failed");else{const C=[...e].reverse().find(R=>R.type==="status")?.content??"";C==="completed"||C==="execution_finished"?(_="✅",b=i("execution.compact.completed")):(_="●",b=i("execution.compact.toolsExecuted",{count:d}))}const v=K(f);return t.jsx("div",{onClick:()=>{Y(),r()},className:`overflow-hidden transition-all cursor-pointer min-w-0 ${o?"hover:bg-surface-elevated/20":`rounded-lg border hover:brightness-110 ${s?"border-2 exec-card-active":"border border-border-default bg-surface-elevated/30 hover:border-brand-500/40"}`}`,children:t.jsxs("div",{className:o?"py-2":"px-3 py-2.5 bg-surface-primary/80",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s?t.jsxs("svg",{className:"w-3.5 h-3.5 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}):t.jsx("span",{className:"text-sm shrink-0",children:_}),t.jsx("span",{className:`text-xs font-medium truncate ${s?"text-fg-primary":"text-fg-secondary"}`,children:b})]}),v&&t.jsx("span",{className:"text-[10px] text-fg-tertiary tabular-nums shrink-0",children:v})]}),n?t.jsx("div",{className:`mt-1.5 ml-5.5 text-xs text-fg-secondary whitespace-pre-wrap break-words leading-relaxed ${o?"":"max-h-32 overflow-y-auto"}`,children:t.jsx(O,{content:n,className:"text-xs"})}):m?t.jsx("div",{className:"mt-1 ml-5.5 text-[11px] font-mono text-fg-tertiary truncate",children:m}):null,t.jsxs("div",{className:"flex items-center justify-between mt-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-fg-tertiary",children:[d>0&&t.jsxs("span",{children:["🔧 ",i("execution.compact.toolsLine",{count:d})]}),e.some(j=>j.type==="text"&&!j.metadata?.isThinking)&&t.jsxs("span",{children:["💬 ",i("execution.compact.text")]}),e.some(j=>j.type==="text"&&j.metadata?.isThinking)&&t.jsxs("span",{className:"text-purple-400",children:["💭 ",i("execution.compact.thinkingTag")]}),k&&p!=null&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"opacity-30",children:"·"}),t.jsx("span",{children:i("execution.compact.round",{n:p})}),t.jsx("span",{className:"opacity-30",children:"·"}),t.jsx("span",{children:i("execution.compact.rounds",{count:g.size})})]})]}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[i("execution.compact.showFullLog"),t.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]})]})})}function Gt(e){const n=new Map;for(const s of e){const r=s.executionRound??1;n.has(r)||n.set(r,[]);const a=be(s);a&&n.get(r).push(a)}return Array.from(n.entries()).sort(([s],[r])=>s-r).map(([s,r])=>({round:s,entries:r}))}function Hn({entries:e,streamingText:n,isActive:s,onCollapse:r,showRounds:a,embedded:o,expandThinking:i,hideApprovalCards:l}){const{t:d}=E("common"),c=x.useRef(null),[u,h]=x.useState(new Set),f=Gt(e),g=a&&f.length>1;x.useEffect(()=>{f.length>0&&h(b=>{const m=new Set(b);return m.add(f[f.length-1].round),m})},[f.length]),x.useEffect(()=>{o||!c.current||!s||(c.current.scrollTop=c.current.scrollHeight)},[e.length,n,s,o]);const p=b=>{Y(),h(m=>{const v=new Set(m);return v.has(b)?v.delete(b):v.add(b),v})},k=g?null:e.map(be).filter(b=>b!==null),_=k?xe(k):null;return t.jsxs("div",{className:`min-w-0 overflow-hidden ${o?"":"rounded-lg border border-border-default bg-surface-primary/50"}`,children:[r&&t.jsxs("div",{onClick:()=>{Y(),r()},className:`flex items-center cursor-pointer hover:bg-surface-elevated/40 transition-colors ${o?"justify-end py-0.5":"justify-between px-3 py-1.5 border-b border-border-default"}`,children:[!o&&t.jsx("span",{className:"text-[10px] text-fg-tertiary font-medium uppercase tracking-wider",children:d("execution.fullLog.title")}),t.jsxs("span",{className:"text-[10px] text-brand-500 flex items-center gap-0.5",children:[d("execution.fullLog.collapse"),t.jsx("svg",{className:"w-3 h-3 rotate-180",viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),t.jsxs("div",{ref:o?void 0:c,className:`space-y-2.5 min-w-0 overflow-x-hidden ${o?"py-1":"px-3 py-2 max-h-[60vh] overflow-y-auto scrollbar-thin"}`,children:[g?f.map(b=>{const m=u.has(b.round),v=xe(b.entries),j=b.entries.filter(C=>C.type==="tool"&&C.info?.status!=="running").length;return t.jsxs("div",{className:"border border-border-default/50 rounded-lg mb-2 overflow-hidden",children:[t.jsxs("button",{onClick:()=>p(b.round),className:"w-full flex items-center justify-between px-3 py-1.5 bg-surface-elevated/30 hover:bg-surface-elevated/50 transition-colors",children:[t.jsx("span",{className:"text-xs text-fg-secondary font-medium",children:d("execution.compact.round",{n:b.round})}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[10px] text-fg-tertiary",children:d("execution.compact.toolsLine",{count:j})}),t.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform ${m?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]})]}),m&&t.jsx("div",{className:"px-3 py-1.5 space-y-2.5",children:v.map((C,R)=>t.jsx(fe,{entry:C,showTime:!1,isLast:R===v.length-1,defaultThinkingExpanded:!!i,hideApprovalCards:l},R))})]},b.round)}):_&&_.map((b,m)=>t.jsx(fe,{entry:b,showTime:!1,isLast:m===_.length-1,defaultThinkingExpanded:!!i,hideApprovalCards:l},m)),s&&n&&t.jsx(qt,{content:n}),s&&!n&&t.jsx(Dt,{})]})]})}function Vn({priority:e}){const{t:n}=E(["common","team"]),s=e==="high"||e==="critical",r=e&&e!=="normal"?` · ${n(`common:priority.${e}`,{defaultValue:e})}`:"";return t.jsxs("div",{className:`inline-flex items-center gap-1 mt-1.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${s?"bg-amber-500/10 text-amber-500 border border-amber-500/20":"bg-brand-500/10 text-brand-400 border border-brand-500/20"}`,children:[t.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),t.jsx("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]}),t.jsxs("span",{children:[n("team:notifications.badgeLabel"),r]})]})}function Xn({name:e,agentId:n,agents:s,onViewProfile:r}){const{t:a}=E(["team","common"]),[o,i]=x.useState(!1),l=x.useRef(null),d=n?s.find(c=>c.id===n):s.find(c=>c.name===e);return x.useEffect(()=>{if(!o)return;const c=u=>{l.current&&!l.current.contains(u.target)&&i(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[o]),d?t.jsxs("span",{ref:l,className:"relative inline-block",children:[t.jsx("button",{onClick:()=>i(!o),className:"text-fg-tertiary hover:text-brand-500 cursor-pointer transition-colors",children:e}),o&&t.jsxs("div",{className:"absolute left-0 top-full mt-1.5 bg-surface-secondary border border-border-default rounded-xl shadow-2xl z-40 w-56 p-3 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Pe,{name:d.name,avatarUrl:d.avatarUrl,size:28,bgClass:"bg-brand-500/15 text-brand-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-xs text-fg-primary font-medium truncate",children:d.name}),t.jsxs("div",{className:"text-[10px] text-fg-tertiary",children:[d.role," · ",d.agentRole??a("page.workerRole")]})]}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${d.status==="working"?"bg-blue-400 animate-pulse":d.status==="error"?"bg-red-400":"bg-green-400"}`})]}),t.jsx("button",{onClick:()=>{i(!1),r?.(d.id)},className:"w-full text-center text-[10px] text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg py-1 transition-colors",children:a("page.viewProfileArrow")})]})]}):t.jsx("span",{children:e})}function Yn({agent:e,anchorRect:n,onClose:s,onViewProfile:r}){const{t:a}=E(["common","team"]),o=x.useRef(null);x.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]);const i=e.status==="idle"?"bg-green-400":e.status==="working"?"bg-blue-400 animate-pulse":e.status==="error"?"bg-red-400":"bg-gray-500",l=e.status==="idle"?a("common:status.online"):e.status==="working"?a("common:status.working"):e.status==="error"?a("common:status.error"):a("common:status.offline"),d=x.useCallback(c=>{if(!c)return;o.current=c;const u=c.getBoundingClientRect(),h=window.innerWidth,f=window.innerHeight,g=8;u.right>h-g&&(c.style.left=`${Math.max(g,h-u.width-g)}px`),u.left<g&&(c.style.left=`${g}px`),u.bottom>f-g&&(c.style.top=`${Math.max(g,f-u.height-g)}px`)},[]);return t.jsxs("div",{ref:d,className:"fixed z-50 w-64 max-w-[calc(100vw-1rem)] bg-surface-secondary border border-border-default rounded-xl shadow-2xl p-4 space-y-3",style:{top:n.top+40,left:n.left},children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Pe,{name:e.name,avatarUrl:e.avatarUrl,size:40,bgClass:"bg-brand-500/15 text-brand-600"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm text-fg-primary font-medium truncate",children:e.name}),t.jsx("div",{className:"text-[11px] text-fg-tertiary",children:e.role}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${i}`}),t.jsx("span",{className:"text-[10px] text-fg-secondary",children:l}),e.agentRole&&t.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["· ",e.agentRole]})]})]})]}),t.jsx("button",{onClick:()=>{s(),r(e.id)},className:"w-full py-1.5 text-xs text-brand-500 hover:text-brand-500 border border-border-default hover:border-gray-600 rounded-lg transition-colors text-center",children:a("team:page.viewProfileArrow")})]})}function Ht(e){const n=String(e);return n.includes("MARKUS_UPSTREAM_ERROR")?!1:n.includes("CU_EXCEEDED")||n.includes("CU_MONTHLY_EXCEEDED")}const Vt="markus:credit-notif-muted";let $e=0;function Jn(){try{if(localStorage.getItem(Vt))return}catch{}const e=Date.now();e-$e<5*6e4||($e=e,window.dispatchEvent(new CustomEvent("markus:credit-exhausted")))}function Xt(e){const n=[...e.matchAll(/"message"\s*:\s*"((?:[^"\\]|\\.)*)"/g)].map(r=>{try{return JSON.parse(`"${r[1]}"`)}catch{return r[1]}}).map(r=>r.replace(/\s*\(request_id:[^)]*\)/gi,"").trim()).filter(Boolean);if(n.length)return n[n.length-1];const s=e.match(/\{[\s\S]*\}/);if(s)try{const r=JSON.parse(s[0]),a=r.error?.message??r.message;if(a)return a}catch{}return""}function Yt(e){const n=e.match(/\b(?:API error|HTTP|status(?: code)?)\s*:?\s*(\d{3})\b/i);if(n)return Number(n[1]);const s=e.match(/\b(\d{3})\s+(Unauthorized|Forbidden|Too Many Requests|Bad Gateway|Service Unavailable|Conflict)\b/i);return s?Number(s[1]):null}function Qn(e,n){const s=String(e);if(s.includes("AbortError")||s.includes("abort"))return"";const r=Xt(s),a=(l,d)=>n(`team:errors.${l}`,d);if(/CONTEXT OVERFLOW|maximum context length/i.test(s)){const l=s.match(/requested (\d+)\s*tokens/i)?.[1],d=s.match(/maximum context length is (\d+)\s*tokens/i)?.[1],c=u=>u?`${Math.round(Number(u)/1e3).toLocaleString()}k`:"—";return a("aiContextOverflow",{asked:c(l),limit:c(d)})}if(s.includes("MARKUS_UPSTREAM_ERROR"))return a("aiUpstreamBillingMismatch",{detail:r||a("defaultUpstreamBillingMismatch")});if(Ht(s)||s.includes("CU_EXCEEDED"))return a("markusCuExceeded");if(s.includes("CU_WINDOW_EXCEEDED"))return a("markusWindowExceeded");if(s.includes("MARKUS_RATE_LIMITED"))return a("markusRateLimited");if(/not available in your region/i.test(s))return a("aiRegionBlocked",{model:(s.match(/\[(?:markus|openrouter):([^\]]+)\]/i)?.[1]||"").trim()||"—"});const o=Yt(s);if(o===401||/unauthorized|invalid.?api.?key/i.test(s))return a("ai401",{detail:r||a("defaultInvalidApiKey")});if(o===402)return a("ai402",{detail:r||a("defaultInsufficientCredits")});if(o===429||/rate.?limit/i.test(s))return a("ai429",{detail:r||a("defaultTooManyRequests")});if(o===409||/conflict/i.test(s))return a("ai409",{detail:r||a("defaultConflict")});if(o===502||/bad.?gateway/i.test(s))return a("ai502",{detail:r||a("defaultUpstreamDown")});if(o===503||/service.?unavailable/i.test(s))return a("ai503",{detail:r||a("defaultServiceDown")});const i=(r||s).replace(/https?:\/\/[^\s]*openrouter\.ai[^\s]*/gi,"").trim();return a("aiGeneric",{detail:(i||s).slice(0,120)})}function Zn({msg:e,onCopy:n,onRetry:s,onResume:r,onReply:a,onRemember:o,isCopied:i,isLastAgentMsg:l,showRemember:d}){const{t:c}=E(["team","common"]),u=e.isError||e.sender==="agent"&&e.text.startsWith("⚠"),h=e.isStopped,f=e.emptyReply===!0,g=l!==!1,p=ht(d,e.sender)&&!!o;return t.jsxs("div",{className:"flex items-center flex-wrap gap-0.5 mt-1",children:[t.jsxs("button",{onClick:()=>n(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("common:copy"),children:[i?t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polyline",{points:"20 6 9 17 4 12"})}):t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),t.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]}),c(i?"common:copied":"common:copy")]}),g&&r&&t.jsxs("button",{onClick:()=>r(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-green-500 hover:text-green-400 hover:bg-green-500/10 transition-colors",title:c("page.messageActions.resumeTitle"),children:[t.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:t.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),c("page.messageActions.resumeTitle")]}),g&&h&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-brand-500 hover:text-brand-500 hover:bg-brand-500/10 transition-colors",title:c("page.messageActions.reaskTitle"),children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.reaskTitle")]}),g&&(u||f)&&!h&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-amber-600 hover:text-amber-600 hover:bg-amber-500/10 transition-colors",title:c("page.messageActions.retryTitle"),children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.retryTitle")]}),g&&!u&&!f&&!h&&e.sender==="agent"&&s&&t.jsxs("button",{onClick:()=>s(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.retryTitle"),children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"23 4 23 10 17 10"}),t.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),c("page.messageActions.retryTitle")]}),a&&t.jsxs("button",{onClick:()=>a(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.replyTitle"),children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[t.jsx("polyline",{points:"9 17 4 12 9 7"}),t.jsx("path",{d:"M20 18v-2a4 4 0 00-4-4H4"})]}),c("page.messageActions.replyTitle")]}),p&&t.jsxs("button",{type:"button",onClick:()=>o(e),className:"flex items-center gap-1 px-2 py-0.5 rounded text-[11px] text-fg-tertiary hover:text-fg-primary hover:bg-surface-overlay/60 transition-colors",title:c("page.messageActions.rememberTitle"),children:[t.jsxs("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M12 2a7 7 0 00-4 12.7V19a1 1 0 001 1h6a1 1 0 001-1v-4.3A7 7 0 0012 2z"}),t.jsx("path",{d:"M9 22h6"})]}),c("page.messageActions.rememberTitle")]}),e.sender==="agent"&&t.jsx("span",{className:"ml-1 px-1 text-[10px] leading-none text-fg-tertiary/70 select-none whitespace-nowrap",children:c("page.messageActions.aiGeneratedDisclaimer")})]})}function es({busy:e,onConfirm:n,onCancel:s}){const{t:r}=E(["team","common"]),[a,o]=x.useState("");return he.createPortal(t.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[10050] p-4",onClick:s,children:t.jsxs("div",{className:"bg-surface-secondary border border-border-default rounded-xl p-6 w-[400px] max-w-[calc(100vw-2rem)] shadow-2xl",onClick:i=>i.stopPropagation(),children:[t.jsx("h3",{className:"font-semibold text-base text-fg-primary",children:r("page.messageActions.rememberModalTitle")}),t.jsx("p",{className:"text-sm text-fg-secondary mt-1.5 leading-relaxed",children:r("page.messageActions.rememberModalHint")}),t.jsx("textarea",{value:a,onChange:i=>o(i.target.value),placeholder:r("page.messageActions.rememberModalPlaceholder"),rows:3,disabled:e,className:"mt-3 w-full px-3 py-2 text-sm bg-surface-primary border border-border-default rounded-lg outline-none focus:border-brand-500/50 resize-y min-h-[72px]"}),t.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[t.jsx("button",{type:"button",onClick:s,disabled:e,className:"px-4 py-1.5 text-sm text-fg-secondary hover:text-fg-primary rounded-lg transition-colors",children:r("page.messageActions.rememberCancel")}),t.jsx("button",{type:"button",onClick:()=>n(a),disabled:e,className:"px-4 py-1.5 text-sm bg-brand-600 hover:bg-brand-500 disabled:opacity-60 text-on-brand rounded-lg transition-colors",children:e?r("common:loading",{defaultValue:"…"}):r("page.messageActions.rememberConfirm")})]})]})}),document.body)}const Jt=/[.!?。!?…::]\s*$|["'”’)\]}】》]\s*$|\n\s*$/,Qt=/^(?:\n|#{1,6}[ \t]|[-*+][ \t]|\d+[.)][ \t]|>|\||```|~~~|---)/;function Zt(e,n){return!(!e.replace(/\s+$/,"")||Jt.test(e)||!n.trim()||Qt.test(n))}function en(e,n,s){return/\s$/.test(e)||/^\s/.test(n)?e+n:s?.spaceNeeded?`${e} ${n}`:e+n}function tn(e){const n=o=>o.type!=="text"||o.metadata?.isThinking===!0,s=[];let r=[],a=-1;for(const o of e){if(n(o)){r.push(o);continue}const i=a>=0?s[a]:void 0;if(i&&r.length>0&&o.metadata?.paragraphBreak!==!0&&i.metadata?.paragraphAfter!==!0&&Zt(i.content,o.content)){i.content=en(i.content,o.content,{spaceNeeded:i.metadata?.trailingSpace===!0||o.metadata?.leadingSpace===!0}),s.push(...r),r=[];continue}r.length>0&&(s.push(...r),r=[]),s.push(o),a=s.length-1}return r.length>0&&s.push(...r),s}function nn(e){return e.type!=="text"||e.metadata?.isThinking===!0}function et(e){const n=Date.parse(e[0]?.createdAt??""),s=Date.parse(e[e.length-1]?.createdAt??"");return Number.isFinite(n)&&Number.isFinite(s)&&s>n?s-n:0}function sn(e){let n=0,s=0,r=0,a=null,o=0;for(const l of e){if(l.type==="text"&&l.metadata?.isThinking===!0){n++;continue}if(l.type==="tool_start"){s++,a=l.content;continue}if(l.type==="tool_end"){l.metadata?.success===!1&&o++,a=null;continue}l.type==="subagent_start"&&r++,l.type==="error"&&o++}const i=et(e);return{thinkingCount:n,toolCount:s,subagentCount:r,running:a!==null,...a?{runningTool:a}:{},tailIsThinking:e[e.length-1]?.type==="text"&&e[e.length-1]?.metadata?.isThinking===!0,elapsedMs:i,errorCount:o}}function tt(e){const n=[];let s=[],r=0;const a=()=>{s.length!==0&&(n.push({kind:"process",key:`proc_${r}`,entries:s,summary:sn(s)}),s=[])};return e.forEach((o,i)=>{if(nn(o)){s.length===0&&(r=i),s.push(o);return}a(),n.push({kind:"text",key:`text_${i}`,entry:o})}),a(),n}function rn(e){for(let n=e.length-1;n>=0;n--)if(e[n].kind==="text")return n;return-1}function an(e,n){if(e.length===0)return{blocks:e,foldedCount:0,foldableCount:0};if(n.interrupted)return{blocks:e,foldedCount:0,foldableCount:0};if(n.isStreaming)return{blocks:e,foldedCount:0,foldableCount:0};const s=rn(e),r=s>0?s:0,a=r>0?e.slice(r):e,o=n.expanded?e:a,i=n.expanded?0:e.length-a.length;return{blocks:o,foldedCount:i,foldableCount:r}}function on(e,n){const s=Math.max(0,Math.round(e/1e3));return s<60?n("common:execution.workedForSeconds",{seconds:s}):n("common:execution.workedForMinutes",{minutes:Math.floor(s/60),seconds:s%60})}function nt({state:e}){return e==="running"?t.jsx("span",{className:"animate-spin inline-flex",children:t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round","aria-hidden":"true",children:t.jsx("path",{d:"M12 3a9 9 0 1 0 9 9"})})}):t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:t.jsx("path",{d:"M20 6.5 9.5 17 4 11.5"})})}function st({entries:e,summary:n,isStreaming:s,isLastBlock:r,hideApprovalCards:a,reconnecting:o,onExpand:i}){const{t:l}=E("common"),[d,c]=x.useState(!1),u=x.useMemo(()=>xe(e.map(be).filter(b=>b!==null)),[e]),h=!!(s&&(r||n.running))||!!o,f=h?"running":"done",g=o?l("execution.reconnecting"):h&&n.runningTool?l("execution.processRun.runningTool",{tool:l(`execution.tools.${n.runningTool}`,{defaultValue:n.runningTool})}):null,p=[];n.thinkingCount>0&&p.push(l("execution.processRun.thinking")),n.toolCount>0&&p.push(l("execution.processRun.tools",{count:n.toolCount})),n.subagentCount>0&&p.push(l("execution.processRun.subagents",{count:n.subagentCount})),n.errorCount>0&&p.push(l("execution.processRun.errors",{count:n.errorCount})),n.elapsedMs>=1e3&&p.push(K(n.elapsedMs));const k=h?g??l("execution.thinkingEllipsis"):p.join(" · ")||l("execution.processRun.label"),_=l(`execution.processRun.state.${f}`);return t.jsxs("div",{className:"min-w-0",children:[t.jsxs("button",{type:"button",onClick:()=>{c(!d),d||i?.()},"aria-expanded":d,"data-process-state":f,title:k,className:"group relative w-full flex items-center gap-2 px-2 py-1 rounded-lg text-left text-[11px] leading-tight text-fg-tertiary bg-surface-elevated/25 hover:bg-surface-elevated/45 border border-border-default/40 hover:border-border-default/70 overflow-hidden transition-colors cursor-pointer select-none",children:[h&&t.jsx("span",{className:"process-run-sweep","aria-hidden":"true"}),t.jsx("span",{className:`relative shrink-0 flex items-center justify-center w-3 h-3 ${f==="running"?"text-brand-400":""}`,children:t.jsx(nt,{state:f})}),t.jsx("span",{className:"sr-only",children:_}),t.jsx("span",{className:`relative min-w-0 truncate ${h&&!g?"activity-text-shimmer":""}`,children:h||p.length===0?k:p.map((b,m)=>t.jsxs("span",{children:[m>0?" · ":"",b]},b+m))}),t.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${d?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),d&&t.jsx("div",{className:"mt-1 ml-[7px] pl-3 border-l-2 border-border-default/50 space-y-2 min-w-0 overflow-hidden",children:u.length>0?u.map((b,m)=>t.jsx(fe,{entry:b,showTime:!1,hideApprovalCards:a},m)):t.jsx("div",{className:"py-1 text-[11px] text-fg-tertiary",children:l("execution.noToolDetail")})})]})}function ts({entries:e,isStreaming:n,streamingText:s,className:r}){const a=x.useMemo(()=>tt(e),[e]);return t.jsxs("div",{className:`space-y-2 min-w-0 overflow-x-hidden ${r??""}`,children:[a.map((o,i)=>o.kind==="text"?o.entry.content.trim()?t.jsx(O,{content:o.entry.content},o.key):null:t.jsx(st,{entries:o.entries,summary:o.summary,isStreaming:n,isLastBlock:n&&i===a.length-1},o.key)),n&&s?t.jsx(O,{content:s}):null]})}function De(e,n,s){if(!e)return[];const r=[];let a=0;const o=n??"";let l=s?new Date(s).getTime():Date.now();const d=e.some(m=>m.createdAt),c=m=>{if(m.createdAt)return m.createdAt;if(d)return new Date(l).toISOString();const v=new Date(l).toISOString();return m.type==="tool"&&m.durationMs?l+=m.durationMs:l+=1e3,v};let u="",h="",f="";const g=()=>{const m=u.trim();if(m){const v=r[r.length-1];v&&v.type==="text"&&v.metadata?.isThinking?v.content+=(v.content?`
|
|
11
|
+
|
|
12
|
+
`:"")+m:r.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"text",content:m,createdAt:f,metadata:{isThinking:!0}})}u=""},p=()=>{const m=h,v=m.trim();if(v){const j={};/^\s*\n/.test(m)&&(j.paragraphBreak=!0),/\n\s*\n\s*$/.test(m)&&(j.paragraphAfter=!0),/\s$/.test(m)&&(j.trailingSpace=!0),/^\s/.test(m)&&(j.leadingSpace=!0),r.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"text",content:v,createdAt:f,...Object.keys(j).length>0?{metadata:j}:{}})}h=""},k="<think>",_="</think>",b=m=>{let v=0,j=!1;for(;v<m.length;)if(j){const C=m.indexOf(_,v);C===-1?v=m.length:(j=!1,v=C+_.length)}else{const C=m.indexOf(k,v);C===-1?(h+=m.slice(v),v=m.length):(h+=m.slice(v,C),j=!0,v=C+k.length)}};for(const m of e)if(f=c(m),m.type==="tool"){p();const v=m.createdAt&&m.durationMs?new Date(new Date(m.createdAt).getTime()-m.durationMs).toISOString():f;r.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"tool_start",content:m.tool,metadata:{arguments:m.args,...m.status==="running"&&m.subagentLogs?.length?{subagentLogs:m.subagentLogs}:{}},createdAt:v}),m.status!=="running"&&r.push({id:`cseg_${a}`,sourceType:"chat",sourceId:"",agentId:o,seq:a++,type:"tool_end",content:m.tool,metadata:{arguments:m.args,result:m.result,error:m.error,durationMs:m.durationMs,success:m.status!=="error",...m.subagentLogs?.length?{subagentLogs:m.subagentLogs}:{}},createdAt:f})}else m.thinking&&(p(),u+=m.thinking,g()),b(ve(m.content).cleaned);return p(),tn(r)}const ns=x.memo(function({msg:n,isStreaming:s,liveActivities:r,onMentionClick:a,knownNames:o}){const{t:i}=E(["team","common"]),l=n.isStopped,[d,c]=x.useState(!1),[u,h]=x.useState(null),f=x.useRef(!1),g=x.useCallback(()=>{!n.needsDetail||!n.sessionId||f.current||(f.current=!0,P.sessions.getMessageDetail(n.sessionId,n.id).then(({message:A})=>{const L=A.metadata?.segments;L?.length&&h(Ve(L))}).catch(()=>{}))},[n.needsDetail,n.sessionId,n.id]);x.useEffect(()=>{d&&g()},[d,g]);const p=u??n.segments,k=A=>A.type==="text"?A.content.length+(A.thinking?.length??0):(A.result?.length??0)+(A.subagentLogs?.length??0)*1e3+(A.liveOutput?.length??0),_=p?p.length+":"+(p.length>0?k(p[p.length-1]):0):"",b=p?p.reduce((A,L)=>A+(L.type==="tool"?L.subagentLogs?.length??0:0),0):0,m=x.useMemo(()=>p&&p.length>0?De(p,n.agentId,n.rawCreatedAt):[],[_,b,n.agentId,n.rawCreatedAt]),v=n.committedSegments,j=v?v.length+":"+(v.length>0?k(v[v.length-1]):0):"",C=v?v.reduce((A,L)=>A+(L.type==="tool"?L.subagentLogs?.length??0:0),0):0,R=x.useMemo(()=>s?m:v&&v.length>0?De(v,n.agentId,n.rawCreatedAt):m,[s,j,C,n.agentId,n.rawCreatedAt,m]);if(p!==void 0&&p.length>0){const L=p.filter(N=>N.type==="text").map(N=>N.content).join(""),B=N=>N.replace(/\n*<!--\s*notify_context:\s*[\s\S]*?-->/g,"").replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim()||null,q=(L?B(L):null)||(n.text?B(n.text):null),I=tt(R),oe=I.some(N=>N.kind==="text"),ie=!!(l||n.isError),Q=an(I,{isStreaming:s,interrupted:ie,expanded:d}),le=Q.blocks,ce=Q.foldableCount>0,H=on(et(R),i),F=[];for(const N of p){if(N.type!=="tool")continue;const V=Fe(N.tool,N.result);if(V){F.push({key:`task-${V.taskId}`,kind:"task",info:V});continue}const X=We(N.tool,N.result);X&&F.push({key:`req-${X.requirementId}`,kind:"req",info:X})}return t.jsxs("div",{className:"space-y-2 min-h-[1em] min-w-0 overflow-x-hidden",children:[ce&&t.jsxs("button",{type:"button",onClick:()=>c(N=>!N),"aria-expanded":d,"data-worked-summary":"true",title:H,className:"group relative w-full flex items-center gap-2 px-2 py-1 rounded-lg text-left text-[11px] leading-tight text-fg-tertiary bg-surface-elevated/25 hover:bg-surface-elevated/45 border border-border-default/40 hover:border-border-default/70 overflow-hidden transition-colors cursor-pointer select-none",children:[t.jsx("span",{className:"relative shrink-0 flex items-center justify-center w-3 h-3",children:t.jsx(nt,{state:"done"})}),t.jsx("span",{className:"relative min-w-0 truncate",children:H}),t.jsx("svg",{className:`relative ml-auto w-3 h-3 shrink-0 transition-transform ${d?"rotate-180":""}`,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z",clipRule:"evenodd"})})]}),le.map(N=>N.kind==="text"?t.jsx(O,{content:N.entry.content,onMentionClick:a,knownNames:o},N.key):t.jsx(st,{entries:N.entries,summary:N.summary,isStreaming:s,isLastBlock:N.key===I[I.length-1]?.key,hideApprovalCards:!0,reconnecting:!!n.reconnecting,onExpand:g},N.key)),I.length===0&&s&&t.jsx(Ne,{activities:r,isActive:!0}),!oe&&q&&t.jsx(O,{content:q,onMentionClick:a,knownNames:o}),F.map(N=>N.kind==="task"?t.jsx(Qe,{info:N.info},N.key):t.jsx(Ze,{info:N.info},N.key)),!s&&!q&&I.length===0&&F.length===0&&!l&&n.emptyReply===!0&&t.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:t.jsx("span",{children:i("page.emptyReply")})}),!s&&(n.isError||n.text.startsWith("⚠"))&&n.text&&!p?.some(N=>N.type==="text"&&N.content&&(N.content===n.text||N.content.startsWith("⚠")))&&t.jsxs("div",{className:"flex items-start gap-1.5 mt-2 text-[11px] text-fg-tertiary leading-relaxed",children:[t.jsxs("svg",{className:"w-3 h-3 mt-0.5 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"9"}),t.jsx("path",{d:"M12 8v4.5M12 16h.01",strokeLinecap:"round"})]}),t.jsxs("span",{className:"min-w-0",children:[t.jsx("span",{className:"text-fg-secondary",children:i("page.endedEarly")}),t.jsx("span",{className:"mx-1",children:"·"}),t.jsx("span",{children:n.text.replace(/^⚠\s*/,"")})]})]}),l&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:i("page.stopped")})]})]})}const z=(n.activities?.length??0)>0,D=n.text?n.text.replace(/<think>[\s\S]*?(<\/think>|$)/g,"").replace(/<(invoke|function_calls|antml:\w+)\b[\s\S]*?(<\/\1>|$)/g,"").replace(/<\/?(invoke|function_calls|antml:\w+)[^>]*>/g,"").trim():"";return t.jsxs(t.Fragment,{children:[(s||z)&&t.jsx(Ne,{activities:s?r:n.activities??[],isActive:s,persistent:!s&&z}),D?n.isError||D.startsWith("⚠")?t.jsx("p",{className:"text-[13px] text-fg-tertiary leading-relaxed whitespace-pre-wrap",children:D.replace(/^⚠\s*/,"")}):t.jsx(O,{content:D,onMentionClick:a,knownNames:o}):null,!s&&!D&&!z&&!l&&n.sender==="agent"&&n.emptyReply===!0&&t.jsx("div",{className:"flex items-start gap-1.5 text-[13px] text-fg-tertiary leading-relaxed",children:t.jsx("span",{children:i("page.emptyReply")})}),l&&t.jsxs("div",{className:"flex items-center gap-1.5 mt-1.5 text-[11px] text-fg-tertiary",children:[t.jsx("svg",{className:"w-3 h-3 shrink-0",viewBox:"0 0 24 24",fill:"currentColor",children:t.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),t.jsx("span",{children:i("page.stopped")})]})]})});export{Dt as $,bn as A,Un as B,zn as C,vn as D,zt as E,mn as F,Tn as G,ve as H,Dn as I,qn as J,On as K,Xn as L,xn as M,Ne as N,ns as O,ts as P,Vn as Q,Zn as R,Yn as S,es as T,Kn as U,Wn as V,Bn as W,Pn as X,Fn as Y,fn as Z,qt as _,Qn as a,xe as a0,be as a1,Hn as a2,Gn as a3,Cn as b,Sn as c,Ln as d,Mn as e,pn as f,U as g,En as h,yn as i,_n as j,Ve as k,Nn as l,jn as m,$n as n,Ht as o,Rn as p,Jn as q,In as r,An as s,un as t,gn as u,wn as v,hn as w,He as x,kn as y,Ge as z};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-
|
|
2
|
-
import{j as a,r as i,_ as f}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-C3gog80t.js","assets/index-BY_HjdWI.js","assets/index-CnyolIne.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as a,r as i,_ as f}from"./index-BY_HjdWI.js";const x=i.lazy(()=>f(()=>import("./MarkdownMessage-C3gog80t.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),b=new Set(["ts","tsx","js","jsx","mjs","cjs","py","go","rs","java","kt","kts","c","cc","cpp","cxx","h","hpp","hxx","cs","rb","php","swift","scala","sh","bash","zsh","fish","ps1","sql","yaml","yml","toml","xml","css","scss","less","vue","svelte","graphql","gql","proto","dockerfile","makefile","cmake","rsx","r","lua","pl","pm","ex","exs","erl","hs","clj","zig","nim","dart","gradle","tf","hcl"]);function v(e){const t=e.split(/[/\\]/).pop()?.toLowerCase()||"";if(t==="dockerfile"||t==="makefile")return"code";const r=t.includes(".")?t.split(".").pop():"";switch(r){case"md":case"markdown":return"markdown";case"html":case"htm":return"html";case"json":case"jsonc":return"json";case"csv":case"tsv":return"csv";default:return r&&b.has(r)?"code":r?"text":void 0}}function w(e){const t=e.trimStart();if(/^<!doctype\s+html/i.test(t)||/^<html[\s>]/i.test(t))return"html";if(t.startsWith("{")||t.startsWith("["))try{return JSON.parse(e),"json"}catch{}}function S(e){if(e.format)return e.format;if(e.reference){const t=v(e.reference);if(t)return t}if(e.content){const t=w(e.content);if(t)return t}return e.reference?"text":"markdown"}function y({content:e,className:t,onSelection:r}){const c=i.useRef(null),[l,h]=i.useState(null);i.useEffect(()=>{const o=d=>{d.data?.type==="__htmlpreview_height"&&typeof d.data.height=="number"&&h(d.data.height),d.data?.type==="__htmlpreview_selection"&&r&&r(d.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const m=`<script>
|
|
3
3
|
(function(){
|
|
4
4
|
function getXPath(el){
|
|
5
5
|
if(!el||el.nodeType!==1)return'';
|
|
@@ -45,7 +45,7 @@ import{j as a,r as i,_ as f}from"./index-CIrsLoqm.js";const b=i.lazy(()=>f(()=>i
|
|
|
45
45
|
},'*');
|
|
46
46
|
});
|
|
47
47
|
})();
|
|
48
|
-
<\/script>`,
|
|
48
|
+
<\/script>`,p=`<script>
|
|
49
49
|
(function(){
|
|
50
50
|
function send(){
|
|
51
51
|
var h = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
@@ -55,7 +55,7 @@ import{j as a,r as i,_ as f}from"./index-CIrsLoqm.js";const b=i.lazy(()=>f(()=>i
|
|
|
55
55
|
else window.addEventListener('load',send);
|
|
56
56
|
new ResizeObserver(send).observe(document.body);
|
|
57
57
|
})();
|
|
58
|
-
<\/script>`,g="<style>html,body{overflow:hidden!important;height:auto!important;}</style>",u=i.useMemo(()=>{const o=g+m
|
|
58
|
+
<\/script>`,g="<style>html,body{overflow:hidden!important;height:auto!important;}</style>",u=i.useMemo(()=>{const o=g+p+m;if(/<html[\s>]/i.test(e)){let n=e;return/<\/body>/i.test(n)?n=n.replace(/<\/body>/i,`${o}</body>`):/<\/html>/i.test(n)?n=n.replace(/<\/html>/i,`${o}</html>`):n=n+o,n}const s=!document.documentElement.classList.contains("light")&&(document.documentElement.classList.contains("dark")||document.documentElement.classList.contains("cyberpunk")||!window.matchMedia("(prefers-color-scheme: light)").matches)?{text:"#e4e4e7",bg:"transparent",border:"#3f3f46",thBg:"rgba(63,63,70,0.5)",link:"#818cf8",codeBg:"rgba(63,63,70,0.5)",preBg:"rgba(24,24,27,0.8)",heading:"#fafafa"}:{text:"#1c1c1e",bg:"transparent",border:"#d1d5db",thBg:"rgba(0,0,0,0.04)",link:"#4f46e5",codeBg:"rgba(0,0,0,0.05)",preBg:"rgba(0,0,0,0.03)",heading:"#111827"};return`<!DOCTYPE html>
|
|
59
59
|
<html>
|
|
60
60
|
<head>
|
|
61
61
|
<meta charset="utf-8">
|
|
@@ -78,5 +78,5 @@ import{j as a,r as i,_ as f}from"./index-CIrsLoqm.js";const b=i.lazy(()=>f(()=>i
|
|
|
78
78
|
h1, h2, h3, h4, h5, h6 { color: ${s.heading}; }
|
|
79
79
|
</style>
|
|
80
80
|
</head>
|
|
81
|
-
<body>${e}${
|
|
82
|
-
</html>`},[e]);return a.jsx("iframe",{ref:c,srcDoc:u,sandbox:"allow-scripts",className:t,style:{width:"100%",height:l!=null?`${l}px`:"auto",minHeight:l==null?"200px":void 0,border:"none",borderRadius:"8px",background:"transparent"},title:"HTML Preview"})}function k({content:e,className:t}){const r=i.useMemo(()=>{try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e]);return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${t??""}`,children:r})}function j({content:e,format:t,className:r,basePath:c,onHtmlSelection:l}){switch(t){case"html":return a.jsx(y,{content:e,className:r,onSelection:l});case"json":return a.jsx(k,{content:e,className:r});case"csv":case"text":case"code":return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${r??""}`,children:e});default:return a.jsx(i.Suspense,{fallback:a.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:a.jsx(
|
|
81
|
+
<body>${e}${p}${m}</body>
|
|
82
|
+
</html>`},[e]);return a.jsx("iframe",{ref:c,srcDoc:u,sandbox:"allow-scripts",className:t,style:{width:"100%",height:l!=null?`${l}px`:"auto",minHeight:l==null?"200px":void 0,border:"none",borderRadius:"8px",background:"transparent"},title:"HTML Preview"})}function k({content:e,className:t}){const r=i.useMemo(()=>{try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}},[e]);return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${t??""}`,children:r})}function j({content:e,format:t,className:r,basePath:c,onHtmlSelection:l,copyVariant:h}){switch(t){case"html":return a.jsx(y,{content:e,className:r,onSelection:l});case"json":return a.jsx(k,{content:e,className:r});case"csv":case"text":case"code":return a.jsx("pre",{className:`text-xs font-mono whitespace-pre-wrap break-words bg-surface-primary/50 rounded-lg p-4 leading-relaxed text-fg-secondary ${r??""}`,children:e});default:return a.jsx(i.Suspense,{fallback:a.jsx("div",{className:"text-xs text-fg-tertiary",children:"Loading…"}),children:a.jsx(x,{content:e,className:r??"text-sm",basePath:c,copyVariant:h})})}}export{j as ContentRenderer,w as detectFormatFromContent,v as detectFormatFromPath,S as resolveFormat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as de,r as u,h as R,V as ue,$ as fe,k as N,j as r}from"./index-BY_HjdWI.js";const G=50*1024*1024,q=new Set(["markdown","html"]);function be(e){return e||"markdown"}function he(e){return q.has(be(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class Q extends S{constructor(){super("需要登录 Markus Hub 账号后才能分享产出物。"),this.name="NotLoggedIntoHubError"}}class pe extends S{bytes;limit;constructor(t,a){super(`产出物文件大小 ${t} 字节超过上限 ${a} 字节(50MB),请压缩或拒绝分享。`),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class me extends S{status;constructor(t,a){super(`Hub 请求失败 (HTTP ${t}): ${a}`),this.name="HubApiError",this.status=t}}function ge(e){const t=e.replace(/\s+/g,"");if(!t)return 0;let a=0;return t.endsWith("==")?a=2:t.endsWith("=")&&(a=1),Math.floor(t.length*3/4)-a}function C(e,t){const a=e&&typeof e=="object"?e:{},l=a.share??a.deliverable??{},s=m=>a[m]??l[m],i=s("id")??s("shareId")??"",c=s("slug"),o=c!=null?String(c):void 0,d=s("url")??s("shareUrl");let b=null;d!=null?b=String(d):o&&t&&(b=`${t.replace(/\/+$/,"")}/deliverable/${encodeURIComponent(o)}`);const f=s("reason")??s("rejectNote"),p=s("localDeliverableId")??s("localId");return{id:String(i),slug:o,visibility:s("visibility")??"public",status:s("status")??"pending_review",url:b,reason:f!=null?String(f):null,localId:p!=null?String(p):null}}class xe{basePath;fetchImpl;hubOrigin;constructor(t){this.getHubToken=t.getHubToken,this.hubOrigin=t.hubUrl,this.basePath=(t.proxyBasePath??"/api/hub").replace(/\/+$/,""),this.fetchImpl=t.fetch??(globalThis.fetch?globalThis.fetch.bind(globalThis):(()=>{throw new Error("fetch unavailable")}))}getHubToken;isHubLoggedIn(){return!!this.getHubToken()}assertHubLoggedIn(){if(!this.getHubToken())throw new Q}async doFetch(t,a){const l=this.getHubToken(),s={"Content-Type":"application/json",...a.headers};l&&(s.Authorization=`Bearer ${l}`);const i=await this.fetchImpl(`${this.basePath}${t}`,{...a,headers:s,credentials:"include"});let c=null;try{c=await i.json()}catch{c=null}if(!i.ok){const o=c&&typeof c=="object"&&"error"in c?String(c.error):i.statusText||`HTTP ${i.status}`;throw new me(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ge(t.fileBase64):0);if(a>G)throw new pe(a,G);const l={localDeliverableId:t.localId,visibility:t.visibility,title:t.title,summary:t.summary,tags:t.tags,filename:t.filename,format:t.format,producerAgent:{id:t.producerAgent.id,name:t.producerAgent.name,source:t.producerAgent.source}};t.content&&(l.content=t.content),t.fileBase64&&(l.fileBase64=t.fileBase64);const{data:s}=await this.doFetch("/deliverables/publish",{method:"POST",body:JSON.stringify(l)});return C(s,this.hubOrigin)}async pollStatus(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch(`/deliverables/status?localId=${encodeURIComponent(t)}`,{method:"GET"});return C(a,this.hubOrigin)}async listMine(){this.assertHubLoggedIn();const{data:t}=await this.doFetch("/deliverables/mine",{method:"GET"}),a=t&&typeof t=="object"?t:{};return(Array.isArray(a.shares)?a.shares:[]).map(s=>C(s,this.hubOrigin))}async revoke(t){this.assertHubLoggedIn();const{data:a}=await this.doFetch("/deliverables/revoke",{method:"POST",body:JSON.stringify({localId:t})});return{...C(a,this.hubOrigin),status:"revoked",url:null}}}function ye(e,t){return new xe({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const ve=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,ke=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function X(e){return ve.test(e)?"image":ke.test(e)?"media":"other"}function je(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function J(e){const t=e.match(/!?\[[^\]]*\]\(([^)]+)\)/);if(t)return t[1].trim().split(/\s+(?="|')/)[0].trim()||null;const a=e.match(/(?:src|href|poster)\s*=\s*["']([^"']+)["']/i);return a?a[1]:null}function Z(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Y(e,t){if(!e)return null;const a=e.trim(),l=a.match(/^\/api\/files\/(?:image|stream|preview)\?path=([^&]+)/i);if(l)try{return decodeURIComponent(l[1])||null}catch{return l[1]||null}return/^file:\/\//i.test(a)?je(a).replace(/\\/g,"/"):/^[a-zA-Z]:[\\/]/.test(a)?a.replace(/\\/g,"/"):a.startsWith("/")?a:t&&(a.startsWith("./")||a.startsWith("../")||!a.includes("://"))?`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${a.replace(/^\.\//,"").replace(/\\/g,"/")}`:null}function we(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}const i=/<[a-zA-Z][^>]*(?:src|href|poster)\s*=\s*["'][^"']+["'][^>]*>/gi;for(const c of e.matchAll(i)){const o=c[0],d=J(o);if(!d||!Z(d))continue;const b=Y(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:X(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ne(e,t){let a=e;for(const[l,s]of t){const i=Se(l,s);a=a.split(l).join(i)}return a}function Se(e,t){const a=e.match(/^(!?\[[^\]]*\])\([^)]*\)$/);if(a)return`${a[1]}(${t})`;const l=e.match(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i);return l?e.replace(/(src|href|poster)(\s*=\s*)(["'])[^"']*\3/i,`${l[1]}${l[2]}${l[3]}${t}${l[3]}`):t}function Ve(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function He(e,t,a){const l=new Map,s=new Map(e.map(i=>[i.localPath,i]));for(const i of t){if(!i.key)continue;const c=s.get(i.key);!c||!i.url||l.set(c.raw,Ve(i.url,a))}return l}async function Ie(e){try{const t=N.files.streamUrl(e),a=await fetch(t).then(d=>d.ok?d.blob():null);if(!a)return null;const l=await a.arrayBuffer(),s=new Uint8Array(l);let i="";const c=32768;for(let d=0;d<s.length;d+=c)i+=String.fromCharCode.apply(null,Array.from(s.subarray(d,d+c)));const o=e.split("/").pop()||"media";return{base64:btoa(i),filename:o}}catch{return null}}async function Te(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ie(c.localPath);o&&l.push({key:c.localPath,filename:o.filename,base64:o.base64})}if(l.length===0)return a;const{files:s,errors:i}=await R.uploadMediaBatch(l);return i.length>0&&console.warn("[deliverable-share] media upload errors:",i),He(e,s,t)}async function $e(e,t,a){if(!e||t==="directory"||e.startsWith("http://")||e.startsWith("https://"))return{};try{const l=await N.files.preview(e);if((l.type==="text"||l.type==="markdown"||l.type==="html"||l.type==="json"||l.type==="csv")&&typeof l.content=="string"){if(!(l.type==="markdown"||l.type==="html"))return{content:l.content};const i=e.replace(/[/\\]/g,"/").split("/").slice(0,-1).join("/"),{refs:c}=we(l.content,i);if(c.length===0)return{content:l.content};const o=await Te(c,a);return o.size===0?{content:l.content}:{content:Ne(l.content,o),uploadedMedia:o.size}}if(l.type==="image"||l.type==="audio"||l.type==="video"||l.type==="binary"){const s=l.streamUrl||(l.path?N.files.streamUrl(l.path):N.files.streamUrl(e)),c=await(await fetch(s).then(f=>f.blob())).arrayBuffer(),o=new Uint8Array(c);let d="";const b=32768;for(let f=0;f<o.length;f+=b)d+=String.fromCharCode.apply(null,Array.from(o.subarray(f,f+b)));return{fileBase64:btoa(d)}}return{}}catch{return{}}}function Ee({item:e,onClose:t,onShared:a,service:l}){const{t:s}=de(["deliverables","common"]),i=u.useMemo(()=>l??ye(ue,R.getUrl()),[l]),[c,o]=u.useState(()=>i?i.isHubLoggedIn():null),[d,b]=u.useState(!1),[f,p]=u.useState(()=>{const n=e.shareStatus;return n==="published"?"published":n==="pending_review"?"pending_review":n==="rejected"?"rejected":"form"}),[m,M]=u.useState("public"),[V,ee]=u.useState(e.title||""),[E,te]=u.useState(e.summary||""),[x,L]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,P]=u.useState(""),[A,re]=u.useState(null),[H,U]=u.useState(!1),[I,g]=u.useState(null),F=u.useRef(a);F.current=a;const y=u.useCallback(n=>{re(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),F.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const se=u.useCallback(async()=>{b(!0),g(null);try{await fe({force:!0}),o(i.isHubLoggedIn())}catch{o(i.isHubLoggedIn())}finally{b(!1)}},[i]),B=u.useCallback(()=>{const n=k.trim().replace(/^#/,"");n&&!x.includes(n)&&L(h=>[...h,n]),P("")},[k,x]),ae=u.useCallback(n=>{L(h=>h.filter(v=>v!==n))},[]),le=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&L(h=>h.slice(0,-1))},[B,k,x.length]),D=u.useCallback(()=>{const n=A?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{U(!0),setTimeout(()=>U(!1),1500)}).catch(()=>{})},[A,e.shareUrl]),ne=u.useCallback(async()=>{if(!he(e.format)){g(`分享仅支持 ${[...q].join(" / ")} 格式`);return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ie,uploadedMedia:z}=await $e(e.reference,e.type,h);z&&console.info(`[deliverable-share] uploaded ${z} local media reference(s) to Hub`);const j=e.agentId??"";let O=j;if(j)try{const{agents:oe}=await N.agents.list({lean:!0}),K=oe.find(ce=>ce.id===j);K&&(O=K.name||j)}catch{}const w=await i.publish({localId:e.id,title:V.trim()||e.title,summary:E.trim(),tags:x,visibility:m,filename:n,format:e.format||"markdown",content:v,fileBase64:ie,producerAgent:{id:j,name:O,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:"分享被拒绝"):t()}catch(n){if(p("form"),n instanceof Q){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y]),_=u.useCallback(async()=>{g(null);try{const n=await i.revoke(e.id);y({...n,status:"revoked",url:null})}catch(n){g(n instanceof S?n.message:String(n))}},[i,e.id,y]),W=u.useCallback(()=>{p("form"),g(null)},[]);u.useEffect(()=>{if(f!=="pending_review")return;let n=!1;const h=setInterval(async()=>{try{const v=await i.pollStatus(e.id);if(n)return;v.status!=="pending_review"&&y(v)}catch{}},8e3);return()=>{n=!0,clearInterval(h)}},[f,i,e.id,y]),u.useEffect(()=>{const n=h=>{h.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t]);const T=m==="link",$=A?.url??e.shareUrl;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/50 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-surface-primary rounded-2xl shadow-2xl border border-border-default w-full max-w-md max-h-[85vh] overflow-y-auto",onClick:n=>n.stopPropagation(),children:[r.jsxs("div",{className:"sticky top-0 bg-surface-primary/95 backdrop-blur-sm border-b border-border-default px-5 py-4 flex items-center justify-between rounded-t-2xl z-10",children:[r.jsx("h3",{className:"text-base font-semibold text-fg-primary",children:s("deliverables:share.title",{defaultValue:"分享到 Markus Hub"})}),r.jsx("button",{onClick:t,className:"p-1.5 rounded-lg hover:bg-surface-overlay transition-colors text-fg-tertiary hover:text-fg-primary",children:r.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsx("div",{className:"px-5 py-4 space-y-4",children:c===!1?r.jsxs("div",{className:"space-y-4 py-2",children:[r.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/10 border border-amber-500/25 p-3",children:[r.jsx("span",{className:"text-lg",children:"🔑"}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.needHubLogin",{defaultValue:"需登录 Markus Hub 账号后才能分享产出物。"})})]}),r.jsx("button",{onClick:()=>{se()},disabled:d,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60",children:d?s("deliverables:share.loggingIn",{defaultValue:"正在打开登录…"}):s("deliverables:share.loginHub",{defaultValue:"登录 Markus Hub 账号"})}),r.jsx("p",{className:"text-[11px] text-fg-tertiary",children:s("deliverables:share.loginHint",{defaultValue:"解锁后将支持一键公开/链接分享产出物。"})})]}):r.jsx(r.Fragment,{children:f==="published"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-green-500/15 text-green-500 font-medium",children:s("deliverables:share.published",{defaultValue:"已发布"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):r.jsx("p",{className:"text-xs text-fg-tertiary",children:s("deliverables:share.urlPending",{defaultValue:"链接生成中,稍后刷新查看…"})}),r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="pending_review"?r.jsxs("div",{className:"space-y-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-amber-500 animate-pulse"}),r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-amber-500/15 text-amber-500 font-medium",children:s("deliverables:share.pendingReview",{defaultValue:"审核中"})}),r.jsx("span",{className:"text-[11px] text-fg-tertiary",children:m==="link"?s("deliverables:share.linkVisibility",{defaultValue:"有链接可见"}):s("deliverables:share.publicVisibility",{defaultValue:"公开"})})]}),r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.pendingHint",{defaultValue:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),$?r.jsxs("div",{className:"flex items-center gap-2 bg-surface-elevated rounded-lg px-3 py-2",children:[r.jsx("span",{className:"text-xs text-fg-secondary font-mono break-all flex-1 select-all",children:$}),r.jsx("button",{onClick:D,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${H?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:H?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{_()},className:"w-full px-3 py-2 text-xs font-medium rounded-lg text-red-500 border border-red-500/30 hover:bg-red-500/10 transition-colors",children:s("deliverables:share.revoke",{defaultValue:"取消分享"})})]}):f==="rejected"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("span",{className:"px-2 py-0.5 text-[11px] rounded-full bg-red-500/15 text-red-500 font-medium",children:s("deliverables:share.rejected",{defaultValue:"已拒绝"})})}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.resubmit",{defaultValue:"重新提交"})})]}):f==="revoked"?r.jsxs("div",{className:"space-y-3",children:[r.jsx("p",{className:"text-sm text-fg-secondary",children:s("deliverables:share.revoked",{defaultValue:"已取消分享,该产出物不再公开可访问。"})}),r.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors",children:s("deliverables:share.shareAgain",{defaultValue:"重新分享"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.visibility",{defaultValue:"可见性"})}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!T,onChange:()=>M("public"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.public",{defaultValue:"公开(所有人可见 + 搜索引擎)"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.publicHint",{defaultValue:"公开产出物需经 Hub 审核后发布,发布后所有人可见并参与搜索"})})]})]}),r.jsxs("label",{className:`flex items-start gap-3 rounded-xl border p-3 cursor-pointer transition-colors ${T?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:T,onChange:()=>M("link"),className:"mt-0.5 accent-brand-500"}),r.jsxs("span",{className:"space-y-0.5",children:[r.jsx("span",{className:"block text-sm font-medium text-fg-primary",children:s("deliverables:share.link",{defaultValue:"有链接可见"})}),r.jsx("span",{className:"block text-[11px] text-fg-tertiary",children:s("deliverables:share.linkHint",{defaultValue:"仅获得链接的人可查看,不参与搜索引擎;同样需经 Hub 审核"})})]})]})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.titleField",{defaultValue:"标题"})}),r.jsx("input",{value:V,onChange:n=>ee(n.target.value),placeholder:s("deliverables:share.titlePlaceholder",{defaultValue:"清晰、可检索的标题"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.summary",{defaultValue:"摘要"})}),r.jsx("textarea",{value:E,onChange:n=>te(n.target.value),rows:3,placeholder:s("deliverables:share.summaryPlaceholder",{defaultValue:"简要描述该产出物…"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none resize-y"})]}),r.jsxs("div",{className:"space-y-1.5",children:[r.jsx("div",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider font-medium",children:s("deliverables:share.tags",{defaultValue:"标签"})}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:x.map(n=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] bg-surface-elevated rounded-md text-fg-secondary",children:[n,r.jsx("button",{onClick:()=>ae(n),className:"text-fg-tertiary hover:text-red-500","aria-label":"remove",children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},n))}),r.jsx("input",{value:k,onChange:n=>P(n.target.value),onKeyDown:le,onBlur:B,placeholder:s("deliverables:share.tagsPlaceholder",{defaultValue:"输入标签后回车添加"}),className:"w-full px-3 py-2 text-sm rounded-lg bg-surface-elevated border border-border-default focus:border-brand-500/60 outline-none"})]}),I&&r.jsx("div",{className:"rounded-lg bg-red-500/10 border border-red-500/25 px-3 py-2 text-xs text-red-500",children:I}),r.jsxs("button",{type:"button",onClick:()=>{ne()},disabled:f==="busy"||!V.trim(),className:"w-full px-3 py-2.5 text-sm font-medium rounded-lg bg-brand-600 text-on-brand hover:bg-brand-500 transition-colors disabled:opacity-60 flex items-center justify-center gap-2",children:[f==="busy"&&r.jsxs("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",opacity:"0.25"}),r.jsx("path",{d:"M22 12a10 10 0 0 0-10-10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),f==="busy"?s("deliverables:share.sharing",{defaultValue:"分享中…"}):s("deliverables:share.shareToHub",{defaultValue:"分享到 Hub"})]})]})})})]})]})}export{Ee as D,he as a,ye as c};
|