@yansigit/opencodex 2.36.1-dev.20260829.32 → 2.36.1-dev.20260829.34
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/gui/dist/assets/{ApiKeys-nJ-qJbkG.js → ApiKeys-BthcYAks.js} +1 -1
- package/gui/dist/assets/{Claude-Br34aNO2.js → Claude-D1uQ1rsr.js} +1 -1
- package/gui/dist/assets/{CodexSet-Bo2Vel9f.js → CodexSet-BUNKAStQ.js} +1 -1
- package/gui/dist/assets/{FileIntegrationPage-8JuhUwT7.js → FileIntegrationPage-CyrJ_kz1.js} +1 -1
- package/gui/dist/assets/{Grok-pTPUqi3L.js → Grok-CeSYaWba.js} +1 -1
- package/gui/dist/assets/{Integrations-N-s59k0n.js → Integrations-BkE9NLJW.js} +2 -2
- package/gui/dist/assets/{IntegrationsOverview-C6Mkt8OU.js → IntegrationsOverview-D-nDl5t5.js} +1 -1
- package/gui/dist/assets/{Logs-BzYAbD9a.js → Logs-uExIBMZr.js} +1 -1
- package/gui/dist/assets/{Models-8o4TdPzd.js → Models-CNpjs-ld.js} +1 -1
- package/gui/dist/assets/{NumberStepper-y1MLMfxu.js → NumberStepper-CKVXkKzE.js} +1 -1
- package/gui/dist/assets/{Providers-oTh_-wqc.js → Providers-D72-5Egl.js} +1 -1
- package/gui/dist/assets/{RestoreDialog-BnPA60nS.js → RestoreDialog-2MVe4MQR.js} +1 -1
- package/gui/dist/assets/{Startup-eM7zbmU_.js → Startup-ClZlpU_Z.js} +1 -1
- package/gui/dist/assets/{Storage-Cuf1wakW.js → Storage-ChC2WGMp.js} +1 -1
- package/gui/dist/assets/{Subagents-DEnwUJJx.js → Subagents-BpkXAXLZ.js} +1 -1
- package/gui/dist/assets/{Usage-BMBOTm6l.js → Usage-BkEOitI3.js} +1 -1
- package/gui/dist/assets/{data-surface-Cq2fDI2w.js → data-surface-BzhqUIJ_.js} +1 -1
- package/gui/dist/assets/{index-CEcmjvjC.js → index-DE4QGJSt.js} +2 -2
- package/gui/dist/assets/{model-display-CTtXLqIv.js → model-display-CCqxubZd.js} +1 -1
- package/gui/dist/assets/{provider-payload-Bs3Sdqv7.js → provider-payload-CI2ayvqv.js} +1 -1
- package/gui/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/adapters/command-code-project-context.ts +24 -19
- package/src/codex/catalog/sync.ts +7 -2
- package/src/generated/compatibility-version.json +11 -11
- package/src/oauth/google-antigravity.ts +18 -5
- package/src/storage/cleanup.ts +11 -0
- package/src/storage/policy-job.ts +29 -3
- package/src/storage/policy-worker.ts +8 -1
- package/src/storage/policy.ts +3 -0
- package/src/storage/restore-job.ts +5 -0
- package/src/storage/restore-worker.ts +7 -1
- package/src/storage/storage-mutation-coordinator.ts +6 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{F as i,G as a,H as o,I as s,J as c,K as l,L as u,N as d,S as f,W as p,d as m,h,k as g,lt as _,p as v,tt as y,yt as b}from"./index-CEcmjvjC.js";import{t as x}from"./data-surface-Cq2fDI2w.js";import{t as S}from"./data-surface-D8RXShV2.js";import{n as C,t as w}from"./section-tabs-DEASco68.js";import{t as T}from"./model-display-CTtXLqIv.js";var E=e(n(),1),D=r();function O({model:e,effort:n,efforts:r,available:i,guidanceEnabled:a,syncCodexDefaults:o,saving:c,onSave:l,prompt:d,childInstructions:p,childInstructionsSaving:m,onChildInstructionsSave:h,ultraMode:g,ultraSaving:_,onUltraModeSave:v,ultraLoadFailed:y,onUltraModeRetry:b,keepNativeChatGptOnV1:x=!1,nativeParentOverride:S={enabled:!1,model:null,active:!1},nativeParentOverrideSaving:C=!1,onNativeParentOverrideSave:w=()=>{},agentTaskRecovery:T={enabled:!1,model:null},agentTaskRecoverySaving:E=!1,onAgentTaskRecoverySave:O=()=>{},routedDelegationBridge:M={enabled:!1},routedDelegationBridgeSaving:N=!1,onRoutedDelegationBridgeSave:P=()=>{}}){let F=t(),I=(g.hintText??``).trim().length>0,L=i.filter(e=>e.canonical!==!0),R=g.multiAgentV2Enabled&&!x&&S.model!==null;return(0,D.jsxs)(`div`,{className:`swi-delegation`,children:[y&&(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.ultraMode`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeLoadFail`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:b,children:F(`common.retry`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.routedDelegationBridge`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.routedDelegationBridgeHint`)})]}),(0,D.jsx)(u,{on:M.enabled,onClick:()=>P(!M.enabled),disabled:N,label:F(`sub.routedDelegationBridge`)}),!g.multiAgentV2Enabled&&M.enabled&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.routedDelegationBridgeInactive`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.delegation.model`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.delegation.modelHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(s,{value:e,options:[{value:``,label:F(`dash.injectionNone`)},...i.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,F)}))],onChange:e=>l({model:e||null,effort:n||null}),disabled:c,label:F(`dash.injectionLabel`),align:`right`}),e&&r.length>0&&(0,D.jsx)(s,{value:n,options:[{value:``,label:F(`dash.injectionEffortNone`)},...r.map(e=>({value:e,label:e}))],onChange:t=>l({model:e||null,effort:t||null}),disabled:c,label:F(`dash.injectionEffortLabel`),align:`right`})]})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`dash.syncCodexSubagentDefaults`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`dash.syncCodexSubagentDefaultsHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${o?`on`:``}`,onClick:()=>l({syncCodexSubagentDefaults:!o}),disabled:c||!e,"aria-label":F(`dash.syncCodexSubagentDefaults`),"aria-pressed":o,children:(0,D.jsx)(`span`,{className:`knob`})})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`dash.multiAgentGuidance`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`dash.multiAgentGuidanceHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${a?`on`:``}`,onClick:()=>l({multiAgentGuidanceEnabled:!a}),disabled:c,"aria-label":F(`dash.multiAgentGuidance`),"aria-pressed":a,children:(0,D.jsx)(`span`,{className:`knob`})})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.ultraMode`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${I?`on`:``}`,onClick:()=>v({multiAgentModeHintText:I?null:A}),disabled:c||_||!I&&!g.multiAgentV2Enabled,"aria-label":F(`sub.ultraMode`),"aria-pressed":I,children:(0,D.jsx)(`span`,{className:`knob`})}),!g.multiAgentV2Enabled&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeV2Required`)})]}),I&&(0,D.jsx)(`div`,{className:`swi-delegation-row swi-ultra-mode-editor`,children:(0,D.jsx)(k,{initialHint:g.hintText??``,disabled:c||_,onSave:v,preset:`Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning sub-agents no longer applies. Delegate independent sub-tasks to sub-agents whenever parallel work would materially improve speed or quality — do not serialize work that can run concurrently. Each sub-agent runs in its own context and can use all available tools; prefer spawning specialists over doing everything yourself. This mode remains active until a later multi-agent mode developer message changes it.`,labels:{text:F(`sub.ultraModeText`),preset:F(`sub.ultraModePreset`),save:F(`common.save`)}},g.hintText)}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.nativeParentOverride`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverrideHint`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverridePrivacyWarning`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(s,{value:S.model??``,options:[{value:``,label:F(`dash.injectionNone`)},...L.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,F)}))],onChange:e=>w({enabled:e?S.enabled:!1,model:e||null,active:S.active}),disabled:C,label:F(`sub.nativeParentOverrideModel`),align:`right`}),(0,D.jsx)(u,{on:S.enabled,onClick:()=>w({enabled:!S.enabled,model:S.model,active:S.active}),disabled:C||!S.enabled&&!R,label:F(`sub.nativeParentOverride`)})]}),!R&&!S.active&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverrideV2Required`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.agentTaskRecovery`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.agentTaskRecoveryHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(`input`,{type:`text`,className:`input input-sm`,style:{width:180,textAlign:`right`},placeholder:`gpt-5.6-luna`,value:T.model??``,onChange:e=>{let t=e.target.value.trim();O({enabled:T.enabled,model:t.length>0?t:null})},disabled:E,"aria-label":F(`sub.agentTaskRecoveryModel`)}),(0,D.jsx)(u,{on:T.enabled,onClick:()=>O({enabled:!T.enabled,model:T.model}),disabled:E,label:F(`sub.agentTaskRecovery`)})]})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row swi-prompt-editor`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.injectionPrompt`)}),(0,D.jsxs)(`div`,{className:`muted setting-hint`,children:[F(`sub.injectionPromptHint`),` `,(0,D.jsx)(`code`,{children:`{{model}}`}),` `,(0,D.jsx)(`code`,{children:`{{effort}}`}),` `,(0,D.jsx)(`code`,{children:`{{roster}}`}),` `,(0,D.jsx)(`code`,{children:`{{fallback}}`}),` `,(0,D.jsx)(`code`,{children:`{{roles}}`})]})]}),(0,D.jsx)(j,{initialValue:d,disabled:c,ariaLabel:F(`sub.injectionPrompt`),saveLabel:F(`sub.injectionPromptSave`),onSave:e=>l({prompt:e.trim()?e:null})},`prompt:${d}`)]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row swi-prompt-editor`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.childInstructions`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.childInstructionsHint`)})]}),(0,D.jsx)(j,{initialValue:p,disabled:c||m,ariaLabel:F(`sub.childInstructions`),saveLabel:F(`sub.childInstructionsSave`),onSave:e=>h(e.trim()?e:null)},`child:${p}`)]})]})}function k({initialHint:e,disabled:t,onSave:n,preset:r,labels:i}){let[a,o]=(0,E.useState)(e);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`textarea`,{className:`input swi-ultra-mode-textarea`,value:a,onChange:e=>o(e.target.value),disabled:t,rows:4,"aria-label":i.text}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>o(r),disabled:t,children:i.preset}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{a.trim().length!==0&&n({multiAgentModeHintText:a})},disabled:t||a.trim().length===0,children:i.save})]})}var A=`Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning sub-agents no longer applies. Delegate independent sub-tasks to sub-agents whenever parallel work would materially improve speed or quality — do not serialize work that can run concurrently. Each sub-agent runs in its own context and can use all available tools; prefer spawning specialists over doing everything yourself. This mode remains active until a later multi-agent mode developer message changes it.`;function j({initialValue:e,disabled:t,ariaLabel:n,saveLabel:r,onSave:i}){let[a,o]=(0,E.useState)(e);return(0,D.jsxs)(`div`,{className:`swi-prompt-draft`,children:[(0,D.jsx)(`textarea`,{className:`input swi-ultra-mode-textarea`,value:a,onChange:e=>o(e.target.value),disabled:t,rows:4,"aria-label":n}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>i(a),disabled:t,"aria-label":r,children:r})]})}var M=8,N=0;function P(){return N+=1,`role-${N}`}function F(e){return{key:P(),id:``,description:``,model:e,effort:``,developerInstructions:``,enabled:!0}}function I(e,t){if(e.indexOf(`/`)<=0)return!1;let n=t.find(t=>t.namespaced===e);return!n||n.provider!==`openai`}function L(e){return{id:e.id.trim(),description:e.description,model:e.model,...e.effort?{effort:e.effort}:{},developerInstructions:e.developerInstructions,enabled:e.enabled}}function R(e,t){return{key:P(),id:typeof e.id==`string`?e.id:``,description:typeof e.description==`string`?e.description:``,model:typeof e.model==`string`?e.model:t,effort:typeof e.effort==`string`?e.effort:``,developerInstructions:typeof e.developerInstructions==`string`?e.developerInstructions:``,enabled:e.enabled!==!1}}function z({apiBase:e,available:n,efforts:r,multiAgentMode:i,keepNativeChatGptOnV1:a,onStatus:o}){let c=t(),[l,p]=(0,E.useState)([]),[m,h]=(0,E.useState)(!1),[g,v]=(0,E.useState)(n),[y,x]=(0,E.useState)(r),[S,C]=(0,E.useState)(void 0),[w,T]=(0,E.useState)(!1),O=(0,E.useRef)(!1),k=g[0]?.namespaced??n[0]?.namespaced??``,A=g.length>0?g:n,j=y.length>0?y:r;(0,E.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`${e}/api/subagent-roles`),r=await d(n,c(`sub.roles.loadFail`));if(t||!r)return;p(Array.isArray(r.roles)?r.roles.map(e=>R(e,``)):[]),Array.isArray(r.available)&&v(r.available),Array.isArray(r.efforts)&&x(r.efforts);let i=typeof r.syncCodexAgentRoles==`boolean`?r.syncCodexAgentRoles:void 0,a=r.syncCodexAgentRolesEffective===!0;C(i),T(a),O.current=a}catch{t||o(!1,c(`sub.roles.loadFail`))}})(),()=>{t=!0}},[e,c,o]);let N=(e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,...t}:n))},P=()=>{p(e=>e.length>=M?e:[...e,F(k)])},z=e=>{p(t=>t.filter((t,n)=>n!==e))},B=async()=>{if(!m){h(!0);try{let t={roles:l.map(L)};(S!==void 0||w!==O.current)&&(t.syncCodexAgentRoles=w);let n=await fetch(`${e}/api/subagent-roles`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await d(n,c(`sub.roles.saveFailed`));if(Array.isArray(r?.roles)&&p(r.roles.map(e=>R(e,k))),r&&typeof r.syncCodexAgentRoles==`boolean`?C(r.syncCodexAgentRoles):r&&!(`syncCodexAgentRoles`in r)&&C(void 0),r){let e=r.syncCodexAgentRolesEffective===!0;T(e),O.current=e}let i=(r?.warnings??[]).filter(e=>typeof e==`string`&&e.trim());o(!0,i.length>0?[c(`sub.roles.saved`),...i].join(` `):c(`sub.roles.saved`))}catch(e){o(!1,e instanceof Error&&e.message?e.message:c(`sub.roles.saveFailed`))}finally{h(!1)}}},V=l.length>=M,H=i===`v2`&&!a;return(0,D.jsxs)(`div`,{className:`swi-roles`,children:[(0,D.jsx)(`p`,{className:`swi-featured-hint`,children:(0,D.jsx)(`span`,{children:c(`sub.roles.hint`)})}),l.length===0?(0,D.jsx)(`div`,{className:`swi-featured-empty`,children:c(`sub.roles.empty`)}):(0,D.jsx)(`div`,{className:`swi-roles-list`,children:l.map((e,t)=>{let n=H&&e.enabled&&I(e.model,A);return(0,D.jsxs)(`div`,{className:`swi-role-card`,children:[(0,D.jsxs)(`div`,{className:`swi-role-grid`,children:[(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.id`)}),(0,D.jsx)(`input`,{className:`input`,type:`text`,value:e.id,onChange:e=>N(t,{id:e.currentTarget.value}),"aria-label":c(`sub.roles.id`),disabled:m})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.model`)}),(0,D.jsx)(s,{value:e.model,options:A.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,c)})),onChange:e=>N(t,{model:e}),disabled:m||A.length===0,label:c(`sub.roles.model`),align:`right`})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.effort`)}),(0,D.jsx)(s,{value:e.effort,options:[{value:``,label:c(`sub.roles.effortNone`)},...j.map(e=>({value:e,label:e}))],onChange:e=>N(t,{effort:e}),disabled:m,label:c(`sub.roles.effort`),align:`right`})]})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.description`)}),(0,D.jsx)(`input`,{className:`input`,type:`text`,value:e.description,onChange:e=>N(t,{description:e.currentTarget.value}),"aria-label":c(`sub.roles.description`),disabled:m}),(0,D.jsx)(`span`,{className:`muted setting-hint`,children:c(`sub.roles.descriptionHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.instructions`)}),(0,D.jsx)(`textarea`,{className:`input swi-role-instructions`,value:e.developerInstructions,onChange:e=>N(t,{developerInstructions:e.currentTarget.value}),"aria-label":c(`sub.roles.instructions`),rows:4,disabled:m}),(0,D.jsx)(`span`,{className:`muted setting-hint`,children:c(`sub.roles.instructionsHint`)})]}),n&&(0,D.jsx)(`div`,{className:`muted setting-hint`,role:`status`,children:c(`sub.roles.routedV2Warning`)}),(0,D.jsxs)(`div`,{className:`swi-role-footer`,children:[(0,D.jsxs)(`div`,{className:`swi-role-enable`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.enabled`)}),(0,D.jsx)(u,{on:e.enabled,onClick:()=>N(t,{enabled:!e.enabled}),disabled:m,label:c(`sub.roles.enabled`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>z(t),disabled:m,"aria-label":c(`sub.roles.delete`,{id:e.id||String(t+1)}),style:{color:`var(--red)`},children:(0,D.jsx)(b,{})})]})]},e.key)})}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:c(`sub.roles.sync`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:c(`sub.roles.syncHint`)})]}),(0,D.jsx)(u,{on:w,onClick:()=>T(e=>!e),disabled:m,label:c(`sub.roles.sync`)})]}),(0,D.jsxs)(`div`,{className:`swi-save-row`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:P,disabled:m||V,"aria-label":c(`sub.roles.add`),title:c(V?`sub.roles.full`:`sub.roles.add`),children:[(0,D.jsx)(_,{style:{width:14,height:14}}),c(`sub.roles.add`)]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{B()},disabled:m,"aria-label":c(`sub.roles.save`),children:c(`sub.roles.save`)})]})]})}function B({available:e,chosen:n,busy:r=!1,onToggle:i,onMove:s,onSave:u,delegation:d,roles:f}){let m=t(),[h,g]=(0,E.useState)(``),v=(0,E.useMemo)(()=>new Set(n),[n]),x=n.length>=5,S=(0,E.useMemo)(()=>{let t=h.trim().toLowerCase();return e.filter(e=>!t||e.toLowerCase().includes(t))},[e,h]),k=(0,E.useMemo)(()=>[{id:`roles`,label:m(`sub.roles`)},{id:`featured`,label:m(`sub.featured`),meta:`${n.length}/5`},{id:`models`,label:m(`sub.models`),meta:String(S.length)},{id:`settings`,label:m(`sub.settings`)}],[m,n.length,S.length]);return(0,D.jsxs)(`div`,{className:`subagents-workspace-shell`,children:[(0,D.jsx)(w,{scope:`subagents`,items:k,ariaLabel:m(`sub.sections`)}),(0,D.jsxs)(`div`,{className:`subagents-workspace-root`,children:[(0,D.jsxs)(`section`,{id:C(`subagents`,`roles`),className:`subagents-workspace-section`,"aria-label":m(`sub.roles`),children:[(0,D.jsx)(`div`,{className:`swi-featured-head`,children:(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.roles`)})}),(0,D.jsx)(z,{apiBase:f.apiBase,available:d.available,efforts:d.efforts,multiAgentMode:f.multiAgentMode,keepNativeChatGptOnV1:f.keepNativeChatGptOnV1,onStatus:f.onStatus})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`featured`),className:`subagents-workspace-section`,"aria-label":m(`sub.featured`),children:[(0,D.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.featured`)}),(0,D.jsxs)(`span`,{className:`swi-featured-count`,children:[n.length,`/`,5]})]}),(0,D.jsxs)(`p`,{className:`swi-featured-hint`,children:[(0,D.jsx)(y,{width:15,height:15,"aria-hidden":`true`}),(0,D.jsx)(`span`,{children:(0,D.jsx)(o,{k:`sub.orderHint`,cmd:`spawn_agent`})})]}),n.length===0?(0,D.jsx)(`div`,{className:`swi-featured-empty`,children:m(`sub.noneSelected`)}):(0,D.jsx)(`div`,{className:`swi-featured-list`,children:n.map((e,t)=>(0,D.jsxs)(`div`,{className:`swi-featured-row`,children:[(0,D.jsx)(`span`,{className:`swi-featured-pos`,children:t+1}),(0,D.jsx)(`span`,{className:`swi-featured-name`,children:T(e)}),(0,D.jsxs)(`span`,{className:`swi-featured-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>s(t,-1),disabled:r||t===0,"aria-label":m(`sub.moveUp`,{m:e}),children:(0,D.jsx)(a,{})}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>s(t,1),disabled:r||t===n.length-1,"aria-label":m(`sub.moveDown`,{m:e}),children:(0,D.jsx)(p,{})}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(e),disabled:r,"aria-label":m(`sub.removeAria`,{m:e}),style:{color:`var(--red)`},children:(0,D.jsx)(b,{})})]})]},e))}),(0,D.jsx)(`div`,{className:`swi-save-row`,children:(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,disabled:r,children:m(`common.save`)})})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`models`),className:`subagents-workspace-section`,"aria-label":m(`sub.models`),children:[(0,D.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.models`)}),(0,D.jsx)(`span`,{className:`swi-featured-count`,children:S.length})]}),(0,D.jsxs)(`div`,{className:`swi-picker-box`,children:[(0,D.jsx)(`div`,{className:`subagents-workspace-rail-search`,children:(0,D.jsx)(`input`,{className:`input`,value:h,onChange:e=>g(e.target.value),placeholder:m(`sub.search`),"aria-label":m(`sub.search`)})}),(0,D.jsx)(`div`,{className:`subagents-workspace-rail-list`,children:S.length===0?(0,D.jsx)(`span`,{className:`subagents-workspace-rail-empty`,children:m(`sub.noModels`)}):S.map(e=>{let t=v.has(e),a=t?n.indexOf(e)+1:null,o=!t&&(x||r);return(0,D.jsxs)(`div`,{className:`subagents-workspace-rail-row${t?` subagents-workspace-rail-row--selected`:``}`,children:[(0,D.jsxs)(`span`,{className:`subagents-workspace-rail-row-main`,children:[(0,D.jsx)(`span`,{className:`swi-rail-priority`,children:a??``}),(0,D.jsx)(l,{className:`swi-rail-icon`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`subagents-workspace-rail-name`,children:T(e)})]}),(0,D.jsx)(`button`,{type:`button`,className:`subagents-workspace-rail-toggle${t?` subagents-workspace-rail-toggle--on`:``}${o?` subagents-workspace-rail-toggle--disabled`:``}`,onClick:()=>{o||i(e)},disabled:o,"aria-pressed":t,"aria-label":m(t?`sub.workspace.removeFromFeatured`:`sub.workspace.addToFeatured`,{m:e}),title:t?m(`sub.workspace.removeFromFeatured`,{m:e}):x?m(`sub.workspace.featuredFull`):m(`sub.workspace.addToFeatured`,{m:e}),children:t?(0,D.jsx)(c,{style:{width:14,height:14}}):(0,D.jsx)(_,{style:{width:14,height:14}})})]},e)})})]})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`settings`),className:`subagents-workspace-section`,"aria-label":m(`sub.settings`),children:[(0,D.jsx)(`div`,{className:`swi-featured-head`,children:(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.settings`)})}),(0,D.jsx)(O,{model:d.model,effort:d.effort,efforts:d.efforts,available:d.available,guidanceEnabled:d.guidanceEnabled,syncCodexDefaults:d.syncCodexDefaults,saving:d.saving,onSave:d.onSave,ultraMode:d.ultraMode,ultraSaving:d.ultraSaving,onUltraModeSave:d.onUltraModeSave,ultraLoadFailed:d.ultraLoadFailed,onUltraModeRetry:d.onUltraModeRetry,nativeParentOverride:d.nativeParentOverride,nativeParentOverrideSaving:d.nativeParentOverrideSaving,onNativeParentOverrideSave:d.onNativeParentOverrideSave,agentTaskRecovery:d.agentTaskRecovery,agentTaskRecoverySaving:d.agentTaskRecoverySaving,onAgentTaskRecoverySave:d.onAgentTaskRecoverySave,routedDelegationBridge:d.routedDelegationBridge,routedDelegationBridgeSaving:d.routedDelegationBridgeSaving,onRoutedDelegationBridgeSave:d.onRoutedDelegationBridgeSave,keepNativeChatGptOnV1:f.keepNativeChatGptOnV1,prompt:d.prompt,childInstructions:d.childInstructions,childInstructionsSaving:d.childInstructionsSaving,onChildInstructionsSave:d.onChildInstructionsSave})]})]})]})}function V(e){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)([]),[f,p]=(0,E.useState)([]),[h,_]=(0,E.useState)(!0),[v,y]=(0,E.useState)(!1),[b,x]=(0,E.useState)(``),S=(0,E.useCallback)(e=>{let t=m(e);_(t.multiAgentGuidanceEnabled),y(t.syncCodexSubagentDefaults),o(t.injectionModel),c(t.injectionEffort),`prompt`in e&&x(typeof e.prompt==`string`?e.prompt:``),Array.isArray(e.efforts)&&u(e.efforts),Array.isArray(e.available)&&p(e.available)},[]);return(0,E.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`${e}/api/injection-model`),r=await g(n);if(t)return;S(r)}catch{}finally{t||n(!0)}})(),()=>{t=!0}},[e,S]),{loaded:t,saving:r,model:a,effort:s,efforts:l,available:f,prompt:b,guidanceEnabled:h,syncCodexDefaults:v,save:(0,E.useCallback)(async t=>{if(r)return{ok:!1,error:``};i(!0);try{let n=await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});await d(n,`injection save failed`);let r=await fetch(`${e}/api/injection-model`);return S(await g(r)),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error&&e.message?e.message:`injection save failed`}}finally{i(!1)}},[e,S,r])}}function H(e){return v(e)}function U({apiBase:e}){let n=t(),r=`ocx.subagents.v1:${e}`,a=H(r),[o,s]=(0,E.useState)(()=>a?.chosen??[]),[c,l]=(0,E.useState)(``),[u,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),g=(0,E.useRef)(!1),_=V(e),[v,y]=(0,E.useState)({enabled:!1,hintText:null,multiAgentV2Enabled:!1}),[b,C]=(0,E.useState)({enabled:!1,model:null,active:!1}),[w,T]=(0,E.useState)({enabled:!1,model:null}),[O,k]=(0,E.useState)({enabled:!1}),[A,j]=(0,E.useState)(`default`),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(``),[I,L]=(0,E.useState)(!1),[R,z]=(0,E.useState)(!1),[U,ee]=(0,E.useState)(!1),W=(0,E.useRef)(!1),[te,G]=(0,E.useState)(!1),K=(0,E.useRef)(!1),q=(0,E.useRef)(!1),[ne,J]=(0,E.useState)(!1),[re,Y]=(0,E.useState)(!1),X=(0,E.useRef)(0),Z=(0,E.useRef)(e);(0,E.useEffect)(()=>{Z.current=e,X.current++},[e]);let Q=(0,E.useCallback)(async t=>{if(Z.current!==e)return!1;let r=++X.current,i=await fetch(`${e}/api/v2`,{signal:t}),a=await d(i,n(`sub.ultraModeLoadFail`));if(!a||t?.aborted||r!==X.current||Z.current!==e)return!1;Y(!1),j(a.multiAgentMode===`v1`||a.multiAgentMode===`v2`?a.multiAgentMode:`default`),N(a.keepNativeChatGptOnV1===!0),F(typeof a.subagentDeveloperInstructions==`string`?a.subagentDeveloperInstructions:``),y({enabled:a.enabled??!1,hintText:a.multiAgentModeHintText??null,multiAgentV2Enabled:a.enabled===!0&&a.multiAgentMode===`v2`});let o=a.v2NativeParentOverride;C({enabled:o?.enabled===!0,model:typeof o?.model==`string`?o.model:null,active:o?.active===!0});let s=a.agentTaskRecovery;return T({enabled:s?.enabled===!0,model:typeof s?.model==`string`?s.model:null}),k({enabled:a.v2RoutedDelegationBridge===!0}),!0},[e,n]);(0,E.useEffect)(()=>{let e=new AbortController;return(async()=>{await Q(e.signal)})().catch(()=>{e.signal.aborted||(f(!1),Y(!0),l(n(`sub.ultraModeLoadFail`)))}),()=>{e.abort()}},[Q,n]);let ie=async t=>{if(R)return;let r=e;z(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(await d(i,n(`sub.ultraModeSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.ultraModeSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{z(!1)}},ae=async t=>{if(W.current)return;W.current=!0;let r=e;ee(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({v2NativeParentOverride:{enabled:t.enabled,model:t.model}})});if(await d(i,n(`sub.nativeParentOverrideSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.nativeParentOverrideSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{W.current=!1,ee(!1)}},oe=async t=>{if(K.current)return;K.current=!0;let r=e;G(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentTaskRecovery:{enabled:t.enabled,model:t.model}})});if(await d(i,n(`sub.agentTaskRecoverySaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.agentTaskRecoverySaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{K.current=!1,G(!1)}},se=async t=>{if(q.current)return;q.current=!0;let r=e;J(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({v2RoutedDelegationBridge:t})});if(await d(i,n(`sub.routedDelegationBridgeSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.routedDelegationBridgeSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{q.current=!1,J(!1)}},ce=async t=>{if(I)return;let r=e;L(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({subagentDeveloperInstructions:t})});if(await d(i,n(`sub.childInstructionsSaveFailed`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.childInstructionsSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{L(!1)}},le=(0,E.useCallback)(async()=>{try{if(!await Q())return;f(!1),l(e=>e===n(`sub.ultraModeLoadFail`)?``:e)}catch{f(!1),Y(!0),l(n(`sub.ultraModeLoadFail`))}},[Q,n]),ue=(0,E.useCallback)(async t=>{let i=await fetch(`${e}/api/subagent-models`,{signal:t}),a=await d(i,n(`sub.loadFail`));if(!a)throw Error(n(`sub.loadFail`));let o=a.available??[],c=new Set(o),l={available:o,chosen:(a.chosen??[]).filter(e=>c.has(e))};return s(l.chosen),h(r,l),l},[e,r,n]),de=x(r,[e],ue,{isEmpty:()=>!1,initialData:a??void 0}),{state:$}=de,fe=de.refresh,pe=$.data??a,me=pe?.available??[],he=e=>{p||(l(``),s(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=5?t:[...t,e]))},ge=(e,t)=>{p||s(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r)})},_e=(0,E.useCallback)((e,t)=>{f(e),l(t)},[]),ve=async()=>{if(!(p||g.current)){g.current=!0,m(!0),l(``);try{let t=await fetch(`${e}/api/subagent-models`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:o})}),i=await d(t,n(`sub.saveFailed`)),a=i?.applied??o;i?.applied&&s(i.applied),h(r,{available:me,chosen:a}),f(!0),l(n(`sub.saved`,{n:a.length,cmd:`ocx sync`}))}catch(e){f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{g.current=!1,m(!1)}}};if($.showSkeleton&&!pe)return(0,D.jsx)(S,{label:n(`sub.loading`),rows:4});if($.kind===`failed-cold`){let e=$.error instanceof Error?$.error.message:n(`sub.loadFail`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(i,{tone:`err`,children:e}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>fe(),children:n(`common.retry`)})]})}return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`page-head`,children:(0,D.jsx)(`h2`,{children:n(`nav.subagents`)})}),c&&(0,D.jsx)(i,{tone:u?`ok`:`err`,children:c}),$.showError&&(0,D.jsx)(i,{tone:`err`,children:n(`sub.loadFail`)}),(0,D.jsx)(B,{available:me,chosen:o,busy:p,onToggle:he,onMove:ge,onSave:()=>{ve()},delegation:{model:_.model,effort:_.effort,efforts:_.efforts,available:_.available,guidanceEnabled:_.guidanceEnabled,syncCodexDefaults:_.syncCodexDefaults,saving:_.saving,onSave:e=>{(async()=>{let t=await _.save(e);`prompt`in e&&(t.ok?(f(!0),l(n(`sub.injectionPromptSaved`))):(f(!1),l(t.error||n(`sub.injectionPromptSaveFailed`))))})()},ultraMode:v,ultraSaving:R,onUltraModeSave:e=>{ie(e)},ultraLoadFailed:re,onUltraModeRetry:()=>{le()},nativeParentOverride:b,nativeParentOverrideSaving:U,onNativeParentOverrideSave:e=>{ae(e)},agentTaskRecovery:w,agentTaskRecoverySaving:te,onAgentTaskRecoverySave:e=>{oe(e)},routedDelegationBridge:O,routedDelegationBridgeSaving:ne,onRoutedDelegationBridgeSave:e=>{se(e)},prompt:_.prompt,childInstructions:P,childInstructionsSaving:I,onChildInstructionsSave:e=>{ce(e)}},roles:{apiBase:e,multiAgentMode:A,keepNativeChatGptOnV1:M,onStatus:_e}})]})}export{U as default};
|
|
1
|
+
import{_ as e,c as t,h as n,m as r}from"./shared-p0R307IX.js";import{F as i,G as a,H as o,I as s,J as c,K as l,L as u,N as d,S as f,W as p,d as m,h,k as g,lt as _,p as v,tt as y,yt as b}from"./index-DE4QGJSt.js";import{t as x}from"./data-surface-BzhqUIJ_.js";import{t as S}from"./data-surface-D8RXShV2.js";import{n as C,t as w}from"./section-tabs-DEASco68.js";import{t as T}from"./model-display-CCqxubZd.js";var E=e(n(),1),D=r();function O({model:e,effort:n,efforts:r,available:i,guidanceEnabled:a,syncCodexDefaults:o,saving:c,onSave:l,prompt:d,childInstructions:p,childInstructionsSaving:m,onChildInstructionsSave:h,ultraMode:g,ultraSaving:_,onUltraModeSave:v,ultraLoadFailed:y,onUltraModeRetry:b,keepNativeChatGptOnV1:x=!1,nativeParentOverride:S={enabled:!1,model:null,active:!1},nativeParentOverrideSaving:C=!1,onNativeParentOverrideSave:w=()=>{},agentTaskRecovery:T={enabled:!1,model:null},agentTaskRecoverySaving:E=!1,onAgentTaskRecoverySave:O=()=>{},routedDelegationBridge:M={enabled:!1},routedDelegationBridgeSaving:N=!1,onRoutedDelegationBridgeSave:P=()=>{}}){let F=t(),I=(g.hintText??``).trim().length>0,L=i.filter(e=>e.canonical!==!0),R=g.multiAgentV2Enabled&&!x&&S.model!==null;return(0,D.jsxs)(`div`,{className:`swi-delegation`,children:[y&&(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.ultraMode`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeLoadFail`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:b,children:F(`common.retry`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.routedDelegationBridge`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.routedDelegationBridgeHint`)})]}),(0,D.jsx)(u,{on:M.enabled,onClick:()=>P(!M.enabled),disabled:N,label:F(`sub.routedDelegationBridge`)}),!g.multiAgentV2Enabled&&M.enabled&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.routedDelegationBridgeInactive`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.delegation.model`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.delegation.modelHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(s,{value:e,options:[{value:``,label:F(`dash.injectionNone`)},...i.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,F)}))],onChange:e=>l({model:e||null,effort:n||null}),disabled:c,label:F(`dash.injectionLabel`),align:`right`}),e&&r.length>0&&(0,D.jsx)(s,{value:n,options:[{value:``,label:F(`dash.injectionEffortNone`)},...r.map(e=>({value:e,label:e}))],onChange:t=>l({model:e||null,effort:t||null}),disabled:c,label:F(`dash.injectionEffortLabel`),align:`right`})]})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`dash.syncCodexSubagentDefaults`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`dash.syncCodexSubagentDefaultsHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${o?`on`:``}`,onClick:()=>l({syncCodexSubagentDefaults:!o}),disabled:c||!e,"aria-label":F(`dash.syncCodexSubagentDefaults`),"aria-pressed":o,children:(0,D.jsx)(`span`,{className:`knob`})})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`dash.multiAgentGuidance`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`dash.multiAgentGuidanceHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${a?`on`:``}`,onClick:()=>l({multiAgentGuidanceEnabled:!a}),disabled:c,"aria-label":F(`dash.multiAgentGuidance`),"aria-pressed":a,children:(0,D.jsx)(`span`,{className:`knob`})})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.ultraMode`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeHint`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`switch ${I?`on`:``}`,onClick:()=>v({multiAgentModeHintText:I?null:A}),disabled:c||_||!I&&!g.multiAgentV2Enabled,"aria-label":F(`sub.ultraMode`),"aria-pressed":I,children:(0,D.jsx)(`span`,{className:`knob`})}),!g.multiAgentV2Enabled&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.ultraModeV2Required`)})]}),I&&(0,D.jsx)(`div`,{className:`swi-delegation-row swi-ultra-mode-editor`,children:(0,D.jsx)(k,{initialHint:g.hintText??``,disabled:c||_,onSave:v,preset:`Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning sub-agents no longer applies. Delegate independent sub-tasks to sub-agents whenever parallel work would materially improve speed or quality — do not serialize work that can run concurrently. Each sub-agent runs in its own context and can use all available tools; prefer spawning specialists over doing everything yourself. This mode remains active until a later multi-agent mode developer message changes it.`,labels:{text:F(`sub.ultraModeText`),preset:F(`sub.ultraModePreset`),save:F(`common.save`)}},g.hintText)}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.nativeParentOverride`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverrideHint`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverridePrivacyWarning`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(s,{value:S.model??``,options:[{value:``,label:F(`dash.injectionNone`)},...L.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,F)}))],onChange:e=>w({enabled:e?S.enabled:!1,model:e||null,active:S.active}),disabled:C,label:F(`sub.nativeParentOverrideModel`),align:`right`}),(0,D.jsx)(u,{on:S.enabled,onClick:()=>w({enabled:!S.enabled,model:S.model,active:S.active}),disabled:C||!S.enabled&&!R,label:F(`sub.nativeParentOverride`)})]}),!R&&!S.active&&(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.nativeParentOverrideV2Required`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.agentTaskRecovery`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.agentTaskRecoveryHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-controls`,children:[(0,D.jsx)(`input`,{type:`text`,className:`input input-sm`,style:{width:180,textAlign:`right`},placeholder:`gpt-5.6-luna`,value:T.model??``,onChange:e=>{let t=e.target.value.trim();O({enabled:T.enabled,model:t.length>0?t:null})},disabled:E,"aria-label":F(`sub.agentTaskRecoveryModel`)}),(0,D.jsx)(u,{on:T.enabled,onClick:()=>O({enabled:!T.enabled,model:T.model}),disabled:E,label:F(`sub.agentTaskRecovery`)})]})]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row swi-prompt-editor`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.injectionPrompt`)}),(0,D.jsxs)(`div`,{className:`muted setting-hint`,children:[F(`sub.injectionPromptHint`),` `,(0,D.jsx)(`code`,{children:`{{model}}`}),` `,(0,D.jsx)(`code`,{children:`{{effort}}`}),` `,(0,D.jsx)(`code`,{children:`{{roster}}`}),` `,(0,D.jsx)(`code`,{children:`{{fallback}}`}),` `,(0,D.jsx)(`code`,{children:`{{roles}}`})]})]}),(0,D.jsx)(j,{initialValue:d,disabled:c,ariaLabel:F(`sub.injectionPrompt`),saveLabel:F(`sub.injectionPromptSave`),onSave:e=>l({prompt:e.trim()?e:null})},`prompt:${d}`)]}),(0,D.jsxs)(`div`,{className:`swi-delegation-row swi-prompt-editor`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:F(`sub.childInstructions`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:F(`sub.childInstructionsHint`)})]}),(0,D.jsx)(j,{initialValue:p,disabled:c||m,ariaLabel:F(`sub.childInstructions`),saveLabel:F(`sub.childInstructionsSave`),onSave:e=>h(e.trim()?e:null)},`child:${p}`)]})]})}function k({initialHint:e,disabled:t,onSave:n,preset:r,labels:i}){let[a,o]=(0,E.useState)(e);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`textarea`,{className:`input swi-ultra-mode-textarea`,value:a,onChange:e=>o(e.target.value),disabled:t,rows:4,"aria-label":i.text}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>o(r),disabled:t,children:i.preset}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>{a.trim().length!==0&&n({multiAgentModeHintText:a})},disabled:t||a.trim().length===0,children:i.save})]})}var A=`Proactive multi-agent delegation is active. Any earlier instruction requiring an explicit user request before spawning sub-agents no longer applies. Delegate independent sub-tasks to sub-agents whenever parallel work would materially improve speed or quality — do not serialize work that can run concurrently. Each sub-agent runs in its own context and can use all available tools; prefer spawning specialists over doing everything yourself. This mode remains active until a later multi-agent mode developer message changes it.`;function j({initialValue:e,disabled:t,ariaLabel:n,saveLabel:r,onSave:i}){let[a,o]=(0,E.useState)(e);return(0,D.jsxs)(`div`,{className:`swi-prompt-draft`,children:[(0,D.jsx)(`textarea`,{className:`input swi-ultra-mode-textarea`,value:a,onChange:e=>o(e.target.value),disabled:t,rows:4,"aria-label":n}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary btn-sm`,onClick:()=>i(a),disabled:t,"aria-label":r,children:r})]})}var M=8,N=0;function P(){return N+=1,`role-${N}`}function F(e){return{key:P(),id:``,description:``,model:e,effort:``,developerInstructions:``,enabled:!0}}function I(e,t){if(e.indexOf(`/`)<=0)return!1;let n=t.find(t=>t.namespaced===e);return!n||n.provider!==`openai`}function L(e){return{id:e.id.trim(),description:e.description,model:e.model,...e.effort?{effort:e.effort}:{},developerInstructions:e.developerInstructions,enabled:e.enabled}}function R(e,t){return{key:P(),id:typeof e.id==`string`?e.id:``,description:typeof e.description==`string`?e.description:``,model:typeof e.model==`string`?e.model:t,effort:typeof e.effort==`string`?e.effort:``,developerInstructions:typeof e.developerInstructions==`string`?e.developerInstructions:``,enabled:e.enabled!==!1}}function z({apiBase:e,available:n,efforts:r,multiAgentMode:i,keepNativeChatGptOnV1:a,onStatus:o}){let c=t(),[l,p]=(0,E.useState)([]),[m,h]=(0,E.useState)(!1),[g,v]=(0,E.useState)(n),[y,x]=(0,E.useState)(r),[S,C]=(0,E.useState)(void 0),[w,T]=(0,E.useState)(!1),O=(0,E.useRef)(!1),k=g[0]?.namespaced??n[0]?.namespaced??``,A=g.length>0?g:n,j=y.length>0?y:r;(0,E.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`${e}/api/subagent-roles`),r=await d(n,c(`sub.roles.loadFail`));if(t||!r)return;p(Array.isArray(r.roles)?r.roles.map(e=>R(e,``)):[]),Array.isArray(r.available)&&v(r.available),Array.isArray(r.efforts)&&x(r.efforts);let i=typeof r.syncCodexAgentRoles==`boolean`?r.syncCodexAgentRoles:void 0,a=r.syncCodexAgentRolesEffective===!0;C(i),T(a),O.current=a}catch{t||o(!1,c(`sub.roles.loadFail`))}})(),()=>{t=!0}},[e,c,o]);let N=(e,t)=>{p(n=>n.map((n,r)=>r===e?{...n,...t}:n))},P=()=>{p(e=>e.length>=M?e:[...e,F(k)])},z=e=>{p(t=>t.filter((t,n)=>n!==e))},B=async()=>{if(!m){h(!0);try{let t={roles:l.map(L)};(S!==void 0||w!==O.current)&&(t.syncCodexAgentRoles=w);let n=await fetch(`${e}/api/subagent-roles`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await d(n,c(`sub.roles.saveFailed`));if(Array.isArray(r?.roles)&&p(r.roles.map(e=>R(e,k))),r&&typeof r.syncCodexAgentRoles==`boolean`?C(r.syncCodexAgentRoles):r&&!(`syncCodexAgentRoles`in r)&&C(void 0),r){let e=r.syncCodexAgentRolesEffective===!0;T(e),O.current=e}let i=(r?.warnings??[]).filter(e=>typeof e==`string`&&e.trim());o(!0,i.length>0?[c(`sub.roles.saved`),...i].join(` `):c(`sub.roles.saved`))}catch(e){o(!1,e instanceof Error&&e.message?e.message:c(`sub.roles.saveFailed`))}finally{h(!1)}}},V=l.length>=M,H=i===`v2`&&!a;return(0,D.jsxs)(`div`,{className:`swi-roles`,children:[(0,D.jsx)(`p`,{className:`swi-featured-hint`,children:(0,D.jsx)(`span`,{children:c(`sub.roles.hint`)})}),l.length===0?(0,D.jsx)(`div`,{className:`swi-featured-empty`,children:c(`sub.roles.empty`)}):(0,D.jsx)(`div`,{className:`swi-roles-list`,children:l.map((e,t)=>{let n=H&&e.enabled&&I(e.model,A);return(0,D.jsxs)(`div`,{className:`swi-role-card`,children:[(0,D.jsxs)(`div`,{className:`swi-role-grid`,children:[(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.id`)}),(0,D.jsx)(`input`,{className:`input`,type:`text`,value:e.id,onChange:e=>N(t,{id:e.currentTarget.value}),"aria-label":c(`sub.roles.id`),disabled:m})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.model`)}),(0,D.jsx)(s,{value:e.model,options:A.map(e=>({value:e.namespaced,label:f(`${e.provider}/${e.model}`,c)})),onChange:e=>N(t,{model:e}),disabled:m||A.length===0,label:c(`sub.roles.model`),align:`right`})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.effort`)}),(0,D.jsx)(s,{value:e.effort,options:[{value:``,label:c(`sub.roles.effortNone`)},...j.map(e=>({value:e,label:e}))],onChange:e=>N(t,{effort:e}),disabled:m,label:c(`sub.roles.effort`),align:`right`})]})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.description`)}),(0,D.jsx)(`input`,{className:`input`,type:`text`,value:e.description,onChange:e=>N(t,{description:e.currentTarget.value}),"aria-label":c(`sub.roles.description`),disabled:m}),(0,D.jsx)(`span`,{className:`muted setting-hint`,children:c(`sub.roles.descriptionHint`)})]}),(0,D.jsxs)(`div`,{className:`swi-role-field`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.instructions`)}),(0,D.jsx)(`textarea`,{className:`input swi-role-instructions`,value:e.developerInstructions,onChange:e=>N(t,{developerInstructions:e.currentTarget.value}),"aria-label":c(`sub.roles.instructions`),rows:4,disabled:m}),(0,D.jsx)(`span`,{className:`muted setting-hint`,children:c(`sub.roles.instructionsHint`)})]}),n&&(0,D.jsx)(`div`,{className:`muted setting-hint`,role:`status`,children:c(`sub.roles.routedV2Warning`)}),(0,D.jsxs)(`div`,{className:`swi-role-footer`,children:[(0,D.jsxs)(`div`,{className:`swi-role-enable`,children:[(0,D.jsx)(`span`,{className:`swi-role-label`,children:c(`sub.roles.enabled`)}),(0,D.jsx)(u,{on:e.enabled,onClick:()=>N(t,{enabled:!e.enabled}),disabled:m,label:c(`sub.roles.enabled`)})]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>z(t),disabled:m,"aria-label":c(`sub.roles.delete`,{id:e.id||String(t+1)}),style:{color:`var(--red)`},children:(0,D.jsx)(b,{})})]})]},e.key)})}),(0,D.jsxs)(`div`,{className:`swi-delegation-row`,children:[(0,D.jsxs)(`div`,{className:`setting-copy`,children:[(0,D.jsx)(`div`,{className:`font-semibold`,children:c(`sub.roles.sync`)}),(0,D.jsx)(`div`,{className:`muted setting-hint`,children:c(`sub.roles.syncHint`)})]}),(0,D.jsx)(u,{on:w,onClick:()=>T(e=>!e),disabled:m,label:c(`sub.roles.sync`)})]}),(0,D.jsxs)(`div`,{className:`swi-save-row`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`btn btn-ghost`,onClick:P,disabled:m||V,"aria-label":c(`sub.roles.add`),title:c(V?`sub.roles.full`:`sub.roles.add`),children:[(0,D.jsx)(_,{style:{width:14,height:14}}),c(`sub.roles.add`)]}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:()=>{B()},disabled:m,"aria-label":c(`sub.roles.save`),children:c(`sub.roles.save`)})]})]})}function B({available:e,chosen:n,busy:r=!1,onToggle:i,onMove:s,onSave:u,delegation:d,roles:f}){let m=t(),[h,g]=(0,E.useState)(``),v=(0,E.useMemo)(()=>new Set(n),[n]),x=n.length>=5,S=(0,E.useMemo)(()=>{let t=h.trim().toLowerCase();return e.filter(e=>!t||e.toLowerCase().includes(t))},[e,h]),k=(0,E.useMemo)(()=>[{id:`roles`,label:m(`sub.roles`)},{id:`featured`,label:m(`sub.featured`),meta:`${n.length}/5`},{id:`models`,label:m(`sub.models`),meta:String(S.length)},{id:`settings`,label:m(`sub.settings`)}],[m,n.length,S.length]);return(0,D.jsxs)(`div`,{className:`subagents-workspace-shell`,children:[(0,D.jsx)(w,{scope:`subagents`,items:k,ariaLabel:m(`sub.sections`)}),(0,D.jsxs)(`div`,{className:`subagents-workspace-root`,children:[(0,D.jsxs)(`section`,{id:C(`subagents`,`roles`),className:`subagents-workspace-section`,"aria-label":m(`sub.roles`),children:[(0,D.jsx)(`div`,{className:`swi-featured-head`,children:(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.roles`)})}),(0,D.jsx)(z,{apiBase:f.apiBase,available:d.available,efforts:d.efforts,multiAgentMode:f.multiAgentMode,keepNativeChatGptOnV1:f.keepNativeChatGptOnV1,onStatus:f.onStatus})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`featured`),className:`subagents-workspace-section`,"aria-label":m(`sub.featured`),children:[(0,D.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.featured`)}),(0,D.jsxs)(`span`,{className:`swi-featured-count`,children:[n.length,`/`,5]})]}),(0,D.jsxs)(`p`,{className:`swi-featured-hint`,children:[(0,D.jsx)(y,{width:15,height:15,"aria-hidden":`true`}),(0,D.jsx)(`span`,{children:(0,D.jsx)(o,{k:`sub.orderHint`,cmd:`spawn_agent`})})]}),n.length===0?(0,D.jsx)(`div`,{className:`swi-featured-empty`,children:m(`sub.noneSelected`)}):(0,D.jsx)(`div`,{className:`swi-featured-list`,children:n.map((e,t)=>(0,D.jsxs)(`div`,{className:`swi-featured-row`,children:[(0,D.jsx)(`span`,{className:`swi-featured-pos`,children:t+1}),(0,D.jsx)(`span`,{className:`swi-featured-name`,children:T(e)}),(0,D.jsxs)(`span`,{className:`swi-featured-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>s(t,-1),disabled:r||t===0,"aria-label":m(`sub.moveUp`,{m:e}),children:(0,D.jsx)(a,{})}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>s(t,1),disabled:r||t===n.length-1,"aria-label":m(`sub.moveDown`,{m:e}),children:(0,D.jsx)(p,{})}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-icon btn-sm`,onClick:()=>i(e),disabled:r,"aria-label":m(`sub.removeAria`,{m:e}),style:{color:`var(--red)`},children:(0,D.jsx)(b,{})})]})]},e))}),(0,D.jsx)(`div`,{className:`swi-save-row`,children:(0,D.jsx)(`button`,{type:`button`,className:`btn btn-primary`,onClick:u,disabled:r,children:m(`common.save`)})})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`models`),className:`subagents-workspace-section`,"aria-label":m(`sub.models`),children:[(0,D.jsxs)(`div`,{className:`swi-featured-head`,children:[(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.models`)}),(0,D.jsx)(`span`,{className:`swi-featured-count`,children:S.length})]}),(0,D.jsxs)(`div`,{className:`swi-picker-box`,children:[(0,D.jsx)(`div`,{className:`subagents-workspace-rail-search`,children:(0,D.jsx)(`input`,{className:`input`,value:h,onChange:e=>g(e.target.value),placeholder:m(`sub.search`),"aria-label":m(`sub.search`)})}),(0,D.jsx)(`div`,{className:`subagents-workspace-rail-list`,children:S.length===0?(0,D.jsx)(`span`,{className:`subagents-workspace-rail-empty`,children:m(`sub.noModels`)}):S.map(e=>{let t=v.has(e),a=t?n.indexOf(e)+1:null,o=!t&&(x||r);return(0,D.jsxs)(`div`,{className:`subagents-workspace-rail-row${t?` subagents-workspace-rail-row--selected`:``}`,children:[(0,D.jsxs)(`span`,{className:`subagents-workspace-rail-row-main`,children:[(0,D.jsx)(`span`,{className:`swi-rail-priority`,children:a??``}),(0,D.jsx)(l,{className:`swi-rail-icon`,"aria-hidden":`true`}),(0,D.jsx)(`span`,{className:`subagents-workspace-rail-name`,children:T(e)})]}),(0,D.jsx)(`button`,{type:`button`,className:`subagents-workspace-rail-toggle${t?` subagents-workspace-rail-toggle--on`:``}${o?` subagents-workspace-rail-toggle--disabled`:``}`,onClick:()=>{o||i(e)},disabled:o,"aria-pressed":t,"aria-label":m(t?`sub.workspace.removeFromFeatured`:`sub.workspace.addToFeatured`,{m:e}),title:t?m(`sub.workspace.removeFromFeatured`,{m:e}):x?m(`sub.workspace.featuredFull`):m(`sub.workspace.addToFeatured`,{m:e}),children:t?(0,D.jsx)(c,{style:{width:14,height:14}}):(0,D.jsx)(_,{style:{width:14,height:14}})})]},e)})})]})]}),(0,D.jsxs)(`section`,{id:C(`subagents`,`settings`),className:`subagents-workspace-section`,"aria-label":m(`sub.settings`),children:[(0,D.jsx)(`div`,{className:`swi-featured-head`,children:(0,D.jsx)(`h2`,{className:`swi-featured-title`,children:m(`sub.settings`)})}),(0,D.jsx)(O,{model:d.model,effort:d.effort,efforts:d.efforts,available:d.available,guidanceEnabled:d.guidanceEnabled,syncCodexDefaults:d.syncCodexDefaults,saving:d.saving,onSave:d.onSave,ultraMode:d.ultraMode,ultraSaving:d.ultraSaving,onUltraModeSave:d.onUltraModeSave,ultraLoadFailed:d.ultraLoadFailed,onUltraModeRetry:d.onUltraModeRetry,nativeParentOverride:d.nativeParentOverride,nativeParentOverrideSaving:d.nativeParentOverrideSaving,onNativeParentOverrideSave:d.onNativeParentOverrideSave,agentTaskRecovery:d.agentTaskRecovery,agentTaskRecoverySaving:d.agentTaskRecoverySaving,onAgentTaskRecoverySave:d.onAgentTaskRecoverySave,routedDelegationBridge:d.routedDelegationBridge,routedDelegationBridgeSaving:d.routedDelegationBridgeSaving,onRoutedDelegationBridgeSave:d.onRoutedDelegationBridgeSave,keepNativeChatGptOnV1:f.keepNativeChatGptOnV1,prompt:d.prompt,childInstructions:d.childInstructions,childInstructionsSaving:d.childInstructionsSaving,onChildInstructionsSave:d.onChildInstructionsSave})]})]})]})}function V(e){let[t,n]=(0,E.useState)(!1),[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(``),[s,c]=(0,E.useState)(``),[l,u]=(0,E.useState)([]),[f,p]=(0,E.useState)([]),[h,_]=(0,E.useState)(!0),[v,y]=(0,E.useState)(!1),[b,x]=(0,E.useState)(``),S=(0,E.useCallback)(e=>{let t=m(e);_(t.multiAgentGuidanceEnabled),y(t.syncCodexSubagentDefaults),o(t.injectionModel),c(t.injectionEffort),`prompt`in e&&x(typeof e.prompt==`string`?e.prompt:``),Array.isArray(e.efforts)&&u(e.efforts),Array.isArray(e.available)&&p(e.available)},[]);return(0,E.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await fetch(`${e}/api/injection-model`),r=await g(n);if(t)return;S(r)}catch{}finally{t||n(!0)}})(),()=>{t=!0}},[e,S]),{loaded:t,saving:r,model:a,effort:s,efforts:l,available:f,prompt:b,guidanceEnabled:h,syncCodexDefaults:v,save:(0,E.useCallback)(async t=>{if(r)return{ok:!1,error:``};i(!0);try{let n=await fetch(`${e}/api/injection-model`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});await d(n,`injection save failed`);let r=await fetch(`${e}/api/injection-model`);return S(await g(r)),{ok:!0}}catch(e){return{ok:!1,error:e instanceof Error&&e.message?e.message:`injection save failed`}}finally{i(!1)}},[e,S,r])}}function H(e){return v(e)}function U({apiBase:e}){let n=t(),r=`ocx.subagents.v1:${e}`,a=H(r),[o,s]=(0,E.useState)(()=>a?.chosen??[]),[c,l]=(0,E.useState)(``),[u,f]=(0,E.useState)(!1),[p,m]=(0,E.useState)(!1),g=(0,E.useRef)(!1),_=V(e),[v,y]=(0,E.useState)({enabled:!1,hintText:null,multiAgentV2Enabled:!1}),[b,C]=(0,E.useState)({enabled:!1,model:null,active:!1}),[w,T]=(0,E.useState)({enabled:!1,model:null}),[O,k]=(0,E.useState)({enabled:!1}),[A,j]=(0,E.useState)(`default`),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(``),[I,L]=(0,E.useState)(!1),[R,z]=(0,E.useState)(!1),[U,ee]=(0,E.useState)(!1),W=(0,E.useRef)(!1),[te,G]=(0,E.useState)(!1),K=(0,E.useRef)(!1),q=(0,E.useRef)(!1),[ne,J]=(0,E.useState)(!1),[re,Y]=(0,E.useState)(!1),X=(0,E.useRef)(0),Z=(0,E.useRef)(e);(0,E.useEffect)(()=>{Z.current=e,X.current++},[e]);let Q=(0,E.useCallback)(async t=>{if(Z.current!==e)return!1;let r=++X.current,i=await fetch(`${e}/api/v2`,{signal:t}),a=await d(i,n(`sub.ultraModeLoadFail`));if(!a||t?.aborted||r!==X.current||Z.current!==e)return!1;Y(!1),j(a.multiAgentMode===`v1`||a.multiAgentMode===`v2`?a.multiAgentMode:`default`),N(a.keepNativeChatGptOnV1===!0),F(typeof a.subagentDeveloperInstructions==`string`?a.subagentDeveloperInstructions:``),y({enabled:a.enabled??!1,hintText:a.multiAgentModeHintText??null,multiAgentV2Enabled:a.enabled===!0&&a.multiAgentMode===`v2`});let o=a.v2NativeParentOverride;C({enabled:o?.enabled===!0,model:typeof o?.model==`string`?o.model:null,active:o?.active===!0});let s=a.agentTaskRecovery;return T({enabled:s?.enabled===!0,model:typeof s?.model==`string`?s.model:null}),k({enabled:a.v2RoutedDelegationBridge===!0}),!0},[e,n]);(0,E.useEffect)(()=>{let e=new AbortController;return(async()=>{await Q(e.signal)})().catch(()=>{e.signal.aborted||(f(!1),Y(!0),l(n(`sub.ultraModeLoadFail`)))}),()=>{e.abort()}},[Q,n]);let ie=async t=>{if(R)return;let r=e;z(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(await d(i,n(`sub.ultraModeSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.ultraModeSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{z(!1)}},ae=async t=>{if(W.current)return;W.current=!0;let r=e;ee(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({v2NativeParentOverride:{enabled:t.enabled,model:t.model}})});if(await d(i,n(`sub.nativeParentOverrideSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.nativeParentOverrideSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{W.current=!1,ee(!1)}},oe=async t=>{if(K.current)return;K.current=!0;let r=e;G(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentTaskRecovery:{enabled:t.enabled,model:t.model}})});if(await d(i,n(`sub.agentTaskRecoverySaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.agentTaskRecoverySaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{K.current=!1,G(!1)}},se=async t=>{if(q.current)return;q.current=!0;let r=e;J(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({v2RoutedDelegationBridge:t})});if(await d(i,n(`sub.routedDelegationBridgeSaveFail`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.routedDelegationBridgeSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{q.current=!1,J(!1)}},ce=async t=>{if(I)return;let r=e;L(!0),l(``);try{let i=await fetch(`${e}/api/v2`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({subagentDeveloperInstructions:t})});if(await d(i,n(`sub.childInstructionsSaveFailed`)),Z.current!==r||!await Q())return;f(!0),l(n(`sub.childInstructionsSaved`))}catch(e){if(Z.current!==r)return;f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{L(!1)}},le=(0,E.useCallback)(async()=>{try{if(!await Q())return;f(!1),l(e=>e===n(`sub.ultraModeLoadFail`)?``:e)}catch{f(!1),Y(!0),l(n(`sub.ultraModeLoadFail`))}},[Q,n]),ue=(0,E.useCallback)(async t=>{let i=await fetch(`${e}/api/subagent-models`,{signal:t}),a=await d(i,n(`sub.loadFail`));if(!a)throw Error(n(`sub.loadFail`));let o=a.available??[],c=new Set(o),l={available:o,chosen:(a.chosen??[]).filter(e=>c.has(e))};return s(l.chosen),h(r,l),l},[e,r,n]),de=x(r,[e],ue,{isEmpty:()=>!1,initialData:a??void 0}),{state:$}=de,fe=de.refresh,pe=$.data??a,me=pe?.available??[],he=e=>{p||(l(``),s(t=>t.includes(e)?t.filter(t=>t!==e):t.length>=5?t:[...t,e]))},ge=(e,t)=>{p||s(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r)})},_e=(0,E.useCallback)((e,t)=>{f(e),l(t)},[]),ve=async()=>{if(!(p||g.current)){g.current=!0,m(!0),l(``);try{let t=await fetch(`${e}/api/subagent-models`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({models:o})}),i=await d(t,n(`sub.saveFailed`)),a=i?.applied??o;i?.applied&&s(i.applied),h(r,{available:me,chosen:a}),f(!0),l(n(`sub.saved`,{n:a.length,cmd:`ocx sync`}))}catch(e){f(!1),l(e instanceof Error&&e.message?e.message:n(`sub.networkError`))}finally{g.current=!1,m(!1)}}};if($.showSkeleton&&!pe)return(0,D.jsx)(S,{label:n(`sub.loading`),rows:4});if($.kind===`failed-cold`){let e=$.error instanceof Error?$.error.message:n(`sub.loadFail`);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(i,{tone:`err`,children:e}),(0,D.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>fe(),children:n(`common.retry`)})]})}return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`page-head`,children:(0,D.jsx)(`h2`,{children:n(`nav.subagents`)})}),c&&(0,D.jsx)(i,{tone:u?`ok`:`err`,children:c}),$.showError&&(0,D.jsx)(i,{tone:`err`,children:n(`sub.loadFail`)}),(0,D.jsx)(B,{available:me,chosen:o,busy:p,onToggle:he,onMove:ge,onSave:()=>{ve()},delegation:{model:_.model,effort:_.effort,efforts:_.efforts,available:_.available,guidanceEnabled:_.guidanceEnabled,syncCodexDefaults:_.syncCodexDefaults,saving:_.saving,onSave:e=>{(async()=>{let t=await _.save(e);`prompt`in e&&(t.ok?(f(!0),l(n(`sub.injectionPromptSaved`))):(f(!1),l(t.error||n(`sub.injectionPromptSaveFailed`))))})()},ultraMode:v,ultraSaving:R,onUltraModeSave:e=>{ie(e)},ultraLoadFailed:re,onUltraModeRetry:()=>{le()},nativeParentOverride:b,nativeParentOverrideSaving:U,onNativeParentOverrideSave:e=>{ae(e)},agentTaskRecovery:w,agentTaskRecoverySaving:te,onAgentTaskRecoverySave:e=>{oe(e)},routedDelegationBridge:O,routedDelegationBridgeSaving:ne,onRoutedDelegationBridgeSave:e=>{se(e)},prompt:_.prompt,childInstructions:P,childInstructionsSaving:I,onChildInstructionsSave:e=>{ce(e)}},roles:{apiBase:e,multiAgentMode:A,keepNativeChatGptOnV1:M,onStatus:_e}})]})}export{U as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,h as t,m as n,s as r}from"./shared-p0R307IX.js";import{C as i,F as a,P as o,St as s,b as c,h as l,p as u,x as d,y as f}from"./index-CEcmjvjC.js";import{t as p}from"./data-surface-Cq2fDI2w.js";import{t as m}from"./data-surface-D8RXShV2.js";import{n as h,t as g}from"./section-tabs-DEASco68.js";import{t as _}from"./model-display-CTtXLqIv.js";import{r as v}from"./intl-formatters-CTcuZoAe.js";var y=e(t(),1),b=s(),x=n();function S(e){return`${Math.round(e*100)}%`}function C(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function w(e){let t=new Map(e.map(e=>[e.date,e]));return f(e,7).map(e=>({...e,models:t.get(e.date)?.models??[]}))}function T(e){let t=window.innerWidth,n=window.innerHeight,r=Math.min(240,Math.max(0,t-16));return{left:Math.max(8,Math.min(e.left+e.width/2-r/2,t-8-r)),maxWidth:r,...e.top-8>n-e.bottom-8?(()=>{let t=Math.max(8,Math.min(n-8,n-e.top+8));return{bottom:t,maxHeight:Math.max(0,n-t-8)}})():(()=>{let t=Math.max(8,Math.min(n-8,e.bottom+8));return{top:t,maxHeight:Math.max(0,n-t-8)}})()}}function E({anchor:e,className:t,children:n}){return(0,b.createPortal)((0,x.jsx)(`div`,{className:`${t} chart-overlay`,role:`tooltip`,style:T(e),children:n}),document.body)}function D(e,t,n){return n(`usage.chart.dayDetail`,{date:c(e.date,t),requests:e.requests,tokens:d(e.totalTokens,t)})}function O(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function k(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function A(e,t){let n=O(e.map(e=>e.totalTokens)),r=new Map(e.map(e=>[e.date,e])),i=new Date;i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()-364),a.setDate(a.getDate()-a.getDay());let o=[],s=[],c=new Intl.DateTimeFormat(t,{month:`short`}),l=-4,u=-1,d=[],f=new Date(a);for(;f<=i;){let e=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,`0`)}-${String(f.getDate()).padStart(2,`0`)}`,t=f.getMonth();f.getDay()===0&&t!==u&&o.length-l>=4&&(s.push({label:c.format(f),col:o.length}),l=o.length,u=t);let i=r.get(e);d.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?k(i.totalTokens,n):0,dayOfWeek:f.getDay()}),f.getDay()===6&&(o.push(d),d=[]),f.setDate(f.getDate()+1)}if(d.length>0){for(;d.length<7;)d.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:d.length});o.push(d)}return{weeks:o,months:s,buckets:n}}function j({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,x.jsxs)(`div`,{className:`usage-filters`,children:[(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,x.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude-color.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,x.jsx)(`img`,{className:`usage-source-mark usage-source-mark--mono`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,x.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function M({summary:e,activeDays:t,locale:n,t:r}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.totalTokens,n)})]}),(0,x.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,x.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,d(e.cacheCreationInputTokens??0,n)]})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:S(e.coverageRatio)})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,x.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,x.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,x.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:v(e.estimatedCostUsd,n)}),(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function N({weekBars:e,locale:t,t:n}){let[r,i]=(0,y.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens)),o=e.find(e=>e.date===r?.date),s=(e,t)=>{i({date:e.date,anchor:t.getBoundingClientRect()})};return(0,x.jsxs)(`div`,{className:`daybars`,role:`group`,"aria-label":n(`usage.section.heatmap`),children:[e.map(e=>{let r=Math.round(e.totalTokens/a*100),o=new Intl.DateTimeFormat(t,{weekday:`short`}).format(new Date(`${e.date}T12:00:00`));return(0,x.jsxs)(`button`,{type:`button`,className:`daybar`,"aria-label":D(e,t,n),onFocus:t=>s(e,t.currentTarget),onBlur:()=>i(t=>t?.date===e.date?null:t),onPointerEnter:t=>s(e,t.currentTarget),onPointerDown:t=>s(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&i(t=>t?.date===e.date?null:t)},children:[(0,x.jsx)(`div`,{className:`daybar-track`,children:(0,x.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,r/100)))},children:[e.models.map(e=>(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:C(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),(0,x.jsx)(`span`,{className:`daybar-count`,children:d(e.totalTokens,t)}),(0,x.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)}),r&&o&&(0,x.jsxs)(E,{className:`daybar-tip`,anchor:r.anchor,children:[(0,x.jsx)(`div`,{className:`daybar-tip-date`,children:c(o.date,t)}),(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{children:n(`usage.heatmap.tooltipRequests`,{requests:o.requests})}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:n(`usage.heatmap.tooltipTokens`,{tokens:d(o.totalTokens,t)})})]}),o.models.slice(0,8).map(e=>(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:C(e.model,e.provider)}}),(0,x.jsx)(`span`,{className:`daybar-tip-name`,children:_(e.model)}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:d(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]})]})}function P({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>t.weeks.flat().filter(e=>e.date),[t]),[s,l]=(0,y.useState)(()=>o.at(-1)?.date??``),[u,f]=(0,y.useState)(null),p=(0,y.useId)(),m=o.some(e=>e.date===s)?s:o.at(-1)?.date??``,h=(e,t)=>{l(e.date),f({date:e.date,anchor:t.getBoundingClientRect()})},g=(e,t)=>{let n=o.findIndex(e=>e.date===t.date),r=e.key===`ArrowUp`?-1:e.key===`ArrowDown`?1:e.key===`ArrowLeft`?-7:e.key===`ArrowRight`?7:0;if(!r||n<0)return;e.preventDefault();let i=o[Math.max(0,Math.min(o.length-1,n+r))];l(i.date);let s=a.current?.querySelector(`[data-date="${i.date}"]`);s&&(s.focus(),f({date:i.date,anchor:s.getBoundingClientRect()}))};return(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,x.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,x.jsx)(N,{weekBars:n,locale:r,t:i}):(0,x.jsxs)(`div`,{className:`heatmap`,ref:a,children:[(0,x.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,x.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,x.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,x.jsxs)(`div`,{className:`heatmap-body`,children:[(0,x.jsxs)(`div`,{className:`heatmap-days`,children:[(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`heatmap-grid`,role:`group`,"aria-labelledby":`usage-heatmap-title`,"aria-describedby":p,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,x.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>e.date?(0,x.jsx)(`button`,{type:`button`,className:`heatmap-cell heatmap-cell-${e.level}`,"data-date":e.date,tabIndex:m===e.date?0:-1,"aria-label":D(e,r,i),onFocus:t=>h(e,t.currentTarget),onBlur:()=>f(t=>t?.date===e.date?null:t),onKeyDown:t=>g(t,e),onPointerEnter:t=>h(e,t.currentTarget),onPointerDown:t=>h(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&f(t=>t?.date===e.date?null:t)}},e.date):(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-0`,"aria-hidden":`true`},`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),(0,x.jsx)(`span`,{id:p,className:`sr-only`,children:i(`usage.heatmap.keyboardLabel`)}),(0,x.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:o.find(e=>e.date===m)?D(o.find(e=>e.date===m),r,i):``}),u&&(()=>{let e=o.find(e=>e.date===u.date);return e?.date?(0,x.jsxs)(E,{className:`heatmap-tip`,anchor:u.anchor,children:[(0,x.jsx)(`div`,{className:`heatmap-tip-date`,children:c(e.date,r)}),(0,x.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:d(e.totalTokens,r)})}),(0,x.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,x.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,x.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,x.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function F({title:e,titleId:t,children:n}){return(0,x.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,x.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function I({models:e,modelQuery:t,onModelQuery:n,locale:r,t:a,workspace:o=!1}){let s=a(`usage.search.models`),c=a(`usage.section.models`),l=`usage-models-title`,u=(0,x.jsx)(`input`,{className:`input`,"aria-label":s,placeholder:s,value:t,onChange:e=>n(e.target.value)}),f=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:a(`logs.col.model`)}),(0,x.jsx)(`th`,{children:a(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:a(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:_(e.model)}),(0,x.jsx)(`td`,{className:`muted`,children:i(e.provider,a)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,r)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return o?(0,x.jsxs)(F,{title:c,titleId:l,children:[(0,x.jsx)(`div`,{className:`usw-section-toolbar`,children:u}),f]}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":l,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{id:l,className:`panel-title`,children:c}),u]}),f]})}function L({providers:e,locale:t,t:n,workspace:r=!1}){let a=n(`usage.section.providers`),o=`usage-providers-title`,s=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:i(e.provider,n)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,t)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,x.jsx)(F,{title:a,titleId:o,children:s}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":o,children:[(0,x.jsx)(`h3`,{id:o,className:`panel-title`,children:a}),s]})}function R({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,x.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,x.jsx)(F,{title:r,titleId:i,children:a}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,x.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function z({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:s,sortedProviders:c,range:l,locale:u,t:d}){let f=!!e&&e.summary.requests===0,p=[{id:`overview`,label:d(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(M,{summary:e.summary,activeDays:r,locale:u,t:d}),(0,x.jsx)(P,{range:l,heatmap:t,weekBars:n,locale:u,t:d})]}):null},{id:`models`,label:d(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,x.jsx)(I,{models:i,modelQuery:a,onModelQuery:s,locale:u,t:d,workspace:!0}):null},{id:`providers`,label:d(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,x.jsx)(L,{providers:c,locale:u,t:d,workspace:!0}):null},{id:`coverage`,label:d(`usage.section.coverage`),meta:e?S(e.summary.coverageRatio):`—`,body:e?(0,x.jsx)(R,{summary:e.summary,t:d,workspace:!0}):null}];return(0,x.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,x.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,x.jsx)(g,{scope:`usage`,ariaLabel:d(`usage.workspace.sections`),items:p.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,x.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":d(`usage.workspace.report`),children:f?(0,x.jsx)(o,{title:d(`usage.empty`)}):p.map(e=>(0,x.jsx)(`div`,{id:h(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var B=new Map;function V(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function H(e,t,n){let r=V(e,t,n);return B.get(r)??u(r)}function U(e,t,n,r){let i=V(e,t,n);B.set(i,r),l(i,r)}function W({apiBase:e}){let{t,locale:n}=r(),[i,o]=(0,y.useState)(`30d`),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(``),d=(0,y.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${i}&surface=${s}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let r=await n.json();return U(e,i,s,r),r},[e,i,s]),f=V(e,i,s),h=H(e,i,s),g=p(f,[e,i,s],d,{isEmpty:()=>!1,initialData:h??void 0}),{state:_}=g,v=_.data??h??null,b=(0,y.useMemo)(()=>A(v?.days??[],n),[v?.days,n]),S=(0,y.useMemo)(()=>w(v?.days??[]),[v?.days]),C=(0,y.useMemo)(()=>(v?.days??[]).filter(e=>e.requests>0).length,[v?.days]),T=(0,y.useMemo)(()=>{let e=l.trim().toLowerCase(),t=(v?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[v?.models,l]),E=(0,y.useMemo)(()=>(v?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[v?.providers]);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,x.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,x.jsx)(j,{surface:s,range:i,onSurface:c,onRange:o,t})]}),(0,x.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),_.showSkeleton&&!v?(0,x.jsx)(m,{label:t(`usage.loading`),rows:5}):_.kind===`failed-cold`?(0,x.jsxs)(a,{tone:`err`,children:[_.error instanceof Error?`${t(`usage.loadError`)} ${_.error.message}`:t(`usage.loadError`),` `,(0,x.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>g.refresh(),children:t(`common.retry`)})]}):(0,x.jsxs)(x.Fragment,{children:[_.showError&&(0,x.jsx)(a,{tone:`err`,children:t(`usage.loadError`)}),v?.historyTruncated&&(0,x.jsx)(a,{tone:`warn`,children:(()=>{let e=G(v.snapshotWindowStart),n=G(v.snapshotWindowEnd);return e!==null&&n!==null?t(`usage.historyTruncatedWindow`,{start:e,end:n}):t(`usage.historyTruncated`)})()}),(0,x.jsx)(z,{data:v,heatmap:b,weekBars:S,activeDays:C,filteredModels:T,modelQuery:l,onModelQuery:u,sortedProviders:E,range:i,locale:n,t})]})]})}function G(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():null}export{W as default};
|
|
1
|
+
import{_ as e,h as t,m as n,s as r}from"./shared-p0R307IX.js";import{C as i,F as a,P as o,St as s,b as c,h as l,p as u,x as d,y as f}from"./index-DE4QGJSt.js";import{t as p}from"./data-surface-BzhqUIJ_.js";import{t as m}from"./data-surface-D8RXShV2.js";import{n as h,t as g}from"./section-tabs-DEASco68.js";import{t as _}from"./model-display-CCqxubZd.js";import{r as v}from"./intl-formatters-CTcuZoAe.js";var y=e(t(),1),b=s(),x=n();function S(e){return`${Math.round(e*100)}%`}function C(e,t){let n=`${t}/${e}`,r=0;for(let e=0;e<n.length;e++)r=r*31+n.charCodeAt(e)>>>0;return`hsl(${r%360} 55% 55%)`}function w(e){let t=new Map(e.map(e=>[e.date,e]));return f(e,7).map(e=>({...e,models:t.get(e.date)?.models??[]}))}function T(e){let t=window.innerWidth,n=window.innerHeight,r=Math.min(240,Math.max(0,t-16));return{left:Math.max(8,Math.min(e.left+e.width/2-r/2,t-8-r)),maxWidth:r,...e.top-8>n-e.bottom-8?(()=>{let t=Math.max(8,Math.min(n-8,n-e.top+8));return{bottom:t,maxHeight:Math.max(0,n-t-8)}})():(()=>{let t=Math.max(8,Math.min(n-8,e.bottom+8));return{top:t,maxHeight:Math.max(0,n-t-8)}})()}}function E({anchor:e,className:t,children:n}){return(0,b.createPortal)((0,x.jsx)(`div`,{className:`${t} chart-overlay`,role:`tooltip`,style:T(e),children:n}),document.body)}function D(e,t,n){return n(`usage.chart.dayDetail`,{date:c(e.date,t),requests:e.requests,tokens:d(e.totalTokens,t)})}function O(e){let t=e.filter(e=>e>0).sort((e,t)=>e-t);if(t.length===0)return[0,0,0,0];let n=e=>t[Math.min(t.length-1,Math.floor(e*t.length))];return[n(.25),n(.5),n(.75),n(.95)]}function k(e,t){return e<=0?0:e<=t[0]?1:e<=t[1]?2:e<=t[2]?3:4}function A(e,t){let n=O(e.map(e=>e.totalTokens)),r=new Map(e.map(e=>[e.date,e])),i=new Date;i.setHours(0,0,0,0);let a=new Date(i);a.setDate(a.getDate()-364),a.setDate(a.getDate()-a.getDay());let o=[],s=[],c=new Intl.DateTimeFormat(t,{month:`short`}),l=-4,u=-1,d=[],f=new Date(a);for(;f<=i;){let e=`${f.getFullYear()}-${String(f.getMonth()+1).padStart(2,`0`)}-${String(f.getDate()).padStart(2,`0`)}`,t=f.getMonth();f.getDay()===0&&t!==u&&o.length-l>=4&&(s.push({label:c.format(f),col:o.length}),l=o.length,u=t);let i=r.get(e);d.push({date:e,requests:i?.requests??0,totalTokens:i?.totalTokens??0,level:i?k(i.totalTokens,n):0,dayOfWeek:f.getDay()}),f.getDay()===6&&(o.push(d),d=[]),f.setDate(f.getDate()+1)}if(d.length>0){for(;d.length<7;)d.push({date:``,requests:0,totalTokens:0,level:0,dayOfWeek:d.length});o.push(d)}return{weeks:o,months:s,buckets:n}}function j({surface:e,range:t,onSurface:n,onRange:r,t:i}){return(0,x.jsxs)(`div`,{className:`usage-filters`,children:[(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`logs.filter.surface.label`),children:[`all`,`codex`,`claude`,`grok`].map(t=>{let r=i(`logs.filter.surface.${t}`);return(0,x.jsxs)(`button`,{type:`button`,className:`usage-segmented-btn usage-source-btn${e===t?` active`:``}`,"aria-label":r,"aria-pressed":e===t,onClick:()=>n(t),children:[t===`codex`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/openai.svg`,alt:``,"aria-hidden":`true`}),t===`claude`&&(0,x.jsx)(`img`,{className:`usage-source-mark`,src:`/provider-icons/claude-color.svg`,alt:``,"aria-hidden":`true`}),t===`grok`&&(0,x.jsx)(`img`,{className:`usage-source-mark usage-source-mark--mono`,src:`/provider-icons/grok.svg`,alt:``,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:t===`all`?`usage-source-label`:`usage-source-label usage-source-label-collapsible`,children:r})]},t)})}),(0,x.jsx)(`div`,{className:`usage-segmented`,role:`group`,"aria-label":i(`usage.title`),children:[`all`,`30d`,`7d`].map(e=>{let n=i(e===`all`?`usage.range.available`:`usage.range.${e}`);return(0,x.jsx)(`button`,{type:`button`,className:`usage-segmented-btn${t===e?` active`:``}`,"aria-label":n,"aria-pressed":t===e,onClick:()=>r(e),children:n},e)})})]})}function M({summary:e,activeDays:t,locale:n,t:r}){return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,role:`group`,"aria-label":r(`usage.title`),children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.requests`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.requests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.totalTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.totalTokens,n)})]}),(0,x.jsxs)(`div`,{className:`stat`,title:r(`usage.card.cachedTokensHint`),children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.cachedTokens`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:d(e.cacheReadInputTokens??e.cachedInputTokens,n)}),(e.cacheCreationInputTokens??0)>0&&(0,x.jsxs)(`div`,{className:`muted text-caption`,children:[r(`usage.card.cacheWriteTokens`),`: `,d(e.cacheCreationInputTokens??0,n)]})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.coverage`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:S(e.coverageRatio)})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:r(`usage.card.activeDays`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:t})]})]}),e.estimatedCostUsd!==void 0&&(0,x.jsxs)(`div`,{className:`usage-cost-row`,role:`note`,children:[(0,x.jsx)(`span`,{className:`muted`,children:r(`usage.cost.total`)}),(0,x.jsx)(`span`,{className:`stat-value mono usage-cost-value`,children:v(e.estimatedCostUsd,n)}),(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.disclaimer`)}),(e.unpricedRequests??0)+(e.unmeteredRequests??0)>0&&(0,x.jsx)(`span`,{className:`muted text-caption`,children:r(`usage.cost.unpricedNote`).replace(`{count}`,String((e.unpricedRequests??0)+(e.unmeteredRequests??0)))})]})]})}function N({weekBars:e,locale:t,t:n}){let[r,i]=(0,y.useState)(null),a=Math.max(1,...e.map(e=>e.totalTokens)),o=e.find(e=>e.date===r?.date),s=(e,t)=>{i({date:e.date,anchor:t.getBoundingClientRect()})};return(0,x.jsxs)(`div`,{className:`daybars`,role:`group`,"aria-label":n(`usage.section.heatmap`),children:[e.map(e=>{let r=Math.round(e.totalTokens/a*100),o=new Intl.DateTimeFormat(t,{weekday:`short`}).format(new Date(`${e.date}T12:00:00`));return(0,x.jsxs)(`button`,{type:`button`,className:`daybar`,"aria-label":D(e,t,n),onFocus:t=>s(e,t.currentTarget),onBlur:()=>i(t=>t?.date===e.date?null:t),onPointerEnter:t=>s(e,t.currentTarget),onPointerDown:t=>s(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&i(t=>t?.date===e.date?null:t)},children:[(0,x.jsx)(`div`,{className:`daybar-track`,children:(0,x.jsxs)(`div`,{className:`daybar-stack`,style:{"--daybar-scale":String(Math.max(0,Math.min(1,r/100)))},children:[e.models.map(e=>(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:e.totalTokens,background:C(e.model,e.provider)}},`${e.provider}/${e.model}`)),e.models.length===0&&e.totalTokens>0&&(0,x.jsx)(`div`,{className:`daybar-seg`,style:{flexGrow:1,background:`var(--green)`}})]})}),(0,x.jsx)(`span`,{className:`daybar-count`,children:d(e.totalTokens,t)}),(0,x.jsx)(`span`,{className:`daybar-label muted`,children:o})]},e.date)}),r&&o&&(0,x.jsxs)(E,{className:`daybar-tip`,anchor:r.anchor,children:[(0,x.jsx)(`div`,{className:`daybar-tip-date`,children:c(o.date,t)}),(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{children:n(`usage.heatmap.tooltipRequests`,{requests:o.requests})}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:n(`usage.heatmap.tooltipTokens`,{tokens:d(o.totalTokens,t)})})]}),o.models.slice(0,8).map(e=>(0,x.jsxs)(`div`,{className:`daybar-tip-row`,children:[(0,x.jsx)(`span`,{className:`daybar-tip-swatch`,style:{background:C(e.model,e.provider)}}),(0,x.jsx)(`span`,{className:`daybar-tip-name`,children:_(e.model)}),(0,x.jsx)(`span`,{className:`daybar-tip-val`,children:d(e.totalTokens,t)})]},`${e.provider}/${e.model}`))]})]})}function P({range:e,heatmap:t,weekBars:n,locale:r,t:i}){let a=(0,y.useRef)(null),o=(0,y.useMemo)(()=>t.weeks.flat().filter(e=>e.date),[t]),[s,l]=(0,y.useState)(()=>o.at(-1)?.date??``),[u,f]=(0,y.useState)(null),p=(0,y.useId)(),m=o.some(e=>e.date===s)?s:o.at(-1)?.date??``,h=(e,t)=>{l(e.date),f({date:e.date,anchor:t.getBoundingClientRect()})},g=(e,t)=>{let n=o.findIndex(e=>e.date===t.date),r=e.key===`ArrowUp`?-1:e.key===`ArrowDown`?1:e.key===`ArrowLeft`?-7:e.key===`ArrowRight`?7:0;if(!r||n<0)return;e.preventDefault();let i=o[Math.max(0,Math.min(o.length-1,n+r))];l(i.date);let s=a.current?.querySelector(`[data-date="${i.date}"]`);s&&(s.focus(),f({date:i.date,anchor:s.getBoundingClientRect()}))};return(0,y.useEffect)(()=>{let e=a.current;if(!e)return;let t=()=>{e.scrollLeft=e.scrollWidth};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[t,e]),(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":`usage-heatmap-title`,children:[(0,x.jsx)(`h3`,{id:`usage-heatmap-title`,className:`panel-title`,children:i(`usage.section.heatmap`)}),e===`7d`?(0,x.jsx)(N,{weekBars:n,locale:r,t:i}):(0,x.jsxs)(`div`,{className:`heatmap`,ref:a,children:[(0,x.jsxs)(`div`,{className:`heatmap-months`,style:{gridTemplateColumns:`28px repeat(${t.weeks.length}, calc(var(--hm-cell) + var(--hm-gap)))`},children:[(0,x.jsx)(`span`,{className:`heatmap-day-spacer`}),t.months.map(e=>(0,x.jsx)(`span`,{className:`heatmap-month`,style:{gridColumn:e.col+2},children:e.label},`${e.label}-${e.col}`))]}),(0,x.jsxs)(`div`,{className:`heatmap-body`,children:[(0,x.jsxs)(`div`,{className:`heatmap-days`,children:[(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayMon`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayWed`)}),(0,x.jsx)(`span`,{}),(0,x.jsx)(`span`,{children:i(`usage.dayFri`)}),(0,x.jsx)(`span`,{})]}),(0,x.jsx)(`div`,{className:`heatmap-grid`,role:`group`,"aria-labelledby":`usage-heatmap-title`,"aria-describedby":p,style:{gridTemplateColumns:`repeat(${t.weeks.length}, var(--hm-cell))`},children:t.weeks.map((e,t)=>(0,x.jsx)(`div`,{className:`heatmap-week`,children:e.map((e,n)=>e.date?(0,x.jsx)(`button`,{type:`button`,className:`heatmap-cell heatmap-cell-${e.level}`,"data-date":e.date,tabIndex:m===e.date?0:-1,"aria-label":D(e,r,i),onFocus:t=>h(e,t.currentTarget),onBlur:()=>f(t=>t?.date===e.date?null:t),onKeyDown:t=>g(t,e),onPointerEnter:t=>h(e,t.currentTarget),onPointerDown:t=>h(e,t.currentTarget),onPointerLeave:t=>{t.pointerType!==`touch`&&document.activeElement!==t.currentTarget&&f(t=>t?.date===e.date?null:t)}},e.date):(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-0`,"aria-hidden":`true`},`pad-${t}-${n}`))},e[0]?.date||`week-${t}`))})]}),(0,x.jsx)(`span`,{id:p,className:`sr-only`,children:i(`usage.heatmap.keyboardLabel`)}),(0,x.jsx)(`span`,{className:`sr-only`,"aria-live":`polite`,children:o.find(e=>e.date===m)?D(o.find(e=>e.date===m),r,i):``}),u&&(()=>{let e=o.find(e=>e.date===u.date);return e?.date?(0,x.jsxs)(E,{className:`heatmap-tip`,anchor:u.anchor,children:[(0,x.jsx)(`div`,{className:`heatmap-tip-date`,children:c(e.date,r)}),(0,x.jsx)(`div`,{className:`heatmap-tip-val`,children:i(`usage.heatmap.tooltipTokens`,{tokens:d(e.totalTokens,r)})}),(0,x.jsx)(`div`,{className:`heatmap-tip-req muted`,children:i(`usage.heatmap.tooltipRequests`,{requests:e.requests})})]}):null})(),(0,x.jsxs)(`div`,{className:`heatmap-legend muted`,children:[(0,x.jsx)(`span`,{children:i(`usage.heatmap.less`)}),[0,1,2,3,4].map(e=>(0,x.jsx)(`span`,{className:`heatmap-cell heatmap-cell-${e}`},e)),(0,x.jsx)(`span`,{children:i(`usage.heatmap.more`)})]})]})]})}function F({title:e,titleId:t,children:n}){return(0,x.jsxs)(`section`,{className:`usw-section`,"aria-labelledby":t,children:[(0,x.jsx)(`h3`,{id:t,className:`h-section`,children:e}),n]})}function I({models:e,modelQuery:t,onModelQuery:n,locale:r,t:a,workspace:o=!1}){let s=a(`usage.search.models`),c=a(`usage.section.models`),l=`usage-models-title`,u=(0,x.jsx)(`input`,{className:`input`,"aria-label":s,placeholder:s,value:t,onChange:e=>n(e.target.value)}),f=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:a(`logs.col.model`)}),(0,x.jsx)(`th`,{children:a(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:a(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:a(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:_(e.model)}),(0,x.jsx)(`td`,{className:`muted`,children:i(e.provider,a)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,r)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},`${e.provider}/${e.model}`))})]})});return o?(0,x.jsxs)(F,{title:c,titleId:l,children:[(0,x.jsx)(`div`,{className:`usw-section-toolbar`,children:u}),f]}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":l,children:[(0,x.jsxs)(`div`,{className:`panel-head`,children:[(0,x.jsx)(`h3`,{id:l,className:`panel-title`,children:c}),u]}),f]})}function L({providers:e,locale:t,t:n,workspace:r=!1}){let a=n(`usage.section.providers`),o=`usage-providers-title`,s=(0,x.jsx)(`div`,{className:`tbl-wrap`,children:(0,x.jsxs)(`table`,{className:`tbl`,children:[(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`th`,{children:n(`logs.col.provider`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.requests`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.measured`)}),(0,x.jsx)(`th`,{className:`num`,children:n(`usage.col.tokens`)}),(0,x.jsx)(`th`,{children:n(`usage.col.share`)})]})}),(0,x.jsx)(`tbody`,{children:e.map(e=>(0,x.jsxs)(`tr`,{children:[(0,x.jsx)(`td`,{className:`mono`,children:i(e.provider,n)}),(0,x.jsx)(`td`,{className:`num`,children:e.requests}),(0,x.jsx)(`td`,{className:`num`,children:e.measuredRequests}),(0,x.jsx)(`td`,{className:`num mono`,children:d(e.totalTokens,t)}),(0,x.jsx)(`td`,{children:(0,x.jsx)(`div`,{className:`usage-bar`,children:(0,x.jsx)(`div`,{className:`usage-bar-fill`,style:{width:`${Math.round(e.shareRatio*100)}%`}})})})]},e.provider))})]})});return r?(0,x.jsx)(F,{title:a,titleId:o,children:s}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":o,children:[(0,x.jsx)(`h3`,{id:o,className:`panel-title`,children:a}),s]})}function R({summary:e,t,workspace:n=!1}){let r=t(`usage.section.coverage`),i=`usage-coverage-title`,a=(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`usage-cards usage-cards-3x2`,children:[(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.measured`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.measuredRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.reported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.reportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`usage.coverage.estimated`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.estimatedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unreported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unreportedRequests})]}),(0,x.jsxs)(`div`,{className:`stat`,children:[(0,x.jsx)(`div`,{className:`muted`,children:t(`logs.tokens.unsupported`)}),(0,x.jsx)(`div`,{className:`stat-value`,children:e.unsupportedRequests})]})]}),(0,x.jsx)(`p`,{className:`muted text-control`,style:{marginTop:12},children:t(`usage.coverage.note`)})]});return n?(0,x.jsx)(F,{title:r,titleId:i,children:a}):(0,x.jsxs)(`section`,{className:`panel`,style:{marginTop:16},"aria-labelledby":i,children:[(0,x.jsx)(`h3`,{id:i,className:`panel-title`,children:r}),a]})}function z({data:e,heatmap:t,weekBars:n,activeDays:r,filteredModels:i,modelQuery:a,onModelQuery:s,sortedProviders:c,range:l,locale:u,t:d}){let f=!!e&&e.summary.requests===0,p=[{id:`overview`,label:d(`usage.section.overview`),meta:e?`${e.summary.requests}`:`—`,body:e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(M,{summary:e.summary,activeDays:r,locale:u,t:d}),(0,x.jsx)(P,{range:l,heatmap:t,weekBars:n,locale:u,t:d})]}):null},{id:`models`,label:d(`usage.section.models`),meta:e?`${e.models.length}`:`—`,body:e?(0,x.jsx)(I,{models:i,modelQuery:a,onModelQuery:s,locale:u,t:d,workspace:!0}):null},{id:`providers`,label:d(`usage.section.providers`),meta:e?`${e.providers.length}`:`—`,body:e?(0,x.jsx)(L,{providers:c,locale:u,t:d,workspace:!0}):null},{id:`coverage`,label:d(`usage.section.coverage`),meta:e?S(e.summary.coverageRatio):`—`,body:e?(0,x.jsx)(R,{summary:e.summary,t:d,workspace:!0}):null}];return(0,x.jsx)(`div`,{className:`usage-workspace-shell`,children:(0,x.jsxs)(`div`,{className:`usage-workspace-root`,children:[(0,x.jsx)(g,{scope:`usage`,ariaLabel:d(`usage.workspace.sections`),items:p.map(e=>({id:e.id,label:e.label,meta:e.meta}))}),(0,x.jsx)(`section`,{className:`usage-workspace-main`,"aria-label":d(`usage.workspace.report`),children:f?(0,x.jsx)(o,{title:d(`usage.empty`)}):p.map(e=>(0,x.jsx)(`div`,{id:h(`usage`,e.id),className:`usw-body usw-section-block`,children:e.body},e.id))})]})})}var B=new Map;function V(e,t,n){return`ocx.usage.v1:${e}:${t}:${n}`}function H(e,t,n){let r=V(e,t,n);return B.get(r)??u(r)}function U(e,t,n,r){let i=V(e,t,n);B.set(i,r),l(i,r)}function W({apiBase:e}){let{t,locale:n}=r(),[i,o]=(0,y.useState)(`30d`),[s,c]=(0,y.useState)(`all`),[l,u]=(0,y.useState)(``),d=(0,y.useCallback)(async t=>{let n=await fetch(`${e}/api/usage?range=${i}&surface=${s}`,{signal:t});if(!n.ok)throw Error(`${n.status} ${n.statusText}`.trim());let r=await n.json();return U(e,i,s,r),r},[e,i,s]),f=V(e,i,s),h=H(e,i,s),g=p(f,[e,i,s],d,{isEmpty:()=>!1,initialData:h??void 0}),{state:_}=g,v=_.data??h??null,b=(0,y.useMemo)(()=>A(v?.days??[],n),[v?.days,n]),S=(0,y.useMemo)(()=>w(v?.days??[]),[v?.days]),C=(0,y.useMemo)(()=>(v?.days??[]).filter(e=>e.requests>0).length,[v?.days]),T=(0,y.useMemo)(()=>{let e=l.trim().toLowerCase(),t=(v?.models??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens);return e?t.filter(t=>t.model.toLowerCase().includes(e)||t.provider.toLowerCase().includes(e)||(t.resolvedModel??``).toLowerCase().includes(e)).slice(0,100):t.slice(0,100)},[v?.models,l]),E=(0,y.useMemo)(()=>(v?.providers??[]).toSorted((e,t)=>t.totalTokens-e.totalTokens),[v?.providers]);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`page-head usage-head`,children:[(0,x.jsx)(`h2`,{id:`usage-page-title`,children:t(`usage.title`)}),(0,x.jsx)(j,{surface:s,range:i,onSurface:c,onRange:o,t})]}),(0,x.jsx)(`p`,{className:`page-sub`,children:t(`usage.subtitle`)}),_.showSkeleton&&!v?(0,x.jsx)(m,{label:t(`usage.loading`),rows:5}):_.kind===`failed-cold`?(0,x.jsxs)(a,{tone:`err`,children:[_.error instanceof Error?`${t(`usage.loadError`)} ${_.error.message}`:t(`usage.loadError`),` `,(0,x.jsx)(`button`,{type:`button`,className:`btn btn-ghost btn-sm`,onClick:()=>g.refresh(),children:t(`common.retry`)})]}):(0,x.jsxs)(x.Fragment,{children:[_.showError&&(0,x.jsx)(a,{tone:`err`,children:t(`usage.loadError`)}),v?.historyTruncated&&(0,x.jsx)(a,{tone:`warn`,children:(()=>{let e=G(v.snapshotWindowStart),n=G(v.snapshotWindowEnd);return e!==null&&n!==null?t(`usage.historyTruncatedWindow`,{start:e,end:n}):t(`usage.historyTruncated`)})()}),(0,x.jsx)(z,{data:v,heatmap:b,weekBars:S,activeDays:C,filteredModels:T,modelQuery:l,onModelQuery:u,sortedProviders:E,range:i,locale:n,t})]})]})}function G(e){if(typeof e!=`number`||!Number.isFinite(e))return null;let t=new Date(e);return Number.isFinite(t.getTime())?t.toLocaleString():null}export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,h as t}from"./shared-p0R307IX.js";import{g as n,m as r,xt as i}from"./index-
|
|
1
|
+
import{_ as e,h as t}from"./shared-p0R307IX.js";import{g as n,m as r,xt as i}from"./index-DE4QGJSt.js";var a=e(t(),1);function o(e,t,n){if(!n)return{kind:`disabled`,data:void 0,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1};let r=e.data!==void 0,i=!e.lastAttemptOk&&e.error!==void 0;return e.refreshing?r?{kind:`loading-with-stale-data`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!0,showError:i}:{kind:i?`retrying-cold`:`cold`,data:void 0,error:i?e.error:void 0,showSkeleton:!0,refreshing:!0,showError:!1}:i?r?{kind:`failed-with-stale`,data:e.data,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:{kind:`failed-cold`,data:void 0,error:e.error,showSkeleton:!1,refreshing:!1,showError:!0}:r?{kind:t(e.data)?`ready-empty`:`ready-populated`,data:e.data,error:void 0,showSkeleton:!1,refreshing:!1,showError:!1}:{kind:`cold`,data:void 0,error:void 0,showSkeleton:!0,refreshing:!1,showError:!1}}function s(e,t,s,c){let{isEmpty:l,sessionCacheKey:u,...d}=c,f=(0,a.useMemo)(()=>u?r(u):null,[u]),p=(0,a.useCallback)(async e=>{let t=await s(e);return u&&n(u,t),t},[s,u]),m=i(e,t,p,{...d,...u?{initialData:d.initialData??f?.data,initialDataCachedAt:d.initialDataCachedAt??f?.cachedAt??null}:{}});return{...m,state:o(m,l,c.enabled!==!1)}}export{s as t};
|