@markus-global/cli 0.12.5-rc.2 → 0.12.5-rc.4
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-BCS9C43h.js → AsyncState-CeDmMBla.js} +1 -1
- package/dist/web-ui/assets/{ChatComponents-B4gMEEQr.js → ChatComponents-u_iLnHEf.js} +1 -1
- package/dist/web-ui/assets/{ContentRenderer-iGJdjFvn.js → ContentRenderer-CHzFmlGx.js} +2 -2
- package/dist/web-ui/assets/{DeliverableShareModal-CY0_wqDC.js → DeliverableShareModal-By9CYH0Q.js} +1 -1
- package/dist/web-ui/assets/{Deliverables-oCzunom7.js → Deliverables-Cn_DRg-F.js} +1 -1
- package/dist/web-ui/assets/{MarkdownMessage-B-9NMrYX.js → MarkdownMessage-BX6YVVx8.js} +1 -1
- package/dist/web-ui/assets/{Search-Badheo3V.js → Search-BGSuNeNO.js} +1 -1
- package/dist/web-ui/assets/{SendToChat-X-3sK9Ph.js → SendToChat-BR3-e7d4.js} +1 -1
- package/dist/web-ui/assets/{Settings-B05tnigv.js → Settings-DJyCWAY9.js} +1 -1
- package/dist/web-ui/assets/{Store-B4hpcTFJ.js → Store-Cl-05eXo.js} +1 -1
- package/dist/web-ui/assets/{Switch-BgdJa330.js → Switch-DGrHkwcq.js} +1 -1
- package/dist/web-ui/assets/{Team-Dfz_Jkoy.js → Team-DfNOc2Oj.js} +4 -4
- package/dist/web-ui/assets/{Work-DqxE8g_Q.js → Work-Cwkb9n7H.js} +1 -1
- package/dist/web-ui/assets/{arc-Dns31Tc9.js → arc-DUrpNW2s.js} +1 -1
- package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-C0MbQViF.js → architectureDiagram-3BPJPVTR-_itbdqjs.js} +1 -1
- package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-DRAhpfjQ.js → blockDiagram-GPEHLZMM-7gcaAgpE.js} +1 -1
- package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DVAnq8L5.js → c4Diagram-AAUBKEIU-BqKuOXWt.js} +1 -1
- package/dist/web-ui/assets/channel-BNcjWETI.js +1 -0
- package/dist/web-ui/assets/{chunk-2J33WTMH-CNZ1Di5i.js → chunk-2J33WTMH-DmFCktA6.js} +1 -1
- package/dist/web-ui/assets/{chunk-4BX2VUAB-BfZWR2ax.js → chunk-4BX2VUAB-w8YtZlZ5.js} +1 -1
- package/dist/web-ui/assets/{chunk-55IACEB6-CLvm88GS.js → chunk-55IACEB6-4k-E46Qp.js} +1 -1
- package/dist/web-ui/assets/{chunk-727SXJPM-YptrHhiQ.js → chunk-727SXJPM-C1-6Iiik.js} +1 -1
- package/dist/web-ui/assets/{chunk-AQP2D5EJ-Bht-7eQm.js → chunk-AQP2D5EJ-CO4NtkeR.js} +1 -1
- package/dist/web-ui/assets/{chunk-FMBD7UC4-CXoaPK-Q.js → chunk-FMBD7UC4-CS_sseZh.js} +1 -1
- package/dist/web-ui/assets/{chunk-ND2GUHAM-Bor_8TtZ.js → chunk-ND2GUHAM-D7-BkEUG.js} +1 -1
- package/dist/web-ui/assets/{chunk-QZHKN3VN-BWVZxTBv.js → chunk-QZHKN3VN-BPCz16Gj.js} +1 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-v3_2DQPV.js +1 -0
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-v3_2DQPV.js +1 -0
- package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-Dc0GRajy.js → cose-bilkent-S5V4N54A-CpYmq76O.js} +1 -1
- package/dist/web-ui/assets/{dagre-BM42HDAG-CTnRRUJj.js → dagre-BM42HDAG-DrBF0YKT.js} +1 -1
- package/dist/web-ui/assets/{diagram-2AECGRRQ-BJpt589H.js → diagram-2AECGRRQ-CzQkjw5L.js} +1 -1
- package/dist/web-ui/assets/{diagram-5GNKFQAL-Wonl9ScH.js → diagram-5GNKFQAL-SneRBO1C.js} +1 -1
- package/dist/web-ui/assets/{diagram-KO2AKTUF-DYlCFdL8.js → diagram-KO2AKTUF-C8iAMOJw.js} +1 -1
- package/dist/web-ui/assets/{diagram-LMA3HP47-0bqbxPqr.js → diagram-LMA3HP47-C2lb4oU1.js} +1 -1
- package/dist/web-ui/assets/{diagram-OG6HWLK6-CCgq0GqI.js → diagram-OG6HWLK6-P-NuPlh6.js} +1 -1
- package/dist/web-ui/assets/{docx-preview-BvKeUHJr.js → docx-preview-YtzS0xMU.js} +1 -1
- package/dist/web-ui/assets/{erDiagram-TEJ5UH35-CLUiZPDr.js → erDiagram-TEJ5UH35-BXcYtaBT.js} +1 -1
- package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-f6pN4cw1.js → flowDiagram-I6XJVG4X-Dm48mLdd.js} +1 -1
- package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BwJkS7mo.js → ganttDiagram-6RSMTGT7-BXrfFYnN.js} +1 -1
- package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-DI2zMknR.js → gitGraphDiagram-PVQCEYII-CxO9AKdS.js} +1 -1
- package/dist/web-ui/assets/{index-Dc1HlaXE.js → index-CudHikwU.js} +6 -6
- package/dist/web-ui/assets/{infoDiagram-5YYISTIA-oD_kael7.js → infoDiagram-5YYISTIA-DSP5_m8e.js} +1 -1
- package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-CU8h8XWC.js → ishikawaDiagram-YF4QCWOH-Bsmqh7_N.js} +1 -1
- package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-0RIRYcwi.js → journeyDiagram-JHISSGLW-CCBod5iD.js} +1 -1
- package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-BbjHZ91H.js → kanban-definition-UN3LZRKU-BGbAEz6s.js} +1 -1
- package/dist/web-ui/assets/{mermaid.core-BlPZWkyC.js → mermaid.core-B17l8z4S.js} +5 -5
- package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BvaY6iLy.js → mindmap-definition-RKZ34NQL-7pahuML0.js} +1 -1
- package/dist/web-ui/assets/{pieDiagram-4H26LBE5-CHAkMEBP.js → pieDiagram-4H26LBE5-AtMgK6F2.js} +1 -1
- package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-BLmxZKSH.js → quadrantDiagram-W4KKPZXB-DxwCSN_z.js} +1 -1
- package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-CszQubly.js → requirementDiagram-4Y6WPE33-DQ4GULQe.js} +1 -1
- package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-ovwXJ_-9.js → sankeyDiagram-5OEKKPKP-DJaWWRUa.js} +1 -1
- package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-C5biPL1f.js → sequenceDiagram-3UESZ5HK-ChrFC_0T.js} +1 -1
- package/dist/web-ui/assets/{stateDiagram-AJRCARHV-B_H8A-zE.js → stateDiagram-AJRCARHV-DZthn0Xq.js} +1 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-CFMNtQOk.js +1 -0
- package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-DxHkO_i6.js → timeline-definition-PNZ67QCA-BM0bxJB9.js} +1 -1
- package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-XuByI13m.js → vennDiagram-CIIHVFJN-Buu596v7.js} +1 -1
- package/dist/web-ui/assets/{wardley-L42UT6IY-DEu5IbdV.js → wardley-L42UT6IY-FsFYXKCE.js} +1 -1
- package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-Coe77zhN.js → wardleyDiagram-YWT4CUSO-CEl-G6gD.js} +1 -1
- package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-vMLEL3LK.js → xychartDiagram-2RQKCTM6-c-k0Gyas.js} +1 -1
- package/dist/web-ui/index.html +1 -1
- package/docs/architecture/desktop-auto-update.md +46 -2
- package/package.json +1 -1
- package/dist/web-ui/assets/channel-Dll32qm6.js +0 -1
- package/dist/web-ui/assets/classDiagram-4FO5ZUOK-BAXna0Rk.js +0 -1
- package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-BAXna0Rk.js +0 -1
- package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-BHZhFie0.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-CudHikwU.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{a4 as lt,j as n,a5 as ct,r as g,u as T,a6 as Y,a1 as ve,k as U,U as Ue,a7 as ie,n as Pe,P as Ke,l as ne,$ as V,a8 as dt,A as We,a9 as ut}from"./index-Dc1HlaXE.js";import{MarkdownMessage as R}from"./MarkdownMessage-B-9NMrYX.js";import{n as pt}from"./chatChips-DVIRVTpT.js";function me({text:e,linkClassName:t="text-brand-500 hover:underline break-all"}){const r=lt(e);return r.length<=1?n.jsx(n.Fragment,{children:e}):n.jsx(n.Fragment,{children:r.map((s,a)=>s.kind==="link"?n.jsx("a",{href:s.value,target:"_blank",rel:"noopener noreferrer",className:t,onClick:o=>{o.preventDefault(),o.stopPropagation(),ct(s.value)},children:s.value},a):n.jsx(g.Fragment,{children:s.value},a))})}const xe=6e4,ze=60*xe,mt=24*ze;function Tn(e,t){const r=new Date(e).getTime();if(!Number.isFinite(r))return"";const s=Date.now()-r;if(s<xe)return t("common:time.now");const a=Math.floor(s/xe);if(a<60)return t("common:time.minutesAgo",{count:a});const o=Math.floor(s/ze);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(s/mt)})}function Sn(e,t){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return"";try{return new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}catch{return r.toLocaleString()}}const fe={suppressAdjustUntil:0};function X(e=2500){const t=typeof performance<"u"?performance.now():Date.now();fe.suppressAdjustUntil=Math.max(fe.suppressAdjustUntil,t+e)}function En(){return(typeof performance<"u"?performance.now():Date.now())<fe.suppressAdjustUntil}const Ne={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:"🔍"}},Ce={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 P(e){const t=e.includes("__")?e.split("__").pop():e,r=Ne[t]??Ne[e],s=Ce[t]??Ce[e]??"settings";return r?{...r,iconName:s,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:s,key:t}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function gt(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return`${r}-${s} ${a}:${o}:${i}`}function he(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Te(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function He(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,r])=>r!=null).map(([r,s])=>({key:r,value:typeof s=="string"?s:JSON.stringify(s,null,2)}))}function xt(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function be(e){const t=new Set;for(let r=0;r<e.length;r++){const s=e[r];if(s.type==="tool"&&(s.info.status==="done"||s.info.status==="error"))for(let a=r-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===s.info.tool&&!t.has(a)){t.add(a);break}}}return e.filter((r,s)=>!t.has(s))}function je(e){const t=gt(e.createdAt),r=e.createdAt,s=e.metadata;switch(e.type){case"text":return s?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:r}:{type:"text",content:e.content,time:t,timestamp:r};case"status":{const a=s?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:t,timestamp:r}}case"error":return{type:"error",content:e.content,time:t,timestamp:r};case"tool_start":return{type:"tool",time:t,timestamp:r,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:s?.arguments,subagentLogs:s?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:r,key:`ee_${e.seq}`,info:{tool:e.content,status:s?.success===!1?"error":"done",args:s?.arguments,result:s?.result,error:s?.error,durationMs:s?.durationMs,subagentLogs:s?.subagentLogs}};default:return null}}function Ge(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const r=JSON.parse(t);if(!r.task)return null;const s=r.task;return{taskId:s.id,title:s.title,description:s.description,assignedAgentId:s.assignedAgentId,priority:s.priority}}catch{return null}}function Ve(e,t){if(e!=="requirement_propose"||!t)return null;try{const r=JSON.parse(t);if(r.status!=="success"||!r.requirement)return null;const s=r.requirement;return s.status!=="pending"?null:{requirementId:s.id,title:s.title,description:s.description,priority:s.priority}}catch{return null}}function ft(e){const t=[];for(const r of e)if(r.phase!=="output"){if(r.phase==="start"){const s=`${r.tool}_${r.ts}`;t.push({key:s,tool:r.tool,status:"running"})}else for(let s=t.length-1;s>=0;s--)if(t[s].tool===r.tool&&t[s].status==="running"){t[s]={...t[s],status:r.success===!1?"error":"done"};break}}return t}function Xe(){return n.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function ht(){return n.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>n.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function Se({item:e}){const{t}=T("common"),r=P(e.tool);return n.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[n.jsx(Y,{name:r.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),n.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${r.key}`,{defaultValue:r.label}),e.status==="running"?"…":""]}),e.status==="running"&&n.jsx(Xe,{})]})}function Ee({activities:e,isActive:t,persistent:r}){const{t:s}=T("common"),a=ft(e),[o,i]=g.useState(!1),l=a.length>0,d=l&&a.every(x=>x.status!=="running");if(r&&d){const x=a.filter(v=>v.status==="error").length,j=a.filter(v=>v.status==="done").length;return n.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[n.jsxs("button",{onClick:()=>i(v=>!v),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[n.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:"font-medium",children:s("activity.step",{count:j})}),x>0&&n.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",s("activity.failed",{count:x})]}),!o&&n.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(v=>{const y=P(v.tool);return n.jsx(Y,{name:y.iconName,size:13,className:`shrink-0 ${v.status==="error"?"text-red-500":"text-green-500"}`},v.key)}),a.length>5&&n.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&n.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((v,y)=>n.jsx(Se,{item:v,idx:y,total:a.length},v.key))})]})}if(!l)return n.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[n.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:s("activity.thinking")}),n.jsx(ht,{})]});const c=a.filter(x=>x.status==="error").length;let u=null;for(let x=a.length-1;x>=0;x--)if(a[x].status==="running"){u=a[x];break}const b=a[a.length-1];let h;if(u){const x=P(u.tool);h=`${s(`execution.tools.${x.key}`,{defaultValue:x.label})}…`}else if(t&&d)h=s("activity.writingResponse");else{const x=P(b.tool);h=s(`execution.tools.${x.key}`,{defaultValue:x.label})}const f=!!u||t&&d;return n.jsxs("div",{className:"mb-1",children:[n.jsxs("button",{onClick:x=>{x.stopPropagation(),i(j=>!j)},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:[n.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:`truncate font-medium ${f?"activity-text-shimmer":"text-fg-secondary"}`,children:h}),n.jsxs("span",{className:"shrink-0",children:["· ",s("activity.step",{count:a.length})]}),c>0&&n.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",s("activity.failed",{count:c})]}),f&&n.jsx(Xe,{})]}),o&&n.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((x,j)=>n.jsx(Se,{item:x,idx:j,total:a.length},x.key))})]})}const bt=1920,yt=10*1024*1024,Me=5,vt=.8;function jt(e,t,r){return new Promise((s,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=t&&l<=t){s(e);return}i>l?(l=Math.round(l*(t/i)),i=t):(i=Math.round(i*(t/l)),l=t);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),s(d.toDataURL("image/jpeg",r))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function kt({candidates:e,filter:t,anchorRef:r,onSelect:s,selectedIndex:a,onIndexChange:o}){const{t:i}=T("common"),[l,d]=g.useState(null),c=g.useRef(null),u=e.filter(b=>b.name.toLowerCase().includes(t));return g.useEffect(()=>{const b=r.current;if(!b)return;const h=b.getBoundingClientRect();d({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[r,t]),g.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const h=r.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.bottom+window.scrollY+4,left:l.left})}},[l,r]),g.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),g.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:ve.createPortal(n.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:[n.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((b,h)=>n.jsxs("button",{"data-selected":h===a,onMouseDown:f=>{f.preventDefault(),s(b)},onMouseEnter:()=>o(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[n.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${b.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:b.name.slice(0,2).toUpperCase()}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"text-fg-primary font-medium",children:b.name}),n.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:b.subtitle??b.type})]}),b.type==="agent"&&n.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${b.online?"bg-green-400":"bg-gray-500"}`})]},b.id))]}),document.body)}function wt(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Ae=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function Mn(e){const t=[];let r;for(Ae.lastIndex=0;(r=Ae.exec(e))!==null;)t.push(r[1]??r[2]);return t}function An(e,t,r){const s=[];let a=0;const o=t.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){s.push(n.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&s.push(n.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const f=e.indexOf("]",l+2);if(f>l+2){const x=e.slice(l+2,f),j=t.find(v=>v.name.toLowerCase()===x.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&j?"cursor-pointer hover:underline":""}`,onClick:r&&j?v=>r(j,v):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",x]},a++)),i=f+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(f=>c.startsWith(f.toLowerCase()));if(u){const f=t.find(x=>x.name.toLowerCase()===u.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&f?"cursor-pointer hover:underline":""}`,onClick:r&&f?x=>r(f,x):void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const b=/^([\w\p{L}\p{N}]+)/u,h=d.match(b);if(h){const f=h[1],x=t.find(j=>j.name.toLowerCase()===f.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&x?"cursor-pointer hover:underline":""}`,onClick:r&&x?j=>r(x,j):void 0,title:x?`${x.name} (${x.role})`:void 0,children:["@",f]},a++)),i=l+1+f.length;continue}s.push(n.jsx("span",{children:"@"},a++)),i=l+1}return s.length>0?s:[n.jsx("span",{children:e},0)]}function Ln({agents:e,humans:t,onSubmit:r,placeholder:s,replyTo:a,onCancelReply:o}){const{t:i}=T("common"),[l,d]=g.useState(""),[c,u]=g.useState(!1),[b,h]=g.useState(null),[f,x]=g.useState(!1),[j,v]=g.useState(""),[y,m]=g.useState([]),[w,k]=g.useState(0),[N,L]=g.useState([]),[ce,B]=g.useState(!1),F=g.useRef(null),$=g.useRef(null),E=g.useRef(null),A=g.useMemo(()=>{const p=(t??[]).map(_=>({id:_.id,name:_.name,type:"human",subtitle:_.role}));for(const _ of e)p.push({id:_.id,name:_.name,type:"agent",subtitle:_.role,online:_.status==="idle"||_.status==="working"});return p},[e,t]),D=A.filter(p=>p.name.toLowerCase().includes(j)),q=g.useCallback(p=>{const _=Array.from(p).filter(C=>C.type.startsWith("image/"));if(_.length!==0)for(const C of _){if(C.size>yt)continue;const M=new FileReader;M.onload=()=>{const te=M.result;jt(te,bt,vt).then(I=>{L(pe=>pe.length>=Me?pe:[...pe,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:I,name:C.name}])})},M.readAsDataURL(C)}},[]),_e=g.useCallback(p=>{L(_=>_.filter(C=>C.id!==p))},[]),H=g.useCallback(p=>{const _=p.clipboardData?.files;if(_&&_.length>0){const C=Array.from(_).filter(M=>M.type.startsWith("image/"));C.length>0&&(p.preventDefault(),q(C))}},[q]),de=g.useCallback(p=>{p.preventDefault(),B(!1);const _=p.dataTransfer?.files;_&&_.length>0&&q(Array.from(_).filter(C=>C.type.startsWith("image/")))},[q]),O=g.useCallback(p=>{p.preventDefault(),B(!0)},[]),G=g.useCallback(()=>{B(!1)},[]),J=async()=>{if(!(!l.trim()&&N.length===0)){u(!0),h(null),E.current={content:l,mentions:[...y],images:[...N]};try{await r(l,y,[...N],a?.id),d(""),m([]),L([]),E.current=null,o?.()}catch(p){h(String(p instanceof Error?p.message:p)||i("commentInput.sendFailed"))}u(!1)}},Q=async()=>{if(!E.current)return;const{content:p,mentions:_,images:C}=E.current;u(!0),h(null);try{await r(p,_,C),d(""),m([]),L([]),E.current=null}catch(M){h(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},Z=g.useCallback(p=>{d(_=>{const C=_.lastIndexOf("@"),M=wt(p.name);return C>=0?_.slice(0,C)+M+" ":_+M+" "}),y.includes(p.id)||m(_=>[..._,p.id]),x(!1),v(""),k(0),F.current?.focus()},[y]),ue=p=>{d(p),h(null);const _=p.lastIndexOf("@");if(_>=0&&(_===0||p[_-1]===" ")){const M=p.slice(_+1).toLowerCase();if(A.some(I=>I.name.toLowerCase().includes(M))){v(M),x(!0),k(0);return}}x(!1)},ee=p=>{if(f&&D.length>0){const _=p.key==="ArrowUp"||p.ctrlKey&&p.key==="p",C=p.key==="ArrowDown"||p.ctrlKey&&p.key==="n",M=p.key==="Enter"||p.key==="Tab",te=p.key==="Escape";if(_){p.preventDefault(),k(I=>(I-1+D.length)%D.length);return}if(C){p.preventDefault(),k(I=>(I+1)%D.length);return}if(M){p.preventDefault();const I=D[w];I&&Z(I);return}if(te){p.preventDefault(),x(!1);return}}p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),J())},W=g.useCallback(()=>{setTimeout(()=>x(!1),200)},[]);return n.jsxs("div",{className:"relative",onDragOver:O,onDragLeave:G,onDrop:de,children:[ce&&n.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:n.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),f&&n.jsx(kt,{candidates:A,filter:j,anchorRef:F,onSelect:Z,selectedIndex:w,onIndexChange:k}),n.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[n.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[n.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),n.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),n.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y.length>0&&n.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:y.map(p=>{const _=A.find(C=>C.id===p);return n.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${_?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",_?.name??p,n.jsx("button",{onClick:()=>m(C=>C.filter(M=>M!==p)),className:"hover:text-red-400",children:"×"})]},p)})}),n.jsx("textarea",{ref:F,value:l,onChange:p=>ue(p.target.value),onKeyDown:ee,onBlur:W,onPaste:H,placeholder:s??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"}),N.length>0&&n.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(p=>n.jsxs("div",{className:"relative group/img shrink-0",children:[n.jsx("img",{src:p.dataUrl,alt:p.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),n.jsx("button",{onClick:()=>_e(p.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:"×"})]},p.id))}),b&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[n.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:b}),n.jsxs("button",{onClick:Q,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[n.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[n.jsx("button",{type:"button",onClick:()=>$.current?.click(),disabled:c||N.length>=Me,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:n.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),n.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),n.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),n.jsx("input",{ref:$,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>{p.target.files&&q(p.target.files),p.target.value=""}}),n.jsx("button",{onClick:J,disabled:!l.trim()&&N.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&&n.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:n.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),n.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function In(e){const t={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(t.chips=e.chips),e.images&&e.images.length>0&&(t.images=e.images),e.replyTo&&(t.replyToId=e.replyTo.id,t.replyToSender=e.replyTo.sender,t.replyToText=e.replyTo.text),t}function _t(e,t){return!!e&&t==="agent"}const Nt=24e3,Ct=200;function Rn(e,t,r=Nt){const s=(e??"")+t;return s.length<=r?s:s.slice(s.length-r)}function $n(e,t,r=Ct){const s=[...e??[],t];return s.length<=r?s:s.slice(s.length-r)}function Ye(e){return!!e.text?.trim()||(e.segments??[]).some(t=>t.type==="text"&&(t.content||t.thinking)||t.type==="tool")}function Dn(e,t){return!!(e.sender==="user"||Ye(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||t&&!e.isStopped)}function Tt(e,t=8){for(let r=e.length-1;r>=Math.max(0,e.length-t);r--){const s=e[r];if(s.isStreaming&&!s.isStopped)return!0}return!1}function ke(e){if(!e||e.length===0)return e;let t=!1;const r=e.map(s=>s.type==="tool"&&s.status==="running"?(t=!0,{...s,status:"stopped"}):s);return t?r:e}function Je(e,t){if(!Ye(e)&&t!=="done")return null;const s={...e,isStreaming:!1,segments:ke(e.segments)};switch(t){case"done":return{...s,isStopped:!1,isError:!1};case"stopped":return{...s,isStopped:!0,isError:!1};case"error":return{...s,isStopped:!0,isError:!0}}}function qn(e){const t=[...e];for(let r=t.length-1;r>=0;r--)if(t[r].sender==="agent"&&!t[r].isStopped&&!t[r].isError){const s=Je(t[r],"stopped");s===null?t.splice(r,1):t[r]=s;break}return t}function On(e,t){if(t){const r=e.findIndex(s=>s.id===t);if(r>=0){const s=e[r],a=ke(s.segments);if(!s.isStreaming&&a===s.segments)return e;const o=[...e];return o[r]={...s,isStreaming:!1,segments:a},o}}return St(e)}function St(e){return Tt(e)?e.map(t=>t.sender!=="agent"||!t.isStreaming||t.isStopped?t:{...t,isStreaming:!1,segments:ke(t.segments)}):e}function Bn(e,t,r){return!t||!r||t===r?e:e.some(s=>s.id===r)?e.filter(s=>s.id!==t):e.map(s=>s.id===t?{...s,id:r}:s)}function Fn(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.sender==="agent"&&r.isStreaming)return t}return-1}function Un(e){return e.sendSessionId?e.authorityStreaming:!1}function Pn(e){const t=e.liveSessions;return!t||t.size===0||!e.sessionId?!0:!t.has(e.sessionId)&&!t.has(e.placeholderId)}function Kn(e){if(!e.isActive||e.previewMode||e.chatMode!=="direct"||!e.selectedAgent)return null;const t=e.activeSessionId;return!t||t===e.placeholderId?null:t}function Wn(e,t="stopped"){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.sender==="agent"&&s.isStreaming&&!s.isStopped){const a=Je(s,t);if(a===null)return e.filter((i,l)=>l!==r);const o=[...e];return o[r]=a,o}}return e}function zn(e,t){if(e.some(o=>o.id===t.id))return e;const r=t.rawCreatedAt?Date.parse(t.rawCreatedAt):NaN;if(!Number.isFinite(r)||e.length===0)return[...e,t];let s=e.length;for(;s>0;){const o=e[s-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=r)break;s--}if(s===e.length)return[...e,t];const a=e.slice();return a.splice(s,0,t),a}function Hn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,thinking:(r.thinking??"")+t}]:[...e,{type:"text",content:"",thinking:t,createdAt:new Date().toISOString()}]}function Gn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,content:r.content+t}]:[...e,{type:"text",content:t,createdAt:new Date().toISOString()}]}const Et=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function we(e){if(!e.includes("notify_context"))return{cleaned:e};let t;const r=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(r?.[1]){const s=r[1].match(/priority\s*=\s*(\w+)/i);s&&(t=s[1])}return{cleaned:e.replace(Et,"").trimEnd(),priority:t}}const Mt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,At=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Vn(e){return e.replace(Mt,"").replace(At,"")}function Lt(e,t,r){if(e.type!=="tool"){const{cleaned:l}=we(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const s=r?.type==="tool"&&r.tool===e.tool?r:void 0,a=e.subagentLogs?.length??0,o=s?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:s?.subagentLogs;return{type:"tool",key:`${e.tool}_${t}`,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 Qe(e,t){const r=(t??[]).filter(a=>a.type==="tool");let s=0;return e.map((a,o)=>{const i=a.type==="tool"?r[s++]:void 0;return Lt(a,o,i)})}const re=new Map,It=2e3;function Ze(e){if(!e)return"";const t=re.get(e);if(t!==void 0)return t;const r=new Date(e),s=isNaN(r.getTime())?"":r.toLocaleTimeString();return re.size>=It&&re.clear(),re.set(e,s),s}function Xn(e){const t={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Ze(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(t.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(t.segments=Qe(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(t.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(t.isError=!0,t.errorRaw=e.content),e.metadata?.emptyReply===!0&&(t.emptyReply=!0,t.isStopped||(t.isError=!0)),e.metadata?.isStreaming&&(t.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(t.isStopped=!0),e.metadata?.images?.length&&(t.images=e.metadata.images),e.metadata?.notifyUser&&(t.isNotification=!0,t.notifyPriority=e.metadata.priority,e.metadata.taskId&&(t.taskId=e.metadata.taskId),e.metadata.requirementId&&(t.requirementId=e.metadata.requirementId)),t.text.includes("<!-- notify_context:")){const{cleaned:r,priority:s}=we(t.text);t.text=r,s&&!t.notifyPriority&&(t.notifyPriority=s),t.isNotification=!0}if(e.metadata?.activityLog&&(t.isActivityLog=!0,t.activityType=e.metadata.activityType,t.outcome=e.metadata.outcome,t.mailboxItemId=e.metadata.mailboxItemId,t.taskId=e.metadata.taskId,t.requirementId=e.metadata.requirementId,!t.outcome&&t.text.startsWith("[ACTIVITY:"))){const r=t.text.lastIndexOf(" → ");r!==-1&&(t.outcome=t.text.slice(r+3)),t.text=t.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(t.replyToId=e.metadata.replyToId,t.replyToSender=e.metadata.replyToSender,t.replyToText=e.metadata.replyToText,t.text=et(t.text,t.replyToSender,t.replyToText)),e.role==="user"){const r=pt(e.metadata?.chips);r&&(t.chips=r)}return t}function et(e,t,r){if(!e||!t||!r)return e;const s=`> **${t}**: ${r}
|
|
1
|
+
import{a4 as lt,j as n,a5 as ct,r as g,u as T,a6 as Y,a1 as ve,k as U,U as Ue,a7 as ie,n as Pe,P as Ke,l as ne,$ as V,a8 as dt,A as We,a9 as ut}from"./index-CudHikwU.js";import{MarkdownMessage as R}from"./MarkdownMessage-BX6YVVx8.js";import{n as pt}from"./chatChips-DVIRVTpT.js";function me({text:e,linkClassName:t="text-brand-500 hover:underline break-all"}){const r=lt(e);return r.length<=1?n.jsx(n.Fragment,{children:e}):n.jsx(n.Fragment,{children:r.map((s,a)=>s.kind==="link"?n.jsx("a",{href:s.value,target:"_blank",rel:"noopener noreferrer",className:t,onClick:o=>{o.preventDefault(),o.stopPropagation(),ct(s.value)},children:s.value},a):n.jsx(g.Fragment,{children:s.value},a))})}const xe=6e4,ze=60*xe,mt=24*ze;function Tn(e,t){const r=new Date(e).getTime();if(!Number.isFinite(r))return"";const s=Date.now()-r;if(s<xe)return t("common:time.now");const a=Math.floor(s/xe);if(a<60)return t("common:time.minutesAgo",{count:a});const o=Math.floor(s/ze);return o<24?t("common:time.hoursAgo",{count:o}):t("common:time.daysAgo",{count:Math.floor(s/mt)})}function Sn(e,t){if(!e)return"";const r=new Date(e);if(Number.isNaN(r.getTime()))return"";try{return new Intl.DateTimeFormat(t||void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(r)}catch{return r.toLocaleString()}}const fe={suppressAdjustUntil:0};function X(e=2500){const t=typeof performance<"u"?performance.now():Date.now();fe.suppressAdjustUntil=Math.max(fe.suppressAdjustUntil,t+e)}function En(){return(typeof performance<"u"?performance.now():Date.now())<fe.suppressAdjustUntil}const Ne={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:"🔍"}},Ce={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 P(e){const t=e.includes("__")?e.split("__").pop():e,r=Ne[t]??Ne[e],s=Ce[t]??Ce[e]??"settings";return r?{...r,iconName:s,key:t}:{label:t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase()),icon:"⚙",iconName:s,key:t}}function K(e){return e==null?"":e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function gt(e){const t=new Date(e);if(isNaN(t.getTime()))return e;const r=String(t.getMonth()+1).padStart(2,"0"),s=String(t.getDate()).padStart(2,"0"),a=String(t.getHours()).padStart(2,"0"),o=String(t.getMinutes()).padStart(2,"0"),i=String(t.getSeconds()).padStart(2,"0");return`${r}-${s} ${a}:${o}:${i}`}function he(e,t){return e.length<=t?e:e.slice(0,t)+"…"}function Te(e){try{const t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}function He(e){return!e||typeof e!="object"?[]:Object.entries(e).filter(([,r])=>r!=null).map(([r,s])=>({key:r,value:typeof s=="string"?s:JSON.stringify(s,null,2)}))}function xt(e){if(e.tool!=="shell_execute"||!e.args||typeof e.args!="object")return null;const t=e.args.command;return typeof t=="string"?t:null}function be(e){const t=new Set;for(let r=0;r<e.length;r++){const s=e[r];if(s.type==="tool"&&(s.info.status==="done"||s.info.status==="error"))for(let a=r-1;a>=0;a--){const o=e[a];if(o.type==="tool"&&o.info.status==="running"&&o.info.tool===s.info.tool&&!t.has(a)){t.add(a);break}}}return e.filter((r,s)=>!t.has(s))}function je(e){const t=gt(e.createdAt),r=e.createdAt,s=e.metadata;switch(e.type){case"text":return s?.isThinking?{type:"thinking",content:e.content,time:t,timestamp:r}:{type:"text",content:e.content,time:t,timestamp:r};case"status":{const a=s?.action;return a&&["chat","chat_stream","task_execution","respond_in_session"].includes(a)?null:{type:"status",content:e.content,time:t,timestamp:r}}case"error":return{type:"error",content:e.content,time:t,timestamp:r};case"tool_start":return{type:"tool",time:t,timestamp:r,key:`es_${e.seq}`,info:{tool:e.content,status:"running",args:s?.arguments,subagentLogs:s?.subagentLogs}};case"tool_end":return{type:"tool",time:t,timestamp:r,key:`ee_${e.seq}`,info:{tool:e.content,status:s?.success===!1?"error":"done",args:s?.arguments,result:s?.result,error:s?.error,durationMs:s?.durationMs,subagentLogs:s?.subagentLogs}};default:return null}}function Ge(e,t){if(e!=="task_create"&&e!=="create_task"||!t)return null;try{const r=JSON.parse(t);if(!r.task)return null;const s=r.task;return{taskId:s.id,title:s.title,description:s.description,assignedAgentId:s.assignedAgentId,priority:s.priority}}catch{return null}}function Ve(e,t){if(e!=="requirement_propose"||!t)return null;try{const r=JSON.parse(t);if(r.status!=="success"||!r.requirement)return null;const s=r.requirement;return s.status!=="pending"?null:{requirementId:s.id,title:s.title,description:s.description,priority:s.priority}}catch{return null}}function ft(e){const t=[];for(const r of e)if(r.phase!=="output"){if(r.phase==="start"){const s=`${r.tool}_${r.ts}`;t.push({key:s,tool:r.tool,status:"running"})}else for(let s=t.length-1;s>=0;s--)if(t[s].tool===r.tool&&t[s].status==="running"){t[s]={...t[s],status:r.success===!1?"error":"done"};break}}return t}function Xe(){return n.jsxs("svg",{className:"w-3 h-3 animate-spin text-brand-500 shrink-0",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}function ht(){return n.jsx("span",{className:"flex items-center gap-0.5",children:[0,150,300].map(e=>n.jsx("span",{className:"w-1 h-1 rounded-full bg-brand-400 animate-bounce",style:{animationDelay:`${e}ms`,animationDuration:"1s"}},e))})}function Se({item:e}){const{t}=T("common"),r=P(e.tool);return n.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",children:[n.jsx(Y,{name:r.iconName,size:15,className:`shrink-0 ${e.status==="running"?"text-brand-500":e.status==="error"?"text-red-500":"text-green-500"}`}),n.jsxs("span",{className:`text-xs ${e.status==="running"?"activity-text-shimmer":e.status==="error"?"text-fg-tertiary":"text-fg-secondary"}`,children:[t(`execution.tools.${r.key}`,{defaultValue:r.label}),e.status==="running"?"…":""]}),e.status==="running"&&n.jsx(Xe,{})]})}function Ee({activities:e,isActive:t,persistent:r}){const{t:s}=T("common"),a=ft(e),[o,i]=g.useState(!1),l=a.length>0,d=l&&a.every(x=>x.status!=="running");if(r&&d){const x=a.filter(v=>v.status==="error").length,j=a.filter(v=>v.status==="done").length;return n.jsxs("div",{className:"mb-3 border-b border-border-default/50 pb-2",children:[n.jsxs("button",{onClick:()=>i(v=>!v),className:"flex items-center gap-1.5 text-xs text-fg-tertiary hover:text-fg-secondary transition-colors select-none",children:[n.jsx("span",{className:`transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:"font-medium",children:s("activity.step",{count:j})}),x>0&&n.jsxs("span",{className:"text-red-500 ml-0.5",children:["· ",s("activity.failed",{count:x})]}),!o&&n.jsxs("span",{className:"ml-1 flex items-center gap-1",children:[a.slice(0,5).map(v=>{const y=P(v.tool);return n.jsx(Y,{name:y.iconName,size:13,className:`shrink-0 ${v.status==="error"?"text-red-500":"text-green-500"}`},v.key)}),a.length>5&&n.jsxs("span",{className:"text-[10px] text-fg-tertiary",children:["+",a.length-5]})]})]}),o&&n.jsx("div",{className:"mt-2 space-y-0.5",children:a.map((v,y)=>n.jsx(Se,{item:v,idx:y,total:a.length},v.key))})]})}if(!l)return n.jsxs("div",{className:"flex items-center gap-1.5 text-xs py-0.5",children:[n.jsx("span",{className:"mr-0.5 activity-text-shimmer",children:s("activity.thinking")}),n.jsx(ht,{})]});const c=a.filter(x=>x.status==="error").length;let u=null;for(let x=a.length-1;x>=0;x--)if(a[x].status==="running"){u=a[x];break}const b=a[a.length-1];let h;if(u){const x=P(u.tool);h=`${s(`execution.tools.${x.key}`,{defaultValue:x.label})}…`}else if(t&&d)h=s("activity.writingResponse");else{const x=P(b.tool);h=s(`execution.tools.${x.key}`,{defaultValue:x.label})}const f=!!u||t&&d;return n.jsxs("div",{className:"mb-1",children:[n.jsxs("button",{onClick:x=>{x.stopPropagation(),i(j=>!j)},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:[n.jsx("span",{className:`shrink-0 transition-transform duration-150 ${o?"rotate-90":""}`,children:"▶"}),n.jsx("span",{className:`truncate font-medium ${f?"activity-text-shimmer":"text-fg-secondary"}`,children:h}),n.jsxs("span",{className:"shrink-0",children:["· ",s("activity.step",{count:a.length})]}),c>0&&n.jsxs("span",{className:"text-red-500 shrink-0",children:["· ",s("activity.failed",{count:c})]}),f&&n.jsx(Xe,{})]}),o&&n.jsx("div",{className:"mt-1 space-y-0.5",children:a.map((x,j)=>n.jsx(Se,{item:x,idx:j,total:a.length},x.key))})]})}const bt=1920,yt=10*1024*1024,Me=5,vt=.8;function jt(e,t,r){return new Promise((s,a)=>{const o=new Image;o.onload=()=>{let{width:i,height:l}=o;if(i<=t&&l<=t){s(e);return}i>l?(l=Math.round(l*(t/i)),i=t):(i=Math.round(i*(t/l)),l=t);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),s(d.toDataURL("image/jpeg",r))},o.onerror=()=>a(new Error("Failed to load image")),o.src=e})}function kt({candidates:e,filter:t,anchorRef:r,onSelect:s,selectedIndex:a,onIndexChange:o}){const{t:i}=T("common"),[l,d]=g.useState(null),c=g.useRef(null),u=e.filter(b=>b.name.toLowerCase().includes(t));return g.useEffect(()=>{const b=r.current;if(!b)return;const h=b.getBoundingClientRect();d({top:h.top+window.scrollY-4,left:h.left+window.scrollX+8})},[r,t]),g.useEffect(()=>{if(!c.current||!l)return;if(c.current.getBoundingClientRect().top<8){const h=r.current;if(!h)return;const f=h.getBoundingClientRect();d({top:f.bottom+window.scrollY+4,left:l.left})}},[l,r]),g.useEffect(()=>{a>=u.length&&o(Math.max(0,u.length-1))},[u.length,a,o]),g.useEffect(()=>{if(!c.current)return;c.current.querySelector('[data-selected="true"]')?.scrollIntoView({block:"nearest"})},[a]),!l||u.length===0?null:ve.createPortal(n.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:[n.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((b,h)=>n.jsxs("button",{"data-selected":h===a,onMouseDown:f=>{f.preventDefault(),s(b)},onMouseEnter:()=>o(h),className:`w-full text-left px-3 py-2 text-xs flex items-center gap-2 transition-colors ${h===a?"bg-brand-500/15 text-brand-500":"hover:bg-surface-elevated"}`,children:[n.jsx("span",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[10px] font-bold shrink-0 ${b.type==="human"?"bg-green-500/20 text-green-500":"bg-brand-500/20 text-brand-500"}`,children:b.name.slice(0,2).toUpperCase()}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsx("span",{className:"text-fg-primary font-medium",children:b.name}),n.jsx("span",{className:"text-fg-tertiary text-[10px] ml-1.5",children:b.subtitle??b.type})]}),b.type==="agent"&&n.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${b.online?"bg-green-400":"bg-gray-500"}`})]},b.id))]}),document.body)}function wt(e){return/^\w+$/.test(e)?`@${e}`:`@[${e}]`}const Ae=/@\[([^\]]+)\]|@([\w\p{L}\p{N}]+)/gu;function Mn(e){const t=[];let r;for(Ae.lastIndex=0;(r=Ae.exec(e))!==null;)t.push(r[1]??r[2]);return t}function An(e,t,r){const s=[];let a=0;const o=t.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){s.push(n.jsx("span",{children:e.slice(i)},a++));break}if(l>i&&s.push(n.jsx("span",{children:e.slice(i,l)},a++)),e[l+1]==="["){const f=e.indexOf("]",l+2);if(f>l+2){const x=e.slice(l+2,f),j=t.find(v=>v.name.toLowerCase()===x.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&j?"cursor-pointer hover:underline":""}`,onClick:r&&j?v=>r(j,v):void 0,title:j?`${j.name} (${j.role})`:void 0,children:["@",x]},a++)),i=f+1;continue}}const d=e.slice(l+1),c=d.toLowerCase(),u=o.find(f=>c.startsWith(f.toLowerCase()));if(u){const f=t.find(x=>x.name.toLowerCase()===u.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&f?"cursor-pointer hover:underline":""}`,onClick:r&&f?x=>r(f,x):void 0,title:f?`${f.name} (${f.role})`:void 0,children:["@",u]},a++)),i=l+1+u.length;continue}const b=/^([\w\p{L}\p{N}]+)/u,h=d.match(b);if(h){const f=h[1],x=t.find(j=>j.name.toLowerCase()===f.toLowerCase());s.push(n.jsxs("span",{className:`text-brand-500 font-medium ${r&&x?"cursor-pointer hover:underline":""}`,onClick:r&&x?j=>r(x,j):void 0,title:x?`${x.name} (${x.role})`:void 0,children:["@",f]},a++)),i=l+1+f.length;continue}s.push(n.jsx("span",{children:"@"},a++)),i=l+1}return s.length>0?s:[n.jsx("span",{children:e},0)]}function Ln({agents:e,humans:t,onSubmit:r,placeholder:s,replyTo:a,onCancelReply:o}){const{t:i}=T("common"),[l,d]=g.useState(""),[c,u]=g.useState(!1),[b,h]=g.useState(null),[f,x]=g.useState(!1),[j,v]=g.useState(""),[y,m]=g.useState([]),[w,k]=g.useState(0),[N,L]=g.useState([]),[ce,B]=g.useState(!1),F=g.useRef(null),$=g.useRef(null),E=g.useRef(null),A=g.useMemo(()=>{const p=(t??[]).map(_=>({id:_.id,name:_.name,type:"human",subtitle:_.role}));for(const _ of e)p.push({id:_.id,name:_.name,type:"agent",subtitle:_.role,online:_.status==="idle"||_.status==="working"});return p},[e,t]),D=A.filter(p=>p.name.toLowerCase().includes(j)),q=g.useCallback(p=>{const _=Array.from(p).filter(C=>C.type.startsWith("image/"));if(_.length!==0)for(const C of _){if(C.size>yt)continue;const M=new FileReader;M.onload=()=>{const te=M.result;jt(te,bt,vt).then(I=>{L(pe=>pe.length>=Me?pe:[...pe,{id:`img_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,dataUrl:I,name:C.name}])})},M.readAsDataURL(C)}},[]),_e=g.useCallback(p=>{L(_=>_.filter(C=>C.id!==p))},[]),H=g.useCallback(p=>{const _=p.clipboardData?.files;if(_&&_.length>0){const C=Array.from(_).filter(M=>M.type.startsWith("image/"));C.length>0&&(p.preventDefault(),q(C))}},[q]),de=g.useCallback(p=>{p.preventDefault(),B(!1);const _=p.dataTransfer?.files;_&&_.length>0&&q(Array.from(_).filter(C=>C.type.startsWith("image/")))},[q]),O=g.useCallback(p=>{p.preventDefault(),B(!0)},[]),G=g.useCallback(()=>{B(!1)},[]),J=async()=>{if(!(!l.trim()&&N.length===0)){u(!0),h(null),E.current={content:l,mentions:[...y],images:[...N]};try{await r(l,y,[...N],a?.id),d(""),m([]),L([]),E.current=null,o?.()}catch(p){h(String(p instanceof Error?p.message:p)||i("commentInput.sendFailed"))}u(!1)}},Q=async()=>{if(!E.current)return;const{content:p,mentions:_,images:C}=E.current;u(!0),h(null);try{await r(p,_,C),d(""),m([]),L([]),E.current=null}catch(M){h(String(M instanceof Error?M.message:M)||i("commentInput.sendFailed"))}u(!1)},Z=g.useCallback(p=>{d(_=>{const C=_.lastIndexOf("@"),M=wt(p.name);return C>=0?_.slice(0,C)+M+" ":_+M+" "}),y.includes(p.id)||m(_=>[..._,p.id]),x(!1),v(""),k(0),F.current?.focus()},[y]),ue=p=>{d(p),h(null);const _=p.lastIndexOf("@");if(_>=0&&(_===0||p[_-1]===" ")){const M=p.slice(_+1).toLowerCase();if(A.some(I=>I.name.toLowerCase().includes(M))){v(M),x(!0),k(0);return}}x(!1)},ee=p=>{if(f&&D.length>0){const _=p.key==="ArrowUp"||p.ctrlKey&&p.key==="p",C=p.key==="ArrowDown"||p.ctrlKey&&p.key==="n",M=p.key==="Enter"||p.key==="Tab",te=p.key==="Escape";if(_){p.preventDefault(),k(I=>(I-1+D.length)%D.length);return}if(C){p.preventDefault(),k(I=>(I+1)%D.length);return}if(M){p.preventDefault();const I=D[w];I&&Z(I);return}if(te){p.preventDefault(),x(!1);return}}p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),J())},W=g.useCallback(()=>{setTimeout(()=>x(!1),200)},[]);return n.jsxs("div",{className:"relative",onDragOver:O,onDragLeave:G,onDrop:de,children:[ce&&n.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:n.jsx("span",{className:"text-sm text-brand-500 font-medium",children:i("commentInput.dragDropHint")})}),f&&n.jsx(kt,{candidates:A,filter:j,anchorRef:F,onSelect:Z,selectedIndex:w,onIndexChange:k}),n.jsxs("div",{className:"border border-border-default rounded-lg bg-surface-elevated",children:[a&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pt-2 pb-1 border-b border-border-default/50",children:[n.jsxs("div",{className:"flex-1 min-w-0 pl-2 border-l-2 border-brand-500/50",children:[n.jsx("span",{className:"text-[10px] font-medium text-brand-500",children:a.authorName}),n.jsx("p",{className:"text-[10px] text-fg-tertiary truncate",children:a.content})]}),n.jsx("button",{onClick:o,className:"text-fg-tertiary hover:text-fg-secondary shrink-0 p-0.5",children:n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),n.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y.length>0&&n.jsx("div",{className:"flex gap-1 px-2.5 pt-2 flex-wrap",children:y.map(p=>{const _=A.find(C=>C.id===p);return n.jsxs("span",{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded-full ${_?.type==="human"?"bg-green-500/15 text-green-500":"bg-brand-500/15 text-brand-500"}`,children:["@",_?.name??p,n.jsx("button",{onClick:()=>m(C=>C.filter(M=>M!==p)),className:"hover:text-red-400",children:"×"})]},p)})}),n.jsx("textarea",{ref:F,value:l,onChange:p=>ue(p.target.value),onKeyDown:ee,onBlur:W,onPaste:H,placeholder:s??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"}),N.length>0&&n.jsx("div",{className:"flex items-center gap-1.5 px-2.5 pb-1.5 overflow-x-auto",children:N.map(p=>n.jsxs("div",{className:"relative group/img shrink-0",children:[n.jsx("img",{src:p.dataUrl,alt:p.name,className:"w-12 h-12 rounded-lg object-cover border border-border-default"}),n.jsx("button",{onClick:()=>_e(p.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:"×"})]},p.id))}),b&&n.jsxs("div",{className:"flex items-center gap-2 px-2.5 pb-1.5",children:[n.jsx("span",{className:"text-[11px] text-red-400 flex-1 truncate",children:b}),n.jsxs("button",{onClick:Q,disabled:c,className:"text-[11px] text-amber-500 hover:text-amber-400 font-medium transition-colors flex items-center gap-1",children:[n.jsxs("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("polyline",{points:"23 4 23 10 17 10"}),n.jsx("path",{d:"M20.49 15a9 9 0 11-2.12-9.36L23 10"})]}),i("commentInput.retry")]})]}),n.jsxs("div",{className:"flex items-center justify-between px-2.5 pb-2",children:[n.jsx("button",{type:"button",onClick:()=>$.current?.click(),disabled:c||N.length>=Me,className:"p-1 text-fg-tertiary hover:text-brand-500 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:i("commentInput.attachImage"),children:n.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),n.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),n.jsx("polyline",{points:"21 15 16 10 5 21"})]})}),n.jsx("input",{ref:$,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:p=>{p.target.files&&q(p.target.files),p.target.value=""}}),n.jsx("button",{onClick:J,disabled:!l.trim()&&N.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&&n.jsx("div",{className:"mt-0.5 -mb-0.5 flex justify-end px-2.5 pointer-events-none select-none",children:n.jsx("span",{className:"text-[10px] text-fg-tertiary/80",children:i("common:shiftEnterHint")})}),n.jsx("p",{className:"mt-1 text-center text-[10px] text-fg-tertiary/80 select-none",children:i("aiDisclaimer")})]})}function In(e){const t={id:e.id,sender:"user",text:e.text,time:e.time,rawCreatedAt:e.rawCreatedAt};return e.chips&&e.chips.length>0&&(t.chips=e.chips),e.images&&e.images.length>0&&(t.images=e.images),e.replyTo&&(t.replyToId=e.replyTo.id,t.replyToSender=e.replyTo.sender,t.replyToText=e.replyTo.text),t}function _t(e,t){return!!e&&t==="agent"}const Nt=24e3,Ct=200;function Rn(e,t,r=Nt){const s=(e??"")+t;return s.length<=r?s:s.slice(s.length-r)}function $n(e,t,r=Ct){const s=[...e??[],t];return s.length<=r?s:s.slice(s.length-r)}function Ye(e){return!!e.text?.trim()||(e.segments??[]).some(t=>t.type==="text"&&(t.content||t.thinking)||t.type==="tool")}function Dn(e,t){return!!(e.sender==="user"||Ye(e)||(e.activities?.length??0)>0||(e.images?.length??0)>0||e.emptyReply===!0||t&&!e.isStopped)}function Tt(e,t=8){for(let r=e.length-1;r>=Math.max(0,e.length-t);r--){const s=e[r];if(s.isStreaming&&!s.isStopped)return!0}return!1}function ke(e){if(!e||e.length===0)return e;let t=!1;const r=e.map(s=>s.type==="tool"&&s.status==="running"?(t=!0,{...s,status:"stopped"}):s);return t?r:e}function Je(e,t){if(!Ye(e)&&t!=="done")return null;const s={...e,isStreaming:!1,segments:ke(e.segments)};switch(t){case"done":return{...s,isStopped:!1,isError:!1};case"stopped":return{...s,isStopped:!0,isError:!1};case"error":return{...s,isStopped:!0,isError:!0}}}function qn(e){const t=[...e];for(let r=t.length-1;r>=0;r--)if(t[r].sender==="agent"&&!t[r].isStopped&&!t[r].isError){const s=Je(t[r],"stopped");s===null?t.splice(r,1):t[r]=s;break}return t}function On(e,t){if(t){const r=e.findIndex(s=>s.id===t);if(r>=0){const s=e[r],a=ke(s.segments);if(!s.isStreaming&&a===s.segments)return e;const o=[...e];return o[r]={...s,isStreaming:!1,segments:a},o}}return St(e)}function St(e){return Tt(e)?e.map(t=>t.sender!=="agent"||!t.isStreaming||t.isStopped?t:{...t,isStreaming:!1,segments:ke(t.segments)}):e}function Bn(e,t,r){return!t||!r||t===r?e:e.some(s=>s.id===r)?e.filter(s=>s.id!==t):e.map(s=>s.id===t?{...s,id:r}:s)}function Fn(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.sender==="agent"&&r.isStreaming)return t}return-1}function Un(e){return e.sendSessionId?e.authorityStreaming:!1}function Pn(e){const t=e.liveSessions;return!t||t.size===0||!e.sessionId?!0:!t.has(e.sessionId)&&!t.has(e.placeholderId)}function Kn(e){if(!e.isActive||e.previewMode||e.chatMode!=="direct"||!e.selectedAgent)return null;const t=e.activeSessionId;return!t||t===e.placeholderId?null:t}function Wn(e,t="stopped"){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.sender==="agent"&&s.isStreaming&&!s.isStopped){const a=Je(s,t);if(a===null)return e.filter((i,l)=>l!==r);const o=[...e];return o[r]=a,o}}return e}function zn(e,t){if(e.some(o=>o.id===t.id))return e;const r=t.rawCreatedAt?Date.parse(t.rawCreatedAt):NaN;if(!Number.isFinite(r)||e.length===0)return[...e,t];let s=e.length;for(;s>0;){const o=e[s-1],i=o.rawCreatedAt?Date.parse(o.rawCreatedAt):NaN;if(!Number.isFinite(i)||i<=r)break;s--}if(s===e.length)return[...e,t];const a=e.slice();return a.splice(s,0,t),a}function Hn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,thinking:(r.thinking??"")+t}]:[...e,{type:"text",content:"",thinking:t,createdAt:new Date().toISOString()}]}function Gn(e,t){if(!t)return e;const r=e[e.length-1];return r?.type==="text"?[...e.slice(0,-1),{...r,content:r.content+t}]:[...e,{type:"text",content:t,createdAt:new Date().toISOString()}]}const Et=/\n*<!--\s*notify_context:\s*([\s\S]*?)-->/g;function we(e){if(!e.includes("notify_context"))return{cleaned:e};let t;const r=e.match(/<!--\s*notify_context:\s*([\s\S]*?)-->/);if(r?.[1]){const s=r[1].match(/priority\s*=\s*(\w+)/i);s&&(t=s[1])}return{cleaned:e.replace(Et,"").trimEnd(),priority:t}}const Mt=/(?:<thinking>| thinking)[\s\S]*?<\/thinking>/g,At=/(?:<thinking>| thinking| thinking| think)[\s\S]*?<\/think>/g;function Vn(e){return e.replace(Mt,"").replace(At,"")}function Lt(e,t,r){if(e.type!=="tool"){const{cleaned:l}=we(e.content??"");return{type:"text",content:l,thinking:e.thinking,createdAt:e.createdAt}}const s=r?.type==="tool"&&r.tool===e.tool?r:void 0,a=e.subagentLogs?.length??0,o=s?.subagentLogs?.length??0,i=a>=o?e.subagentLogs:s?.subagentLogs;return{type:"tool",key:`${e.tool}_${t}`,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 Qe(e,t){const r=(t??[]).filter(a=>a.type==="tool");let s=0;return e.map((a,o)=>{const i=a.type==="tool"?r[s++]:void 0;return Lt(a,o,i)})}const re=new Map,It=2e3;function Ze(e){if(!e)return"";const t=re.get(e);if(t!==void 0)return t;const r=new Date(e),s=isNaN(r.getTime())?"":r.toLocaleTimeString();return re.size>=It&&re.clear(),re.set(e,s),s}function Xn(e){const t={id:e.id,sender:e.role==="user"?"user":"agent",text:e.content,time:Ze(e.createdAt),rawCreatedAt:e.createdAt,agentId:e.role!=="user"?e.agentId:void 0,sessionId:e.sessionId};if(e.metadata?.segmentsTruncated===!0&&(t.needsDetail=!0),e.role!=="user"&&e.metadata?.segments&&e.metadata.segments.length>0&&(t.segments=Qe(e.metadata.segments)),e.role==="assistant"&&(e.content==="[cancelled]"||e.content==="[Stream cancelled]")&&(t.text=""),(e.metadata?.isError||e.role==="assistant"&&e.content.startsWith("⚠"))&&(t.isError=!0,t.errorRaw=e.content),e.metadata?.emptyReply===!0&&(t.emptyReply=!0,t.isStopped||(t.isError=!0)),e.metadata?.isStreaming&&(t.isStreaming=!0),e.metadata?.isStopped&&!e.metadata?.isStreaming&&(t.isStopped=!0),e.metadata?.images?.length&&(t.images=e.metadata.images),e.metadata?.notifyUser&&(t.isNotification=!0,t.notifyPriority=e.metadata.priority,e.metadata.taskId&&(t.taskId=e.metadata.taskId),e.metadata.requirementId&&(t.requirementId=e.metadata.requirementId)),t.text.includes("<!-- notify_context:")){const{cleaned:r,priority:s}=we(t.text);t.text=r,s&&!t.notifyPriority&&(t.notifyPriority=s),t.isNotification=!0}if(e.metadata?.activityLog&&(t.isActivityLog=!0,t.activityType=e.metadata.activityType,t.outcome=e.metadata.outcome,t.mailboxItemId=e.metadata.mailboxItemId,t.taskId=e.metadata.taskId,t.requirementId=e.metadata.requirementId,!t.outcome&&t.text.startsWith("[ACTIVITY:"))){const r=t.text.lastIndexOf(" → ");r!==-1&&(t.outcome=t.text.slice(r+3)),t.text=t.text.replace(/^\[ACTIVITY:\s*\w+\]\s*/,"")}if(e.metadata?.replyToId&&(t.replyToId=e.metadata.replyToId,t.replyToSender=e.metadata.replyToSender,t.replyToText=e.metadata.replyToText,t.text=et(t.text,t.replyToSender,t.replyToText)),e.role==="user"){const r=pt(e.metadata?.chips);r&&(t.chips=r)}return t}function et(e,t,r){if(!e||!t||!r)return e;const s=`> **${t}**: ${r}
|
|
2
2
|
|
|
3
3
|
`;return e.startsWith(s)?e.slice(s.length):e}function Yn(e,t={}){if(t.expectedMessageId)for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.id===t.expectedMessageId&&a.sender==="agent"&&!a.isError)return a}let r=-1;for(let s=e.length-1;s>=0;s--)if(e[s].sender==="user"){r=s;break}for(let s=e.length-1;s>=0;s--){const a=e[s];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"))||t.allowCurrentTurnPartial&&r>=0&&s>r?a:void 0}}function Jn(e){const t=e?.messageId||e?.streamId;return t?`reattach_${t}`:null}function Qn(e,t){const r=e.senderType==="system"||e.senderType==="agent"&&e.text.startsWith("⚠"),s=e.senderType==="human"&&(!t||e.senderId===t);let a=e.text;s&&e.replyToId&&e.replyToSender&&e.replyToText&&(a=et(a,e.replyToSender,e.replyToText));const o={id:e.id,sender:s?"user":"agent",text:a,time:Ze(e.createdAt),rawCreatedAt:e.createdAt,agentName:s?void 0:e.senderName,agentId:s?void 0:e.senderId,isError:r,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{u as g,j as a,r as i,_ as b}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-BX6YVVx8.js","assets/index-CudHikwU.js","assets/index-9SXWNIl0.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{u as g,j as a,r as i,_ as b}from"./index-CudHikwU.js";const v=i.lazy(()=>b(()=>import("./MarkdownMessage-BX6YVVx8.js"),__vite__mapDeps([0,1,2])).then(e=>({default:e.MarkdownMessage}))),w=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 y(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&&w.has(r)?"code":r?"text":void 0}}function k(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 _(e){if(e.format)return e.format;if(e.reference){const t=y(e.reference);if(t)return t}if(e.content){const t=k(e.content);if(t)return t}return e.reference?"text":"markdown"}function E({content:e,className:t,onSelection:r}){const{t:c}=g("common"),h=i.useRef(null),[d,m]=i.useState(null);i.useEffect(()=>{const o=l=>{l.data?.type==="__htmlpreview_height"&&typeof l.data.height=="number"&&m(l.data.height),l.data?.type==="__htmlpreview_selection"&&r&&r(l.data)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[r]);const p=`<script>
|
|
3
3
|
(function(){
|
|
4
4
|
function getXPath(el){
|
|
5
5
|
if(!el||el.nodeType!==1)return'';
|
package/dist/web-ui/assets/{DeliverableShareModal-CY0_wqDC.js → DeliverableShareModal-By9CYH0Q.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as M,u as fe,r as u,h as R,V as be,a0 as he,k as N,j as r,a1 as pe}from"./index-Dc1HlaXE.js";const J=50*1024*1024,ee=new Set(["markdown","html"]);function me(e){return e||"markdown"}function ge(e){return ee.has(me(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class te extends S{constructor(){super(M.t("deliverables:share.notLoggedIntoHub")),this.name="NotLoggedIntoHubError"}}class xe extends S{bytes;limit;constructor(t,a){super(M.t("deliverables:share.tooLarge",{bytes:t,limit:a})),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class ye extends S{status;constructor(t,a){super(M.t("deliverables:share.hubRequestFailed",{status:t,message:a})),this.name="HubApiError",this.status=t}}function ve(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 ke{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 te}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 ye(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ve(t.fileBase64):0);if(a>J)throw new xe(a,J);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 je(e,t){return new ke({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const we=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,Ne=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function Z(e){return we.test(e)?"image":Ne.test(e)?"media":"other"}function Se(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function q(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 Y(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Q(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)?Se(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 Ve(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(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=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ie(e,t){let a=e;for(const[l,s]of t){const i=He(l,s);a=a.split(l).join(i)}return a}function He(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 Le(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function Te(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,Le(i.url,a))}return l}async function Ce(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 Ee(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ce(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),Te(e,s,t)}async function Ae(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}=Ve(l.content,i);if(c.length===0)return{content:l.content};const o=await Ee(c,a);return o.size===0?{content:l.content}:{content:Ie(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 Be({item:e,onClose:t,onShared:a,service:l}){const{t:s}=fe(["deliverables","common"]),i=u.useMemo(()=>l??je(be,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,P]=u.useState("public"),[V,re]=u.useState(e.title||""),[E,se]=u.useState(e.summary||""),[x,A]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,U]=u.useState(""),[$,ae]=u.useState(null),[I,F]=u.useState(!1),[H,g]=u.useState(null),D=u.useRef(a);D.current=a;const y=u.useCallback(n=>{ae(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),D.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const le=u.useCallback(async()=>{b(!0),g(null);try{await he({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)&&A(h=>[...h,n]),U("")},[k,x]),ne=u.useCallback(n=>{A(h=>h.filter(v=>v!==n))},[]),ie=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&A(h=>h.slice(0,-1))},[B,k,x.length]),_=u.useCallback(()=>{const n=$?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{F(!0),setTimeout(()=>F(!1),1500)}).catch(()=>{})},[$,e.shareUrl]),oe=u.useCallback(async()=>{if(!ge(e.format)){g(s("deliverables:share.formatUnsupported",{formats:[...ee].join(" / ")}));return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ce,uploadedMedia:K}=await Ae(e.reference,e.type,h);K&&console.info(`[deliverable-share] uploaded ${K} local media reference(s) to Hub`);const j=e.agentId??"";let G=j;if(j)try{const{agents:de}=await N.agents.list({lean:!0}),X=de.find(ue=>ue.id===j);X&&(G=X.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:ce,producerAgent:{id:j,name:G,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:s("deliverables:share.rejectedFallback")):t()}catch(n){if(p("form"),n instanceof te){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y,s]),W=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]),z=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 L=m==="link",T=$?.url??e.shareUrl,O=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:()=>{le()},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:"公开"})})]}),T?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:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?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:()=>{W()},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:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),T?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:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{W()},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:"已拒绝"})})}),H&&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:H}),r.jsx("button",{onClick:z,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:z,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 ${L?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!L,onChange:()=>P("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 ${L?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:L,onChange:()=>P("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=>re(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=>se(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:()=>ne(n),className:"text-fg-tertiary hover:text-red-500","aria-label":s("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=>U(n.target.value),onKeyDown:ie,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"})]}),H&&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:H}),r.jsxs("button",{type:"button",onClick:()=>{oe()},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"})]})]})})})]})]});return typeof document<"u"?pe.createPortal(O,document.body):O}export{Be as D,ge as a,je as c};
|
|
1
|
+
import{$ as M,u as fe,r as u,h as R,V as be,a0 as he,k as N,j as r,a1 as pe}from"./index-CudHikwU.js";const J=50*1024*1024,ee=new Set(["markdown","html"]);function me(e){return e||"markdown"}function ge(e){return ee.has(me(e))}class S extends Error{constructor(t){super(t),this.name="DeliverableShareError"}}class te extends S{constructor(){super(M.t("deliverables:share.notLoggedIntoHub")),this.name="NotLoggedIntoHubError"}}class xe extends S{bytes;limit;constructor(t,a){super(M.t("deliverables:share.tooLarge",{bytes:t,limit:a})),this.name="DeliverableTooLargeError",this.bytes=t,this.limit=a}}class ye extends S{status;constructor(t,a){super(M.t("deliverables:share.hubRequestFailed",{status:t,message:a})),this.name="HubApiError",this.status=t}}function ve(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 ke{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 te}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 ye(i.status,o)}return{status:i.status,data:c}}async publish(t){this.assertHubLoggedIn();const a=t.fileSizeBytes??(t.fileBase64?ve(t.fileBase64):0);if(a>J)throw new xe(a,J);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 je(e,t){return new ke({getHubToken:e,hubUrl:t,proxyBasePath:"/api/hub"})}const we=/\.(png|jpe?g|gif|webp|svg|bmp|avif|ico)$/i,Ne=/\.(mp4|webm|mp3|wav|ogg|m4a|mov|avi|mkv|flac)$/i;function Z(e){return we.test(e)?"image":Ne.test(e)?"media":"other"}function Se(e){return e.replace(/^file:\/\//i,"").replace(/^file:/i,"")}function q(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 Y(e){return!e||/^(https?:|data:|mailto:|tel:|#)/i.test(e)||e.startsWith("//")?!1:(e.startsWith("/api/files/"),!0)}function Q(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)?Se(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 Ve(e,t){const a=[],l=new Set,s=/!?\[[^\]]*\]\(([^)\s]+(?:\s+["'][^"']*["'])?)\)/g;for(const c of e.matchAll(s)){const o=c[0],d=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(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=q(o);if(!d||!Y(d))continue;const b=Q(d,t);!b||l.has(o)||(l.add(o),a.push({raw:o,localPath:b,kind:Z(b.split("?")[0])}))}return{refs:a,baseDir:t??""}}function Ie(e,t){let a=e;for(const[l,s]of t){const i=He(l,s);a=a.split(l).join(i)}return a}function He(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 Le(e,t){return/^https?:\/\//i.test(e)?e:`${t.replace(/\/+$/,"")}${e.startsWith("/")?"":"/"}${e}`}function Te(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,Le(i.url,a))}return l}async function Ce(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 Ee(e,t){const a=new Map;if(e.length===0)return a;const l=[];for(const c of e){const o=await Ce(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),Te(e,s,t)}async function Ae(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}=Ve(l.content,i);if(c.length===0)return{content:l.content};const o=await Ee(c,a);return o.size===0?{content:l.content}:{content:Ie(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 Be({item:e,onClose:t,onShared:a,service:l}){const{t:s}=fe(["deliverables","common"]),i=u.useMemo(()=>l??je(be,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,P]=u.useState("public"),[V,re]=u.useState(e.title||""),[E,se]=u.useState(e.summary||""),[x,A]=u.useState(Array.isArray(e.tags)?[...e.tags]:[]),[k,U]=u.useState(""),[$,ae]=u.useState(null),[I,F]=u.useState(!1),[H,g]=u.useState(null),D=u.useRef(a);D.current=a;const y=u.useCallback(n=>{ae(n);const h=n.status;p(h==="published"?"published":h==="rejected"?"rejected":h==="revoked"?"revoked":h==="pending_review"?"pending_review":"form"),D.current?.(n)},[]);u.useEffect(()=>{o(i.isHubLoggedIn())},[i]);const le=u.useCallback(async()=>{b(!0),g(null);try{await he({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)&&A(h=>[...h,n]),U("")},[k,x]),ne=u.useCallback(n=>{A(h=>h.filter(v=>v!==n))},[]),ie=u.useCallback(n=>{n.key==="Enter"||n.key===","?(n.preventDefault(),B()):n.key==="Backspace"&&!k&&x.length&&A(h=>h.slice(0,-1))},[B,k,x.length]),_=u.useCallback(()=>{const n=$?.url??e.shareUrl;n&&navigator.clipboard?.writeText(n).then(()=>{F(!0),setTimeout(()=>F(!1),1500)}).catch(()=>{})},[$,e.shareUrl]),oe=u.useCallback(async()=>{if(!ge(e.format)){g(s("deliverables:share.formatUnsupported",{formats:[...ee].join(" / ")}));return}g(null),p("busy");try{const n=e.reference.replace(/[/\\]/g,"/").split("/").pop()||"deliverable",h=R.getUrl(),{content:v,fileBase64:ce,uploadedMedia:K}=await Ae(e.reference,e.type,h);K&&console.info(`[deliverable-share] uploaded ${K} local media reference(s) to Hub`);const j=e.agentId??"";let G=j;if(j)try{const{agents:de}=await N.agents.list({lean:!0}),X=de.find(ue=>ue.id===j);X&&(G=X.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:ce,producerAgent:{id:j,name:G,source:"local"}});y(w),w.status==="rejected"?g(typeof w.reason=="string"&&w.reason?w.reason:s("deliverables:share.rejectedFallback")):t()}catch(n){if(p("form"),n instanceof te){o(!1);return}g(n instanceof S||n instanceof Error?n.message:String(n))}},[i,e,V,E,x,m,y,s]),W=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]),z=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 L=m==="link",T=$?.url??e.shareUrl,O=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:()=>{le()},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:"公开"})})]}),T?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:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?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:()=>{W()},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:"你的产出物已公开,其他人现在就能通过链接访问。管理员审核通过后,内容将进入搜索引擎收录。"})}),T?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:T}),r.jsx("button",{onClick:_,className:`px-2 py-1 text-[10px] rounded transition-colors shrink-0 ${I?"bg-green-500/20 text-green-500":"bg-brand-600/20 text-brand-500 hover:bg-brand-600/30"}`,children:I?s("common:copied",{defaultValue:"已复制"}):s("common:copy",{defaultValue:"复制链接"})})]}):null,r.jsx("button",{onClick:()=>{W()},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:"已拒绝"})})}),H&&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:H}),r.jsx("button",{onClick:z,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:z,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 ${L?"border-border-default hover:bg-surface-elevated":"border-brand-500/50 bg-brand-500/5"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:!L,onChange:()=>P("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 ${L?"border-brand-500/50 bg-brand-500/5":"border-border-default hover:bg-surface-elevated"}`,children:[r.jsx("input",{type:"radio",name:"visibility",checked:L,onChange:()=>P("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=>re(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=>se(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:()=>ne(n),className:"text-fg-tertiary hover:text-red-500","aria-label":s("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=>U(n.target.value),onKeyDown:ie,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"})]}),H&&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:H}),r.jsxs("button",{type:"button",onClick:()=>{oe()},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"})]})]})})})]})]});return typeof document<"u"?pe.createPortal(O,document.body):O}export{Be as D,ge as a,je 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-CudHikwU.js";import{MarkdownMessage as Nt}from"./MarkdownMessage-BX6YVVx8.js";import{resolveFormat as Us,ContentRenderer as Os}from"./ContentRenderer-CHzFmlGx.js";import{c as Ks,a as zs,D as Gs}from"./DeliverableShareModal-By9CYH0Q.js";import{S as Ys,s as qs}from"./SendToChat-BR3-e7d4.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
|