@markus-global/cli 0.12.3-rc.3 → 0.12.3
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/web-ui/assets/{AsyncState-D2omBzdj.js → AsyncState-_UC7xcxJ.js} +1 -1
- package/dist/web-ui/assets/{ChatComponents-lSVBiM5B.js → ChatComponents-Ca9tWI9W.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-DxgRNOd1.js → ContentRenderer-C-V5k_3K.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-DU0PupsS.js → DeliverableShareModal-BvpyowYJ.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-BYacAH8w.js → Deliverables-CQnWqbTb.js} +1 -1
- package/dist/web-ui/assets/{MarkdownMessage-DwxvYN4X.js → MarkdownMessage-DedA8Zob.js} +1 -1
- package/dist/web-ui/assets/{Search-jBc36ZOH.js → Search-CVYQIy_D.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-13m2h7gu.js → SendToChat-IOAvuta-.js} +1 -1
- package/dist/web-ui/assets/{Settings-BkKMrBt2.js → Settings-BQDqf4q5.js} +1 -1
- package/dist/web-ui/assets/{Store-dLubNc0P.js → Store-BEsLd_RN.js} +1 -1
- package/dist/web-ui/assets/{Switch-CXRQn2gn.js → Switch-C6InTNUi.js} +1 -1
- package/dist/web-ui/assets/{Team-zVv87kaX.js → Team-nfNyWj-s.js} +4 -4
- package/dist/web-ui/assets/{Work-DbPgRas-.js → Work-BQvgkynj.js} +1 -1
- package/dist/web-ui/assets/{arc-C6rhmRdi.js → arc-DP1Vf7Sx.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BvaRSMDl.js → architectureDiagram-3BPJPVTR-Buq8JYN8.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DP7IwNLE.js → blockDiagram-GPEHLZMM-BCa2p2_X.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-CEQJBqku.js → c4Diagram-AAUBKEIU-BxsgggQY.js} +1 -1
- package/dist/web-ui/assets/channel-BTSrOo6c.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-BtGwhrHv.js → chunk-2J33WTMH-BJZZ60c9.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-DNKfs4jy.js → chunk-4BX2VUAB-C5hc4E6J.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-Bd4eMlUg.js → chunk-55IACEB6-CbyvZ6Mk.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-CHmRT5rY.js → chunk-727SXJPM-JmNt9TVA.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-CmoWgw5d.js → chunk-AQP2D5EJ-BTk0v5ba.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-Csafnaj6.js → chunk-FMBD7UC4-BO-dhB1U.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Cip_3Llj.js → chunk-ND2GUHAM-BdjCcLdb.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-C0WlO578.js → chunk-QZHKN3VN-BAzRC82n.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BSYlcnF9.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BSYlcnF9.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-ByhHiryW.js → cose-bilkent-S5V4N54A-CVffmErT.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-B5-K3iqP.js → dagre-BM42HDAG-Dd9pB2fX.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-Ci16wMOI.js → diagram-2AECGRRQ-BG_AUqzM.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Dfnzu_xA.js → diagram-5GNKFQAL-D5qFMRFf.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-K9NvC1S4.js → diagram-KO2AKTUF-B3qTxSWl.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-CaKq8BY-.js → diagram-LMA3HP47-BrxC1636.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-DqY8Y9OR.js → diagram-OG6HWLK6-BvXyEQ9-.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-DS9aOywt.js → docx-preview-DBAZFeEb.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-iW17lrM1.js → erDiagram-TEJ5UH35-CMap9oy_.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BBkXZBPV.js → flowDiagram-I6XJVG4X-BZerJtvk.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-J2QuVqg4.js → ganttDiagram-6RSMTGT7-CagPMHMO.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-EhZa3sGY.js → gitGraphDiagram-PVQCEYII-DZ5dDKRu.js} +1 -1
- package/dist/web-ui/assets/{index-BHu6brRf.js → index-CKPQYzzR.js} +6 -6
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-BaiNGDG7.js → infoDiagram-5YYISTIA-CHLdsDUZ.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-BYN0gLmP.js → ishikawaDiagram-YF4QCWOH-SdeinQaS.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CKUGXjL8.js → journeyDiagram-JHISSGLW-BtlL2fi0.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-iKb5H8rf.js → kanban-definition-UN3LZRKU-BKPQYXkB.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BSghRCEC.js → mermaid.core-MkJR6w4B.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-JjtDu_0Z.js → mindmap-definition-RKZ34NQL-CbOmHX_u.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-BDXCI_g9.js → pieDiagram-4H26LBE5-CypGjJP1.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-bATU3F6v.js → quadrantDiagram-W4KKPZXB-CGtemfUz.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-BNJWpDxg.js → requirementDiagram-4Y6WPE33-N7YfpCvE.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-C3B8NPUe.js → sankeyDiagram-5OEKKPKP-CYnSrei-.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-DhGwy4UV.js → sequenceDiagram-3UESZ5HK-CsB7dCPF.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BtfcmNhI.js → stateDiagram-AJRCARHV-DTDFUXFP.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-AVnDjlzF.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-BpY3qMyG.js → timeline-definition-PNZ67QCA-C_bWAN9B.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-S0f15t2D.js → vennDiagram-CIIHVFJN-CX_qAuUT.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-BdcJNPNt.js → wardley-L42UT6IY-q53jQ293.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-mR-gwtcd.js → wardleyDiagram-YWT4CUSO-D34dKCJU.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-Dq0PtvdL.js → xychartDiagram-2RQKCTM6-BFAngp66.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-pUJ_pqAp.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-Cs9dF-hf.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-Cs9dF-hf.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BOaSwLIS.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-CKPQYzzR.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
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,a5 as at}from"./index-BHu6brRf.js";import{MarkdownMessage as O}from"./MarkdownMessage-DwxvYN4X.js";import{n as ot}from"./chatChips-DVIRVTpT.js";const pe=6e4,Ue=60*pe,it=24*Ue;function pn(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/it)})}function mn(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 gn(){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 lt(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 ct(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=lt(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 dt(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 ut(){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=dt(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(ut,{})]});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 pt=1920,mt=10*1024*1024,Ce=5,gt=.8;function xt(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 ft({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 ht(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Se=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function xn(e){const n=[];let s;for(Se.lastIndex=0;(s=Se.exec(e))!==null;)n.push(s[1]??s[2]);return n}function fn(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 hn({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>mt)continue;const M=new FileReader;M.onload=()=>{const Z=M.result;xt(Z,pt,gt).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=ht(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(ft,{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 bn(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 bt(e,n){return!!e&&n==="agent"}const yt=24e3,vt=200;function yn(e,n,s=yt){const r=(e??"")+n;return r.length<=s?r:r.slice(r.length-s)}function vn(e,n,s=vt){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 jn(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 jt(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 kn(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 _n(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 kt(e)}function kt(e){return jt(e)?e.map(n=>n.sender!=="agent"||!n.isStreaming||n.isStopped?n:{...n,isStreaming:!1,segments:ye(n.segments)}):e}function wn(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 Nn(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 Cn(e){if(!e.sendSessionId)return!1;const n=e.liveSessions;return!n||n.size===0?!1:n.has(e.sendSessionId)}function Sn(e){const n=e.liveSessions;return!n||n.size===0||!e.sessionId?!0:!n.has(e.sessionId)&&!n.has(e.placeholderId)}function Tn(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 En(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 Mn(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 An(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 _t=/\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(_t,"").trimEnd(),priority:n}}const wt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,Nt=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Ln(e){return e.replace(wt,"").replace(Nt,"")}function Ct(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 Ct(a,o,i)})}const te=new Map,St=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>=St&&te.clear(),te.set(e,r),r}function Rn(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=ot(e.metadata?.chips);s&&(n.chips=s)}return n}function Ye(e,n,s){if(!e||!n||!s)return e;const r=`> **${n}**: ${s}
|
|
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,a5 as at}from"./index-CKPQYzzR.js";import{MarkdownMessage as O}from"./MarkdownMessage-DedA8Zob.js";import{n as ot}from"./chatChips-DVIRVTpT.js";const pe=6e4,Ue=60*pe,it=24*Ue;function pn(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/it)})}function mn(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 gn(){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 lt(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 ct(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=lt(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 dt(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 ut(){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=dt(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(ut,{})]});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 pt=1920,mt=10*1024*1024,Ce=5,gt=.8;function xt(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 ft({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 ht(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Se=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function xn(e){const n=[];let s;for(Se.lastIndex=0;(s=Se.exec(e))!==null;)n.push(s[1]??s[2]);return n}function fn(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 hn({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>mt)continue;const M=new FileReader;M.onload=()=>{const Z=M.result;xt(Z,pt,gt).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=ht(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(ft,{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 bn(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 bt(e,n){return!!e&&n==="agent"}const yt=24e3,vt=200;function yn(e,n,s=yt){const r=(e??"")+n;return r.length<=s?r:r.slice(r.length-s)}function vn(e,n,s=vt){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 jn(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 jt(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 kn(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 _n(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 kt(e)}function kt(e){return jt(e)?e.map(n=>n.sender!=="agent"||!n.isStreaming||n.isStopped?n:{...n,isStreaming:!1,segments:ye(n.segments)}):e}function wn(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 Nn(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 Cn(e){if(!e.sendSessionId)return!1;const n=e.liveSessions;return!n||n.size===0?!1:n.has(e.sendSessionId)}function Sn(e){const n=e.liveSessions;return!n||n.size===0||!e.sessionId?!0:!n.has(e.sessionId)&&!n.has(e.placeholderId)}function Tn(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 En(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 Mn(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 An(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 _t=/\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(_t,"").trimEnd(),priority:n}}const wt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,Nt=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Ln(e){return e.replace(wt,"").replace(Nt,"")}function Ct(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 Ct(a,o,i)})}const te=new Map,St=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>=St&&te.clear(),te.set(e,r),r}function Rn(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=ot(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
2
|
|
|
3
3
|
`;return e.startsWith(r)?e.slice(r.length):e}function In(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 $n(e){const n=e?.messageId||e?.streamId;return n?`reattach_${n}`:null}function Dn(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
4
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-
|
|
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-DedA8Zob.js","assets/index-CKPQYzzR.js","assets/index-CzHSs0Vd.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{j as a,r as i,_ as f}from"./index-CKPQYzzR.js";const x=i.lazy(()=>f(()=>import("./MarkdownMessage-DedA8Zob.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'';
|
package/dist/web-ui/assets/{DeliverableShareModal-DU0PupsS.js → DeliverableShareModal-BvpyowYJ.js}
RENAMED
|
@@ -1 +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-BHu6brRf.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};
|
|
1
|
+
import{u as de,r as u,h as R,V as ue,$ as fe,k as N,j as r}from"./index-CKPQYzzR.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};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{u as Qe,j as e,r as a,a as Bs,b as As,Q as Ms,R as ns,c as $s,k as h,U as wt,V as as,W as Ds,P as I,n as J,X as Vs,Y as Fs,Z as Hs,h as Ws,i as ls,N as _s}from"./index-
|
|
1
|
+
import{u as Qe,j as e,r as a,a as Bs,b as As,Q as Ms,R as ns,c as $s,k as h,U as wt,V as as,W as Ds,P as I,n as J,X as Vs,Y as Fs,Z as Hs,h as Ws,i as ls,N as _s}from"./index-CKPQYzzR.js";import{MarkdownMessage as Nt}from"./MarkdownMessage-DedA8Zob.js";import{resolveFormat as Us,ContentRenderer as Os}from"./ContentRenderer-C-V5k_3K.js";import{c as Ks,a as zs,D as Gs}from"./DeliverableShareModal-BvpyowYJ.js";import{S as Ys,s as qs}from"./SendToChat-IOAvuta-.js";import"./chatChips-DVIRVTpT.js";function M(o){return Array.isArray(o)?o.map(d=>String(d).trim()).filter(Boolean):typeof o=="string"&&o?o.split(",").map(d=>d.trim()).filter(Boolean):[]}function Qs(o){return o.files&&typeof o.files=="object"&&!Array.isArray(o.files)?o.files:null}function ee({label:o,value:d}){return d?e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o}),e.jsx("div",{className:"text-xs text-fg-secondary mt-0.5",children:d})]}):null}function xe({label:o,value:d,color:u}){if(!d)return null;const s={purple:"bg-brand-500/15 text-brand-500",cyan:"bg-blue-500/15 text-blue-600",indigo:"bg-brand-500/15 text-brand-500",gray:"bg-gray-500/15 text-fg-secondary",emerald:"bg-green-500/15 text-green-600"};return e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:o}),e.jsx("div",{className:`mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-medium ${s[u]??s.gray} capitalize inline-block`,children:d})]})}function St({files:o}){const{t:d}=Qe(["builder","common"]),[u,s]=a.useState(Object.keys(o)[0]??""),c=Object.keys(o);return c.length===0?null:e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:d("builder:artifact.files",{count:c.length})}),e.jsxs("div",{className:"mt-1 bg-surface-elevated/50 rounded-lg border border-border-default/30 overflow-hidden",children:[e.jsx("div",{className:"flex gap-0.5 px-1.5 py-1 border-b border-border-default/30 overflow-x-auto",children:c.map(b=>e.jsx("button",{onClick:()=>s(b),className:`px-2 py-0.5 text-[10px] rounded whitespace-nowrap transition-colors ${u===b?"bg-brand-600/30 text-brand-500":"text-fg-tertiary hover:text-fg-secondary"}`,children:b},b))}),u&&o[u]!=null&&e.jsx("pre",{className:"p-2 text-[10px] text-fg-secondary max-h-[120px] overflow-auto whitespace-pre-wrap font-mono",children:o[u]})]})]})}function Xs({artifact:o,mode:d}){const{t:u}=Qe(["builder","common"]),s=Qs(o),c=o.agent,b=o.team,S=o.dependencies,w=o.displayName??o.name;if(d==="agent"){const j=c?.roleName,P=c?.agentRole,k=c?.llmProvider,R=c?.llmModel,g=M(S?.env),E=M(S?.skills);return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(ee,{label:u("builder:artifact.name"),value:w}),e.jsx(ee,{label:u("builder:artifact.description"),value:o.description}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[j&&e.jsx(xe,{label:u("builder:artifact.baseTemplate"),value:j,color:"indigo"}),e.jsx(xe,{label:u("builder:artifact.agentRole"),value:P,color:P==="manager"?"purple":"cyan"})]}),M(o.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(o.tags).map(N=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:N},N))}),(k||R)&&e.jsxs("div",{className:"flex gap-2",children:[k&&e.jsx(xe,{label:u("builder:artifact.llmProvider"),value:k,color:"gray"}),R&&e.jsx(xe,{label:u("builder:artifact.llmModel"),value:R,color:"gray"})]}),g.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u("builder:artifact.requiredEnv")}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:g.map(N=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-amber-500/10 text-amber-600 rounded font-mono",children:N},N))})]}),E.length>0&&e.jsx(ee,{label:u("builder:artifact.skills"),value:E.join(", ")}),s&&e.jsx(St,{files:s})]})}if(d==="team"){const P=b?.members??[];return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(ee,{label:u("builder:artifact.name"),value:w}),e.jsx(ee,{label:u("builder:artifact.description"),value:o.description}),e.jsx("div",{className:"flex flex-wrap gap-2",children:e.jsx(xe,{label:u("builder:artifact.category"),value:o.category,color:"indigo"})}),M(o.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(o.tags).map(k=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:k},k))}),s&&e.jsx(St,{files:s}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary uppercase tracking-wider",children:u("builder:artifact.members",{count:P.length})}),e.jsx("div",{className:"mt-1.5 space-y-1.5",children:P.map((k,R)=>e.jsxs("div",{className:"bg-surface-elevated/30 rounded-lg px-2 py-1.5 border border-border-default/20",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-5 h-5 rounded flex items-center justify-center text-[10px] font-bold ${k.role==="manager"?"bg-brand-500/20 text-brand-500":"bg-blue-500/20 text-blue-600"}`,children:k.role==="manager"?"★":R+1}),e.jsx("span",{className:"text-xs text-fg-secondary flex-1 truncate",children:k.name}),typeof k.roleName=="string"&&k.roleName&&e.jsx("span",{className:"text-[10px] text-brand-500/70 font-mono",children:k.roleName}),e.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["x",String(k.count??1)]})]}),M(k.skills).length>0&&e.jsx("div",{className:"mt-1 ml-7 flex flex-wrap gap-1",children:M(k.skills).map(g=>e.jsx("span",{className:"px-1 py-0.5 text-[9px] bg-green-500/10 text-green-600 rounded font-mono",children:g},g))})]},R))})]})]})}return e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsx(ee,{label:u("builder:artifact.name"),value:w}),e.jsx(ee,{label:u("builder:artifact.description"),value:o.description}),e.jsx("div",{className:"flex gap-2",children:e.jsx(xe,{label:u("builder:artifact.category"),value:o.category,color:"indigo"})}),s&&e.jsx(St,{files:s}),M(o.tags).length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:M(o.tags).map(j=>e.jsx("span",{className:"px-1.5 py-0.5 text-[10px] bg-surface-elevated text-fg-tertiary rounded",children:j},j))})]})}function is(o){const d=document.scrollingElement,s=!!o&&o.scrollHeight>o.clientHeight+1?o:d,c=s?.scrollTop??0,b=s?.clientHeight??window.innerHeight,S=s?.scrollHeight??document.body.scrollHeight;return{scrollTop:c,clientHeight:b,scrollHeight:S,atTop:c<=0,atBottom:c+b>=S-1}}const fe={file:{icon:"📄",color:"bg-green-500/10 text-green-600"},directory:{icon:"📁",color:"bg-blue-500/10 text-blue-600"}},Zs=["file","directory"];function qe(o){return/^https?:\/\//i.test(o)}function L(o){return o?.shareStatus??null}function Js(o,d){const u=Date.now(),s=new Date(o).getTime(),c=u-s,b=Math.floor(c/6e4);if(b<1)return d("time.justNow");if(b<60)return d("time.minutesAgo",{count:b});const S=Math.floor(b/60);if(S<24)return d("time.hoursAgo",{count:S});const w=Math.floor(S/24);if(w===1)return d("time.yesterday");if(w<30)return d("time.daysAgo",{count:w});const j=Math.floor(w/30);return j<12?d("time.monthsAgo",{count:j}):d("time.yearsAgo",{count:Math.floor(j/12)})}function Ct(o){const d=o.title?.trim()||o.id;return{kind:"deliverable",label:`📄 ${qs(d)}`,content:["[deliverable]",`ID: ${o.id}`,`Title: ${o.title??""}`,o.reference?`Reference: ${o.reference}`:"",o.taskId?`Task: ${o.taskId}`:"",o.projectId?`Project: ${o.projectId}`:""].filter(Boolean).join(`
|
|
2
2
|
`)}}const z={agent:{icon:"✦",color:"bg-brand-500/10 text-brand-500"},team:{icon:"◈",color:"bg-blue-500/10 text-blue-600"},skill:{icon:"⬡",color:"bg-amber-500/10 text-amber-600"}};function ir({authUser:o,previewMode:d,previewData:u}={}){const{t:s}=Qe(["deliverables","common"]),c=Bs(),b=As(I.DELIVERABLES),S=Ms({side:"left",defaultWidth:384,minWidth:280,maxWidth:600,storageKey:"markus_deliverables_list"}),[w,j]=a.useState(!1),P=a.useRef(w);P.current=w,a.useEffect(()=>(ns(I.DELIVERABLES,c&&w?1:0),()=>ns(I.DELIVERABLES,0)),[c,w]),a.useEffect(()=>{if(!c)return;const t=()=>{P.current&&j(!1)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[c]);const k=20,R=60,[g,E]=a.useState(u?.items??[]),[N,D]=a.useState(u?.items?.length??0),[m,te]=a.useState(!1),[Xe,It]=a.useState(u?.projects??[]),[Ze,Lt]=a.useState(u?.agents??[]),[cs,ds]=a.useState([]),[us,Rt]=a.useState(!1),[Et,xs]=a.useState([]),[me,Pt]=a.useState(!u),[Pe,Te]=a.useState(""),[pe,Be]=a.useState(""),[V,ge]=a.useState(""),[F,be]=a.useState(""),[H,W]=a.useState(""),[se,Ae]=a.useState(""),[fs,Je]=a.useState(!1),[$,hs]=a.useState("date"),[n,T]=a.useState(()=>u?.initialSelectedId&&u.items?u.items.find(t=>t.id===u.initialSelectedId)??u.items[0]??null:u?.items?.[0]??null),[et,Tt]=a.useState(null),[Bt,At]=a.useState(""),[re,ms]=a.useState(!0),[Mt,ye]=a.useState(()=>{const t=new Date,r=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;return new Set([r])}),[tt,ps]=a.useState(!1),[st,$t]=a.useState(!1),Me=a.useRef(null),[$e,ne]=a.useState(null),[De,Dt]=a.useState("markdown"),[ve,rt]=a.useState(null),[je,nt]=a.useState(null),[ae,at]=a.useState(null),[G,ke]=a.useState(null),[lt,le]=a.useState(!1),[Vt,Y]=a.useState(!1),[we,Ft]=a.useState(!1),[Ht,Ve]=a.useState(null),[it,Fe]=a.useState(null),[ot,He]=a.useState(null),[gs,ct]=a.useState(!1),[dt,bs]=a.useState(""),[Wt,ys]=a.useState(new Set),_t=ae&&n?.type==="file",We=_t||!!G&&n?.type==="directory",[_,q]=a.useState(!1),A=$s(),ie=A?.keyboardPane??"content",[Ne,oe]=a.useState(null),[ce,Q]=a.useState(!1),[Se,ut]=a.useState(""),[U,X]=a.useState(!1),[xt,Ut]=a.useState(!1),[ft,Z]=a.useState(null),ht=a.useRef(null),Ot=a.useCallback(t=>{t&&(t.style.height="auto",t.style.height=t.scrollHeight+"px")},[]),Kt=a.useRef(void 0);a.useEffect(()=>{Ot(ht.current)},[Se,ce,Ot]);const B=(t,r)=>{Tt({type:t,text:r}),setTimeout(()=>Tt(null),3e3)},_e=async t=>{await _s(t)?(Ft(!0),setTimeout(()=>Ft(!1),1500)):B("error",s("detail.copyFailed"))},Ue=a.useMemo(()=>new Map(Ze.map(t=>[t.id,t])),[Ze]),mt=a.useMemo(()=>new Map(Xe.map(t=>[t.id,t])),[Xe]),zt=a.useMemo(()=>new Map(Et.map(t=>[t.id,t])),[Et]),Ce=a.useCallback(t=>{if(!t||t==="default")return null;const r=mt.get(t)?.name;return!r||r==="default"?null:r},[mt]);a.useEffect(()=>{d||(h.projects.list().then(t=>It(t.projects)).catch(()=>{}),h.agents.list().then(t=>Lt(t.agents??[])).catch(()=>{}),h.users.list().then(t=>ds(t.users??[])).catch(()=>{}),h.teams.list().then(t=>xs(t.teams??[])).catch(()=>{}),h.system.info().then(t=>bs(t.dataDir+"/shared")).catch(()=>{}),h.deliverables.checkHealth().then(t=>ys(new Set(t.missingFiles))).catch(()=>{}))},[d]),a.useEffect(()=>(Kt.current=setTimeout(()=>Be(Pe),300),()=>clearTimeout(Kt.current)),[Pe]);const de=a.useMemo(()=>({q:pe||void 0,projectId:se||void 0,type:V||void 0,artifactType:F||void 0,source:H||void 0}),[pe,V,F,se,H]),ue=$==="date"?k:R,pt=a.useCallback((t,r)=>r?{...r,hubShareId:r.hubShareId!=null?r.hubShareId:t.hubShareId??null,shareStatus:r.shareStatus!=null?r.shareStatus:t.shareStatus??null,shareUrl:r.shareUrl!=null?r.shareUrl:t.shareUrl??null,shareVisibility:r.shareVisibility!=null?r.shareVisibility:t.shareVisibility??null,shareReason:r.shareReason!=null?r.shareReason:t.shareReason}:t,[]),Oe=a.useCallback(async()=>{try{const{results:t,total:r}=await h.deliverables.search({...de,offset:0,limit:ue});E(i=>i.map(l=>{const f=t.find(x=>x.id===l.id);return f?pt(l,f):l})),D(r),T(i=>{if(!i)return null;const l=t.find(f=>f.id===i.id);return l?pt(i,l):i})}catch{}},[de,ue,pt]),O=a.useCallback(async()=>{Pt(!0),Me.current?.scrollTo({top:0,behavior:"instant"}),window.scrollY>0&&window.scrollTo({top:0,behavior:"instant"});try{const{results:t,total:r}=await h.deliverables.search({...de,offset:0,limit:ue});E(t),D(r),T(i=>i&&t.some(l=>l.id===i.id)?i:null)}catch{E([]),D(0),T(null)}Pt(!1)},[de,ue]),vs=a.useCallback(async()=>{if(!(m||g.length>=N)){te(!0);try{const{results:t,total:r}=await h.deliverables.search({...de,offset:g.length,limit:ue});E(i=>[...i,...t]),D(r)}catch{}te(!1)}},[de,ue,g.length,N,m]);a.useEffect(()=>{d||O()},[O,d]),a.useEffect(()=>{!d||!u||(E(u.items??[]),D(u.items?.length??0),It(u.projects??[]),Lt(u.agents??[]),u.initialSelectedId&&T(u.items?.find(t=>t.id===u.initialSelectedId)??u.items?.[0]??null))},[d,u]);const gt=a.useRef(n);gt.current=n,a.useEffect(()=>{if(d||!b)return;const t=wt.on("deliverable:created",()=>O()),r=wt.on("deliverable:updated",l=>{Oe();const f=l.payload?.deliverableId;f&>.current?.id===f&&h.deliverables.get(f).then(x=>{x.deliverable&&(T(p=>({...p??x.deliverable,...x.deliverable,hubShareId:p?.hubShareId??x.deliverable.hubShareId??null,shareStatus:p?.shareStatus??x.deliverable.shareStatus??null,shareUrl:p?.shareUrl??x.deliverable.shareUrl??null,shareVisibility:p?.shareVisibility??x.deliverable.shareVisibility??null,shareReason:p?.shareReason??x.deliverable.shareReason??null})),Yt(x.deliverable))}).catch(()=>{})}),i=wt.on("deliverable:removed",()=>O());return()=>{t(),r(),i()}},[Oe,b,d]);const Gt=a.useMemo(()=>Ks(as,Ws.getUrl()),[]);a.useEffect(()=>{if(d||!b||!as())return;let t=!1;const r=async()=>{try{const l=await Gt.listMine();if(t)return;const f=new Map,x=new Map;for(const v of l)v.id&&f.set(v.id,v),v.localId&&x.set(v.localId,v);const p=new Map;E(v=>v.map(y=>{const C=y.hubShareId&&f.get(y.hubShareId)||x.get(y.id);if(!C)return y;const Ee={hubShareId:y.hubShareId??C.id??null,shareStatus:C.status??null,shareUrl:C.url??null,shareVisibility:y.shareVisibility??C.visibility??null,...C.reason!=null?{shareReason:C.reason}:{}};return p.set(y.id,Ee),{...y,...Ee}})),T(v=>{if(!v)return v;const y=p.get(v.id);return y?{...v,...y}:v});for(const[v,y]of p)h.deliverables.update(v,y).catch(C=>{console.warn("[deliverables] Hub 分享状态本地持久化失败:",C)})}catch{}};r();const i=setInterval(r,3e4);return()=>{t=!0,clearInterval(i)}},[Gt,b,d]);const Ke=a.useRef(null),bt=a.useRef(g);bt.current=g;const Ie=a.useCallback(t=>{const r=l=>{T(l),c&&(j(!0),history.pushState({mobileDetail:I.DELIVERABLES},"",window.location.hash))},i=bt.current.find(l=>l.id===t);if(i){r(i);return}h.deliverables.get(t).then(l=>{l.deliverable&&r(l.deliverable)}).catch(()=>{})},[c]);a.useEffect(()=>{if(d)return;const t=window.location.hash.slice(1).split("/"),r=Ds(t[0])===I.DELIVERABLES?t[1]:void 0,i=localStorage.getItem("markus_nav_projectId"),l=localStorage.getItem("markus_nav_source");i&&(localStorage.removeItem("markus_nav_projectId"),Ae(i)),(l==="knowledge"||l==="agent")&&(localStorage.removeItem("markus_nav_source"),W(l));const f=localStorage.getItem("markus_nav_openDeliverable")||r;f&&(localStorage.removeItem("markus_nav_openDeliverable"),bt.current.length>0?Ie(f):Ke.current=f);const x=p=>{const y=p.detail?.params;y?.projectId&&Ae(y.projectId),(y?.source==="knowledge"||y?.source==="agent")&&W(y.source),y?.openDeliverable&&(localStorage.removeItem("markus_nav_openDeliverable"),Ie(y.openDeliverable))};return window.addEventListener("markus:navigate",x),()=>window.removeEventListener("markus:navigate",x)},[Ie,d]),a.useEffect(()=>{const t=Ke.current;!t||g.length===0||(Ke.current=null,Ie(t))},[g,Ie]);const K=a.useMemo(()=>{const t=new Map;for(const i of g){let l,f;if($==="project"){const x=Ce(i.projectId);l=x?i.projectId??"_none":"_none",f=x??s("noProject")}else if($==="team"){const p=(i.agentId?Ue.get(i.agentId):void 0)?.teamId??"_none";l=p,f=p!=="_none"?zt.get(p)?.name??p:s("noTeam")}else if($==="agent")l=i.agentId??"_none",f=i.agentId?Ue.get(i.agentId)?.name??i.agentId:s("common:unknown");else{const x=new Date(i.updatedAt);l=`${x.getFullYear()}-${String(x.getMonth()+1).padStart(2,"0")}-${String(x.getDate()).padStart(2,"0")}`,f=l}t.has(l)||t.set(l,{label:f,items:[]}),t.get(l).items.push(i)}const r=[...t.entries()];return $==="date"?r.sort((i,l)=>l[0].localeCompare(i[0])):r.sort((i,l)=>i[1].label.localeCompare(l[1].label)),r},[g,$,mt,Ue,zt,s]);a.useEffect(()=>{if($==="date"&&re){const t=new Date,r=`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,"0")}-${String(t.getDate()).padStart(2,"0")}`;ye(new Set([r]))}else ye(new Set)},[$]);const js=async t=>{At("remove");try{await h.deliverables.remove(t.id),B("success",s("removed")),T(null),O()}catch(r){B("error",s("common:error",{message:String(r)}))}At("")},ks=a.useCallback(t=>{const r=gt.current,i=r?.id;if(!i)return;const l={hubShareId:t.id??null,shareStatus:t.status??null,shareUrl:t.url??null,shareVisibility:t.visibility??null,...t.reason!=null||t.status==="rejected"?{shareReason:t.reason??r?.shareReason??null}:{}},f={...l,shareStatus:l.shareStatus??r?.shareStatus??null};T(x=>x&&x.id===i?{...x,...f}:x),E(x=>x.map(p=>p.id===i?{...p,...f}:p)),(async()=>{try{await h.deliverables.update(i,l)}catch(x){console.warn("[deliverables] 分享状态本地回写失败,将由 Hub 轮询补偿:",x)}Oe()})()},[Oe]),ws=()=>{J.navigate(I.BUILDER)},Le=a.useCallback(async(t,r,i)=>{if(t.type==="directory"&&Array.isArray(t.entries))ke({path:t.path,name:t.name,entries:t.entries});else if(t.type==="image"&&t.mimeType){const l=t.streamUrl||(t.path?h.files.streamUrl(t.path):h.files.streamUrl(r));rt({src:l,name:t.name})}else if(t.type==="audio"||t.type==="video"){const l=t.streamUrl||(t.path?h.files.streamUrl(t.path):h.files.streamUrl(r));nt({kind:t.type,src:l,name:t.name})}else if(t.type==="office"){const l=t.streamUrl||(t.path?h.files.streamUrl(t.path):h.files.streamUrl(r));at({format:t.format||String(t.extension||"").replace(/^\./,"")||"pdf",streamUrl:l,name:t.name,size:t.size,reference:t.path||r})}else t.type==="binary"?Y(!0):typeof t.content=="string"?(ne(t.content),Dt(Us({format:i,reference:r,content:t.content}))):Y(!0)},[]),yt=a.useCallback(async t=>{le(!0),ne(null),rt(null),nt(null),at(null),Y(!1),ke(null),Ve(null),Fe(null);try{const r=await h.files.preview(t);r.type==="directory"&&Array.isArray(r.entries)?ke({path:r.path,name:r.name,entries:r.entries}):await Le(r,t)}catch{Y(!0)}le(!1)},[Le]),Ns=a.useCallback(async(t,r)=>{le(!0),Ve(r??null),Fe(t),ke(null);try{const i=await h.files.preview(t);await Le(i,t)}catch{ne(null),Y(!0)}le(!1)},[Le]),Yt=async t=>{if(t.reference&&!qe(t.reference)){if(t.type==="directory"){yt(t.reference);return}le(!0);try{const r=await h.files.preview(t.reference);await Le(r,t.reference,t.format)}catch{ne(null),t.type==="file"&&Y(!0)}le(!1)}};a.useEffect(()=>{d||(ne(null),Dt("markdown"),rt(null),nt(null),at(null),ke(null),Y(!1),Ve(null),Fe(null),n&&Yt(n))},[n?.id,d]);const qt=a.useCallback(t=>re!==Mt.has(t),[re,Mt]),Qt=K.length>0&&K.every(([t])=>qt(t)),Ss=a.useCallback(t=>{ye(r=>{const i=new Set(r);return i.has(t)?i.delete(t):i.add(t),i})},[]),Xt=a.useCallback(t=>{ye(r=>{if(r.has(t)===re)return r;const i=new Set(r);return re?i.add(t):i.delete(t),i})},[re]),Cs=a.useCallback(()=>{ms(t=>!t),ye(new Set)},[]),ze=!!(V||F||H||se||pe),Zt=a.useCallback(()=>{ge(""),be(""),W(""),Ae(""),Te(""),Be("")},[]),Re=a.useMemo(()=>K.flatMap(([,t])=>t.items),[K]);a.useEffect(()=>{d||c||me||n||Ke.current||Re.length!==0&&T(Re[0])},[d,c,me,n,Re]);const vt=a.useRef(null);a.useEffect(()=>{if(!n){vt.current=null;return}if(vt.current===n.id)return;const t=K.find(([,r])=>r.items.some(i=>i.id===n.id));t&&(vt.current=n.id,Xt(t[0]))},[n?.id,K,Xt]);const Jt=a.useRef(null),es=a.useRef(null),Ge=a.useRef(!1),ts=a.useRef(ie);a.useEffect(()=>{if(d||c||!b)return;const t=ts.current;ts.current=ie,!(ie!=="l1"||t==="l1")&&_&&(Ge.current=!0,q(!1))},[ie,d,c,b,_]),a.useEffect(()=>{if(d||c||!b)return;const t=r=>{if(r.metaKey||r.ctrlKey){if(r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement){r.key==="Escape"&&(r.target.blur(),r.preventDefault());return}if(ls(r.target))return;if(r.key==="f"){r.preventDefault(),Jt.current?.focus();return}if(r.key.toLowerCase()==="b"){r.preventDefault(),q(C=>{const Ee=!C;return Ee&&(Ge.current=!0,A?.setKeyboardPane("l1"),requestAnimationFrame(()=>es.current?.focus())),Ee});return}if(r.key.toLowerCase()==="l"){r.preventDefault(),kt();return}return r.altKey,void 0}if(A?.keyboardPane==="l0")return;if(r.target instanceof HTMLInputElement||r.target instanceof HTMLTextAreaElement){r.key==="Escape"&&(r.target.blur(),r.preventDefault());return}if(ls(r.target)||r.metaKey||r.ctrlKey||r.altKey)return;const l=r.key.length===1?r.key.toLowerCase():r.key;if(l==="h"||l==="ArrowLeft"){r.preventDefault(),_&&q(!1),A?.setL0FocusPageId(I.DELIVERABLES),A?.setLeftCollapsed(!1),A?.setKeyboardPane("l0");return}if(l==="l"||l==="ArrowRight"){r.preventDefault(),_&&q(!1),A?.keyboardPane!=="l1"&&A?.setKeyboardPane("l1");return}const f=l==="j"||l==="ArrowDown"?1:l==="k"||l==="ArrowUp"?-1:0;if(!f)return;r.preventDefault(),A?.setKeyboardPane("l1"),_&&(Ge.current=!0,q(!1));const x=Re;if(x.length===0)return;const p=n?x.findIndex(C=>C.id===n.id):-1,v=p<0?f>0?-1:0:p,y=Math.max(0,Math.min(x.length-1,v+f));ss(x[y]),requestAnimationFrame(()=>{document.querySelector(`[data-deliverable-id="${x[y].id}"]`)?.scrollIntoView({block:"nearest"})})};return document.addEventListener("keydown",t,!0),()=>document.removeEventListener("keydown",t,!0)},[Re,n,d,c,b,A,_]);const Ye=a.useRef(null),Is=a.useCallback(t=>{if(!c||!is(Me.current).atTop)return;const r=t.touches[0];r&&(Ye.current={y:r.clientY,x:r.clientX})},[c]),Ls=a.useCallback(t=>{if(!c||!Ye.current||st)return;const r=t.changedTouches[0],i=Ye.current;if(Ye.current=null,!r)return;const l=r.clientY-i.y,f=Math.abs(r.clientX-i.x);l<72||f>l||is(Me.current).atTop&&($t(!0),O().finally(()=>$t(!1)))},[c,st,O]),ss=t=>{const r=()=>{T(t),ct(!1),Q(!1),X(!1),c&&(j(!0),history.pushState({mobileDetail:I.DELIVERABLES},"",window.location.hash))};U?Z({action:r}):r()},Rs=()=>{if(!U){const t=$e??n?.summary??"";ut(t)}Q(!0)},Es=()=>{U?Z({action:()=>{Q(!1),X(!1)}}):Q(!1)},rs=async()=>{if(!(!n?.reference||xt)){Ut(!0);try{await h.files.write(n.reference,Se),ne(Se),X(!1),Q(!1),B("success",s("detail.saved"))}catch(t){B("error",s("detail.saveFailed")+": "+String(t))}Ut(!1)}},Ps=()=>{Q(!1),X(!1),Z(null)};a.useEffect(()=>{if(!U)return;const t=r=>{r.preventDefault()};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[U]),a.useEffect(()=>{if(!U)return;const t=r=>{r.preventDefault(),r.stopImmediatePropagation(),Z({action:()=>{Q(!1),X(!1);const{page:i,params:l}=r.detail||{};i&&J.navigate(i,l)}})};return window.addEventListener("markus:navigate",t),()=>window.removeEventListener("markus:navigate",t)},[U]);const jt=a.useRef(null),kt=a.useCallback((t,r)=>{const i=n?.agentId??"",l=n?.id??"",f={};l&&(f.openDeliverable=l);const x=[];if(n&&x.push(Ct(n)),t?.trim()){const p=t.trim().length>40?`${t.trim().slice(0,24)}…${t.trim().slice(-12)}`:t.trim();if(r){const v=n?.reference??"";x.push({label:`🌐 ${p}`,content:["[html-selection]",`Text: "${t.trim()}"`,`CSS Selector: ${r.cssSelector}`,`XPath: ${r.xpath}`,v?`File: ${v}`:""].filter(Boolean).join(`
|
|
3
3
|
`)})}else x.push({label:`📝 ${p}`,content:t.trim()})}x.length>0&&(f.chatChips=JSON.stringify(x)),i&&(f.agentId=i),oe(null),window.getSelection()?.removeAllRanges(),J.navigate(I.TEAM,f)},[n]),Ts=a.useCallback(t=>{if(!t.text.trim())return;const i=jt.current?.querySelector("iframe")?.getBoundingClientRect(),l=(i?.left??0)+t.rect.x+t.rect.width/2,f=(i?.top??0)+t.rect.y;oe({x:l,y:f,text:t.text,htmlMeta:{xpath:t.xpath,cssSelector:t.cssSelector}})},[]);return a.useEffect(()=>{const t=jt.current;if(!t)return;const r=()=>{requestAnimationFrame(()=>{const l=window.getSelection(),f=l?.toString().trim();if(!f||!l?.rangeCount){oe(null);return}const x=l.getRangeAt(0);if(!t.contains(x.commonAncestorContainer)){oe(null);return}const p=x.getBoundingClientRect();oe({x:p.left+p.width/2,y:p.top,text:f})})},i=l=>{const f=document.getElementById("selection-toolbar");f&&f.contains(l.target)||oe(null)};return t.addEventListener("mouseup",r),document.addEventListener("mousedown",i),()=>{t.removeEventListener("mouseup",r),document.removeEventListener("mousedown",i)}},[]),e.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[e.jsxs("div",{ref:es,tabIndex:-1,"data-keyboard-pane":"l1",className:`${c?"flex-1 min-w-0":"shrink-0"} flex flex-col bg-surface-secondary rounded-xl m-1 mr-0 outline-none ${!c&&ie==="l1"?"ring-1 ring-inset ring-brand-500/30":""}`,style:c?w?{display:"none"}:void 0:_?{display:"none"}:{width:S.width},children:[e.jsxs("div",{"data-electron-drag":!0,className:"p-4 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between gap-2",children:e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[c&&e.jsx(Vs,{}),!c&&e.jsx("button",{onClick:()=>q(!0),className:"w-8 h-8 flex items-center justify-center rounded-lg transition-colors shrink-0 bg-brand-500/15 text-brand-500 hover:bg-brand-500/25",title:s("sidebar.collapse"),children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"9",y1:"3",x2:"9",y2:"21"})]})}),e.jsxs("h2",{className:"text-sm font-semibold text-fg-secondary truncate",children:[s("title"),N>0&&e.jsxs("span",{className:"ml-1.5 text-fg-tertiary font-normal",children:["(",N,")"]})]})]})}),e.jsxs("div",{className:"relative",children:[e.jsxs("svg",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-fg-muted pointer-events-none",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{ref:Jt,value:Pe,onChange:t=>Te(t.target.value),placeholder:s("searchPlaceholder"),className:"w-full bg-surface-elevated border border-border-default rounded-lg pl-8 pr-8 py-2 text-sm text-fg-primary focus:border-brand-500 focus:outline-none transition-colors"}),Pe&&e.jsx("button",{onClick:()=>{Te(""),Be("")},className:"absolute right-2.5 top-1/2 -translate-y-1/2 w-4 h-4 flex items-center justify-center rounded-full bg-surface-overlay text-fg-tertiary hover:text-fg-secondary transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),dt&&!c&&e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-1.5 bg-surface-elevated rounded-lg text-[10px] text-fg-tertiary",children:[e.jsx("span",{className:"truncate font-mono",children:dt}),e.jsx("button",{onClick:()=>{h.system.openPath(dt)},className:"shrink-0 underline hover:text-fg-secondary transition-colors",children:s("common:open")})]}),c&&e.jsxs("button",{onClick:()=>ps(t=>!t),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-xs transition-colors ${tt||ze?"bg-brand-500/15 text-brand-500":"bg-surface-elevated text-fg-secondary"}`,children:[e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),e.jsx("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),e.jsx("line",{x1:"12",y1:"18",x2:"20",y2:"18"})]}),s("filters.filtersLabel"),ze&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-brand-500"}),e.jsx("svg",{className:`w-3 h-3 ml-auto transition-transform ${tt?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsxs("div",{className:c&&!tt?"hidden":"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary shrink-0",children:s("filters.source")}),e.jsx(he,{label:s("filters.allSources"),value:"",current:H,onClick:()=>W("")}),e.jsx(he,{label:s("filters.sourceAgent"),value:"agent",current:H,onClick:t=>W(t||"")}),e.jsx(he,{label:s("filters.sourceKnowledge"),value:"knowledge",current:H,onClick:t=>W(t||"")}),e.jsxs("button",{type:"button",onClick:()=>Je(!0),className:"ml-auto shrink-0 flex items-center gap-1 px-2 py-1 rounded text-[10px] text-fg-tertiary hover:text-brand-500 hover:bg-surface-elevated transition-colors",title:s("filters.bindKnowledgeBase"),children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),s("filters.bindKnowledgeBase")]})]}),e.jsxs("div",{className:"flex gap-1 overflow-x-auto scrollbar-hide filter-pills-fade",children:[e.jsx(he,{label:s("filters.allTypes"),value:"",current:V||F||"",onClick:()=>{ge(""),be("")}}),Zs.map(t=>e.jsx(he,{label:`${fe[t]?.icon??""} ${t}`,value:t,current:V,onClick:r=>{ge(r),be("")}},t)),["agent","team","skill"].map(t=>e.jsx(he,{label:`${z[t].icon} ${s(`artifactTypes.${t}`)}`,value:t,current:F,onClick:r=>{be(r),ge("")}},t))]}),e.jsxs("div",{className:"flex gap-1.5 items-center",children:[e.jsx("span",{className:"text-[10px] text-fg-tertiary",children:s("filters.group")}),["date","project","team","agent"].map(t=>e.jsx("button",{onClick:()=>{hs(t)},className:`px-2 py-1 rounded text-xs transition-colors ${$===t?"bg-brand-600 text-on-brand":"bg-surface-elevated text-fg-secondary hover:bg-surface-overlay"}`,children:s(`groupBy.${t}`)},t)),K.length>1&&e.jsx("button",{onClick:Cs,className:"ml-auto px-1.5 py-1 rounded text-[10px] text-fg-tertiary hover:text-fg-secondary hover:bg-surface-elevated transition-colors",title:s(Qt?"expandAllTooltip":"collapseAllTooltip"),children:s(Qt?"expandAll":"collapseAll")})]})]}),ze&&e.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[pe&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:["“",pe,"”",e.jsx("button",{onClick:()=>{Te(""),Be("")},className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),V&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[fe[V]?.icon," ",V,e.jsx("button",{onClick:()=>ge(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),F&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[z[F]?.icon," ",s(`artifactTypes.${F}`),e.jsx("button",{onClick:()=>be(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),H&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[s(H==="knowledge"?"filters.sourceKnowledge":"filters.sourceAgent"),e.jsx("button",{onClick:()=>W(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),se&&e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-brand-500/10 text-brand-500 text-[10px]",children:[Ce(se)??se,e.jsx("button",{onClick:()=>Ae(""),className:"hover:text-brand-400",children:e.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("button",{onClick:Zt,className:"text-[10px] text-fg-tertiary hover:text-brand-500 ml-auto transition-colors",children:s("filters.clearAll")})]})]}),et&&e.jsx("div",{className:`mx-4 mt-2 px-3 py-1.5 text-xs rounded-lg ${et.type==="success"?"bg-green-500/15 text-green-600":"bg-red-500/15 text-red-500"}`,children:et.text}),e.jsxs("div",{ref:Me,className:"flex-1 overflow-y-auto p-2 space-y-1 transition-opacity duration-150",style:{opacity:me?.5:1},onTouchStart:c?Is:void 0,onTouchEnd:c?Ls:void 0,children:[st&&e.jsxs("div",{className:"flex items-center justify-center gap-2 py-2 text-brand-500",children:[e.jsx(os,{})," ",e.jsx("span",{className:"text-[10px]",children:s("filters.refreshing")})]}),me?e.jsx("div",{className:"p-4 space-y-3",children:[1,2,3].map(t=>e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-surface-elevated rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-surface-elevated rounded w-1/2"})]},t))}):g.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-fg-muted mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})}),ze?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.noResults")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.noResultsHint")}),e.jsx("button",{onClick:Zt,className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:s("filters.clearAll")})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-fg-secondary",children:s("empty.title")}),e.jsx("p",{className:"text-xs text-fg-tertiary mt-1 mb-3",children:s("empty.subtitle")}),e.jsx("button",{onClick:()=>J.navigate(I.WORK),className:"text-xs px-3 py-1.5 rounded-lg bg-brand-600 hover:bg-brand-500 text-on-brand transition-colors",children:s("empty.goToWork")})]})]}):K.map(([t,r])=>{const i=qt(t);return e.jsxs("div",{className:"mb-1 cv-row",children:[e.jsxs("button",{onClick:()=>Ss(t),className:"w-full flex items-center gap-1.5 px-2 py-2 rounded-md hover:bg-surface-elevated/50 transition-colors group/header border-b border-border-subtle/50",children:[e.jsx("svg",{className:`w-3 h-3 text-fg-tertiary transition-transform duration-200 shrink-0 ${i?"":"rotate-90"}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 5l7 7-7 7"})}),e.jsx("span",{className:"text-[11px] font-semibold text-fg-tertiary uppercase tracking-wider truncate",children:r.label}),e.jsxs("span",{className:"text-[10px] text-fg-muted bg-surface-elevated px-1.5 py-0.5 rounded-full shrink-0",children:[r.items.length,g.length<N?"+":""]})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-200 ${i?"max-h-0 opacity-0":"max-h-[5000px] opacity-100"}`,children:r.items.map(l=>e.jsx("button",{"data-deliverable-id":l.id,onClick:()=>ss(l),className:`cv-row w-full text-left px-3 py-2 rounded-lg transition-all duration-150 ${n?.id===l.id?ie==="l1"?"bg-brand-500/25 ring-1 ring-inset ring-brand-500/40 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"bg-brand-600/15 border-l-2 border-l-brand-500 border-y border-r border-y-brand-500/20 border-r-brand-500/20":"hover:bg-surface-elevated/60 border-l-2 border-l-transparent border-y border-r border-transparent"}`,children:e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[l.artifactType&&z[l.artifactType]?e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium shrink-0 ${z[l.artifactType].color}`,children:z[l.artifactType].icon}):e.jsx("span",{className:`text-[10px] px-1 py-0.5 rounded font-medium uppercase shrink-0 ${fe[l.type]?.color??"bg-surface-overlay text-fg-secondary"}`,children:fe[l.type]?.icon??l.type.charAt(0)}),e.jsx("span",{className:"text-sm font-medium text-fg-primary truncate flex-1",children:l.title}),L(l)==="published"&&e.jsxs("svg",{className:"shrink-0 text-green-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.published",{defaultValue:"已发布到 Hub"}),children:[e.jsx("title",{children:s("share.published",{defaultValue:"已发布到 Hub"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),L(l)==="pending_review"&&e.jsxs("svg",{className:"shrink-0 text-amber-500 animate-pulse",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.pendingReview",{defaultValue:"Hub 审核中"}),children:[e.jsx("title",{children:s("share.pendingReview",{defaultValue:"Hub 审核中"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),L(l)==="rejected"&&e.jsxs("svg",{className:"shrink-0 text-red-500",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-label":s("share.rejected",{defaultValue:"Hub 已拒绝"}),children:[e.jsx("title",{children:s("share.rejected",{defaultValue:"Hub 已拒绝"})}),e.jsx("circle",{cx:"18",cy:"5",r:"3"}),e.jsx("circle",{cx:"6",cy:"12",r:"3"}),e.jsx("circle",{cx:"18",cy:"19",r:"3"}),e.jsx("line",{x1:"8.59",y1:"13.51",x2:"15.42",y2:"17.49"}),e.jsx("line",{x1:"15.41",y1:"6.51",x2:"8.59",y2:"10.49"})]}),Wt.has(l.id)&&e.jsx("span",{className:"shrink-0 text-amber-500",title:s("detail.fileMissing"),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),e.jsx("span",{className:"text-[10px] text-fg-muted shrink-0",children:Js(l.updatedAt,s)})]})},l.id))})]},t)}),g.length<N&&e.jsx("div",{className:"flex justify-center py-3",children:e.jsx("button",{type:"button",disabled:m,onClick:()=>{vs()},className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-lg
|
|
4
4
|
border border-border-default text-fg-secondary bg-surface-elevated/60
|