@xopcai/xopc 0.0.112 → 0.0.113
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/browser-ext/icons/icon-128.png +0 -0
- package/dist/browser-ext/icons/icon-16.png +0 -0
- package/dist/browser-ext/icons/icon-32.png +0 -0
- package/dist/browser-ext/icons/icon-48.png +0 -0
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/delivery-to.d.ts +3 -3
- package/dist/extensions/weixin/src/delivery-to.js.map +1 -1
- package/dist/gateway/static/root/apple-touch-icon.png +0 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-EhRp-ZMa.js → agent-avatar-dicebear-CBlklyNr.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-browser-settings-page-H4foVCiS.js → agent-browser-settings-page-rGbKc2Hh.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-tabbed-page-DDNw2oNU.js → agent-defaults-tabbed-page-CtwVbjOA.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-E_X2kzS1.js → agents-CCBmGcwc.js} +3 -3
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BIy7KEsM.js → app-management-settings-panel-28E_WfMe.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DGQG8NwA.js → appearance-settings-Do1z0XgJ.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-BZLvInLr.js → apps-page-xwCsJS15.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-uuQPupqx.js → archive-plugin-BAFlsov_.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DBkv0cAv.js → attachment-load-V3qGPC3x.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-DxxN_VAR.js → binary-plugins-DT8NvA6W.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-CwnUlRmO.js → block-editor-CdLMEcHd.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-BHvUKlzw.js → channels-settings-C044DcYk.js} +1 -1
- package/dist/gateway/static/root/assets/{config-api-BD-NcD5d.js → config-api-Bf5mjpu7.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-settings-VBzXcEXL.js → connectors-settings-8VEWUOTj.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-api-C5DoipZA.js → cron-api--pAB_rps.js} +1 -1
- package/dist/gateway/static/root/assets/cron-page-DqmNGNOy.js +3 -0
- package/dist/gateway/static/root/assets/{dreaming-settings-DSVhXTPq.js → dreaming-settings-6UZE1FSK.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BDHA9o_e.js → extension-debug-page-BGhE7msg.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DmDLVSPE.js → extension-page-CvpI45WG.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-1124aHw_.js → extension-settings-page-DAmR5FUe.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-DOe56Wmy.js → fetch-NZmjSXLl.js} +1 -1
- package/dist/gateway/static/root/assets/{format-interval-label-tsMSvBSR.js → format-interval-label-qhth3BMV.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CsD4FC9D.js → gateway-config-api-CaXBt-9R.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-HQ8FBhY2.js → gateway-settings-DphpbLBc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-C1zg7pH3.js → gateway-startup-retry-Be1omjh3.js} +1 -1
- package/dist/gateway/static/root/assets/{goal-detail-page-BG3Onph0.js → goal-detail-page-bv0VRDaf.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-1Ywnt4Cb.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-B5nI6lgz.js → goals-settings-ceEBjnfc.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-config-api-CIv42nJD.js → heartbeat-config-api-BzO6G4fD.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DFcVuJ3M.js → heartbeat-settings-DCST9-du.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BTmbp2AU.js → index-Cxm6xsps.js} +59 -58
- package/dist/gateway/static/root/assets/{index-5A_ZaABy.css → index-b_R4tKqt.css} +1 -1
- package/dist/gateway/static/root/assets/{interval-presets-DGP3S7OB.js → interval-presets-DJmshV8n.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-fETaDYQP.js → keyboard-shortcuts-settings-9AUUlQ5Q.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-B1-b27lK.js → logs-page-B_wrxhee.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CgeBJMOD.js → markdown-split-CYYELqAr.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C30GzlV2.js → media-plugins-BEcMR2M8.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CkT-lcgP.js +3 -0
- package/dist/gateway/static/root/assets/{models-hub-panel-DPcTS1-u.js → models-hub-panel-D0JDSbNu.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-page-xeGb4owe.js → note-detail-page-DpFV-EO6.js} +2 -2
- package/dist/gateway/static/root/assets/{note-image-lightbox-t1g0qZYh.js → note-image-lightbox-DNAoPcmm.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-C_TdnKBe.js → notes-page-CdkjTch8.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DeWp9x5g.js → preview-open-alternatives-BPLz0AIv.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BtkPmJIN.js → remote-access-hub-DSYVAi96.js} +1 -1
- package/dist/gateway/static/root/assets/{save-bar-controls-BOaAOJI3.js → save-bar-controls-CrWwWRVK.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-BLWLKqgw.js → schedule-field-CF2sadvN.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-plqRFYT8.js → schema-form-Di5cKjYE.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-DOUjxzJm.js → sessions-page-CenkcVjF.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-D9sva86V.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-BP5zRrDI.js → settings-collapsible-section-Chh282jW.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-Bv8MZplG.js → settings-form-section-Dq-83cQd.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DmDfE1ww.js → settings-page-DL35U0x0.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BEFwNcIZ.js → setup-status-panel-Ctwbp9Er.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-4OX1YCgp.js → share-preview-page-0FXYnSUA.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CbKmJZot.js → shares-settings-DIM3JNsr.js} +1 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DAlNaNzL.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CLrHVzAt.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-CGy4f_s2.js → system-settings-panel-W1pTcojB.js} +1 -1
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BVRvkK7m.js +1 -0
- package/dist/gateway/static/root/assets/{use-channel-catalog-CjGHnDvN.js → use-channel-catalog-CgJibfMM.js} +1 -1
- package/dist/gateway/static/root/assets/{use-settings-tab-guard-BMMFa0oA.js → use-settings-tab-guard-Bw_qkRQE.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-DnRbhMNq.js → voice-api-key-field-vYAO71Gn.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-player-store-D5vzWwls.js → voice-player-store-C7lziaAx.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-page.utils-tjGpRVnw.js → workflow-page.utils-sgHjOXOm.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-DqqHKGj2.js → workflows-page-DYyOTmFx.js} +1 -1
- package/dist/gateway/static/root/favicon-16x16.png +0 -0
- package/dist/gateway/static/root/favicon-32x32.png +0 -0
- package/dist/gateway/static/root/favicon-icon.svg +1 -0
- package/dist/gateway/static/root/favicon.ico +0 -0
- package/dist/gateway/static/root/favicon.png +0 -0
- package/dist/gateway/static/root/favicon.svg +24 -17
- package/dist/gateway/static/root/index.html +5 -5
- package/dist/gateway/static/root/logo-dark.svg +23 -15
- package/dist/gateway/static/root/logo.svg +23 -16
- package/dist/package.js +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +9 -4
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/ai-assist/text-assist.d.ts +3 -0
- package/dist/src/ai-assist/text-assist.js +25 -7
- package/dist/src/ai-assist/text-assist.js.map +1 -1
- package/dist/src/channels/plugins/types.adapters.d.ts +2 -2
- package/dist/src/cron/executor.js.map +1 -1
- package/dist/src/cron/types.d.ts +2 -2
- package/dist/src/session/store-reader.d.ts +5 -0
- package/dist/src/session/store-reader.js +1 -0
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/cron-page-BLTpdm34.js +0 -3
- package/dist/gateway/static/root/assets/goals-page-DgeKn8zL.js +0 -2
- package/dist/gateway/static/root/assets/messages-BUUfPaZ9.js +0 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-qK_bnTrw.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-YdtnUHtK.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-DwW1IzQ0.js +0 -2
- package/dist/gateway/static/root/assets/use-agent-defaults-form-BMuMvzl_.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,ir as t,l as n}from"./index-
|
|
1
|
+
import{c as e,ir as t,l as n}from"./index-Cxm6xsps.js";function r(e){return e===`zh`?`zh`:`en`}function i(e,t){let n=r(t),i=n===`en`?void 0:e.metadata.i18n?.[n],a=i?.examplePrompts&&i.examplePrompts.length>0?i.examplePrompts:e.metadata.examplePrompts??[];return{description:o(i?.description,e.description),whenToUse:s(i?.whenToUse,e.metadata.whenToUse),examplePrompts:a}}function a(e){return[e.name,e.title,e.description,e.metadata.whenToUse??``,...(e.metadata.examplePrompts??[]).map(e=>e.text),...Object.values(e.metadata.i18n??{}).flatMap(e=>[e.description??``,e.whenToUse??``,...(e.examplePrompts??[]).map(e=>e.text)]),...e.metadata.tags].join(` `).toLowerCase()}function o(e,t){return e?.trim()||t}function s(e,t){return e?.trim()||t?.trim()||void 0}function c(e,t,n){if(e.field===`goal`){t(e.text);return}n(t=>({...t,[e.field]:e.text}))}function l(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function u(e,t){return e?new Intl.DateTimeFormat(t,{month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`}).format(new Date(e)):`—`}function d(e){if(!e||!Number.isFinite(e))return`—`;let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m ${r}s`:`${n}m`;let i=Math.floor(n/60),a=n%60;return a?`${i}h ${a}m`:`${i}h`}function f(e){return e===`succeeded`?`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`bg-red-500/15 text-red-700 dark:text-red-300`:e===`cancelled`?`bg-amber-500/15 text-amber-700 dark:text-amber-300`:`bg-accent-soft text-accent-fg`}function p(t){let r=t.metadata.tags.map(e=>e.toLowerCase());for(let t of e)if(n[t].some(e=>r.includes(e)))return t;return null}function m(e,t){if(t===`all`)return!0;let r=e.metadata.tags.map(e=>e.toLowerCase());return n[t].some(e=>r.includes(e))}function h(t){let n=new Map;for(let e of t){let t=p(e)??`uncategorized`,r=n.get(t)??[];r.push(e),n.set(t,r)}let r=[];for(let t of e){let e=n.get(t);e?.length&&r.push({category:t,items:e})}let i=n.get(`uncategorized`);return i?.length&&r.push({category:`uncategorized`,items:i}),r}function g(e,t){return t===`all`?!0:t===`builtin`?e.metadata.builtIn:e.metadata.source===`user`}function _(e,t,n,r){let i=t.trim().toLowerCase();return e.filter(e=>!m(e,n)||!g(e,r)?!1:i?a(e).includes(i):!0)}function v(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function y(e){if(e==null)return e;if(typeof e==`object`&&e&&`raw`in e){let t=e.raw;return t===void 0?e:t}return e}function b(e){let n=e.run.metadata?.sessionKey?.trim();return n&&t(n)?n:null}function x(e,t){let n=`/chat/${encodeURIComponent(e)}`,r=t?.trim();return r?`${n}?${new URLSearchParams({draft:r}).toString()}`:n}function S(e){let t=e.source;return t&&typeof t==`object`&&`kind`in t&&typeof t.kind==`string`?t.kind:e.metadata?.triggerSource?.trim()||`unknown`}function C(e,t){let n=t.trim();return!n||n===`all`?!0:S(e)===n}function w(e){let t={};for(let[n,r]of Object.entries(e)){let e=r.trim();e&&(t[n]=e)}return Object.keys(t).length>0?t:void 0}function T(e){let t=[];e.run.error&&t.push({key:`run-error`,kind:`run_error`,severity:e.run.error.recoverable?`warning`:`error`,code:e.run.error.code,message:e.run.error.message,detail:e.run.error.detail});for(let n of e.agents){n.status===`error`?t.push({key:`agent-error:${n.id}`,kind:`agent_error`,severity:`error`,agentId:n.id,agentLabel:n.label,message:n.error,detail:n.resultPreview}):n.status===`skipped`&&t.push({key:`agent-skipped:${n.id}`,kind:`agent_skipped`,severity:`warning`,agentId:n.id,agentLabel:n.label,message:n.error});for(let e of n.steps??[])e.status===`error`&&t.push({key:`step-error:${n.id}:${e.id}`,kind:`step_error`,severity:`error`,agentId:n.id,agentLabel:n.label,stepId:e.id,stepLabel:e.label,message:e.error,detail:e.resultPreview??e.detail})}return t}export{u as a,y as c,f as d,v as f,i as h,d as i,b as l,c as m,T as n,h as o,x as p,_ as r,l as s,w as t,C as u};
|
package/dist/gateway/static/root/assets/{workflows-page-DqqHKGj2.js → workflows-page-DYyOTmFx.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-BUUfPaZ9.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-DOe56Wmy.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{$r as l,A as u,Ao as d,C as f,D as p,Ds as m,E as h,Ea as g,F as _,Fo as v,Ft as y,Ha as b,I as x,Ia as S,Ii as C,Jr as w,M as T,Mo as E,N as D,Oa as O,Qr as k,Ro as A,S as j,T as M,Ts as N,Vi as P,Vt as F,Xr as I,Yr as ee,Zo as L,Zr as te,_ as ne,_i as re,a as R,aa as ie,ba as z,bo as B,cs as V,d as ae,f as H,g as U,h as oe,i as se,ii as ce,is as W,j as G,ji as K,k as le,ki as q,m as ue,o as J,oo as de,pa as fe,qi as pe,qo as me,qr as he,r as ge,ra as _e,rs as ve,s as ye,sa as be,u as xe,v as Se,w as Ce,xi as we,y as Te,ya as Ee}from"./index-BTmbp2AU.js";import{a as De,c as Oe,d as ke,f as Ae,h as Y,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as X,t as Re,u as ze}from"./workflow-page.utils-tjGpRVnw.js";var Z=e(t(),1),Q=n(),Be=[`queued`,`running`,`succeeded`,`attention`],Ve=10080*60*1e3,He=new Set([`failed`,`timeout`,`cancelled`]);function Ue(e){return e.metadata?.sessionKey?.trim()||null}function We(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Ge(e,t){if(!e||typeof e!=`object`)return null;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}function Ke(e,t=90){let n=e.metadata?.input?.goal?.trim()||(typeof e.metadata?.input?.payload==`string`?e.metadata.input.payload.trim():null)||Ge(e.metadata?.input?.payload,[`query`,`goal`,`prompt`,`input`,`message`])||Ge(e.metadata?.input?.variables,[`query`,`goal`,`prompt`,`input`,`message`]);return n?We(n,t):null}function qe(e,t=90){return Ke(e,t)??We(e.title?.trim()||e.definitionId,t)}function Je(e,t=44){return We(e.title?.trim()||e.definitionId,t)}function Ye(e,t){let n=t.trim().toLowerCase();return n?[Ke(e,500),e.title,e.definitionId,e.id].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function Xe(e,t){let n=t.workflowFilterId.trim();return e.filter(e=>n&&e.definitionId!==n||!ze(e,t.triggerFilter??`all`)?!1:Ye(e,t.searchQuery))}function Ze(e){return e.completedAtMs??e.createdAtMs}function Qe(e,t){return t-Ze(e)<=Ve}function $e(e,t){return e.status===`queued`?`queued`:e.status===`running`?`running`:e.status===`succeeded`?Qe(e,t)?`succeeded`:null:He.has(e.status)?`attention`:null}function et(e,t){let n=[...t];return e===`queued`?n.sort((e,t)=>e.createdAtMs-t.createdAtMs):e===`running`?n.sort((e,t)=>(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)):n.sort((e,t)=>Ze(t)-Ze(e))}function tt(e,t){let n={queued:[],running:[],succeeded:[],attention:[]};for(let r of e){let e=$e(r,t);e&&n[e].push(r)}let r=et(`succeeded`,n.succeeded),i=r.length,a=r.slice(0,20),o=Math.max(0,i-20);return Be.map(e=>e===`succeeded`?{id:e,runs:a,totalInWindow:i,hiddenByCap:o}:{id:e,runs:et(e,n[e])})}var nt=new Map;function rt(e){let t=nt.get(e);return t||(t=new Intl.RelativeTimeFormat(e,{numeric:`auto`}),nt.set(e,t)),t}function it(e,t,n){let r=Math.round((t-e)/1e3),i=rt(n);if(r<60)return i.format(-r,`second`);let a=Math.round(r/60);if(a<60)return i.format(-a,`minute`);let o=Math.round(a/60);if(o<48)return i.format(-o,`hour`);let s=Math.round(o/24);return i.format(-s,`day`)}function at(e){return e.status===`queued`||e.status===`running`}function ot(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}var $=r(),st=(0,Z.memo)(function(e){let t=(0,Q.c)(65),{run:n,language:r,localeTag:o,nowMs:s,selected:c,onOpen:l,onOpenChat:u,onCancel:f,onRetry:p}=e,m=a(r).workflows,[h,g]=(0,Z.useState)(!1),_;t[0]===n?_=t[1]:(_=Ue(n),t[0]=n,t[1]=_);let v=!_,y;t[2]===n?y=t[3]:(y=at(n),t[2]=n,t[3]=y);let b=y,x=n.status===`running`||n.status===`queued`,S;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(S=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[4]=n.metrics.agentCount,t[5]=n.metrics.doneAgentCount,t[6]=S):S=t[6];let C=S,w=n.metrics.errorAgentCount>0,T=n.startedAtMs??n.createdAtMs,E=je(b?s-T:n.metrics.durationMs),D=X(m.taskArtifacts,{count:n.metrics.artifactCount}),O;t[7]===n?O=t[8]:(O=qe(n),t[7]=n,t[8]=O);let k=O,A;t[9]===n?A=t[10]:(A=Je(n),t[9]=n,t[10]=A);let j=A,M;t[11]!==l||t[12]!==n?(M=()=>{l(n)},t[11]=l,t[12]=n,t[13]=M):M=t[13];let N=M,F;t[14]!==v||t[15]!==u||t[16]!==n?(F=()=>{v||u(n)},t[14]=v,t[15]=u,t[16]=n,t[17]=F):F=t[17];let I=F,ee=c?`border-accent/70 ring-1 ring-accent/30`:`border-edge`,L;t[18]===ee?L=t[19]:(L=i(`group relative overflow-hidden rounded-xl border bg-surface-panel p-3.5 transition-colors`,ee,`hover:border-edge-strong hover:bg-surface-hover/50`),t[18]=ee,t[19]=L);let te;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(te=i(`w-full text-left`,we.focusRingPanel),t[20]=te):te=t[20];let ne;t[21]===k?ne=t[22]:(ne=(0,$.jsx)(`div`,{className:`line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:k}),t[21]=k,t[22]=ne);let re;t[23]===j?re=t[24]:(re=(0,$.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:j}),t[23]=j,t[24]=re);let R;t[25]!==ne||t[26]!==re?(R=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[ne,re]}),t[25]=ne,t[26]=re,t[27]=R):R=t[27];let ie;t[28]===n.status?ie=t[29]:(ie=i(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,ke(n.status)),t[28]=n.status,t[29]=ie);let z;t[30]!==o||t[31]!==s||t[32]!==T?(z=it(T,s,o),t[30]=o,t[31]=s,t[32]=T,t[33]=z):z=t[33];let B;t[34]===z?B=t[35]:(B=(0,$.jsx)(`span`,{children:z}),t[34]=z,t[35]=B);let V=E===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:X(m.taskElapsed,{duration:E})})]}),ae;t[36]!==B||t[37]!==V?(ae=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[B,V]}),t[36]=B,t[37]=V,t[38]=ae):ae=t[38];let H=n.metrics.artifactCount>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:D}):null,U=c?(0,$.jsx)(`span`,{className:`font-medium text-accent-fg`,children:m.taskOpenDetails}):null,oe;t[39]!==H||t[40]!==U?(oe=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[H,U]}),t[39]=H,t[40]=U,t[41]=oe):oe=t[41];let se;t[42]===g?se=t[43]:(se=()=>g(lt),t[42]=g,t[43]=se);let ce;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[44]=ce):ce=t[44];let W;t[45]!==m.taskActionsAria||t[46]!==h||t[47]!==se?(W=(0,$.jsx)(q,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":m.taskActionsAria,"aria-expanded":h,onClick:se,children:ce}),t[45]=m.taskActionsAria,t[46]=h,t[47]=se,t[48]=W):W=t[48];let G;t[49]!==b||t[50]!==v||t[51]!==I||t[52]!==m.cancel||t[53]!==m.continueInChat||t[54]!==m.rerun||t[55]!==m.taskCloseMenu||t[56]!==h||t[57]!==f||t[58]!==p||t[59]!==n||t[60]!==g?(G=h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":m.taskCloseMenu,onClick:()=>g(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 min-w-36 rounded-lg border border-edge bg-surface-panel py-1 shadow-surface`,children:[(0,$.jsx)(ct,{label:m.continueInChat,disabled:v,onClick:()=>{g(!1),I()}}),b?(0,$.jsx)(ct,{label:m.cancel,tone:`danger`,onClick:()=>{g(!1),f(n.id)}}):null,ot(n)?(0,$.jsx)(ct,{label:m.rerun,onClick:()=>{g(!1),p(n.id)}}):null]})]}):null,t[49]=b,t[50]=v,t[51]=I,t[52]=m.cancel,t[53]=m.continueInChat,t[54]=m.rerun,t[55]=m.taskCloseMenu,t[56]=h,t[57]=f,t[58]=p,t[59]=n,t[60]=g,t[61]=G):G=t[61];let K;return t[62]!==W||t[63]!==G?(K=(0,$.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[W,G]}),t[62]=W,t[63]=G,t[64]=K):K=t[64],(0,$.jsxs)(`div`,{className:L,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:N,"aria-label":`${m.taskOpenDetails}: ${k}`,"aria-current":c?`true`:void 0,className:te,children:[(0,$.jsxs)(`div`,{className:`pr-7`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[R,(0,$.jsx)(`span`,{className:ie,children:m.status[n.status]??n.status})]}),ae]}),x?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{children:X(m.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{children:[C,`%`]})]}),(0,$.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${C}%`}})})]}):null,oe,w?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(P,{className:`size-3 shrink-0`,"aria-hidden":!0}),X(m.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),K]})});function ct(e){let t=(0,Q.c)(8),{label:n,disabled:r,tone:a,onClick:o}=e,s=r?`cursor-not-allowed text-fg-subtle`:`text-fg hover:bg-surface-hover`,c=a===`danger`&&!r&&`text-red-600 dark:text-red-300`,l;t[0]!==s||t[1]!==c?(l=i(`block w-full px-3 py-1.5 text-left text-xs`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==l?(u=(0,$.jsx)(`button`,{type:`button`,disabled:r,onClick:o,className:l,children:n}),t[3]=r,t[4]=n,t[5]=o,t[6]=l,t[7]=u):u=t[7],u}function lt(e){return!e}function ut(e,t){return t.boardColumns[e]}var dt=(0,Z.memo)(function(e){let t=(0,Q.c)(14),{column:n,language:r,localeTag:o,nowMs:s,selectedRunId:c,onOpenRun:l,onOpenRunChat:u,onCancelRun:d,onRetryRun:f}=e,p=a(r).workflows,[m,h]=(0,Z.useState)(!1),g=n.id===`succeeded`,_=g?5:n.runs.length,v;t[0]!==_||t[1]!==n.runs||t[2]!==m||t[3]!==g?(v=g&&!m?n.runs.slice(0,_):n.runs,t[0]=_,t[1]=n.runs,t[2]=m,t[3]=g,t[4]=v):v=t[4];let y=v,b=g&&n.runs.length>5&&!m,x=g&&m,S;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`flex h-full w-80 shrink-0 snap-center flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel/40`),t[5]=S):S=t[5];let C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-accent`,"aria-hidden":!0}),t[6]=C):C=t[6];let w;t[7]===n.runs.length?w=t[8]:(w=(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs font-semibold tabular-nums text-fg-muted`,children:n.runs.length}),t[7]=n.runs.length,t[8]=w);let T=y.length===0?(0,$.jsx)(`div`,{className:`flex min-h-32 items-center justify-center rounded-xl border border-dashed border-edge bg-surface-panel/40 px-4 py-6 text-center text-xs text-fg-subtle`,children:p.boardColumnEmpty}):y.map(e=>(0,$.jsx)(st,{run:e,language:r,localeTag:o,nowMs:s,selected:e.id===c,onOpen:l,onOpenChat:u,onCancel:d,onRetry:f},e.id)),E=b?(0,$.jsx)(q,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>h(!0),children:X(p.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,D=x?(0,$.jsx)(q,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>h(!1),children:p.boardCollapseSucceeded}):null,O=g&&(n.hiddenByCap??0)>0?(0,$.jsx)(`p`,{className:`px-1 text-center text-[11px] text-fg-subtle`,children:X(p.boardSucceededCapHint,{count:n.hiddenByCap??0})}):null,k;return t[9]!==T||t[10]!==E||t[11]!==D||t[12]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2.5`,children:[T,E,D,O]}),t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k):k=t[13],(0,$.jsxs)(`section`,{className:S,"aria-label":ut(n.id,p),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 rounded-t-2xl border-b border-edge-subtle bg-surface-panel/90 px-3.5 py-3 backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[C,(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:ut(n.id,p)})]}),w]}),k]})}),ft=(0,Z.memo)(function(e){let t=(0,Q.c)(45),{runs:n,language:r,localeTag:i,labels:a,searchQuery:o,workflowFilterId:s,triggerFilter:c,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m,onStart:h}=e,g;t[0]===n?g=t[1]:(g=n.some(pt),t[0]=n,t[1]=g);let _=g,[v,y]=(0,Z.useState)(mt),b,x;t[2]===_?(b=t[3],x=t[4]):(b=()=>{if(!_)return;let e=window.setInterval(()=>y(Date.now()),1e3);return()=>window.clearInterval(e)},x=[_],t[2]=_,t[3]=b,t[4]=x),(0,Z.useEffect)(b,x);let S;t[5]!==v||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(S=tt(Xe(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),v),t[5]=v,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=S):S=t[10];let C=S,w=C.reduce(ht,0);if(u&&w===0){let e;return t[11]===a.loading?e=t[12]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading}),t[11]=a.loading,t[12]=e),e}if(!u&&w===0){let e;t[13]===a.boardEmptyTitle?e=t[14]:(e=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:a.boardEmptyTitle}),t[13]=a.boardEmptyTitle,t[14]=e);let n;t[15]===a.boardEmptyHint?n=t[16]:(n=(0,$.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.boardEmptyHint}),t[15]=a.boardEmptyHint,t[16]=n);let r;t[17]!==a.boardStart||t[18]!==h?(r=(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsx)(q,{variant:`primary`,onClick:h,children:a.boardStart})}),t[17]=a.boardStart,t[18]=h,t[19]=r):r=t[19];let i;return t[20]!==e||t[21]!==n||t[22]!==r?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center rounded-2xl border border-dashed border-edge bg-surface-panel/40 px-6 py-12 text-center`,children:[e,n,r]}),t[20]=e,t[21]=n,t[22]=r,t[23]=i):i=t[23],i}let T;if(t[24]!==C||t[25]!==r||t[26]!==i||t[27]!==v||t[28]!==p||t[29]!==d||t[30]!==f||t[31]!==m||t[32]!==l){let e;t[34]!==r||t[35]!==i||t[36]!==v||t[37]!==p||t[38]!==d||t[39]!==f||t[40]!==m||t[41]!==l?(e=e=>(0,$.jsx)(dt,{column:e,language:r,localeTag:i,nowMs:v,selectedRunId:l,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m},e.id),t[34]=r,t[35]=i,t[36]=v,t[37]=p,t[38]=d,t[39]=f,t[40]=m,t[41]=l,t[42]=e):e=t[42],T=C.map(e),t[24]=C,t[25]=r,t[26]=i,t[27]=v,t[28]=p,t[29]=d,t[30]=f,t[31]=m,t[32]=l,t[33]=T}else T=t[33];let E;return t[43]===T?E=t[44]:(E=(0,$.jsx)(`div`,{className:`-mx-1 flex h-full min-w-0 snap-x snap-mandatory gap-3 overflow-x-auto px-1 pb-3`,children:T}),t[43]=T,t[44]=E),E});function pt(e){return e.status===`queued`||e.status===`running`}function mt(){return Date.now()}function ht(e,t){return e+t.runs.length}var gt=`export const meta = {
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-CkT-lcgP.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s}from"./fetch-NZmjSXLl.js";import{i as c}from"./vendor-swr-BIWyz7Rc.js";import{$r as l,A as u,Ao as d,C as f,D as p,Ds as m,E as h,Ea as g,F as _,Fo as v,Ft as y,Ha as b,I as x,Ia as S,Ii as C,Jr as w,M as T,Mo as E,N as D,Oa as O,Qr as k,Ro as A,S as j,T as M,Ts as N,Vi as P,Vt as F,Xr as I,Yr as ee,Zo as L,Zr as te,_ as ne,_i as re,a as R,aa as ie,ba as z,bo as B,cs as V,d as ae,f as H,g as U,h as oe,i as se,ii as ce,is as W,j as G,ji as K,k as le,ki as q,m as ue,o as J,oo as de,pa as fe,qi as pe,qo as me,qr as he,r as ge,ra as _e,rs as ve,s as ye,sa as be,u as xe,v as Se,w as Ce,xi as we,y as Te,ya as Ee}from"./index-Cxm6xsps.js";import{a as De,c as Oe,d as ke,f as Ae,h as Y,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as X,t as Re,u as ze}from"./workflow-page.utils-sgHjOXOm.js";var Z=e(t(),1),Q=n(),Be=[`queued`,`running`,`succeeded`,`attention`],Ve=10080*60*1e3,He=new Set([`failed`,`timeout`,`cancelled`]);function Ue(e){return e.metadata?.sessionKey?.trim()||null}function We(e,t){return e.length<=t?e:`${e.slice(0,t-1)}…`}function Ge(e,t){if(!e||typeof e!=`object`)return null;let n=e;for(let e of t){let t=n[e];if(typeof t==`string`&&t.trim())return t.trim()}return null}function Ke(e,t=90){let n=e.metadata?.input?.goal?.trim()||(typeof e.metadata?.input?.payload==`string`?e.metadata.input.payload.trim():null)||Ge(e.metadata?.input?.payload,[`query`,`goal`,`prompt`,`input`,`message`])||Ge(e.metadata?.input?.variables,[`query`,`goal`,`prompt`,`input`,`message`]);return n?We(n,t):null}function qe(e,t=90){return Ke(e,t)??We(e.title?.trim()||e.definitionId,t)}function Je(e,t=44){return We(e.title?.trim()||e.definitionId,t)}function Ye(e,t){let n=t.trim().toLowerCase();return n?[Ke(e,500),e.title,e.definitionId,e.id].filter(Boolean).join(` `).toLowerCase().includes(n):!0}function Xe(e,t){let n=t.workflowFilterId.trim();return e.filter(e=>n&&e.definitionId!==n||!ze(e,t.triggerFilter??`all`)?!1:Ye(e,t.searchQuery))}function Ze(e){return e.completedAtMs??e.createdAtMs}function Qe(e,t){return t-Ze(e)<=Ve}function $e(e,t){return e.status===`queued`?`queued`:e.status===`running`?`running`:e.status===`succeeded`?Qe(e,t)?`succeeded`:null:He.has(e.status)?`attention`:null}function et(e,t){let n=[...t];return e===`queued`?n.sort((e,t)=>e.createdAtMs-t.createdAtMs):e===`running`?n.sort((e,t)=>(t.startedAtMs??t.createdAtMs)-(e.startedAtMs??e.createdAtMs)):n.sort((e,t)=>Ze(t)-Ze(e))}function tt(e,t){let n={queued:[],running:[],succeeded:[],attention:[]};for(let r of e){let e=$e(r,t);e&&n[e].push(r)}let r=et(`succeeded`,n.succeeded),i=r.length,a=r.slice(0,20),o=Math.max(0,i-20);return Be.map(e=>e===`succeeded`?{id:e,runs:a,totalInWindow:i,hiddenByCap:o}:{id:e,runs:et(e,n[e])})}var nt=new Map;function rt(e){let t=nt.get(e);return t||(t=new Intl.RelativeTimeFormat(e,{numeric:`auto`}),nt.set(e,t)),t}function it(e,t,n){let r=Math.round((t-e)/1e3),i=rt(n);if(r<60)return i.format(-r,`second`);let a=Math.round(r/60);if(a<60)return i.format(-a,`minute`);let o=Math.round(a/60);if(o<48)return i.format(-o,`hour`);let s=Math.round(o/24);return i.format(-s,`day`)}function at(e){return e.status===`queued`||e.status===`running`}function ot(e){return e.status===`failed`||e.status===`timeout`||e.status===`cancelled`}var $=r(),st=(0,Z.memo)(function(e){let t=(0,Q.c)(65),{run:n,language:r,localeTag:o,nowMs:s,selected:c,onOpen:l,onOpenChat:u,onCancel:f,onRetry:p}=e,m=a(r).workflows,[h,g]=(0,Z.useState)(!1),_;t[0]===n?_=t[1]:(_=Ue(n),t[0]=n,t[1]=_);let v=!_,y;t[2]===n?y=t[3]:(y=at(n),t[2]=n,t[3]=y);let b=y,x=n.status===`running`||n.status===`queued`,S;t[4]!==n.metrics.agentCount||t[5]!==n.metrics.doneAgentCount?(S=n.metrics.agentCount>0?Math.round(n.metrics.doneAgentCount/n.metrics.agentCount*100):0,t[4]=n.metrics.agentCount,t[5]=n.metrics.doneAgentCount,t[6]=S):S=t[6];let C=S,w=n.metrics.errorAgentCount>0,T=n.startedAtMs??n.createdAtMs,E=je(b?s-T:n.metrics.durationMs),D=X(m.taskArtifacts,{count:n.metrics.artifactCount}),O;t[7]===n?O=t[8]:(O=qe(n),t[7]=n,t[8]=O);let k=O,A;t[9]===n?A=t[10]:(A=Je(n),t[9]=n,t[10]=A);let j=A,M;t[11]!==l||t[12]!==n?(M=()=>{l(n)},t[11]=l,t[12]=n,t[13]=M):M=t[13];let N=M,F;t[14]!==v||t[15]!==u||t[16]!==n?(F=()=>{v||u(n)},t[14]=v,t[15]=u,t[16]=n,t[17]=F):F=t[17];let I=F,ee=c?`border-accent/70 ring-1 ring-accent/30`:`border-edge`,L;t[18]===ee?L=t[19]:(L=i(`group relative overflow-hidden rounded-xl border bg-surface-panel p-3.5 transition-colors`,ee,`hover:border-edge-strong hover:bg-surface-hover/50`),t[18]=ee,t[19]=L);let te;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(te=i(`w-full text-left`,we.focusRingPanel),t[20]=te):te=t[20];let ne;t[21]===k?ne=t[22]:(ne=(0,$.jsx)(`div`,{className:`line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:k}),t[21]=k,t[22]=ne);let re;t[23]===j?re=t[24]:(re=(0,$.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:j}),t[23]=j,t[24]=re);let R;t[25]!==ne||t[26]!==re?(R=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[ne,re]}),t[25]=ne,t[26]=re,t[27]=R):R=t[27];let ie;t[28]===n.status?ie=t[29]:(ie=i(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,ke(n.status)),t[28]=n.status,t[29]=ie);let z;t[30]!==o||t[31]!==s||t[32]!==T?(z=it(T,s,o),t[30]=o,t[31]=s,t[32]=T,t[33]=z):z=t[33];let B;t[34]===z?B=t[35]:(B=(0,$.jsx)(`span`,{children:z}),t[34]=z,t[35]=B);let V=E===`—`?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{children:X(m.taskElapsed,{duration:E})})]}),ae;t[36]!==B||t[37]!==V?(ae=(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[B,V]}),t[36]=B,t[37]=V,t[38]=ae):ae=t[38];let H=n.metrics.artifactCount>0?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:D}):null,U=c?(0,$.jsx)(`span`,{className:`font-medium text-accent-fg`,children:m.taskOpenDetails}):null,oe;t[39]!==H||t[40]!==U?(oe=(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,children:[H,U]}),t[39]=H,t[40]=U,t[41]=oe):oe=t[41];let se;t[42]===g?se=t[43]:(se=()=>g(lt),t[42]=g,t[43]=se);let ce;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t[44]=ce):ce=t[44];let W;t[45]!==m.taskActionsAria||t[46]!==h||t[47]!==se?(W=(0,$.jsx)(q,{variant:`ghost`,className:`size-7 p-0 opacity-0 group-hover:opacity-100 group-focus-within:opacity-100`,"aria-label":m.taskActionsAria,"aria-expanded":h,onClick:se,children:ce}),t[45]=m.taskActionsAria,t[46]=h,t[47]=se,t[48]=W):W=t[48];let G;t[49]!==b||t[50]!==v||t[51]!==I||t[52]!==m.cancel||t[53]!==m.continueInChat||t[54]!==m.rerun||t[55]!==m.taskCloseMenu||t[56]!==h||t[57]!==f||t[58]!==p||t[59]!==n||t[60]!==g?(G=h?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,className:`fixed inset-0 z-10 cursor-default`,"aria-label":m.taskCloseMenu,onClick:()=>g(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 z-20 mt-1 min-w-36 rounded-lg border border-edge bg-surface-panel py-1 shadow-surface`,children:[(0,$.jsx)(ct,{label:m.continueInChat,disabled:v,onClick:()=>{g(!1),I()}}),b?(0,$.jsx)(ct,{label:m.cancel,tone:`danger`,onClick:()=>{g(!1),f(n.id)}}):null,ot(n)?(0,$.jsx)(ct,{label:m.rerun,onClick:()=>{g(!1),p(n.id)}}):null]})]}):null,t[49]=b,t[50]=v,t[51]=I,t[52]=m.cancel,t[53]=m.continueInChat,t[54]=m.rerun,t[55]=m.taskCloseMenu,t[56]=h,t[57]=f,t[58]=p,t[59]=n,t[60]=g,t[61]=G):G=t[61];let K;return t[62]!==W||t[63]!==G?(K=(0,$.jsxs)(`div`,{className:`absolute right-2 top-2`,children:[W,G]}),t[62]=W,t[63]=G,t[64]=K):K=t[64],(0,$.jsxs)(`div`,{className:L,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:N,"aria-label":`${m.taskOpenDetails}: ${k}`,"aria-current":c?`true`:void 0,className:te,children:[(0,$.jsxs)(`div`,{className:`pr-7`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[R,(0,$.jsx)(`span`,{className:ie,children:m.status[n.status]??n.status})]}),ae]}),x?(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{children:X(m.agentProgress,{done:n.metrics.doneAgentCount,total:n.metrics.agentCount})}),(0,$.jsxs)(`span`,{children:[C,`%`]})]}),(0,$.jsx)(`div`,{className:`mt-1.5 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-all`,style:{width:`${C}%`}})})]}):null,oe,w?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1 text-[11px] text-amber-700 dark:text-amber-300`,children:[(0,$.jsx)(P,{className:`size-3 shrink-0`,"aria-hidden":!0}),X(m.runRowErrorSummary,{count:n.metrics.errorAgentCount})]}):null]}),K]})});function ct(e){let t=(0,Q.c)(8),{label:n,disabled:r,tone:a,onClick:o}=e,s=r?`cursor-not-allowed text-fg-subtle`:`text-fg hover:bg-surface-hover`,c=a===`danger`&&!r&&`text-red-600 dark:text-red-300`,l;t[0]!==s||t[1]!==c?(l=i(`block w-full px-3 py-1.5 text-left text-xs`,s,c),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==r||t[4]!==n||t[5]!==o||t[6]!==l?(u=(0,$.jsx)(`button`,{type:`button`,disabled:r,onClick:o,className:l,children:n}),t[3]=r,t[4]=n,t[5]=o,t[6]=l,t[7]=u):u=t[7],u}function lt(e){return!e}function ut(e,t){return t.boardColumns[e]}var dt=(0,Z.memo)(function(e){let t=(0,Q.c)(14),{column:n,language:r,localeTag:o,nowMs:s,selectedRunId:c,onOpenRun:l,onOpenRunChat:u,onCancelRun:d,onRetryRun:f}=e,p=a(r).workflows,[m,h]=(0,Z.useState)(!1),g=n.id===`succeeded`,_=g?5:n.runs.length,v;t[0]!==_||t[1]!==n.runs||t[2]!==m||t[3]!==g?(v=g&&!m?n.runs.slice(0,_):n.runs,t[0]=_,t[1]=n.runs,t[2]=m,t[3]=g,t[4]=v):v=t[4];let y=v,b=g&&n.runs.length>5&&!m,x=g&&m,S;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`flex h-full w-80 shrink-0 snap-center flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel/40`),t[5]=S):S=t[5];let C;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(`span`,{className:`size-2 rounded-full bg-accent`,"aria-hidden":!0}),t[6]=C):C=t[6];let w;t[7]===n.runs.length?w=t[8]:(w=(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs font-semibold tabular-nums text-fg-muted`,children:n.runs.length}),t[7]=n.runs.length,t[8]=w);let T=y.length===0?(0,$.jsx)(`div`,{className:`flex min-h-32 items-center justify-center rounded-xl border border-dashed border-edge bg-surface-panel/40 px-4 py-6 text-center text-xs text-fg-subtle`,children:p.boardColumnEmpty}):y.map(e=>(0,$.jsx)(st,{run:e,language:r,localeTag:o,nowMs:s,selected:e.id===c,onOpen:l,onOpenChat:u,onCancel:d,onRetry:f},e.id)),E=b?(0,$.jsx)(q,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>h(!0),children:X(p.boardExpandSucceeded,{count:Math.min(n.runs.length,n.totalInWindow??n.runs.length)})}):null,D=x?(0,$.jsx)(q,{variant:`ghost`,className:`h-8 w-full text-xs`,onClick:()=>h(!1),children:p.boardCollapseSucceeded}):null,O=g&&(n.hiddenByCap??0)>0?(0,$.jsx)(`p`,{className:`px-1 text-center text-[11px] text-fg-subtle`,children:X(p.boardSucceededCapHint,{count:n.hiddenByCap??0})}):null,k;return t[9]!==T||t[10]!==E||t[11]!==D||t[12]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2.5`,children:[T,E,D,O]}),t[9]=T,t[10]=E,t[11]=D,t[12]=O,t[13]=k):k=t[13],(0,$.jsxs)(`section`,{className:S,"aria-label":ut(n.id,p),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 rounded-t-2xl border-b border-edge-subtle bg-surface-panel/90 px-3.5 py-3 backdrop-blur`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[C,(0,$.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:ut(n.id,p)})]}),w]}),k]})}),ft=(0,Z.memo)(function(e){let t=(0,Q.c)(45),{runs:n,language:r,localeTag:i,labels:a,searchQuery:o,workflowFilterId:s,triggerFilter:c,selectedRunId:l,loading:u,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m,onStart:h}=e,g;t[0]===n?g=t[1]:(g=n.some(pt),t[0]=n,t[1]=g);let _=g,[v,y]=(0,Z.useState)(mt),b,x;t[2]===_?(b=t[3],x=t[4]):(b=()=>{if(!_)return;let e=window.setInterval(()=>y(Date.now()),1e3);return()=>window.clearInterval(e)},x=[_],t[2]=_,t[3]=b,t[4]=x),(0,Z.useEffect)(b,x);let S;t[5]!==v||t[6]!==n||t[7]!==o||t[8]!==c||t[9]!==s?(S=tt(Xe(n,{searchQuery:o,workflowFilterId:s,triggerFilter:c}),v),t[5]=v,t[6]=n,t[7]=o,t[8]=c,t[9]=s,t[10]=S):S=t[10];let C=S,w=C.reduce(ht,0);if(u&&w===0){let e;return t[11]===a.loading?e=t[12]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.loading}),t[11]=a.loading,t[12]=e),e}if(!u&&w===0){let e;t[13]===a.boardEmptyTitle?e=t[14]:(e=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:a.boardEmptyTitle}),t[13]=a.boardEmptyTitle,t[14]=e);let n;t[15]===a.boardEmptyHint?n=t[16]:(n=(0,$.jsx)(`p`,{className:`mx-auto mt-2 max-w-md text-sm leading-6 text-fg-muted`,children:a.boardEmptyHint}),t[15]=a.boardEmptyHint,t[16]=n);let r;t[17]!==a.boardStart||t[18]!==h?(r=(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsx)(q,{variant:`primary`,onClick:h,children:a.boardStart})}),t[17]=a.boardStart,t[18]=h,t[19]=r):r=t[19];let i;return t[20]!==e||t[21]!==n||t[22]!==r?(i=(0,$.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col items-center justify-center rounded-2xl border border-dashed border-edge bg-surface-panel/40 px-6 py-12 text-center`,children:[e,n,r]}),t[20]=e,t[21]=n,t[22]=r,t[23]=i):i=t[23],i}let T;if(t[24]!==C||t[25]!==r||t[26]!==i||t[27]!==v||t[28]!==p||t[29]!==d||t[30]!==f||t[31]!==m||t[32]!==l){let e;t[34]!==r||t[35]!==i||t[36]!==v||t[37]!==p||t[38]!==d||t[39]!==f||t[40]!==m||t[41]!==l?(e=e=>(0,$.jsx)(dt,{column:e,language:r,localeTag:i,nowMs:v,selectedRunId:l,onOpenRun:d,onOpenRunChat:f,onCancelRun:p,onRetryRun:m},e.id),t[34]=r,t[35]=i,t[36]=v,t[37]=p,t[38]=d,t[39]=f,t[40]=m,t[41]=l,t[42]=e):e=t[42],T=C.map(e),t[24]=C,t[25]=r,t[26]=i,t[27]=v,t[28]=p,t[29]=d,t[30]=f,t[31]=m,t[32]=l,t[33]=T}else T=t[33];let E;return t[43]===T?E=t[44]:(E=(0,$.jsx)(`div`,{className:`-mx-1 flex h-full min-w-0 snap-x snap-mandatory gap-3 overflow-x-auto px-1 pb-3`,children:T}),t[43]=T,t[44]=E),E});function pt(e){return e.status===`queued`||e.status===`running`}function mt(){return Date.now()}function ht(e,t){return e+t.runs.length}var gt=`export const meta = {
|
|
2
2
|
name: 'my_workflow',
|
|
3
3
|
description: 'Describe what this workflow does.',
|
|
4
4
|
whenToUse: 'When the user asks for ...',
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" fill="none" aria-hidden="true" viewBox="0 0 100 100"><title>xopc app icon</title><defs><linearGradient id="bg" x1="18" x2="86" y1="8" y2="96" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#202434"/><stop offset=".46" stop-color="#0a0a0a"/><stop offset="1" stop-color="#111827"/></linearGradient><linearGradient id="rim" x1="22" x2="76" y1="8" y2="92" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#fff" stop-opacity=".24"/><stop offset=".42" stop-color="#fff" stop-opacity=".06"/><stop offset="1" stop-opacity=".34"/></linearGradient><linearGradient id="mark" x1="33" x2="72" y1="21" y2="80" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#fff"/><stop offset=".58" stop-color="#f4f7ff"/><stop offset="1" stop-color="#dde6ff"/></linearGradient><radialGradient id="loopGlow" cx="0" cy="0" r="1" gradientTransform="rotate(48 -5.214 42.69)scale(74 58)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#3a6bff" stop-opacity=".46"/><stop offset=".42" stop-color="#5b57ff" stop-opacity=".18"/><stop offset="1" stop-color="#2ed8ff" stop-opacity="0"/></radialGradient><radialGradient id="cyanSheen" cx="0" cy="0" r="1" gradientTransform="rotate(228 58.7 24.19)scale(62 48)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#2ed8ff" stop-opacity=".3"/><stop offset=".58" stop-color="#3a6bff" stop-opacity=".08"/><stop offset="1" stop-color="#2ed8ff" stop-opacity="0"/></radialGradient><filter id="softShadow" width="140%" height="140%" x="-20%" y="-20%" color-interpolation-filters="sRGB"><feDropShadow dx="0" dy="2" flood-color="#000" flood-opacity=".42" stdDeviation="2"/></filter><filter id="grain" width="100%" height="100%" x="0" y="0" color-interpolation-filters="sRGB"><feTurbulence baseFrequency=".9" numOctaves="3" stitchTiles="stitch" type="fractalNoise"/><feColorMatrix type="saturate" values="0"/><feComponentTransfer><feFuncA tableValues="0 0.035" type="table"/></feComponentTransfer></filter><clipPath id="iconClip"><rect width="88" height="88" x="6" y="6" rx="22"/></clipPath></defs><g clip-path="url(#iconClip)"><rect width="88" height="88" x="6" y="6" fill="url(#bg)" rx="22"/><rect width="88" height="88" x="6" y="6" fill="url(#loopGlow)" rx="22"/><rect width="88" height="88" x="6" y="6" fill="url(#cyanSheen)" rx="22"/><path stroke="#fff" stroke-opacity=".16" stroke-width="1.2" d="M14 22C32 7 63 7 86 31"/><path stroke="#2ed8ff" stroke-opacity=".1" d="M12 78c22 13 55 16 78-13"/><rect width="88" height="88" x="6" y="6" filter="url(#grain)" opacity=".9" rx="22"/></g><rect width="87" height="87" x="6.5" y="6.5" stroke="url(#rim)" rx="21.5"/><g filter="url(#softShadow)" transform="matrix(.76 0 0 .76 12 12)"><g stroke="url(#mark)" stroke-linecap="round"><g stroke-width="4"><path d="M29.375 23.602a33.5 33.5 0 0 1 41.25 0"/><path d="M76.398 29.375a33.5 33.5 0 0 1 0 41.25"/><path d="M70.625 76.398a33.5 33.5 0 0 1-41.25 0"/><path d="M23.602 70.625a33.5 33.5 0 0 1 0-41.25"/></g><g stroke-width="3.2" opacity=".86"><path d="M53.989 24.814A25.5 25.5 0 0 1 75.186 46.01"/><path d="M75.186 53.989A25.5 25.5 0 0 1 53.99 75.186"/><path d="M46.011 75.186A25.5 25.5 0 0 1 24.814 53.99"/><path d="M24.814 46.011A25.5 25.5 0 0 1 46.01 24.814"/></g></g><path fill="url(#mark)" d="m61 50 .159.548.47.597.752.692.993.823 1.176.985 1.293 1.161 1.335 1.34 1.3 1.508 1.189 1.648 1.009 1.749.767 1.802.478 1.794.154 1.725-.187 1.591-.529 1.396-.853 1.147-1.147.853-1.396.529-1.591.187-1.725-.154-1.794-.478-1.802-.767-1.749-1.009-1.648-1.189-1.508-1.3-1.34-1.335-1.161-1.293-.985-1.176-.823-.993-.692-.752-.597-.47L50 61l-.548.159-.597.47-.692.752-.823.993-.985 1.176-1.161 1.293-1.34 1.335-1.508 1.3-1.648 1.189-1.749 1.009-1.802.767-1.794.478-1.725.154-1.591-.187-1.396-.529-1.147-.853-.853-1.147-.529-1.396-.187-1.591.154-1.725.478-1.794.767-1.802 1.009-1.749 1.189-1.648 1.3-1.508 1.335-1.34 1.293-1.161 1.176-.985.993-.823.752-.692.47-.597L39 50l-.159-.548-.47-.597-.752-.692-.993-.823-1.176-.985-1.293-1.161-1.335-1.34-1.3-1.508-1.189-1.648-1.009-1.749-.767-1.802-.478-1.794-.154-1.725.187-1.591.529-1.396.853-1.147 1.147-.853 1.396-.529 1.591-.187 1.725.154 1.794.478 1.802.767 1.749 1.009 1.648 1.189 1.508 1.3 1.34 1.335 1.161 1.293.985 1.176.823.993.692.752.597.47L50 39l.548-.159.597-.47.692-.752.823-.993.985-1.176 1.161-1.293 1.34-1.335 1.508-1.3 1.648-1.189 1.749-1.009 1.802-.767 1.794-.478 1.725-.154 1.591.187 1.396.529 1.147.853.853 1.147.529 1.396.187 1.591-.154 1.725-.478 1.794-.767 1.802-1.009 1.749-1.189 1.648-1.3 1.508-1.335 1.34-1.293 1.161-1.176.985-.993.823-.752.692-.47.597z" transform="matrix(.72 0 0 .72 14 14)"/></g></svg>
|
|
Binary file
|
|
Binary file
|
|
@@ -1,20 +1,27 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 10 80 80" fill="none" aria-hidden="true">
|
|
2
2
|
<title>xopc</title>
|
|
3
|
-
<rect x="
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
<rect x="10" y="10" width="80" height="80" rx="18" fill="#ffffff" />
|
|
4
|
+
<g transform="translate(50 50) scale(0.92) translate(-50 -50)">
|
|
5
|
+
<!-- Goal loop: outer system boundary + inner feedback loop -->
|
|
6
|
+
<g stroke-linecap="round" fill="none">
|
|
7
|
+
<g stroke="#000000" stroke-width="4">
|
|
8
|
+
<path d="M 29.375 23.602 A 33.5 33.5 0 0 1 70.625 23.602" />
|
|
9
|
+
<path d="M 76.398 29.375 A 33.5 33.5 0 0 1 76.398 70.625" />
|
|
10
|
+
<path d="M 70.625 76.398 A 33.5 33.5 0 0 1 29.375 76.398" />
|
|
11
|
+
<path d="M 23.602 70.625 A 33.5 33.5 0 0 1 23.602 29.375" />
|
|
12
|
+
</g>
|
|
13
|
+
<g stroke="#000000" stroke-width="3.2" transform="rotate(45 50 50)">
|
|
14
|
+
<path d="M 35.011 29.370 A 25.5 25.5 0 0 1 64.989 29.370" />
|
|
15
|
+
<path d="M 70.630 35.011 A 25.5 25.5 0 0 1 70.630 64.989" />
|
|
16
|
+
<path d="M 64.989 70.630 A 25.5 25.5 0 0 1 35.011 70.630" />
|
|
17
|
+
<path d="M 29.370 64.989 A 25.5 25.5 0 0 1 29.370 35.011" />
|
|
18
|
+
</g>
|
|
19
|
+
</g>
|
|
20
|
+
<!-- Central hub -->
|
|
21
|
+
<path
|
|
22
|
+
fill="#000000"
|
|
23
|
+
transform="translate(50 50) scale(0.72) translate(-50 -50)"
|
|
24
|
+
d="M 61.000 50.000 L 61.159 50.548 L 61.629 51.145 L 62.381 51.837 L 63.374 52.660 L 64.550 53.645 L 65.843 54.806 L 67.178 56.146 L 68.478 57.654 L 69.667 59.302 L 70.676 61.051 L 71.443 62.853 L 71.921 64.647 L 72.075 66.372 L 71.888 67.963 L 71.359 69.359 L 70.506 70.506 L 69.359 71.359 L 67.963 71.888 L 66.372 72.075 L 64.647 71.921 L 62.853 71.443 L 61.051 70.676 L 59.302 69.667 L 57.654 68.478 L 56.146 67.178 L 54.806 65.843 L 53.645 64.550 L 52.660 63.374 L 51.837 62.381 L 51.145 61.629 L 50.548 61.159 L 50.000 61.000 L 49.452 61.159 L 48.855 61.629 L 48.163 62.381 L 47.340 63.374 L 46.355 64.550 L 45.194 65.843 L 43.854 67.178 L 42.346 68.478 L 40.698 69.667 L 38.949 70.676 L 37.147 71.443 L 35.353 71.921 L 33.628 72.075 L 32.037 71.888 L 30.641 71.359 L 29.494 70.506 L 28.641 69.359 L 28.112 67.963 L 27.925 66.372 L 28.079 64.647 L 28.557 62.853 L 29.324 61.051 L 30.333 59.302 L 31.522 57.654 L 32.822 56.146 L 34.157 54.806 L 35.450 53.645 L 36.626 52.660 L 37.619 51.837 L 38.371 51.145 L 38.841 50.548 L 39.000 50.000 L 38.841 49.452 L 38.371 48.855 L 37.619 48.163 L 36.626 47.340 L 35.450 46.355 L 34.157 45.194 L 32.822 43.854 L 31.522 42.346 L 30.333 40.698 L 29.324 38.949 L 28.557 37.147 L 28.079 35.353 L 27.925 33.628 L 28.112 32.037 L 28.641 30.641 L 29.494 29.494 L 30.641 28.641 L 32.037 28.112 L 33.628 27.925 L 35.353 28.079 L 37.147 28.557 L 38.949 29.324 L 40.698 30.333 L 42.346 31.522 L 43.854 32.822 L 45.194 34.157 L 46.355 35.450 L 47.340 36.626 L 48.163 37.619 L 48.855 38.371 L 49.452 38.841 L 50.000 39.000 L 50.548 38.841 L 51.145 38.371 L 51.837 37.619 L 52.660 36.626 L 53.645 35.450 L 54.806 34.157 L 56.146 32.822 L 57.654 31.522 L 59.302 30.333 L 61.051 29.324 L 62.853 28.557 L 64.647 28.079 L 66.372 27.925 L 67.963 28.112 L 69.359 28.641 L 70.506 29.494 L 71.359 30.641 L 71.888 32.037 L 72.075 33.628 L 71.921 35.353 L 71.443 37.147 L 70.676 38.949 L 69.667 40.698 L 68.478 42.346 L 67.178 43.854 L 65.843 45.194 L 64.550 46.355 L 63.374 47.340 L 62.381 48.163 L 61.629 48.855 L 61.159 49.452 L 61.000 50.000 Z"
|
|
25
|
+
/>
|
|
14
26
|
</g>
|
|
15
|
-
<!-- Central hub -->
|
|
16
|
-
<path
|
|
17
|
-
fill="#000000"
|
|
18
|
-
d="M 61.000 50.000 L 61.159 50.548 L 61.629 51.145 L 62.381 51.837 L 63.374 52.660 L 64.550 53.645 L 65.843 54.806 L 67.178 56.146 L 68.478 57.654 L 69.667 59.302 L 70.676 61.051 L 71.443 62.853 L 71.921 64.647 L 72.075 66.372 L 71.888 67.963 L 71.359 69.359 L 70.506 70.506 L 69.359 71.359 L 67.963 71.888 L 66.372 72.075 L 64.647 71.921 L 62.853 71.443 L 61.051 70.676 L 59.302 69.667 L 57.654 68.478 L 56.146 67.178 L 54.806 65.843 L 53.645 64.550 L 52.660 63.374 L 51.837 62.381 L 51.145 61.629 L 50.548 61.159 L 50.000 61.000 L 49.452 61.159 L 48.855 61.629 L 48.163 62.381 L 47.340 63.374 L 46.355 64.550 L 45.194 65.843 L 43.854 67.178 L 42.346 68.478 L 40.698 69.667 L 38.949 70.676 L 37.147 71.443 L 35.353 71.921 L 33.628 72.075 L 32.037 71.888 L 30.641 71.359 L 29.494 70.506 L 28.641 69.359 L 28.112 67.963 L 27.925 66.372 L 28.079 64.647 L 28.557 62.853 L 29.324 61.051 L 30.333 59.302 L 31.522 57.654 L 32.822 56.146 L 34.157 54.806 L 35.450 53.645 L 36.626 52.660 L 37.619 51.837 L 38.371 51.145 L 38.841 50.548 L 39.000 50.000 L 38.841 49.452 L 38.371 48.855 L 37.619 48.163 L 36.626 47.340 L 35.450 46.355 L 34.157 45.194 L 32.822 43.854 L 31.522 42.346 L 30.333 40.698 L 29.324 38.949 L 28.557 37.147 L 28.079 35.353 L 27.925 33.628 L 28.112 32.037 L 28.641 30.641 L 29.494 29.494 L 30.641 28.641 L 32.037 28.112 L 33.628 27.925 L 35.353 28.079 L 37.147 28.557 L 38.949 29.324 L 40.698 30.333 L 42.346 31.522 L 43.854 32.822 L 45.194 34.157 L 46.355 35.450 L 47.340 36.626 L 48.163 37.619 L 48.855 38.371 L 49.452 38.841 L 50.000 39.000 L 50.548 38.841 L 51.145 38.371 L 51.837 37.619 L 52.660 36.626 L 53.645 35.450 L 54.806 34.157 L 56.146 32.822 L 57.654 31.522 L 59.302 30.333 L 61.051 29.324 L 62.853 28.557 L 64.647 28.079 L 66.372 27.925 L 67.963 28.112 L 69.359 28.641 L 70.506 29.494 L 71.359 30.641 L 71.888 32.037 L 72.075 33.628 L 71.921 35.353 L 71.443 37.147 L 70.676 38.949 L 69.667 40.698 L 68.478 42.346 L 67.178 43.854 L 65.843 45.194 L 64.550 46.355 L 63.374 47.340 L 62.381 48.163 L 61.629 48.855 L 61.159 49.452 L 61.000 50.000 Z"
|
|
19
|
-
/>
|
|
20
27
|
</svg>
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.pngv=20260623-2" />
|
|
11
11
|
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png?v=20260623-2" />
|
|
12
12
|
<title>xopc</title>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-Cxm6xsps.js"></script>
|
|
14
14
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-aKtaBQYM.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-zJ_50EbN.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/vendor-react-BOUWij0V.js">
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
<link rel="modulepreload" crossorigin href="/assets/middleware-Pd0e8Igk.js">
|
|
24
24
|
<link rel="modulepreload" crossorigin href="/assets/locale-store-DjbfSsfA.js">
|
|
25
25
|
<link rel="modulepreload" crossorigin href="/assets/config-reload-event-Bjh2zoKp.js">
|
|
26
|
-
<link rel="modulepreload" crossorigin href="/assets/messages-
|
|
27
|
-
<link rel="modulepreload" crossorigin href="/assets/fetch-
|
|
28
|
-
<link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-
|
|
26
|
+
<link rel="modulepreload" crossorigin href="/assets/messages-CkT-lcgP.js">
|
|
27
|
+
<link rel="modulepreload" crossorigin href="/assets/fetch-NZmjSXLl.js">
|
|
28
|
+
<link rel="modulepreload" crossorigin href="/assets/gateway-startup-retry-Be1omjh3.js">
|
|
29
29
|
<link rel="modulepreload" crossorigin href="/assets/toast-z0toXu32.js">
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/assets/theme-store-CD2wtgZV.js">
|
|
31
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
31
|
+
<link rel="stylesheet" crossorigin href="/assets/index-b_R4tKqt.css">
|
|
32
32
|
</head>
|
|
33
33
|
<body>
|
|
34
34
|
<div id="root"></div>
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 10 80 80" fill="none" aria-hidden="true">
|
|
2
2
|
<title>xopc</title>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
<g transform="translate(50 50) scale(0.92) translate(-50 -50)">
|
|
4
|
+
<!-- Goal loop: outer system boundary + inner feedback loop -->
|
|
5
|
+
<g stroke-linecap="round" fill="none">
|
|
6
|
+
<g stroke="#ffffff" stroke-width="4">
|
|
7
|
+
<path d="M 29.375 23.602 A 33.5 33.5 0 0 1 70.625 23.602" />
|
|
8
|
+
<path d="M 76.398 29.375 A 33.5 33.5 0 0 1 76.398 70.625" />
|
|
9
|
+
<path d="M 70.625 76.398 A 33.5 33.5 0 0 1 29.375 76.398" />
|
|
10
|
+
<path d="M 23.602 70.625 A 33.5 33.5 0 0 1 23.602 29.375" />
|
|
11
|
+
</g>
|
|
12
|
+
<g stroke="#ffffff" stroke-width="3.2" transform="rotate(45 50 50)">
|
|
13
|
+
<path d="M 35.011 29.370 A 25.5 25.5 0 0 1 64.989 29.370" />
|
|
14
|
+
<path d="M 70.630 35.011 A 25.5 25.5 0 0 1 70.630 64.989" />
|
|
15
|
+
<path d="M 64.989 70.630 A 25.5 25.5 0 0 1 35.011 70.630" />
|
|
16
|
+
<path d="M 29.370 64.989 A 25.5 25.5 0 0 1 29.370 35.011" />
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
<!-- Central hub -->
|
|
20
|
+
<path
|
|
21
|
+
fill="#ffffff"
|
|
22
|
+
transform="translate(50 50) scale(0.72) translate(-50 -50)"
|
|
23
|
+
d="M 61.000 50.000 L 61.159 50.548 L 61.629 51.145 L 62.381 51.837 L 63.374 52.660 L 64.550 53.645 L 65.843 54.806 L 67.178 56.146 L 68.478 57.654 L 69.667 59.302 L 70.676 61.051 L 71.443 62.853 L 71.921 64.647 L 72.075 66.372 L 71.888 67.963 L 71.359 69.359 L 70.506 70.506 L 69.359 71.359 L 67.963 71.888 L 66.372 72.075 L 64.647 71.921 L 62.853 71.443 L 61.051 70.676 L 59.302 69.667 L 57.654 68.478 L 56.146 67.178 L 54.806 65.843 L 53.645 64.550 L 52.660 63.374 L 51.837 62.381 L 51.145 61.629 L 50.548 61.159 L 50.000 61.000 L 49.452 61.159 L 48.855 61.629 L 48.163 62.381 L 47.340 63.374 L 46.355 64.550 L 45.194 65.843 L 43.854 67.178 L 42.346 68.478 L 40.698 69.667 L 38.949 70.676 L 37.147 71.443 L 35.353 71.921 L 33.628 72.075 L 32.037 71.888 L 30.641 71.359 L 29.494 70.506 L 28.641 69.359 L 28.112 67.963 L 27.925 66.372 L 28.079 64.647 L 28.557 62.853 L 29.324 61.051 L 30.333 59.302 L 31.522 57.654 L 32.822 56.146 L 34.157 54.806 L 35.450 53.645 L 36.626 52.660 L 37.619 51.837 L 38.371 51.145 L 38.841 50.548 L 39.000 50.000 L 38.841 49.452 L 38.371 48.855 L 37.619 48.163 L 36.626 47.340 L 35.450 46.355 L 34.157 45.194 L 32.822 43.854 L 31.522 42.346 L 30.333 40.698 L 29.324 38.949 L 28.557 37.147 L 28.079 35.353 L 27.925 33.628 L 28.112 32.037 L 28.641 30.641 L 29.494 29.494 L 30.641 28.641 L 32.037 28.112 L 33.628 27.925 L 35.353 28.079 L 37.147 28.557 L 38.949 29.324 L 40.698 30.333 L 42.346 31.522 L 43.854 32.822 L 45.194 34.157 L 46.355 35.450 L 47.340 36.626 L 48.163 37.619 L 48.855 38.371 L 49.452 38.841 L 50.000 39.000 L 50.548 38.841 L 51.145 38.371 L 51.837 37.619 L 52.660 36.626 L 53.645 35.450 L 54.806 34.157 L 56.146 32.822 L 57.654 31.522 L 59.302 30.333 L 61.051 29.324 L 62.853 28.557 L 64.647 28.079 L 66.372 27.925 L 67.963 28.112 L 69.359 28.641 L 70.506 29.494 L 71.359 30.641 L 71.888 32.037 L 72.075 33.628 L 71.921 35.353 L 71.443 37.147 L 70.676 38.949 L 69.667 40.698 L 68.478 42.346 L 67.178 43.854 L 65.843 45.194 L 64.550 46.355 L 63.374 47.340 L 62.381 48.163 L 61.629 48.855 L 61.159 49.452 L 61.000 50.000 Z"
|
|
24
|
+
/>
|
|
13
25
|
</g>
|
|
14
|
-
<path
|
|
15
|
-
fill="#ebebef"
|
|
16
|
-
d="M 61.000 50.000 L 61.159 50.548 L 61.629 51.145 L 62.381 51.837 L 63.374 52.660 L 64.550 53.645 L 65.843 54.806 L 67.178 56.146 L 68.478 57.654 L 69.667 59.302 L 70.676 61.051 L 71.443 62.853 L 71.921 64.647 L 72.075 66.372 L 71.888 67.963 L 71.359 69.359 L 70.506 70.506 L 69.359 71.359 L 67.963 71.888 L 66.372 72.075 L 64.647 71.921 L 62.853 71.443 L 61.051 70.676 L 59.302 69.667 L 57.654 68.478 L 56.146 67.178 L 54.806 65.843 L 53.645 64.550 L 52.660 63.374 L 51.837 62.381 L 51.145 61.629 L 50.548 61.159 L 50.000 61.000 L 49.452 61.159 L 48.855 61.629 L 48.163 62.381 L 47.340 63.374 L 46.355 64.550 L 45.194 65.843 L 43.854 67.178 L 42.346 68.478 L 40.698 69.667 L 38.949 70.676 L 37.147 71.443 L 35.353 71.921 L 33.628 72.075 L 32.037 71.888 L 30.641 71.359 L 29.494 70.506 L 28.641 69.359 L 28.112 67.963 L 27.925 66.372 L 28.079 64.647 L 28.557 62.853 L 29.324 61.051 L 30.333 59.302 L 31.522 57.654 L 32.822 56.146 L 34.157 54.806 L 35.450 53.645 L 36.626 52.660 L 37.619 51.837 L 38.371 51.145 L 38.841 50.548 L 39.000 50.000 L 38.841 49.452 L 38.371 48.855 L 37.619 48.163 L 36.626 47.340 L 35.450 46.355 L 34.157 45.194 L 32.822 43.854 L 31.522 42.346 L 30.333 40.698 L 29.324 38.949 L 28.557 37.147 L 28.079 35.353 L 27.925 33.628 L 28.112 32.037 L 28.641 30.641 L 29.494 29.494 L 30.641 28.641 L 32.037 28.112 L 33.628 27.925 L 35.353 28.079 L 37.147 28.557 L 38.949 29.324 L 40.698 30.333 L 42.346 31.522 L 43.854 32.822 L 45.194 34.157 L 46.355 35.450 L 47.340 36.626 L 48.163 37.619 L 48.855 38.371 L 49.452 38.841 L 50.000 39.000 L 50.548 38.841 L 51.145 38.371 L 51.837 37.619 L 52.660 36.626 L 53.645 35.450 L 54.806 34.157 L 56.146 32.822 L 57.654 31.522 L 59.302 30.333 L 61.051 29.324 L 62.853 28.557 L 64.647 28.079 L 66.372 27.925 L 67.963 28.112 L 69.359 28.641 L 70.506 29.494 L 71.359 30.641 L 71.888 32.037 L 72.075 33.628 L 71.921 35.353 L 71.443 37.147 L 70.676 38.949 L 69.667 40.698 L 68.478 42.346 L 67.178 43.854 L 65.843 45.194 L 64.550 46.355 L 63.374 47.340 L 62.381 48.163 L 61.629 48.855 L 61.159 49.452 L 61.000 50.000 Z"
|
|
17
|
-
/>
|
|
18
26
|
</svg>
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="10 10 80 80" fill="none" aria-hidden="true">
|
|
2
2
|
<title>xopc</title>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
<g transform="translate(50 50) scale(0.92) translate(-50 -50)">
|
|
4
|
+
<!-- Goal loop: outer system boundary + inner feedback loop -->
|
|
5
|
+
<g stroke-linecap="round" fill="none">
|
|
6
|
+
<g stroke="#000000" stroke-width="4">
|
|
7
|
+
<path d="M 29.375 23.602 A 33.5 33.5 0 0 1 70.625 23.602" />
|
|
8
|
+
<path d="M 76.398 29.375 A 33.5 33.5 0 0 1 76.398 70.625" />
|
|
9
|
+
<path d="M 70.625 76.398 A 33.5 33.5 0 0 1 29.375 76.398" />
|
|
10
|
+
<path d="M 23.602 70.625 A 33.5 33.5 0 0 1 23.602 29.375" />
|
|
11
|
+
</g>
|
|
12
|
+
<g stroke="#000000" stroke-width="3.2" transform="rotate(45 50 50)">
|
|
13
|
+
<path d="M 35.011 29.370 A 25.5 25.5 0 0 1 64.989 29.370" />
|
|
14
|
+
<path d="M 70.630 35.011 A 25.5 25.5 0 0 1 70.630 64.989" />
|
|
15
|
+
<path d="M 64.989 70.630 A 25.5 25.5 0 0 1 35.011 70.630" />
|
|
16
|
+
<path d="M 29.370 64.989 A 25.5 25.5 0 0 1 29.370 35.011" />
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
<!-- Central hub -->
|
|
20
|
+
<path
|
|
21
|
+
fill="#000000"
|
|
22
|
+
transform="translate(50 50) scale(0.72) translate(-50 -50)"
|
|
17
23
|
d="M 61.000 50.000 L 61.159 50.548 L 61.629 51.145 L 62.381 51.837 L 63.374 52.660 L 64.550 53.645 L 65.843 54.806 L 67.178 56.146 L 68.478 57.654 L 69.667 59.302 L 70.676 61.051 L 71.443 62.853 L 71.921 64.647 L 72.075 66.372 L 71.888 67.963 L 71.359 69.359 L 70.506 70.506 L 69.359 71.359 L 67.963 71.888 L 66.372 72.075 L 64.647 71.921 L 62.853 71.443 L 61.051 70.676 L 59.302 69.667 L 57.654 68.478 L 56.146 67.178 L 54.806 65.843 L 53.645 64.550 L 52.660 63.374 L 51.837 62.381 L 51.145 61.629 L 50.548 61.159 L 50.000 61.000 L 49.452 61.159 L 48.855 61.629 L 48.163 62.381 L 47.340 63.374 L 46.355 64.550 L 45.194 65.843 L 43.854 67.178 L 42.346 68.478 L 40.698 69.667 L 38.949 70.676 L 37.147 71.443 L 35.353 71.921 L 33.628 72.075 L 32.037 71.888 L 30.641 71.359 L 29.494 70.506 L 28.641 69.359 L 28.112 67.963 L 27.925 66.372 L 28.079 64.647 L 28.557 62.853 L 29.324 61.051 L 30.333 59.302 L 31.522 57.654 L 32.822 56.146 L 34.157 54.806 L 35.450 53.645 L 36.626 52.660 L 37.619 51.837 L 38.371 51.145 L 38.841 50.548 L 39.000 50.000 L 38.841 49.452 L 38.371 48.855 L 37.619 48.163 L 36.626 47.340 L 35.450 46.355 L 34.157 45.194 L 32.822 43.854 L 31.522 42.346 L 30.333 40.698 L 29.324 38.949 L 28.557 37.147 L 28.079 35.353 L 27.925 33.628 L 28.112 32.037 L 28.641 30.641 L 29.494 29.494 L 30.641 28.641 L 32.037 28.112 L 33.628 27.925 L 35.353 28.079 L 37.147 28.557 L 38.949 29.324 L 40.698 30.333 L 42.346 31.522 L 43.854 32.822 L 45.194 34.157 L 46.355 35.450 L 47.340 36.626 L 48.163 37.619 L 48.855 38.371 L 49.452 38.841 L 50.000 39.000 L 50.548 38.841 L 51.145 38.371 L 51.837 37.619 L 52.660 36.626 L 53.645 35.450 L 54.806 34.157 L 56.146 32.822 L 57.654 31.522 L 59.302 30.333 L 61.051 29.324 L 62.853 28.557 L 64.647 28.079 L 66.372 27.925 L 67.963 28.112 L 69.359 28.641 L 70.506 29.494 L 71.359 30.641 L 71.888 32.037 L 72.075 33.628 L 71.921 35.353 L 71.443 37.147 L 70.676 38.949 L 69.667 40.698 L 68.478 42.346 L 67.178 43.854 L 65.843 45.194 L 64.550 46.355 L 63.374 47.340 L 62.381 48.163 L 61.629 48.855 L 61.159 49.452 L 61.000 50.000 Z"
|
|
18
|
-
|
|
24
|
+
/>
|
|
25
|
+
</g>
|
|
19
26
|
</svg>
|
package/dist/package.js
CHANGED
|
@@ -219,6 +219,15 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
219
219
|
content: formatStreamError(err instanceof Error ? err.message : String(err))
|
|
220
220
|
});
|
|
221
221
|
} finally {
|
|
222
|
+
if (!userAborted && channel === "webchat") try {
|
|
223
|
+
const ttsAudioEvent = await deps.maybeEmitWebchatTts(sessionKey, inboundVoice);
|
|
224
|
+
if (ttsAudioEvent) queue.push(ttsAudioEvent);
|
|
225
|
+
} catch (ttsErr) {
|
|
226
|
+
deps.log.warn({
|
|
227
|
+
err: ttsErr,
|
|
228
|
+
sessionKey
|
|
229
|
+
}, "Failed to emit TTS audio before stream close");
|
|
230
|
+
}
|
|
222
231
|
queue.close();
|
|
223
232
|
}
|
|
224
233
|
})();
|
|
@@ -254,10 +263,6 @@ async function* runProcessDirectStreaming(deps, input) {
|
|
|
254
263
|
sessionKey
|
|
255
264
|
}, "Failed to persist webchat slash command receipt");
|
|
256
265
|
}
|
|
257
|
-
if (!userAborted) {
|
|
258
|
-
const ttsAudioEvent = await deps.maybeEmitWebchatTts(sessionKey, inboundVoice);
|
|
259
|
-
if (ttsAudioEvent) yield ttsAudioEvent;
|
|
260
|
-
}
|
|
261
266
|
deps.recordPersistentGoalStreamOutcome?.(sessionKey, { skipPersistentGoalPostTurn: ranSlashCommand });
|
|
262
267
|
} finally {
|
|
263
268
|
if (channel === "webchat") deps.unregisterWebchatSsePublisher(sessionKey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-direct-streaming.js","names":[],"sources":["../../../../src/agent/service/process-direct-streaming.ts"],"sourcesContent":["import type { AgentMessage } from '@earendil-works/pi-agent-core';\nimport type { ImageContent } from '@earendil-works/pi-ai';\n\nimport type { Config } from '../../config/schema.js';\nimport type { InboundAttachmentInput, MediaRef } from '../../channels/attachments/inbound-persist.js';\nimport { readAgentMessageContent } from '../memory/agent-message-access.js';\nimport {\n isVoiceLikeAttachment,\n mergeVoiceTranscriptsIntoUserText,\n mergeSttConfigFromAppConfig,\n} from '../../channels/attachments/voice-stt-webchat.js';\nimport {\n resolveEffectiveReasoningLevel,\n initSessionTurn,\n type SessionConfigStore,\n type SessionStore,\n} from '../../session/index.js';\nimport type { SessionContext } from '../session/index.js';\nimport { applyReasoningVisibilityToSseEvent } from '../streaming/reasoning-visibility-sse.js';\nimport type { ReasoningLevel } from '../transcript/thinking-types.js';\nimport { formatAgentRunErrorForClient } from '../client-error-format.js';\nimport { abortEmbeddedRun } from '../embedded/runs.js';\nimport type { AgentInstanceGateway } from '../agent-instance-gateway.js';\nimport type { CommandHandler } from '../messaging/command-handler.js';\nimport type { ModelManager } from '../models/index.js';\nimport { injectSourceContextIntoUserMessage } from '../source-context/injector.js';\nimport { isSessionSourceBinding, type AgentSourceContextResolver } from '../source-context/types.js';\n\nimport { AsyncQueue } from './async-queue.js';\nimport {\n hydratePerTurnState,\n runDirectAgentTurn,\n tryRunSlashCommand,\n} from './direct-turn-helpers.js';\nimport {\n clearPendingTranscriptUserMessage,\n setPendingTranscriptUserMessage,\n type TranscriptUserMessage,\n} from '../inbound/attachment-pipeline.js';\n\nexport type DirectStreamInboundAttachment = InboundAttachmentInput;\n\nexport type ProcessDirectStreamLog = {\n info: (obj: Record<string, unknown>, msg: string) => void;\n warn: (obj: Record<string, unknown>, msg: string) => void;\n debug?: (obj: Record<string, unknown>, msg: string) => void;\n};\n\nexport interface ProcessDirectStreamingDeps {\n log: ProcessDirectStreamLog;\n parseSessionKey: (sessionKey: string) => { channel: string; chatId: string };\n initDirectStreamingSession: (\n sessionKey: string,\n channel: string,\n chatId: string,\n ) => SessionContext;\n registerWebchatSsePublisher: (\n sessionKey: string,\n publisher: (event: { type: string; [key: string]: unknown }) => void,\n ) => void;\n unregisterWebchatSsePublisher: (sessionKey: string) => void;\n agentManager: AgentInstanceGateway;\n hydrateSessionWorkspaceFromStore: (sessionKey: string) => Promise<void>;\n hydrateSessionModelFromStore: (sessionKey: string) => Promise<void>;\n sessionStore: SessionStore;\n modelManager: ModelManager;\n applyResolvedThinkingLevel: (sessionKey: string, thinking?: string | null) => Promise<void>;\n getConfig: () => Config | undefined;\n sessionConfigStore: SessionConfigStore;\n commandHandler: Pick<CommandHandler, 'executeCommandAndAggregateReply'>;\n prepareInboundAttachments: (\n sessionKey: string,\n attachments?: DirectStreamInboundAttachment[],\n ) => Promise<MediaRef[] | undefined>;\n buildTranscriptUserMessage: (\n content: string,\n prepared: MediaRef[] | undefined,\n sessionKey: string,\n ) => Promise<TranscriptUserMessage>;\n recordPersistentGoalStreamOutcome?: (\n sessionKey: string,\n outcome: { skipPersistentGoalPostTurn: boolean },\n ) => void;\n onTurnComplete?: (sessionKey: string, lastAssistantText?: string) => void;\n enqueueProvisionalSessionTitle?: (sessionKey: string, userText: string) => void;\n /** Disk-only transcript sync (slash receipt already streamed as tokens). */\n reloadWebchatTranscript?: (sessionKey: string) => void;\n maybeEmitWebchatTts: (\n sessionKey: string,\n hadInboundVoice: boolean,\n ) => Promise<{ type: 'tts_audio'; uri: string; mimeType: string; name: string } | null>;\n endDirectRequestContext: () => void;\n resetSession: (sessionKey: string) => Promise<{ sessionId: string; previousSessionId: string } | null>;\n sourceContextResolver?: AgentSourceContextResolver;\n}\n\nexport interface ProcessDirectStreamingInput {\n content: string;\n sessionKey?: string;\n attachments?: DirectStreamInboundAttachment[];\n thinking?: string;\n signal?: AbortSignal;\n runId?: string;\n}\n\nexport type ProcessDirectStreamingSseEvent = { type: string; [key: string]: unknown };\n\nfunction makeAssistantReceiptMessage(text: string): AgentMessage {\n return {\n role: 'assistant',\n content: [{ type: 'text', text }],\n timestamp: Date.now(),\n } as AgentMessage;\n}\n\nfunction pushAssistantReceipt(\n queue: AsyncQueue<ProcessDirectStreamingSseEvent>,\n text: string,\n runId?: string,\n): void {\n const message = makeAssistantReceiptMessage(text);\n queue.push({ type: 'message_start', runId, message });\n queue.push({ type: 'message_update', runId, message });\n queue.push({ type: 'message_end', runId, message });\n}\n\nexport async function* runProcessDirectStreaming(\n deps: ProcessDirectStreamingDeps,\n input: ProcessDirectStreamingInput,\n): AsyncGenerator<ProcessDirectStreamingSseEvent, void, unknown> {\n const sessionKey = input.sessionKey ?? 'agent:main:main';\n const { channel, chatId } = deps.parseSessionKey(sessionKey);\n const context = deps.initDirectStreamingSession(sessionKey, channel, chatId);\n\n const queue = new AsyncQueue<ProcessDirectStreamingSseEvent>();\n let reasoningLevel: ReasoningLevel = 'stream';\n\n const pushVisible = (event: ProcessDirectStreamingSseEvent) => {\n const visible = applyReasoningVisibilityToSseEvent(event, reasoningLevel);\n if (visible !== null) {\n queue.push(visible);\n }\n };\n\n const formatStreamError = (raw: string): string => {\n let provider: string | undefined;\n let modelRef: string | undefined;\n try {\n const resolved = deps.modelManager.getResolvedModelForSession(sessionKey);\n provider = resolved.provider;\n modelRef = deps.modelManager.getModelForSession(sessionKey);\n } catch {\n /* ignore — format without provider context */\n }\n return formatAgentRunErrorForClient(raw, { provider, modelRef });\n };\n\n if (channel === 'webchat') {\n deps.registerWebchatSsePublisher(sessionKey, pushVisible);\n }\n\n const signal = input.signal;\n let userAborted = false;\n let abortHandled = false;\n let inboundVoice = false;\n let ranSlashCommand = false;\n let mergedUserText = input.content;\n let webchatSlashReceipt: string | undefined;\n let slashCommandMetadata: Record<string, unknown> | undefined;\n\n const taskPromise = (async () => {\n try {\n const cfg = deps.getConfig();\n let turnBody = input.content;\n let resetTriggeredAtInit = false;\n if (cfg) {\n const turn = await initSessionTurn({\n cfg,\n sessionKey,\n body: input.content,\n resetSession: deps.resetSession,\n });\n resetTriggeredAtInit = turn.resetTriggered;\n if (turn.bareReset && turn.ackMessage) {\n ranSlashCommand = true;\n webchatSlashReceipt = turn.ackMessage;\n pushAssistantReceipt(queue, turn.ackMessage, input.runId);\n return;\n }\n turnBody = turn.bodyStripped;\n if (turn.isNewSession) {\n deps.log.debug(\n {\n sessionKey,\n sessionId: turn.sessionId,\n previousSessionId: turn.previousSessionId,\n resetTriggered: turn.resetTriggered,\n staleRollover: turn.staleRollover,\n },\n 'Session reset boundary at direct turn start',\n );\n }\n }\n\n await hydratePerTurnState(deps, sessionKey, input.thinking);\n {\n const defReason = (deps.getConfig()?.agents?.defaults?.reasoningDefault ?? 'stream') as ReasoningLevel;\n reasoningLevel = await resolveEffectiveReasoningLevel(deps.sessionConfigStore, sessionKey, defReason);\n }\n\n const prepared = await deps.prepareInboundAttachments(sessionKey, input.attachments);\n\n const sttCfg = mergeSttConfigFromAppConfig(deps.getConfig()?.tools?.media?.audio, deps.getConfig()?.tools?.media);\n const voiceMerge = await mergeVoiceTranscriptsIntoUserText(prepared, turnBody, sttCfg);\n mergedUserText = voiceMerge.text;\n inboundVoice = voiceMerge.inboundVoice;\n\n if (inboundVoice) {\n const transcriptParts = [\n voiceMerge.voiceTranscripts.filter(Boolean).join('\\n'),\n turnBody.trim(),\n ].filter(Boolean);\n const voiceMedia = (prepared ?? []).filter(isVoiceLikeAttachment).map((att) => ({\n uri: att.uri,\n mimeType: att.mimeType,\n name: att.name,\n }));\n pushVisible({\n type: 'user_transcript',\n text: transcriptParts.join('\\n\\n'),\n media: voiceMedia,\n });\n }\n\n const armAbort = () => {\n if (abortHandled) {\n return;\n }\n abortHandled = true;\n userAborted = true;\n void abortEmbeddedRun(sessionKey);\n queue.close();\n };\n if (signal) {\n if (signal.aborted) {\n armAbort();\n return;\n }\n signal.addEventListener('abort', armAbort, { once: true });\n }\n\n const slash = await tryRunSlashCommand(\n deps,\n {\n sessionKey,\n channel,\n chatId,\n senderId: context.senderId,\n isGroup: context.isGroup,\n inboundMetadata: context.metadata,\n },\n mergedUserText,\n { skipResetCommands: resetTriggeredAtInit },\n );\n if (slash.matched) {\n ranSlashCommand = true;\n slashCommandMetadata = slash.metadata;\n const text = slash.aggregatedText.trim();\n if (text) {\n webchatSlashReceipt = text;\n pushAssistantReceipt(queue, text, input.runId);\n } else if (channel === 'webchat') {\n webchatSlashReceipt =\n 'Command finished with no assistant text. If you used `/goal`, a follow-up turn may still be scheduled automatically.';\n pushAssistantReceipt(queue, webchatSlashReceipt, input.runId);\n }\n const workflowRun = slash.metadata?.workflowRun;\n if (workflowRun && typeof workflowRun === 'object') {\n queue.push({\n type: 'workflow_run_started',\n runId: input.runId,\n payload: { workflowRun },\n });\n }\n return;\n }\n\n const textForAgent = mergedUserText.trimStart().startsWith('/skill:')\n ? deps.agentManager.expandSkillUserText(mergedUserText)\n : mergedUserText;\n const userMessage = await deps.buildTranscriptUserMessage(textForAgent, prepared, sessionKey);\n let sourceEnrichedUserMessage: AgentMessage = userMessage;\n let sourceImages: ImageContent[] | undefined;\n if (deps.sourceContextResolver) {\n const metadata = await deps.sessionStore.getMetadata(sessionKey).catch(() => null);\n const sourceBinding = metadata?.customData && typeof metadata.customData === 'object'\n ? (metadata.customData as Record<string, unknown>).sourceBinding\n : undefined;\n if (isSessionSourceBinding(sourceBinding)) {\n const sourceContext = await deps.sourceContextResolver(sourceBinding, sessionKey);\n sourceEnrichedUserMessage = injectSourceContextIntoUserMessage(userMessage, sourceContext);\n sourceImages = sourceContext?.images;\n }\n }\n\n if (channel === 'webchat') {\n pushVisible({\n type: 'user_message',\n timestamp: userMessage.timestamp ?? Date.now(),\n content: readAgentMessageContent(userMessage),\n media: userMessage.media,\n });\n if (textForAgent.trim()) {\n deps.enqueueProvisionalSessionTitle?.(sessionKey, textForAgent);\n }\n }\n\n const pendingUserMessage = userMessage as TranscriptUserMessage;\n setPendingTranscriptUserMessage(sessionKey, pendingUserMessage);\n\n try {\n const result = await runDirectAgentTurn(\n {\n sessionStore: deps.sessionStore,\n agentManager: deps.agentManager,\n modelManager: deps.modelManager,\n config: deps.getConfig(),\n },\n {\n sessionKey,\n userMessage: sourceEnrichedUserMessage,\n abortSignal: signal,\n sourceImages,\n runId: input.runId,\n onEvent: (embeddedEvent) => {\n const event = { ...embeddedEvent };\n if (event.type === 'error' && typeof event.content === 'string') {\n event.content = formatStreamError(event.content);\n }\n pushVisible(event);\n },\n },\n );\n\n if (result.lastAssistantText) {\n deps.onTurnComplete?.(sessionKey, result.lastAssistantText);\n }\n if (!result.ok && result.errorMessage && !abortHandled) {\n pushVisible({ type: 'error', content: formatStreamError(result.errorMessage) });\n }\n } finally {\n clearPendingTranscriptUserMessage(sessionKey, pendingUserMessage);\n }\n } catch (err) {\n if (!abortHandled) {\n const em = err instanceof Error ? err.message : String(err);\n pushVisible({ type: 'error', content: formatStreamError(em) });\n }\n } finally {\n queue.close();\n }\n })();\n\n try {\n for await (const event of queue) {\n yield event;\n }\n await taskPromise;\n\n if (channel === 'webchat' && ranSlashCommand) {\n try {\n const userMsg = {\n role: 'user' as const,\n content: [{ type: 'text' as const, text: mergedUserText }],\n timestamp: Date.now(),\n } as AgentMessage;\n await deps.sessionStore.appendTranscriptMessage(sessionKey, userMsg);\n if (webchatSlashReceipt?.trim()) {\n const assistantMsg = {\n role: 'assistant' as const,\n content: [{ type: 'text' as const, text: webchatSlashReceipt.trim() }],\n timestamp: Date.now(),\n ...(slashCommandMetadata && Object.keys(slashCommandMetadata).length > 0\n ? { metadata: slashCommandMetadata }\n : {}),\n } as AgentMessage;\n await deps.sessionStore.appendTranscriptMessage(sessionKey, assistantMsg);\n }\n deps.reloadWebchatTranscript?.(sessionKey);\n } catch (err) {\n deps.log.warn({ err, sessionKey }, 'Failed to persist webchat slash command receipt');\n }\n }\n\n if (!userAborted) {\n const ttsAudioEvent = await deps.maybeEmitWebchatTts(sessionKey, inboundVoice);\n if (ttsAudioEvent) {\n yield ttsAudioEvent;\n }\n }\n\n deps.recordPersistentGoalStreamOutcome?.(sessionKey, { skipPersistentGoalPostTurn: ranSlashCommand });\n } finally {\n if (channel === 'webchat') {\n deps.unregisterWebchatSsePublisher(sessionKey);\n }\n deps.endDirectRequestContext();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2GA,SAAS,4BAA4B,MAA4B;AAC/D,QAAO;EACL,MAAM;EACN,SAAS,CAAC;GAAE,MAAM;GAAQ;GAAM,CAAC;EACjC,WAAW,KAAK,KAAK;EACtB;;AAGH,SAAS,qBACP,OACA,MACA,OACM;CACN,MAAM,UAAU,4BAA4B,KAAK;AACjD,OAAM,KAAK;EAAE,MAAM;EAAiB;EAAO;EAAS,CAAC;AACrD,OAAM,KAAK;EAAE,MAAM;EAAkB;EAAO;EAAS,CAAC;AACtD,OAAM,KAAK;EAAE,MAAM;EAAe;EAAO;EAAS,CAAC;;AAGrD,gBAAuB,0BACrB,MACA,OAC+D;CAC/D,MAAM,aAAa,MAAM,cAAc;CACvC,MAAM,EAAE,SAAS,WAAW,KAAK,gBAAgB,WAAW;CAC5D,MAAM,UAAU,KAAK,2BAA2B,YAAY,SAAS,OA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,YAAY,UACd,MAAK,8BAA8B,WAAW;AAEhD,OAAK,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"process-direct-streaming.js","names":[],"sources":["../../../../src/agent/service/process-direct-streaming.ts"],"sourcesContent":["import type { AgentMessage } from '@earendil-works/pi-agent-core';\nimport type { ImageContent } from '@earendil-works/pi-ai';\n\nimport type { Config } from '../../config/schema.js';\nimport type { InboundAttachmentInput, MediaRef } from '../../channels/attachments/inbound-persist.js';\nimport { readAgentMessageContent } from '../memory/agent-message-access.js';\nimport {\n isVoiceLikeAttachment,\n mergeVoiceTranscriptsIntoUserText,\n mergeSttConfigFromAppConfig,\n} from '../../channels/attachments/voice-stt-webchat.js';\nimport {\n resolveEffectiveReasoningLevel,\n initSessionTurn,\n type SessionConfigStore,\n type SessionStore,\n} from '../../session/index.js';\nimport type { SessionContext } from '../session/index.js';\nimport { applyReasoningVisibilityToSseEvent } from '../streaming/reasoning-visibility-sse.js';\nimport type { ReasoningLevel } from '../transcript/thinking-types.js';\nimport { formatAgentRunErrorForClient } from '../client-error-format.js';\nimport { abortEmbeddedRun } from '../embedded/runs.js';\nimport type { AgentInstanceGateway } from '../agent-instance-gateway.js';\nimport type { CommandHandler } from '../messaging/command-handler.js';\nimport type { ModelManager } from '../models/index.js';\nimport { injectSourceContextIntoUserMessage } from '../source-context/injector.js';\nimport { isSessionSourceBinding, type AgentSourceContextResolver } from '../source-context/types.js';\n\nimport { AsyncQueue } from './async-queue.js';\nimport {\n hydratePerTurnState,\n runDirectAgentTurn,\n tryRunSlashCommand,\n} from './direct-turn-helpers.js';\nimport {\n clearPendingTranscriptUserMessage,\n setPendingTranscriptUserMessage,\n type TranscriptUserMessage,\n} from '../inbound/attachment-pipeline.js';\n\nexport type DirectStreamInboundAttachment = InboundAttachmentInput;\n\nexport type ProcessDirectStreamLog = {\n info: (obj: Record<string, unknown>, msg: string) => void;\n warn: (obj: Record<string, unknown>, msg: string) => void;\n debug?: (obj: Record<string, unknown>, msg: string) => void;\n};\n\nexport interface ProcessDirectStreamingDeps {\n log: ProcessDirectStreamLog;\n parseSessionKey: (sessionKey: string) => { channel: string; chatId: string };\n initDirectStreamingSession: (\n sessionKey: string,\n channel: string,\n chatId: string,\n ) => SessionContext;\n registerWebchatSsePublisher: (\n sessionKey: string,\n publisher: (event: { type: string; [key: string]: unknown }) => void,\n ) => void;\n unregisterWebchatSsePublisher: (sessionKey: string) => void;\n agentManager: AgentInstanceGateway;\n hydrateSessionWorkspaceFromStore: (sessionKey: string) => Promise<void>;\n hydrateSessionModelFromStore: (sessionKey: string) => Promise<void>;\n sessionStore: SessionStore;\n modelManager: ModelManager;\n applyResolvedThinkingLevel: (sessionKey: string, thinking?: string | null) => Promise<void>;\n getConfig: () => Config | undefined;\n sessionConfigStore: SessionConfigStore;\n commandHandler: Pick<CommandHandler, 'executeCommandAndAggregateReply'>;\n prepareInboundAttachments: (\n sessionKey: string,\n attachments?: DirectStreamInboundAttachment[],\n ) => Promise<MediaRef[] | undefined>;\n buildTranscriptUserMessage: (\n content: string,\n prepared: MediaRef[] | undefined,\n sessionKey: string,\n ) => Promise<TranscriptUserMessage>;\n recordPersistentGoalStreamOutcome?: (\n sessionKey: string,\n outcome: { skipPersistentGoalPostTurn: boolean },\n ) => void;\n onTurnComplete?: (sessionKey: string, lastAssistantText?: string) => void;\n enqueueProvisionalSessionTitle?: (sessionKey: string, userText: string) => void;\n /** Disk-only transcript sync (slash receipt already streamed as tokens). */\n reloadWebchatTranscript?: (sessionKey: string) => void;\n maybeEmitWebchatTts: (\n sessionKey: string,\n hadInboundVoice: boolean,\n ) => Promise<{ type: 'tts_audio'; uri: string; mimeType: string; name: string } | null>;\n endDirectRequestContext: () => void;\n resetSession: (sessionKey: string) => Promise<{ sessionId: string; previousSessionId: string } | null>;\n sourceContextResolver?: AgentSourceContextResolver;\n}\n\nexport interface ProcessDirectStreamingInput {\n content: string;\n sessionKey?: string;\n attachments?: DirectStreamInboundAttachment[];\n thinking?: string;\n signal?: AbortSignal;\n runId?: string;\n}\n\nexport type ProcessDirectStreamingSseEvent = { type: string; [key: string]: unknown };\n\nfunction makeAssistantReceiptMessage(text: string): AgentMessage {\n return {\n role: 'assistant',\n content: [{ type: 'text', text }],\n timestamp: Date.now(),\n } as AgentMessage;\n}\n\nfunction pushAssistantReceipt(\n queue: AsyncQueue<ProcessDirectStreamingSseEvent>,\n text: string,\n runId?: string,\n): void {\n const message = makeAssistantReceiptMessage(text);\n queue.push({ type: 'message_start', runId, message });\n queue.push({ type: 'message_update', runId, message });\n queue.push({ type: 'message_end', runId, message });\n}\n\nexport async function* runProcessDirectStreaming(\n deps: ProcessDirectStreamingDeps,\n input: ProcessDirectStreamingInput,\n): AsyncGenerator<ProcessDirectStreamingSseEvent, void, unknown> {\n const sessionKey = input.sessionKey ?? 'agent:main:main';\n const { channel, chatId } = deps.parseSessionKey(sessionKey);\n const context = deps.initDirectStreamingSession(sessionKey, channel, chatId);\n\n const queue = new AsyncQueue<ProcessDirectStreamingSseEvent>();\n let reasoningLevel: ReasoningLevel = 'stream';\n\n const pushVisible = (event: ProcessDirectStreamingSseEvent) => {\n const visible = applyReasoningVisibilityToSseEvent(event, reasoningLevel);\n if (visible !== null) {\n queue.push(visible);\n }\n };\n\n const formatStreamError = (raw: string): string => {\n let provider: string | undefined;\n let modelRef: string | undefined;\n try {\n const resolved = deps.modelManager.getResolvedModelForSession(sessionKey);\n provider = resolved.provider;\n modelRef = deps.modelManager.getModelForSession(sessionKey);\n } catch {\n /* ignore — format without provider context */\n }\n return formatAgentRunErrorForClient(raw, { provider, modelRef });\n };\n\n if (channel === 'webchat') {\n deps.registerWebchatSsePublisher(sessionKey, pushVisible);\n }\n\n const signal = input.signal;\n let userAborted = false;\n let abortHandled = false;\n let inboundVoice = false;\n let ranSlashCommand = false;\n let mergedUserText = input.content;\n let webchatSlashReceipt: string | undefined;\n let slashCommandMetadata: Record<string, unknown> | undefined;\n\n const taskPromise = (async () => {\n try {\n const cfg = deps.getConfig();\n let turnBody = input.content;\n let resetTriggeredAtInit = false;\n if (cfg) {\n const turn = await initSessionTurn({\n cfg,\n sessionKey,\n body: input.content,\n resetSession: deps.resetSession,\n });\n resetTriggeredAtInit = turn.resetTriggered;\n if (turn.bareReset && turn.ackMessage) {\n ranSlashCommand = true;\n webchatSlashReceipt = turn.ackMessage;\n pushAssistantReceipt(queue, turn.ackMessage, input.runId);\n return;\n }\n turnBody = turn.bodyStripped;\n if (turn.isNewSession) {\n deps.log.debug(\n {\n sessionKey,\n sessionId: turn.sessionId,\n previousSessionId: turn.previousSessionId,\n resetTriggered: turn.resetTriggered,\n staleRollover: turn.staleRollover,\n },\n 'Session reset boundary at direct turn start',\n );\n }\n }\n\n await hydratePerTurnState(deps, sessionKey, input.thinking);\n {\n const defReason = (deps.getConfig()?.agents?.defaults?.reasoningDefault ?? 'stream') as ReasoningLevel;\n reasoningLevel = await resolveEffectiveReasoningLevel(deps.sessionConfigStore, sessionKey, defReason);\n }\n\n const prepared = await deps.prepareInboundAttachments(sessionKey, input.attachments);\n\n const sttCfg = mergeSttConfigFromAppConfig(deps.getConfig()?.tools?.media?.audio, deps.getConfig()?.tools?.media);\n const voiceMerge = await mergeVoiceTranscriptsIntoUserText(prepared, turnBody, sttCfg);\n mergedUserText = voiceMerge.text;\n inboundVoice = voiceMerge.inboundVoice;\n\n if (inboundVoice) {\n const transcriptParts = [\n voiceMerge.voiceTranscripts.filter(Boolean).join('\\n'),\n turnBody.trim(),\n ].filter(Boolean);\n const voiceMedia = (prepared ?? []).filter(isVoiceLikeAttachment).map((att) => ({\n uri: att.uri,\n mimeType: att.mimeType,\n name: att.name,\n }));\n pushVisible({\n type: 'user_transcript',\n text: transcriptParts.join('\\n\\n'),\n media: voiceMedia,\n });\n }\n\n const armAbort = () => {\n if (abortHandled) {\n return;\n }\n abortHandled = true;\n userAborted = true;\n void abortEmbeddedRun(sessionKey);\n queue.close();\n };\n if (signal) {\n if (signal.aborted) {\n armAbort();\n return;\n }\n signal.addEventListener('abort', armAbort, { once: true });\n }\n\n const slash = await tryRunSlashCommand(\n deps,\n {\n sessionKey,\n channel,\n chatId,\n senderId: context.senderId,\n isGroup: context.isGroup,\n inboundMetadata: context.metadata,\n },\n mergedUserText,\n { skipResetCommands: resetTriggeredAtInit },\n );\n if (slash.matched) {\n ranSlashCommand = true;\n slashCommandMetadata = slash.metadata;\n const text = slash.aggregatedText.trim();\n if (text) {\n webchatSlashReceipt = text;\n pushAssistantReceipt(queue, text, input.runId);\n } else if (channel === 'webchat') {\n webchatSlashReceipt =\n 'Command finished with no assistant text. If you used `/goal`, a follow-up turn may still be scheduled automatically.';\n pushAssistantReceipt(queue, webchatSlashReceipt, input.runId);\n }\n const workflowRun = slash.metadata?.workflowRun;\n if (workflowRun && typeof workflowRun === 'object') {\n queue.push({\n type: 'workflow_run_started',\n runId: input.runId,\n payload: { workflowRun },\n });\n }\n return;\n }\n\n const textForAgent = mergedUserText.trimStart().startsWith('/skill:')\n ? deps.agentManager.expandSkillUserText(mergedUserText)\n : mergedUserText;\n const userMessage = await deps.buildTranscriptUserMessage(textForAgent, prepared, sessionKey);\n let sourceEnrichedUserMessage: AgentMessage = userMessage;\n let sourceImages: ImageContent[] | undefined;\n if (deps.sourceContextResolver) {\n const metadata = await deps.sessionStore.getMetadata(sessionKey).catch(() => null);\n const sourceBinding = metadata?.customData && typeof metadata.customData === 'object'\n ? (metadata.customData as Record<string, unknown>).sourceBinding\n : undefined;\n if (isSessionSourceBinding(sourceBinding)) {\n const sourceContext = await deps.sourceContextResolver(sourceBinding, sessionKey);\n sourceEnrichedUserMessage = injectSourceContextIntoUserMessage(userMessage, sourceContext);\n sourceImages = sourceContext?.images;\n }\n }\n\n if (channel === 'webchat') {\n pushVisible({\n type: 'user_message',\n timestamp: userMessage.timestamp ?? Date.now(),\n content: readAgentMessageContent(userMessage),\n media: userMessage.media,\n });\n if (textForAgent.trim()) {\n deps.enqueueProvisionalSessionTitle?.(sessionKey, textForAgent);\n }\n }\n\n const pendingUserMessage = userMessage as TranscriptUserMessage;\n setPendingTranscriptUserMessage(sessionKey, pendingUserMessage);\n\n try {\n const result = await runDirectAgentTurn(\n {\n sessionStore: deps.sessionStore,\n agentManager: deps.agentManager,\n modelManager: deps.modelManager,\n config: deps.getConfig(),\n },\n {\n sessionKey,\n userMessage: sourceEnrichedUserMessage,\n abortSignal: signal,\n sourceImages,\n runId: input.runId,\n onEvent: (embeddedEvent) => {\n const event = { ...embeddedEvent };\n if (event.type === 'error' && typeof event.content === 'string') {\n event.content = formatStreamError(event.content);\n }\n pushVisible(event);\n },\n },\n );\n\n if (result.lastAssistantText) {\n deps.onTurnComplete?.(sessionKey, result.lastAssistantText);\n }\n if (!result.ok && result.errorMessage && !abortHandled) {\n pushVisible({ type: 'error', content: formatStreamError(result.errorMessage) });\n }\n } finally {\n clearPendingTranscriptUserMessage(sessionKey, pendingUserMessage);\n }\n } catch (err) {\n if (!abortHandled) {\n const em = err instanceof Error ? err.message : String(err);\n pushVisible({ type: 'error', content: formatStreamError(em) });\n }\n } finally {\n if (!userAborted && channel === 'webchat') {\n try {\n const ttsAudioEvent = await deps.maybeEmitWebchatTts(sessionKey, inboundVoice);\n if (ttsAudioEvent) {\n queue.push(ttsAudioEvent);\n }\n } catch (ttsErr) {\n deps.log.warn({ err: ttsErr, sessionKey }, 'Failed to emit TTS audio before stream close');\n }\n }\n queue.close();\n }\n })();\n\n try {\n for await (const event of queue) {\n yield event;\n }\n await taskPromise;\n\n if (channel === 'webchat' && ranSlashCommand) {\n try {\n const userMsg = {\n role: 'user' as const,\n content: [{ type: 'text' as const, text: mergedUserText }],\n timestamp: Date.now(),\n } as AgentMessage;\n await deps.sessionStore.appendTranscriptMessage(sessionKey, userMsg);\n if (webchatSlashReceipt?.trim()) {\n const assistantMsg = {\n role: 'assistant' as const,\n content: [{ type: 'text' as const, text: webchatSlashReceipt.trim() }],\n timestamp: Date.now(),\n ...(slashCommandMetadata && Object.keys(slashCommandMetadata).length > 0\n ? { metadata: slashCommandMetadata }\n : {}),\n } as AgentMessage;\n await deps.sessionStore.appendTranscriptMessage(sessionKey, assistantMsg);\n }\n deps.reloadWebchatTranscript?.(sessionKey);\n } catch (err) {\n deps.log.warn({ err, sessionKey }, 'Failed to persist webchat slash command receipt');\n }\n }\n\n deps.recordPersistentGoalStreamOutcome?.(sessionKey, { skipPersistentGoalPostTurn: ranSlashCommand });\n } finally {\n if (channel === 'webchat') {\n deps.unregisterWebchatSsePublisher(sessionKey);\n }\n deps.endDirectRequestContext();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA2GA,SAAS,4BAA4B,MAA4B;AAC/D,QAAO;EACL,MAAM;EACN,SAAS,CAAC;GAAE,MAAM;GAAQ;GAAM,CAAC;EACjC,WAAW,KAAK,KAAK;EACtB;;AAGH,SAAS,qBACP,OACA,MACA,OACM;CACN,MAAM,UAAU,4BAA4B,KAAK;AACjD,OAAM,KAAK;EAAE,MAAM;EAAiB;EAAO;EAAS,CAAC;AACrD,OAAM,KAAK;EAAE,MAAM;EAAkB;EAAO;EAAS,CAAC;AACtD,OAAM,KAAK;EAAE,MAAM;EAAe;EAAO;EAAS,CAAC;;AAGrD,gBAAuB,0BACrB,MACA,OAC+D;CAC/D,MAAM,aAAa,MAAM,cAAc;CACvC,MAAM,EAAE,SAAS,WAAW,KAAK,gBAAgB,WAAW;CAC5D,MAAM,UAAU,KAAK,2BAA2B,YAAY,SAAS,OAAO;CAE5E,MAAM,QAAQ,IAAI,YAA4C;CAC9D,IAAI,iBAAiC;CAErC,MAAM,eAAe,UAA0C;EAC7D,MAAM,UAAU,mCAAmC,OAAO,eAAe;AACzE,MAAI,YAAY,KACd,OAAM,KAAK,QAAQ;;CAIvB,MAAM,qBAAqB,QAAwB;EACjD,IAAI;EACJ,IAAI;AACJ,MAAI;AAEF,cADiB,KAAK,aAAa,2BAA2B,WAC3C,CAAC;AACpB,cAAW,KAAK,aAAa,mBAAmB,WAAW;UACrD;AAGR,SAAO,6BAA6B,KAAK;GAAE;GAAU;GA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IAAE,CAAC;YAExD;AACR,OAAI,CAAC,eAAe,YAAY,UAC9B,KAAI;IACF,MAAM,gBAAgB,MAAM,KAAK,oBAAoB,YAAY,aAAa;AAC9E,QAAI,cACF,OAAM,KAAK,cAAc;YAEpB,QAAQ;AACf,SAAK,IAAI,KAAK;KAAE,KAAK;KAAQ;KAAY,EAAE,+CAA+C;;AAG9F,SAAM,OAAO;;KAEb;AAEJ,KAAI;AACF,aAAW,MAAM,SAAS,MACxB,OAAM;AAER,QAAM;AAEN,MAAI,YAAY,aAAa,gBAC3B,KAAI;GACF,MAAM,UAAU;IACd,MAAM;IACN,SAAS,CAAC;KAAE,MAAM;KAAiB,MAAM;KAAgB,CAAC;IAC1D,WAAW,KAAK,KAAK;IACtB;AACD,SAAM,KAAK,aAAa,wBAAwB,YAAY,QAAQ;AACpE,OAAI,qBAAqB,MAAM,EAAE;IAC/B,MAAM,eAAe;KACnB,MAAM;KACN,SAAS,CAAC;MAAE,MAAM;MAAiB,MAAM,oBAAoB,MAAM;MAAE,CAAC;KACtE,WAAW,KAAK,KAAK;KACrB,GAAI,wBAAwB,OAAO,KAAK,qBAAqB,CAAC,SAAS,IACnE,EAAE,UAAU,sBAAsB,GAClC,EAAE;KACP;AACD,UAAM,KAAK,aAAa,wBAAwB,YAAY,aAAa;;AAE3E,QAAK,0BAA0B,WAAW;WACnC,KAAK;AACZ,QAAK,IAAI,KAAK;IAAE;IAAK;IAAY,EAAE,kDAAkD;;AAIzF,OAAK,oCAAoC,YAAY,EAAE,4BAA4B,iBAAiB,CAAC;WAC7F;AACR,MAAI,YAAY,UACd,MAAK,8BAA8B,WAAW;AAEhD,OAAK,yBAAyB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger/index.js";
|
|
2
2
|
import { init_logger } from "../utils/logger.js";
|
|
3
3
|
import { getApiKey, getDefaultModelSync, init_providers, resolveModel } from "../providers/index.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getAssistantMessageErrorReason, stripCodeFences } from "../agent/goals/judge.js";
|
|
5
5
|
import { createExtensionAwareStreamFn } from "../providers/extension-stream-bridge.js";
|
|
6
6
|
//#region src/ai-assist/text-assist.ts
|
|
7
7
|
init_providers();
|
|
@@ -68,6 +68,16 @@ const SCENARIOS = {
|
|
|
68
68
|
function sanitizeOutput(text, max) {
|
|
69
69
|
return stripCodeFences(text).slice(0, max);
|
|
70
70
|
}
|
|
71
|
+
function extractAssistantVisibleText(content) {
|
|
72
|
+
if (!Array.isArray(content)) return "";
|
|
73
|
+
let textParts = "";
|
|
74
|
+
for (const block of content) {
|
|
75
|
+
if (!block || typeof block !== "object") continue;
|
|
76
|
+
const typed = block;
|
|
77
|
+
if (typed.type === "text" && typeof typed.text === "string") textParts += typed.text;
|
|
78
|
+
}
|
|
79
|
+
return textParts;
|
|
80
|
+
}
|
|
71
81
|
function stringifyContext(context, maxContextChars, maxContextValueChars) {
|
|
72
82
|
if (!context) return "";
|
|
73
83
|
const safe = {};
|
|
@@ -194,23 +204,31 @@ async function* streamTextAssist(request, config, signal) {
|
|
|
194
204
|
});
|
|
195
205
|
let streamedText = "";
|
|
196
206
|
for await (const event of stream) {
|
|
197
|
-
|
|
198
|
-
|
|
207
|
+
const streamEvent = event;
|
|
208
|
+
if (streamEvent.type === "text_delta" && typeof streamEvent.delta === "string") {
|
|
209
|
+
streamedText += streamEvent.delta;
|
|
199
210
|
yield {
|
|
200
211
|
type: "text_delta",
|
|
201
|
-
delta:
|
|
212
|
+
delta: streamEvent.delta
|
|
213
|
+
};
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
if (streamEvent.type === "thinking_delta") {
|
|
217
|
+
if (typeof streamEvent.delta === "string" && streamEvent.delta) yield {
|
|
218
|
+
type: "thinking_delta",
|
|
219
|
+
delta: streamEvent.delta
|
|
202
220
|
};
|
|
203
221
|
continue;
|
|
204
222
|
}
|
|
205
|
-
if (
|
|
206
|
-
const errorMessage =
|
|
223
|
+
if (streamEvent.type === "error") {
|
|
224
|
+
const errorMessage = streamEvent.error?.errorMessage || getAssistantMessageErrorReason(streamEvent.error) || "AI text assist failed";
|
|
207
225
|
throw new Error(errorMessage);
|
|
208
226
|
}
|
|
209
227
|
}
|
|
210
228
|
const response = await stream.result();
|
|
211
229
|
const errorReason = getAssistantMessageErrorReason(response);
|
|
212
230
|
if (errorReason) throw new Error(errorReason);
|
|
213
|
-
const text = sanitizeOutput(streamedText ||
|
|
231
|
+
const text = sanitizeOutput(streamedText || extractAssistantVisibleText(response.content), scenario.maxOutputChars ?? MAX_OUTPUT_CHARS);
|
|
214
232
|
if (!text) {
|
|
215
233
|
logEmptyOutput(request, scenario, response);
|
|
216
234
|
throw new Error("AI returned an empty suggestion");
|