@capagents/forgeqe 3.4.6 → 3.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/forgeqe.js +2106 -1967
  2. package/dist/web/assets/{Agent-D_W8YJWv.js → Agent-5Q96YSvr.js} +1 -1
  3. package/dist/web/assets/{AgentWork-CPYvG2HI.js → AgentWork-BWjyDUEc.js} +1 -1
  4. package/dist/web/assets/{ApiTests-CElarw4P.js → ApiTests-D493px70.js} +1 -1
  5. package/dist/web/assets/{Chat-CJsKzudh.js → Chat-CzEPSJKG.js} +1 -1
  6. package/dist/web/assets/{Compare-DlSaG3td.js → Compare-BYFsbaGF.js} +1 -1
  7. package/dist/web/assets/{Compare-DBNzy6Hm.js → Compare-sqYji9Pk.js} +1 -1
  8. package/dist/web/assets/{Cost-DsERWen5.js → Cost-CWWczZfn.js} +1 -1
  9. package/dist/web/assets/{Data-BSemg5Ky.js → Data-BNcT6ygh.js} +1 -1
  10. package/dist/web/assets/{Desktop-BcXzby1F.js → Desktop-CG9lFU5l.js} +1 -1
  11. package/dist/web/assets/{DesktopReview-CDv_Swu0.js → DesktopReview-Cd-oH_U5.js} +1 -1
  12. package/dist/web/assets/{Evidence-BYQvjtqD.js → Evidence-DPF6gCpK.js} +1 -1
  13. package/dist/web/assets/{Explore-GAaQCWbY.js → Explore-CIrFwA2S.js} +1 -1
  14. package/dist/web/assets/{Features-BoFooP6n.js → Features-DzK_-8h1.js} +1 -1
  15. package/dist/web/assets/{FileTree-a0-UuNhM.js → FileTree-CNGOe2xf.js} +1 -1
  16. package/dist/web/assets/{Flags-B9BwmpT9.js → Flags-C69Twz3o.js} +1 -1
  17. package/dist/web/assets/{Flaky-NIz-XNcl.js → Flaky-CNPjhYIZ.js} +1 -1
  18. package/dist/web/assets/{Impact-D-2WTh3g.js → Impact-Dc1w1OJz.js} +1 -1
  19. package/dist/web/assets/{Jobs-BtLMd2Pe.js → Jobs-hS20eWew.js} +1 -1
  20. package/dist/web/assets/{KindPage-YFqKZMNZ.js → KindPage-Dwn1bRlI.js} +1 -1
  21. package/dist/web/assets/{LiveDevice-BDmDTtX_.js → LiveDevice-CAqR5xdi.js} +1 -1
  22. package/dist/web/assets/{Migration-Bs1Qc0Yg.js → Migration-B8Cde1ef.js} +1 -1
  23. package/dist/web/assets/{Mobile-zXRXR_3S.js → Mobile-D3Pch-1L.js} +1 -1
  24. package/dist/web/assets/{Observability-qNxOzrmI.js → Observability-QUxLZNhO.js} +1 -1
  25. package/dist/web/assets/{OwnItems-CO-zBy4W.js → OwnItems-Cw923K1y.js} +1 -1
  26. package/dist/web/assets/{PageAgent-C0u0uyou.js → PageAgent-xDYi2Zgw.js} +1 -1
  27. package/dist/web/assets/{Product-5nybx8oL.js → Product-CVn9yHyn.js} +1 -1
  28. package/dist/web/assets/{Production-C2FVz9Df.js → Production-BNg-ims6.js} +1 -1
  29. package/dist/web/assets/{Quality-CwlN84zJ.js → Quality-BzcQTBgO.js} +1 -1
  30. package/dist/web/assets/{Readiness-gzFYSc8y.js → Readiness-Bx5JZpXY.js} +1 -1
  31. package/dist/web/assets/Record-CM_ZJv5n.js +1 -0
  32. package/dist/web/assets/{Regression-DuP8VGvl.js → Regression-DSGl56Mr.js} +1 -1
  33. package/dist/web/assets/{Reports-Bk5A2rMW.js → Reports-CBanmypE.js} +1 -1
  34. package/dist/web/assets/{Requirements-BnOO72Q7.js → Requirements-D-FLXDK0.js} +1 -1
  35. package/dist/web/assets/{Responsive-9eqRKydd.js → Responsive-DLU7BLkW.js} +1 -1
  36. package/dist/web/assets/{RunDiff-DAiOiWdE.js → RunDiff-D2IKjRcf.js} +1 -1
  37. package/dist/web/assets/{Settings-jkOoqeEY.js → Settings-Bi99A4lM.js} +3 -3
  38. package/dist/web/assets/{SiteScan-BVI8Z-cC.js → SiteScan-CKc7eUOn.js} +1 -1
  39. package/dist/web/assets/{Steps-CZxAX4yk.js → Steps-DvTL0-9L.js} +1 -1
  40. package/dist/web/assets/{TestData-CyqXcyZv.js → TestData-Bo0i6j6h.js} +1 -1
  41. package/dist/web/assets/{TestManagement-UKBq1Jcj.js → TestManagement-a1zMxdc6.js} +1 -1
  42. package/dist/web/assets/{WhatsNew-BnWCLSSu.js → WhatsNew-OtotufjV.js} +1 -1
  43. package/dist/web/assets/{agentSettingsSheet-Bca1rnig.js → agentSettingsSheet-DJDT3xqY.js} +1 -1
  44. package/dist/web/assets/{dataParts-DD4VTinq.js → dataParts-DCcZLVns.js} +1 -1
  45. package/dist/web/assets/{index-DZMkBMxL.js → index-B58JrUzp.js} +3 -3
  46. package/dist/web/assets/{productParts-Cjy7N4bQ.js → productParts-BTy_xRc1.js} +1 -1
  47. package/dist/web/assets/{qualityParts-Bnl_yBH6.js → qualityParts-CaibRb_n.js} +1 -1
  48. package/dist/web/index.html +1 -1
  49. package/package.json +1 -1
  50. package/py/forgeqe_engine/capture.py +80 -2
  51. package/py/forgeqe_engine/d365.py +117 -11
  52. package/py/forgeqe_engine/memory.py +91 -25
  53. package/py/forgeqe_engine/recordsession.py +9 -1
  54. package/py/forgeqe_engine/webrecord_page.py +87 -4
  55. package/dist/web/assets/Record-DeucQwHe.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{t as r}from"./utils-DJRAScIl.js";import{t as i}from"./jsx-runtime-LKYXHABd.js";import{I as a}from"./palette-BEo5X3wD.js";import{v as o}from"./api-BJHzfOse.js";import{C as s,F as c,I as l,T as u,_ as d,g as f,k as p,n as m,y as h}from"./pageBack-BKHdI-pD.js";import{$ as g,Er as _,Rn as v,Tr as y,Ut as b,Wr as x,Xn as S,Zt as C,mr as w,o as T}from"./line-icons-Cwj9OmCz.js";import{u as E}from"./nav-DS7OIItb.js";import{Ft as D,G as O,J as k,L as A,U as j,W as M,Xt as N,cn as P,pn as F,xt as I,yt as L,zt as R}from"./index-DZMkBMxL.js";import{d as z}from"./qualityParts-Bnl_yBH6.js";var B=e(t(),1),V={view:e=>o(`GET`,`/api/observability?days=${e}`)},H=i(),U=12,W=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),G=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function K({series:e}){let[t,n]=(0,B.useState)(-1),r=e.reduce((e,t)=>e+t.sessions,0),i=e.reduce((e,t)=>e+t.problems,0),a=e.reduce((e,t)=>t.sessions>e.sessions?t:e,e[0]),o=t>=0?e[t]:e[e.length-1];return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`p`,{"aria-live":`polite`,className:`m-0 text-body-sm text-ink-2`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:W(o.day)}),`: `,G(o.sessions,`session`),o.problems?`, ${o.problems} with an error`:``]}),(0,H.jsx)(d,{series:[{values:e.map(e=>e.sessions)}],label:`Sessions a day for the last ${e.length} days: ${r} in all, ${i} with an error; the busiest was ${W(a.day)} with ${a.sessions}.`,hover:t,onHover:n,className:`h-[160px]`,axis:[W(e[0].day),W(e[e.length-1].day)]})]})}function q({rows:e,label:t,empty:n,unit:r,failedWord:i=`failed`}){if(!e.length)return(0,H.jsx)(P,{className:`py-4`,children:n});let a=Math.max(1,e.reduce((e,t)=>e+t.value,0));return(0,H.jsx)(h,{label:t,rows:e.slice(0,U).map(e=>({key:e.key,label:e.label,value:e.value.toLocaleString(),sub:G(e.value,r).replace(/^[\d,.]+\s*/,``),share:e.value/a,note:e.failed?(0,H.jsxs)(`span`,{className:`text-label-sm whitespace-nowrap text-fail tabular-nums`,children:[e.failed,` `,i]}):void 0})),more:e.length>U?`and ${e.length-U} more`:void 0})}var J={passed:`pass`,failed:`fail`,error:`fail`};function Y({runs:e}){let t=e.reduce((e,t)=>e+t.count,0);if(!t)return(0,H.jsx)(P,{className:`py-4`,children:`No browser run ended in these days.`});let n=e=>J[e]??`neutral`,r={pass:`bg-pass`,fail:`bg-fail`,neutral:`bg-muted`};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(s,{label:`Runs by how they ended: ${e.map(e=>`${e.status} ${e.count}`).join(`, `)}, of ${t}.`,parts:e.map(e=>({key:e.status,value:e.count,className:r[n(e.status)]}))}),(0,H.jsx)(`span`,{className:`flex flex-wrap gap-2 text-body-sm`,children:e.map(e=>(0,H.jsxs)(p,{tone:n(e.status),children:[e.status[0].toUpperCase()+e.status.slice(1),` `,e.count]},e.status))})]})}var X=[{id:`7`,label:`Last 7 days`},{id:`30`,label:`Last 30 days`},{id:`90`,label:`Last 90 days`}],Z=e=>e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(1)} s`:`${Math.round(e/6e4)} min`,Q=(e,t)=>t?`${Math.round(e/t*100)}%`:`–`;function $({id:e,icon:t,title:n,children:r,note:i,divider:a}){return(0,H.jsx)(N,{id:e,icon:t,title:n,description:i,divider:a,children:r})}function ee(){let[e,t]=(0,B.useState)(30),[i,o]=(0,B.useState)(null),[s,d]=(0,B.useState)(``),h=(0,B.useCallback)(()=>{d(``),V.view(e).then(o,e=>d(e.message))},[e]);(0,B.useEffect)(h,[h]);let N=i&&i.days===e?i:null,U=N?.totals,W=N?[N.source.skipped?`${N.source.skipped} log file${N.source.skipped===1?` was`:`s were`} skipped: a link, or not inside the logs folder.`:``,N.source.truncated?`${N.source.truncated} very long log${N.source.truncated===1?` was`:`s were`} read only in part.`:``,N.source.ledger?``:`Model calls are counted once this project has a forgeqe.yaml: the usage ledger keeps calls by project.`].filter(Boolean):[];return(0,H.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,H.jsx)(k,{}),(0,H.jsxs)(`main`,{className:r(A,`@container flex-auto gap-4`),children:[(0,H.jsx)(m,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,H.jsx)(F,{pixel:a.observability,size:`lg`,head:!0}),(0,H.jsx)(`h1`,{className:`m-0 text-headline-md`,children:E(`observability`)})]}),(0,H.jsx)(O,{more:(0,H.jsxs)(H.Fragment,{children:[`Read from ForgeQE's session logs`,N?(0,H.jsxs)(H.Fragment,{children:[` `,`in `,(0,H.jsx)(`code`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:N.source.logs})]}):``,` `,`and this project's model calls. These are the numbers the OpenTelemetry export sends, counted here whether it is on or not: send them to your own collector in`,` `,(0,H.jsx)(`a`,{href:n(`settings`,`observability`),children:`Settings › Observability`}),`. Each session is in the day it started.`]}),children:`See how ForgeQE's own chats, runs and tools went on this computer.`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,H.jsx)(u,{items:X,value:`${e}`,onChange:e=>t(Number(e))})}),s&&(0,H.jsx)(`p`,{role:`alert`,className:r(l.fail,`m-0`),children:s}),!N&&!s&&(0,H.jsx)(f,{shape:`detail`}),N&&U&&!U.sessions&&!U.modelCalls&&(0,H.jsx)(P,{page:!0,icon:b,title:`No sessions in the last ${e} days`,action:(0,H.jsxs)(`a`,{className:c({size:`sm`}),href:n(`runs`),"data-tip":`Open Runs`,children:[(0,H.jsx)(T,{"aria-hidden":`true`}),`Runs`]}),children:(0,H.jsx)(`span`,{className:`text-ink-2`,children:`Every ForgeQE chat, run and suite writes a session log. Start one, and how it went shows here.`})}),N&&U&&(U.sessions>0||U.modelCalls>0)&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(j,{label:`ForgeQE's work in these days`,children:[(0,H.jsx)(M,{tip:`${N.from} to ${N.to}`,dot:`neutral`,value:U.sessions,label:U.sessions===1?`session`:`sessions`}),(0,H.jsx)(M,{tip:U.sessions?`${Q(U.problemSessions,U.sessions)} of sessions`:void 0,dot:U.problemSessions?`fail`:`pass`,value:U.problemSessions,label:`with an error`}),(0,H.jsx)(M,{dot:U.turnsFailed?`fail`:`pass`,value:U.turnsFailed,label:`failed of ${U.turns} turn${U.turns===1?``:`s`}`}),(0,H.jsx)(M,{dot:U.runsFailed?`fail`:`pass`,value:U.runsFailed,label:`failed of ${U.runs} browser run${U.runs===1?``:`s`}`}),(0,H.jsx)(M,{tip:Q(U.toolErrors,U.toolCalls),dot:U.toolErrors?`warn`:`pass`,value:U.toolErrors,label:`tool errors of ${U.toolCalls} call${U.toolCalls===1?``:`s`}`}),(0,H.jsx)(M,{tip:`${I(U.tokens)} tokens`,dot:`neutral`,value:U.modelCalls,label:`model calls`})]}),W.length>0&&(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm text-ink-2`,children:W.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(C,{size:14,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),e]},e))}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,H.jsx)($,{id:`obs-days`,icon:y,title:`Sessions over time`,note:N.turnTime?`A turn took ${Z(N.turnTime.p50)} at the median, ${Z(N.turnTime.p95)} at the 95th percentile.`:void 0,children:(0,H.jsx)(K,{series:N.series})}),(0,H.jsxs)(`div`,{className:`grid gap-x-6 gap-y-8 pt-6 @3xl:grid-cols-2`,children:[(0,H.jsx)($,{id:`obs-commands`,icon:w,title:`By command`,divider:!1,children:(0,H.jsx)(q,{rows:N.commands.map(e=>({key:e.command,label:`forgeqe ${e.command}`,value:e.sessions,failed:e.problems})),label:`Sessions by command`,empty:`No session in these days.`,unit:`session`,failedWord:`with an error`})}),(0,H.jsx)($,{id:`obs-runs`,icon:v,title:`Browser runs`,divider:!1,children:(0,H.jsx)(Y,{runs:N.runs})}),(0,H.jsx)($,{id:`obs-tools`,icon:x,title:`Tool calls`,divider:!1,children:(0,H.jsx)(q,{rows:N.tools.map(e=>({key:e.tool,label:e.tool===`system_tool`?`Other systems' tools`:e.tool,value:e.calls,failed:e.errors})),label:`Tool calls by tool`,empty:`No tool call in these days.`,unit:`call`})}),(0,H.jsx)($,{id:`obs-health`,icon:b,title:`Session health`,divider:!1,note:`The ways a chat has gone wrong before, found by their signature in the logs.`,children:(0,H.jsx)(q,{rows:N.health.map(e=>({key:e.kind,label:e.text,value:e.count})),label:`Session health findings`,empty:`No known kind of trouble in these days.`,unit:`time`})})]}),(0,H.jsx)($,{id:`obs-models`,icon:g,title:`Model calls`,children:(0,H.jsx)(R,{label:`Model calls by model`,placeholder:`Find a model`,resetKey:e,empty:N.source.ledger?`No model call in these days.`:`Model calls are counted once this project has a forgeqe.yaml.`,search:N.models.length>8,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[34%]`),children:`Model`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Calls`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Tokens`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Median`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`95th percentile`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Cost`})]}),children:N.models.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`max-w-0`),children:(0,H.jsx)(`span`,{"data-tip":e.model,className:`block truncate font-mono text-body-sm`,children:e.model})}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:e.calls}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-tip":`${I(e.input)} read, ${I(e.output)} written`,"data-sort":e.input+e.output,children:I(e.input+e.output)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @xl:table-cell`),"data-sort":e.p50??-1,children:e.p50===null?`–`:Z(e.p50)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @xl:table-cell`),"data-sort":e.p95??-1,children:e.p95===null?`–`:Z(e.p95)}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.amount??-1,children:e.amount!==void 0&&e.currency?L(e.amount,e.currency):(0,H.jsx)(`span`,{className:`text-muted`,children:`–`})})]},e.model))})}),(0,H.jsx)($,{id:`obs-problems`,icon:_,title:`Latest problems`,note:`Errors and warnings, as the export sends them as log records: in ForgeQE's words, never what the model, the page or a person wrote.`,children:(0,H.jsx)(R,{label:`Latest problems`,placeholder:`Find a problem or session`,resetKey:e,empty:`No problem in these days.`,search:N.problems.length>8,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Problem`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`When`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Session`})]}),children:N.problems.map((e,t)=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`td`,{className:`px-4 py-2`,children:(0,H.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(p,{tone:e.severity===`error`?`fail`:`warn`,children:e.severity===`error`?`Error`:`Warning`}),(0,H.jsx)(`span`,{children:e.text}),e.detail&&(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.detail})]})}),(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`whitespace-nowrap text-muted`),"data-tip":z(e.at),"data-sort":new Date(e.at).getTime()||0,children:D(e.at)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`hidden max-w-[220px] @xl:table-cell`),children:(0,H.jsx)(`a`,{href:n(`runs`,encodeURIComponent(e.session)),"data-tip":`Open this session in Runs`,className:`block truncate font-mono text-body-sm`,children:e.session.replace(/\.log$/,``)})})]},`${e.session}-${e.at}-${t}`))})})]}),(0,H.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-body-sm text-muted`,children:[(0,H.jsx)(S,{size:14,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[N.source.read,` session log`,N.source.read===1?``:`s`,` read. `,(0,H.jsx)(`a`,{href:n(`settings`,`observability`),children:`Send these to your collector`}),`.`]})]})]})]})]})}export{ee as Observability};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{t as r}from"./utils-DJRAScIl.js";import{t as i}from"./jsx-runtime-LKYXHABd.js";import{I as a}from"./palette-BEo5X3wD.js";import{v as o}from"./api-BJHzfOse.js";import{C as s,F as c,I as l,T as u,_ as d,g as f,k as p,n as m,y as h}from"./pageBack-BKHdI-pD.js";import{$ as g,Er as _,Rn as v,Tr as y,Ut as b,Wr as x,Xn as S,Zt as C,mr as w,o as T}from"./line-icons-Cwj9OmCz.js";import{u as E}from"./nav-DS7OIItb.js";import{Ft as D,G as O,J as k,L as A,U as j,W as M,Xt as N,cn as P,pn as F,xt as I,yt as L,zt as R}from"./index-B58JrUzp.js";import{d as z}from"./qualityParts-CaibRb_n.js";var B=e(t(),1),V={view:e=>o(`GET`,`/api/observability?days=${e}`)},H=i(),U=12,W=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),G=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`;function K({series:e}){let[t,n]=(0,B.useState)(-1),r=e.reduce((e,t)=>e+t.sessions,0),i=e.reduce((e,t)=>e+t.problems,0),a=e.reduce((e,t)=>t.sessions>e.sessions?t:e,e[0]),o=t>=0?e[t]:e[e.length-1];return(0,H.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,H.jsxs)(`p`,{"aria-live":`polite`,className:`m-0 text-body-sm text-ink-2`,children:[(0,H.jsx)(`span`,{className:`font-medium`,children:W(o.day)}),`: `,G(o.sessions,`session`),o.problems?`, ${o.problems} with an error`:``]}),(0,H.jsx)(d,{series:[{values:e.map(e=>e.sessions)}],label:`Sessions a day for the last ${e.length} days: ${r} in all, ${i} with an error; the busiest was ${W(a.day)} with ${a.sessions}.`,hover:t,onHover:n,className:`h-[160px]`,axis:[W(e[0].day),W(e[e.length-1].day)]})]})}function q({rows:e,label:t,empty:n,unit:r,failedWord:i=`failed`}){if(!e.length)return(0,H.jsx)(P,{className:`py-4`,children:n});let a=Math.max(1,e.reduce((e,t)=>e+t.value,0));return(0,H.jsx)(h,{label:t,rows:e.slice(0,U).map(e=>({key:e.key,label:e.label,value:e.value.toLocaleString(),sub:G(e.value,r).replace(/^[\d,.]+\s*/,``),share:e.value/a,note:e.failed?(0,H.jsxs)(`span`,{className:`text-label-sm whitespace-nowrap text-fail tabular-nums`,children:[e.failed,` `,i]}):void 0})),more:e.length>U?`and ${e.length-U} more`:void 0})}var J={passed:`pass`,failed:`fail`,error:`fail`};function Y({runs:e}){let t=e.reduce((e,t)=>e+t.count,0);if(!t)return(0,H.jsx)(P,{className:`py-4`,children:`No browser run ended in these days.`});let n=e=>J[e]??`neutral`,r={pass:`bg-pass`,fail:`bg-fail`,neutral:`bg-muted`};return(0,H.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,H.jsx)(s,{label:`Runs by how they ended: ${e.map(e=>`${e.status} ${e.count}`).join(`, `)}, of ${t}.`,parts:e.map(e=>({key:e.status,value:e.count,className:r[n(e.status)]}))}),(0,H.jsx)(`span`,{className:`flex flex-wrap gap-2 text-body-sm`,children:e.map(e=>(0,H.jsxs)(p,{tone:n(e.status),children:[e.status[0].toUpperCase()+e.status.slice(1),` `,e.count]},e.status))})]})}var X=[{id:`7`,label:`Last 7 days`},{id:`30`,label:`Last 30 days`},{id:`90`,label:`Last 90 days`}],Z=e=>e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(1)} s`:`${Math.round(e/6e4)} min`,Q=(e,t)=>t?`${Math.round(e/t*100)}%`:`–`;function $({id:e,icon:t,title:n,children:r,note:i,divider:a}){return(0,H.jsx)(N,{id:e,icon:t,title:n,description:i,divider:a,children:r})}function ee(){let[e,t]=(0,B.useState)(30),[i,o]=(0,B.useState)(null),[s,d]=(0,B.useState)(``),h=(0,B.useCallback)(()=>{d(``),V.view(e).then(o,e=>d(e.message))},[e]);(0,B.useEffect)(h,[h]);let N=i&&i.days===e?i:null,U=N?.totals,W=N?[N.source.skipped?`${N.source.skipped} log file${N.source.skipped===1?` was`:`s were`} skipped: a link, or not inside the logs folder.`:``,N.source.truncated?`${N.source.truncated} very long log${N.source.truncated===1?` was`:`s were`} read only in part.`:``,N.source.ledger?``:`Model calls are counted once this project has a forgeqe.yaml: the usage ledger keeps calls by project.`].filter(Boolean):[];return(0,H.jsxs)(`div`,{className:`flex min-h-(--screen) flex-col`,children:[(0,H.jsx)(k,{}),(0,H.jsxs)(`main`,{className:r(A,`@container flex-auto gap-4`),children:[(0,H.jsx)(m,{}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,H.jsx)(F,{pixel:a.observability,size:`lg`,head:!0}),(0,H.jsx)(`h1`,{className:`m-0 text-headline-md`,children:E(`observability`)})]}),(0,H.jsx)(O,{more:(0,H.jsxs)(H.Fragment,{children:[`Read from ForgeQE's session logs`,N?(0,H.jsxs)(H.Fragment,{children:[` `,`in `,(0,H.jsx)(`code`,{className:`font-mono text-body-sm [overflow-wrap:anywhere]`,children:N.source.logs})]}):``,` `,`and this project's model calls. These are the numbers the OpenTelemetry export sends, counted here whether it is on or not: send them to your own collector in`,` `,(0,H.jsx)(`a`,{href:n(`settings`,`observability`),children:`Settings › Observability`}),`. Each session is in the day it started.`]}),children:`See how ForgeQE's own chats, runs and tools went on this computer.`}),(0,H.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,H.jsx)(u,{items:X,value:`${e}`,onChange:e=>t(Number(e))})}),s&&(0,H.jsx)(`p`,{role:`alert`,className:r(l.fail,`m-0`),children:s}),!N&&!s&&(0,H.jsx)(f,{shape:`detail`}),N&&U&&!U.sessions&&!U.modelCalls&&(0,H.jsx)(P,{page:!0,icon:b,title:`No sessions in the last ${e} days`,action:(0,H.jsxs)(`a`,{className:c({size:`sm`}),href:n(`runs`),"data-tip":`Open Runs`,children:[(0,H.jsx)(T,{"aria-hidden":`true`}),`Runs`]}),children:(0,H.jsx)(`span`,{className:`text-ink-2`,children:`Every ForgeQE chat, run and suite writes a session log. Start one, and how it went shows here.`})}),N&&U&&(U.sessions>0||U.modelCalls>0)&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(j,{label:`ForgeQE's work in these days`,children:[(0,H.jsx)(M,{tip:`${N.from} to ${N.to}`,dot:`neutral`,value:U.sessions,label:U.sessions===1?`session`:`sessions`}),(0,H.jsx)(M,{tip:U.sessions?`${Q(U.problemSessions,U.sessions)} of sessions`:void 0,dot:U.problemSessions?`fail`:`pass`,value:U.problemSessions,label:`with an error`}),(0,H.jsx)(M,{dot:U.turnsFailed?`fail`:`pass`,value:U.turnsFailed,label:`failed of ${U.turns} turn${U.turns===1?``:`s`}`}),(0,H.jsx)(M,{dot:U.runsFailed?`fail`:`pass`,value:U.runsFailed,label:`failed of ${U.runs} browser run${U.runs===1?``:`s`}`}),(0,H.jsx)(M,{tip:Q(U.toolErrors,U.toolCalls),dot:U.toolErrors?`warn`:`pass`,value:U.toolErrors,label:`tool errors of ${U.toolCalls} call${U.toolCalls===1?``:`s`}`}),(0,H.jsx)(M,{tip:`${I(U.tokens)} tokens`,dot:`neutral`,value:U.modelCalls,label:`model calls`})]}),W.length>0&&(0,H.jsx)(`ul`,{className:`m-0 flex list-none flex-col gap-1 p-0 text-body-sm text-ink-2`,children:W.map(e=>(0,H.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,H.jsx)(C,{size:14,"aria-hidden":`true`,className:`mt-1 flex-none text-muted`}),e]},e))}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,H.jsx)($,{id:`obs-days`,icon:y,title:`Sessions over time`,note:N.turnTime?`A turn took ${Z(N.turnTime.p50)} at the median, ${Z(N.turnTime.p95)} at the 95th percentile.`:void 0,children:(0,H.jsx)(K,{series:N.series})}),(0,H.jsxs)(`div`,{className:`grid gap-x-6 gap-y-8 pt-6 @3xl:grid-cols-2`,children:[(0,H.jsx)($,{id:`obs-commands`,icon:w,title:`By command`,divider:!1,children:(0,H.jsx)(q,{rows:N.commands.map(e=>({key:e.command,label:`forgeqe ${e.command}`,value:e.sessions,failed:e.problems})),label:`Sessions by command`,empty:`No session in these days.`,unit:`session`,failedWord:`with an error`})}),(0,H.jsx)($,{id:`obs-runs`,icon:v,title:`Browser runs`,divider:!1,children:(0,H.jsx)(Y,{runs:N.runs})}),(0,H.jsx)($,{id:`obs-tools`,icon:x,title:`Tool calls`,divider:!1,children:(0,H.jsx)(q,{rows:N.tools.map(e=>({key:e.tool,label:e.tool===`system_tool`?`Other systems' tools`:e.tool,value:e.calls,failed:e.errors})),label:`Tool calls by tool`,empty:`No tool call in these days.`,unit:`call`})}),(0,H.jsx)($,{id:`obs-health`,icon:b,title:`Session health`,divider:!1,note:`The ways a chat has gone wrong before, found by their signature in the logs.`,children:(0,H.jsx)(q,{rows:N.health.map(e=>({key:e.kind,label:e.text,value:e.count})),label:`Session health findings`,empty:`No known kind of trouble in these days.`,unit:`time`})})]}),(0,H.jsx)($,{id:`obs-models`,icon:g,title:`Model calls`,children:(0,H.jsx)(R,{label:`Model calls by model`,placeholder:`Find a model`,resetKey:e,empty:N.source.ledger?`No model call in these days.`:`Model calls are counted once this project has a forgeqe.yaml.`,search:N.models.length>8,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`w-[34%]`),children:`Model`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Calls`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Tokens`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Median`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`95th percentile`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-right text-label-md font-medium whitespace-nowrap text-muted`,children:`Cost`})]}),children:N.models.map(e=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`max-w-0`),children:(0,H.jsx)(`span`,{"data-tip":e.model,className:`block truncate font-mono text-body-sm`,children:e.model})}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,children:e.calls}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-tip":`${I(e.input)} read, ${I(e.output)} written`,"data-sort":e.input+e.output,children:I(e.input+e.output)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @xl:table-cell`),"data-sort":e.p50??-1,children:e.p50===null?`–`:Z(e.p50)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2 text-right whitespace-nowrap tabular-nums`,`hidden @xl:table-cell`),"data-sort":e.p95??-1,children:e.p95===null?`–`:Z(e.p95)}),(0,H.jsx)(`td`,{className:`px-4 py-2 text-right whitespace-nowrap tabular-nums`,"data-sort":e.amount??-1,children:e.amount!==void 0&&e.currency?L(e.amount,e.currency):(0,H.jsx)(`span`,{className:`text-muted`,children:`–`})})]},e.model))})}),(0,H.jsx)($,{id:`obs-problems`,icon:_,title:`Latest problems`,note:`Errors and warnings, as the export sends them as log records: in ForgeQE's words, never what the model, the page or a person wrote.`,children:(0,H.jsx)(R,{label:`Latest problems`,placeholder:`Find a problem or session`,resetKey:e,empty:`No problem in these days.`,search:N.problems.length>8,head:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`Problem`}),(0,H.jsx)(`th`,{scope:`col`,className:`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,children:`When`}),(0,H.jsx)(`th`,{scope:`col`,className:r(`px-4 py-2 text-left text-label-md font-medium whitespace-nowrap text-muted`,`hidden @xl:table-cell`),children:`Session`})]}),children:N.problems.map((e,t)=>(0,H.jsxs)(`tr`,{className:`h-12 border-t border-line-soft align-middle transition-colors duration-150 data-[state=selected]:bg-tint-hover`,children:[(0,H.jsx)(`td`,{className:`px-4 py-2`,children:(0,H.jsxs)(`span`,{className:`inline-flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(p,{tone:e.severity===`error`?`fail`:`warn`,children:e.severity===`error`?`Error`:`Warning`}),(0,H.jsx)(`span`,{children:e.text}),e.detail&&(0,H.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.detail})]})}),(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`whitespace-nowrap text-muted`),"data-tip":z(e.at),"data-sort":new Date(e.at).getTime()||0,children:D(e.at)}),(0,H.jsx)(`td`,{className:r(`px-4 py-2`,`hidden max-w-[220px] @xl:table-cell`),children:(0,H.jsx)(`a`,{href:n(`runs`,encodeURIComponent(e.session)),"data-tip":`Open this session in Runs`,className:`block truncate font-mono text-body-sm`,children:e.session.replace(/\.log$/,``)})})]},`${e.session}-${e.at}-${t}`))})})]}),(0,H.jsxs)(`p`,{className:`m-0 flex items-center gap-2 text-body-sm text-muted`,children:[(0,H.jsx)(S,{size:14,"aria-hidden":`true`}),(0,H.jsxs)(`span`,{children:[N.source.read,` session log`,N.source.read===1?``:`s`,` read. `,(0,H.jsx)(`a`,{href:n(`settings`,`observability`),children:`Send these to your collector`}),`.`]})]})]})]})]})}export{ee as Observability};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{I as r,L as i,P as a,V as o}from"./surface-c1kG1KPS.js";import{n as s,t as c}from"./utils-DJRAScIl.js";import{t as l}from"./jsx-runtime-LKYXHABd.js";import{r as u}from"./palette-BEo5X3wD.js";import{ct as d}from"./api-BJHzfOse.js";import{I as f,P as p,k as m}from"./pageBack-BKHdI-pD.js";import{Cr as h,Nr as g,Vn as _,ir as v,o as y,sr as b,xt as x,yn as S}from"./line-icons-Cwj9OmCz.js";import{Fn as C,cn as w,f as T,kt as E,pn as D}from"./index-DZMkBMxL.js";var O=e(t(),1),k=l(),A={skills:{one:`skill`,many:`skills`,icon:b,body:`How to do it`,placeholder:`1. Read the failed run's board.
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{r as n}from"./route-9BkoTWUE.js";import{I as r,L as i,P as a,V as o}from"./surface-c1kG1KPS.js";import{n as s,t as c}from"./utils-DJRAScIl.js";import{t as l}from"./jsx-runtime-LKYXHABd.js";import{r as u}from"./palette-BEo5X3wD.js";import{ct as d}from"./api-BJHzfOse.js";import{I as f,P as p,k as m}from"./pageBack-BKHdI-pD.js";import{Cr as h,Nr as g,Vn as _,ir as v,o as y,sr as b,xt as x,yn as S}from"./line-icons-Cwj9OmCz.js";import{Fn as C,cn as w,f as T,kt as E,pn as D}from"./index-B58JrUzp.js";var O=e(t(),1),k=l(),A={skills:{one:`skill`,many:`skills`,icon:b,body:`How to do it`,placeholder:`1. Read the failed run's board.
2
2
  2. Sort each failure: product bug, test bug or flaky.
3
3
  3. Give the evidence for each.`,describe:{title:`When to use it`,placeholder:`When a check fails and the team must sort why`,required:!0},audience:!1},prompts:{one:`prompt`,many:`prompts`,icon:S,body:`What the agents are told`,placeholder:`Check the API before the pages. Report each failure with the request and the response you saw.`,describe:{title:`What it is for (optional)`,placeholder:`How the team reports`},audience:!0},guardrails:{one:`guardrail set`,many:`guardrails`,icon:v,body:`Rules, one per line`,placeholder:`- Never pay with a real card
4
4
  - Use only qa accounts`,describe:{title:`What they are for (optional)`,placeholder:`Payment safety`},audience:!0},knowledge:{one:`note`,many:`notes`,icon:x,body:`What it says`,placeholder:`A release needs two green passes on qa before sign-off.`,audience:!1}},j={all:`Every agent`,lead:`The lead`,members:`The members`},M=e=>e.split(/\r?\n/).filter(e=>e.trim()&&!e.trim().startsWith(`#`)&&!e.trim().startsWith(`<!--`)).length,N=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+/,``).slice(0,64),P=(e,t)=>({kind:e,team:t,name:``,description:``,for:`all`,body:``}),F=(e,t,n)=>({kind:e,team:t,name:n.name,description:n.description,for:n.for||`all`,body:n.body,old:!0});function I({draft:e,teams:t,taken:n,onClose:o,onSaved:l}){let[u,m]=(0,O.useState)(e),[g,_]=(0,O.useState)(!1),[v,y]=(0,O.useState)(``),[b,x]=(0,O.useState)(!1);(0,O.useEffect)(()=>{m(e),y(``),x(!1)},[e]);let S=u?A[u.kind]:null,w=u?.kind===`skills`&&!u.old&&n.includes(u.name),T=u?.kind===`guardrails`?M(u.body):0,D=u?.kind===`guardrails`&&u.body.split(/\r?\n/).some(e=>e.replace(/^\s*[-*+]\s+/,``).trim().length>300),P=u&&u.team&&u.name&&u.body.trim()&&!w&&!D&&(u.kind!==`guardrails`||T>0&&T<=40)&&(!S?.describe?.required||u.description.trim()),F=t.find(e=>e.id===u?.team)?.name||u?.team,I=async()=>{if(u&&P){_(!0),y(``);try{l(await d.own(u.team,{item:{kind:u.kind,name:u.name,...S?.describe?{description:u.description}:{},...S?.audience?{for:u.for}:{},body:u.body},...u.old?{replace:!0}:{}}),`${u.old?`Changed`:`Added`} ${S.one} ${u.name} for ${F}. The team uses it once a person approves the team again.`)}catch(e){y(e.message)}finally{_(!1)}}},L=async()=>{if(u){if(!b)return x(!0);_(!0),y(``);try{l(await d.own(u.team,{remove:!0,kind:u.kind,name:u.name}),`Removed ${S.one} ${u.name} from ${F}. The team stops using it once a person approves the team again.`)}catch(e){y(e.message)}finally{_(!1)}}};return(0,k.jsx)(C,{wide:!0,open:!!e,onClose:o,title:u?`${u.old?`Change`:`Add`} a team ${S.one}`:``,description:u?`Only ${F?`${F}'s`:`the team's`} agents get it, while they work in the team; no other agent sees it.`:void 0,footer:(0,k.jsxs)(k.Fragment,{children:[u?.old&&(0,k.jsxs)(p,{variant:b?`destructive`:`danger`,className:`mr-auto`,disabled:g,onClick:()=>void L(),children:[(0,k.jsx)(h,{"aria-hidden":`true`}),b?`Remove it for good`:`Remove`]}),(0,k.jsx)(p,{variant:`outline`,onClick:o,children:`Cancel`}),(0,k.jsx)(p,{variant:`primary`,disabled:g||!P,onClick:()=>void I(),children:g?`Saving…`:`Save`})]}),children:u&&S&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-6 pt-4`,children:[!u.old&&t.length>1&&(0,k.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:`Team`}),(0,k.jsxs)(r,{value:u.team,onChange:e=>m({...u,team:e.target.value}),children:[(0,k.jsx)(`option`,{value:``,children:`Choose a team…`}),t.map(e=>(0,k.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,k.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:`Name`}),(0,k.jsx)(a,{value:u.name,disabled:u.old,maxLength:64,placeholder:u.kind===`skills`?`triage-failures`:u.kind===`guardrails`?`payment-safety`:u.kind===`prompts`?`how-we-report`:`release-rules`,onChange:e=>m({...u,name:N(e.target.value)}),"aria-describedby":`own-name-hint`}),(0,k.jsx)(`span`,{id:`own-name-hint`,className:c(`text-body-sm`,w?`text-fail`:`text-muted`),children:w?`ForgeQE already has a skill named ${u.name}: give the team's another name, or pick the shared one in the team's Knowledge.`:u.old?`A name stays as it is: add a new one to rename.`:`Lower-case words joined by dashes.`})]}),S.describe&&(0,k.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:S.describe.title}),(0,k.jsx)(a,{value:u.description,maxLength:400,placeholder:S.describe.placeholder,onChange:e=>m({...u,description:e.target.value.replace(/[\r\n]+/g,` `)})})]}),S.audience&&(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,k.jsx)(`span`,{className:`text-body-sm font-medium text-ink-2`,children:`For`}),(0,k.jsx)(E,{label:`Whom of the team it is for`,value:u.for,onChange:e=>m({...u,for:e}),options:[`all`,`lead`,`members`].map(e=>({id:e,label:j[e]}))})]}),(0,k.jsxs)(`label`,{className:`flex flex-col gap-2`,children:[(0,k.jsxs)(`span`,{className:`flex items-baseline justify-between gap-2 text-body-sm font-medium text-ink-2`,children:[S.body,u.kind===`guardrails`&&(0,k.jsx)(`span`,{className:c(`font-normal`,T>40||D?`text-fail`:`text-muted`),children:D?`A rule is longer than 300 characters`:`${s(T,`rule`)} of 40`})]}),(0,k.jsx)(i,{rows:u.kind===`guardrails`?8:12,value:u.body,maxLength:39e3,placeholder:S.placeholder,className:u.kind===`knowledge`?void 0:`font-mono text-body-sm`,onChange:e=>m({...u,body:e.target.value})}),u.kind===`guardrails`&&(0,k.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Each line is one rule the team's agents follow. They add to ForgeQE's own limits and never lift one.`}),u.kind===`prompts`&&(0,k.jsx)(`span`,{className:`text-body-sm text-muted`,children:`Guidance for how the team works. It never changes what an agent may do: its limits are kept in code.`})]}),v&&(0,k.jsx)(`p`,{role:`alert`,className:c(f.fail,`m-0`),children:v})]})})}function L({kind:e,item:t,onOpen:n,compact:r=!1}){let i=A[e],a=t.description||t.body.split(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{t as n}from"./utils-DJRAScIl.js";import{t as r}from"./jsx-runtime-LKYXHABd.js";import{r as ee}from"./palette-BEo5X3wD.js";import{a as te,i}from"./sectionList-B6NF3ZMb.js";import{b as a}from"./api-BJHzfOse.js";import{N as ne,P as o}from"./pageBack-BKHdI-pD.js";import{Vn as s}from"./line-icons-Cwj9OmCz.js";import{An as c,Bn as l,Dn as u,En as d,In as re,Mn as ie,Nn as ae,Tn as oe,X as se,Z as ce,an as le,et as ue,in as de,nn as fe,on as pe,rn as me,tn as f,wn as he}from"./index-DZMkBMxL.js";import{r as p}from"./choice-W0qOx_1k.js";var m=e(t(),1),h=r(),g=e=>e&&e!==`forgeqe`?i.find(t=>t.agent===e)?.crew:void 0;function _({id:e,agent:t=te,question:r,intro:i,underIntro:_,starters:ge,placeholder:_e,replyPlaceholder:v,note:y,turnNote:b,track:x,onTurnEnd:ve,ask:S,askSends:ye=!1,draft:C,above:be,menu:w,compose:T,onNew:E,className:D}){let O=`${e}-agent-box`,{chat:k,thread:A,last:j,busy:M,ended:N,send:xe,reset:Se}=ce(`forgeqe.${e}.chat`),Ce=re(),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(``),[R,z]=(0,m.useState)(!1),B=pe(),V=ae(P,F,O,{chat:k&&!N?k:void 0,code:B.tools.code}),H=u(`${e}-agent`,e=>{F(e),d(O)}),U=(0,m.useRef)(new Map),[W,G]=(0,m.useState)({}),K=j?.id,q=j?.outcome;(0,m.useEffect)(()=>{K&&q&&(ve?.(),x&&x.after().then(e=>{let t=[...e].filter(([e,t])=>U.current.get(e)!==t).map(([e])=>e);t.length&&(G(e=>({...e,[K]:t})),x.onMade?.(t))},()=>{}))},[K,q]);let J=async e=>{if(!B.ready)return;let t=T?T.add(e.trim()):e.trim();if(!(R||!t&&!V.hasFiles)){z(!0),L(``);try{x&&(U.current=await x.now());let e=await V.wrap(t);if(!e.trim())return;let n=b?b():``;await xe(e,n?`${y()}\n${n}`:y(),B.choice),F(``),V.reset({keep:!0}),T?.clear()}catch(e){L(e.message)}finally{z(!1)}}},Y=e=>{F(e),setTimeout(()=>document.getElementById(O)?.focus(),0)},X=(0,m.useRef)(0);(0,m.useEffect)(()=>{S&&S.n!==X.current&&(X.current=S.n,(S.send??ye)&&!M?J(S.text):Y(S.text))},[S?.n]);let Z=(0,m.useRef)(0);(0,m.useEffect)(()=>{C&&C.n!==Z.current&&(Z.current=C.n,C.ifEmpty&&P.trim()||Y(C.text))},[C?.n]);let Q=!k||!A.turns.length,$=A.turns.flatMap(e=>W[e.id]||[]).at(-1);return(0,h.jsxs)(`div`,{className:n(`mx-auto flex w-full max-w-[880px] flex-auto flex-col gap-6`,D),children:[Q?(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4 pt-2 text-center short:gap-4 short:pt-0`,children:[(0,h.jsx)(ee,{agent:t,px:Ce?72:112,working:R||M,className:`mb-1`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`h2`,{className:`m-0 text-headline-sm`,children:r}),(0,h.jsx)(`p`,{className:`m-0 text-body-lg text-muted`,children:i}),g(t)&&(0,h.jsx)(l,{crew:g(t)})]}),_,(0,h.jsx)(`div`,{className:`grid w-full gap-2 text-left sm:grid-cols-2`,children:ge.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>e.onPick?e.onPick():e.send?void J(e.text):Y(e.text),className:p,children:[(0,h.jsx)(ne,{icon:e.icon,size:18,className:`mt-1 text-icon`}),(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`text-body-sm font-medium text-ink`,children:e.title}),(0,h.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.hint})]})]},e.title))})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(`div`,{className:`z-10 flex items-center justify-end bg-canvas md:sticky md:top-[var(--page-head,0px)] md:py-1`,children:(0,h.jsxs)(o,{size:`sm`,variant:`ghost`,onClick:()=>{Se(),V.reset(),G({}),F(``),E?.()},disabled:M,"data-tip":`Start a new conversation`,children:[(0,h.jsx)(s,{"aria-hidden":`true`}),`New`]})}),A.turns.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(ie,{text:e.user,scope:{chat:k||void 0}}),(0,h.jsx)(ue,{turn:e.error?{...e,error:se(e.error)}:e,live:!N,onAnswer:(e,t)=>void a.answer(k,e,t).catch(e=>L(e.message)),onProceed:(e,t)=>void a.proceed(k,e,t).catch(e=>L(e.message))}),x&&(W[e.id]||[]).map(e=>(0,h.jsx)(`div`,{children:x.card(e,{busy:M,send:e=>void J(e),error:L})},e))]},e.id)),A.fatal&&(0,h.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:A.fatal})]}),(0,h.jsxs)(`div`,{className:`mt-auto flex flex-col empty:hidden`,children:[!B.ready&&B.setup&&(0,h.jsx)(le,{project:B.setup.project}),B.ready&&(0,h.jsx)(de,{c:B})]}),(0,h.jsxs)(`div`,{className:`sticky bottom-0 z-10 flex flex-col gap-2 bg-gradient-to-t from-canvas from-85% to-transparent pt-6 pb-4 [:empty+&]:mt-auto`,children:[be?.($,Y),(I||V.error)&&(0,h.jsx)(`p`,{className:`m-0 bg-canvas text-body-sm text-fail [overflow-wrap:anywhere]`,children:I||V.error}),(0,h.jsx)(c,{id:O,label:`Ask the agent`,value:P,onChange:F,onSend:()=>void J(P),onStop:()=>k&&void a.stop(k),busy:M,disabled:R||H.running||!B.ready,canSend:!!P.trim()||V.hasFiles||!!T?.has,onEdit:V.onEdit,onKey:V.onKeyDown,onFiles:V.onFiles,dropping:V.dropping,drop:V.drop,mentions:V.mentions,combo:V.combo,placeholder:Q?_e:v?v($):`Reply, or ask for the next thing…`,top:(0,h.jsxs)(h.Fragment,{children:[V.chips,H.state&&(0,h.jsx)(oe,{state:H.state,onStop:()=>void H.stop(),onUndo:H.undo,onClose:H.close})]}),left:(0,h.jsxs)(h.Fragment,{children:[V.fileInput,(0,h.jsx)(f,{attach:{pick:V.pick},...w?{before:w}:{},...Q?{choice:B}:k?{started:{chat:k,thread:A,ended:N,snap:B.snap,onError:L}}:{}}),(0,h.jsx)(he,{running:H.running,disabled:!P.trim()||R||!B.ready,onClick:()=>void H.start(P)})]}),right:Q?(0,h.jsx)(fe,{c:B}):k?(0,h.jsx)(me,{chat:k,thread:A,ended:N,busy:M||R,snap:B.snap,onError:L}):void 0})]})]})}export{_ as t};
1
+ import{r as e}from"./rolldown-runtime-XKyaHtl9.js";import{t}from"./react-BDur5s0O.js";import{t as n}from"./utils-DJRAScIl.js";import{t as r}from"./jsx-runtime-LKYXHABd.js";import{r as ee}from"./palette-BEo5X3wD.js";import{a as te,i}from"./sectionList-B6NF3ZMb.js";import{b as a}from"./api-BJHzfOse.js";import{N as ne,P as o}from"./pageBack-BKHdI-pD.js";import{Vn as s}from"./line-icons-Cwj9OmCz.js";import{An as c,Bn as l,Dn as u,En as d,In as re,Mn as ie,Nn as ae,Tn as oe,X as se,Z as ce,an as le,et as ue,in as de,nn as fe,on as pe,rn as me,tn as f,wn as he}from"./index-B58JrUzp.js";import{r as p}from"./choice-W0qOx_1k.js";var m=e(t(),1),h=r(),g=e=>e&&e!==`forgeqe`?i.find(t=>t.agent===e)?.crew:void 0;function _({id:e,agent:t=te,question:r,intro:i,underIntro:_,starters:ge,placeholder:_e,replyPlaceholder:v,note:y,turnNote:b,track:x,onTurnEnd:ve,ask:S,askSends:ye=!1,draft:C,above:be,menu:w,compose:T,onNew:E,className:D}){let O=`${e}-agent-box`,{chat:k,thread:A,last:j,busy:M,ended:N,send:xe,reset:Se}=ce(`forgeqe.${e}.chat`),Ce=re(),[P,F]=(0,m.useState)(``),[I,L]=(0,m.useState)(``),[R,z]=(0,m.useState)(!1),B=pe(),V=ae(P,F,O,{chat:k&&!N?k:void 0,code:B.tools.code}),H=u(`${e}-agent`,e=>{F(e),d(O)}),U=(0,m.useRef)(new Map),[W,G]=(0,m.useState)({}),K=j?.id,q=j?.outcome;(0,m.useEffect)(()=>{K&&q&&(ve?.(),x&&x.after().then(e=>{let t=[...e].filter(([e,t])=>U.current.get(e)!==t).map(([e])=>e);t.length&&(G(e=>({...e,[K]:t})),x.onMade?.(t))},()=>{}))},[K,q]);let J=async e=>{if(!B.ready)return;let t=T?T.add(e.trim()):e.trim();if(!(R||!t&&!V.hasFiles)){z(!0),L(``);try{x&&(U.current=await x.now());let e=await V.wrap(t);if(!e.trim())return;let n=b?b():``;await xe(e,n?`${y()}\n${n}`:y(),B.choice),F(``),V.reset({keep:!0}),T?.clear()}catch(e){L(e.message)}finally{z(!1)}}},Y=e=>{F(e),setTimeout(()=>document.getElementById(O)?.focus(),0)},X=(0,m.useRef)(0);(0,m.useEffect)(()=>{S&&S.n!==X.current&&(X.current=S.n,(S.send??ye)&&!M?J(S.text):Y(S.text))},[S?.n]);let Z=(0,m.useRef)(0);(0,m.useEffect)(()=>{C&&C.n!==Z.current&&(Z.current=C.n,C.ifEmpty&&P.trim()||Y(C.text))},[C?.n]);let Q=!k||!A.turns.length,$=A.turns.flatMap(e=>W[e.id]||[]).at(-1);return(0,h.jsxs)(`div`,{className:n(`mx-auto flex w-full max-w-[880px] flex-auto flex-col gap-6`,D),children:[Q?(0,h.jsxs)(`div`,{className:`flex flex-col items-center gap-4 pt-2 text-center short:gap-4 short:pt-0`,children:[(0,h.jsx)(ee,{agent:t,px:Ce?72:112,working:R||M,className:`mb-1`}),(0,h.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,h.jsx)(`h2`,{className:`m-0 text-headline-sm`,children:r}),(0,h.jsx)(`p`,{className:`m-0 text-body-lg text-muted`,children:i}),g(t)&&(0,h.jsx)(l,{crew:g(t)})]}),_,(0,h.jsx)(`div`,{className:`grid w-full gap-2 text-left sm:grid-cols-2`,children:ge.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>e.onPick?e.onPick():e.send?void J(e.text):Y(e.text),className:p,children:[(0,h.jsx)(ne,{icon:e.icon,size:18,className:`mt-1 text-icon`}),(0,h.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`span`,{className:`text-body-sm font-medium text-ink`,children:e.title}),(0,h.jsx)(`span`,{className:`text-body-sm text-muted`,children:e.hint})]})]},e.title))})]}):(0,h.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,h.jsx)(`div`,{className:`z-10 flex items-center justify-end bg-canvas md:sticky md:top-[var(--page-head,0px)] md:py-1`,children:(0,h.jsxs)(o,{size:`sm`,variant:`ghost`,onClick:()=>{Se(),V.reset(),G({}),F(``),E?.()},disabled:M,"data-tip":`Start a new conversation`,children:[(0,h.jsx)(s,{"aria-hidden":`true`}),`New`]})}),A.turns.map(e=>(0,h.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,h.jsx)(ie,{text:e.user,scope:{chat:k||void 0}}),(0,h.jsx)(ue,{turn:e.error?{...e,error:se(e.error)}:e,live:!N,onAnswer:(e,t)=>void a.answer(k,e,t).catch(e=>L(e.message)),onProceed:(e,t)=>void a.proceed(k,e,t).catch(e=>L(e.message))}),x&&(W[e.id]||[]).map(e=>(0,h.jsx)(`div`,{children:x.card(e,{busy:M,send:e=>void J(e),error:L})},e))]},e.id)),A.fatal&&(0,h.jsx)(`p`,{className:`m-0 text-body-sm text-fail`,children:A.fatal})]}),(0,h.jsxs)(`div`,{className:`mt-auto flex flex-col empty:hidden`,children:[!B.ready&&B.setup&&(0,h.jsx)(le,{project:B.setup.project}),B.ready&&(0,h.jsx)(de,{c:B})]}),(0,h.jsxs)(`div`,{className:`sticky bottom-0 z-10 flex flex-col gap-2 bg-gradient-to-t from-canvas from-85% to-transparent pt-6 pb-4 [:empty+&]:mt-auto`,children:[be?.($,Y),(I||V.error)&&(0,h.jsx)(`p`,{className:`m-0 bg-canvas text-body-sm text-fail [overflow-wrap:anywhere]`,children:I||V.error}),(0,h.jsx)(c,{id:O,label:`Ask the agent`,value:P,onChange:F,onSend:()=>void J(P),onStop:()=>k&&void a.stop(k),busy:M,disabled:R||H.running||!B.ready,canSend:!!P.trim()||V.hasFiles||!!T?.has,onEdit:V.onEdit,onKey:V.onKeyDown,onFiles:V.onFiles,dropping:V.dropping,drop:V.drop,mentions:V.mentions,combo:V.combo,placeholder:Q?_e:v?v($):`Reply, or ask for the next thing…`,top:(0,h.jsxs)(h.Fragment,{children:[V.chips,H.state&&(0,h.jsx)(oe,{state:H.state,onStop:()=>void H.stop(),onUndo:H.undo,onClose:H.close})]}),left:(0,h.jsxs)(h.Fragment,{children:[V.fileInput,(0,h.jsx)(f,{attach:{pick:V.pick},...w?{before:w}:{},...Q?{choice:B}:k?{started:{chat:k,thread:A,ended:N,snap:B.snap,onError:L}}:{}}),(0,h.jsx)(he,{running:H.running,disabled:!P.trim()||R||!B.ready,onClick:()=>void H.start(P)})]}),right:Q?(0,h.jsx)(fe,{c:B}):k?(0,h.jsx)(me,{chat:k,thread:A,ended:N,busy:M||R,snap:B.snap,onError:L}):void 0})]})]})}export{_ as t};