@abelxiaoxing/cadence 2.2.1 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/service-management.md +3 -1
- package/package.json +1 -1
- package/src/cadence-mode.ts +5 -6
- package/src/coordinator-tools.mjs +71 -1
- package/src/model-preview.mjs +7 -0
- package/src/native-build.ts +1 -1
- package/src/native-workflow-history.ts +1 -1
- package/src/service/contracts/workbench.ts +13 -7
- package/src/service/contracts/workflow.ts +30 -2
- package/src/service/workflow-git.ts +28 -8
- package/src/service-cli.mjs +7 -0
- package/src/service-host.mjs +260 -47
- package/src/worker-public.mjs +8 -0
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +28 -28
- package/web/dist/index.html +6 -6
- package/web/dist/manifest.json +7 -7
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import{r as e}from"./rolldown-runtime.js";import{i as t,n,r,t as i}from"./react.js";import{a,c as o,i as s,l as c,n as l,o as u,r as d,s as f,t as p,u as m}from"./markdown.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var h=e(t(),1),g=n(),_=Object.freeze({chunkChars:262144,idleMs:6e5}),v=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function y(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function b(e,t){if(!v.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
|
|
2
2
|
|
|
3
|
-
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var x=`cadence-graph/2`,S=`cadence-public-export/2`,C=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,cookieLifetimeMs:31536e6,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,coordinatorBytes:393216,chunkBytes:8192,detailBytes:33554432,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),w=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],T=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function E(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function D(){throw new T}function O(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&D(),k(e)>t)throw new T(`oversize`);return e}function k(e){return new TextEncoder().encode(e).length}function A(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&D(),e}function j(e){return typeof e!=`boolean`&&D(),e}function M(e,t){return(typeof e!=`string`||!t.includes(e))&&D(),e}function N(e,t){return e!==t&&D(),t}function P(e,t){return e===null?null:t(e)}function F(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&D();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&D();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&D(),r[n]=t.value}return r}function I(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&D();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&D(),r.push(n(i.value))}return r}function L(e){let t=O(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||D(),t}function R(e){let t=O(e,64);return/^[0-9a-f]{64}$/.test(t)||D(),t}function z(e){let t=O(e,C.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||D(),t}function ee(e,t){return z(e),z(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function te(e){let t=O(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||D(),t}function B(e,t=C.controlBytes){let n=t,r=e=>{if(n-=k(e),n<0)throw new T(`oversize`);return e};function i(e,n){if(n>64&&D(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return O(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||D(),r(JSON.stringify(e));if(Array.isArray(e)){let a=I(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&D();let a=t.sort(),o=F(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return D()}return i(e,0)}function ne(e,t=C.controlBytes){O(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return O(JSON.parse(e.slice(r,n)),t)}catch{return D()}i=!i&&a===`\\`}return D()}function a(t){if(t>64&&D(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&D(),d=i(),u.has(d)&&D(),u.add(d),r(),e[n++]!==`:`&&D());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&D()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||D(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&D(),s}let o=a(0);return r(),n!==e.length&&D(),o}function re(e){let t=F(e,[`code`,`effect`,`recovery`]);return{code:M(t.code,w),effect:M(t.effect,[`none`,`accepted`,`uncertain`]),recovery:M(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ie=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],ae=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],oe=[`not-launched`,`direct-child-closed`,`unconfirmed`],se=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],ce=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function le(e){let t=F(e,[`provider`,`model`,`api`,`thinking`]);return{provider:O(t.provider,128,!0),model:O(t.model,256,!0),api:M(t.api,se),thinking:M(t.thinking,ce)}}function ue(e){let{sourceSelectionId:t,...n}=F(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:L(t),...le(n)}}function de(e){let t=F(e,[`role`,`sha256`]);return{role:M(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:R(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function V(e){let t=F(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:L(t.recordId),version:A(t.version,1),field:M(t.field,ie),bytes:A(t.bytes,0,C.detailBytes),sha256:R(t.sha256)}}function pe(e){let t=F(e,[`start`,`end`]),n=A(t.start);return{start:n,end:A(t.end,n+1,C.detailBytes)}}function me(e){let t=F(e,[`source`,`range`,`requireCompleteObservation`]),n=H(t.source),r;if(n===`current`)r={kind:n,assignmentId:te(F(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=F(t.source,[`kind`,`runId`,`childRunId`,`result`]);N(n,`historical`);let i=V(e.result);N(i.field,`final-text`),r={kind:`historical`,runId:L(e.runId),childRunId:L(e.childRunId),result:i}}let i=P(t.range,pe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&D(),{source:r,range:i,requireCompleteObservation:j(t.requireCompleteObservation)}}function H(e,t=`kind`){(typeof e!=`object`||!e)&&D();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&D(),O(n.value,64,!0)}function he(e){B(e,C.graphBytes);let t=F(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=V(t.plan);N(n.field,`plan`);let r=A(t.planRevision,1);n.version!==r&&D();let i={schema:N(t.schema,x),taskId:L(t.taskId),taskKind:M(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:A(t.taskRevision,1),revision:A(t.revision,1),planRevision:r,plan:n,assignments:I(t.assignments,C.assignments,e=>{let t=F(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:te(t.id),purpose:M(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:O(t.instructions,C.instructionsBytes,!0),expectedOutput:O(t.expectedOutput,C.expectedOutputBytes,!0),role:de(t.role),model:ue(t.model),dependencies:I(t.dependencies,C.assignments,me)}})};i.assignments.length||D();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&D();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&D(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=B(n.source);if(t.has(e)&&D(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||D(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new T(`forbidden`);c(e)}return i}function ge(e){let t=F(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=P(t.graphRevision,e=>A(e,1)),r=P(t.graphIdentity,R);return n===null!=(r===null)&&D(),{id:L(t.id),kind:M(t.kind,[`code`,`research`,`diagnosis`]),revision:A(t.revision,1),identity:R(t.identity),graphRevision:n,graphIdentity:r}}function _e(e){let t=F(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=F(t.observation,[`identity`,`complete`]);return{epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),configRev:A(t.configRev,1),controlRev:A(t.controlRev,1),workspaceId:L(t.workspaceId),cwdId:L(t.cwdId),model:ue(t.model),checkEnvGeneration:A(t.checkEnvGeneration,1),checkoutGeneration:A(t.checkoutGeneration),observation:{identity:R(n.identity),complete:j(n.complete)},task:P(t.task,ge)}}function U(e){let t=F(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:M(t.kind,[`configured`,`manual`]),name:O(t.name,128,!0),command:O(t.command,4096,!0),timeoutMs:A(t.timeoutMs,100,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&D(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&D(),n}function W(e){switch(B(e),H(e)){case`create`:{let t=F(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:M(t.taskKind,[`code`,`research`,`diagnosis`]),goal:O(t.goal,8192,!0)}}case`save-plan`:{let t=F(e,[`kind`,`taskId`,`plan`,`graph`]),n=he(t.graph),r=L(t.taskId);return n.taskId!==r&&D(),{kind:`save-plan`,taskId:r,plan:O(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:H(e),taskId:L(F(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=F(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:L(t.taskId),check:U(t.check)}}case`review`:{let t=F(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:L(t.taskId),runId:L(t.runId),changesIdentity:R(t.changesIdentity),checksRevision:A(t.checksRevision),acceptIssues:j(t.acceptIssues)}}default:return D()}}function ve(e){B(e);let t=F(e,[`expected`,`action`]);return{expected:_e(t.expected),action:W(t.action)}}function ye(e){B(e);let t=F(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:L(t.commandId),grant:L(t.grant),expected:_e(t.expected),action:W(t.action)}}function be(e){if(B(e),H(e)===`action`){let t=F(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:_e(t.expected),action:W(t.action)}}let t=F(e,[`kind`,`epoch`,`runId`]);return N(t.kind,`cancel`),{kind:`cancel`,epoch:L(t.epoch),runId:L(t.runId)}}function xe(e){let t=F(e,[`commandId`,`epoch`,`runId`]);return{commandId:L(t.commandId),epoch:L(t.epoch),runId:L(t.runId)}}function Se(e){B(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=F(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=I(n.configuredChecks,32,U);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&D(),{...t?{checkEnvironmentPolicy:N(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:A(n.checksRevision),reviewRunId:P(n.reviewRunId,L),version:_e(n.version),action:W(n.action),rootLabel:O(n.rootLabel,4096,!0),cwdLabel:O(n.cwdLabel,4096,!0),readablePlan:O(n.readablePlan,32768),graph:P(n.graph,he),activeRunId:P(n.activeRunId,L),issues:I(n.issues,7,e=>M(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ce(e){B(e);let t=F(e,[`grant`,`expiresAt`,`preview`]),n=O(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&D(),{grant:L(t.grant),expiresAt:n,preview:Se(t.preview)}}function G(e){let t=F(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:M(t.observed,[`complete`,`incomplete`]),source:M(t.source,[`complete`,`limited`,`unavailable`]),redacted:j(t.redacted),omissions:I(t.omissions,6,e=>M(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&D(),n}function we(e){let t=F(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:A(t.graphRevision,1),inputs:I(t.inputs,C.assignments,e=>{let t=F(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=V(t.result);N(i.field,`final-text`);let a=P(t.range,pe);a&&a.end>i.bytes&&D();let o=O(t.text,C.predecessorBytes);if(n+=k(o),n>C.handoffBytes)throw new T(`oversize`);let s=A(t.dependencyIndex,0,C.assignments-1);return r.has(s)&&D(),r.add(s),k(o)!==(a?a.end-a.start:i.bytes)&&D(),{assignmentId:te(t.assignmentId),dependencyIndex:s,runId:L(t.runId),childRunId:L(t.childRunId),result:i,range:a,text:o,coverage:G(t.coverage)}})}}function Te(e){let t=F(e,[`source`,`reason`,`target`]);return{source:M(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:O(t.reason,128,!0),target:O(t.target,128,!0)}}function Ee(e){let t=F(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Te(t.stop)},outcome:M(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:M(t.closure,oe),exitCode:P(t.exitCode,e=>A(e,-2147483648,4294967295)),signal:P(t.signal,e=>O(e,32,!0)),durationMs:A(t.durationMs),stdin:M(t.stdin,[`delivered`,`failed`,`not-required`]),final:M(t.final,[`valid`,`missing`,`invalid`]),cleanup:M(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:G(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&D(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&D(),n}function De(e){let t=F(e,[`kind`,`id`]);return{kind:M(t.kind,[`task`,`run`,`child`]),id:L(t.id)}}function Oe(e){let t=O(e,C.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||D(),t}function ke(e){B(e);let t=F(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:L(t.storeId),scope:De(t.scope),query:P(t.query,e=>{let t=O(e,C.queryBytes);return t.length||D(),t}),snapshotSeq:z(t.snapshotSeq),recordId:P(t.recordId,L),recordVersion:P(t.recordVersion,e=>A(e,1)),field:P(t.field,e=>M(e,ie)),offset:A(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&D(),n}function Ae(e){let t=F(e,[`disposition`,`value`]),n=M(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&D(),{disposition:n,value:r}}function je(e){let t=F(e,[`messageId`,`blockId`]);return{messageId:L(t.messageId),blockId:L(t.blockId)}}function Me(e){let t=H(e);if(t===`message-final`)return{kind:t,messageId:L(F(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:M(F(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=F(e,[`kind`,`dependencyIndex`,`source`]),r=V(n.source);return N(r.field,`final-text`),{kind:t,dependencyIndex:A(n.dependencyIndex,0,C.assignments-1),source:r}}if(t===`message`){let n=F(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:L(n.messageId),blockId:L(n.blockId),index:A(n.index,0,C.dataFrames),stage:M(n.stage,[`stream`,`final`])}}let n=F(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return N(t,`tool`),{kind:`tool`,callId:L(n.callId),blockId:L(n.blockId),index:A(n.index,0,C.dataFrames),stage:M(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=F(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=M(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=M(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&D(),{owner:n,field:r,encoding:i}}function Pe(e){let t=F(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=M(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=M(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=P(t.mimeType,e=>O(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&D(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=O(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||D(),t}function Ie(e){let t=F(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`,...Object.hasOwn(e??{},`reason`)?[`reason`]:[]]),n=A(t.maxAttempts,1),r={phase:M(t.phase,[`waiting`,`requesting`]),attempt:A(t.attempt,1,n),maxAttempts:n,delayMs:A(t.delayMs,0,2147483647),...t.reason===void 0?{}:{reason:O(t.reason,256,!0)}};if(r.phase===`requesting`&&r.delayMs!==0)throw new T(`invalid`);return r}function Le(e){let t=H(e);switch(t){case`ready`:{let n=F(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:N(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=F(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:O(e.sdkVersion,128,!0),workerHash:R(e.workerHash)}})()}}}case`message-start`:{let n=F(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=M(n.role,[`user`,`assistant`,`tool-result`]),i=P(n.resultCallId,L);return r!==`tool-result`&&i!==null&&D(),{kind:t,messageId:L(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`thinking-activity`:{let n=F(e,[`kind`,`messageId`,`index`,`phase`]);return{kind:t,messageId:L(n.messageId),index:A(n.index,0,C.dataFrames),phase:M(n.phase,[`active`,`complete`,`unavailable`])}}case`message-text`:{let n=F(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:L(n.detailId)}}case`message-end`:{let n=F(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:L(n.messageId),finalDetailId:P(n.finalDetailId,L),finalBlockCount:A(n.finalBlockCount,0,C.dataFrames),stopReason:M(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=F(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:L(n.callId),declaration:je(n.declaration),index:A(n.index,0,C.dataFrames),source:Ae(n.source),name:O(n.name,128,!0),argsDetailId:P(n.argsDetailId,L),stage:M(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=F(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:L(n.callId),declaration:P(n.declaration,je),source:Ae(n.source),name:O(n.name,128,!0),argsDetailId:P(n.argsDetailId,L)}}case`tool-update`:{let n=F(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:L(n.callId),detailId:L(n.detailId),semantics:N(n.semantics,`snapshot`)}}case`tool-end`:{let n=F(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=M(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=P(n.declaration,je),a=j(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&D(),{kind:t,callId:L(n.callId),declaration:i,source:Ae(n.source),name:O(n.name,128,!0),resultDetailId:L(n.resultDetailId),isError:j(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(F(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=F(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:L(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=F(e,[`kind`,`detailId`,`offset`,`text`]),r=O(n.text,C.chunkBytes),i=A(n.offset,0,C.detailBytes);return i+k(r)>C.detailBytes&&D(),{kind:t,detailId:L(n.detailId),offset:i,text:r}}case`detail-end`:{let n=F(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:L(n.detailId),bytes:A(n.bytes,0,C.detailBytes),sha256:R(n.sha256),coverage:G(n.coverage)}}case`model-retry`:return{kind:t,progress:P(F(e,[`kind`,`progress`]).progress,Ie)};case`capture-status`:return{kind:t,coverage:G(F(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:M(F(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=F(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:L(n.messageId),detailId:L(n.detailId),stopReason:N(n.stopReason,`stop`)}}default:return D()}}function Re(e){let t=F(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Te(t.stop)},outcome:M(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:M(t.closure,oe),exitCode:P(t.exitCode,e=>A(e,-2147483648,4294967295)),signal:P(t.signal,e=>O(e,32,!0)),durationMs:A(t.durationMs),stdin:N(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&D(),n}function ze(e){let t=F(e,[`messageId`,`detailId`]);return{messageId:L(t.messageId),detailId:L(t.detailId)}}function Be(e){let t=F(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=z(t.committedSeq);return n===`0`&&D(),{childRunId:L(t.childRunId),detailId:L(t.detailId),content:V(t.content),committedSeq:n}}function Ve(e){let t=H(e,`status`);if(t===`committed`){let n=F(e,[`status`,`selected`,`detail`]),r=ze(n.selected),i=Be(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&D(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=F(e,[`status`,`selected`,`error`]);return{status:t,selected:P(n.selected,ze),error:re(n.error)}}let n=F(e,[`status`,`selected`]);return{status:M(t,[`pending`,`uncertain`]),selected:P(n.selected,ze)}}function He(e,t){let n=P(e,z);return(n===`0`||n!==null&&t.status===`committed`&&ee(n,t.detail.committedSeq)<0)&&D(),n}function Ue(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function We(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Ue(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function Ge(e){let t=H(e);if(t===`sdk`){let n=F(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ve(n.recording),i=He(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=F(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=P(n.settlementSeq,z);return r===`0`&&D(),{kind:t,native:Re(n.native),capture:G(n.capture),settlementSeq:r}}let n=F(e,[`kind`,`outcome`,`required`]);N(t,`parent`);let r=I(n.required,C.assignments,e=>{let t=F(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=L(t.childRunId),r=Ve(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&D(),{assignmentId:te(t.assignmentId),childRunId:n,native:P(t.native,Ee),recording:r,settlementSeq:He(t.settlementSeq,r)}}),i=M(n.outcome,ae);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(Ue))&&D(),{kind:`parent`,outcome:i,required:r}}function Ke(e){let t=F(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=A(t.first,1,2**53-1),r=A(t.last,n,2**53-1),i=A(t.firstObservedMs),a=A(t.lastObservedMs,i);return n===r&&i!==a&&D(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function qe(e){let t=F(e,[`source`,`event`]),n=Ke(t.source),r=H(t.event);if(r===`stored-chunk`){let e=F(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:L(e.detailId),text:O(e.text,C.chunkBytes)}}}if(r===`stored-end`){let e=F(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:L(e.detailId),coverage:G(e.coverage)}}}let i=Le(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&D(),{source:n,event:i}}function Je(e){let t=F(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:L(t.epoch),taskId:L(t.taskId),runId:L(t.runId),childRunId:L(t.childRunId)}}function Ye(e){let t=O(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||D(),t}function Xe(e){let t=F(e,[`id`,`cwd`]);return{id:Ye(t.id),cwd:O(t.cwd,4096,!0)}}function Ze(e){let t=F(e,[`id`,`cwd`,`revision`,`model`]);return{id:Ye(t.id),cwd:O(t.cwd,4096,!0),revision:A(t.revision,0,2**53-1-1),model:P(t.model,le)}}function Qe(e){let t=F(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:O(t.cwd,4096,!0),checkoutRoot:O(t.checkoutRoot,4096,!0),version:K(t.version),model:P(t.model,ue)}}function K(e){let t=F(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:Xe(t.conversation)},epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),configRev:A(t.configRev,1),catalogId:L(t.catalogId)}}function $e(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`version`,`selected`]);return{version:K(t.version),selected:P(t.selected,ue)}}function et(e){B(e);let t=F(e,[`expected`,`choice`]);return{expected:K(t.expected),choice:le(t.choice)}}function tt(e){let t=F(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:j(t.images)},...t.contextWindow===void 0?{}:{contextWindow:A(t.contextWindow,1)},provider:O(t.provider,128,!0),model:O(t.model,256,!0),api:P(t.api,e=>M(e,se)),thinking:I(t.thinking,7,e=>{let t=F(e,[`level`,`selectable`]);return{level:M(t.level,ce),selectable:j(t.selectable)}}),eligibility:M(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&D(),n}function nt(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function rt(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`status`,`entries`,`withheld`,`remembered`]),n=I(t.entries,C.maxPageEntries,tt),r=P(t.remembered,le),i=M(t.status,[`complete`,`capacity`]),a=A(t.withheld,0,C.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>C.maxPageEntries||new Set(n.map(e=>B([e.provider,e.model]))).size!==n.length||r&&!nt(n,r))&&D(),{status:i,entries:n,withheld:a,remembered:r}}function it(e){let{version:t,selected:n,...r}=F(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return B({kind:`ok`,value:e},C.pageBytes),{...rt(r),version:K(t),selected:P(n,ue)}}var q={tasks:16,route:48,questions:32,checks:16,bytes:262144,context:32768,reason:1024,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4},at=[`queued`,`running`,`completed`,`failed`,`superseded`],ot=class extends Error{};function J(e,t){throw new ot(`${e}: ${t}`)}var st=e=>JSON.stringify(mt(e,80));function ct(e,t){try{return t()}catch(t){if(t instanceof ot)throw t;return J(e,t instanceof T?t.code===`oversize`?`is too long`:`is not valid`:t instanceof Error?t.message:`is not valid`)}}function lt(e,t,n,r=!1){if(t===void 0)return J(e,`is missing`);if(typeof t!=`string`)return J(e,`must be text`);if(r&&!t.trim())return J(e,`must not be empty`);let i=k(t);return i>n?J(e,`is ${i} bytes; at most ${n}`):ct(e,()=>O(t,n,r))}function ut(e,t,n,r){return t===void 0?J(e,`is missing`):Array.isArray(t)?t.length>n?J(e,`has ${t.length} entries; at most ${n}`):ct(e,()=>I(t,n,e=>e)).map((t,n)=>r(t,`${e}[${n}]`)):J(e,`must be a list`)}function dt(e,t,n,r=[]){if(t===void 0)return J(e,`is missing`);if(typeof t!=`object`||!t||Array.isArray(t))return J(e,`must be an object`);let i=Object.keys(t),a=[...n,...r],o=i.filter(e=>!a.includes(e));if(o.length)return J(e,`has no field ${o.map(st).join(`, `)}; its fields are ${a.join(`, `)}`);let s=n.filter(e=>!i.includes(e));return s.length?J(e,`is missing ${s.join(`, `)}`):ct(e,()=>F(t,a.filter(e=>i.includes(e))))}var ft=/^(?:research-[0-9]{1,4}-)?([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/u;function pt(e){return ft.exec(e)?.[1]??null}function mt(e,t){if(e.length<=t)return e;let n=e.charCodeAt(t-1);return e.slice(0,n>=55296&&n<=56319?t-1:t)}function ht(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function gt(e,t=!1){let n=O(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`is not a plain path inside the repository (relative, forward slashes, no . or .. segment, no colon, not .git or .env)`);return n}var _t=(e,t=!1)=>{let n=O(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`is not an assignment id (lowercase letters, digits and hyphens, starting with a letter, at most 48 characters)`);return n};function vt(e,t=`check`){let n=dt(t,e,[`name`,`command`],[`timeoutMs`]);return{name:lt(`${t}.name`,n.name,128,!0),command:lt(`${t}.command`,n.command,4096,!0),...n.timeoutMs===void 0?{}:{timeoutMs:ct(`${t}.timeoutMs`,()=>{try{return A(n.timeoutMs,100,2147483647)}catch{throw Error(`is a whole number of milliseconds from 100 to 2147483647, or left out for no timeout`)}})}}}function yt(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`an assignment id is used twice`);for(;n.length<e.length;){let r=e.find(e=>!t.has(e.id)&&e.after.every(e=>t.has(e)));if(!r)throw Error(`the after lists name a missing assignment or form a cycle`);n.push(r),t.add(r.id)}return n}function bt(e,t){let n=new Set,r=t=>{for(let i of e.find(e=>e.id===t)?.after??[])n.has(i)||(n.add(i),r(i))};return yt(e),r(t),yt(e).filter(e=>n.has(e.id))}function xt(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);try{B(e,q.bytes)}catch(e){J(`plan`,e instanceof T&&e.code===`oversize`?`is larger than ${q.bytes} bytes as a whole`:`is not plain JSON data`)}let i=r?e.version:void 0;if(r&&i!==2&&i!==3)throw Error(`Unsupported delivery agreement version`);let a=i===3;if(n&&!a)throw Error(`Publish a new delivery agreement; earlier agreements are readonly`);let o=dt(`plan`,e,[`goal`,`design`,`decisions`,`acceptance`,...a?[`version`,`assumptions`,`documents`,`reviewReads`,`policy`]:r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),s=(e,t)=>ut(t,e,16,(e,t)=>ct(t,()=>{let t=gt(e,n);if(!t.endsWith(`.md`))throw Error(`must be a Markdown file (.md)`);return t})),c=ut(`tasks`,o.tasks,q.tasks,(e,t)=>{let r=dt(t,e,[`id`,`title`,`instructions`,`writes`,`after`,...a?[`reads`]:[]]);return{id:ct(`${t}.id`,()=>_t(r.id,n)),title:lt(`${t}.title`,r.title,256,!0),instructions:lt(`${t}.instructions`,r.instructions,8192,!0),writes:ut(`${t}.writes`,r.writes,128,(e,t)=>ct(t,()=>gt(e,n))),after:ut(`${t}.after`,r.after,q.tasks,(e,t)=>ct(t,()=>_t(e,n))),...a?{reads:wt(r.reads,n,`${t}.reads`)}:{}}});c.length||J(`tasks`,`needs at least one assignment`);let l=c.map(e=>e.id);for(let[e,t]of c.entries()){let n=`tasks[${e}]`;l.indexOf(t.id)!==e&&J(`${n}.id`,`${st(t.id)} is already the id of tasks[${l.indexOf(t.id)}]`),t.writes.length||J(`${n}.writes`,`needs at least one path this assignment writes`),new Set(t.writes).size!==t.writes.length&&J(`${n}.writes`,`lists a path twice`),new Set(t.after).size!==t.after.length&&J(`${n}.after`,`lists an assignment twice`);let r=t.after.find(e=>!l.includes(e));r!==void 0&&J(`${n}.after`,`names ${st(r)}, which is not the id of an assignment in tasks`)}ct(`tasks`,()=>yt(c));for(let e of r?[]:c)for(let t of c)if(!(e.id>=t.id||bt(c,e.id).some(e=>e.id===t.id)||bt(c,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>ht(t.writes,e))||t.writes.some(t=>ht(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let u=(e,t,n)=>ut(t,e,n,vt),d=u(o.checks,`checks`,q.checks);d.length||J(`checks`,`needs at least one real verification command`);let f={goal:lt(`goal`,o.goal,8192,!0),design:lt(`design`,o.design,32768,!0),decisions:lt(`decisions`,o.decisions,16384),acceptance:lt(`acceptance`,o.acceptance,16384,!0),...a?{version:3,assumptions:lt(`assumptions`,o.assumptions,16384),documents:s(o.documents,`documents`),reviewReads:wt(o.reviewReads,n,`reviewReads`),policy:{installs:ct(`policy.installs`,()=>{try{return j(dt(`policy`,o.policy,[`installs`]).installs)}catch(e){throw e instanceof ot?e:Error(`must be true or false`)}})}}:r?{version:2,knowledge:s(o.knowledge,`knowledge`)}:{projectContext:lt(`projectContext`,o.projectContext,16384),repairAttempts:ct(`repairAttempts`,()=>A(o.repairAttempts,0,2))},tasks:c,checks:d,setup:ut(`setup`,o.setup,4,(e,t)=>{let{placement:r,...i}=dt(t,e,[`name`,`command`,...n?[`placement`]:[]],[`timeoutMs`,...n?[]:[`placement`]]);return{...vt(i,t),...r===void 0?{}:{placement:ct(`${t}.placement`,()=>M(r,[`target`,`candidate`,`worktree`]))}}}),baselineChecks:u(o.baselineChecks,`baselineChecks`,q.checks),delivery:ct(`delivery`,()=>{try{return M(o.delivery,[`local-merge`,`working-copy`])}catch{throw Error(`is local-merge or working-copy`)}})},p=k(Tt(f));p>q.context&&J(`plan`,`goal, design, decisions, assumptions and acceptance are ${p} bytes together (${[`goal`,`design`,`decisions`,`assumptions`,`acceptance`].map(e=>`${e} ${k(f[e]??``)}`).join(`, `)}); together at most ${q.context}`);let m=k(Ct(f).join(`, `));m>16384&&J(`tasks`,`the write paths of all assignments and documents are ${m} bytes together; at most 16384`);let h=(e,t)=>(e??[]).flatMap((e,n)=>[[`${t}[${n}].reason`,e.reason],[`${t}[${n}].section`,`section`in e?e.section??``:``]]);for(let[e,t]of[[`goal`,f.goal],[`design`,f.design],[`decisions`,f.decisions],[`acceptance`,f.acceptance],[`assumptions`,f.assumptions??``],[`projectContext`,f.projectContext??``],...h(f.reviewReads,`reviewReads`),...f.tasks.flatMap((e,t)=>[[`tasks[${t}].title`,e.title],[`tasks[${t}].instructions`,e.instructions],...h(e.reads,`tasks[${t}].reads`)]),...[`checks`,`setup`,`baselineChecks`].flatMap(e=>f[e].flatMap((t,n)=>[[`${e}[${n}].name`,t.name],[`${e}[${n}].command`,t.command]]))])[...t].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
4
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[--]/u.test(e))&&J(e,`contains an invisible control character (only newline and tab are accepted)`);return f}function St(e){return e.documents??e.knowledge??[]}function Ct(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...St(e)])]}function wt(e,t,n){return ut(n,e,16,(e,n)=>{if(Object.hasOwn(e??{},`research`)){let t=dt(n,e,[`research`,`reason`]),r=typeof t.research==`string`?pt(t.research):null;return r===null&&J(`${n}.research`,`${typeof t.research==`string`?`${st(t.research)} `:``}is not an investigation; give the "investigation" value of a completed research step`),{research:r,reason:lt(`${n}.reason`,t.reason,q.reason,!0)}}let r=dt(n,e,[`path`,`reason`],[`section`]);return{path:ct(`${n}.path`,()=>gt(r.path,t)),...r.section===void 0?{}:{section:lt(`${n}.section`,r.section,256,!0)},reason:lt(`${n}.reason`,r.reason,q.reason,!0)}})}var Tt=e=>`# ${e.goal}\n\nInitial route (${e.version===3?`the owner may revise it`:`adapt within the approved boundary`}): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}${e.assumptions?`\n\nAssumptions confirmed with the agreement: ${e.assumptions}`:``}\n\nAcceptance: ${e.acceptance}`;function Et(e){let t=O(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Dt(e){let t=O(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function Ot(e){let t=O(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function kt(e){let t=F(e,[`policy`,`target`]),n=F(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:M(t.policy,[`task-branch-v1`]),target:{checkoutRoot:Ot(n.checkoutRoot),repository:Ot(n.repository),repositoryIdentity:R(n.repositoryIdentity),branch:Dt(n.branch),head:Et(n.head)}}}function At(e){let t=F(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=F(t.integration,[`status`,`before`,`after`,`reason`]),r=F(t.cleanup,[`status`,`reason`]),i=e=>O(e,160,!0),a=P(t.acceptance,e=>{let t=F(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=I(t.checks,q.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Et(t.candidate),tree:Et(t.tree),planDigest:R(t.planDigest),contextDigest:R(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:I(t.waived,q.checks,i).filter(e=>n.includes(e))}}}),o=P(t.candidate,Et);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=P(t.workspace,e=>{let t=F(e,[`head`,`state`]);return{head:Et(t.head),state:M(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=kt(t.binding),l=Dt(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:Ot(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:I(t.artifacts,256,e=>{let t=F(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:_t(t.id),path:Ot(t.path),base:Et(t.base),head:Et(t.head),applied:P(t.applied,Et),state:M(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:M(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:M(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Et(n.before),after:P(n.after,Et),reason:O(n.reason,2048)},postChecks:M(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:M(r.status,[`pending`,`removed`,`retained`]),reason:O(r.reason,2048)}}}function jt(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate. Independent conversations may use separate candidates concurrently.\nAcceptance: checks and automatic Agent review of the exact candidate. A verified, non-overlapping sibling delivery may be merged into the isolated candidate, followed by fresh checks and review.\nDelivery: serialized fast-forward only into the bound target at its approved, verified-sibling or own last confirmed baseline. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function Mt(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=F(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...Object.hasOwn(e??{},`revalidatedFrom`)?[`revalidatedFrom`]:[],...t?[`display`]:[]]);return{...n.revalidatedFrom===void 0?{}:{revalidatedFrom:L(n.revalidatedFrom)},...n.delivery===void 0?{}:{delivery:kt(n.delivery)},id:L(n.id),epoch:L(n.epoch),digest:R(n.digest),observation:R(n.observation),model:K(n.model),plan:xt(n.plan),cwd:O(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:O(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=F(n.display,[`model`,`branch`,`baseCommit`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:O(e.runtime,4096,!0)},model:O(e.model,1024,!0),branch:O(e.branch,1024),baseCommit:O(e.baseCommit,64)}})()}:{}}}function Nt(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=F(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=I(n.questions,q.questions,e=>O(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:I(n.roots,8,e=>O(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:O(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:K(n.model)}}if(t===`propose`){let n=F(e,[`action`,`plan`,`model`]);return{action:t,plan:xt(n.plan),model:K(n.model)}}if(t===`prepare`||t===`execute`){let n=F(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:L(n.proposalId),digest:R(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:L(n.grant)}}let n=F(e,[`action`,`runId`]);return{action:M(n.action,[`cancel`]),runId:L(n.runId)}}function Pt(e){let t=F(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`scope`)?[`scope`]:[],...Object.hasOwn(e??{},`deviations`)?[`deviations`]:[],...Object.hasOwn(e??{},`tasks`)?[`tasks`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>M(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=F(t.verification,[`id`,`source`,`steps`]);return{id:L(e.id),source:R(e.source),steps:I(e.steps,32,e=>O(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:A(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:A(t.revision,0)},...t.scope===void 0?{}:{scope:I(t.scope,1024,e=>gt(e))},...t.deviations===void 0?{}:{deviations:I(t.deviations,16,e=>{let t=F(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:A(t.revision,0),item:O(t.item,2048,!0),reason:O(t.reason,4096,!0),delivered:O(t.delivered,4096,!0),waives:I(t.waives,16,e=>O(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:I(t.tasks,q.route,e=>{let t=F(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:_t(t.id),title:O(t.title,256,!0),after:I(t.after,q.tasks,e=>_t(e)),state:M(t.state,at),...t.revision===void 0?{}:{revision:A(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:At(t.delivery)},...t.execution===void 0?{}:{execution:Qe(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Ht(t.diagnostics)},id:L(t.id),epoch:L(t.epoch),goal:O(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:M(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:O(t.notice,2048),mergedCommit:P(t.mergedCommit,e=>O(e,64,!0)),humanReviewed:!1,steps:I(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=F(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Vt(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=F(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:O(e.sdkVersion,128,!0),workerHash:R(e.workerHash)}})()},id:O(r.id,160,!0),...t?{childRunId:L(r.childRunId)}:{},kind:M(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:[`implementation`,`knowledge`].includes(r.kind)&&[`partial`,`blocked`].includes(r.status)?M(r.status,[`partial`,`blocked`]):n(r.status),text:O(r.text,65536),exitCode:P(r.exitCode,e=>A(e,-2147483648,2147483647)),truncated:j(r.truncated)}})}}function Ft(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Pt(F(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Mt(F(e,[`type`,`proposal`]).proposal)};let n=F(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:M(n.type,[`grant`]),proposal:Mt(n.proposal),grant:L(n.grant),expiresAt:A(n.expiresAt,0)}}var It=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,Lt=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function Rt(e){return e.version===3?`After approval the service works to completion without further confirmation. It may on its own: retry and repair a failed assignment; revise the route, the assignments and their order; and bring further repository files into the write scope (never credentials, keys, .env, .git or files outside the repository). When an acceptance item or decision proves impossible it delivers the closest achievable result as a recorded deviation, which names the item, the evidence and what was delivered instead, must be confirmed necessary and minimal by the independent Agent review, and leads the final report. Declared checks always run; a check is set aside only through such a deviation, never silently. At the end it maintains the project's knowledge store under .cadence/ within its fixed budget, adding what this delivery taught and removing what went stale, when a fast-forward can carry it. It stops only for a condition outside the repository: an unavailable model, failed authentication, storage or permission limits, a target branch changed from outside, or a required installation this agreement does not allow. ${e.policy?.installs?`Revisions may add dependency-installation commands with the project's own package manager.`:`No dependency installation beyond the setup commands listed here.`}`:e.version===2?`Retained agreement (readonly): diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`}function zt(e){let t=St(e);return`# ${e.goal}\n\n## Initial route (the service may revise it)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}${e.version===3?`\n\n## Assumptions (confirmed by approval)\n${e.assumptions||`None beyond the decisions above.`}`:``}\n\n## Tasks\n${yt(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}${e.reads?.length?`\nReads first: ${e.reads.map(Lt).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
3
|
+
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var x=`cadence-graph/2`,S=`cadence-public-export/2`,C=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,cookieLifetimeMs:31536e6,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,coordinatorBytes:393216,chunkBytes:8192,detailBytes:33554432,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),w=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],T=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function E(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function D(){throw new T}function O(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&D(),k(e)>t)throw new T(`oversize`);return e}function k(e){return new TextEncoder().encode(e).length}function A(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&D(),e}function j(e){return typeof e!=`boolean`&&D(),e}function M(e,t){return(typeof e!=`string`||!t.includes(e))&&D(),e}function N(e,t){return e!==t&&D(),t}function P(e,t){return e===null?null:t(e)}function F(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&D();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&D();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&D(),r[n]=t.value}return r}function I(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&D();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&D(),r.push(n(i.value))}return r}function L(e){let t=O(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||D(),t}var R=Object.freeze({checkout:e=>I(e,8,e=>O(e,1024,!0)),path:e=>O(e,1024,!0),section:e=>O(e,512,!0),match:e=>O(e,256,!0),investigation:L});function z(e){let t=O(e,64);return/^[0-9a-f]{64}$/.test(t)||D(),t}function B(e){let t=O(e,C.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||D(),t}function V(e,t){return B(e),B(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ee(e){let t=O(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||D(),t}function H(e,t=C.controlBytes){let n=t,r=e=>{if(n-=k(e),n<0)throw new T(`oversize`);return e};function i(e,n){if(n>64&&D(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return O(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||D(),r(JSON.stringify(e));if(Array.isArray(e)){let a=I(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&D();let a=t.sort(),o=F(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return D()}return i(e,0)}function te(e,t=C.controlBytes){O(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return O(JSON.parse(e.slice(r,n)),t)}catch{return D()}i=!i&&a===`\\`}return D()}function a(t){if(t>64&&D(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&D(),d=i(),u.has(d)&&D(),u.add(d),r(),e[n++]!==`:`&&D());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&D()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||D(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&D(),s}let o=a(0);return r(),n!==e.length&&D(),o}function ne(e){let t=F(e,[`code`,`effect`,`recovery`]);return{code:M(t.code,w),effect:M(t.effect,[`none`,`accepted`,`uncertain`]),recovery:M(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var re=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],ie=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],ae=[`not-launched`,`direct-child-closed`,`unconfirmed`],oe=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],se=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ce(e){let t=F(e,[`provider`,`model`,`api`,`thinking`]);return{provider:O(t.provider,128,!0),model:O(t.model,256,!0),api:M(t.api,oe),thinking:M(t.thinking,se)}}function U(e){let{sourceSelectionId:t,...n}=F(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:L(t),...ce(n)}}function le(e){let t=F(e,[`role`,`sha256`]);return{role:M(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:z(t.sha256)}}function ue(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function W(e){let t=F(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:L(t.recordId),version:A(t.version,1),field:M(t.field,re),bytes:A(t.bytes,0,C.detailBytes),sha256:z(t.sha256)}}function de(e){let t=F(e,[`start`,`end`]),n=A(t.start);return{start:n,end:A(t.end,n+1,C.detailBytes)}}function fe(e){let t=F(e,[`source`,`range`,`requireCompleteObservation`]),n=pe(t.source),r;if(n===`current`)r={kind:n,assignmentId:ee(F(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=F(t.source,[`kind`,`runId`,`childRunId`,`result`]);N(n,`historical`);let i=W(e.result);N(i.field,`final-text`),r={kind:`historical`,runId:L(e.runId),childRunId:L(e.childRunId),result:i}}let i=P(t.range,de);return r.kind===`historical`&&i&&i.end>r.result.bytes&&D(),{source:r,range:i,requireCompleteObservation:j(t.requireCompleteObservation)}}function pe(e,t=`kind`){(typeof e!=`object`||!e)&&D();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&D(),O(n.value,64,!0)}function G(e){H(e,C.graphBytes);let t=F(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=W(t.plan);N(n.field,`plan`);let r=A(t.planRevision,1);n.version!==r&&D();let i={schema:N(t.schema,x),taskId:L(t.taskId),taskKind:M(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:A(t.taskRevision,1),revision:A(t.revision,1),planRevision:r,plan:n,assignments:I(t.assignments,C.assignments,e=>{let t=F(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ee(t.id),purpose:M(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:O(t.instructions,C.instructionsBytes,!0),expectedOutput:O(t.expectedOutput,C.expectedOutputBytes,!0),role:le(t.role),model:U(t.model),dependencies:I(t.dependencies,C.assignments,fe)}})};i.assignments.length||D();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&D();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&D(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=H(n.source);if(t.has(e)&&D(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||D(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==ue(e.purpose))throw new T(`forbidden`);c(e)}return i}function me(e){let t=F(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=P(t.graphRevision,e=>A(e,1)),r=P(t.graphIdentity,z);return n===null!=(r===null)&&D(),{id:L(t.id),kind:M(t.kind,[`code`,`research`,`diagnosis`]),revision:A(t.revision,1),identity:z(t.identity),graphRevision:n,graphIdentity:r}}function he(e){let t=F(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=F(t.observation,[`identity`,`complete`]);return{epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),configRev:A(t.configRev,1),controlRev:A(t.controlRev,1),workspaceId:L(t.workspaceId),cwdId:L(t.cwdId),model:U(t.model),checkEnvGeneration:A(t.checkEnvGeneration,1),checkoutGeneration:A(t.checkoutGeneration),observation:{identity:z(n.identity),complete:j(n.complete)},task:P(t.task,me)}}function ge(e){let t=F(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:M(t.kind,[`configured`,`manual`]),name:O(t.name,128,!0),command:O(t.command,4096,!0),timeoutMs:A(t.timeoutMs,100,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&D(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&D(),n}function _e(e){switch(H(e),pe(e)){case`create`:{let t=F(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:M(t.taskKind,[`code`,`research`,`diagnosis`]),goal:O(t.goal,8192,!0)}}case`save-plan`:{let t=F(e,[`kind`,`taskId`,`plan`,`graph`]),n=G(t.graph),r=L(t.taskId);return n.taskId!==r&&D(),{kind:`save-plan`,taskId:r,plan:O(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:pe(e),taskId:L(F(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=F(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:L(t.taskId),check:ge(t.check)}}case`review`:{let t=F(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:L(t.taskId),runId:L(t.runId),changesIdentity:z(t.changesIdentity),checksRevision:A(t.checksRevision),acceptIssues:j(t.acceptIssues)}}default:return D()}}function ve(e){H(e);let t=F(e,[`expected`,`action`]);return{expected:he(t.expected),action:_e(t.action)}}function ye(e){H(e);let t=F(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:L(t.commandId),grant:L(t.grant),expected:he(t.expected),action:_e(t.action)}}function be(e){if(H(e),pe(e)===`action`){let t=F(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:he(t.expected),action:_e(t.action)}}let t=F(e,[`kind`,`epoch`,`runId`]);return N(t.kind,`cancel`),{kind:`cancel`,epoch:L(t.epoch),runId:L(t.runId)}}function K(e){let t=F(e,[`commandId`,`epoch`,`runId`]);return{commandId:L(t.commandId),epoch:L(t.epoch),runId:L(t.runId)}}function xe(e){H(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=F(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=I(n.configuredChecks,32,ge);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&D(),{...t?{checkEnvironmentPolicy:N(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:A(n.checksRevision),reviewRunId:P(n.reviewRunId,L),version:he(n.version),action:_e(n.action),rootLabel:O(n.rootLabel,4096,!0),cwdLabel:O(n.cwdLabel,4096,!0),readablePlan:O(n.readablePlan,32768),graph:P(n.graph,G),activeRunId:P(n.activeRunId,L),issues:I(n.issues,7,e=>M(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Se(e){H(e);let t=F(e,[`grant`,`expiresAt`,`preview`]),n=O(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&D(),{grant:L(t.grant),expiresAt:n,preview:xe(t.preview)}}function Ce(e){let t=F(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:M(t.observed,[`complete`,`incomplete`]),source:M(t.source,[`complete`,`limited`,`unavailable`]),redacted:j(t.redacted),omissions:I(t.omissions,6,e=>M(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&D(),n}function we(e){let t=F(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:A(t.graphRevision,1),inputs:I(t.inputs,C.assignments,e=>{let t=F(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=W(t.result);N(i.field,`final-text`);let a=P(t.range,de);a&&a.end>i.bytes&&D();let o=O(t.text,C.predecessorBytes);if(n+=k(o),n>C.handoffBytes)throw new T(`oversize`);let s=A(t.dependencyIndex,0,C.assignments-1);return r.has(s)&&D(),r.add(s),k(o)!==(a?a.end-a.start:i.bytes)&&D(),{assignmentId:ee(t.assignmentId),dependencyIndex:s,runId:L(t.runId),childRunId:L(t.childRunId),result:i,range:a,text:o,coverage:Ce(t.coverage)}})}}function Te(e){let t=F(e,[`source`,`reason`,`target`]);return{source:M(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:O(t.reason,128,!0),target:O(t.target,128,!0)}}function Ee(e){let t=F(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Te(t.stop)},outcome:M(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:M(t.closure,ae),exitCode:P(t.exitCode,e=>A(e,-2147483648,4294967295)),signal:P(t.signal,e=>O(e,32,!0)),durationMs:A(t.durationMs),stdin:M(t.stdin,[`delivered`,`failed`,`not-required`]),final:M(t.final,[`valid`,`missing`,`invalid`]),cleanup:M(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Ce(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&D(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&D(),n}function De(e){let t=F(e,[`kind`,`id`]);return{kind:M(t.kind,[`task`,`run`,`child`]),id:L(t.id)}}function Oe(e){let t=O(e,C.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||D(),t}function ke(e){H(e);let t=F(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:L(t.storeId),scope:De(t.scope),query:P(t.query,e=>{let t=O(e,C.queryBytes);return t.length||D(),t}),snapshotSeq:B(t.snapshotSeq),recordId:P(t.recordId,L),recordVersion:P(t.recordVersion,e=>A(e,1)),field:P(t.field,e=>M(e,re)),offset:A(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&D(),n}function Ae(e){let t=F(e,[`disposition`,`value`]),n=M(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&D(),{disposition:n,value:r}}function je(e){let t=F(e,[`messageId`,`blockId`]);return{messageId:L(t.messageId),blockId:L(t.blockId)}}function Me(e){let t=pe(e);if(t===`message-final`)return{kind:t,messageId:L(F(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:M(F(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=F(e,[`kind`,`dependencyIndex`,`source`]),r=W(n.source);return N(r.field,`final-text`),{kind:t,dependencyIndex:A(n.dependencyIndex,0,C.assignments-1),source:r}}if(t===`message`){let n=F(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:L(n.messageId),blockId:L(n.blockId),index:A(n.index,0,C.dataFrames),stage:M(n.stage,[`stream`,`final`])}}let n=F(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return N(t,`tool`),{kind:`tool`,callId:L(n.callId),blockId:L(n.blockId),index:A(n.index,0,C.dataFrames),stage:M(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=F(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=M(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=M(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&D(),{owner:n,field:r,encoding:i}}function Pe(e){let t=F(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=M(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=M(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=P(t.mimeType,e=>O(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&D(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=O(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||D(),t}function Ie(e){let t=F(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`,...Object.hasOwn(e??{},`reason`)?[`reason`]:[]]),n=A(t.maxAttempts,1),r={phase:M(t.phase,[`waiting`,`requesting`]),attempt:A(t.attempt,1,n),maxAttempts:n,delayMs:A(t.delayMs,0,2147483647),...t.reason===void 0?{}:{reason:O(t.reason,256,!0)}};if(r.phase===`requesting`&&r.delayMs!==0)throw new T(`invalid`);return r}function Le(e){let t=pe(e);switch(t){case`ready`:{let n=F(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:N(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=F(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:O(e.sdkVersion,128,!0),workerHash:z(e.workerHash)}})()}}}case`message-start`:{let n=F(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=M(n.role,[`user`,`assistant`,`tool-result`]),i=P(n.resultCallId,L);return r!==`tool-result`&&i!==null&&D(),{kind:t,messageId:L(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`thinking-activity`:{let n=F(e,[`kind`,`messageId`,`index`,`phase`]);return{kind:t,messageId:L(n.messageId),index:A(n.index,0,C.dataFrames),phase:M(n.phase,[`active`,`complete`,`unavailable`])}}case`message-text`:{let n=F(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:L(n.detailId)}}case`message-end`:{let n=F(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:L(n.messageId),finalDetailId:P(n.finalDetailId,L),finalBlockCount:A(n.finalBlockCount,0,C.dataFrames),stopReason:M(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=F(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:L(n.callId),declaration:je(n.declaration),index:A(n.index,0,C.dataFrames),source:Ae(n.source),name:O(n.name,128,!0),argsDetailId:P(n.argsDetailId,L),stage:M(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=F(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:L(n.callId),declaration:P(n.declaration,je),source:Ae(n.source),name:O(n.name,128,!0),argsDetailId:P(n.argsDetailId,L)}}case`tool-update`:{let n=F(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:L(n.callId),detailId:L(n.detailId),semantics:N(n.semantics,`snapshot`)}}case`tool-end`:{let n=F(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=M(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=P(n.declaration,je),a=j(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&D(),{kind:t,callId:L(n.callId),declaration:i,source:Ae(n.source),name:O(n.name,128,!0),resultDetailId:L(n.resultDetailId),isError:j(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(F(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=F(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:L(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=F(e,[`kind`,`detailId`,`offset`,`text`]),r=O(n.text,C.chunkBytes),i=A(n.offset,0,C.detailBytes);return i+k(r)>C.detailBytes&&D(),{kind:t,detailId:L(n.detailId),offset:i,text:r}}case`detail-end`:{let n=F(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:L(n.detailId),bytes:A(n.bytes,0,C.detailBytes),sha256:z(n.sha256),coverage:Ce(n.coverage)}}case`model-retry`:return{kind:t,progress:P(F(e,[`kind`,`progress`]).progress,Ie)};case`capture-status`:return{kind:t,coverage:Ce(F(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:M(F(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=F(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:L(n.messageId),detailId:L(n.detailId),stopReason:N(n.stopReason,`stop`)}}default:return D()}}function Re(e){let t=F(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Te(t.stop)},outcome:M(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:M(t.closure,ae),exitCode:P(t.exitCode,e=>A(e,-2147483648,4294967295)),signal:P(t.signal,e=>O(e,32,!0)),durationMs:A(t.durationMs),stdin:N(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&D(),n}function ze(e){let t=F(e,[`messageId`,`detailId`]);return{messageId:L(t.messageId),detailId:L(t.detailId)}}function Be(e){let t=F(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=B(t.committedSeq);return n===`0`&&D(),{childRunId:L(t.childRunId),detailId:L(t.detailId),content:W(t.content),committedSeq:n}}function Ve(e){let t=pe(e,`status`);if(t===`committed`){let n=F(e,[`status`,`selected`,`detail`]),r=ze(n.selected),i=Be(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&D(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=F(e,[`status`,`selected`,`error`]);return{status:t,selected:P(n.selected,ze),error:ne(n.error)}}let n=F(e,[`status`,`selected`]);return{status:M(t,[`pending`,`uncertain`]),selected:P(n.selected,ze)}}function He(e,t){let n=P(e,B);return(n===`0`||n!==null&&t.status===`committed`&&V(n,t.detail.committedSeq)<0)&&D(),n}function Ue(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function We(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Ue(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function Ge(e){let t=pe(e);if(t===`sdk`){let n=F(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ve(n.recording),i=He(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=F(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=P(n.settlementSeq,B);return r===`0`&&D(),{kind:t,native:Re(n.native),capture:Ce(n.capture),settlementSeq:r}}let n=F(e,[`kind`,`outcome`,`required`]);N(t,`parent`);let r=I(n.required,C.assignments,e=>{let t=F(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=L(t.childRunId),r=Ve(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&D(),{assignmentId:ee(t.assignmentId),childRunId:n,native:P(t.native,Ee),recording:r,settlementSeq:He(t.settlementSeq,r)}}),i=M(n.outcome,ie);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(Ue))&&D(),{kind:`parent`,outcome:i,required:r}}function Ke(e){let t=F(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=A(t.first,1,2**53-1),r=A(t.last,n,2**53-1),i=A(t.firstObservedMs),a=A(t.lastObservedMs,i);return n===r&&i!==a&&D(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function qe(e){let t=F(e,[`source`,`event`]),n=Ke(t.source),r=pe(t.event);if(r===`stored-chunk`){let e=F(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:L(e.detailId),text:O(e.text,C.chunkBytes)}}}if(r===`stored-end`){let e=F(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:L(e.detailId),coverage:Ce(e.coverage)}}}let i=Le(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&D(),{source:n,event:i}}function Je(e){let t=F(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:L(t.epoch),taskId:L(t.taskId),runId:L(t.runId),childRunId:L(t.childRunId)}}function Ye(e){let t=O(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||D(),t}function Xe(e){let t=F(e,[`id`,`cwd`]);return{id:Ye(t.id),cwd:O(t.cwd,4096,!0)}}function Ze(e){let t=F(e,[`id`,`cwd`,`revision`,`model`]);return{id:Ye(t.id),cwd:O(t.cwd,4096,!0),revision:A(t.revision,0,2**53-1-1),model:P(t.model,ce)}}function Qe(e){let t=F(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:O(t.cwd,4096,!0),checkoutRoot:O(t.checkoutRoot,4096,!0),version:q(t.version),model:P(t.model,U)}}function q(e){let t=F(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:Xe(t.conversation)},epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),configRev:A(t.configRev,1),catalogId:L(t.catalogId)}}function $e(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`version`,`selected`]);return{version:q(t.version),selected:P(t.selected,U)}}function et(e){H(e);let t=F(e,[`expected`,`choice`]);return{expected:q(t.expected),choice:ce(t.choice)}}function tt(e){let t=F(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:j(t.images)},...t.contextWindow===void 0?{}:{contextWindow:A(t.contextWindow,1)},provider:O(t.provider,128,!0),model:O(t.model,256,!0),api:P(t.api,e=>M(e,oe)),thinking:I(t.thinking,7,e=>{let t=F(e,[`level`,`selectable`]);return{level:M(t.level,se),selectable:j(t.selectable)}}),eligibility:M(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&D(),n}function nt(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function rt(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`status`,`entries`,`withheld`,`remembered`]),n=I(t.entries,C.maxPageEntries,tt),r=P(t.remembered,ce),i=M(t.status,[`complete`,`capacity`]),a=A(t.withheld,0,C.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>C.maxPageEntries||new Set(n.map(e=>H([e.provider,e.model]))).size!==n.length||r&&!nt(n,r))&&D(),{status:i,entries:n,withheld:a,remembered:r}}function it(e){let{version:t,selected:n,...r}=F(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return H({kind:`ok`,value:e},C.pageBytes),{...rt(r),version:q(t),selected:P(n,U)}}var J={tasks:16,route:48,questions:32,checks:16,bytes:262144,context:32768,reason:1024,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4},at=[`queued`,`running`,`completed`,`failed`,`superseded`],ot=class extends Error{};function Y(e,t){throw new ot(`${e}: ${t}`)}var st=e=>JSON.stringify(mt(e,80));function ct(e,t){try{return t()}catch(t){if(t instanceof ot)throw t;return Y(e,t instanceof T?t.code===`oversize`?`is too long`:`is not valid`:t instanceof Error?t.message:`is not valid`)}}function lt(e,t,n,r=!1){if(t===void 0)return Y(e,`is missing`);if(typeof t!=`string`)return Y(e,`must be text`);if(r&&!t.trim())return Y(e,`must not be empty`);let i=k(t);return i>n?Y(e,`is ${i} bytes; at most ${n}`):ct(e,()=>O(t,n,r))}function ut(e,t,n,r){return t===void 0?Y(e,`is missing`):Array.isArray(t)?t.length>n?Y(e,`has ${t.length} entries; at most ${n}`):ct(e,()=>I(t,n,e=>e)).map((t,n)=>r(t,`${e}[${n}]`)):Y(e,`must be a list`)}function dt(e,t,n,r=[]){if(t===void 0)return Y(e,`is missing`);if(typeof t!=`object`||!t||Array.isArray(t))return Y(e,`must be an object`);let i=Object.keys(t),a=[...n,...r],o=i.filter(e=>!a.includes(e));if(o.length)return Y(e,`has no field ${o.map(st).join(`, `)}; its fields are ${a.join(`, `)}`);let s=n.filter(e=>!i.includes(e));return s.length?Y(e,`is missing ${s.join(`, `)}`):ct(e,()=>F(t,a.filter(e=>i.includes(e))))}var ft=/^(?:research-[0-9]{1,4}-)?([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/u;function pt(e){return ft.exec(e)?.[1]??null}function mt(e,t){if(e.length<=t)return e;let n=e.charCodeAt(t-1);return e.slice(0,n>=55296&&n<=56319?t-1:t)}function ht(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function gt(e,t=!1){let n=O(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`is not a plain path inside the repository (relative, forward slashes, no . or .. segment, no colon, not .git or .env)`);return n}var _t=(e,t=!1)=>{let n=O(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`is not an assignment id (lowercase letters, digits and hyphens, starting with a letter, at most 48 characters)`);return n};function vt(e,t=`check`){let n=dt(t,e,[`name`,`command`],[`timeoutMs`]);return{name:lt(`${t}.name`,n.name,128,!0),command:lt(`${t}.command`,n.command,4096,!0),...n.timeoutMs===void 0?{}:{timeoutMs:ct(`${t}.timeoutMs`,()=>{try{return A(n.timeoutMs,100,2147483647)}catch{throw Error(`is a whole number of milliseconds from 100 to 2147483647, or left out for no timeout`)}})}}}function yt(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`an assignment id is used twice`);for(;n.length<e.length;){let r=e.find(e=>!t.has(e.id)&&e.after.every(e=>t.has(e)));if(!r)throw Error(`the after lists name a missing assignment or form a cycle`);n.push(r),t.add(r.id)}return n}function bt(e,t){let n=new Set,r=t=>{for(let i of e.find(e=>e.id===t)?.after??[])n.has(i)||(n.add(i),r(i))};return yt(e),r(t),yt(e).filter(e=>n.has(e.id))}function xt(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);try{H(e,J.bytes)}catch(e){Y(`plan`,e instanceof T&&e.code===`oversize`?`is larger than ${J.bytes} bytes as a whole`:`is not plain JSON data`)}let i=r?e.version:void 0;if(r&&i!==2&&i!==3)throw Error(`Unsupported delivery agreement version`);let a=i===3;if(n&&!a)throw Error(`Publish a new delivery agreement; earlier agreements are readonly`);let o=dt(`plan`,e,[`goal`,`design`,`decisions`,`acceptance`,...a?[`version`,`assumptions`,`documents`,`reviewReads`,`policy`]:r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),s=(e,t)=>ut(t,e,16,(e,t)=>ct(t,()=>{let t=gt(e,n);if(!t.endsWith(`.md`))throw Error(`must be a Markdown file (.md)`);return t})),c=ut(`tasks`,o.tasks,J.tasks,(e,t)=>{let r=dt(t,e,[`id`,`title`,`instructions`,`writes`,`after`,...a?[`reads`]:[]]);return{id:ct(`${t}.id`,()=>_t(r.id,n)),title:lt(`${t}.title`,r.title,256,!0),instructions:lt(`${t}.instructions`,r.instructions,8192,!0),writes:ut(`${t}.writes`,r.writes,128,(e,t)=>ct(t,()=>gt(e,n))),after:ut(`${t}.after`,r.after,J.tasks,(e,t)=>ct(t,()=>_t(e,n))),...a?{reads:wt(r.reads,n,`${t}.reads`)}:{}}});c.length||Y(`tasks`,`needs at least one assignment`);let l=c.map(e=>e.id);for(let[e,t]of c.entries()){let n=`tasks[${e}]`;l.indexOf(t.id)!==e&&Y(`${n}.id`,`${st(t.id)} is already the id of tasks[${l.indexOf(t.id)}]`),t.writes.length||Y(`${n}.writes`,`needs at least one path this assignment writes`),new Set(t.writes).size!==t.writes.length&&Y(`${n}.writes`,`lists a path twice`),new Set(t.after).size!==t.after.length&&Y(`${n}.after`,`lists an assignment twice`);let r=t.after.find(e=>!l.includes(e));r!==void 0&&Y(`${n}.after`,`names ${st(r)}, which is not the id of an assignment in tasks`)}ct(`tasks`,()=>yt(c));for(let e of r?[]:c)for(let t of c)if(!(e.id>=t.id||bt(c,e.id).some(e=>e.id===t.id)||bt(c,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>ht(t.writes,e))||t.writes.some(t=>ht(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let u=(e,t,n)=>ut(t,e,n,vt),d=u(o.checks,`checks`,J.checks);d.length||Y(`checks`,`needs at least one real verification command`);let f={goal:lt(`goal`,o.goal,8192,!0),design:lt(`design`,o.design,32768,!0),decisions:lt(`decisions`,o.decisions,16384),acceptance:lt(`acceptance`,o.acceptance,16384,!0),...a?{version:3,assumptions:lt(`assumptions`,o.assumptions,16384),documents:s(o.documents,`documents`),reviewReads:wt(o.reviewReads,n,`reviewReads`),policy:{installs:ct(`policy.installs`,()=>{try{return j(dt(`policy`,o.policy,[`installs`]).installs)}catch(e){throw e instanceof ot?e:Error(`must be true or false`)}})}}:r?{version:2,knowledge:s(o.knowledge,`knowledge`)}:{projectContext:lt(`projectContext`,o.projectContext,16384),repairAttempts:ct(`repairAttempts`,()=>A(o.repairAttempts,0,2))},tasks:c,checks:d,setup:ut(`setup`,o.setup,4,(e,t)=>{let{placement:r,...i}=dt(t,e,[`name`,`command`,...n?[`placement`]:[]],[`timeoutMs`,...n?[]:[`placement`]]);return{...vt(i,t),...r===void 0?{}:{placement:ct(`${t}.placement`,()=>M(r,[`target`,`candidate`,`worktree`]))}}}),baselineChecks:u(o.baselineChecks,`baselineChecks`,J.checks),delivery:ct(`delivery`,()=>{try{return M(o.delivery,[`local-merge`,`working-copy`])}catch{throw Error(`is local-merge or working-copy`)}})},p=k(Tt(f));p>J.context&&Y(`plan`,`goal, design, decisions, assumptions and acceptance are ${p} bytes together (${[`goal`,`design`,`decisions`,`assumptions`,`acceptance`].map(e=>`${e} ${k(f[e]??``)}`).join(`, `)}); together at most ${J.context}`);let m=k(Ct(f).join(`, `));m>16384&&Y(`tasks`,`the write paths of all assignments and documents are ${m} bytes together; at most 16384`);let h=(e,t)=>(e??[]).flatMap((e,n)=>[[`${t}[${n}].reason`,e.reason],[`${t}[${n}].section`,`section`in e?e.section??``:``]]);for(let[e,t]of[[`goal`,f.goal],[`design`,f.design],[`decisions`,f.decisions],[`acceptance`,f.acceptance],[`assumptions`,f.assumptions??``],[`projectContext`,f.projectContext??``],...h(f.reviewReads,`reviewReads`),...f.tasks.flatMap((e,t)=>[[`tasks[${t}].title`,e.title],[`tasks[${t}].instructions`,e.instructions],...h(e.reads,`tasks[${t}].reads`)]),...[`checks`,`setup`,`baselineChecks`].flatMap(e=>f[e].flatMap((t,n)=>[[`${e}[${n}].name`,t.name],[`${e}[${n}].command`,t.command]]))])[...t].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
4
|
+
`&&e!==` `||e.charCodeAt(0)===127||/[--]/u.test(e))&&Y(e,`contains an invisible control character (only newline and tab are accepted)`);return f}function St(e){return e.documents??e.knowledge??[]}function Ct(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...St(e)])]}function wt(e,t,n){return ut(n,e,16,(e,n)=>{if(Object.hasOwn(e??{},`research`)){let t=dt(n,e,[`research`,`reason`]),r=typeof t.research==`string`?pt(t.research):null;return r===null&&Y(`${n}.research`,`${typeof t.research==`string`?`${st(t.research)} `:``}is not an investigation; give the "investigation" value of a completed research step`),{research:r,reason:lt(`${n}.reason`,t.reason,J.reason,!0)}}let r=dt(n,e,[`path`,`reason`],[`section`]);return{path:ct(`${n}.path`,()=>gt(r.path,t)),...r.section===void 0?{}:{section:lt(`${n}.section`,r.section,256,!0)},reason:lt(`${n}.reason`,r.reason,J.reason,!0)}})}var Tt=e=>`# ${e.goal}\n\nInitial route (${e.version===3?`the owner may revise it`:`adapt within the approved boundary`}): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}${e.assumptions?`\n\nAssumptions confirmed with the agreement: ${e.assumptions}`:``}\n\nAcceptance: ${e.acceptance}`;function Et(e){let t=O(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Dt(e){let t=O(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function Ot(e){let t=O(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function kt(e){let t=F(e,[`policy`,`target`]),n=F(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:M(t.policy,[`task-branch-v1`]),target:{checkoutRoot:Ot(n.checkoutRoot),repository:Ot(n.repository),repositoryIdentity:z(n.repositoryIdentity),branch:Dt(n.branch),head:Et(n.head)}}}function At(e){let t=F(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=F(t.integration,[`status`,`before`,`after`,`reason`]),r=F(t.cleanup,[`status`,`reason`]),i=e=>O(e,160,!0),a=P(t.acceptance,e=>{let t=F(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=I(t.checks,J.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Et(t.candidate),tree:Et(t.tree),planDigest:z(t.planDigest),contextDigest:z(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:I(t.waived,J.checks,i).filter(e=>n.includes(e))}}}),o=P(t.candidate,Et);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=P(t.workspace,e=>{let t=F(e,[`head`,`state`]);return{head:Et(t.head),state:M(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=kt(t.binding),l=Dt(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:Ot(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:I(t.artifacts,256,e=>{let t=F(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:_t(t.id),path:Ot(t.path),base:Et(t.base),head:Et(t.head),applied:P(t.applied,Et),state:M(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:M(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:M(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Et(n.before),after:P(n.after,Et),reason:O(n.reason,2048)},postChecks:M(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:M(r.status,[`pending`,`removed`,`retained`]),reason:O(r.reason,2048)}}}function jt(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate. Independent conversations may use separate candidates concurrently.\nAcceptance: checks and automatic Agent review of the exact candidate. A verified, non-overlapping sibling delivery may be merged into the isolated candidate, followed by fresh checks and review.\nDelivery: serialized fast-forward only into the bound target at its approved, verified-sibling or own last confirmed baseline. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function Mt(e,t){let n=t!==`running`&&t!==`queued`,r=n&&t!==`unknown`,i=r&&e.workspace===null&&e.preparation===`pending`,a=e=>e!==`pending`||!n?e:r?`Not executed`:`Not recorded`;return{preparation:e.preparation===`pending`&&n&&!i?`Not recorded`:a(e.preparation),missingCandidate:i?`Not executed`:`Not recorded`,integration:a(e.integration.status),cleanup:a(e.cleanup.status)}}function Nt(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=F(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...Object.hasOwn(e??{},`revalidatedFrom`)?[`revalidatedFrom`]:[],...t?[`display`]:[]]);return{...n.revalidatedFrom===void 0?{}:{revalidatedFrom:L(n.revalidatedFrom)},...n.delivery===void 0?{}:{delivery:kt(n.delivery)},id:L(n.id),epoch:L(n.epoch),digest:z(n.digest),observation:z(n.observation),model:q(n.model),plan:xt(n.plan),cwd:O(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:O(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=F(n.display,[`model`,`branch`,`baseCommit`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:O(e.runtime,4096,!0)},model:O(e.model,1024,!0),branch:O(e.branch,1024),baseCommit:O(e.baseCommit,64)}})()}:{}}}function Pt(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=F(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=I(n.questions,J.questions,e=>O(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:I(n.roots,8,e=>O(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:O(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:q(n.model)}}if(t===`propose`){let n=F(e,[`action`,`plan`,`model`]);return{action:t,plan:xt(n.plan),model:q(n.model)}}if(t===`prepare`||t===`execute`){let n=F(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:L(n.proposalId),digest:z(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:L(n.grant)}}let n=F(e,[`action`,`runId`]);return{action:M(n.action,[`cancel`]),runId:L(n.runId)}}function Ft(e){let t=F(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`scope`)?[`scope`]:[],...Object.hasOwn(e??{},`deviations`)?[`deviations`]:[],...Object.hasOwn(e??{},`tasks`)?[`tasks`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>M(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=F(t.verification,[`id`,`source`,`steps`]);return{id:L(e.id),source:z(e.source),steps:I(e.steps,32,e=>O(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:A(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:A(t.revision,0)},...t.scope===void 0?{}:{scope:I(t.scope,1024,e=>gt(e))},...t.deviations===void 0?{}:{deviations:I(t.deviations,16,e=>{let t=F(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:A(t.revision,0),item:O(t.item,2048,!0),reason:O(t.reason,4096,!0),delivered:O(t.delivered,4096,!0),waives:I(t.waives,16,e=>O(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:I(t.tasks,J.route,e=>{let t=F(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:_t(t.id),title:O(t.title,256,!0),after:I(t.after,J.tasks,e=>_t(e)),state:M(t.state,at),...t.revision===void 0?{}:{revision:A(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:At(t.delivery)},...t.execution===void 0?{}:{execution:Qe(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Ut(t.diagnostics)},id:L(t.id),epoch:L(t.epoch),goal:O(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:M(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:O(t.notice,2048),mergedCommit:P(t.mergedCommit,e=>O(e,64,!0)),humanReviewed:!1,steps:I(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=F(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Ht(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=F(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:O(e.sdkVersion,128,!0),workerHash:z(e.workerHash)}})()},id:O(r.id,160,!0),...t?{childRunId:L(r.childRunId)}:{},kind:M(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:[`implementation`,`knowledge`].includes(r.kind)&&[`partial`,`blocked`].includes(r.status)?M(r.status,[`partial`,`blocked`]):n(r.status),text:O(r.text,65536),exitCode:P(r.exitCode,e=>A(e,-2147483648,2147483647)),truncated:j(r.truncated)}})}}function It(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Ft(F(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Nt(F(e,[`type`,`proposal`]).proposal)};let n=F(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:M(n.type,[`grant`]),proposal:Nt(n.proposal),grant:L(n.grant),expiresAt:A(n.expiresAt,0)}}var Lt=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,Rt=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function zt(e){return e.version===3?`After approval the service works to completion without further confirmation. It may on its own: retry and repair a failed assignment; revise the route, the assignments and their order; and bring further repository files into the write scope (never credentials, keys, .env, .git or files outside the repository). When an acceptance item or decision proves impossible it delivers the closest achievable result as a recorded deviation, which names the item, the evidence and what was delivered instead, must be confirmed necessary and minimal by the independent Agent review, and leads the final report. Declared checks always run; a check is set aside only through such a deviation, never silently. At the end it maintains the project's knowledge store under .cadence/ within its fixed budget, adding what this delivery taught and removing what went stale, when a fast-forward can carry it. It stops only for a condition outside the repository: an unavailable model, failed authentication, storage or permission limits, a target branch changed from outside, or a required installation this agreement does not allow. ${e.policy?.installs?`Revisions may add dependency-installation commands with the project's own package manager.`:`No dependency installation beyond the setup commands listed here.`}`:e.version===2?`Retained agreement (readonly): diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`}function Bt(e){let t=St(e);return`# ${e.goal}\n\n## Initial route (the service may revise it)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}${e.version===3?`\n\n## Assumptions (confirmed by approval)\n${e.assumptions||`None beyond the decisions above.`}`:``}\n\n## Tasks\n${yt(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}${e.reads?.length?`\nReads first: ${e.reads.map(Rt).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
5
5
|
|
|
6
|
-
`)}\n\n## Setup (explicitly authorized commands)\nExecution order: target once before worktree creation, candidate once, then worktree in the candidate and every detached child; listed order within each stage. Each command is a separate process; exports do not persist.\n${e.setup.map(e=>`[${e.placement??`worktree`}] ${
|
|
7
|
-
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(
|
|
8
|
-
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(
|
|
9
|
-
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(
|
|
10
|
-
`)}`:``}\n\n## Automation boundary\n${
|
|
11
|
-
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var
|
|
12
|
-
`)}var
|
|
13
|
-
`)}function
|
|
14
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function gn(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:mn(e.text,fn);return{id:e.id,...En(e),role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?mn(hn(e.args),pn):``,error:e.error,parts:t}}function _n(e){let t=F(e,[`id`,`updatedAt`]);return{id:Ye(t.id),updatedAt:A(t.updatedAt,0)}}function vn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`project-knowledge`:return{kind:t,source:on(F(e,[`kind`,`source`]).source)};case`conversation-context`:case`reload-conversation-models`:case`conversation-models`:return{kind:t,location:Xe(F(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=F(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,an),ordinal:A(n.ordinal,0),before:P(n.before,e=>A(e,0))}}case`conversation-image`:{let n=F(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=A(n.offset,0);if(r%_.chunkChars||n.live!==void 0&&n.live!==!0)throw new T(`invalid`);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,an),...n.live===void 0?{}:{live:!0},entry:an(n.entry),index:A(n.index,0),offset:r}}case`conversation-step`:{let n=F(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,an),turnId:an(n.turnId),step:A(n.step,0),part:A(n.part,0)}}case`cadence-conversation`:return{kind:t,id:Ye(F(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=F(e,[`kind`,`id`,`leaf`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,an)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=F(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:P(r.after,L),...n?{scan:L(r.scan)}:{}}}case`workflow-active`:return F(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=F(e,[`kind`,`id`,`stepId`]);return{kind:t,id:L(n.id),stepId:O(n.stepId,160,!0)}}case`workflow`:{let n=F(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:L(n.id),...n.before===void 0?{}:{before:A(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=F(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new T(`invalid`);return{kind:t,...n?{after:P(i.after,_n)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return F(e,[`kind`]),{kind:t};case`conversation`:{let n=F(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,an),known:P(n.known,an)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=F(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=A(r.offset,0);if(i%196608||i>=67108864)throw new T(`invalid`);return{kind:t,path:O(r.path,4096),offset:i,...n?{location:Xe(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=F(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:M(r.kind,[`files`,`file`,`directories`]),path:O(r.path,4096),...n?{location:Xe(r.location)}:{}}}}}function yn(e){let t=O(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new T(`invalid`);if([...t].length>100)throw new T(`oversize`);return t}function bn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=F(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:L(n.commandId),location:Xe(n.location),expected:K(n.expected),choice:le(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=F(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new T(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:L(n.commandId),epoch:L(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:Xe(n.location)},...r?{expected:K(n.expected),choice:le(n.choice)}:{}}:{kind:t,...i,runId:L(n.runId)}}if(t===`cadence-exit`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:Xe(n.location)},commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,an),revision:A(n.revision,0)}}if(t===`image-upload`){let n=F(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new T(`invalid`);let r=bn(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new T(`invalid`);return{kind:t,commandId:L(n.commandId),imageId:L(n.imageId),send:r,mimeType:M(n.mimeType,v),size:A(n.size,1),offset:A(n.offset,0),data:O(n.data,_.chunkChars,!0)}}if(t===`cadence-send`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,an),text:O(n.text,cn),...n.images===void 0?{}:{images:I(n.images,2**53-1,L)},model:K(n.model),revision:A(n.revision,0),intent:M(n.intent,[`message`,`enter`,`exit`,`design`])}}if(t===`cadence-design-edit`){let n=F(e,[`kind`,`commandId`,`conversationId`,`revision`,`designId`,`answers`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),revision:A(n.revision,0),designId:L(n.designId),answers:qt(n.answers)}}if(t===`cadence-revalidate`){let n=F(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=Ye(n.conversationId),i=Ze(n.context);if(i.id!==r)throw new T(`invalid`);return{kind:t,commandId:L(n.commandId),conversationId:r,revision:A(n.revision,0),proposalId:L(n.proposalId),digest:R(n.digest),head:P(n.head,an),context:i,expected:K(n.expected),model:le(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=F(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:L(r.commandId),conversationId:Ye(r.conversationId),revision:A(r.revision,0),proposalId:L(r.proposalId),digest:R(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:L(r.grant)}}if(t===`workflow`){let n=F(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:L(n.commandId),epoch:L(n.epoch),request:Nt(n.request)}}if(t===`send`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,an),text:O(n.text,cn),...n.images===void 0?{}:{images:I(n.images,2**53-1,L)},model:K(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=F(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:L(n.commandId),conversationId:Ye(n.conversationId),turnId:L(n.turnId),epoch:L(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:M(n.mode,[`steer`,`queue`]),text:O(n.text,cn,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:L(n.inputId)}}if(t===`conversation-rename`){let n=F(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),name:yn(n.name)}}if(t===`conversation-archive`){let n=F(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),archived:j(n.archived)}}let n=F(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:M(n.kind,[`open-project`]),commandId:L(n.commandId),path:O(n.path,4096,!0),epoch:L(n.epoch)}}function xn(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=F(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?F(i.transcript,[`pages`]):null,o=n?F(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:Qe(i.execution)},...i.retry===void 0?{}:{retry:Ie(i.retry)},id:L(i.id),epoch:L(i.epoch),status:M(i.status,ln),notice:O(i.notice,1024),...a?{transcript:{pages:A(a.pages,0)}}:{},omitted:{thinking:o?j(o.thinking):!1,media:o?j(o.media):!1,other:o?j(o.other):!1},items:I(i.items,256,kn)}}var Sn=[`user`,`assistant`,`tool`,`thinking`];function Cn(e){return I(e,2**53-1,e=>{let t=F(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new T(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:an(t.entry),index:A(t.index,0),mimeType:M(t.mimeType,v)}})}var wn=[`renderId`,`version`,`state`];function Tn(e){return wn.filter(t=>Object.hasOwn(e??{},t))}function En(e){return{...e.renderId===void 0?{}:{renderId:e.renderId},...e.version===void 0?{}:{version:e.version},...e.state===void 0?{}:{state:e.state}}}function Dn(e){return{...e.renderId===void 0?{}:{renderId:O(e.renderId,160,!0)},...e.version===void 0?{}:{version:R(e.version)},...e.state===void 0?{}:{state:M(e.state,[`pending`,`streaming`,`running`,`completed`,`failed`,`canceled`,`unavailable`])}}}function On(e){let t=F(e,[`kind`,`sequence`,...Object.hasOwn(e??{},`name`)?[`name`]:[]]),n=M(t.kind,[`waiting`,`thinking`,`text`,`tool`]);if(t.name!==void 0&&n!==`tool`)throw new T(`invalid`);return{kind:n,sequence:A(t.sequence,0),...t.name===void 0?{}:{name:O(t.name,128)}}}function kn(e){let t=F(e,[...Tn(e),`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...Dn(t),...t.images===void 0?{}:{images:Cn(t.images)},id:O(t.id,160,!0),role:M(t.role,Sn),text:O(t.text,262144),name:O(t.name,128),args:O(t.args,65536),error:j(t.error)}}function An(e){let t=F(e,[...Tn(e),`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...Dn(t),...t.images===void 0?{}:{images:Cn(t.images)},id:O(t.id,160,!0),role:M(t.role,Sn),text:O(t.text,fn),clipped:j(t.clipped),name:O(t.name,128),target:O(t.target,pn),error:j(t.error),parts:A(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&(!n.parts&&!(n.renderId&&[`streaming`,`completed`,`unavailable`,`canceled`,`failed`].includes(n.state??``))||n.parts&&n.state!==void 0&&n.state!==`completed`))throw new T(`invalid`);return n}function jn(e){let t=F(e,[...Object.hasOwn(e??{},`activity`)?[`activity`]:[],`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=F(t.omitted,[`thinking`,`media`,`other`]),r=A(t.steps,0);return{...t.activity===void 0?{}:{activity:On(t.activity)},...t.execution===void 0?{}:{execution:Qe(t.execution)},...t.retry===void 0?{}:{retry:Ie(t.retry)},id:an(t.id),entry:P(t.entry,an),...t.parent===void 0?{}:{parent:P(t.parent,an)},at:A(t.at,0),status:M(t.status,un),notice:O(t.notice,1024),omitted:{thinking:j(n.thinking),media:j(n.media),other:j(n.other)},steps:r,stable:A(t.stable,0,r)}}function Mn(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=F(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?F(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new T(`invalid`);return{id:Ye(n.id),title:O(n.title,512,!0),leaf:P(n.leaf,an),status:M(n.status,un),updatedAt:A(n.updatedAt,0),origin:M(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:j(n.cadence)}:{},...r?{live:{commandId:L(r.commandId),epoch:L(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function Nn(e){let t=F(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:L(t.commandId),text:O(t.text,16384),status:M(t.status,un),notice:O(t.notice,1024)}}function Pn(e){let t=F(e,[`commandId`,`mode`,`text`]);return{commandId:L(t.commandId),mode:M(t.mode,[`steer`,`queue`]),text:O(t.text,256)}}function Fn(e){let t=F(e,[`tokens`,`provider`,`model`]);return{tokens:P(t.tokens,e=>A(e,1)),provider:O(t.provider,128),model:O(t.model,256)}}function In(e){let t=F(e,[`input`,`read`,`write`]);return{input:A(t.input,0),read:A(t.read,0),write:A(t.write,0)}}function Ln(e){let t=F(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:an(t.id),parent:P(t.parent,an),text:O(t.text,1024),at:A(t.at,0),leaf:an(t.leaf),current:j(t.current)}}function Rn(e){B(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=F(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:L(n.commandId),imageId:L(n.imageId),offset:A(n.offset,0)}}if(t===`conversation-image`){let n=F(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:M(n.mimeType,v),data:O(n.data,_.chunkChars,!0),next:P(n.next,e=>A(e,0))}}if(t===`conversation-context`)return{kind:t,context:Ze(F(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:it(F(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=F(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:L(n.commandId),choice:$e(n.choice)}}if(t===`workflow-transcript`){let n=F(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:L(n.runId),stepId:O(n.stepId,160,!0),turn:P(n.turn,xn)}}if(t===`cadence-conversation`)return{kind:t,state:rn(F(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=F(e,[`kind`,`after`,`scan`]);return{kind:t,after:P(n.after,L),scan:L(n.scan)}}if(t===`workflow-history`){let n=F(e,[`kind`,`entries`,`next`]),r=I(n.entries,q.historyPage,e=>{let t=F(e,[`id`,`run`]),n=L(t.id),r=P(t.run,Pt);if(r&&r.id!==n)throw new T(`invalid`);return{id:n,run:r}}),i=P(n.next,L);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new T(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=F(e,[`kind`,`runs`,...n?[`links`]:[]]),i=I(r.runs,4,Pt),a=n?I(r.links,4,e=>{let t=F(e,[`runId`,`conversationId`]);return{runId:L(t.runId),conversationId:Ye(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new T(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-revalidated`){let n=F(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:L(n.commandId),state:rn(n.state)}}if(t===`cadence-grant`){let n=F(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:L(n.commandId),grant:L(n.grant),expiresAt:A(n.expiresAt,0),revision:A(n.revision,0),proposal:Mt(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=F(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:P(t.commandId,L),response:Ft(t.response)}}if(n===`conversation-active`)return{kind:n,entries:I(F(e,[`kind`,`entries`]).entries,8,Mn)};if(n===`conversations`){let t=F(e,[`kind`,`entries`,`next`]);return{kind:n,entries:I(t.entries,200,Mn),next:P(t.next,_n)}}if(n===`conversation`){let t=F(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`cache`)?[`cache`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=P(t.summary,Mn),i=A(t.turns,0);if(!r&&i)throw new T(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:I(t.commands,64,L)},...t.context===void 0?{}:{context:Fn(t.context)},...t.cache===void 0?{}:{cache:In(t.cache)},...t.pending===void 0?{}:{pending:I(t.pending,8,Pn)},...t.undelivered===void 0?{}:{undelivered:I(t.undelivered,8,Nn)},summary:r,leaf:P(t.leaf,an),continues:j(t.continues),turns:i,branches:A(t.branches,0),runs:I(t.runs,200,L),attempt:P(t.attempt,Nn)}}if(n===`conversation-tree`){let t=F(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:Ye(t.conversationId),nodes:I(t.nodes,dn,Ln),truncated:j(t.truncated)}}if(n===`conversation-turn`){let t=F(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=jn(t.turn),i=A(t.start,0),a=I(t.steps,24,An);if(i+a.length>r.steps)throw new T(`invalid`);return{kind:n,conversationId:Ye(t.conversationId),leaf:P(t.leaf,an),ordinal:A(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=F(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:Ye(t.conversationId),leaf:P(t.leaf,an),turnId:an(t.turnId),step:A(t.step,0),part:A(t.part,0),item:kn(t.item)}}if(n===`files`||n===`directories`){let t=F(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:O(t.path,4096),parent:P(t.parent,e=>O(e,4096)),limited:j(t.limited),entries:I(t.entries,200,e=>{let t=F(e,[`name`,`path`,`directory`]);return{name:O(t.name,1024,!0),path:O(t.path,4096,!0),directory:j(t.directory)}})}}if(n===`file`){let t=F(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:O(t.path,4096),text:O(t.text,262144),limited:j(t.limited)}}if(n===`file-part`){let t=F(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=A(t.size,0),i=O(t.data,sn/3*4),a=P(t.next,e=>A(e,1)),o=O(t.version,32,!0);if(r>67108864||!/^[a-f0-9]{32}$/.test(o)||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)||a!==null&&(a%196608!=0||a>=r))throw new T(`invalid`);return{kind:n,path:O(t.path,4096),size:r,version:o,data:i,next:a}}if(n===`projects`)return{kind:n,entries:I(F(e,[`kind`,`entries`]).entries,128,e=>{let t=F(e,[`path`,`current`]);return{path:O(t.path,4096,!0),current:j(t.current)}})};if(n===`accepted`)return{kind:n,commandId:L(F(e,[`kind`,`commandId`]).commandId)};let r=F(e,[`kind`,`commandId`,`path`,`link`]);return{kind:M(r.kind,[`project`]),commandId:L(r.commandId),path:O(r.path,4096,!0),link:O(r.link,8192,!0)}}function zn(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?Ye(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Bn(e=typeof window>`u`?``:window.location.search){return zn(e,``).project}function Vn(e=typeof window>`u`?``:window.location.hash){return zn(``,e).chat}var Hn=`cadence:login-return`;function Un(e){let{chat:t}=zn(``,e);if(!t)return null;let{leaf:n,selected:r}=qn(e,t);return Jn(`#chat=${t}${r?`&activity=1`:``}`,n)}function Wn(){try{let e=Un(location.hash);sessionStorage.removeItem(Hn),e&&location.pathname===`/app`&&(!location.search||/^\?project=[a-f0-9]{64}$/.test(location.search))&&sessionStorage.setItem(Hn,JSON.stringify([location.search,e]))}catch{}}function Gn(){try{let e=sessionStorage.getItem(Hn);if(!e)return;sessionStorage.removeItem(Hn);let[t,n]=JSON.parse(e);if(location.hash||location.pathname!==`/app`||t!==location.search||typeof n!=`string`)return;let r=Un(n);r&&history.replaceState(history.state,``,r)}catch{}}function Kn(){let e=Bn();return e?`/projects/${e}`:``}function qn(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&zn(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?an(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function Jn(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,an(t)),`#${n}`}function Yn(e,t){if(typeof window>`u`||Vn()!==e)return;let n=Jn(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}var Xn={"Design choices":`设计选项`,"Fill unanswered with recommendations":`为未回答的问题填入推荐项`,"Discard typed answer":`放弃未采用的回答`,"Choose answers":`选择答案`,"Review choices":`查看或修改选择`,"{answered} of {total} questions answered":`已回答 {answered} / {total} 个问题`,"Submitting answers requests a plan, not implementation.":`提交后将根据你的选择生成实施计划,不会开始实施。`,"Plan identity":`计划标识`,Questions:`问题`,Recommended:`推荐`,Acceptance:`验收`,"Other idea":`其他想法`,"Use this answer":`采用这项回答`,"Design submitted":`设计已提交`,"Submit design and use recommendations for unanswered questions":`整批提交,未回答的问题采用推荐项`,"Thinking activity observed":`已观察到思考活动`,"Thinking activity ended":`思考活动已结束`,"Thinking content unavailable":`思考内容不可用`,"Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.":`不传输思考正文;可读取的思考内容落盘后可展开查看。`,"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The provider said: {reason}":`供应商返回:{reason}`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"The model request failed and automatic retries did not recover it.":`模型请求失败,自动重试后仍未恢复。`,"Partial work is preserved.":`已有工作已保留。`,"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Validate the plan with this model before approving it.":`请先使用此模型重新核验计划,再确认实施。`,"Restore execution and validate plan":`恢复执行服务并核验计划`,"Validate plan again":`重新核验计划`,"Validating plan…":`正在核验计划…`,"Confirm implementation":`确认实施`,"Previous execution context":`核验前的执行上下文`,"Preparing execution and validating the plan; no implementation is approved.":`正在准备执行服务并核验计划;尚未批准任何实施。`,"Reading the validated plan…":`正在读取核验后的计划…`,"The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.":`计划内容未变,已重新核验执行上下文。请查看下方当前计划后确认实施;尚未批准任何实施。`,"Repository or execution-environment evidence changed. Review the current context before confirming.":`仓库或执行环境的核验证据已变化,请查看当前上下文后再确认。`,"Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.":`核验可能启动执行服务并应用界面中选择的模型,但不会发送聊天消息或实施计划;核验后仍需确认。`,"Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.":`计划核验未完成({code})。未批准任何实施;请读取当前计划后再决定是否重新核验。`,"Preparing execution…":`正在准备执行环境…`,"Checking execution state…":`正在确认执行状态…`,"Execution state unavailable":`执行状态暂时无法确认`,"Model list unavailable":`模型目录读取失败`,"Last used: {model}":`上次使用:{model}`,"Last used model; availability is checked when you send.":`上次使用的模型,发送时会验证其可用性。`,"Execution is being prepared for your Send. Models will load when it is ready.":`正在为本次发送准备执行环境,就绪后会加载模型。`,"The model list changed. Read the current list before choosing again.":`模型列表已变化,请读取当前列表后再选择。`,"The choice was not confirmed. Read the current model before choosing again.":`模型选择结果尚未确认,请读取当前模型后再决定是否重新选择。`,"Recorded history could not be read.":`暂时无法读取历史证据。`,"Recorded history unavailable: {reason}.":`无法读取历史记录:{reason}。`,"History workspace does not match the selected owner":`历史工作区与所选执行服务不匹配`,"History anchor does not match the selected workspace":`历史链接与所选工作区不匹配`,"History identity not confirmed":`未能确认历史工作区的身份`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Connection status: {state}":`连接状态:{state}`,"Updating state…":`正在更新状态…`,"Task up to date":`任务状态已更新`,"Execution stopped":`执行服务已停止`,"Execution not started":`执行服务尚未启动`,"Browsing only":`仅浏览`,"Last known state":`仅有上次读取的状态`,"Sign-in required":`需要重新登录`,"Sign in again":`重新登录`,"Viewer access not confirmed":`未能确认此入口可连接执行服务`,"No recent update from the task connection":`最近未收到任务实时连接的更新`,"The task connection closed":`任务实时连接已关闭`,stopped:`已停止`,"Waiting for current state from this connection.":`正在等待此连接返回最新状态。`,"This owner is running independently. Browsing history does not connect it to this workbench.":`执行服务正在独立运行。浏览历史不会将它关联到此工作台。`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Workbench observation: {code}.":`工作台入口读取:{code}。`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Observing approval request {id}; no approval is replayed.":`正在查询审批请求 {id} 的结果;不会重放审批。`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,"Context {used} / {window} · {percent}%":`上下文 {used} / {window} · {percent}%`,"Context {used} tokens":`上下文 {used} tokens`,"Context unknown after compaction":`压缩后上下文大小未知`,"Context window in use":`上下文窗口占用`,"Context size not observed yet":`尚未读取到上下文大小`,"No completed model response is within reach of this branch's end, so no context size is stated.":`这条分支末尾附近还没有完成的模型回复,因此没有上下文大小。`,"Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).":`网络延迟:{ms}ms(最近一分钟内到服务最快的一次请求,从发出到收到回复首字节)。`,"Cache hit":`缓存命中`,"Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)":`缓存命中:{rate} · 缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,"Summed over every usage record of this session, on every branch.":`按本会话全部用量记录累计,包含所有分支。`,"Cache hit: this session's usage records state no input tokens yet.":`缓存命中:本会话的用量记录里还没有输入 token。`,"Context size as of the last completed model response ({model}). Messages after that response are not counted.":`上下文大小以最近一次完成的模型回复({model})为准,不包含那次回复之后的消息。`,"A compaction followed that response, so the size is unknown until the next one.":`那次回复之后做过压缩,下一次模型回复完成前无法得知大小。`,"The model list states no context window for this model, so no percentage is shown.":`模型列表没有给出这个模型的上下文窗口,因此不显示占比。`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files appear once this folder has been observed.":`读取到该目录的状态后即可浏览文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Active Pi work":`Pi 活动工作`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder":`选择工作文件夹`,"Choose a working folder to start. You can write a draft below.":`选择工作文件夹即可开始,也可以先在下方写草稿。`,"Write a message. Choose a folder before sending…":`输入消息,发送前请选择文件夹…`,"Choose a folder before sending.":`发送前请选择文件夹。`,"Returning to your last folder {path}…":`正在返回上次的文件夹 {path}…`,"Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.":`选择服务所在主机上的文件夹。会话保留在原文件夹中,运行中的工作不受影响;仅在发送消息时按需启动执行服务。`,"Connecting…":`正在连接…`,"Ready to prepare execution":`可按需准备执行服务`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.":`执行服务准备被拒绝,未产生任何变更({code})。本次未启动执行服务;消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Conversation context: {code}.":`对话上下文:{code}。`,"Conversation read: {code}.":`对话读取:{code}。`,"Project directories: {code}.":`项目目录:{code}。`,"Conversation activity: {code}.":`活跃对话:{code}。`,"Workflow activity: {code}.":`活跃工作流:{code}。`,"Recorded workflows: {code}.":`已记录的工作流:{code}。`,"Workflow observation: {code}.":`工作流观察:{code}。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.":`批准覆盖本目标及其决定、验收标准和假设。之后由服务自行完成:它可以在仓库内调整路线和写入范围;对验收的任何偏离都会记录下来,交给自动审查确认,并在最终报告中置顶。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Waiting messages":`等待中的消息`,"Steering: read at the model's next step":`插队:模型下一步就会读到`,"Queued: sent when this reply ends":`排队:这条回复结束后发送`,Withdraw:`撤回`,"Withdraw and put back in the message box":`撤回并放回输入框`,"Not delivered.":`未送达。`,"Not delivered: the reply ended before this message reached the model. Nothing was replayed; send it again.":`未送达:回复在这条消息到达模型之前就结束了。没有任何内容被重放;需要的话请重新发送。`,"Not observed: the session could not be read when the reply ended, so whether this message was delivered was not recorded. Nothing was replayed.":`未观察到:回复结束时会话无法读取,因此没有记录这条消息是否送达。没有任何内容被重放。`,"Put back in the message box":`放回输入框`,"Queue behind this reply":`排在这条回复之后`,"Queue: sent when this reply ends (Alt+Enter)":`排队:这条回复结束后发送(Alt+Enter)`,"Steer this reply":`插队到这条回复`,"Steer: read at the model's next step (Enter)":`插队:模型下一步就会读到(Enter)`,"Enter steers this reply · Alt+Enter queues behind it":`Enter 插队 · Alt+Enter 排队`,"The running reply did not take the message ({reason}). Your text stays here.":`进行中的回复没有接收这条消息({reason})。你的文字仍在输入框里。`,"That message has already been handed to the model and can no longer be withdrawn.":`这条消息已经交给模型,无法再撤回。`,"The message was not withdrawn ({reason}).":`消息没有撤回({reason})。`,"A message into a running reply carries no images. Remove them, or send after the reply ends.":`发给进行中回复的消息不能带图片。请移除图片,或等回复结束后再发送。`,"Cadence mode is not changed by a message into a running reply. Send this after the reply ends.":`发给进行中回复的消息不会切换 Cadence 模式。请等回复结束后再发送。`,"Eight messages already wait for this reply. Withdraw one, or wait.":`已有 8 条消息在等这条回复。请撤回一条,或稍等。`,"A message into a running reply continues that reply, not another entry.":`发给进行中回复的消息只能接在这条回复上,不能接到别的位置。`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Download file {path}":`下载文件 {path}`,"Reference path only: {path} (the agent reads it on demand)":`仅引用路径 {path}(AI 按需读取)`,"Link folder path {path} to the chat":`链接文件夹路径 {path} 到对话`,"Copy name {path}":`复制名称 {path}`,"Copy path {path}":`复制路径 {path}`,"Download of {path} failed: {error}":`{path} 下载失败:{error}`,"the file is larger than the 64 MiB download limit":`文件超过 64 MiB 的下载上限`,"No visible files":`没有可显示的文件`,"Close preview":`关闭预览`,"Bounded listing; narrow the directory to see more.":`列表已达到显示上限,请进入更具体的目录查看。`,"File preview is limited; this is not the complete file.":`文件预览已截断,并非完整内容。`,"Readonly preview · references send paths, not file contents · a download is the file's own bytes, unredacted":`只读预览 · 引用只发送路径,不自动注入文件内容 · 下载的是文件原始字节,不做脱敏`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking that could not be read is not shown.":`无法读取的思考内容不显示。`,"Show thinking":`展开思考内容`,"Thinking still being recorded":`思考内容仍在记录中`,"No thinking text is recorded for this block.":`这段思考没有记录文本。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"The choices changed before this answer was saved.":`保存前选项已变化,本次答案未保存。`,Connection:`连接`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Link copied.":`链接已复制。`,"Dismiss notification":`关闭通知`,"Theme: {current}. Switch to {next}.":`主题:{current}。点击切换为{next}。`,System:`跟随系统`,Light:`浅色`,Dark:`深色`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"Service unavailable":`服务不可用`,"Task snapshot not observed yet":`尚未观察到任务快照`,"No task selected":`未选择任务`,"Resize left pane":`调整左侧面板宽度`,"Resize right pane":`调整右侧面板宽度`,Detached:`已断开`,"Accepted service work continues. No Cancel was requested.":`已接受的服务工作会继续进行。没有请求取消。`,"Observe command after reconnect:":`重新连接后观察命令:`,"Reconnect as a viewer":`以查看者身份重新连接`,"Current action context unavailable; observe again.":`当前操作上下文不可用;请重新观察。`,"Preflight refused: {code}":`预检被拒绝:{code}`,"Preflight unavailable. No automatic retry.":`预检不可用。不会自动重试。`,"Stop requested; settlement is not yet confirmed.":`已请求停止;尚未确认结束。`,"{code}; cancellation effect {effect}. Observe exact receipt.":`{code};取消效果 {effect}。请观察确切回执。`,"Cancellation effect uncertain. Observe exact receipt.":`取消效果不确定。请观察确切回执。`,"Observation unavailable.":`观察不可用。`,"Access revoked; explicit token re-entry required.":`访问已被撤销;需要显式重新输入令牌。`,Kind:`类型`,Code:`代码`,"Readonly research":`只读调研`,"Readonly diagnosis":`只读诊断`,Goal:`目标`,"Preview Create (does not Start)":`预览创建(不会启动)`,"Close dialog — no cancellation of accepted work":`关闭对话框——不会取消已接受的工作`,"Close — accepted work is not cancelled":`关闭——不会取消已接受的工作`,Checkout:`工作副本`,Observation:`观察`,Expires:`过期时间`,"Expected: {output}":`预期产出:{output}`,"Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.":`显式的所有者级选择,仅在空闲时可用。它不会解析凭据、探测提供方、保存计划或启动工作。`,"Current: {model}":`当前:{model}`,"No model selected":`未选择模型`,"Exact model / API / thinking":`确切的模型 / API / 思考级别`,"Select explicitly":`请显式选择`,"Catalog capacity exceeded; no partial model list is selectable.":`模型目录超出容量;不能从不完整的列表中选择。`,"{error}. No automatic replacement or retry.":`{error}。不会自动替换或重试。`,"{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,Command:`命令`,Arguments:`参数`,"Copy tool summary":`复制工具摘要`,"Copy command":`复制命令`,"Copy arguments":`复制参数`,"Copy output":`复制输出`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"Attempts shown: {partial} partial · {blocked} blocked · {failed} failed":`当前显示的尝试:{partial} 项部分完成 · {blocked} 项受阻 · {failed} 项失败`,"Partial or blocked assignments preserve work; they are not process failures or delivery approval.":`部分完成或受阻的任务保留已有成果,不代表进程故障,也不代表交付通过。`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,starting:`正在启动`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,superseded:`已被取代`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重新打开模型选择器。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Stop work and upgrade to {version}":`停止运行中的工作并升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"The service stops in order and starts again; this page waits for the result.":`服务会有序停止并重新启动;此页面会等待重启结果。`,"Cadence downloads the update before stopping. If startup fails, it tries to restore the previous version. After a successful upgrade, this page reloads automatically; unsent images must be attached again.":`Cadence 会先下载更新,再停止服务并安装。如果新版本未能启动,会尝试恢复旧版本。升级成功后页面会自动刷新;未发送的图片需要重新添加。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Conversation {id}":`会话 {id}`,"Cadence could not confirm which work would stop. Refresh the service status to continue.":`Cadence 无法确认将停止的工作。请刷新服务状态后继续。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},Y=i(),Zn=`cadence-locale`,Qn=new Map(Object.entries(Xn));function $n(e,t,n){let r=e===`zh`?Qn.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var er={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function tr(e,t){let n=Object.hasOwn(er,t)?er[t]:void 0;return n?e(n,{code:t}):t}function nr({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,Y.jsx)(h.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function rr(){try{let e=localStorage.getItem(Zn);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function ir(e,t){return{locale:e,t:(t,n)=>$n(e,t,n),tx:t=>$n(e,t),setLocale:t}}var ar=(0,h.createContext)(ir(`en`,()=>{}));function X(){return(0,h.useContext)(ar)}function or({initial:e,children:t}){let[n,r]=(0,h.useState)(()=>e??rr()),i=(0,h.useMemo)(()=>ir(n,e=>{try{localStorage.setItem(Zn,e)}catch{}r(e)}),[n]);return(0,h.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=$n(n,`Cadence task workspace`)},[n]),(0,Y.jsx)(ar.Provider,{value:i,children:t})}var sr=`cadence-theme`,cr=[`system`,`light`,`dark`],lr=e=>e===`light`||e===`dark`;function ur(){try{let e=localStorage.getItem(sr);if(lr(e))return e}catch{}return`system`}function dr(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function fr(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return lr(e)?e:`system`}function pr(e){try{e===`system`?localStorage.removeItem(sr):localStorage.setItem(sr,e)}catch{}dr(e)}var mr=e=>cr[(cr.indexOf(e)+1)%cr.length];function hr(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}function gr(e){B({kind:`ok`,value:e},C.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=F(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:L(n.storeId),workspaceId:L(n.workspaceId),epoch:L(n.epoch)};if(!t)return N(n.status,`unavailable`),{...r,status:`unavailable`,error:_r(n.error)};let i=I(n.runs,C.episodes,e=>{let t=F(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:L(t.taskId),runId:L(t.runId),operationId:L(t.operationId),epoch:L(t.epoch),kind:M(t.kind,[`start`,`generate-plan`,`check`]),stage:M(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&D(),{...r,status:`complete`,runs:i}}function _r(e){let t=re(e);return N(t.effect,`none`),t}function vr(e){let t=F(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:R(t.sourceHash),contractHash:R(t.contractHash),buildId:R(t.buildId)}}function yr(e){let t=M(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=F(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:R(n.contractHash)}:{kind:t,...vr({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function br(e){let t=F(e,[`contractHash`,`assets`]);return{contractHash:R(t.contractHash),assets:vr(t.assets)}}function xr(e){B(e);let t=F(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:L(t.commandId),operationId:L(t.operationId),runId:P(t.runId,L),admission:M(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:z(t.committedSeq),execution:P(t.execution,e=>M(e,ae)),settlement:P(t.settlement,Ge),created:P(t.created,e=>{let t=F(e,[`kind`,`taskId`,`state`]);return{kind:N(t.kind,`task`),taskId:L(t.taskId),state:M(t.state,[`reserved`,`published`])}}),publication:M(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&We(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&D(),n}function Sr(e){B(e);let t=F(e,[`identity`,`receipt`]),n=be(t.identity),r=xr(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&D();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&D(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&D()}return{identity:n,receipt:r}}function Z(e,t){if(H(e)===`ok`)return{kind:`ok`,value:t(F(e,[`kind`,`value`]).value)};let n=F(e,[`kind`,`error`]);return N(n.kind,`error`),{kind:`error`,error:re(n.error)}}function Cr(e){switch(B(e),H(e,`status`)){case`found`:return{status:`found`,receipt:xr(F(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:z(F(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:re(F(e,[`status`,`error`]).error)};default:return D()}}function wr(e){let t=F(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:L(t.runId),taskId:L(t.taskId),childRunId:P(t.childRunId,L),assignmentId:P(t.assignmentId,te),admission:Pr(t.admission),lifecycle:M(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:P(t.outcome,e=>M(e,ae)),settlement:P(t.settlement,Ge),reason:P(t.reason,e=>M(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:M(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:G(t.coverage),result:P(t.result,V)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&B(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==B(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&B(n.result)!==B(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&We(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||We(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&D(),n}function Tr(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Er(e,t,n){return Tr(e,t)&&e.taskId===Lr(n)&&e.admission.context.workspaceId===Ir(n)}function Dr(e){B(e,C.pageBytes);let t=F(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:N(t.protocol,1),storeId:L(t.storeId),epoch:L(t.epoch),scope:De(t.scope),committedSeq:z(t.committedSeq),context:Fr(t.context),runs:I(t.runs,C.maxPageEntries,wr),horizon:Yr(t.horizon)};return(!Rr(n.context,n.epoch,n.scope)||B(n.horizon.historicalRuns.scope)!==B(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!Er(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&D(),n}function Or(e){B(e,C.pageBytes);let t=H(e),n=F(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:L(n.storeId),epoch:L(n.epoch),scope:De(n.scope),committedSeq:z(n.committedSeq)};if(t===`update`){let e=z(n.previousSeq);ee(r.committedSeq,e)<=0&&D();let i=Fr(n.context);Rr(i,r.epoch,r.scope)||D();let a=I(n.runs,C.maxPageEntries,wr),o=I(n.removed,C.maxPageEntries,L),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!Er(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&D(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return N(t,`heartbeat`),{kind:`heartbeat`,...r}}function kr(e){let{navigation:t,...n}=e;return n}function Ar(e,t){(!t.navigation||t.navigation===e.navigation||B(kr(e))!==B(kr(t)))&&D()}function jr(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mr(e);B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return Ar(n,r),{kind:`progress`,cursor:n,next:r,coverage:G(t.coverage)}}function Mr(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:V(t.content),range:P(t.range,pe),text:O(t.text,C.detailPageBytes),next:P(t.next,ke),coverage:G(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==k(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&D(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&D(),n.next&&(n.next.offset!==n.range?.end||B(kr({...n.next,offset:n.cursor.offset}))!==B(kr(n.cursor)))&&D(),n}function Nr(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||D();let r=k(n.query),i=I(t.hits,C.maxPageEntries,e=>{let t=F(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=V(t.content),a=Vr(t.owner);Hr(a,n.scope)||D();let o=pe(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||B(s.scope)!==B(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&D(),{content:i,owner:a,range:o,preview:O(t.preview,C.previewBytes),cursor:s}}),a=P(t.next,ke);return a&&(a.storeId!==n.storeId||B(a.scope)!==B(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&D(),{cursor:n,hits:i,next:a,coverage:G(t.coverage)}}function Pr(e){let t=F(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=_e(t.context),r=P(t.graph,e=>{let t=F(e,[`recordId`,`revision`,`sha256`]);return{recordId:L(t.recordId),revision:A(t.revision,1),sha256:R(t.sha256)}}),i=M(t.kind,[`start`,`generate-plan`,`check`]),a=I(t.assignments,C.assignments,e=>{let t=F(e,[`assignmentId`,`childRunId`]);return{assignmentId:te(t.assignmentId),childRunId:L(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&D(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&D(),{operationId:L(t.operationId),commandId:L(t.commandId),kind:i,context:n,assignments:a,graph:r}}function Fr(e){if(H(e,`status`)===`available`)return{status:`available`,version:_e(F(e,[`status`,`version`]).version)};let t=F(e,[`status`,`workspaceId`,`taskId`,`error`]);N(t.status,`unavailable`);let n=re(t.error);return N(n.effect,`none`),{status:`unavailable`,workspaceId:L(t.workspaceId),taskId:P(t.taskId,L),error:n}}function Ir(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Lr(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Rr(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Lr(e)===n.id)}function zr(e){let t=F(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=F(t.capabilities,[`actions`,`manualChecks`,`history`]),r=M(t.authority,[`browser`,`local`]),i=P(t.csrf,L),a={actions:j(n.actions),manualChecks:j(n.manualChecks),history:j(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&D(),{...t.build===void 0?{}:{build:br(t.build)},protocol:N(t.protocol,1),storeId:L(t.storeId),epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function Br(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:gr(t.activeRuns)},workspaceId:L(t.workspaceId),storeId:L(t.storeId),epoch:L(t.epoch),committedSeq:z(t.committedSeq),rootLabel:O(t.rootLabel,4096,!0),context:Fr(t.context),models:I(t.models,C.maxPageEntries,ue)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&D(),(Ir(n.context)!==n.workspaceId||Lr(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&D(),n}function Vr(e){let t=F(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=F(t.entity,[`kind`,`id`,`version`]),r={taskId:L(t.taskId),runId:P(t.runId,L),childRunId:P(t.childRunId,L),entity:{kind:M(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:L(n.id),version:A(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&D(),r}function Hr(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Ur(e){let t=F(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:R(t.identity),complete:j(t.complete),checkoutGeneration:A(t.checkoutGeneration)}}function Wr(e){B(e,C.controlBytes);let t=H(e);switch(t){case`assignment-state`:{let n=F(e,[`kind`,`childRunId`,`state`,`reason`]),r=M(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=P(n.reason,e=>M(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&D(),(r===`ready`||r===`preparing`)&&i!==null&&D(),{kind:t,childRunId:L(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:M(F(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=F(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:L(n.runId),identity:Pr(n.identity)}}case`parent-settled`:{let n=F(e,[`kind`,`runId`,`settlement`]),r=Ge(n.settlement);return r.kind!==`parent`&&D(),{kind:t,runId:L(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=F(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:L(r.reservationId)}:{},lane:M(r.lane,[`reader`,`writer`,`check`]),state:M(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:A(r.checkoutGeneration)}}case`handoff`:{let n=F(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:L(n.childRunId),handoff:we(n.handoff),observation:Ur(n.observation)}}case`changes`:{let n=F(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=V(n.content);return N(r.field,`changes`),{kind:t,observationId:L(n.observationId),stage:M(n.stage,[`before`,`after`,`review`]),observation:Ur(n.observation),content:r}}case`check-start`:{let n=F(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:L(n.checkId),selection:U(n.selection),cwdId:L(n.cwdId),cwdLabel:O(n.cwdLabel,4096,!0),checkEnvGeneration:A(n.checkEnvGeneration,1),before:Ur(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=F(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=F(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:L(e.operationId),reservationId:L(e.reservationId),from:A(e.from),to:A(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&D()}let a=Re(r.native),o=M(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=Ur(r.before),c=Ur(r.after),l=P(r.output,V),u=G(r.coverage);return l&&l.field!==`check`&&D(),o===`passed`&&(a.outcome!==`completed`||B({...s,checkoutGeneration:c.checkoutGeneration})!==B(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&D(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&D(),{kind:t,...i?{ownAdvance:i}:{},checkId:L(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=F(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=j(n.acceptIssues),i=M(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=V(n.content);return N(a.field,`review`),i===`reviewed-with-issues`&&!r&&D(),{kind:t,reviewId:L(n.reviewId),runId:L(n.runId),checksRevision:A(n.checksRevision),changesIdentity:R(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=F(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=A(n.expectedRevision),i=P(n.expectedIdentity,R),a=A(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&D(),{kind:t,publicationId:L(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:R(n.nextIdentity)}}case`publication-settled`:{let n=F(e,[`kind`,`publicationId`,`status`,`observed`]),r=M(n.status,[`published`,`conflict`,`uncertain`]),i=P(n.observed,e=>{let t=F(e,[`revision`,`identity`]);return{revision:A(t.revision,1),identity:R(t.identity)}});return r===`published`&&i===null&&D(),{kind:t,publicationId:L(n.publicationId),status:r,observed:i}}default:return D()}}function Gr(e){let t=F(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:L(t.epoch),operationId:L(t.operationId),taskId:L(t.taskId),runId:P(t.runId,L)}}function Kr(e){B(e,C.ownerQueueBytes);let t=F(e,[`observedMs`,`link`,`events`]),n=Gr(t.link),r=I(t.events,C.ownerQueueFrames,e=>{let t=H(e);if(t===`fact`){let r=Wr(F(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&D(),{kind:t,fact:r}}if(t===`content-begin`){let r=F(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=Vr(r.owner),a=M(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&D(),{kind:t,detailId:L(r.detailId),owner:i,field:a,encoding:N(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=F(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:L(n.detailId),text:O(n.text,C.chunkBytes)}}let r=F(e,[`kind`,`detailId`,`coverage`]);return N(t,`content-end`),{kind:`content-end`,detailId:L(r.detailId),coverage:G(r.coverage)}});return{observedMs:A(t.observedMs),link:n,events:r}}var qr=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Jr(e){let t=F(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=M(t.reader,qr),r=F(t.scope,[`kind`,`id`]),i={kind:M(r.kind,[`workspace`,`task`,`run`,`child`]),id:L(r.id)},a=P(t.snapshotSeq,z),o=P(t.after,e=>{let t=F(e,[`recordId`,`version`,`offset`]);return{recordId:L(t.recordId),version:A(t.version,1),offset:A(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&D(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:i,snapshotSeq:a,after:o,limit:A(t.limit,1,C.maxPageEntries)}}function Yr(e){let t=F(e,[`policy`,`historicalRuns`]),n=Jr(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&D(),{policy:N(t.policy,`active-and-recent`),historicalRuns:n}}function Xr(e){let t=H(e);if(t===`run`)return{kind:t,projection:wr(F(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=F(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=z(n.committedSeq);return r===`0`&&D(),{kind:t,recordId:L(n.recordId),committedSeq:r,link:Je(n.link),capture:qe(n.capture)}}if(t===`owner-fact`){let n=F(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Kr({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&D();let a=z(n.committedSeq);return a===`0`&&D(),{kind:t,recordId:L(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=F(e,[...n,...r]),a=Vr(i.owner),o=A(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&D(),t===`task`){let e=P(i.plan,V);return e&&e.field!==`plan`&&D(),{kind:t,owner:a,version:o,goal:O(i.goal,8192,!0),plan:e}}if(t===`message`){let e=M(i.role,[`user`,`assistant`,`tool-result`]),n=M(i.state,[`partial`,`final`]),r=P(i.finalBlockCount,e=>A(e,0,C.dataFrames)),s=P(i.finalText,V),c=P(i.resultCallId,L);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&D(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=P(i.declaration,je),n=P(i.declarationStage,e=>M(e,[`partial`,`final`])),r=j(i.startObserved),s=P(i.result,e=>{let t=Le(e);return t.kind!==`tool-end`&&D(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||B(s.declaration)!==B(e)))&&D(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:O(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=V(i.content);return(e.field!==n.field||!Zr(e.owner,a))&&D(),{kind:t,owner:a,version:o,detailId:L(i.detailId),descriptor:e,content:n,coverage:G(i.coverage)}}N(t,`omitted`);let s=Pe(i.block);return Zr(s.owner,a)||D(),{kind:`omitted`,owner:a,version:o,block:s}}function Zr(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function Qr(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function $r(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`records`,`next`,`coverage`]),n=Jr(t.request);n.snapshotSeq===null&&D();let r=I(t.records,n.limit,Xr),i=P(t.next,Jr);return(r.some(e=>!Qr(e,n))||i&&(i.after===null||B(kr({...i,after:n.after}))!==B(kr(n))||B(i.after)===B(n.after)))&&D(),{request:n,records:r,next:i,coverage:G(t.coverage)}}function ei(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=Jr(t.request),r=Jr(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||B(kr({...r,snapshotSeq:null}))!==B(kr(n)))&&D(),{kind:`snapshot`,request:n,next:r,coverage:G(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return $r(e);B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=Jr(t.request),r=Jr(t.next);return Ar(n,r),{kind:`progress`,request:n,next:r,coverage:G(t.coverage)}}function ti(e,t){return B({...t.request,snapshotSeq:e.snapshotSeq})===B(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function ni(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=F(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:z(t.snapshotSeq),graph:{recordId:L(n.recordId),revision:A(n.revision,1),sha256:R(n.sha256)}}}function ri(e){B({kind:`ok`,value:e});let t=F(e,[`request`,`graph`]),n=ni(t.request),r=he(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&D(),{request:n,graph:r}}function ii(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return ri(e);B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=ni(t.request),r=ni(t.next);return Ar(n,r),{kind:`progress`,request:n,next:r,coverage:G(t.coverage)}}function ai(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:z(t.snapshotSeq),format:M(t.format,[`ndjson`,`markdown`])}}function oi(e){B(e,C.controlBytes);let t=F(e,[`exportId`,`ordinal`,`event`]),n=H(t.event),r;switch(n){case`manifest`:{let e=F(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=F(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:R(i.exporterBuildSha256),capturePolicy:N(i.capturePolicy,`public-text-tools/2`)},schema:N(e.schema,S),request:ai(e.request),coverage:G(e.coverage),serviceProtocol:N(e.serviceProtocol,1),workerProtocol:N(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Xr(F(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:ri(F(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=F(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=V(e.content),a=P(e.range,pe),o=O(e.text,C.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==k(o):i.bytes!==0||o!==``)&&D(),r={kind:n,owner:Vr(e.owner),content:i,range:a,text:o,coverage:G(e.coverage)};break}case`markdown`:r={kind:n,text:O(F(t.event,[`kind`,`text`]).text,C.detailPageBytes)};break;case`trailer`:{let e=F(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=G(e.coverage),a=j(e.complete);a&&i.observed!==`complete`&&D(),r={kind:n,complete:a,frames:A(e.frames,1),encodedBytes:A(e.encodedBytes),sha256:R(e.sha256),committedSeq:z(e.committedSeq),coverage:i};break}default:return D()}return{exportId:L(t.exportId),ordinal:A(t.ordinal,1),event:r}}function si(e,t){let n=oi(e);return t===`ndjson`?`${B(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&D(),`\n\n\`\`\`json\n${B(n)}\n\`\`\`\n`)}var ci=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=ai(e)}receive(e){let t=oi(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&D(),this.ordinal===0?(n.kind!==`manifest`||B(n.request)!==B(this.request))&&D():n.kind===`manifest`&&D(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&D(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&D(),this.request.format===`ndjson`&&n.kind===`markdown`&&D(),n.kind===`detail`&&!Hr(n.owner,this.request.scope)&&D(),n.kind===`graph`&&(B(n.graph.request.scope)!==B(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&D(),n.kind===`record`&&!li(n.record,this.request.scope)&&D(),this.bytes+=k(si(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function li(e,t){return e.kind===`run`?Tr(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:Hr(e.owner,t)}function ui(e){let t=F(e,[`taskId`,`revision`,`definitions`]),n=I(t.definitions,32,e=>{let t=F(e,[`selection`,`status`,`checkId`]),n=U(t.selection),r=M(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=P(t.checkId,L);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&D(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&D(),{taskId:L(t.taskId),revision:A(t.revision),definitions:n}}function di(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:z(t.snapshotSeq),kind:M(t.kind,[`task`,`message`,`tool`]),id:L(t.id),version:A(t.version,1)}}function fi(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`record`]),n=di(t.request),r=Xr(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!Hr(r.owner,n.scope))&&D(),{request:n,record:r}}function pi(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return fi(e);B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=di(t.request),r=di(t.next);return Ar(n,r),{kind:`progress`,request:n,next:r,coverage:G(t.coverage)}}var mi=e=>{let t=re(e);return N(t.effect,`none`),t};function hi(e){let t=F(e,[`storeId`,`taskId`]);return{storeId:L(t.storeId),taskId:P(t.taskId,L)}}function gi(e){let t=hi(e);return t.taskId===null&&D(),t}function _i(e){let t=F(e,[`id`,`kind`,`revision`,`identity`]);return{id:L(t.id),kind:M(t.kind,[`code`,`research`,`diagnosis`]),revision:A(t.revision,1),identity:R(t.identity)}}function vi(e){let t=I(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&D(),t}function yi(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return F(e,[`status`]),{status:t};if(t===`saved`){let n=F(e,[`status`,`request`,`planRevision`]);return{status:t,request:ni(n.request),planRevision:A(n.planRevision,1)}}let n=F(e,[`status`,`error`]);return N(n.status,`unavailable`),{status:`unavailable`,error:mi(n.error)}}function bi(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Ir(e.context)!==e.workspaceId||Lr(e.context)!==e.request.taskId)&&D(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&D()}}function xi(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:hi(t.request),workspaceId:L(t.workspaceId),epoch:L(t.epoch),committedSeq:z(t.committedSeq),context:Fr(t.context),task:P(t.task,_i),roles:vi(t.roles),savedGraph:yi(t.savedGraph),readablePlan:P(t.readablePlan,e=>{let t=F(e,[`source`,`text`,`editable`,`coverage`]),n=G(t.coverage),r=j(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&D(),{source:N(t.source,`current-v1`),text:O(t.text,32768),editable:r,coverage:n}})};bi(n),!!n.task!=!!n.readablePlan&&D();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&D(),r.status===`unavailable`&&n.context.status===`available`&&D(),n}function Si(e){B({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=F(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:gi(t.request),workspaceId:L(t.workspaceId),epoch:L(t.epoch),committedSeq:z(t.committedSeq),context:Fr(t.context),task:_i(t.task),observation:{identity:R(n.identity),complete:j(n.complete),checkoutGeneration:A(n.checkoutGeneration,0)},text:O(t.text,131072),git:j(t.git),coverage:G(t.coverage)};if(bi(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&D()}return r}var Ci={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},wi=h.createContext&&h.createContext(Ci),Ti=[`attr`,`size`,`title`];function Ei(e,t){if(e==null)return{};var n,r,i=Di(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Di(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Oi(){return Oi=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Oi.apply(null,arguments)}function ki(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Ai(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ki(Object(n),!0).forEach(function(t){ji(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ki(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ji(e,t,n){return(t=Mi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Mi(e){var t=Ni(e,`string`);return typeof t==`symbol`?t:t+``}function Ni(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Pi(e){return e&&e.map((e,t)=>h.createElement(e.tag,Ai({key:t},e.attr),Pi(e.child)))}function Q(e){return t=>h.createElement(Fi,Oi({attr:Ai({},e.attr)},t),Pi(e.child))}function Fi(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Ei(e,Ti),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),h.createElement(`svg`,Oi({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Ai(Ai({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&h.createElement(`title`,null,i),e.children)};return wi===void 0?t(Ci):h.createElement(wi.Consumer,null,e=>t(e))}function Ii(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Li(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Ri(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function zi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function Bi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Vi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function Hi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function Ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Wi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function Gi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Ki(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function qi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function Ji(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function Yi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Xi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Zi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Qi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},child:[]}]})(e)}function $i(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ea(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function ta(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function na(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function ra(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function ia(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function aa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function oa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function sa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function ca(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function la(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function ua(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function da(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function fa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function pa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function ma(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function ha(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function ga(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function _a(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function va(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function ya(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function ba(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function xa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function Sa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function Ca(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function wa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function Ta(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function Ea(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function Da(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function Oa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function ka(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function Aa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function ja(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function Ma(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function Na(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function Pa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function Fa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function Ia(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function La(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function Ra(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function za(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function Ba(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Va(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Ha(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var $=e=>({kind:`error`,error:E(`unavailable`,e?`uncertain`:`none`)}),Ua=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=vn(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Rn);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?$(!1):e}catch{return $(!1)}}async workbenchCommand(e){let t=bn(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Rn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=hi(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),xi);return e.kind===`ok`&&B(e.value.request)!==B(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=gi(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),Si);return e.kind===`ok`&&B(e.value.request)!==B(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),gr):$(!1)}catch{return $(!1)}}async models(e,t,n=!1){try{if(t){let r=await this.workbenchRead({kind:n?`reload-conversation-models`:`conversation-models`,location:t},e);return r.kind===`error`?r:r.value.kind===`conversation-models`&&r.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:r.value.catalog}:$(!1)}return this.transport.models?Z(await this.transport.models(e),it):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=et(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:$(!0)}else{if(!this.transport.chooseModel)return $(!1);e=Z(await this.transport.chooseModel(n),$e)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(B(i)!==B(n.choice)||B(e.value.version.conversation??null)!==B(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){L(e);try{let n=Z(await this.transport.checkObligations(e,t),ui);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=di({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),pi);return e.kind===`ok`&&B(e.value.request)!==B(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),zr)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),Br)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Jr({...t,reader:e});try{let t=Z(await this.transport[e](r,n),ei);return t.kind===`ok`&&!ti(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=ni(e);try{let e=Z(await this.transport.graph(n,t),ii);return e.kind===`ok`&&B(e.value.request)!==B(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=ai(e),r=new ci(n),i;try{if(t.aborted)throw new T(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new T(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new T(`unavailable`);yield i}catch{throw new T(`unavailable`)}}async preflight(e,t){let n=ve({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Ce);return e.kind===`ok`&&(B(e.value.preview.version)!==B(n.expected)||B(e.value.preview.action)!==B(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=ye(t);if(n.action.kind!==e)return{kind:`error`,error:E(`invalid`)};try{let e=Z(await this.transport.command(n),xr);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);Sr({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=xe(e);try{let e=Z(await this.transport.cancel(t),xr);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);Sr({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){L(e);try{let n=Cr(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:E(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Z(await this.transport.snapshot(n,t),Dr);return e.kind===`ok`&&B(e.value.scope)!==B(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),jr);return e.kind===`ok`&&B(e.value.cursor)!==B(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),Nr);return e.kind===`ok`&&B(e.value.cursor)!==B(n)?$(!1):e}catch{return $(!1)}}},Wa=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=Dr(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&B(i.scope)===B(r.scope)&&ee(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=C.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=C.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=Or(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||B(i.scope)!==B(a.scope))return this.resync();let o=ee(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Ir(i.context)!==Ir(a.context)||Lr(i.context)!==Lr(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||B(t.admission)!==B(e.admission))return this.resync();s[n]=e}}if(s.length>C.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{Dr(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}},Ga={session:`/api/v1/session`,workbenchRead:`/api/v1/workbench/read`,workbenchCommand:`/api/v1/workbench/command`,current:`/api/v1/current`,currentChanges:`/api/v1/current-changes`,activeRuns:`/api/v1/active-runs`,models:`/api/v1/models`,chooseModel:`/api/v1/model-choice`,workspace:`/api/v1/workspace`,tasks:`/api/v1/tasks`,runs:`/api/v1/runs`,messages:`/api/v1/messages`,tools:`/api/v1/tools`,contents:`/api/v1/contents`,events:`/api/v1/history-events`,checks:`/api/v1/checks`,changes:`/api/v1/changes`,reviews:`/api/v1/reviews`,checkObligations:`/api/v1/check-obligations`,entity:`/api/v1/entity`,graph:`/api/v1/graph`,snapshot:`/api/v1/snapshot`,detail:`/api/v1/details`,search:`/api/v1/search`,export:`/api/v1/export`,download:`/api/v1/download`,preflight:`/api/v1/preflight`,command:`/api/v1/commands`,cancel:`/api/v1/cancel`,receipt:`/api/v1/receipt`,detach:`/api/v1/detach`},Ka=`/api/v1/events`,qa=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`],Ja=`x-cadence-history-csrf`,Ya=[...qa,`entity`,`graph`,`detail`,`search`];function Xa(e){return Ya.includes(e)}function Za(e,t){if(qa.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return C.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return C.pageBytes}return C.controlBytes}function Qa(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function $a(e,t){switch(e){case`workbenchRead`:return vn(t);case`workbenchCommand`:return bn(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new T(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Jr(t);if(n.reader!==e)throw new T(`invalid`);return n}case`current`:return hi(t);case`currentChanges`:return gi(t);case`checkObligations`:case`receipt`:return L(t);case`entity`:return di(t);case`graph`:return ni(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return ai(t);case`chooseModel`:return et(t);case`preflight`:return ve(t);case`command`:return ye(t);case`cancel`:return xe(t)}}function eo(e,t){if(qa.includes(e))return Z(t,ei);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Rn);case`current`:return Z(t,xi);case`currentChanges`:return Z(t,Si);case`activeRuns`:return Z(t,gr);case`models`:return Z(t,it);case`chooseModel`:return Z(t,$e);case`session`:return Z(t,zr);case`workspace`:return Z(t,Br);case`checkObligations`:return Z(t,ui);case`entity`:return Z(t,pi);case`graph`:return Z(t,ii);case`snapshot`:return Z(t,Dr);case`detail`:return Z(t,jr);case`search`:return Z(t,Nr);case`preflight`:return Z(t,Ce);case`command`:case`cancel`:return Z(t,xr);case`receipt`:return Cr(t);case`detach`:return Z(t,e=>{if(e!==null)throw new T(`invalid`);return null});default:throw new T(`invalid`)}}function to(e){return[...Ya,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`snapshot`,`export`,`download`,`receipt`].includes(e)}function no(e,t){let n=Ga[e];return t===null||Qa(e)?n:`${n}?request=${encodeURIComponent(B(t))}`}function ro(e,t){let n=$a(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ga[e]:no(e,n);return Qa(e)||to(e)&&(r||k(i)>C.headerBytes/4)?{path:Ga[e],method:`POST`,body:B(n)}:{path:i,method:`GET`}}function io(e){B(e,C.viewerBytes);let t=M(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:Dr(F(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:Or(F(e,[`kind`,`event`]).event)}:(F(e,[`kind`]),{kind:t})}var ao=class{options;attachment;csrf=null;historyCsrf;bootstrapRevision=0;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project)||e.retainedHistory&&e.localCapability)throw new T(`invalid`);this.origin=e.origin,e.build&&=yr(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e,t=!1){let n={"Cache-Control":`no-store`};if(this.options.build&&(n[`X-Cadence-Build`]=B(this.options.build)),this.attachment&&(e||t)&&(n[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(n[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new T(`stale`);n[`Content-Type`]=`application/json`,this.csrf&&(n[`X-Cadence-CSRF`]=this.csrf)}return n}async request(e,t,n){if(this.options.retainedHistory&&e!==`workspace`&&!Xa(e))throw new T(`forbidden`);let r=ro(e,$a(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:hr([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;e===`session`&&(this.attachment??=crypto.randomUUID());let t=this.options.retainedHistory&&e===`workspace`?++this.bootstrapRevision:void 0;t!==void 0&&(this.historyCsrf=void 0);let n=this.options.retainedHistory&&i,a=this.headers(i&&!n,e===`session`);if(n){if(!this.historyCsrf)throw new T(`stale`);a[Ja]=this.historyCsrf,a[`Content-Type`]=`application/json`}let s=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:a,credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),c;try{if(e===`session`&&s.ok&&(c=L(s.headers.get(`x-cadence-attachment`)),c!==this.attachment))throw new T(`invalid`)}catch(e){throw await s.body?.cancel().catch(()=>{}),e}let l=await oo(s,Za(e)),u=ne(l);if(k(l)>Za(e,u))throw new T(`oversize`);let d=eo(e,u);if(t!==void 0&&s.ok&&Object.getOwnPropertyDescriptor(d??{},`kind`)?.value===`ok`){if(o?.aborted||this.bootstrapRevision!==t)throw new T(`stale`);this.historyCsrf=L(s.headers.get(Ja))}if(e===`session`){let e=Z(d,zr);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new T(`forbidden`);if(o?.aborted||c!==this.attachment||!c)throw new T(`stale`);this.csrf=e.value.csrf}}return d}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,et(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,L(e),t)}entity(e,t){return this.request(`entity`,di(e),t)}tasks(e,t){return this.request(`tasks`,Jr(e),t)}runs(e,t){return this.request(`runs`,Jr(e),t)}messages(e,t){return this.request(`messages`,Jr(e),t)}tools(e,t){return this.request(`tools`,Jr(e),t)}contents(e,t){return this.request(`contents`,Jr(e),t)}events(e,t){return this.request(`events`,Jr(e),t)}checks(e,t){return this.request(`checks`,Jr(e),t)}changes(e,t){return this.request(`changes`,Jr(e),t)}reviews(e,t){return this.request(`reviews`,Jr(e),t)}graph(e,t){return this.request(`graph`,ni(e),t)}preflight(e){return this.request(`preflight`,ve(e))}command(e){return this.request(`command`,ye(e))}cancel(e){return this.request(`cancel`,xe(e))}receipt(e,t){return this.request(`receipt`,L(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=!1;for(;;){if(!this.options.localCapability&&!this.csrf){t=!0;let n=Z(await this.session(),zr);if(n.kind===`error`){if(n.error.code===`forbidden`)return n;if(![`stale`,`unauthenticated`].includes(n.error.code))throw new T(n.error.code);return this.attachment===e&&(this.attachment=void 0),n}}if(this.attachment!==e)throw new T(`stale`);let n=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new T(`invalid`);return null});if(n.kind===`error`&&n.error.code!==`stale`&&n.error.code!==`unauthenticated`){if(n.error.code===`forbidden`&&!this.options.localCapability&&this.attachment===e){if(this.csrf=null,!t)continue;return n}throw new T(n.error.code)}return this.attachment===e&&(this.attachment=void 0,this.csrf=null),n}}async*export(e,t){if(this.options.retainedHistory)throw new T(`forbidden`);let n=ro(`export`,ai(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new T(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new T(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=C.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+C.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
15
|
-
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield
|
|
16
|
-
`)}if(new TextEncoder().encode(o).length>C.controlBytes)throw new T(`oversize`)}if(n){if(o)throw new T(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=De(e);if(!this.attachment||!this.options.socket)throw new T(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Ka}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{let e=Date.now()-s;if(e>=C.staleMs&&(u(`stale`),!a||e>C.reconcileMs))return l();if(a&&!o)try{Date.now()-c>=C.reconcileMs?(i.send(B({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}},C.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0,s=c=Date.now();try{i.send(B({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o&&a)try{if(typeof e.data!=`string`)throw new T(`invalid`);let n=io(ne(e.data,C.viewerBytes));s=Date.now(),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function oo(e,t){if(!e.body)throw new T(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new T(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var so={sourceHash:`eb48701128a6edc423d850fceddceb22256fe90dad8388ae949e1987bb3a6da3`,contractHash:`190a21e723f753a233225a9f4bcf12a99d71b294a58728961846cd110cd60a17`,buildId:`3764a5306a520843e6a002ac856e53096112fc0143de6464ec20cf428a331fcc`};function co(e){let t=new ao({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...so?{build:{kind:`browser`,...so}}:{},socket:e=>new WebSocket(e)});return{client:new Ua(t),transport:t}}function lo(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function uo(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var fo=[],po=null,mo,ho,go=new Set;function _o(){let e=uo(fo,performance.now());if(e!==po){po=e;for(let e of go)e()}}function vo(e){if(go.add(e),go.size===1&&typeof PerformanceObserver<`u`)try{mo=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=lo(t,location.origin);e&&(fo=[...fo.slice(-19),e])}_o()}),mo.observe({type:`resource`,buffered:!0}),ho=setInterval(_o,5e3)}catch{mo=void 0}return()=>{go.delete(e),!go.size&&(mo?.disconnect(),mo=void 0,clearInterval(ho),fo=[],po=null)}}function yo(){return(0,h.useSyncExternalStore)(vo,()=>po,()=>null)}function bo(e){let t=F(e,[`id`,`path`,`cwd`,`epoch`]);return{id:R(t.id),path:O(t.path,4096,!0),cwd:O(t.cwd,4096,!0),epoch:t.epoch===null?null:L(t.epoch)}}function xo(e){let t=F(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:N(t.kind,`project-observation`),status:M(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:L(t.epoch),workspaceId:t.workspaceId===null?null:L(t.workspaceId)}}var So=[`registry`,`workbench`,`project`],Co=[`reboot`,`crash`,`restart`,`storage`],wo=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function To(e){let t=F(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:L(t.id),at:A(t.at,0),scope:M(t.scope,So),path:t.path===null?null:O(t.path,4096,!0),cause:M(t.cause,Co),actions:I(t.actions,wo.length,e=>M(e,wo)),workers:A(t.workers,0,1e6),archived:j(t.archived)}}function Eo(e){let t=F(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:N(t.kind,`workbench`),epoch:L(t.epoch),csrf:L(t.csrf),home:O(t.home,4096,!0),projects:I(t.projects,128,bo),recoveries:I(t.recoveries,20,To),build:br(t.build)}}var Do=[`restart`,`upgrade`],Oo=[`running`,`ready`,`failed`,`rolled-back`],ko=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Ao=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function jo(e){let t=O(e,96,!0);if(!Ao.test(t))throw new T(`invalid`);return t}function Mo(e){let t=F(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:L(t.id),action:M(t.action,Do),from:jo(t.from),to:t.to===null?null:jo(t.to),state:M(t.state,Oo),reason:t.reason===null?null:M(t.reason,ko),version:t.version===null?null:jo(t.version),at:A(t.at,0),endedAt:t.endedAt===null?null:A(t.endedAt,0)}}var No=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Po(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function Fo(e){let t=F(e,[`digest`,`items`]);return{digest:R(t.digest),items:I(t.items,256,e=>{let t=F(e,[`project`,`source`,`id`,`sessionId`]);return{project:O(t.project,4096,!0),source:M(t.source,[`turn`,`workflow`]),id:L(t.id),sessionId:t.sessionId===null?null:Ye(t.sessionId)}})}}function Io(e){let t=F(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=F(t.unit,[`name`,`scope`]);n={name:O(e.name,96,!0),scope:M(e.scope,[`user`,`system`])}}return{kind:N(t.kind,`service`),version:jo(t.version),unit:n,upgrade:M(t.upgrade,No),work:t.work===null?null:Fo(t.work),job:t.job===null?null:Mo(t.job)}}function Lo(e){let t=F(e,[`kind`,`version`,`deprecated`]);return{kind:N(t.kind,`release`),version:jo(t.version),deprecated:j(t.deprecated)}}function Ro(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}async function zo(e){return ne(await oo(e,1048576),1048576)}function Bo(e){return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`code`in e.error?String(e.error.code):`unavailable`}function Vo(e){let t=Error(Bo(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function Ho(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await zo(r);if(!r.ok)throw Error(Bo(i));return t(i)}function Uo(e){return Ho(`/workbench/v1/service`,Io,e)}function Wo(e){return Ho(`/workbench/v1/service/release`,Lo,e)}async function Go(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await zo(n);if(!n.ok)throw Error(Bo(r));let i=F(r,[`kind`,`job`]);return N(i.kind,`service-job`),Mo(i.job)}var Ko=1e4,qo=5e3;function Jo(e){return e===`unauthenticated`||e===`forbidden`}var Yo=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function Xo(e,t,n){if(t.aborted)throw t.reason;let r=performance.now()+Ko,i=hr([t],Ko),a=()=>t.aborted?t.reason:Error(`timeout`),o,s=new Promise((e,t)=>{o=()=>t(a()),i.signal.addEventListener(`abort`,o,{once:!0})}),c=()=>{if(i.signal.aborted||performance.now()>=r)throw a()},l=async()=>{let t=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal});if(c(),t.status===401||t.status===403)throw t.body?.cancel().catch(()=>{}),new Yo(t.status,t.status===401?`unauthenticated`:`forbidden`);let r=await zo(t);if(c(),!t.ok){let e=Z(r,()=>void 0);throw new Yo(t.status,e.kind===`error`?e.error.code:`unavailable`)}let a=n(r,t);return c(),a};try{return await Promise.race([s,l()])}finally{i.signal.removeEventListener(`abort`,o),i.dispose()}}var Zo=class{controller=new AbortController;signal=this.controller.signal;denial;get refusal(){return this.denial}refuse(e,t){Jo(t)&&!this.refusal&&(this.denial={source:e,code:t},this.controller.abort(Error(t)))}check(){if(this.signal.aborted)throw this.signal.reason}subscribe=e=>(this.signal.addEventListener(`abort`,e),()=>this.signal.removeEventListener(`abort`,e));snapshot=()=>this.refusal},Qo=class{api;access;serial=Promise.resolve();version=0;attachmentVersion=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),this.access.signal.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{if(n&&this.version>n)return a(Error(`stale`));this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.readCurrent&&t.attached&&!t.error&&t.transportStatus===`current`&&(!t.observation||t.observation.connection===`current`)&&a()},s=()=>a(Error(this.access.refusal?.code??this.latest?.error??`unavailable`));t.aborted||this.access.signal.aborted?s():(this.readiness.add(o),this.access.signal.addEventListener(`abort`,s,{once:!0}),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e,t=new Zo){this.api=e,this.access=t}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Wa,l=0,u=0,d,f,p,m=!1,h=0,g=!1,_=!1,v=!1,y=0,b=0,x=!1,S=!1,C=`0`,w=!1,T={readCurrent:!1,actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=T;let E=()=>!r&&n===this.version,D=e=>e.epoch===T.epoch&&e.storeId===f,O=()=>{if(!E())return;let n=c.state;this.latest={...T,error:T.error??p,observation:n,actions:T.readCurrent&&T.actions&&T.transportStatus===`current`&&(!e||n?.connection===`current`)},t(this.latest);for(let e of this.readiness)e(this.latest)},k=()=>{u++,s.abort(),i?.(),i=void 0,T={...T,attached:!1,readCurrent:!1,actions:!1,allocationSignal:void 0}},A=()=>{r||(r=!0,this.access.signal.removeEventListener(`abort`,L),k(),clearInterval(a),clearTimeout(o),n===this.version&&(this.pollCurrent=void 0,this.latest=void 0),_||M(P))};this.stopCurrent=A;let j=()=>{clearTimeout(o),E()&&!_&&(o=setTimeout(N,1e3))},M=e=>{this.serial=this.serial.then(e).catch(e=>{E()&&!_&&(k(),T.error=e instanceof Error?e.message:`unavailable`,T.transportStatus=`stale`,O(),j())})},N=()=>{!E()||_||m||(clearTimeout(o),m=!0,M(async()=>{try{await R()}finally{m=!1}}))},P=async()=>{await d;let e=await this.api.transport.detach();v=!1,e?.kind===`error`&&Jo(e.error.code)&&this.access.refuse(`viewer`,e.error.code)},F=(t=!0)=>{if(!E()||!T.attached||_||d)return d;let n=s.signal,r=y;return T.actions=!1,h=Date.now(),d=I(t,n,r,b).then(t=>{d=void 0,E()&&!n.aborted&&(r===y?(g=!t,t&&(T.workspace=t,T.error=void 0,e||(T.transportStatus=`current`)),T.readCurrent=!!t,T.actions=!!t&&w,O(),!t&&T.error===`stale`?m?j():N():S&&(S=!1,F())):(S=!1,F()))}),O(),d},I=async(t,n,r,i)=>{let a=e=>!E()||n.aborted?!1:e.kind===`error`&&Jo(e.error.code)?(this.access.refuse(`viewer`,e.error.code),!1):r===y;try{if(t){let e=await this.api.client.session(n);if(!a(e))return;if(e.kind===`error`){T.error=e.error.code;return}if(!D(e.value)){T.error=`stale`;return}w=e.value.capabilities.actions}let r=await this.api.client.activeRuns(n);if(!a(r))return;if(r.kind===`ok`){if(!D(r.value)){T.error=`stale`;return}T.activeRuns=r.value}else T.activeRuns=void 0;O();let o=await this.api.client.workspace(n);if(!a(o))return;if(o.kind===`error`){T.error=o.error.code;return}if(!D(o.value)){T.error=`stale`;return}if(e){let t=c.beginSnapshot(),r=await this.api.client.snapshot(e,n);if(!a(r))return;if(r.kind===`error`){T.error=r.error.code;return}if(!D(r.value)){T.error=`stale`;return}if(i!==b||ee(r.value.committedSeq,C)<0)return;let o=c.state,s=c.install(r.value,Date.now(),t);s!==void 0&&(l=s,x=!1,T.transportStatus===`current`&&(o?.connection!==`current`||o.snapshot.committedSeq!==r.value.committedSeq)&&(T.transportStatus=`stale`))}return o.value}catch{E()&&!n.aborted&&r===y&&(T.error=`Observation unavailable.`,T.actions=!1,T.transportStatus=`stale`)}},L=()=>{_=!0,k(),T.transportStatus=`closed`,T.error=this.access.refusal?.code,T.workspace=void 0,T.activeRuns=void 0,c=new Wa,clearInterval(a),clearTimeout(o),v&&M(P),O()},R=async()=>{if(!E()||_||(k(),O(),await P(),!E()||_))return;v=!0;let t=y,n=await this.api.client.session(this.access.signal);if(!E()||_)return;if(n.kind===`error`){if(Jo(n.error.code)){v=!1,this.access.refuse(`viewer`,n.error.code);return}throw Error(n.error.code)}if(s=new AbortController,c=new Wa,f=n.value.storeId,b=0,x=S=!1,C=`0`,T={epoch:n.value.epoch,attached:!0,allocationSignal:s.signal,readCurrent:!1,actions:!1,transportStatus:`closed`,attachmentVersion:++this.attachmentVersion},w=n.value.capabilities.actions,O(),await F(t!==y),!E()||_||!e||T.error===`stale`)return;let r=++u,a=e=>{k(),p=e,T.transportStatus=`closed`,T.attachmentVersion=++this.attachmentVersion,j(),O()};i=this.api.transport.subscribe(e,t=>{if(!E()||_||r!==u)return;let n=t.kind===`snapshot`?t.snapshot:t.kind===`event`?t.event:void 0;if(n&&(!D(n)||n.scope.kind!==e.kind||n.scope.id!==e.id)){a(`stale`);return}let i=!1;if(t.kind===`snapshot`){if(ee(t.snapshot.committedSeq,C)<0)return;let e=c.install(t.snapshot,Date.now(),c.beginSnapshot());e!==void 0&&(l=e,x=S=!1,i=!0)}else if(t.kind===`event`){if(x&&ee(t.event.committedSeq,C)<=0)return;let e=x?`resync`:c.receive(t.event,l,Date.now());if(e===`duplicate`)return;i=e===`applied`}i?(p=void 0,T.transportStatus=`current`):(T.transportStatus=`stale`,n&&ee(n.committedSeq,C)>0&&(C=n.committedSeq),x=!0,b++,d?S=!0:F()),O()},e=>{E()&&!_&&r===u&&(e===`closed`?a(p??`socket-closed`):(p=`socket-timeout`,T.transportStatus=`stale`,O()))})};return this.access.signal.aborted?(L(),A):(this.access.signal.addEventListener(`abort`,L,{once:!0}),N(),this.pollCurrent=()=>{E()&&!_&&(y++,T.readCurrent=!1,T.actions=!1,T.attached?d?O():F():N())},a=setInterval(()=>{E()&&!_&&(c.tick(Date.now()),O(),(Date.now()-h>=(g?2e3:3e4)||e&&c.needsPoll(Date.now()))&&F())},1e3),A)}};function $o(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ee(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&B(t.settlement)!==B(r.settlement))?i=!0:(!r||ee(t.committedSeq,r.committedSeq)>0||B(r)===B(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function es(e,t,n=0,r,i=0,a){let o=JSON.stringify(t),s=(0,h.useMemo)(()=>({client:e,key:o,attachmentVersion:i,access:r,allocation:a}),[e,o,i,r,a]),c=(0,h.useRef)(s);c.current=s;let[l,u]=(0,h.useState)(0),d=(0,h.useRef)(0),f=(0,h.useRef)(void 0),[p,m]=(0,h.useState)();(0,h.useEffect)(()=>{if(o===`null`||r?.signal.aborted||a?.aborted)return;let t=new AbortController,i,u=()=>{t.abort(),clearTimeout(i)};f.current=u;let p=r?.subscribe(u);a?.addEventListener(`abort`,u);let h=async()=>{let a=await e.workbenchRead(vn(JSON.parse(o)),t.signal).catch(()=>({kind:`error`,error:E(`unavailable`)}));if(t.signal.aborted||c.current!==s||d.current!==l)return;if(a.kind===`error`&&r&&Jo(a.error.code)){r.refuse(`viewer`,a.error.code);return}m(e=>a.kind===`ok`?{scope:s,revision:l,value:a.value}:{scope:s,revision:l,value:e?.scope===s?e.value:void 0,error:a.error.code});let u=n||(r&&a.kind===`error`?5e3:0);u&&(i=setTimeout(()=>void h(),u))};return h(),()=>{a?.removeEventListener(`abort`,u),p?.(),u()}},[e,o,l,n,r,s,a]);let g=(0,h.useCallback)(()=>{c.current!==s||r?.signal.aborted||(f.current?.(),u(++d.current))},[s,r]),_=!r?.signal.aborted&&!a?.aborted&&p?.scope===s;return{..._?p:{},loading:o!==`null`&&(!_||p.revision!==l),refresh:g}}function ts(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function ns(e,t,n=!1){let[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)([]),s=es(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}function rs(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function is(e,t,n){return!t||t.value.status===`unavailable`?{value:e??t?.value,association:`unknown`,error:n??`unavailable`}:{...t,error:void 0}}function as(e,t,n){let[r,i]=(0,h.useState)(0),a=(0,h.useRef)(0),o=(0,h.useRef)(0),[s,c]=(0,h.useState)({});(0,h.useEffect)(()=>{if(!e||n.signal.aborted)return;let i=++o.current,a=new AbortController,s=()=>!a.signal.aborted&&o.current===i,l,u=()=>{a.abort(),clearTimeout(l)},d=n.subscribe(u),f=(i,a)=>{s()&&(a&&Jo(a)?n.refuse(`project`,a):(c(n=>({id:e,revision:r,selectedEpoch:t,...is(n.id===e?n.value:void 0,i,a)})),l=setTimeout(()=>void p(),qo)))},p=async()=>{if(s())try{f(await Xo(`/workbench/v1/projects/${e}`,a.signal,(e,t)=>({value:xo(e),association:nn(t.headers.get(tn))})))}catch(e){f(void 0,e instanceof Error?e.message:`unavailable`)}};return p(),()=>{d(),u()}},[e,r,t,n]);let l=(0,h.useCallback)(()=>{if(n.signal.aborted)return a.current;++o.current;let e=++a.current;return i(e),e},[n]),u=t=>{n.check();let r=l();c(n=>({id:e,revision:r,selectedEpoch:t,association:`associated`,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:n.id===e?n.value?.workspaceId??null:null}}))},d=n.refusal?{error:n.refusal.source===`project`?n.refusal.code:void 0}:s.id===e?s:{},f=d.revision===r&&d.selectedEpoch===t;return{...d,association:f?d.association??`unknown`:`unknown`,readiness:rs(d.value,d.error,f),refresh:l,prepared:u}}var os=1e4;function ss(e,t,n,r,i){let[a,o]=(0,h.useState)(0),s=(0,h.useRef)(void 0),c=(0,h.useMemo)(()=>({project:e,task:t,workspaceId:n,epoch:r,access:i,revision:a}),[e,t,n,r,i,a]),l=(0,h.useRef)(c);l.current=c;let[u,d]=(0,h.useState)();(0,h.useEffect)(()=>{let{project:e,workspaceId:t,epoch:n,access:r}=c;if(!e||!t||!n||r.signal.aborted)return;let i=!1,a=()=>!i&&!r.signal.aborted&&l.current===c,o=new Ua(new ao({origin:window.location.origin,project:e,retainedHistory:!0,requestTimeoutMs:os,fetch:async(e,t)=>{if(!a())throw Error(`stale`);let n=await fetch(e,t);if(!a()||t?.signal?.aborted)throw n.body?.cancel().catch(()=>{}),Error(`stale`);return(n.status===401||n.status===403)&&r.refuse(`project`,n.status===401?`unauthenticated`:`forbidden`),n}})),u,f,p=()=>{let e=new AbortController;u=e;let i=()=>a()&&!e.signal.aborted,s=t=>{i()&&(e.abort(),clearTimeout(f),Jo(t)?r.refuse(`project`,t):(d({selection:c,error:t}),f=setTimeout(p,qo)))};f=setTimeout(()=>s(`timeout`),os),o.workspace(e.signal).then(e=>{if(!i())return;if(e.kind===`error`)return s(e.error.code);let r=e.value;if(r.workspaceId!==t||r.epoch!==n)return s(`History workspace does not match the selected owner`);clearTimeout(f),d({selection:c,history:{client:o,workspace:{workspaceId:t,epoch:n,storeId:r.storeId,committedSeq:r.committedSeq}}})}).catch(()=>s(`unavailable`))},m=()=>{i=!0,clearTimeout(f),u.abort()};s.current=m;let h=r.subscribe(m);return p(),()=>{s.current=void 0,h(),m()}},[c]);let f=()=>{e&&!i.signal.aborted&&l.current===c&&(s.current?.(),o(e=>e+1))};return!e||i.signal.aborted?{refresh:f}:!r||!n?{error:`History identity not confirmed`,refresh:f}:{...u?.selection===c?u:{},refresh:f}}var cs={readCurrent:!1,actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};function ls(e,t,n,r,i){let a=(0,h.useMemo)(()=>new Qo(e,i),[e,i]),[o,s]=(0,h.useState)(0),c=t?.kind,l=t?.id,u=(0,h.useMemo)(()=>({kind:c,id:l,enabled:n,epoch:r,revision:o,observer:a}),[c,l,n,r,o,a]),[d,f]=(0,h.useState)();return(0,h.useEffect)(()=>{let{enabled:e,kind:t,id:n,observer:r}=u;if(e)return r.observe(t&&n?{kind:t,id:n}:null,e=>f({selection:u,value:e}))},[u]),{...d?.selection===u&&!i.signal.aborted?d.value:cs,refresh:()=>a.refresh(),whenReady:(e,t,n)=>a.whenReady(e,t,n),reconnect:()=>{i.check();let e=a.nextObservation();return s(e=>e+1),e}}}var us=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function ds({client:e,value:t,onChange:n}){let{t:r,tx:i}=X(),a=(0,h.useRef)(!0),o=(0,h.useRef)(null);(0,h.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,h.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,Y.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,Y.jsx)(`h3`,{children:r(`Command receipt`)}),(0,Y.jsx)(`code`,{children:t.commandId}),t.error&&(0,Y.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,Y.jsxs)(`dl`,{children:[(0,Y.jsx)(`dt`,{children:r(`Admission`)}),(0,Y.jsx)(`dd`,{children:i(l.admission)}),(0,Y.jsx)(`dt`,{children:r(`Execution`)}),(0,Y.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,Y.jsx)(`dt`,{children:r(`Publication`)}),(0,Y.jsx)(`dd`,{children:i(l.publication)}),(0,Y.jsx)(`dt`,{children:r(`Run`)}),(0,Y.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,Y.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,Y.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function fs(e,t){let n=e??{content:t.content,chunks:[],offset:0},r=n.content,i=t.content;if(r.recordId!==i.recordId||r.version!==i.version||r.field!==i.field||r.sha256!==i.sha256||r.bytes!==i.bytes||n.offset!==(t.range?.start??0))throw Error(`Noncontiguous immutable field`);return{...n,chunks:[...n.chunks,t.text],offset:t.range?.end??0}}function ps(e,t,n){switch(t.reader){case`tasks`:return e.tasks(t,n);case`runs`:return e.runs(t,n);case`messages`:return e.messages(t,n);case`tools`:return e.tools(t,n);case`contents`:return e.contents(t,n);case`events`:return e.events(t,n);case`checks`:return e.checks(t,n);case`changes`:return e.changes(t,n);case`reviews`:return e.reviews(t,n)}}function ms(e,t,n,r){return{storeId:e,scope:t,snapshotSeq:n,query:null,recordId:r.recordId,recordVersion:r.version,field:r.field,offset:0}}async function hs(e,t,n){let r={...t,offset:0};delete r.navigation;let i=null,a=!0;for(;r;){if(n.aborted)throw Error(`canceled`);let t=await e.detail(r,n);if(n.aborted)throw Error(`canceled`);if(t.kind===`error`)throw Error(t.error.code);let o=t.value;r=o.next,`kind`in o||(a&&=o.coverage.observed===`complete`,i=fs(i,o)),await new Promise(e=>setTimeout(e,0))}if(!i||i.offset!==i.content.bytes)throw Error(`incomplete-content`);return{text:i.chunks.join(``),recordingComplete:a}}function gs(e,t){let n=t?B({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,h.useState)(),[a,o]=(0,h.useState)(!1),[s,c]=(0,h.useState)(),[l,u]=(0,h.useState)(t),[d,f]=(0,h.useState)([]),p=(0,h.useRef)(0),[m,g]=(0,h.useState)(n);return m!==n&&(p.current++,g(n),i(void 0),c(void 0),u(t),f([])),(0,h.useEffect)(()=>{let t=++p.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),ps(e,l,n.signal).then(e=>{t===p.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===p.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),p.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&f(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),f(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),f([]),u(t?{...t}:null)}}}function _s({value:e,compact:t=!1}){let{t:n,tx:r}=X();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,Y.jsxs)(`details`,{className:`coverage-details`,children:[(0,Y.jsx)(`summary`,{children:n(`Recording details`)}),(0,Y.jsx)(_s,{value:e})]}):(0,Y.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[n(`Recording: {observed}; source: {source};`,{observed:r(e.observed),source:r(e.source)}),` `,e.redacted?n(`redacted`):n(`no reported redaction`),e.omissions.length>0&&n(`; omitted: {omissions}`,{omissions:e.omissions.map(r).join(`, `)}),n(`. Not a guarantee of complete original source or universal secret detection.`)]})}function vs(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function ys(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return vs(e)}return vs(e)}function bs(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,h.useRef)(!0),[a,o]=(0,h.useState)(!1),s=(0,h.useRef)(null),c=(0,h.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,h.useCallback)(()=>{c(),o(!1)},[c]);return(0,h.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,h.useCallback)(async e=>{let a=!1;try{a=await ys(e)}catch(e){a=!1,r&&r(e)}return i.current&&(a?(o(!0),c(),s.current=setTimeout(()=>{o(!1),s.current=null},t),n?.(e)):r&&!a&&r(Error(`Copy failed`))),a},[t,n,r,c]),reset:l}}var xs=r();function Ss(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
17
|
-
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,h.createElement)(n.type,i)]]:a.map(e=>[(0,h.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Cs=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ws(!0)},text:{92:ws(!1)}});let t={enter:{backslashMathInline:Ts,backslashMathDisplay:Ts,backslashMathBlock:Ts},exit:{backslashMathInline:Es,backslashMathDisplay:Es,backslashMathBlock:Es}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ws(e){return{tokenize:function(t,n,r){let i=this,a=93,o=e?`backslashMathBlock`:`backslashMathDisplay`,s;return c;function c(e){return e===92?(s=t.enter(o),t.consume(e),l):r(e)}function l(n){return n!==91&&(e||n!==40)?r(n):(a=n===91?93:41,!e&&n===40&&(o=`backslashMathInline`,s.type=o),t.consume(n),u)}function u(n){return n===null||e&&i.parser.lazy[i.now().line]?r(n):n===-5||n===-4||n===-3?(t.enter(`lineEnding`),t.consume(n),t.exit(`lineEnding`),u):(f(n),n===92?d:u)}function d(i){return i===a?(f(i),t.exit(o),e?p:n):i===null?r(i):i===-5||i===-4||i===-3?u(i):(f(i),u)}function f(e){t.enter(`backslashMathData`),t.consume(e),t.exit(`backslashMathData`)}function p(e){return e===null||e===-5||e===-4||e===-3?n(e):e===32||e===-2||e===-1?(t.enter(`whitespace`),t.consume(e),t.exit(`whitespace`),p):r(e)}},concrete:e,name:e?`backslashMathBlock`:`backslashMathText`}}var Ts=function(e){let t=e.type===`backslashMathBlock`,n=e.type!==`backslashMathInline`,r=this.sliceSerialize(e).slice(2,-2).trim(),i={type:`element`,tagName:`code`,properties:{className:[`language-math`,n?`math-display`:`math-inline`]},children:[{type:`text`,value:r}]},a=t?{type:`math`,meta:null,value:r,data:{hName:`pre`,hChildren:[i]}}:{type:`inlineMath`,value:r,data:{hName:`code`,hProperties:i.properties,hChildren:i.children}};this.enter(a,e)},Es=function(e){this.exit(e)};function Ds(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var Os=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function ks(e,t,n=3){let r=[...e.filter(e=>!Os(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var As=[],js=1,Ms=new Set;function Ns(e){if(!(e.length===As.length&&e.every((e,t)=>e===As[t]))){As=e;for(let e of Ms)e()}}function Ps(e,t,n){let r=js++;return Ns(ks(As,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function Fs(e){Ns(As.filter(t=>t.id!==e))}function Is(e){Ns(As.filter(t=>t.key!==e))}function Ls(e){return Ms.add(e),()=>{Ms.delete(e)}}var Rs=()=>As,zs=(0,h.memo)(function({text:e,label:t,className:n=`copy-btn`}){let{t:r}=X(),{copied:i,copy:a}=bs();return(0,Y.jsx)(`button`,{type:`button`,className:i?`${n} copied`:n,title:t??r(`Copy displayed text`),"aria-label":t??r(`Copy displayed text`),onClick:()=>{a(e).then(e=>{e||Ps(`error`,r(`Copy unavailable`))})},children:i?(0,Y.jsx)(Pa,{}):(0,Y.jsx)(Ea,{})})}),Bs=[l,p,Cs],Vs=[l,d,p,Cs],Hs=[[u,{strict:!1,throwOnError:!1,errorColor:`var(--err-text)`,trust:!1,maxExpand:1e3}],[f,{detect:!1,ignoreMissing:!0}]];function Us(e){if(e.startsWith(`#`)&&![...e].some(e=>e.charCodeAt(0)<=32))return e;try{let t=new URL(e);return![`https:`,`http:`].includes(t.protocol)||t.username||t.password||t.searchParams.has(`token`)?void 0:e}catch{return}}function Ws({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,Y.jsx)(o,{remarkPlugins:n?Vs:Bs,remarkRehypeOptions:{footnoteLabelProperties:{className:[`sr-only`],dataFieldChrome:``}},rehypePlugins:t?[a,s,...Hs]:Hs,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Ys,a:Ks,img:({alt:e})=>(0,Y.jsxs)(`span`,{className:`omission`,children:[(0,Y.jsx)(`span`,{"data-field-chrome":``,children:`[Image omitted: `}),e||(0,Y.jsx)(`span`,{"data-field-chrome":``,children:`external/media content`}),(0,Y.jsx)(`span`,{"data-field-chrome":``,children:`]`})]})},children:e})}var Gs=(0,h.memo)(function(e){return(0,Y.jsx)(`div`,{className:`md`,children:(0,Y.jsx)(Ws,{...e})})});function Ks({href:e,children:t,...n}){let r=e&&Us(e);return r?(0,Y.jsx)(`a`,{"data-field-chrome":`data-footnote-ref`in n||`data-footnote-backref`in n?``:void 0,href:r,target:r.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,Y.jsxs)(`span`,{children:[t,(0,Y.jsx)(`span`,{"data-field-chrome":``,children:` [link unavailable]`})]})}var qs=new WeakMap;function Js(e){let t=e.startContainer.parentElement?.closest(`pre`),n=t&&qs.get(t);n&&(0,xs.flushSync)(n)}function Ys({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=e&&typeof e==`object`&&`props`in e?String(e.props.className??``).match(/(?:^|\s)language-([^\s]+)/)?.[1]:void 0,{locale:a}=X(),[o,s]=(0,h.useState)(!0),c=0,l=Ss(r).map(e=>{let t=`code-offset:${c}`;return c+=Xs(e).length+1,{key:t,nodes:e}}),u=l.length>1,d=u?`${String(l.length).length+1}ch`:void 0;return(0,Y.jsxs)(`div`,{className:`codeblock`,children:[(0,Y.jsxs)(`div`,{"data-field-chrome":``,className:`code-caption`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:()=>s(!o),children:[(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:o?`▾`:`▸`}),i||(a===`zh`?`代码`:`Code`)]}),(0,Y.jsx)(zs,{text:Xs(e),className:`output-copy`})]}),(0,Y.jsx)(`pre`,{...n,hidden:!o,ref:o?void 0:e=>{if(e)return qs.set(e,()=>s(!0)),()=>{qs.delete(e)}},children:l.map(({nodes:e,key:t},n)=>(0,Y.jsxs)(`div`,{className:`code-line`,children:[u&&(0,Y.jsx)(`span`,{"data-field-chrome":``,className:`code-num`,style:d?{width:d}:void 0,children:n+1}),(0,Y.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Xs(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Xs).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Xs(t?.children)}return``}function Zs(e,t){let n=[],r=t;if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(t){let n=t.parentElement;return!n||!e.contains(n.closest(`[data-retained-field]`))||n.closest(`[data-field-chrome], .katex-mathml, .search-bar, .msg-collapsed`)?NodeFilter.FILTER_REJECT:(t.textContent??``).includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=e.textContent??``,i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();if(a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),n.length===1e3)return n;i=t.indexOf(r,i+r.length)}}return n}var Qs=new Map;function $s(e,t){t.length?Qs.set(e,t):Qs.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Qs].filter(([e])=>e.endsWith(`-active`)===n).flatMap(([,e])=>e);let r=CSS;if(!r.highlights)return;if(t.length===0){r.highlights.delete(e);return}let i=window.Highlight;i&&r.highlights.set(e,new i(...t))}function ec(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function tc(e,t){let n=t.startContainer.parentElement;for(let r of ec(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function nc({container:e,version:t}){let{t:n}=X(),[r,i]=(0,h.useState)(``),[a,o]=(0,h.useState)(0),[s,c]=(0,h.useState)(0),l=(0,h.useRef)([]),u=`cadence-page-${(0,h.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,h.useLayoutEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?Zs(n,r):[];return l.current=i,c(i.length),o(0),$s(u,i),()=>{l.current=[],$s(u,[]),$s(`${u}-active`,[])}},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0,i=e.current,c=l.current[n];if(!i||!c||!i.contains(c.commonAncestorContainer)||(Js(c),e.current!==i||!i.isConnected||l.current[n]!==c||!i.contains(c.commonAncestorContainer)||c.toString()!==r))return;let{width:d,height:f}=c.getBoundingClientRect();d&&f&&(tc(document.documentElement,c),o(n),$s(`${u}-active`,[c]))};return(0,Y.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,Y.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,Y.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,Y.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,Y.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function rc({client:e,cursor:t,highlight:n,preview:r,compact:i=!1}){let{t:a,tx:o}=X(),s=B(t),c=(0,h.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,h.useState)(t),[d,f]=(0,h.useState)(),[p,m]=(0,h.useState)([]),[g,_]=(0,h.useState)(!1),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(i?`markdown`:`raw`),[S,C]=(0,h.useState)(``),w=(0,h.useRef)(null),T=(0,h.useRef)(null);(0,h.useEffect)(()=>(u(c),m([]),f(void 0),y(void 0),()=>w.current?.abort()),[c]),(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return _(!0),y(void 0),e.detail(l,n.signal).then(e=>{t&&(_(!1),e.kind===`error`?y(e.error.code):f(e.value))}).catch(()=>{t&&(y(`Read unavailable.`),_(!1))}),()=>{t=!1,n.abort()}},[e,l]);let E=async()=>{if(w.current)return;let n=new AbortController;w.current=n,C(a(`Reading all retained field pages…`));try{let r=await hs(e,t,n.signal);if(n.signal.aborted)return;let i=await ys(r.text);if(n.signal.aborted)return;C(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||C(a(`Full-field copy refused/incomplete.`))}finally{w.current===n&&(w.current=null)}},D=d&&!(`kind`in d)?d:void 0,O=D?B(D.cursor):``;return(0,Y.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,Y.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,Y.jsx)(`summary`,{children:a(`Field details`)}),(0,Y.jsxs)(`div`,{className:`detail-identity`,children:[(0,Y.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,Y.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,Y.jsxs)(`div`,{className:`toolbar`,children:[!r&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>x(e=>e===`raw`?`markdown`:`raw`),children:a(b===`raw`?`Markdown page`:`Raw page`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:!!w.current,onClick:()=>void E(),children:a(`Copy full retained field`)}),!!w.current&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{w.current?.abort(),w.current=null,C(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),S&&(0,Y.jsx)(`p`,{role:`status`,children:S}),v&&(0,Y.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(v)})}),g&&(0,Y.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,Y.jsx)(_s,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,Y.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),D&&(0,Y.jsxs)(Y.Fragment,{children:[(!i||D.next)&&(0,Y.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:D.range?.start??0,end:D.range?.end??0,total:D.content.bytes}),` `,D.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,Y.jsx)(nc,{container:T,version:`${O}:${r?.view??b}`}),(0,Y.jsx)(`div`,{ref:T,children:r?(0,Y.jsx)(`div`,{children:r.render(D.text)},O):(0,Y.jsx)(`div`,{"data-retained-field":!0,children:b===`markdown`?(0,Y.jsx)(Gs,{text:D.text}):(0,Y.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!D||!n||!D.range)return D?.text;let e=Math.max(n.start,D.range.start)-D.range.start,t=Math.min(n.end,D.range.end)-D.range.start;if(t<=e)return D.text;let r=new TextEncoder().encode(D.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,Y.jsxs)(Y.Fragment,{children:[i(0,e),(0,Y.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})})]}),(!i||p.length>0||d?.next)&&(0,Y.jsxs)(`div`,{className:`toolbar`,children:[(0,Y.jsx)(`button`,{type:`button`,disabled:g||!p.length,onClick:()=>{u(p[p.length-1]),m(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:g||!d?.next,onClick:()=>{d?.next&&(m(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function ic({pager:e,compact:t=!1}){let{t:n,tx:r}=X(),{page:i,busy:a,error:o}=e;return(0,Y.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,Y.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,Y.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,Y.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,Y.jsx)(_s,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,Y.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,Y.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,Y.jsx)(Yi,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,Y.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function ac({client:e,seed:t,entityId:n}){let{t:r,tx:i}=X(),a=gs(e,{...t,reader:`contents`}),[o,s]=(0,h.useState)(),c=a.page;return(0,Y.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,Y.jsx)(ic,{pager:a}),n&&(0,Y.jsx)(`p`,{children:(0,Y.jsx)(nr,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,Y.jsx)(`code`,{children:n})}})}),c&&!(`kind`in c)&&c.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,Y.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,Y.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,Y.jsxs)(`article`,{children:[(0,Y.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,Y.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,Y.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,Y.jsx)(_s,{value:e.coverage}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ms(c.request.storeId,c.request.scope,c.request.snapshotSeq,e.content))},children:r(`Inspect complete retained field`)})]},`${e.content.recordId}:${e.content.version}`)),o&&(0,Y.jsx)(rc,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function oc({client:e,seed:t}){return(0,Y.jsx)(sc,{client:e,seed:t},B(t))}function sc({client:e,seed:t}){let{t:n,tx:r}=X(),[i,a]=(0,h.useState)(t),[o,s]=(0,h.useState)(),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(i.kind===`message`?e.message(i,n.signal):i.kind===`tool`?e.tool(i,n.signal):e.task(i,n.signal)).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,Y.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,Y.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,Y.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,Y.jsx)(_s,{value:o.coverage}),o&&(`kind`in o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,Y.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function cc(e){let t=ro(`download`,ai(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Kn()+t.path,n.download=`cadence-${e.scope.kind}-${e.scope.id}.${e.format===`markdown`?`md`:`ndjson`}`,n.referrerPolicy=`no-referrer`,document.body.appendChild(n),n.click(),n.remove()}function lc({title:e,children:t,onClose:n}){let{t:r}=X(),i=(0,h.useRef)(null),a=(0,h.useId)(),o=(0,h.useRef)(n);return o.current=n,(0,h.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,Y.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`h2`,{id:a,children:e}),n&&(0,Y.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]}),t]})}function uc({request:e,onClose:t}){let{t:n,tx:r}=X(),[i]=(0,h.useState)(e),[a,o]=(0,h.useState)(e.format),[s,c]=(0,h.useState)(``);return(0,Y.jsxs)(lc,{title:n(`Export retained history`),onClose:t,children:[(0,Y.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,Y.jsxs)(`label`,{children:[n(`Format`),(0,Y.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,Y.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,Y.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,Y.jsx)(`p`,{children:n(`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`)}),(0,Y.jsx)(`p`,{children:n(`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{try{cc({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,Y.jsx)(`p`,{role:`status`,children:s})]})}function dc(e,t){if(!t||k(t)>C.queryBytes)throw Error(`Query must be 1–${C.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function fc(e){return e.next?`No hits in this bounded window; search is not finished.`:`No hits in the final retained window. Coverage limits above still apply.`}function pc({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=X(),[o]=(0,h.useState)(t),s=(0,h.useRef)(null),c=(0,h.useRef)(0),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)(0),p=(0,h.useId)(),m=(0,h.useRef)(null),g=(0,h.useRef)(null),_=(0,h.useRef)(!1),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(),w=(0,h.useRef)(null),T=(0,h.useCallback)(async(t,n)=>{w.current?.abort();let r=new AbortController;w.current=r,x(!0),C(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?C(i.error.code):(_.current=!0,y(i.value),f(0))}catch{c.current===n&&!r.signal.aborted&&C(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&x(!1)}},[e]);(0,h.useEffect)(()=>(s.current?.focus(),()=>{c.current++,w.current?.abort()}),[]),(0,h.useEffect)(()=>{let e=++c.current;if(w.current?.abort(),x(!1),y(void 0),f(0),C(void 0),!l)return;let t;try{t=dc(o,l)}catch{C(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void T(t,e),300);return()=>{clearTimeout(n),c.current++,w.current?.abort()}},[l,o,T]);let E=v?.cursor.query===l?v:void 0,D=E?.hits[d],O=({content:e,range:t})=>`${p}-${e.recordId}-${e.version}-${e.field}-${t.start}-${t.end}`;return(0,h.useLayoutEffect)(()=>{if(!D||!_.current||!m.current||!g.current)return;let e=m.current,t=g.current.getBoundingClientRect(),n=e.getBoundingClientRect().top+e.clientTop,r=n+e.clientHeight;t.top<n||t.height>e.clientHeight?e.scrollTop+=Math.floor(t.top-n):t.bottom>r&&(e.scrollTop+=Math.ceil(t.bottom-r))},[D]),(0,Y.jsx)(lc,{title:i(`Search retained history`),onClose:n,children:(0,Y.jsxs)(`div`,{className:`gs-modal`,children:[(0,Y.jsxs)(`div`,{className:`gs-input-row`,children:[(0,Y.jsx)(qi,{}),(0,Y.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!!D,"aria-controls":p,"aria-activedescendant":D?O(D):void 0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{if(D&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),_.current=!0;let t=e.key===`ArrowDown`?1:-1;f(e=>Math.max(0,Math.min(e+t,E.hits.length-1)))}e.key===`Enter`&&(e.preventDefault(),r(D),n())}}})]}),(0,Y.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,Y.jsxs)(`div`,{className:`gs-results`,ref:m,children:[b&&(0,Y.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),S&&(0,Y.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(S)})}),!l&&(0,Y.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),E&&(0,Y.jsx)(_s,{value:E.coverage}),(0,Y.jsxs)(`div`,{className:`gs-section`,hidden:!E,children:[(0,Y.jsx)(`div`,{className:`gs-section-head`,id:`${p}-label`,children:i(`Matches on this page: {count}`,{count:E?.hits.length??0})}),(0,Y.jsx)(`div`,{role:`listbox`,id:p,"aria-labelledby":`${p}-label`,hidden:!D,children:E?.hits.map((e,t)=>(0,Y.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,id:O(e),ref:D===e?g:void 0,"aria-selected":D===e,className:`gs-item`,onMouseDown:e=>e.preventDefault(),onMouseMove:()=>{_.current=!1,e!==D&&f(t)},onClick:()=>{r(e),n()},children:[(0,Y.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,Y.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,Y.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` /`,` `,i(`bytes {start}–{end}`,{start:e.range.start,end:e.range.end})]})]},O(e)))}),E&&E.hits.length===0&&(0,Y.jsx)(`p`,{children:a(fc(E))})]}),E&&(0,Y.jsx)(`button`,{type:`button`,disabled:b||!E.next,onClick:()=>{E.next&&(s.current?.focus({preventScroll:!0}),T(E.next,++c.current))},children:i(`Continue same snapshot search`)})]}),(0,Y.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function mc({run:e,historical:t=!1}){let{t:n,tx:r}=X();return(0,Y.jsxs)(`article`,{className:`run-summary`,children:[(0,Y.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,Y.jsx)(`p`,{children:(0,Y.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,Y.jsxs)(`dl`,{children:[(0,Y.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,Y.jsx)(`dd`,{children:r(e.lifecycle)}),(0,Y.jsx)(`dt`,{children:n(`Execution`)}),(0,Y.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,Y.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,Y.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,Y.jsx)(`dt`,{children:n(`Summary publication`)}),(0,Y.jsx)(`dd`,{children:r(e.publication)})]}),(0,Y.jsx)(_s,{value:e.coverage}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,Y.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function hc({client:e,seed:t}){return(0,Y.jsx)(gc,{client:e,seed:t},B(t))}function gc({client:e,seed:t}){let{t:n,tx:r}=X(),[i,a]=(0,h.useState)(t),[o,s]=(0,h.useState)(),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),e.graph(i,n.signal).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,Y.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,Y.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,Y.jsx)(_s,{value:o.coverage}),o&&(`kind`in o?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,Y.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(rc,{client:e,cursor:ms(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,Y.jsxs)(`article`,{children:[(0,Y.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,Y.jsx)(Gs,{text:e.instructions}),(0,Y.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,Y.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function _c({client:e,seed:t,onScope:n}){let{t:r}=X(),i=gs(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,h.useState)();return(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(ic,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,Y.jsxs)(`article`,{children:[(0,Y.jsx)(mc,{run:e.projection,historical:!0}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,Y.jsx)(hc,{client:e,seed:o},o.graph.recordId)]})}function vc({onOpen:e,disabled:t}){let{t:n}=X();return(0,Y.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,Y.jsx)(qi,{"aria-hidden":`true`})})}function yc(e,t,n,r,i){let a=i??t,o=[],s=[],c=0;for(let i of e)n.has(i.id)||(r.has(i.id)?i.top<t.bottom&&i.bottom>t.top&&o.push(i.id):i.top<a.bottom&&i.bottom>a.top||(s.push(i.id),i.bottom<=a.top&&(c+=i.bottom-i.top)));return{show:o,hide:s,shrinkAbove:c}}function bc(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function xc(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??Sc(n.role,n.customType)}return r}function Sc(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`tool-result`:return 120;case`custom`:return t===`file`?96:72;default:return 60}}function Cc(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function wc(e,t,n=null,r=1800,i){let a=(0,h.useRef)(i);a.current=i;let o=(0,h.useRef)(null),[s,c]=(0,h.useState)(()=>new Set),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(new Map),d=(0,h.useRef)(new Map),f=(0,h.useRef)(new Map),p=(0,h.useRef)(0),m=(0,h.useRef)(new Map);m.current=new Map(t.map(e=>[e.id,e.version]));let g=(0,h.useRef)(new Set);g.current=xc(t,u.current,r),n!==null&&g.current.add(n);let _=(0,h.useCallback)((e,t)=>{let n=m.current.get(e);n!==void 0&&(d.current.set(e,{h:t,len:n}),u.current.set(e,t))},[]),v=(0,h.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of f.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),l.current.has(e)||_(e,n.height)}let i=yc(r,{top:n.top-1200,bottom:n.bottom+1200},g.current,l.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=f.current.get(e);t&&_(e,t.offsetHeight)}c(e=>bc(e,i))},[_,e]),y=(0,h.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,v()})},[v]);return(0,h.useLayoutEffect)(()=>{t.length?v():c(new Set)},[v,t,n]),(0,h.useEffect)(()=>{let t=new ResizeObserver(()=>{y(),a.current?.()});o.current=t,e.current&&t.observe(e.current);for(let e of f.current.values())t.observe(e);return()=>{o.current=null,t.disconnect(),cancelAnimationFrame(p.current),p.current=0}},[y,e]),{hidden:s,scheduleSweep:y,recordMeasured:_,register:(0,h.useCallback)(e=>t=>{let n=f.current.get(e);n&&n!==t&&o.current?.unobserve(n),t?(f.current.set(e,t),o.current?.observe(t)):f.current.delete(e)},[]),placeholder:(0,h.useCallback)((e,t,n)=>Cc(e,t,d.current,n),[])}}function Tc(e,t){e&&t&&(e.scrollTop=e.scrollHeight)}function Ec(e,t,n){(0,h.useEffect)(()=>{let r=new ResizeObserver(()=>Tc(e.current,n.current));return t.current&&r.observe(t.current),()=>r.disconnect()},[e,t,n])}var Dc=(0,h.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,h.useRef)(null);return(0,h.useLayoutEffect)(()=>{if(!t)return;let n=s.current;if(!n)return;let r=n.offsetHeight;r>0&&i?.(e,r)},[t,e,i]),t?(0,Y.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,Y.jsx)(`div`,{ref:s,children:o})}):(0,Y.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Oc=(0,h.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=X(),[a,o]=(0,h.useState)(!1);return(0,Y.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,Y.jsxs)(`header`,{className:`msg-meta`,children:[(0,Y.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,Y.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,Y.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,Y.jsx)(Aa,{"aria-hidden":`true`}):(0,Y.jsx)(va,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,Y.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,Y.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,Y.jsx)(`div`,{className:`msg-text`,children:(0,Y.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,Y.jsx)(rc,{compact:!0,client:t,cursor:ms(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,Y.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,Y.jsxs)(`div`,{className:`message-inspection`,children:[(0,Y.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,Y.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,Y.jsxs)(`details`,{open:!0,children:[(0,Y.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,Y.jsx)(ac,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function kc({messages:e,client:t,seed:n}){let{t:r}=X(),i=(0,h.useRef)(null),a=(0,h.useRef)(!0),o=(0,h.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=wc(i,o);return(0,Y.jsxs)(`div`,{className:`messages-wrap`,children:[(0,Y.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,Y.jsx)(Dc,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,Y.jsx)(Oc,{message:a,client:t,seed:n})},e))}),(0,Y.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,Y.jsx)(za,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Ac({client:e,seed:t}){let{t:n}=X(),r=gs(e,{...t,reader:`messages`}),i=r.page;return(0,Y.jsxs)(`section`,{className:`transcript`,children:[(0,Y.jsx)(ic,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,Y.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,Y.jsxs)(Y.Fragment,{children:[i.records.length===0&&(0,Y.jsx)(`p`,{className:`empty-note panel-empty`,children:i.next?n(`No message records on this page; more history remains.`):n(`No message records on this page.`)}),(0,Y.jsx)(kc,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function jc({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,Y.jsxs)(`div`,{className:`chead ${n}`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,Y.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,Y.jsx)(Na,{}):(0,Y.jsx)(ja,{})}):c,(0,Y.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,Y.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Mc=(0,h.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=X(),[a,o]=(0,h.useState)(!1),s=e.result?e.result.isError?r(`SDK tool error observed`):r(`SDK tool end observed`):e.startObserved?r(`Start observed; end not observed in this snapshot`):r(`No start observed`),c=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,Y.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,Y.jsx)(jc,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,Y.jsx)(Bi,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,Y.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,Y.jsxs)(`div`,{className:`toolcall-body`,children:[(0,Y.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,Y.jsxs)(`dl`,{children:[(0,Y.jsx)(`dt`,{children:r(`Source ID`)}),(0,Y.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,Y.jsx)(`dt`,{children:r(`Declaration`)}),(0,Y.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,Y.jsxs)(`div`,{className:`toolcall-output`,children:[(0,Y.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(`Recorded tool end (not parsed from output)`),e.result&&(0,Y.jsx)(zs,{text:JSON.stringify(e.result,null,2),className:`output-copy`})]}),(0,Y.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,Y.jsx)(`div`,{className:`toolcall-args`,children:(0,Y.jsx)(ac,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Nc=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function Pc({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=X(),s=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(Nc(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length),c=!!t||e?.completeness===`partial`;return!s?.length&&!c?null:(0,Y.jsx)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:(0,Y.jsxs)(`div`,{className:`lp-section-body`,children:[c&&(0,Y.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),s?.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,Y.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,Y.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,Y.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,Y.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})})}function Fc(e){return e.replace(/(?:-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})+$/i,``)}function Ic(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var Lc=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function Rc(e,t){return Lc.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function zc(e){let t=Ic(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function Bc(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>Fc(e.id)===n.id),...r?{artifact:r}:{}}})}var Vc=[`queued`,`running`];function Hc(e,t){let n=e=>Number(!Vc.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function Uc(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(Fc(t.id))):!1}var Wc=[`queued`,`running`],Gc=4,Kc=1e4;function qc(e,t,n=2e3){let[r,i]=(0,h.useState)(()=>({runs:new Map,unreadable:new Set})),a=(0,h.useRef)(void 0),o=(0,h.useRef)({client:e,records:new Map}),s=JSON.stringify([...new Set(t)]);return(0,h.useEffect)(()=>{let t=new AbortController,r;o.current.client!==e&&(o.current={client:e,records:new Map});let{records:c}=o.current,l=JSON.parse(s),u=new Set(l);for(let e of c.keys())u.has(e)||c.delete(e);let d=new Map,f=()=>{let e,t=new Map;for(let n of l){let r=c.get(n);r&&(t.set(n,r.run),e??=r.error)}return i({runs:t,error:e,unreadable:new Set(d.keys())}),t},p=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(!t.signal.aborted){if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`)c.set(n,{run:r.value.response.run}),d.delete(n);else{let e=c.get(n);e?e.error=r.kind===`error`?r.error.code:`unavailable`:d.set(n,Date.now())}}},m=!1,h=!1,g=async()=>{if(clearTimeout(r),m){h=!0;return}m=!0;let e=Date.now(),i=l.filter(t=>{let n=c.get(t);return n?Wc.includes(n.run.status):e-(d.get(t)??0)>=Kc}).reverse();for(let e=0;e<i.length;e+=Gc){if(await Promise.all(i.slice(e,e+Gc).map(p)),t.signal.aborted)return;e+Gc<i.length&&f()}let a=f();m=!1,h?(h=!1,g()):[...a.values()].some(e=>Wc.includes(e.status))?r=setTimeout(()=>void g(),n):d.size&&(r=setTimeout(()=>void g(),Kc))};return a.current=g,g(),()=>{a.current=void 0,t.abort(),clearTimeout(r)}},[e,s,n]),{...r,refresh:()=>a.current?.()}}function Jc({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=X(),o=Ic(e),s=n?.runId===e.id?n.stepId:void 0,c=s===null;return(0,Y.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${c?` active`:``}`,"aria-current":c||void 0,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,Y.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,Y.jsx)(`span`,{className:`agent-dock-run-state`,children:Rc(o,i)})]}),t.map(t=>{let n=s===t.id,o=Fc(t.id),c=e.tasks?.find(e=>e.id===o);return(0,Y.jsxs)(`button`,{type:`button`,className:`agent-dock-row${n?` active`:``}`,"aria-current":n||void 0,title:c?`${c.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:o}),children:[(0,Y.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,Y.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,Y.jsx)(`strong`,{children:`${a(t.kind)} · ${o}`}),c&&(0,Y.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(c.state)})})]}),(0,Y.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function Yc({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=X(),[d,f]=(0,h.useState)(null),[p,m]=(0,h.useState)([]),[g,_]=(0,h.useState)(!1),v=qc(e,a),y=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,h.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(y)){let r=await e.snapshot({kind:`task`,id:n},t.signal);if(t.signal.aborted)return;if(r.kind===`ok`)for(let e of r.value.runs)e.childRunId&&i.push({taskId:n,run:e,snapshot:r.value.committedSeq});else a=!0}t.signal.aborted||(m(i),_(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,y]);let b=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],x=[...p,...b.filter(e=>!p.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),S=Hc(a,v.runs),C=S.flatMap(e=>e.steps),w=x.length+C.length,T=C.filter(e=>Wc.includes(e.status)).length+x.filter(e=>e.run.lifecycle!==`settled`).length,E=d??(w>0||!!g);return(0,Y.jsxs)(`section`,{className:`agent-dock${E?``:` collapsed`}`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":E,onClick:()=>f(!E),children:[(0,Y.jsx)(Na,{}),(0,Y.jsx)(Ca,{}),(0,Y.jsx)(`span`,{children:l(`Subagents`)}),(0,Y.jsx)(`span`,{className:`lp-count${T?` live`:``}`,children:T?l(`{active} active · {total} total`,{active:T,total:w}):w})]}),E&&(0,Y.jsxs)(`div`,{className:`agent-dock-body`,children:[(g||t?.status!==`complete`||v.error)&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),w===0&&!g&&t?.status===`complete`&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),S.map(({run:e,steps:t})=>(0,Y.jsx)(Jc,{run:e,steps:t,selected:o,onOpen:c},e.id)),x.map(e=>(0,Y.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,Y.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,Y.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,Y.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,Y.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,Y.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}function Xc(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function Zc(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var Qc=e=>e.filter(e=>e.current);function $c(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function el(e,t,n,r,i){let[a,o]=(0,h.useState)();(0,h.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=es(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,h.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,f]=(0,h.useState)();return(0,h.useEffect)(()=>{u&&f(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function tl({view:e,onChosen:t}){let{t:n,locale:r}=X(),[i,a]=(0,h.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,h.useMemo)(()=>Xc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,Y.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,Y.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,Y.jsxs)(`label`,{className:`lp-filter`,children:[(0,Y.jsx)(qi,{"aria-hidden":`true`}),(0,Y.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,Y.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]}),(0,Y.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,Y.jsx)(Yi,{"aria-hidden":`true`})})]}),(0,Y.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,Y.jsxs)(`p`,{className:`branches-pinned`,children:[(0,Y.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,Y.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:tr(n,e.error)}),s?.truncated&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,Y.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,Y.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,Y.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,Y.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,Y.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,Y.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,Y.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,Y.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,Y.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,Y.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,Y.jsx)(ba,{"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,Y.jsx)(Ta,{"aria-hidden":`true`})})]},t.id))})]})}function nl(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function rl(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function il(e,t){return Math.round(e/t*100)}var al=e=>e.trim().split(`
|
|
18
|
-
`,1)[0].slice(0,200);function ol(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var sl=(e,t)=>e?e.entry:t,cl=(e,t)=>e!==null&&t>=e.from;function ll(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:an(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function ul(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function dl(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function fl(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function pl(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function ml(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}function hl(e){for(let t of e){if(!v.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function gl(e){hl([e]);let t=new Uint8Array(await e.arrayBuffer());return b(t,e.type),t}var _l=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)};async function vl(e,t,n,r){hl(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await gl(a);if(!r())throw Error(`stale`);let o=_l(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=_.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+_.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function yl(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>_.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==_.chunkChars)throw Error(`invalid`)}let i=y(n.join(``));return b(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var bl=e=>e.renderId??`legacy:${e.id}`;function xl(e,t){let n=new Map(e.map(e=>[bl(e),e])),r=new Set;return t.map(e=>{let t=bl(e);if(r.has(t))throw new El(`stale`);r.add(t);let i=n.get(t);return i&&JSON.stringify(i)===JSON.stringify(e)?i:e})}var Sl=1e3,Cl=1e4,wl=4,Tl=e=>e===`starting`||e===`queued`||e===`running`,El=class extends Error{},Dl=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;cache;count=0;first=null;opening=null;turns=new Map;imageReaders=new Map;error=``;loadingEarlier=!1;inFlight;attachment=null;observation=null;again=!1;closed=!1;active=!1;timer;selection=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e,t=null){(this.active!==e||this.attachment!==t)&&(this.retireSync(),this.active=e,this.attachment=t,this.observation&&(this.observation=null,this.publish()),e&&this.tick())}retireSync(){clearTimeout(this.timer),this.inFlight?.abort(),this.inFlight=void 0,this.again=!1}close(){this.closed=!0,this.retireSync(),this.selection.abort()}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.retireSync(),this.selection.abort(),this.selection=new AbortController,this.observation=null,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{observation:this.observation,summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...this.cache?{cache:this.cache}:{},count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.inFlight){this.again=!0;return}let e=new AbortController;this.inFlight=e,clearTimeout(this.timer);let t=this.loadingEarlier;try{await this.sync(e.signal,this.attachment)}catch(t){if(e.signal.aborted)return;e.abort(),this.observation=null,this.error=t instanceof El?t.message:`unavailable`}if(this.inFlight!==e)return;if(this.inFlight=void 0,t&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=this.error===`stale`||Tl(this.summary?.status)||[...this.turns.values()].some(e=>Tl(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Sl:Cl)}async sync(e,t){let n=this.pinned,r=await this.read({kind:`conversation`,id:this.id,leaf:n,known:this.leaf},e);if(e.aborted)return;if(r.kind!==`conversation`)throw new El(`invalid`);let i=!r.continues||r.turns<this.count,a=r.leaf===this.leaf?this.count:this.count-1,o=Math.max(0,r.turns-2),s=Math.min((i?null:this.first)??this.opening??o,o),c=[];for(let e=s;e<r.turns;e++){let n=i?void 0:this.turns.get(e);(!n||e>=a||t!==this.observation&&e===r.turns-1||n.header.stable<n.header.steps||Tl(n.header.status))&&c.push(e)}let l=await Promise.all(c.map(t=>this.load(t,r.leaf,e,i?void 0:this.turns.get(t))));if(!e.aborted){i&&this.forget(),this.leaf=r.leaf,this.branches=r.branches,this.runs=r.runs,this.attempt=r.attempt,this.pending=r.pending??[],this.undelivered=r.undelivered??[],this.commands=r.commands??[],this.context=r.context,this.cache=r.cache,this.summary=r.summary,this.observation=t,this.error=``,this.count=r.turns,this.first=Math.min(s,this.first??s),this.opening=null;for(let e of l)this.turns.set(e.ordinal,e)}}async load(e,t,n,r){let i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,a.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{let n=i.start+t;if(r?.header.id===a.id&&n<Math.min(r.header.stable,a.stable)&&bl(r.steps[n])!==bl(e))throw new El(`stale`);o[n]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n)))){if(JSON.stringify(r.turn)!==JSON.stringify(a))throw new El(`stale`);r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)})}if(n.aborted||o.includes(void 0))throw new El(`stale`);let l=xl(r?.steps??[],o);return r&&r.image===this.imageReader(t,this.selection.signal)&&JSON.stringify(r.header)===JSON.stringify(a)&&r.steps.length===l.length&&l.every((e,t)=>e===r.steps[t])?r:{ordinal:e,renderId:l.find(e=>e.role===`user`)?.renderId??a.id,header:a,steps:l,detail:this.detail(t,a.id,l,this.selection.signal),image:this.imageReader(t,this.selection.signal)}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new El(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=hr([t,r]);try{return await yl(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n,r){return async(i,a,o)=>{let s=n[i];if(!s)throw new El(`stale`);let c=await Promise.all(Array.from({length:a},async(n,a)=>{let c=hr([r,o]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:i,part:a},c.signal);if(n.kind!==`conversation-step`||n.part!==a||n.conversationId!==this.id||n.leaf!==e||n.turnId!==t||n.step!==i)throw new El(`invalid`);if(s.renderId&&n.item.renderId!==s.renderId||s.version&&n.item.version!==s.version)throw new El(`stale`);return n.item}finally{c.dispose()}}));return{text:c.map(e=>e.text).join(``),args:c.map(e=>e.args).join(``)}}}async read(e,t){this.reads>=wl&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new El(`stale`);let n=await this.client.workbenchRead(e,t);if(this.closed||t.aborted)throw new El(`stale`);if(n.kind===`error`)throw new El(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}},Ol=2e4;async function kl(e,t,n,r){let i=hr([t],Ol);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Al(e,t){if(t===`none`)return`Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.`;switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function jl(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function Ml(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function Nl(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Pl(e){let t={commandId:crypto.randomUUID(),conversationId:Ye(e.id),head:e.head===null?null:an(e.head)},n=e.location?Xe(e.location):void 0;if(n&&n.id!==t.conversationId)throw new T(`stale`);let r=O(e.text,cn,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:A(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:A(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Fl(e.model))}:{}})}function Fl(e){return le({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Il(e,t){return Object.freeze({...e,model:Object.freeze(Fl(t))})}function Ll(e,t){if(e.model&&B(e.model)!==B(Fl(t)))throw new T(`stale`)}function Rl(e,t){return Object.freeze({...e,preparedEpoch:L(t)})}function zl(e,t,n){return Object.freeze({...Il(e,t),installModel:!n})}function Bl(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function Vl(e,t){return!!e&&e===t}async function Hl(e,t,n,r){if(!r())throw new T(`stale`);if(!t.installModel||!t.model)return n;if(!nt(n.entries,t.model))throw new T(`unsupported-context`);if(n.selected&&B(Fl(n.selected))===B(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new T(`stale`);if(i.kind===`error`)throw new T(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new T(`stale`);if(a.kind===`error`)throw new T(a.error.code);if(!a.value.selected||B(a.value.version)!==B(i.value.version)||B(a.value.selected)!==B(i.value.selected))throw new T(`stale`);return Ll(t,a.value.selected),a.value}function Ul(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&B(e.location)!==B(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new T(`stale`);let n=bn(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new T(`invalid`);return n}function Wl(e,t,...n){let r=`cadence:draft:${e}:${t}`;try{let e=e=>[e,`${e}:pending`,`${e}:mode`].some(e=>sessionStorage.getItem(e)!==null);if(e(r))return r;for(let r of n){if(!r)continue;let n=`cadence:draft:${r}:${t}`;if(e(n))return n}}catch{}return r}function Gl(e,t,n,r,i=null){let a=(0,h.useMemo)(()=>({client:e,id:t,initialLeaf:i}),[e,t,i]),o=r?.epoch??null,s=r?.attachmentVersion??null,c=(0,h.useMemo)(()=>n&&o!==null&&s!==null?{epoch:o,attachmentVersion:s}:null,[n,o,s]),l=(0,h.useRef)(a);l.current=a;let[u,d]=(0,h.useState)();(0,h.useEffect)(()=>{let n=new Dl(e,t,()=>{l.current===a&&d({scope:a,reader:n,view:n.view()})});return n.choose(i),d({scope:a,reader:n,view:n.view()}),()=>n.close()},[e,t,i,a]);let f=u?.scope===a?u:void 0,p=f?.reader,m=f?.view;return(0,h.useLayoutEffect)(()=>{p?.setActive(n,c)},[p,n,c]),{...m??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},observation:m?.observation===c?c:null,refresh:p?.refresh??Kl,loadEarlier:p?.loadEarlier??Kl,showFrom:p?.showFrom??Kl,choose:p?.choose??Kl}}function Kl(){}function ql(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`preparing`?r:void 0,[s,c]=(0,h.useState)(0),l=(0,h.useRef)(0),u=(0,h.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,preview:o}),[e,i,a,n,o]),d=(0,h.useRef)(null),f=(0,h.useMemo)(()=>({...u,revision:s,reload:d.current===u}),[u,s]),p=(0,h.useRef)(f);p.current=f;let m=(0,h.useRef)(!0);(0,h.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let g=(0,h.useCallback)(()=>m.current&&(f.epoch!==null||!!f.preview)&&p.current===f&&l.current===f.revision,[f]),[_,v]=(0,h.useState)();(0,h.useEffect)(()=>{if(f.epoch===null&&!f.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&g();return f.preview?(f.preview(t.signal).then(e=>{n()&&v({scope:f,preview:e})}).catch(e=>{n()&&v({scope:f,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal,f.reload).then(e=>{n()&&(e.kind===`error`?v({scope:f,error:e.error.code}):e.value.version.epoch===f.epoch?v({scope:f,catalog:e.value}):v({scope:f,error:`stale`}))}).catch(()=>{n()&&v({scope:f,error:`unavailable`})}),()=>t.abort())},[e,f,g]);let y=_?.scope===f&&g()?_:void 0;return{catalog:y?.catalog,preview:y?.preview,error:y?.error,loading:(i!==null||!!o)&&!y,isCurrent:g,reread(e=!1){g()&&(d.current=e?u:null,c(++l.current))},accept(e){return!g()||e.version.epoch!==f.epoch?!1:(v({scope:f,catalog:e}),!0)}}}function Jl(e,t,n,r=!1){return t?r||!n||B(n)!==B(e.model)?`validate`:`approve`:`restore`}async function Yl(e){let t=structuredClone(e.state),n=t.proposal,r=structuredClone(e.context),i={id:r.id,cwd:r.cwd},a=structuredClone(e.model),o=e.head,s=crypto.randomUUID(),c=()=>!e.signal.aborted&&e.current();if(!n||!t.enabled||r.id!==t.id||!c()||(e.prepare&&await kl(e.prepare,e.signal,i,e.progress??(()=>{})),!c()))throw Error(`stale`);let l=await e.client.models(e.signal,i);if(!c())throw Error(`stale`);if(l.kind!==`ok`)throw Error(l.error.code);let u=await e.client.workbenchCommand({kind:`cadence-revalidate`,commandId:s,conversationId:t.id,revision:t.revision,proposalId:n.id,digest:n.digest,head:o,context:r,model:a,expected:l.value.version});if(!c())throw Error(`stale`);if(u.kind!==`ok`)throw Error(u.error.code);if(u.value.kind!==`cadence-revalidated`||u.value.state.id!==t.id||u.value.state.revision!==t.revision+1||!u.value.state.enabled||u.value.state.head!==t.head||B(u.value.state.runs)!==B(t.runs)||u.value.state.proposal?.id!==s||u.value.state.proposal.revalidatedFrom!==n.id||u.value.state.proposal.epoch!==l.value.version.epoch||u.value.state.proposal.cwd!==r.cwd||B(u.value.state.proposal.model.conversation??null)!==B(i)||B(u.value.state.proposal.plan)!==B(n.plan))throw Error(`stale`);return u.value.state}async function Xl(e){let t=e.state.proposal;if(!t||!e.state.enabled||!e.current())throw Error(`stale`);let n={conversationId:e.state.id,revision:e.state.revision,proposalId:t.id,digest:t.digest},r=await e.client.workbenchCommand({kind:`cadence-prepare`,commandId:crypto.randomUUID(),...n});if(r.kind!==`ok`)throw Error(r.error.code);if(r.value.kind!==`cadence-grant`||!e.current()||r.value.revision!==e.state.revision||B(r.value.proposal)!==B(t)||Date.now()>=r.value.expiresAt)throw Error(`stale`);let i=crypto.randomUUID();return e.submitting(i),e.client.workbenchCommand({kind:`cadence-approve`,commandId:i,...n,grant:r.value.grant})}function Zl(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Ql(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var $l=e=>`cadence:prompt-history:${e}`;function eu(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function tu(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function nu(e){try{let t=sessionStorage.getItem($l(e));return t?eu(JSON.parse(t)):[]}catch{return[]}}function ru(e,t){let n=t;for(;n;)try{sessionStorage.setItem($l(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function iu(e,t){let n=nu(e),r=tu(n,t);r!==n&&ru(e,r)}var au={index:-1,draft:``};function ou(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:au,text:t.draft}}function su({known:e,active:t,armed:n}){return e?t?`on`:n?`armed`:`off`:`unknown`}var cu={unknown:`Cadence state unavailable`,on:`Cadence on`,armed:`Cadence on next Send`,off:`Cadence off`},lu={unknown:cu.unknown,on:`Cadence mode is on. Click to exit it.`,armed:`Your next message turns on Cadence mode. Click to cancel.`,off:`Turn on Cadence mode: agree on a plan before implementation.`},uu={unknown:cu.unknown,on:`Cadence stays on. Confirm one plan before implementation.`,armed:`Your next message turns on Cadence mode.`,off:null};function du({disabled:e,onClick:t,...n}){let{t:r}=X(),i=su(n),a=r(cu[i]);return(0,Y.jsxs)(`button`,{type:`button`,className:`mode-toggle ${i}`,"aria-label":a,disabled:e||i===`unknown`,title:r(lu[i]),onClick:t,children:[(0,Y.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),a]})}function fu(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function pu(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!fu(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function mu(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var hu=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function gu(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function _u(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function vu(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var yu=``;function bu(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function xu(e,t){return{first:!e.slice(0,t).includes(`
|
|
6
|
+
`)}\n\n## Setup (explicitly authorized commands)\nExecution order: target once before worktree creation, candidate once, then worktree in the candidate and every detached child; listed order within each stage. Each command is a separate process; exports do not persist.\n${e.setup.map(e=>`[${e.placement??`worktree`}] ${Lt(e)}`).join(`
|
|
7
|
+
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(Lt).join(`
|
|
8
|
+
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(Lt).join(`
|
|
9
|
+
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(Rt).join(`
|
|
10
|
+
`)}`:``}\n\n## Automation boundary\n${zt(e)} Only actual verification and independent Agent review permit delivery. ${e.delivery===`local-merge`?`Authorize one new named task branch and stable isolated worktree after approval, temporary worktrees beside it for assignments that run side by side, local commits and serialized fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Independent conversations may implement in separate candidates; a verified non-overlapping sibling delivery may be merged into this candidate and checked/reviewed again. Conflicts, changed instructions, overlapping inputs or external target drift retain the candidate for a fresh plan. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project documents\n${e.version===void 0?e.projectContext:t.join(`
|
|
11
|
+
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var Vt=e=>A(e,0,864e13);function Ht(e){let t=F(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,...Object.hasOwn(e??{},`timeoutMs`)?[`timeoutMs`]:[],`stopReason`]);return{createdAt:Vt(t.createdAt),preparedAt:P(t.preparedAt,Vt),startedAt:P(t.startedAt,Vt),stopRequestedAt:P(t.stopRequestedAt,Vt),closedAt:P(t.closedAt,Vt),settledAt:P(t.settledAt,Vt),...t.timeoutMs===void 0?{}:{timeoutMs:A(t.timeoutMs,100,2147483647)},stopReason:P(t.stopReason,e=>O(e,320,!0))}}function Ut(e){let t=F(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=F(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Vt(t.acceptedAt),acquiredAt:P(t.acquiredAt,Vt),settledAt:P(t.settledAt,Vt),owner:{version:O(n.version,128,!0),build:O(n.build,64,!0),entry:O(n.entry,4096,!0),pid:A(n.pid,1),node:O(n.node,128,!0),platform:O(n.platform,32,!0),startedAt:Vt(n.startedAt)}}}function Wt(e){let t=e.diagnostics;if(!t)return`Owner timing/runtime observations not recorded.`;let n=e=>e===null?`not observed`:new Date(e).toISOString();return[`Owner: Cadence ${t.owner.version} · ${t.owner.platform} · Node ${t.owner.node} · PID ${t.owner.pid} · epoch ${e.epoch}`,`Build: ${t.owner.build} · entry: ${t.owner.entry} · owner started: ${n(t.owner.startedAt)}`,`Accepted: ${n(t.acceptedAt)} · checkout acquired: ${n(t.acquiredAt)} · settled: ${n(t.settledAt)}`,`Checkout wait: ${t.acquiredAt===null?`still waiting or not acquired`:`${Math.max(0,t.acquiredAt-t.acceptedAt)}ms`}. Readonly research shares access; isolated implementation holds no target checkout permit. Direct edits and final delivery are exclusive.`,...e.steps.flatMap(e=>e.timing?[`${e.id}: preparing ${n(e.timing.createdAt)} · prepared ${n(e.timing.preparedAt)} · spawned ${n(e.timing.startedAt)} · stop ${n(e.timing.stopRequestedAt)} (${e.timing.stopReason??`none`}) · direct child closed ${n(e.timing.closedAt)} · settled ${n(e.timing.settledAt)} · ${e.timing.timeoutMs===void 0?`no total runtime deadline`:`historical process budget ${e.timing.timeoutMs}ms`}${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
|
|
12
|
+
`)}var Gt=e=>O(e,1024,!0),Kt=(e,t=`id`)=>{let n=lt(t,e,48,!0);return/^[a-z][a-z0-9-]*$/u.test(n)?n:Y(t,`start with a lowercase letter; use lowercase letters, digits and hyphens`)};function qt(e,t){let{questions:n}=dt(`design`,e,[`questions`]),r=new Map,i=ut(`questions`,n,12,(e,n)=>{let i=dt(n,e,[`id`,`question`,`options`,`recommended`,`reason`,`acceptance`],[`when`]),a=Kt(i.id,`${n}.id`);if(r.has(a))return Y(`${n}.id`,`use a distinct question ID`);let o=new Set,s=ut(`${n}.options`,i.options,6,(e,t)=>{let n=dt(t,e,[`id`,`label`,`cost`]),r=Kt(n.id,`${t}.id`);return o.has(r)?Y(`${t}.id`,`use a distinct option ID`):(o.add(r),{id:r,label:lt(`${t}.label`,n.label,1024,!0),cost:lt(`${t}.cost`,n.cost,1024,!0)})});if(s.length<2)return Y(`${n}.options`,`supply at least two alternatives`);let c=Kt(i.recommended,`${n}.recommended`);if(!o.has(c))return Y(`${n}.recommended`,`name an option ID of this question`);let l;if(i.when!==void 0&&(t!==`tool`||i.when!==null)){let e=dt(`${n}.when`,i.when,[`question`,`option`]);if(t!==`tool`||e.question!==``||e.option!==``){let t=Kt(e.question,`${n}.when.question`);if(!r.has(t))return Y(`${n}.when.question`,`name an earlier question, or omit when for an independent question`);let i=Kt(e.option,`${n}.when.option`);if(!r.get(t)?.has(i))return Y(`${n}.when.option`,`name an option ID of the earlier question`);l={question:t,option:i}}}return r.set(a,o),{id:a,question:lt(`${n}.question`,i.question,1024,!0),options:s,recommended:c,reason:lt(`${n}.reason`,i.reason,1024,!0),acceptance:lt(`${n}.acceptance`,i.acceptance,1024,!0),...l?{when:l}:{}}});if(!i.length)throw Error(`questions: supply a material product decision`);try{H(i,24576)}catch(e){if(!(e instanceof T)||e.code!==`oversize`)throw e;return Y(`questions`,`the complete batch must fit in 24 KiB of encoded JSON`)}return i}function Jt(e){return I(e,12,e=>{let t=Object.hasOwn(e??{},`other`),n=F(e,[`question`,t?`other`:`option`]),r=Kt(n.question);return t?{question:r,other:Gt(n.other)}:{question:r,option:Kt(n.option)}})}function Yt(e,t){let n=e.when;return!n||t.some(e=>e.question===n.question&&`option`in e&&e.option===n.option)}function Xt(e,t,n=!1){let r=[],i=new Map(t.map(e=>[e.question,e]));if(i.size!==t.length||t.some(t=>!e.some(e=>e.id===t.question)))throw new T(`invalid`);for(let t of e){if(!Yt(t,r))continue;let e=i.get(t.id);if(e&&`option`in e&&!t.options.some(t=>t.id===e.option))throw new T(`invalid`);e?r.push(e):n&&r.push({question:t.id,option:t.recommended})}return r}function Zt(e){let t=F(e,[`id`,`revision`,`questions`,`answers`,`submitted`]),n=qt({questions:t.questions},`record`),r=j(t.submitted),i=Jt(t.answers);if(H(Xt(n,i,r))!==H(i))throw new T(`invalid`);return{id:L(t.id),revision:A(t.revision,1),questions:n,answers:i,submitted:r}}function Qt(e,t){return t&&(`other`in t?t.other:e.options.find(e=>e.id===t.option)?.label)}function $t(e){return e.questions.filter(t=>Yt(t,e.answers)).map(t=>`- ${t.question} — ${Qt(t,e.answers.find(e=>e.question===t.id))??`…`}\n Acceptance: ${t.acceptance}`).join(`
|
|
13
|
+
`)}function en(e,t){let n=$t(e);return new TextEncoder().encode(n).length<=t?n:`Submit design ${e.id}, revision ${e.revision}. Read the confirmed decisions in cadence_status and publish the implementation plan.`}function tn(e,t,n){return{...e,revision:e.revision+1,answers:Xt(e.questions,t,n),submitted:n}}var nn=`x-cadence-project-association`;function rn(e){return e==null?`unknown`:M(e,[`associated`,`unassociated`])}function an(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=F(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[],...Object.hasOwn(e??{},`design`)?[`design`]:[]]);return{id:Ye(n.id),revision:A(n.revision,0),enabled:j(n.enabled),head:P(n.head,L),proposal:P(n.proposal,Nt),runs:I(n.runs,200,L),...n.design===void 0?{}:{design:Zt(n.design)},...t?{notice:O(n.notice,1024,!0)}:{}}}function on(e){let t=O(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new T(`invalid`);return t}function sn(e){if(Object.hasOwn(e??{},`checkout`)){let{checkout:t}=F(e,[`checkout`]);return{checkout:R.checkout(t)}}if(Object.hasOwn(e??{},`investigation`))return{investigation:R.investigation(F(e,[`investigation`]).investigation)};if(Object.hasOwn(e??{},`match`)){let t=F(e,[`path`,`match`]);return{path:R.path(t.path),match:R.match(t.match)}}let t=F(e,[`path`,...Object.hasOwn(e??{},`section`)?[`section`]:[]]);return{path:R.path(t.path),...t.section===void 0?{}:{section:R.section(t.section)}}}var cn=196608,ln=16384,un=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`],dn=[`starting`,...un],fn=1e3,pn=16384,mn=1024;function hn(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function gn(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
|
|
14
|
+
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function _n(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:hn(e.text,pn);return{id:e.id,...Dn(e),role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?hn(gn(e.args),mn):``,error:e.error,parts:t}}function vn(e){let t=F(e,[`id`,`updatedAt`]);return{id:Ye(t.id),updatedAt:A(t.updatedAt,0)}}function yn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`project-knowledge`:return{kind:t,source:sn(F(e,[`kind`,`source`]).source)};case`conversation-context`:case`reload-conversation-models`:case`conversation-models`:return{kind:t,location:Xe(F(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=F(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,on),ordinal:A(n.ordinal,0),before:P(n.before,e=>A(e,0))}}case`conversation-image`:{let n=F(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=A(n.offset,0);if(r%_.chunkChars||n.live!==void 0&&n.live!==!0)throw new T(`invalid`);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,on),...n.live===void 0?{}:{live:!0},entry:on(n.entry),index:A(n.index,0),offset:r}}case`conversation-step`:{let n=F(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,on),turnId:on(n.turnId),step:A(n.step,0),part:A(n.part,0)}}case`cadence-conversation`:return{kind:t,id:Ye(F(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=F(e,[`kind`,`id`,`leaf`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,on)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=F(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:P(r.after,L),...n?{scan:L(r.scan)}:{}}}case`workflow-active`:return F(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=F(e,[`kind`,`id`,`stepId`]);return{kind:t,id:L(n.id),stepId:O(n.stepId,160,!0)}}case`workflow`:{let n=F(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:L(n.id),...n.before===void 0?{}:{before:A(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=F(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new T(`invalid`);return{kind:t,...n?{after:P(i.after,vn)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return F(e,[`kind`]),{kind:t};case`conversation`:{let n=F(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:Ye(n.id),leaf:P(n.leaf,on),known:P(n.known,on)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=F(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=A(r.offset,0);if(i%196608||i>=67108864)throw new T(`invalid`);return{kind:t,path:O(r.path,4096),offset:i,...n?{location:Xe(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=F(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:M(r.kind,[`files`,`file`,`directories`]),path:O(r.path,4096),...n?{location:Xe(r.location)}:{}}}}}function bn(e){let t=O(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new T(`invalid`);if([...t].length>100)throw new T(`oversize`);return t}function xn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=F(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:L(n.commandId),location:Xe(n.location),expected:q(n.expected),choice:ce(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=F(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new T(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:L(n.commandId),epoch:L(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:Xe(n.location)},...r?{expected:q(n.expected),choice:ce(n.choice)}:{}}:{kind:t,...i,runId:L(n.runId)}}if(t===`cadence-exit`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:Xe(n.location)},commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,on),revision:A(n.revision,0)}}if(t===`image-upload`){let n=F(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new T(`invalid`);let r=xn(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new T(`invalid`);return{kind:t,commandId:L(n.commandId),imageId:L(n.imageId),send:r,mimeType:M(n.mimeType,v),size:A(n.size,1),offset:A(n.offset,0),data:O(n.data,_.chunkChars,!0)}}if(t===`cadence-send`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,on),text:O(n.text,ln),...n.images===void 0?{}:{images:I(n.images,2**53-1,L)},model:q(n.model),revision:A(n.revision,0),intent:M(n.intent,[`message`,`enter`,`exit`,`design`])}}if(t===`cadence-design-edit`){let n=F(e,[`kind`,`commandId`,`conversationId`,`revision`,`designId`,`answers`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),revision:A(n.revision,0),designId:L(n.designId),answers:Jt(n.answers)}}if(t===`cadence-revalidate`){let n=F(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=Ye(n.conversationId),i=Ze(n.context);if(i.id!==r)throw new T(`invalid`);return{kind:t,commandId:L(n.commandId),conversationId:r,revision:A(n.revision,0),proposalId:L(n.proposalId),digest:z(n.digest),head:P(n.head,on),context:i,expected:q(n.expected),model:ce(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=F(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:L(r.commandId),conversationId:Ye(r.conversationId),revision:A(r.revision,0),proposalId:L(r.proposalId),digest:z(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:L(r.grant)}}if(t===`workflow`){let n=F(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:L(n.commandId),epoch:L(n.epoch),request:Pt(n.request)}}if(t===`send`){let n=F(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),head:P(n.head,on),text:O(n.text,ln),...n.images===void 0?{}:{images:I(n.images,2**53-1,L)},model:q(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=F(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:L(n.commandId),conversationId:Ye(n.conversationId),turnId:L(n.turnId),epoch:L(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:M(n.mode,[`steer`,`queue`]),text:O(n.text,ln,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:L(n.inputId)}}if(t===`conversation-rename`){let n=F(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),name:bn(n.name)}}if(t===`conversation-archive`){let n=F(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:L(n.commandId),conversationId:Ye(n.conversationId),archived:j(n.archived)}}let n=F(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:M(n.kind,[`open-project`]),commandId:L(n.commandId),path:O(n.path,4096,!0),epoch:L(n.epoch)}}function Sn(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=F(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?F(i.transcript,[`pages`]):null,o=n?F(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:Qe(i.execution)},...i.retry===void 0?{}:{retry:Ie(i.retry)},id:L(i.id),epoch:L(i.epoch),status:M(i.status,un),notice:O(i.notice,1024),...a?{transcript:{pages:A(a.pages,0)}}:{},omitted:{thinking:o?j(o.thinking):!1,media:o?j(o.media):!1,other:o?j(o.other):!1},items:I(i.items,256,An)}}var Cn=[`user`,`assistant`,`tool`,`thinking`];function wn(e){return I(e,2**53-1,e=>{let t=F(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new T(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:on(t.entry),index:A(t.index,0),mimeType:M(t.mimeType,v)}})}var Tn=[`renderId`,`version`,`state`];function En(e){return Tn.filter(t=>Object.hasOwn(e??{},t))}function Dn(e){return{...e.renderId===void 0?{}:{renderId:e.renderId},...e.version===void 0?{}:{version:e.version},...e.state===void 0?{}:{state:e.state}}}function On(e){return{...e.renderId===void 0?{}:{renderId:O(e.renderId,160,!0)},...e.version===void 0?{}:{version:z(e.version)},...e.state===void 0?{}:{state:M(e.state,[`pending`,`streaming`,`running`,`completed`,`failed`,`canceled`,`unavailable`])}}}function kn(e){let t=F(e,[`kind`,`sequence`,...Object.hasOwn(e??{},`name`)?[`name`]:[]]),n=M(t.kind,[`waiting`,`thinking`,`text`,`tool`]);if(t.name!==void 0&&n!==`tool`)throw new T(`invalid`);return{kind:n,sequence:A(t.sequence,0),...t.name===void 0?{}:{name:O(t.name,128)}}}function An(e){let t=F(e,[...En(e),`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...On(t),...t.images===void 0?{}:{images:wn(t.images)},id:O(t.id,160,!0),role:M(t.role,Cn),text:O(t.text,262144),name:O(t.name,128),args:O(t.args,65536),error:j(t.error)}}function jn(e){let t=F(e,[...En(e),`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...On(t),...t.images===void 0?{}:{images:wn(t.images)},id:O(t.id,160,!0),role:M(t.role,Cn),text:O(t.text,pn),clipped:j(t.clipped),name:O(t.name,128),target:O(t.target,mn),error:j(t.error),parts:A(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&(!n.parts&&!(n.renderId&&[`streaming`,`completed`,`unavailable`,`canceled`,`failed`].includes(n.state??``))||n.parts&&n.state!==void 0&&n.state!==`completed`))throw new T(`invalid`);return n}function Mn(e){let t=F(e,[...Object.hasOwn(e??{},`activity`)?[`activity`]:[],`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=F(t.omitted,[`thinking`,`media`,`other`]),r=A(t.steps,0);return{...t.activity===void 0?{}:{activity:kn(t.activity)},...t.execution===void 0?{}:{execution:Qe(t.execution)},...t.retry===void 0?{}:{retry:Ie(t.retry)},id:on(t.id),entry:P(t.entry,on),...t.parent===void 0?{}:{parent:P(t.parent,on)},at:A(t.at,0),status:M(t.status,dn),notice:O(t.notice,1024),omitted:{thinking:j(n.thinking),media:j(n.media),other:j(n.other)},steps:r,stable:A(t.stable,0,r)}}function Nn(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=F(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?F(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new T(`invalid`);return{id:Ye(n.id),title:O(n.title,512,!0),leaf:P(n.leaf,on),status:M(n.status,dn),updatedAt:A(n.updatedAt,0),origin:M(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:j(n.cadence)}:{},...r?{live:{commandId:L(r.commandId),epoch:L(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function Pn(e){let t=F(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:L(t.commandId),text:O(t.text,16384),status:M(t.status,dn),notice:O(t.notice,1024)}}function Fn(e){let t=F(e,[`commandId`,`mode`,`text`]);return{commandId:L(t.commandId),mode:M(t.mode,[`steer`,`queue`]),text:O(t.text,256)}}function In(e){let t=F(e,[`tokens`,`provider`,`model`]);return{tokens:P(t.tokens,e=>A(e,1)),provider:O(t.provider,128),model:O(t.model,256)}}function Ln(e){let t=F(e,[`input`,`read`,`write`]);return{input:A(t.input,0),read:A(t.read,0),write:A(t.write,0)}}function Rn(e){let t=F(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:on(t.id),parent:P(t.parent,on),text:O(t.text,1024),at:A(t.at,0),leaf:on(t.leaf),current:j(t.current)}}function zn(e){H(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=F(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:L(n.commandId),imageId:L(n.imageId),offset:A(n.offset,0)}}if(t===`conversation-image`){let n=F(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:M(n.mimeType,v),data:O(n.data,_.chunkChars,!0),next:P(n.next,e=>A(e,0))}}if(t===`conversation-context`)return{kind:t,context:Ze(F(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:it(F(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=F(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:L(n.commandId),choice:$e(n.choice)}}if(t===`workflow-transcript`){let n=F(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:L(n.runId),stepId:O(n.stepId,160,!0),turn:P(n.turn,Sn)}}if(t===`cadence-conversation`)return{kind:t,state:an(F(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=F(e,[`kind`,`after`,`scan`]);return{kind:t,after:P(n.after,L),scan:L(n.scan)}}if(t===`workflow-history`){let n=F(e,[`kind`,`entries`,`next`]),r=I(n.entries,J.historyPage,e=>{let t=F(e,[`id`,`run`]),n=L(t.id),r=P(t.run,Ft);if(r&&r.id!==n)throw new T(`invalid`);return{id:n,run:r}}),i=P(n.next,L);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new T(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=F(e,[`kind`,`runs`,...n?[`links`]:[]]),i=I(r.runs,4,Ft),a=n?I(r.links,4,e=>{let t=F(e,[`runId`,`conversationId`]);return{runId:L(t.runId),conversationId:Ye(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new T(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-revalidated`){let n=F(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:L(n.commandId),state:an(n.state)}}if(t===`cadence-grant`){let n=F(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:L(n.commandId),grant:L(n.grant),expiresAt:A(n.expiresAt,0),revision:A(n.revision,0),proposal:Nt(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=F(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:P(t.commandId,L),response:It(t.response)}}if(n===`conversation-active`)return{kind:n,entries:I(F(e,[`kind`,`entries`]).entries,8,Nn)};if(n===`conversations`){let t=F(e,[`kind`,`entries`,`next`]);return{kind:n,entries:I(t.entries,200,Nn),next:P(t.next,vn)}}if(n===`conversation`){let t=F(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`cache`)?[`cache`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=P(t.summary,Nn),i=A(t.turns,0);if(!r&&i)throw new T(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:I(t.commands,64,L)},...t.context===void 0?{}:{context:In(t.context)},...t.cache===void 0?{}:{cache:Ln(t.cache)},...t.pending===void 0?{}:{pending:I(t.pending,8,Fn)},...t.undelivered===void 0?{}:{undelivered:I(t.undelivered,8,Pn)},summary:r,leaf:P(t.leaf,on),continues:j(t.continues),turns:i,branches:A(t.branches,0),runs:I(t.runs,200,L),attempt:P(t.attempt,Pn)}}if(n===`conversation-tree`){let t=F(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:Ye(t.conversationId),nodes:I(t.nodes,fn,Rn),truncated:j(t.truncated)}}if(n===`conversation-turn`){let t=F(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Mn(t.turn),i=A(t.start,0),a=I(t.steps,24,jn);if(i+a.length>r.steps)throw new T(`invalid`);return{kind:n,conversationId:Ye(t.conversationId),leaf:P(t.leaf,on),ordinal:A(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=F(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:Ye(t.conversationId),leaf:P(t.leaf,on),turnId:on(t.turnId),step:A(t.step,0),part:A(t.part,0),item:An(t.item)}}if(n===`files`||n===`directories`){let t=F(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:O(t.path,4096),parent:P(t.parent,e=>O(e,4096)),limited:j(t.limited),entries:I(t.entries,200,e=>{let t=F(e,[`name`,`path`,`directory`]);return{name:O(t.name,1024,!0),path:O(t.path,4096,!0),directory:j(t.directory)}})}}if(n===`file`){let t=F(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:O(t.path,4096),text:O(t.text,262144),limited:j(t.limited)}}if(n===`file-part`){let t=F(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=A(t.size,0),i=O(t.data,cn/3*4),a=P(t.next,e=>A(e,1)),o=O(t.version,32,!0);if(r>67108864||!/^[a-f0-9]{32}$/.test(o)||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)||a!==null&&(a%196608!=0||a>=r))throw new T(`invalid`);return{kind:n,path:O(t.path,4096),size:r,version:o,data:i,next:a}}if(n===`projects`)return{kind:n,entries:I(F(e,[`kind`,`entries`]).entries,128,e=>{let t=F(e,[`path`,`current`]);return{path:O(t.path,4096,!0),current:j(t.current)}})};if(n===`accepted`)return{kind:n,commandId:L(F(e,[`kind`,`commandId`]).commandId)};let r=F(e,[`kind`,`commandId`,`path`,`link`]);return{kind:M(r.kind,[`project`]),commandId:L(r.commandId),path:O(r.path,4096,!0),link:O(r.link,8192,!0)}}function Bn(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?Ye(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Vn(e=typeof window>`u`?``:window.location.search){return Bn(e,``).project}function Hn(e=typeof window>`u`?``:window.location.hash){return Bn(``,e).chat}var Un=`cadence:login-return`;function Wn(e){let{chat:t}=Bn(``,e);if(!t)return null;let{leaf:n,selected:r}=Jn(e,t);return Yn(`#chat=${t}${r?`&activity=1`:``}`,n)}function Gn(){try{let e=Wn(location.hash);sessionStorage.removeItem(Un),e&&location.pathname===`/app`&&(!location.search||/^\?project=[a-f0-9]{64}$/.test(location.search))&&sessionStorage.setItem(Un,JSON.stringify([location.search,e]))}catch{}}function Kn(){try{let e=sessionStorage.getItem(Un);if(!e)return;sessionStorage.removeItem(Un);let[t,n]=JSON.parse(e);if(location.hash||location.pathname!==`/app`||t!==location.search||typeof n!=`string`)return;let r=Wn(n);r&&history.replaceState(history.state,``,r)}catch{}}function qn(){let e=Vn();return e?`/projects/${e}`:``}function Jn(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&Bn(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?on(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function Yn(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,on(t)),`#${n}`}function Xn(e,t){if(typeof window>`u`||Hn()!==e)return;let n=Yn(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}var Zn={"Design choices":`设计选项`,"Fill unanswered with recommendations":`为未回答的问题填入推荐项`,"Discard typed answer":`放弃未采用的回答`,"Choose answers":`选择答案`,"Review choices":`查看或修改选择`,"{answered} of {total} questions answered":`已回答 {answered} / {total} 个问题`,"Submitting answers requests a plan, not implementation.":`提交后将根据你的选择生成实施计划,不会开始实施。`,"Plan identity":`计划标识`,Questions:`问题`,Recommended:`推荐`,Acceptance:`验收`,"Other idea":`其他想法`,"Use this answer":`采用这项回答`,"Design submitted":`设计已提交`,"Submit design and use recommendations for unanswered questions":`整批提交,未回答的问题采用推荐项`,"Thinking activity observed":`已观察到思考活动`,"Thinking activity ended":`思考活动已结束`,"Thinking content unavailable":`思考内容不可用`,"Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.":`不传输思考正文;可读取的思考内容落盘后可展开查看。`,"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The provider said: {reason}":`供应商返回:{reason}`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"The model request failed and automatic retries did not recover it.":`模型请求失败,自动重试后仍未恢复。`,"Partial work is preserved.":`已有工作已保留。`,"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Validate the plan with this model before approving it.":`请先使用此模型重新核验计划,再确认实施。`,"Restore execution and validate plan":`恢复执行服务并核验计划`,"Validate plan again":`重新核验计划`,"Validating plan…":`正在核验计划…`,"Confirm implementation":`确认实施`,"Previous execution context":`核验前的执行上下文`,"Preparing execution and validating the plan; no implementation is approved.":`正在准备执行服务并核验计划;尚未批准任何实施。`,"Reading the validated plan…":`正在读取核验后的计划…`,"The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.":`计划内容未变,已重新核验执行上下文。请查看下方当前计划后确认实施;尚未批准任何实施。`,"Repository or execution-environment evidence changed. Review the current context before confirming.":`仓库或执行环境的核验证据已变化,请查看当前上下文后再确认。`,"Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.":`核验可能启动执行服务并应用界面中选择的模型,但不会发送聊天消息或实施计划;核验后仍需确认。`,"Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.":`计划核验未完成({code})。未批准任何实施;请读取当前计划后再决定是否重新核验。`,"Preparing execution…":`正在准备执行环境…`,"Checking execution state…":`正在确认执行状态…`,"Execution state unavailable":`执行状态暂时无法确认`,"Model list unavailable":`模型目录读取失败`,"Last used: {model}":`上次使用:{model}`,"Last used model; availability is checked when you send.":`上次使用的模型,发送时会验证其可用性。`,"Execution is being prepared for your Send. Models will load when it is ready.":`正在为本次发送准备执行环境,就绪后会加载模型。`,"The model list changed. Read the current list before choosing again.":`模型列表已变化,请读取当前列表后再选择。`,"The choice was not confirmed. Read the current model before choosing again.":`模型选择结果尚未确认,请读取当前模型后再决定是否重新选择。`,"Recorded history could not be read.":`暂时无法读取历史证据。`,"Recorded history unavailable: {reason}.":`无法读取历史记录:{reason}。`,"History workspace does not match the selected owner":`历史工作区与所选执行服务不匹配`,"History anchor does not match the selected workspace":`历史链接与所选工作区不匹配`,"History identity not confirmed":`未能确认历史工作区的身份`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Connection status: {state}":`连接状态:{state}`,"Updating state…":`正在更新状态…`,"Task up to date":`任务状态已更新`,"Execution stopped":`执行服务已停止`,"Execution not started":`执行服务尚未启动`,"Browsing only":`仅浏览`,"Last known state":`仅有上次读取的状态`,"Sign-in required":`需要重新登录`,"Sign in again":`重新登录`,"Viewer access not confirmed":`未能确认此入口可连接执行服务`,"No recent update from the task connection":`最近未收到任务实时连接的更新`,"The task connection closed":`任务实时连接已关闭`,stopped:`已停止`,"Waiting for current state from this connection.":`正在等待此连接返回最新状态。`,"This owner is running independently. Browsing history does not connect it to this workbench.":`执行服务正在独立运行。浏览历史不会将它关联到此工作台。`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Workbench observation: {code}.":`工作台入口读取:{code}。`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Observing approval request {id}; no approval is replayed.":`正在查询审批请求 {id} 的结果;不会重放审批。`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,"Context {used} / {window} · {percent}%":`上下文 {used} / {window} · {percent}%`,"Context {used} tokens":`上下文 {used} tokens`,"Context unknown after compaction":`压缩后上下文大小未知`,"Context window in use":`上下文窗口占用`,"Context size not observed yet":`尚未读取到上下文大小`,"No completed model response is within reach of this branch's end, so no context size is stated.":`这条分支末尾附近还没有完成的模型回复,因此没有上下文大小。`,"Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).":`网络延迟:{ms}ms(最近一分钟内到服务最快的一次请求,从发出到收到回复首字节)。`,"Cache hit":`缓存命中`,"Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)":`缓存命中:{rate} · 缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,"Summed over every usage record of this session, on every branch.":`按本会话全部用量记录累计,包含所有分支。`,"Cache hit: this session's usage records state no input tokens yet.":`缓存命中:本会话的用量记录里还没有输入 token。`,"Context size as of the last completed model response ({model}). Messages after that response are not counted.":`上下文大小以最近一次完成的模型回复({model})为准,不包含那次回复之后的消息。`,"A compaction followed that response, so the size is unknown until the next one.":`那次回复之后做过压缩,下一次模型回复完成前无法得知大小。`,"The model list states no context window for this model, so no percentage is shown.":`模型列表没有给出这个模型的上下文窗口,因此不显示占比。`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files appear once this folder has been observed.":`读取到该目录的状态后即可浏览文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Active Pi work":`Pi 活动工作`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not executed":`未执行`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder":`选择工作文件夹`,"Choose a working folder to start. You can write a draft below.":`选择工作文件夹即可开始,也可以先在下方写草稿。`,"Write a message. Choose a folder before sending…":`输入消息,发送前请选择文件夹…`,"Choose a folder before sending.":`发送前请选择文件夹。`,"Returning to your last folder {path}…":`正在返回上次的文件夹 {path}…`,"Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.":`选择服务所在主机上的文件夹。会话保留在原文件夹中,运行中的工作不受影响;仅在发送消息时按需启动执行服务。`,"Connecting…":`正在连接…`,"Ready to prepare execution":`可按需准备执行服务`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.":`执行服务准备被拒绝,未产生任何变更({code})。本次未启动执行服务;消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Conversation context: {code}.":`对话上下文:{code}。`,"Conversation read: {code}.":`对话读取:{code}。`,"Project directories: {code}.":`项目目录:{code}。`,"Conversation activity: {code}.":`活跃对话:{code}。`,"Workflow activity: {code}.":`活跃工作流:{code}。`,"Recorded workflows: {code}.":`已记录的工作流:{code}。`,"Workflow observation: {code}.":`工作流观察:{code}。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.":`批准覆盖本目标及其决定、验收标准和假设。之后由服务自行完成:它可以在仓库内调整路线和写入范围;对验收的任何偏离都会记录下来,交给自动审查确认,并在最终报告中置顶。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Waiting messages":`等待中的消息`,"Steering: read at the model's next step":`插队:模型下一步就会读到`,"Queued: sent when this reply ends":`排队:这条回复结束后发送`,Withdraw:`撤回`,"Withdraw and put back in the message box":`撤回并放回输入框`,"Not delivered.":`未送达。`,"Not delivered: the reply ended before this message reached the model. Nothing was replayed; send it again.":`未送达:回复在这条消息到达模型之前就结束了。没有任何内容被重放;需要的话请重新发送。`,"Not observed: the session could not be read when the reply ended, so whether this message was delivered was not recorded. Nothing was replayed.":`未观察到:回复结束时会话无法读取,因此没有记录这条消息是否送达。没有任何内容被重放。`,"Put back in the message box":`放回输入框`,"Queue behind this reply":`排在这条回复之后`,"Queue: sent when this reply ends (Alt+Enter)":`排队:这条回复结束后发送(Alt+Enter)`,"Steer this reply":`插队到这条回复`,"Steer: read at the model's next step (Enter)":`插队:模型下一步就会读到(Enter)`,"Enter steers this reply · Alt+Enter queues behind it":`Enter 插队 · Alt+Enter 排队`,"The running reply did not take the message ({reason}). Your text stays here.":`进行中的回复没有接收这条消息({reason})。你的文字仍在输入框里。`,"That message has already been handed to the model and can no longer be withdrawn.":`这条消息已经交给模型,无法再撤回。`,"The message was not withdrawn ({reason}).":`消息没有撤回({reason})。`,"A message into a running reply carries no images. Remove them, or send after the reply ends.":`发给进行中回复的消息不能带图片。请移除图片,或等回复结束后再发送。`,"Cadence mode is not changed by a message into a running reply. Send this after the reply ends.":`发给进行中回复的消息不会切换 Cadence 模式。请等回复结束后再发送。`,"Eight messages already wait for this reply. Withdraw one, or wait.":`已有 8 条消息在等这条回复。请撤回一条,或稍等。`,"A message into a running reply continues that reply, not another entry.":`发给进行中回复的消息只能接在这条回复上,不能接到别的位置。`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Download file {path}":`下载文件 {path}`,"Reference path only: {path} (the agent reads it on demand)":`仅引用路径 {path}(AI 按需读取)`,"Link folder path {path} to the chat":`链接文件夹路径 {path} 到对话`,"Copy name {path}":`复制名称 {path}`,"Copy path {path}":`复制路径 {path}`,"Download of {path} failed: {error}":`{path} 下载失败:{error}`,"the file is larger than the 64 MiB download limit":`文件超过 64 MiB 的下载上限`,"No visible files":`没有可显示的文件`,"Close preview":`关闭预览`,"Bounded listing; narrow the directory to see more.":`列表已达到显示上限,请进入更具体的目录查看。`,"File preview is limited; this is not the complete file.":`文件预览已截断,并非完整内容。`,"Readonly preview · references send paths, not file contents · a download is the file's own bytes, unredacted":`只读预览 · 引用只发送路径,不自动注入文件内容 · 下载的是文件原始字节,不做脱敏`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking that could not be read is not shown.":`无法读取的思考内容不显示。`,"Show thinking":`展开思考内容`,"Thinking still being recorded":`思考内容仍在记录中`,"No thinking text is recorded for this block.":`这段思考没有记录文本。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"The choices changed before this answer was saved.":`保存前选项已变化,本次答案未保存。`,Connection:`连接`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Link copied.":`链接已复制。`,"Dismiss notification":`关闭通知`,"Theme: {current}. Switch to {next}.":`主题:{current}。点击切换为{next}。`,System:`跟随系统`,Light:`浅色`,Dark:`深色`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"Service unavailable":`服务不可用`,"Task snapshot not observed yet":`尚未观察到任务快照`,"No task selected":`未选择任务`,"Resize left pane":`调整左侧面板宽度`,"Resize right pane":`调整右侧面板宽度`,Detached:`已断开`,"Accepted service work continues. No Cancel was requested.":`已接受的服务工作会继续进行。没有请求取消。`,"Observe command after reconnect:":`重新连接后观察命令:`,"Reconnect as a viewer":`以查看者身份重新连接`,"Current action context unavailable; observe again.":`当前操作上下文不可用;请重新观察。`,"Preflight refused: {code}":`预检被拒绝:{code}`,"Preflight unavailable. No automatic retry.":`预检不可用。不会自动重试。`,"Stop requested; settlement is not yet confirmed.":`已请求停止;尚未确认结束。`,"{code}; cancellation effect {effect}. Observe exact receipt.":`{code};取消效果 {effect}。请观察确切回执。`,"Cancellation effect uncertain. Observe exact receipt.":`取消效果不确定。请观察确切回执。`,"Observation unavailable.":`观察不可用。`,"Access revoked; explicit token re-entry required.":`访问已被撤销;需要显式重新输入令牌。`,Kind:`类型`,Code:`代码`,"Readonly research":`只读调研`,"Readonly diagnosis":`只读诊断`,Goal:`目标`,"Preview Create (does not Start)":`预览创建(不会启动)`,"Close dialog — no cancellation of accepted work":`关闭对话框——不会取消已接受的工作`,"Close — accepted work is not cancelled":`关闭——不会取消已接受的工作`,Checkout:`工作副本`,Observation:`观察`,Expires:`过期时间`,"Expected: {output}":`预期产出:{output}`,"Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.":`显式的所有者级选择,仅在空闲时可用。它不会解析凭据、探测提供方、保存计划或启动工作。`,"Current: {model}":`当前:{model}`,"No model selected":`未选择模型`,"Exact model / API / thinking":`确切的模型 / API / 思考级别`,"Select explicitly":`请显式选择`,"Catalog capacity exceeded; no partial model list is selectable.":`模型目录超出容量;不能从不完整的列表中选择。`,"{error}. No automatic replacement or retry.":`{error}。不会自动替换或重试。`,"{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,Command:`命令`,Arguments:`参数`,"Copy tool summary":`复制工具摘要`,"Copy command":`复制命令`,"Copy arguments":`复制参数`,"Copy output":`复制输出`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"Attempts shown: {partial} partial · {blocked} blocked · {failed} failed":`当前显示的尝试:{partial} 项部分完成 · {blocked} 项受阻 · {failed} 项失败`,"Partial or blocked assignments preserve work; they are not process failures or delivery approval.":`部分完成或受阻的任务保留已有成果,不代表进程故障,也不代表交付通过。`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,starting:`正在启动`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,superseded:`已被取代`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重新打开模型选择器。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Stop work and upgrade to {version}":`停止运行中的工作并升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"The service stops in order and starts again; this page waits for the result.":`服务会有序停止并重新启动;此页面会等待重启结果。`,"Cadence downloads the update before stopping. If startup fails, it tries to restore the previous version. After a successful upgrade, this page reloads automatically; unsent images must be attached again.":`Cadence 会先下载更新,再停止服务并安装。如果新版本未能启动,会尝试恢复旧版本。升级成功后页面会自动刷新;未发送的图片需要重新添加。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Conversation {id}":`会话 {id}`,"Cadence could not confirm which work would stop. Refresh the service status to continue.":`Cadence 无法确认将停止的工作。请刷新服务状态后继续。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},X=i(),Qn=`cadence-locale`,$n=new Map(Object.entries(Zn));function er(e,t,n){let r=e===`zh`?$n.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var tr={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function nr(e,t){let n=Object.hasOwn(tr,t)?tr[t]:void 0;return n?e(n,{code:t}):t}function rr({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,X.jsx)(h.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function ir(){try{let e=localStorage.getItem(Qn);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function ar(e,t){return{locale:e,t:(t,n)=>er(e,t,n),tx:t=>er(e,t),setLocale:t}}var or=(0,h.createContext)(ar(`en`,()=>{}));function Z(){return(0,h.useContext)(or)}function sr({initial:e,children:t}){let[n,r]=(0,h.useState)(()=>e??ir()),i=(0,h.useMemo)(()=>ar(n,e=>{try{localStorage.setItem(Qn,e)}catch{}r(e)}),[n]);return(0,h.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=er(n,`Cadence task workspace`)},[n]),(0,X.jsx)(or.Provider,{value:i,children:t})}var cr=`cadence-theme`,lr=[`system`,`light`,`dark`],ur=e=>e===`light`||e===`dark`;function dr(){try{let e=localStorage.getItem(cr);if(ur(e))return e}catch{}return`system`}function fr(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function pr(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return ur(e)?e:`system`}function mr(e){try{e===`system`?localStorage.removeItem(cr):localStorage.setItem(cr,e)}catch{}fr(e)}var hr=e=>lr[(lr.indexOf(e)+1)%lr.length];function gr(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}function _r(e){H({kind:`ok`,value:e},C.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=F(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:L(n.storeId),workspaceId:L(n.workspaceId),epoch:L(n.epoch)};if(!t)return N(n.status,`unavailable`),{...r,status:`unavailable`,error:vr(n.error)};let i=I(n.runs,C.episodes,e=>{let t=F(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:L(t.taskId),runId:L(t.runId),operationId:L(t.operationId),epoch:L(t.epoch),kind:M(t.kind,[`start`,`generate-plan`,`check`]),stage:M(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&D(),{...r,status:`complete`,runs:i}}function vr(e){let t=ne(e);return N(t.effect,`none`),t}function yr(e){let t=F(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:z(t.sourceHash),contractHash:z(t.contractHash),buildId:z(t.buildId)}}function br(e){let t=M(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=F(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:z(n.contractHash)}:{kind:t,...yr({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function xr(e){let t=F(e,[`contractHash`,`assets`]);return{contractHash:z(t.contractHash),assets:yr(t.assets)}}function Sr(e){H(e);let t=F(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:L(t.commandId),operationId:L(t.operationId),runId:P(t.runId,L),admission:M(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:B(t.committedSeq),execution:P(t.execution,e=>M(e,ie)),settlement:P(t.settlement,Ge),created:P(t.created,e=>{let t=F(e,[`kind`,`taskId`,`state`]);return{kind:N(t.kind,`task`),taskId:L(t.taskId),state:M(t.state,[`reserved`,`published`])}}),publication:M(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&We(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&D(),n}function Cr(e){H(e);let t=F(e,[`identity`,`receipt`]),n=be(t.identity),r=Sr(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&D();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&D(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&D()}return{identity:n,receipt:r}}function Q(e,t){if(pe(e)===`ok`)return{kind:`ok`,value:t(F(e,[`kind`,`value`]).value)};let n=F(e,[`kind`,`error`]);return N(n.kind,`error`),{kind:`error`,error:ne(n.error)}}function wr(e){switch(H(e),pe(e,`status`)){case`found`:return{status:`found`,receipt:Sr(F(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:B(F(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ne(F(e,[`status`,`error`]).error)};default:return D()}}function Tr(e){let t=F(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:L(t.runId),taskId:L(t.taskId),childRunId:P(t.childRunId,L),assignmentId:P(t.assignmentId,ee),admission:Fr(t.admission),lifecycle:M(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:P(t.outcome,e=>M(e,ie)),settlement:P(t.settlement,Ge),reason:P(t.reason,e=>M(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:M(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Ce(t.coverage),result:P(t.result,W)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&H(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==H(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&H(n.result)!==H(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&We(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||We(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&D(),n}function Er(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Dr(e,t,n){return Er(e,t)&&e.taskId===Rr(n)&&e.admission.context.workspaceId===Lr(n)}function Or(e){H(e,C.pageBytes);let t=F(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:N(t.protocol,1),storeId:L(t.storeId),epoch:L(t.epoch),scope:De(t.scope),committedSeq:B(t.committedSeq),context:Ir(t.context),runs:I(t.runs,C.maxPageEntries,Tr),horizon:Xr(t.horizon)};return(!zr(n.context,n.epoch,n.scope)||H(n.horizon.historicalRuns.scope)!==H(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!Dr(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&D(),n}function kr(e){H(e,C.pageBytes);let t=pe(e),n=F(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:L(n.storeId),epoch:L(n.epoch),scope:De(n.scope),committedSeq:B(n.committedSeq)};if(t===`update`){let e=B(n.previousSeq);V(r.committedSeq,e)<=0&&D();let i=Ir(n.context);zr(i,r.epoch,r.scope)||D();let a=I(n.runs,C.maxPageEntries,Tr),o=I(n.removed,C.maxPageEntries,L),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!Dr(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&D(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return N(t,`heartbeat`),{kind:`heartbeat`,...r}}function Ar(e){let{navigation:t,...n}=e;return n}function jr(e,t){(!t.navigation||t.navigation===e.navigation||H(Ar(e))!==H(Ar(t)))&&D()}function Mr(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Nr(e);H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return jr(n,r),{kind:`progress`,cursor:n,next:r,coverage:Ce(t.coverage)}}function Nr(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:W(t.content),range:P(t.range,de),text:O(t.text,C.detailPageBytes),next:P(t.next,ke),coverage:Ce(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==k(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&D(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&D(),n.next&&(n.next.offset!==n.range?.end||H(Ar({...n.next,offset:n.cursor.offset}))!==H(Ar(n.cursor)))&&D(),n}function Pr(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||D();let r=k(n.query),i=I(t.hits,C.maxPageEntries,e=>{let t=F(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=W(t.content),a=Hr(t.owner);Ur(a,n.scope)||D();let o=de(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||H(s.scope)!==H(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&D(),{content:i,owner:a,range:o,preview:O(t.preview,C.previewBytes),cursor:s}}),a=P(t.next,ke);return a&&(a.storeId!==n.storeId||H(a.scope)!==H(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&D(),{cursor:n,hits:i,next:a,coverage:Ce(t.coverage)}}function Fr(e){let t=F(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=he(t.context),r=P(t.graph,e=>{let t=F(e,[`recordId`,`revision`,`sha256`]);return{recordId:L(t.recordId),revision:A(t.revision,1),sha256:z(t.sha256)}}),i=M(t.kind,[`start`,`generate-plan`,`check`]),a=I(t.assignments,C.assignments,e=>{let t=F(e,[`assignmentId`,`childRunId`]);return{assignmentId:ee(t.assignmentId),childRunId:L(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&D(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&D(),{operationId:L(t.operationId),commandId:L(t.commandId),kind:i,context:n,assignments:a,graph:r}}function Ir(e){if(pe(e,`status`)===`available`)return{status:`available`,version:he(F(e,[`status`,`version`]).version)};let t=F(e,[`status`,`workspaceId`,`taskId`,`error`]);N(t.status,`unavailable`);let n=ne(t.error);return N(n.effect,`none`),{status:`unavailable`,workspaceId:L(t.workspaceId),taskId:P(t.taskId,L),error:n}}function Lr(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Rr(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function zr(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Rr(e)===n.id)}function Br(e){let t=F(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=F(t.capabilities,[`actions`,`manualChecks`,`history`]),r=M(t.authority,[`browser`,`local`]),i=P(t.csrf,L),a={actions:j(n.actions),manualChecks:j(n.manualChecks),history:j(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&D(),{...t.build===void 0?{}:{build:xr(t.build)},protocol:N(t.protocol,1),storeId:L(t.storeId),epoch:L(t.epoch),accessGeneration:A(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function Vr(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:_r(t.activeRuns)},workspaceId:L(t.workspaceId),storeId:L(t.storeId),epoch:L(t.epoch),committedSeq:B(t.committedSeq),rootLabel:O(t.rootLabel,4096,!0),context:Ir(t.context),models:I(t.models,C.maxPageEntries,U)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&D(),(Lr(n.context)!==n.workspaceId||Rr(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&D(),n}function Hr(e){let t=F(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=F(t.entity,[`kind`,`id`,`version`]),r={taskId:L(t.taskId),runId:P(t.runId,L),childRunId:P(t.childRunId,L),entity:{kind:M(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:L(n.id),version:A(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&D(),r}function Ur(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Wr(e){let t=F(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:z(t.identity),complete:j(t.complete),checkoutGeneration:A(t.checkoutGeneration)}}function Gr(e){H(e,C.controlBytes);let t=pe(e);switch(t){case`assignment-state`:{let n=F(e,[`kind`,`childRunId`,`state`,`reason`]),r=M(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=P(n.reason,e=>M(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&D(),(r===`ready`||r===`preparing`)&&i!==null&&D(),{kind:t,childRunId:L(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:M(F(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=F(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:L(n.runId),identity:Fr(n.identity)}}case`parent-settled`:{let n=F(e,[`kind`,`runId`,`settlement`]),r=Ge(n.settlement);return r.kind!==`parent`&&D(),{kind:t,runId:L(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=F(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:L(r.reservationId)}:{},lane:M(r.lane,[`reader`,`writer`,`check`]),state:M(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:A(r.checkoutGeneration)}}case`handoff`:{let n=F(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:L(n.childRunId),handoff:we(n.handoff),observation:Wr(n.observation)}}case`changes`:{let n=F(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=W(n.content);return N(r.field,`changes`),{kind:t,observationId:L(n.observationId),stage:M(n.stage,[`before`,`after`,`review`]),observation:Wr(n.observation),content:r}}case`check-start`:{let n=F(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:L(n.checkId),selection:ge(n.selection),cwdId:L(n.cwdId),cwdLabel:O(n.cwdLabel,4096,!0),checkEnvGeneration:A(n.checkEnvGeneration,1),before:Wr(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=F(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=F(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:L(e.operationId),reservationId:L(e.reservationId),from:A(e.from),to:A(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&D()}let a=Re(r.native),o=M(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=Wr(r.before),c=Wr(r.after),l=P(r.output,W),u=Ce(r.coverage);return l&&l.field!==`check`&&D(),o===`passed`&&(a.outcome!==`completed`||H({...s,checkoutGeneration:c.checkoutGeneration})!==H(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&D(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&D(),{kind:t,...i?{ownAdvance:i}:{},checkId:L(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=F(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=j(n.acceptIssues),i=M(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=W(n.content);return N(a.field,`review`),i===`reviewed-with-issues`&&!r&&D(),{kind:t,reviewId:L(n.reviewId),runId:L(n.runId),checksRevision:A(n.checksRevision),changesIdentity:z(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=F(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=A(n.expectedRevision),i=P(n.expectedIdentity,z),a=A(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&D(),{kind:t,publicationId:L(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:z(n.nextIdentity)}}case`publication-settled`:{let n=F(e,[`kind`,`publicationId`,`status`,`observed`]),r=M(n.status,[`published`,`conflict`,`uncertain`]),i=P(n.observed,e=>{let t=F(e,[`revision`,`identity`]);return{revision:A(t.revision,1),identity:z(t.identity)}});return r===`published`&&i===null&&D(),{kind:t,publicationId:L(n.publicationId),status:r,observed:i}}default:return D()}}function Kr(e){let t=F(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:L(t.epoch),operationId:L(t.operationId),taskId:L(t.taskId),runId:P(t.runId,L)}}function qr(e){H(e,C.ownerQueueBytes);let t=F(e,[`observedMs`,`link`,`events`]),n=Kr(t.link),r=I(t.events,C.ownerQueueFrames,e=>{let t=pe(e);if(t===`fact`){let r=Gr(F(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&D(),{kind:t,fact:r}}if(t===`content-begin`){let r=F(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=Hr(r.owner),a=M(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&D(),{kind:t,detailId:L(r.detailId),owner:i,field:a,encoding:N(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=F(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:L(n.detailId),text:O(n.text,C.chunkBytes)}}let r=F(e,[`kind`,`detailId`,`coverage`]);return N(t,`content-end`),{kind:`content-end`,detailId:L(r.detailId),coverage:Ce(r.coverage)}});return{observedMs:A(t.observedMs),link:n,events:r}}var Jr=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Yr(e){let t=F(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=M(t.reader,Jr),r=F(t.scope,[`kind`,`id`]),i={kind:M(r.kind,[`workspace`,`task`,`run`,`child`]),id:L(r.id)},a=P(t.snapshotSeq,B),o=P(t.after,e=>{let t=F(e,[`recordId`,`version`,`offset`]);return{recordId:L(t.recordId),version:A(t.version,1),offset:A(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&D(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:i,snapshotSeq:a,after:o,limit:A(t.limit,1,C.maxPageEntries)}}function Xr(e){let t=F(e,[`policy`,`historicalRuns`]),n=Yr(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&D(),{policy:N(t.policy,`active-and-recent`),historicalRuns:n}}function Zr(e){let t=pe(e);if(t===`run`)return{kind:t,projection:Tr(F(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=F(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=B(n.committedSeq);return r===`0`&&D(),{kind:t,recordId:L(n.recordId),committedSeq:r,link:Je(n.link),capture:qe(n.capture)}}if(t===`owner-fact`){let n=F(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=qr({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&D();let a=B(n.committedSeq);return a===`0`&&D(),{kind:t,recordId:L(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=F(e,[...n,...r]),a=Hr(i.owner),o=A(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&D(),t===`task`){let e=P(i.plan,W);return e&&e.field!==`plan`&&D(),{kind:t,owner:a,version:o,goal:O(i.goal,8192,!0),plan:e}}if(t===`message`){let e=M(i.role,[`user`,`assistant`,`tool-result`]),n=M(i.state,[`partial`,`final`]),r=P(i.finalBlockCount,e=>A(e,0,C.dataFrames)),s=P(i.finalText,W),c=P(i.resultCallId,L);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&D(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=P(i.declaration,je),n=P(i.declarationStage,e=>M(e,[`partial`,`final`])),r=j(i.startObserved),s=P(i.result,e=>{let t=Le(e);return t.kind!==`tool-end`&&D(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||H(s.declaration)!==H(e)))&&D(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:O(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=W(i.content);return(e.field!==n.field||!Qr(e.owner,a))&&D(),{kind:t,owner:a,version:o,detailId:L(i.detailId),descriptor:e,content:n,coverage:Ce(i.coverage)}}N(t,`omitted`);let s=Pe(i.block);return Qr(s.owner,a)||D(),{kind:`omitted`,owner:a,version:o,block:s}}function Qr(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function $r(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function ei(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`records`,`next`,`coverage`]),n=Yr(t.request);n.snapshotSeq===null&&D();let r=I(t.records,n.limit,Zr),i=P(t.next,Yr);return(r.some(e=>!$r(e,n))||i&&(i.after===null||H(Ar({...i,after:n.after}))!==H(Ar(n))||H(i.after)===H(n.after)))&&D(),{request:n,records:r,next:i,coverage:Ce(t.coverage)}}function ti(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=Yr(t.request),r=Yr(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||H(Ar({...r,snapshotSeq:null}))!==H(Ar(n)))&&D(),{kind:`snapshot`,request:n,next:r,coverage:Ce(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return ei(e);H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=Yr(t.request),r=Yr(t.next);return jr(n,r),{kind:`progress`,request:n,next:r,coverage:Ce(t.coverage)}}function ni(e,t){return H({...t.request,snapshotSeq:e.snapshotSeq})===H(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function ri(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=F(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:B(t.snapshotSeq),graph:{recordId:L(n.recordId),revision:A(n.revision,1),sha256:z(n.sha256)}}}function ii(e){H({kind:`ok`,value:e});let t=F(e,[`request`,`graph`]),n=ri(t.request),r=G(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&D(),{request:n,graph:r}}function ai(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return ii(e);H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=ri(t.request),r=ri(t.next);return jr(n,r),{kind:`progress`,request:n,next:r,coverage:Ce(t.coverage)}}function oi(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:B(t.snapshotSeq),format:M(t.format,[`ndjson`,`markdown`])}}function si(e){H(e,C.controlBytes);let t=F(e,[`exportId`,`ordinal`,`event`]),n=pe(t.event),r;switch(n){case`manifest`:{let e=F(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=F(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:z(i.exporterBuildSha256),capturePolicy:N(i.capturePolicy,`public-text-tools/2`)},schema:N(e.schema,S),request:oi(e.request),coverage:Ce(e.coverage),serviceProtocol:N(e.serviceProtocol,1),workerProtocol:N(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Zr(F(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:ii(F(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=F(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=W(e.content),a=P(e.range,de),o=O(e.text,C.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==k(o):i.bytes!==0||o!==``)&&D(),r={kind:n,owner:Hr(e.owner),content:i,range:a,text:o,coverage:Ce(e.coverage)};break}case`markdown`:r={kind:n,text:O(F(t.event,[`kind`,`text`]).text,C.detailPageBytes)};break;case`trailer`:{let e=F(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Ce(e.coverage),a=j(e.complete);a&&i.observed!==`complete`&&D(),r={kind:n,complete:a,frames:A(e.frames,1),encodedBytes:A(e.encodedBytes),sha256:z(e.sha256),committedSeq:B(e.committedSeq),coverage:i};break}default:return D()}return{exportId:L(t.exportId),ordinal:A(t.ordinal,1),event:r}}function ci(e,t){let n=si(e);return t===`ndjson`?`${H(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&D(),`\n\n\`\`\`json\n${H(n)}\n\`\`\`\n`)}var li=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=oi(e)}receive(e){let t=si(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&D(),this.ordinal===0?(n.kind!==`manifest`||H(n.request)!==H(this.request))&&D():n.kind===`manifest`&&D(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&D(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&D(),this.request.format===`ndjson`&&n.kind===`markdown`&&D(),n.kind===`detail`&&!Ur(n.owner,this.request.scope)&&D(),n.kind===`graph`&&(H(n.graph.request.scope)!==H(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&D(),n.kind===`record`&&!ui(n.record,this.request.scope)&&D(),this.bytes+=k(ci(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function ui(e,t){return e.kind===`run`?Er(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:Ur(e.owner,t)}function di(e){let t=F(e,[`taskId`,`revision`,`definitions`]),n=I(t.definitions,32,e=>{let t=F(e,[`selection`,`status`,`checkId`]),n=ge(t.selection),r=M(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=P(t.checkId,L);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&D(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&D(),{taskId:L(t.taskId),revision:A(t.revision),definitions:n}}function fi(e){let t=F(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:L(t.storeId),scope:De(t.scope),snapshotSeq:B(t.snapshotSeq),kind:M(t.kind,[`task`,`message`,`tool`]),id:L(t.id),version:A(t.version,1)}}function pi(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`record`]),n=fi(t.request),r=Zr(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!Ur(r.owner,n.scope))&&D(),{request:n,record:r}}function mi(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return pi(e);H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`kind`,`request`,`next`,`coverage`]),n=fi(t.request),r=fi(t.next);return jr(n,r),{kind:`progress`,request:n,next:r,coverage:Ce(t.coverage)}}var hi=e=>{let t=ne(e);return N(t.effect,`none`),t};function gi(e){let t=F(e,[`storeId`,`taskId`]);return{storeId:L(t.storeId),taskId:P(t.taskId,L)}}function _i(e){let t=gi(e);return t.taskId===null&&D(),t}function vi(e){let t=F(e,[`id`,`kind`,`revision`,`identity`]);return{id:L(t.id),kind:M(t.kind,[`code`,`research`,`diagnosis`]),revision:A(t.revision,1),identity:z(t.identity)}}function yi(e){let t=I(e,3,le);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&D(),t}function bi(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return F(e,[`status`]),{status:t};if(t===`saved`){let n=F(e,[`status`,`request`,`planRevision`]);return{status:t,request:ri(n.request),planRevision:A(n.planRevision,1)}}let n=F(e,[`status`,`error`]);return N(n.status,`unavailable`),{status:`unavailable`,error:hi(n.error)}}function xi(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Lr(e.context)!==e.workspaceId||Rr(e.context)!==e.request.taskId)&&D(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&D()}}function Si(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:gi(t.request),workspaceId:L(t.workspaceId),epoch:L(t.epoch),committedSeq:B(t.committedSeq),context:Ir(t.context),task:P(t.task,vi),roles:yi(t.roles),savedGraph:bi(t.savedGraph),readablePlan:P(t.readablePlan,e=>{let t=F(e,[`source`,`text`,`editable`,`coverage`]),n=Ce(t.coverage),r=j(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&D(),{source:N(t.source,`current-v1`),text:O(t.text,32768),editable:r,coverage:n}})};xi(n),!!n.task!=!!n.readablePlan&&D();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&D(),r.status===`unavailable`&&n.context.status===`available`&&D(),n}function Ci(e){H({kind:`ok`,value:e},C.pageBytes);let t=F(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=F(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:_i(t.request),workspaceId:L(t.workspaceId),epoch:L(t.epoch),committedSeq:B(t.committedSeq),context:Ir(t.context),task:vi(t.task),observation:{identity:z(n.identity),complete:j(n.complete),checkoutGeneration:A(n.checkoutGeneration,0)},text:O(t.text,131072),git:j(t.git),coverage:Ce(t.coverage)};if(xi(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&D()}return r}var wi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ti=h.createContext&&h.createContext(wi),Ei=[`attr`,`size`,`title`];function Di(e,t){if(e==null)return{};var n,r,i=Oi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ki.apply(null,arguments)}function Ai(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ji(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ai(Object(n),!0).forEach(function(t){Mi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ai(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mi(e,t,n){return(t=Ni(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ni(e){var t=Pi(e,`string`);return typeof t==`symbol`?t:t+``}function Pi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Fi(e){return e&&e.map((e,t)=>h.createElement(e.tag,ji({key:t},e.attr),Fi(e.child)))}function $(e){return t=>h.createElement(Ii,ki({attr:ji({},e.attr)},t),Fi(e.child))}function Ii(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Di(e,Ei),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),h.createElement(`svg`,ki({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ji(ji({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&h.createElement(`title`,null,i),e.children)};return Ti===void 0?t(wi):h.createElement(Ti.Consumer,null,e=>t(e))}function Li(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Ri(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function zi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Bi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function Vi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Hi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function Ui(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function Wi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Gi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function Ki(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function Ji(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function Yi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function Xi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Zi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function $i(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},child:[]}]})(e)}function ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function na(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function ra(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function ia(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function sa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function la(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function ua(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function fa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function pa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function ma(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function ha(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function ga(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function _a(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function ya(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function ba(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function xa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function Sa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function Ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function wa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function Ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function Ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function Da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function Oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function ka(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function Aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function ja(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function Ma(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function Na(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function Pa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function Fa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function Ia(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function La(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function Ra(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function za(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function Ba(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function Va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ha(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Ua(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var Wa=e=>({kind:`error`,error:E(`unavailable`,e?`uncertain`:`none`)}),Ga=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=yn(e);try{if(!this.transport.workbenchRead)return Wa(!1);let e=Q(await this.transport.workbenchRead(n,t),zn);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?Wa(!1):e}catch{return Wa(!1)}}async workbenchCommand(e){let t=xn(e);try{if(!this.transport.workbenchCommand)return Wa(!0);let e=Q(await this.transport.workbenchCommand(t),zn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Wa(!0):e}catch{return Wa(!0)}}async current(e,t){let n=gi(e);try{if(!this.transport.current)return Wa(!1);let e=Q(await this.transport.current(n,t),Si);return e.kind===`ok`&&H(e.value.request)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}async currentChanges(e,t){let n=_i(e);try{if(!this.transport.currentChanges)return Wa(!1);let e=Q(await this.transport.currentChanges(n,t),Ci);return e.kind===`ok`&&H(e.value.request)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),_r):Wa(!1)}catch{return Wa(!1)}}async models(e,t,n=!1){try{if(t){let r=await this.workbenchRead({kind:n?`reload-conversation-models`:`conversation-models`,location:t},e);return r.kind===`error`?r:r.value.kind===`conversation-models`&&r.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:r.value.catalog}:Wa(!1)}return this.transport.models?Q(await this.transport.models(e),it):Wa(!1)}catch{return Wa(!1)}}async chooseModel(e,t){let n=et(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:Wa(!0)}else{if(!this.transport.chooseModel)return Wa(!1);e=Q(await this.transport.chooseModel(n),$e)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(H(i)!==H(n.choice)||H(e.value.version.conversation??null)!==H(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return Wa(!0)}return e}catch{return Wa(!0)}}async checkObligations(e,t){L(e);try{let n=Q(await this.transport.checkObligations(e,t),di);return n.kind===`ok`&&n.value.taskId!==e?Wa(!1):n}catch{return Wa(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=fi({...t,kind:e});try{let e=Q(await this.transport.entity(r,n),mi);return e.kind===`ok`&&H(e.value.request)!==H(r)?Wa(!1):e}catch{return Wa(!1)}}async session(e){try{return Q(await this.transport.session(e),Br)}catch{return Wa(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),Vr)}catch{return Wa(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Yr({...t,reader:e});try{let t=Q(await this.transport[e](r,n),ti);return t.kind===`ok`&&!ni(r,t.value)?Wa(!1):t}catch{return Wa(!1)}}async graph(e,t){let n=ri(e);try{let e=Q(await this.transport.graph(n,t),ai);return e.kind===`ok`&&H(e.value.request)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}async*export(e,t){let n=oi(e),r=new li(n),i;try{if(t.aborted)throw new T(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new T(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new T(`unavailable`);yield i}catch{throw new T(`unavailable`)}}async preflight(e,t){let n=ve({expected:e,action:t});try{let e=Q(await this.transport.preflight(n),Se);return e.kind===`ok`&&(H(e.value.preview.version)!==H(n.expected)||H(e.value.preview.action)!==H(n.action))?Wa(!1):e}catch{return Wa(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=ye(t);if(n.action.kind!==e)return{kind:`error`,error:E(`invalid`)};try{let e=Q(await this.transport.command(n),Sr);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Wa(!0);Cr({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Wa(!0)}}async cancel(e){let t=K(e);try{let e=Q(await this.transport.cancel(t),Sr);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Wa(!0);Cr({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Wa(!0)}}async receipt(e,t){L(e);try{let n=wr(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:E(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Q(await this.transport.snapshot(n,t),Or);return e.kind===`ok`&&H(e.value.scope)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}async detail(e,t){let n=ke(e);try{let e=Q(await this.transport.detail(n,t),Mr);return e.kind===`ok`&&H(e.value.cursor)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}async search(e,t){let n=ke(e);try{let e=Q(await this.transport.search(n,t),Pr);return e.kind===`ok`&&H(e.value.cursor)!==H(n)?Wa(!1):e}catch{return Wa(!1)}}},Ka=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=Or(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&H(i.scope)===H(r.scope)&&V(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=C.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=C.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=kr(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||H(i.scope)!==H(a.scope))return this.resync();let o=V(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Lr(i.context)!==Lr(a.context)||Rr(i.context)!==Rr(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||H(t.admission)!==H(e.admission))return this.resync();s[n]=e}}if(s.length>C.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{Or(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}},qa={session:`/api/v1/session`,workbenchRead:`/api/v1/workbench/read`,workbenchCommand:`/api/v1/workbench/command`,current:`/api/v1/current`,currentChanges:`/api/v1/current-changes`,activeRuns:`/api/v1/active-runs`,models:`/api/v1/models`,chooseModel:`/api/v1/model-choice`,workspace:`/api/v1/workspace`,tasks:`/api/v1/tasks`,runs:`/api/v1/runs`,messages:`/api/v1/messages`,tools:`/api/v1/tools`,contents:`/api/v1/contents`,events:`/api/v1/history-events`,checks:`/api/v1/checks`,changes:`/api/v1/changes`,reviews:`/api/v1/reviews`,checkObligations:`/api/v1/check-obligations`,entity:`/api/v1/entity`,graph:`/api/v1/graph`,snapshot:`/api/v1/snapshot`,detail:`/api/v1/details`,search:`/api/v1/search`,export:`/api/v1/export`,download:`/api/v1/download`,preflight:`/api/v1/preflight`,command:`/api/v1/commands`,cancel:`/api/v1/cancel`,receipt:`/api/v1/receipt`,detach:`/api/v1/detach`},Ja=`/api/v1/events`,Ya=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`],Xa=`x-cadence-history-csrf`,Za=[...Ya,`entity`,`graph`,`detail`,`search`];function Qa(e){return Za.includes(e)}function $a(e,t){if(Ya.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return C.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return C.pageBytes}return C.controlBytes}function eo(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function to(e,t){switch(e){case`workbenchRead`:return yn(t);case`workbenchCommand`:return xn(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new T(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Yr(t);if(n.reader!==e)throw new T(`invalid`);return n}case`current`:return gi(t);case`currentChanges`:return _i(t);case`checkObligations`:case`receipt`:return L(t);case`entity`:return fi(t);case`graph`:return ri(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return oi(t);case`chooseModel`:return et(t);case`preflight`:return ve(t);case`command`:return ye(t);case`cancel`:return K(t)}}function no(e,t){if(Ya.includes(e))return Q(t,ti);switch(e){case`workbenchRead`:case`workbenchCommand`:return Q(t,zn);case`current`:return Q(t,Si);case`currentChanges`:return Q(t,Ci);case`activeRuns`:return Q(t,_r);case`models`:return Q(t,it);case`chooseModel`:return Q(t,$e);case`session`:return Q(t,Br);case`workspace`:return Q(t,Vr);case`checkObligations`:return Q(t,di);case`entity`:return Q(t,mi);case`graph`:return Q(t,ai);case`snapshot`:return Q(t,Or);case`detail`:return Q(t,Mr);case`search`:return Q(t,Pr);case`preflight`:return Q(t,Se);case`command`:case`cancel`:return Q(t,Sr);case`receipt`:return wr(t);case`detach`:return Q(t,e=>{if(e!==null)throw new T(`invalid`);return null});default:throw new T(`invalid`)}}function ro(e){return[...Za,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`snapshot`,`export`,`download`,`receipt`].includes(e)}function io(e,t){let n=qa[e];return t===null||eo(e)?n:`${n}?request=${encodeURIComponent(H(t))}`}function ao(e,t){let n=to(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?qa[e]:io(e,n);return eo(e)||ro(e)&&(r||k(i)>C.headerBytes/4)?{path:qa[e],method:`POST`,body:H(n)}:{path:i,method:`GET`}}function oo(e){H(e,C.viewerBytes);let t=M(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:Or(F(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:kr(F(e,[`kind`,`event`]).event)}:(F(e,[`kind`]),{kind:t})}var so=class{options;attachment;csrf=null;historyCsrf;bootstrapRevision=0;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project)||e.retainedHistory&&e.localCapability)throw new T(`invalid`);this.origin=e.origin,e.build&&=br(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e,t=!1){let n={"Cache-Control":`no-store`};if(this.options.build&&(n[`X-Cadence-Build`]=H(this.options.build)),this.attachment&&(e||t)&&(n[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(n[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new T(`stale`);n[`Content-Type`]=`application/json`,this.csrf&&(n[`X-Cadence-CSRF`]=this.csrf)}return n}async request(e,t,n){if(this.options.retainedHistory&&e!==`workspace`&&!Qa(e))throw new T(`forbidden`);let r=ao(e,to(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:gr([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;e===`session`&&(this.attachment??=crypto.randomUUID());let t=this.options.retainedHistory&&e===`workspace`?++this.bootstrapRevision:void 0;t!==void 0&&(this.historyCsrf=void 0);let n=this.options.retainedHistory&&i,a=this.headers(i&&!n,e===`session`);if(n){if(!this.historyCsrf)throw new T(`stale`);a[Xa]=this.historyCsrf,a[`Content-Type`]=`application/json`}let s=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:a,credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),c;try{if(e===`session`&&s.ok&&(c=L(s.headers.get(`x-cadence-attachment`)),c!==this.attachment))throw new T(`invalid`)}catch(e){throw await s.body?.cancel().catch(()=>{}),e}let l=await co(s,$a(e)),u=te(l);if(k(l)>$a(e,u))throw new T(`oversize`);let d=no(e,u);if(t!==void 0&&s.ok&&Object.getOwnPropertyDescriptor(d??{},`kind`)?.value===`ok`){if(o?.aborted||this.bootstrapRevision!==t)throw new T(`stale`);this.historyCsrf=L(s.headers.get(Xa))}if(e===`session`){let e=Q(d,Br);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new T(`forbidden`);if(o?.aborted||c!==this.attachment||!c)throw new T(`stale`);this.csrf=e.value.csrf}}return d}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,et(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,L(e),t)}entity(e,t){return this.request(`entity`,fi(e),t)}tasks(e,t){return this.request(`tasks`,Yr(e),t)}runs(e,t){return this.request(`runs`,Yr(e),t)}messages(e,t){return this.request(`messages`,Yr(e),t)}tools(e,t){return this.request(`tools`,Yr(e),t)}contents(e,t){return this.request(`contents`,Yr(e),t)}events(e,t){return this.request(`events`,Yr(e),t)}checks(e,t){return this.request(`checks`,Yr(e),t)}changes(e,t){return this.request(`changes`,Yr(e),t)}reviews(e,t){return this.request(`reviews`,Yr(e),t)}graph(e,t){return this.request(`graph`,ri(e),t)}preflight(e){return this.request(`preflight`,ve(e))}command(e){return this.request(`command`,ye(e))}cancel(e){return this.request(`cancel`,K(e))}receipt(e,t){return this.request(`receipt`,L(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=!1;for(;;){if(!this.options.localCapability&&!this.csrf){t=!0;let n=Q(await this.session(),Br);if(n.kind===`error`){if(n.error.code===`forbidden`)return n;if(![`stale`,`unauthenticated`].includes(n.error.code))throw new T(n.error.code);return this.attachment===e&&(this.attachment=void 0),n}}if(this.attachment!==e)throw new T(`stale`);let n=Q(await this.request(`detach`,null),e=>{if(e!==null)throw new T(`invalid`);return null});if(n.kind===`error`&&n.error.code!==`stale`&&n.error.code!==`unauthenticated`){if(n.error.code===`forbidden`&&!this.options.localCapability&&this.attachment===e){if(this.csrf=null,!t)continue;return n}throw new T(n.error.code)}return this.attachment===e&&(this.attachment=void 0,this.csrf=null),n}}async*export(e,t){if(this.options.retainedHistory)throw new T(`forbidden`);let n=ao(`export`,oi(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new T(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new T(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=C.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+C.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
15
|
+
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield si(te(e,C.controlBytes)),r=o.indexOf(`
|
|
16
|
+
`)}if(new TextEncoder().encode(o).length>C.controlBytes)throw new T(`oversize`)}if(n){if(o)throw new T(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=De(e);if(!this.attachment||!this.options.socket)throw new T(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Ja}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{let e=Date.now()-s;if(e>=C.staleMs&&(u(`stale`),!a||e>C.reconcileMs))return l();if(a&&!o)try{Date.now()-c>=C.reconcileMs?(i.send(H({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}},C.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0,s=c=Date.now();try{i.send(H({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o&&a)try{if(typeof e.data!=`string`)throw new T(`invalid`);let n=oo(te(e.data,C.viewerBytes));s=Date.now(),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function co(e,t){if(!e.body)throw new T(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new T(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var lo={sourceHash:`2e0372fee8a1eab88a0c4e35056ecbfcc47dbd335af4a42d7ae19f0a2734b406`,contractHash:`80875479add4b7830419060b7e5018a39de200665edfbdec20fc10d50861bfea`,buildId:`e88fdf359f1d74065570ec097fb5bd5f4ad647ecf4ba7d3c53f1c69aec37550a`};function uo(e){let t=new so({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...lo?{build:{kind:`browser`,...lo}}:{},socket:e=>new WebSocket(e)});return{client:new Ga(t),transport:t}}function fo(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function po(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var mo=[],ho=null,go,_o,vo=new Set;function yo(){let e=po(mo,performance.now());if(e!==ho){ho=e;for(let e of vo)e()}}function bo(e){if(vo.add(e),vo.size===1&&typeof PerformanceObserver<`u`)try{go=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=fo(t,location.origin);e&&(mo=[...mo.slice(-19),e])}yo()}),go.observe({type:`resource`,buffered:!0}),_o=setInterval(yo,5e3)}catch{go=void 0}return()=>{vo.delete(e),!vo.size&&(go?.disconnect(),go=void 0,clearInterval(_o),mo=[],ho=null)}}function xo(){return(0,h.useSyncExternalStore)(bo,()=>ho,()=>null)}function So(e){let t=F(e,[`id`,`path`,`cwd`,`epoch`]);return{id:z(t.id),path:O(t.path,4096,!0),cwd:O(t.cwd,4096,!0),epoch:t.epoch===null?null:L(t.epoch)}}function Co(e){let t=F(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:N(t.kind,`project-observation`),status:M(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:L(t.epoch),workspaceId:t.workspaceId===null?null:L(t.workspaceId)}}var wo=[`registry`,`workbench`,`project`],To=[`reboot`,`crash`,`restart`,`storage`],Eo=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function Do(e){let t=F(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:L(t.id),at:A(t.at,0),scope:M(t.scope,wo),path:t.path===null?null:O(t.path,4096,!0),cause:M(t.cause,To),actions:I(t.actions,Eo.length,e=>M(e,Eo)),workers:A(t.workers,0,1e6),archived:j(t.archived)}}function Oo(e){let t=F(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:N(t.kind,`workbench`),epoch:L(t.epoch),csrf:L(t.csrf),home:O(t.home,4096,!0),projects:I(t.projects,128,So),recoveries:I(t.recoveries,20,Do),build:xr(t.build)}}var ko=[`restart`,`upgrade`],Ao=[`running`,`ready`,`failed`,`rolled-back`],jo=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Mo=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function No(e){let t=O(e,96,!0);if(!Mo.test(t))throw new T(`invalid`);return t}function Po(e){let t=F(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:L(t.id),action:M(t.action,ko),from:No(t.from),to:t.to===null?null:No(t.to),state:M(t.state,Ao),reason:t.reason===null?null:M(t.reason,jo),version:t.version===null?null:No(t.version),at:A(t.at,0),endedAt:t.endedAt===null?null:A(t.endedAt,0)}}var Fo=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Io(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function Lo(e){let t=F(e,[`digest`,`items`]);return{digest:z(t.digest),items:I(t.items,256,e=>{let t=F(e,[`project`,`source`,`id`,`sessionId`]);return{project:O(t.project,4096,!0),source:M(t.source,[`turn`,`workflow`]),id:L(t.id),sessionId:t.sessionId===null?null:Ye(t.sessionId)}})}}function Ro(e){let t=F(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=F(t.unit,[`name`,`scope`]);n={name:O(e.name,96,!0),scope:M(e.scope,[`user`,`system`])}}return{kind:N(t.kind,`service`),version:No(t.version),unit:n,upgrade:M(t.upgrade,Fo),work:t.work===null?null:Lo(t.work),job:t.job===null?null:Po(t.job)}}function zo(e){let t=F(e,[`kind`,`version`,`deprecated`]);return{kind:N(t.kind,`release`),version:No(t.version),deprecated:j(t.deprecated)}}function Bo(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}async function Vo(e){return te(await co(e,1048576),1048576)}function Ho(e){return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`code`in e.error?String(e.error.code):`unavailable`}function Uo(e){let t=Error(Ho(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function Wo(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Vo(r);if(!r.ok)throw Error(Ho(i));return t(i)}function Go(e){return Wo(`/workbench/v1/service`,Ro,e)}function Ko(e){return Wo(`/workbench/v1/service/release`,zo,e)}async function qo(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await Vo(n);if(!n.ok)throw Error(Ho(r));let i=F(r,[`kind`,`job`]);return N(i.kind,`service-job`),Po(i.job)}var Jo=1e4,Yo=5e3;function Xo(e){return e===`unauthenticated`||e===`forbidden`}var Zo=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function Qo(e,t,n){if(t.aborted)throw t.reason;let r=performance.now()+Jo,i=gr([t],Jo),a=()=>t.aborted?t.reason:Error(`timeout`),o,s=new Promise((e,t)=>{o=()=>t(a()),i.signal.addEventListener(`abort`,o,{once:!0})}),c=()=>{if(i.signal.aborted||performance.now()>=r)throw a()},l=async()=>{let t=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal});if(c(),t.status===401||t.status===403)throw t.body?.cancel().catch(()=>{}),new Zo(t.status,t.status===401?`unauthenticated`:`forbidden`);let r=await Vo(t);if(c(),!t.ok){let e=Q(r,()=>void 0);throw new Zo(t.status,e.kind===`error`?e.error.code:`unavailable`)}let a=n(r,t);return c(),a};try{return await Promise.race([s,l()])}finally{i.signal.removeEventListener(`abort`,o),i.dispose()}}var $o=class{controller=new AbortController;signal=this.controller.signal;denial;get refusal(){return this.denial}refuse(e,t){Xo(t)&&!this.refusal&&(this.denial={source:e,code:t},this.controller.abort(Error(t)))}check(){if(this.signal.aborted)throw this.signal.reason}waitError(e,t){return Error(this.denial?.code??(e.reason?.name===`TimeoutError`?`timeout`:t))}subscribe=e=>(this.signal.addEventListener(`abort`,e),()=>this.signal.removeEventListener(`abort`,e));snapshot=()=>this.refusal},es=class{api;access;serial=Promise.resolve();version=0;attachmentVersion=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),this.access.signal.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{if(n&&this.version>n)return a(Error(`stale`));this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.readCurrent&&t.attached&&!t.error&&t.transportStatus===`current`&&(!t.observation||t.observation.connection===`current`)&&a()},s=()=>a(this.access.waitError(t,this.latest?.error??`unavailable`));t.aborted||this.access.signal.aborted?s():(this.readiness.add(o),this.access.signal.addEventListener(`abort`,s,{once:!0}),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e,t=new $o){this.api=e,this.access=t}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Ka,l=0,u=0,d,f,p,m=!1,h=0,g=!1,_=!1,v=!1,y=0,b=0,x=!1,S=!1,C=`0`,w=!1,T={readCurrent:!1,actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=T;let E=()=>!r&&n===this.version,D=e=>e.epoch===T.epoch&&e.storeId===f,O=()=>{if(!E())return;let n=c.state;this.latest={...T,error:T.error??p,observation:n,actions:T.readCurrent&&T.actions&&T.transportStatus===`current`&&(!e||n?.connection===`current`)},t(this.latest);for(let e of this.readiness)e(this.latest)},k=()=>{u++,s.abort(),i?.(),i=void 0,T={...T,attached:!1,readCurrent:!1,actions:!1,allocationSignal:void 0}},A=()=>{r||(r=!0,this.access.signal.removeEventListener(`abort`,L),k(),clearInterval(a),clearTimeout(o),n===this.version&&(this.pollCurrent=void 0,this.latest=void 0),_||M(P))};this.stopCurrent=A;let j=()=>{clearTimeout(o),E()&&!_&&(o=setTimeout(N,1e3))},M=e=>{this.serial=this.serial.then(e).catch(e=>{E()&&!_&&(k(),T.error=e instanceof Error?e.message:`unavailable`,T.transportStatus=`stale`,O(),j())})},N=()=>{!E()||_||m||(clearTimeout(o),m=!0,M(async()=>{try{await R()}finally{m=!1}}))},P=async()=>{await d;let e=await this.api.transport.detach();v=!1,e?.kind===`error`&&Xo(e.error.code)&&this.access.refuse(`viewer`,e.error.code)},F=(t=!0)=>{if(!E()||!T.attached||_||d)return d;let n=s.signal,r=y;return T.actions=!1,h=Date.now(),d=I(t,n,r,b).then(t=>{d=void 0,E()&&!n.aborted&&(r===y?(g=!t,t&&(T.workspace=t,T.error=void 0,e||(T.transportStatus=`current`)),T.readCurrent=!!t,T.actions=!!t&&w,O(),!t&&T.error===`stale`?m?j():N():S&&(S=!1,F())):(S=!1,F()))}),O(),d},I=async(t,n,r,i)=>{let a=e=>!E()||n.aborted?!1:e.kind===`error`&&Xo(e.error.code)?(this.access.refuse(`viewer`,e.error.code),!1):r===y;try{if(t){let e=await this.api.client.session(n);if(!a(e))return;if(e.kind===`error`){T.error=e.error.code;return}if(!D(e.value)){T.error=`stale`;return}w=e.value.capabilities.actions}let r=await this.api.client.activeRuns(n);if(!a(r))return;if(r.kind===`ok`){if(!D(r.value)){T.error=`stale`;return}T.activeRuns=r.value}else T.activeRuns=void 0;O();let o=await this.api.client.workspace(n);if(!a(o))return;if(o.kind===`error`){T.error=o.error.code;return}if(!D(o.value)){T.error=`stale`;return}if(e){let t=c.beginSnapshot(),r=await this.api.client.snapshot(e,n);if(!a(r))return;if(r.kind===`error`){T.error=r.error.code;return}if(!D(r.value)){T.error=`stale`;return}if(i!==b||V(r.value.committedSeq,C)<0)return;let o=c.state,s=c.install(r.value,Date.now(),t);s!==void 0&&(l=s,x=!1,T.transportStatus===`current`&&(o?.connection!==`current`||o.snapshot.committedSeq!==r.value.committedSeq)&&(T.transportStatus=`stale`))}return o.value}catch{E()&&!n.aborted&&r===y&&(T.error=`Observation unavailable.`,T.actions=!1,T.transportStatus=`stale`)}},L=()=>{_=!0,k(),T.transportStatus=`closed`,T.error=this.access.refusal?.code,T.workspace=void 0,T.activeRuns=void 0,c=new Ka,clearInterval(a),clearTimeout(o),v&&M(P),O()},R=async()=>{if(!E()||_||(k(),O(),await P(),!E()||_))return;v=!0;let t=y,n=await this.api.client.session(this.access.signal);if(!E()||_)return;if(n.kind===`error`){if(Xo(n.error.code)){v=!1,this.access.refuse(`viewer`,n.error.code);return}throw Error(n.error.code)}if(s=new AbortController,c=new Ka,f=n.value.storeId,b=0,x=S=!1,C=`0`,T={epoch:n.value.epoch,attached:!0,allocationSignal:s.signal,readCurrent:!1,actions:!1,transportStatus:`closed`,attachmentVersion:++this.attachmentVersion},w=n.value.capabilities.actions,O(),await F(t!==y),!E()||_||!e||T.error===`stale`)return;let r=++u,a=e=>{k(),p=e,T.transportStatus=`closed`,T.attachmentVersion=++this.attachmentVersion,j(),O()};i=this.api.transport.subscribe(e,t=>{if(!E()||_||r!==u)return;let n=t.kind===`snapshot`?t.snapshot:t.kind===`event`?t.event:void 0;if(n&&(!D(n)||n.scope.kind!==e.kind||n.scope.id!==e.id)){a(`stale`);return}let i=!1;if(t.kind===`snapshot`){if(V(t.snapshot.committedSeq,C)<0)return;let e=c.install(t.snapshot,Date.now(),c.beginSnapshot());e!==void 0&&(l=e,x=S=!1,i=!0)}else if(t.kind===`event`){if(x&&V(t.event.committedSeq,C)<=0)return;let e=x?`resync`:c.receive(t.event,l,Date.now());if(e===`duplicate`)return;i=e===`applied`}i?(p=void 0,T.transportStatus=`current`):(T.transportStatus=`stale`,n&&V(n.committedSeq,C)>0&&(C=n.committedSeq),x=!0,b++,d?S=!0:F()),O()},e=>{E()&&!_&&r===u&&(e===`closed`?a(p??`socket-closed`):(p=`socket-timeout`,T.transportStatus=`stale`,O()))})};return this.access.signal.aborted?(L(),A):(this.access.signal.addEventListener(`abort`,L,{once:!0}),N(),this.pollCurrent=()=>{E()&&!_&&(y++,T.readCurrent=!1,T.actions=!1,T.attached?d?O():F():N())},a=setInterval(()=>{E()&&!_&&(c.tick(Date.now()),O(),(Date.now()-h>=(g?2e3:3e4)||e&&c.needsPoll(Date.now()))&&F())},1e3),A)}};function ts(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&V(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&H(t.settlement)!==H(r.settlement))?i=!0:(!r||V(t.committedSeq,r.committedSeq)>0||H(r)===H(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function ns(e,t,n=0,r,i=0,a){let o=JSON.stringify(t),s=(0,h.useMemo)(()=>({client:e,key:o,attachmentVersion:i,access:r,allocation:a}),[e,o,i,r,a]),c=(0,h.useRef)(s);c.current=s;let[l,u]=(0,h.useState)(0),d=(0,h.useRef)(0),f=(0,h.useRef)(void 0),[p,m]=(0,h.useState)();(0,h.useEffect)(()=>{if(o===`null`||r?.signal.aborted||a?.aborted)return;let t=new AbortController,i,u=()=>{t.abort(),clearTimeout(i)};f.current=u;let p=r?.subscribe(u);a?.addEventListener(`abort`,u);let h=async()=>{let a=await e.workbenchRead(yn(JSON.parse(o)),t.signal).catch(()=>({kind:`error`,error:E(`unavailable`)}));if(t.signal.aborted||c.current!==s||d.current!==l)return;if(a.kind===`error`&&r&&Xo(a.error.code)){r.refuse(`viewer`,a.error.code);return}m(e=>a.kind===`ok`?{scope:s,revision:l,value:a.value}:{scope:s,revision:l,value:e?.scope===s?e.value:void 0,error:a.error.code});let u=n||(r&&a.kind===`error`?5e3:0);u&&(i=setTimeout(()=>void h(),u))};return h(),()=>{a?.removeEventListener(`abort`,u),p?.(),u()}},[e,o,l,n,r,s,a]);let g=(0,h.useCallback)(()=>{c.current!==s||r?.signal.aborted||(f.current?.(),u(++d.current))},[s,r]),_=!r?.signal.aborted&&!a?.aborted&&p?.scope===s;return{..._?p:{},loading:o!==`null`&&(!_||p.revision!==l),refresh:g}}function rs(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function is(e,t,n=!1){let[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)([]),s=ns(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}function as(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function os(e,t,n){return!t||t.value.status===`unavailable`?{value:e??t?.value,association:`unknown`,error:n??`unavailable`}:{...t,error:void 0}}function ss(e,t,n){let[r,i]=(0,h.useState)(0),a=(0,h.useRef)(0),o=(0,h.useRef)(0),[s,c]=(0,h.useState)({});(0,h.useEffect)(()=>{if(!e||n.signal.aborted)return;let i=++o.current,a=new AbortController,s=()=>!a.signal.aborted&&o.current===i,l,u=()=>{a.abort(),clearTimeout(l)},d=n.subscribe(u),f=(i,a)=>{s()&&(a&&Xo(a)?n.refuse(`project`,a):(c(n=>({id:e,revision:r,selectedEpoch:t,...os(n.id===e?n.value:void 0,i,a)})),l=setTimeout(()=>void p(),Yo)))},p=async()=>{if(s())try{f(await Qo(`/workbench/v1/projects/${e}`,a.signal,(e,t)=>({value:Co(e),association:rn(t.headers.get(nn))})))}catch(e){f(void 0,e instanceof Error?e.message:`unavailable`)}};return p(),()=>{d(),u()}},[e,r,t,n]);let l=(0,h.useCallback)(()=>{if(n.signal.aborted)return a.current;++o.current;let e=++a.current;return i(e),e},[n]),u=t=>{n.check();let r=l();c(n=>({id:e,revision:r,selectedEpoch:t,association:`associated`,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:n.id===e?n.value?.workspaceId??null:null}}))},d=n.refusal?{error:n.refusal.source===`project`?n.refusal.code:void 0}:s.id===e?s:{},f=d.revision===r&&d.selectedEpoch===t;return{...d,association:f?d.association??`unknown`:`unknown`,readiness:as(d.value,d.error,f),refresh:l,prepared:u}}var cs=1e4;function ls(e,t,n,r,i){let[a,o]=(0,h.useState)(0),s=(0,h.useRef)(void 0),c=(0,h.useMemo)(()=>({project:e,task:t,workspaceId:n,epoch:r,access:i,revision:a}),[e,t,n,r,i,a]),l=(0,h.useRef)(c);l.current=c;let[u,d]=(0,h.useState)();(0,h.useEffect)(()=>{let{project:e,workspaceId:t,epoch:n,access:r}=c;if(!e||!t||!n||r.signal.aborted)return;let i=!1,a=()=>!i&&!r.signal.aborted&&l.current===c,o=new Ga(new so({origin:window.location.origin,project:e,retainedHistory:!0,requestTimeoutMs:cs,fetch:async(e,t)=>{if(!a())throw Error(`stale`);let n=await fetch(e,t);if(!a()||t?.signal?.aborted)throw n.body?.cancel().catch(()=>{}),Error(`stale`);return(n.status===401||n.status===403)&&r.refuse(`project`,n.status===401?`unauthenticated`:`forbidden`),n}})),u,f,p=()=>{let e=new AbortController;u=e;let i=()=>a()&&!e.signal.aborted,s=t=>{i()&&(e.abort(),clearTimeout(f),Xo(t)?r.refuse(`project`,t):(d({selection:c,error:t}),f=setTimeout(p,Yo)))};f=setTimeout(()=>s(`timeout`),cs),o.workspace(e.signal).then(e=>{if(!i())return;if(e.kind===`error`)return s(e.error.code);let r=e.value;if(r.workspaceId!==t||r.epoch!==n)return s(`History workspace does not match the selected owner`);clearTimeout(f),d({selection:c,history:{client:o,workspace:{workspaceId:t,epoch:n,storeId:r.storeId,committedSeq:r.committedSeq}}})}).catch(()=>s(`unavailable`))},m=()=>{i=!0,clearTimeout(f),u.abort()};s.current=m;let h=r.subscribe(m);return p(),()=>{s.current=void 0,h(),m()}},[c]);let f=()=>{e&&!i.signal.aborted&&l.current===c&&(s.current?.(),o(e=>e+1))};return!e||i.signal.aborted?{refresh:f}:!r||!n?{error:`History identity not confirmed`,refresh:f}:{...u?.selection===c?u:{},refresh:f}}var us={readCurrent:!1,actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};function ds(e,t,n,r,i){let a=(0,h.useMemo)(()=>new es(e,i),[e,i]),[o,s]=(0,h.useState)(0),c=t?.kind,l=t?.id,u=(0,h.useMemo)(()=>({kind:c,id:l,enabled:n,epoch:r,revision:o,observer:a}),[c,l,n,r,o,a]),[d,f]=(0,h.useState)();return(0,h.useEffect)(()=>{let{enabled:e,kind:t,id:n,observer:r}=u;if(e)return r.observe(t&&n?{kind:t,id:n}:null,e=>f({selection:u,value:e}))},[u]),{...d?.selection===u&&!i.signal.aborted?d.value:us,refresh:()=>a.refresh(),whenReady:(e,t,n)=>a.whenReady(e,t,n),reconnect:()=>{i.check();let e=a.nextObservation();return s(e=>e+1),e}}}var fs=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function ps({client:e,value:t,onChange:n}){let{t:r,tx:i}=Z(),a=(0,h.useRef)(!0),o=(0,h.useRef)(null);(0,h.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,h.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,X.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,X.jsx)(`h3`,{children:r(`Command receipt`)}),(0,X.jsx)(`code`,{children:t.commandId}),t.error&&(0,X.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:r(`Admission`)}),(0,X.jsx)(`dd`,{children:i(l.admission)}),(0,X.jsx)(`dt`,{children:r(`Execution`)}),(0,X.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,X.jsx)(`dt`,{children:r(`Publication`)}),(0,X.jsx)(`dd`,{children:i(l.publication)}),(0,X.jsx)(`dt`,{children:r(`Run`)}),(0,X.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,X.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,X.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function ms(e,t){let n=e??{content:t.content,chunks:[],offset:0},r=n.content,i=t.content;if(r.recordId!==i.recordId||r.version!==i.version||r.field!==i.field||r.sha256!==i.sha256||r.bytes!==i.bytes||n.offset!==(t.range?.start??0))throw Error(`Noncontiguous immutable field`);return{...n,chunks:[...n.chunks,t.text],offset:t.range?.end??0}}function hs(e,t,n){switch(t.reader){case`tasks`:return e.tasks(t,n);case`runs`:return e.runs(t,n);case`messages`:return e.messages(t,n);case`tools`:return e.tools(t,n);case`contents`:return e.contents(t,n);case`events`:return e.events(t,n);case`checks`:return e.checks(t,n);case`changes`:return e.changes(t,n);case`reviews`:return e.reviews(t,n)}}function gs(e,t,n,r){return{storeId:e,scope:t,snapshotSeq:n,query:null,recordId:r.recordId,recordVersion:r.version,field:r.field,offset:0}}async function _s(e,t,n){let r={...t,offset:0};delete r.navigation;let i=null,a=!0;for(;r;){if(n.aborted)throw Error(`canceled`);let t=await e.detail(r,n);if(n.aborted)throw Error(`canceled`);if(t.kind===`error`)throw Error(t.error.code);let o=t.value;r=o.next,`kind`in o||(a&&=o.coverage.observed===`complete`,i=ms(i,o)),await new Promise(e=>setTimeout(e,0))}if(!i||i.offset!==i.content.bytes)throw Error(`incomplete-content`);return{text:i.chunks.join(``),recordingComplete:a}}function vs(e,t){let n=t?H({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,h.useState)(),[a,o]=(0,h.useState)(!1),[s,c]=(0,h.useState)(),[l,u]=(0,h.useState)(t),[d,f]=(0,h.useState)([]),p=(0,h.useRef)(0),[m,g]=(0,h.useState)(n);return m!==n&&(p.current++,g(n),i(void 0),c(void 0),u(t),f([])),(0,h.useEffect)(()=>{let t=++p.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),hs(e,l,n.signal).then(e=>{t===p.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===p.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),p.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&f(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),f(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),f([]),u(t?{...t}:null)}}}function ys({value:e,compact:t=!1}){let{t:n,tx:r}=Z();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,X.jsxs)(`details`,{className:`coverage-details`,children:[(0,X.jsx)(`summary`,{children:n(`Recording details`)}),(0,X.jsx)(ys,{value:e})]}):(0,X.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[n(`Recording: {observed}; source: {source};`,{observed:r(e.observed),source:r(e.source)}),` `,e.redacted?n(`redacted`):n(`no reported redaction`),e.omissions.length>0&&n(`; omitted: {omissions}`,{omissions:e.omissions.map(r).join(`, `)}),n(`. Not a guarantee of complete original source or universal secret detection.`)]})}function bs(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function xs(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return bs(e)}return bs(e)}function Ss(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,h.useRef)(!0),[a,o]=(0,h.useState)(!1),s=(0,h.useRef)(null),c=(0,h.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,h.useCallback)(()=>{c(),o(!1)},[c]);return(0,h.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,h.useCallback)(async e=>{let a=!1;try{a=await xs(e)}catch(e){a=!1,r&&r(e)}return i.current&&(a?(o(!0),c(),s.current=setTimeout(()=>{o(!1),s.current=null},t),n?.(e)):r&&!a&&r(Error(`Copy failed`))),a},[t,n,r,c]),reset:l}}var Cs=r();function ws(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
17
|
+
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,h.createElement)(n.type,i)]]:a.map(e=>[(0,h.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Ts=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Es(!0)},text:{92:Es(!1)}});let t={enter:{backslashMathInline:Ds,backslashMathDisplay:Ds,backslashMathBlock:Ds},exit:{backslashMathInline:Os,backslashMathDisplay:Os,backslashMathBlock:Os}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Es(e){return{tokenize:function(t,n,r){let i=this,a=93,o=e?`backslashMathBlock`:`backslashMathDisplay`,s;return c;function c(e){return e===92?(s=t.enter(o),t.consume(e),l):r(e)}function l(n){return n!==91&&(e||n!==40)?r(n):(a=n===91?93:41,!e&&n===40&&(o=`backslashMathInline`,s.type=o),t.consume(n),u)}function u(n){return n===null||e&&i.parser.lazy[i.now().line]?r(n):n===-5||n===-4||n===-3?(t.enter(`lineEnding`),t.consume(n),t.exit(`lineEnding`),u):(f(n),n===92?d:u)}function d(i){return i===a?(f(i),t.exit(o),e?p:n):i===null?r(i):i===-5||i===-4||i===-3?u(i):(f(i),u)}function f(e){t.enter(`backslashMathData`),t.consume(e),t.exit(`backslashMathData`)}function p(e){return e===null||e===-5||e===-4||e===-3?n(e):e===32||e===-2||e===-1?(t.enter(`whitespace`),t.consume(e),t.exit(`whitespace`),p):r(e)}},concrete:e,name:e?`backslashMathBlock`:`backslashMathText`}}var Ds=function(e){let t=e.type===`backslashMathBlock`,n=e.type!==`backslashMathInline`,r=this.sliceSerialize(e).slice(2,-2).trim(),i={type:`element`,tagName:`code`,properties:{className:[`language-math`,n?`math-display`:`math-inline`]},children:[{type:`text`,value:r}]},a=t?{type:`math`,meta:null,value:r,data:{hName:`pre`,hChildren:[i]}}:{type:`inlineMath`,value:r,data:{hName:`code`,hProperties:i.properties,hChildren:i.children}};this.enter(a,e)},Os=function(e){this.exit(e)};function ks(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var As=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function js(e,t,n=3){let r=[...e.filter(e=>!As(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var Ms=[],Ns=1,Ps=new Set;function Fs(e){if(!(e.length===Ms.length&&e.every((e,t)=>e===Ms[t]))){Ms=e;for(let e of Ps)e()}}function Is(e,t,n){let r=Ns++;return Fs(js(Ms,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function Ls(e){Fs(Ms.filter(t=>t.id!==e))}function Rs(e){Fs(Ms.filter(t=>t.key!==e))}function zs(e){return Ps.add(e),()=>{Ps.delete(e)}}var Bs=()=>Ms,Vs=(0,h.memo)(function({text:e,label:t,className:n=`copy-btn`}){let{t:r}=Z(),{copied:i,copy:a}=Ss();return(0,X.jsx)(`button`,{type:`button`,className:i?`${n} copied`:n,title:t??r(`Copy displayed text`),"aria-label":t??r(`Copy displayed text`),onClick:()=>{a(e).then(e=>{e||Is(`error`,r(`Copy unavailable`))})},children:i?(0,X.jsx)(Fa,{}):(0,X.jsx)(Da,{})})}),Hs=[l,p,Ts],Us=[l,d,p,Ts],Ws=[[u,{strict:!1,throwOnError:!1,errorColor:`var(--err-text)`,trust:!1,maxExpand:1e3}],[f,{detect:!1,ignoreMissing:!0}]];function Gs(e){if(e.startsWith(`#`)&&![...e].some(e=>e.charCodeAt(0)<=32))return e;try{let t=new URL(e);return![`https:`,`http:`].includes(t.protocol)||t.username||t.password||t.searchParams.has(`token`)?void 0:e}catch{return}}function Ks({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,X.jsx)(o,{remarkPlugins:n?Us:Hs,remarkRehypeOptions:{footnoteLabelProperties:{className:[`sr-only`],dataFieldChrome:``}},rehypePlugins:t?[a,s,...Ws]:Ws,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Zs,a:Js,img:({alt:e})=>(0,X.jsxs)(`span`,{className:`omission`,children:[(0,X.jsx)(`span`,{"data-field-chrome":``,children:`[Image omitted: `}),e||(0,X.jsx)(`span`,{"data-field-chrome":``,children:`external/media content`}),(0,X.jsx)(`span`,{"data-field-chrome":``,children:`]`})]})},children:e})}var qs=(0,h.memo)(function(e){return(0,X.jsx)(`div`,{className:`md`,children:(0,X.jsx)(Ks,{...e})})});function Js({href:e,children:t,...n}){let r=e&&Gs(e);return r?(0,X.jsx)(`a`,{"data-field-chrome":`data-footnote-ref`in n||`data-footnote-backref`in n?``:void 0,href:r,target:r.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,X.jsxs)(`span`,{children:[t,(0,X.jsx)(`span`,{"data-field-chrome":``,children:` [link unavailable]`})]})}var Ys=new WeakMap;function Xs(e){let t=e.startContainer.parentElement?.closest(`pre`),n=t&&Ys.get(t);n&&(0,Cs.flushSync)(n)}function Zs({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=e&&typeof e==`object`&&`props`in e?String(e.props.className??``).match(/(?:^|\s)language-([^\s]+)/)?.[1]:void 0,{locale:a}=Z(),[o,s]=(0,h.useState)(!0),c=0,l=ws(r).map(e=>{let t=`code-offset:${c}`;return c+=Qs(e).length+1,{key:t,nodes:e}}),u=l.length>1,d=u?`${String(l.length).length+1}ch`:void 0;return(0,X.jsxs)(`div`,{className:`codeblock`,children:[(0,X.jsxs)(`div`,{"data-field-chrome":``,className:`code-caption`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:()=>s(!o),children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,children:o?`▾`:`▸`}),i||(a===`zh`?`代码`:`Code`)]}),(0,X.jsx)(Vs,{text:Qs(e),className:`output-copy`})]}),(0,X.jsx)(`pre`,{...n,hidden:!o,ref:o?void 0:e=>{if(e)return Ys.set(e,()=>s(!0)),()=>{Ys.delete(e)}},children:l.map(({nodes:e,key:t},n)=>(0,X.jsxs)(`div`,{className:`code-line`,children:[u&&(0,X.jsx)(`span`,{"data-field-chrome":``,className:`code-num`,style:d?{width:d}:void 0,children:n+1}),(0,X.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Qs(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Qs).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Qs(t?.children)}return``}function $s(e,t){let n=[],r=t;if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(t){let n=t.parentElement;return!n||!e.contains(n.closest(`[data-retained-field]`))||n.closest(`[data-field-chrome], .katex-mathml, .search-bar, .msg-collapsed`)?NodeFilter.FILTER_REJECT:(t.textContent??``).includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=e.textContent??``,i=t.indexOf(r);for(;i!==-1;){let a=document.createRange();if(a.setStart(e,i),a.setEnd(e,i+r.length),n.push(a),n.length===1e3)return n;i=t.indexOf(r,i+r.length)}}return n}var ec=new Map;function tc(e,t){t.length?ec.set(e,t):ec.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...ec].filter(([e])=>e.endsWith(`-active`)===n).flatMap(([,e])=>e);let r=CSS;if(!r.highlights)return;if(t.length===0){r.highlights.delete(e);return}let i=window.Highlight;i&&r.highlights.set(e,new i(...t))}function nc(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function rc(e,t){let n=t.startContainer.parentElement;for(let r of nc(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function ic({container:e,version:t}){let{t:n}=Z(),[r,i]=(0,h.useState)(``),[a,o]=(0,h.useState)(0),[s,c]=(0,h.useState)(0),l=(0,h.useRef)([]),u=`cadence-page-${(0,h.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,h.useLayoutEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?$s(n,r):[];return l.current=i,c(i.length),o(0),tc(u,i),()=>{l.current=[],tc(u,[]),tc(`${u}-active`,[])}},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0,i=e.current,c=l.current[n];if(!i||!c||!i.contains(c.commonAncestorContainer)||(Xs(c),e.current!==i||!i.isConnected||l.current[n]!==c||!i.contains(c.commonAncestorContainer)||c.toString()!==r))return;let{width:d,height:f}=c.getBoundingClientRect();d&&f&&(rc(document.documentElement,c),o(n),tc(`${u}-active`,[c]))};return(0,X.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,X.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,X.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,X.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,X.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,X.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function ac({client:e,cursor:t,highlight:n,preview:r,compact:i=!1}){let{t:a,tx:o}=Z(),s=H(t),c=(0,h.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,h.useState)(t),[d,f]=(0,h.useState)(),[p,m]=(0,h.useState)([]),[g,_]=(0,h.useState)(!1),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(i?`markdown`:`raw`),[S,C]=(0,h.useState)(``),w=(0,h.useRef)(null),T=(0,h.useRef)(null);(0,h.useEffect)(()=>(u(c),m([]),f(void 0),y(void 0),()=>w.current?.abort()),[c]),(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return _(!0),y(void 0),e.detail(l,n.signal).then(e=>{t&&(_(!1),e.kind===`error`?y(e.error.code):f(e.value))}).catch(()=>{t&&(y(`Read unavailable.`),_(!1))}),()=>{t=!1,n.abort()}},[e,l]);let E=async()=>{if(w.current)return;let n=new AbortController;w.current=n,C(a(`Reading all retained field pages…`));try{let r=await _s(e,t,n.signal);if(n.signal.aborted)return;let i=await xs(r.text);if(n.signal.aborted)return;C(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||C(a(`Full-field copy refused/incomplete.`))}finally{w.current===n&&(w.current=null)}},D=d&&!(`kind`in d)?d:void 0,O=D?H(D.cursor):``;return(0,X.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,X.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,X.jsx)(`summary`,{children:a(`Field details`)}),(0,X.jsxs)(`div`,{className:`detail-identity`,children:[(0,X.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,X.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,X.jsxs)(`div`,{className:`toolbar`,children:[!r&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>x(e=>e===`raw`?`markdown`:`raw`),children:a(b===`raw`?`Markdown page`:`Raw page`)}),(0,X.jsx)(`button`,{type:`button`,disabled:!!w.current,onClick:()=>void E(),children:a(`Copy full retained field`)}),!!w.current&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>{w.current?.abort(),w.current=null,C(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),S&&(0,X.jsx)(`p`,{role:`status`,children:S}),v&&(0,X.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(v)})}),g&&(0,X.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,X.jsx)(ys,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,X.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),D&&(0,X.jsxs)(X.Fragment,{children:[(!i||D.next)&&(0,X.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:D.range?.start??0,end:D.range?.end??0,total:D.content.bytes}),` `,D.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,X.jsx)(ic,{container:T,version:`${O}:${r?.view??b}`}),(0,X.jsx)(`div`,{ref:T,children:r?(0,X.jsx)(`div`,{children:r.render(D.text)},O):(0,X.jsx)(`div`,{"data-retained-field":!0,children:b===`markdown`?(0,X.jsx)(qs,{text:D.text}):(0,X.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!D||!n||!D.range)return D?.text;let e=Math.max(n.start,D.range.start)-D.range.start,t=Math.min(n.end,D.range.end)-D.range.start;if(t<=e)return D.text;let r=new TextEncoder().encode(D.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,X.jsxs)(X.Fragment,{children:[i(0,e),(0,X.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})})]}),(!i||p.length>0||d?.next)&&(0,X.jsxs)(`div`,{className:`toolbar`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:g||!p.length,onClick:()=>{u(p[p.length-1]),m(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,X.jsx)(`button`,{type:`button`,disabled:g||!d?.next,onClick:()=>{d?.next&&(m(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function oc({pager:e,compact:t=!1}){let{t:n,tx:r}=Z(),{page:i,busy:a,error:o}=e;return(0,X.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,X.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,X.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,X.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,X.jsx)(ys,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,X.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,X.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,X.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,X.jsx)(Xi,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,X.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function sc({client:e,seed:t,entityId:n}){let{t:r,tx:i}=Z(),a=vs(e,{...t,reader:`contents`}),[o,s]=(0,h.useState)(),c=a.page;return(0,X.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,X.jsx)(oc,{pager:a}),n&&(0,X.jsx)(`p`,{children:(0,X.jsx)(rr,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,X.jsx)(`code`,{children:n})}})}),c&&!(`kind`in c)&&c.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,X.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,X.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,X.jsxs)(`article`,{children:[(0,X.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,X.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,X.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,X.jsx)(ys,{value:e.coverage}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(gs(c.request.storeId,c.request.scope,c.request.snapshotSeq,e.content))},children:r(`Inspect complete retained field`)})]},`${e.content.recordId}:${e.content.version}`)),o&&(0,X.jsx)(ac,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function cc({client:e,seed:t}){return(0,X.jsx)(lc,{client:e,seed:t},H(t))}function lc({client:e,seed:t}){let{t:n,tx:r}=Z(),[i,a]=(0,h.useState)(t),[o,s]=(0,h.useState)(),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(i.kind===`message`?e.message(i,n.signal):i.kind===`tool`?e.tool(i,n.signal):e.task(i,n.signal)).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,X.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,X.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,X.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,X.jsx)(ys,{value:o.coverage}),o&&(`kind`in o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,X.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,X.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function uc(e){let t=ao(`download`,oi(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=qn()+t.path,n.download=`cadence-${e.scope.kind}-${e.scope.id}.${e.format===`markdown`?`md`:`ndjson`}`,n.referrerPolicy=`no-referrer`,document.body.appendChild(n),n.click(),n.remove()}function dc({title:e,children:t,onClose:n}){let{t:r}=Z(),i=(0,h.useRef)(null),a=(0,h.useId)(),o=(0,h.useRef)(n);return o.current=n,(0,h.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,X.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h2`,{id:a,children:e}),n&&(0,X.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]}),t]})}function fc({request:e,onClose:t}){let{t:n,tx:r}=Z(),[i]=(0,h.useState)(e),[a,o]=(0,h.useState)(e.format),[s,c]=(0,h.useState)(``);return(0,X.jsxs)(dc,{title:n(`Export retained history`),onClose:t,children:[(0,X.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,X.jsxs)(`label`,{children:[n(`Format`),(0,X.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,X.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,X.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,X.jsx)(`p`,{children:n(`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`)}),(0,X.jsx)(`p`,{children:n(`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{try{uc({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,X.jsx)(`p`,{role:`status`,children:s})]})}function pc(e,t){if(!t||k(t)>C.queryBytes)throw Error(`Query must be 1–${C.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function mc(e){return e.next?`No hits in this bounded window; search is not finished.`:`No hits in the final retained window. Coverage limits above still apply.`}function hc({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=Z(),[o]=(0,h.useState)(t),s=(0,h.useRef)(null),c=(0,h.useRef)(0),[l,u]=(0,h.useState)(``),[d,f]=(0,h.useState)(0),p=(0,h.useId)(),m=(0,h.useRef)(null),g=(0,h.useRef)(null),_=(0,h.useRef)(!1),[v,y]=(0,h.useState)(),[b,x]=(0,h.useState)(!1),[S,C]=(0,h.useState)(),w=(0,h.useRef)(null),T=(0,h.useCallback)(async(t,n)=>{w.current?.abort();let r=new AbortController;w.current=r,x(!0),C(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?C(i.error.code):(_.current=!0,y(i.value),f(0))}catch{c.current===n&&!r.signal.aborted&&C(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&x(!1)}},[e]);(0,h.useEffect)(()=>(s.current?.focus(),()=>{c.current++,w.current?.abort()}),[]),(0,h.useEffect)(()=>{let e=++c.current;if(w.current?.abort(),x(!1),y(void 0),f(0),C(void 0),!l)return;let t;try{t=pc(o,l)}catch{C(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void T(t,e),300);return()=>{clearTimeout(n),c.current++,w.current?.abort()}},[l,o,T]);let E=v?.cursor.query===l?v:void 0,D=E?.hits[d],O=({content:e,range:t})=>`${p}-${e.recordId}-${e.version}-${e.field}-${t.start}-${t.end}`;return(0,h.useLayoutEffect)(()=>{if(!D||!_.current||!m.current||!g.current)return;let e=m.current,t=g.current.getBoundingClientRect(),n=e.getBoundingClientRect().top+e.clientTop,r=n+e.clientHeight;t.top<n||t.height>e.clientHeight?e.scrollTop+=Math.floor(t.top-n):t.bottom>r&&(e.scrollTop+=Math.ceil(t.bottom-r))},[D]),(0,X.jsx)(dc,{title:i(`Search retained history`),onClose:n,children:(0,X.jsxs)(`div`,{className:`gs-modal`,children:[(0,X.jsxs)(`div`,{className:`gs-input-row`,children:[(0,X.jsx)(Ji,{}),(0,X.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),role:`combobox`,"aria-autocomplete":`list`,"aria-expanded":!!D,"aria-controls":p,"aria-activedescendant":D?O(D):void 0,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{if(D&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),_.current=!0;let t=e.key===`ArrowDown`?1:-1;f(e=>Math.max(0,Math.min(e+t,E.hits.length-1)))}e.key===`Enter`&&(e.preventDefault(),r(D),n())}}})]}),(0,X.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,X.jsxs)(`div`,{className:`gs-results`,ref:m,children:[b&&(0,X.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),S&&(0,X.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(S)})}),!l&&(0,X.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),E&&(0,X.jsx)(ys,{value:E.coverage}),(0,X.jsxs)(`div`,{className:`gs-section`,hidden:!E,children:[(0,X.jsx)(`div`,{className:`gs-section-head`,id:`${p}-label`,children:i(`Matches on this page: {count}`,{count:E?.hits.length??0})}),(0,X.jsx)(`div`,{role:`listbox`,id:p,"aria-labelledby":`${p}-label`,hidden:!D,children:E?.hits.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,role:`option`,tabIndex:-1,id:O(e),ref:D===e?g:void 0,"aria-selected":D===e,className:`gs-item`,onMouseDown:e=>e.preventDefault(),onMouseMove:()=>{_.current=!1,e!==D&&f(t)},onClick:()=>{r(e),n()},children:[(0,X.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,X.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,X.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` /`,` `,i(`bytes {start}–{end}`,{start:e.range.start,end:e.range.end})]})]},O(e)))}),E&&E.hits.length===0&&(0,X.jsx)(`p`,{children:a(mc(E))})]}),E&&(0,X.jsx)(`button`,{type:`button`,disabled:b||!E.next,onClick:()=>{E.next&&(s.current?.focus({preventScroll:!0}),T(E.next,++c.current))},children:i(`Continue same snapshot search`)})]}),(0,X.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function gc({run:e,historical:t=!1}){let{t:n,tx:r}=Z();return(0,X.jsxs)(`article`,{className:`run-summary`,children:[(0,X.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,X.jsx)(`p`,{children:(0,X.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,X.jsx)(`dd`,{children:r(e.lifecycle)}),(0,X.jsx)(`dt`,{children:n(`Execution`)}),(0,X.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,X.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,X.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,X.jsx)(`dt`,{children:n(`Summary publication`)}),(0,X.jsx)(`dd`,{children:r(e.publication)})]}),(0,X.jsx)(ys,{value:e.coverage}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,X.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function _c({client:e,seed:t}){return(0,X.jsx)(vc,{client:e,seed:t},H(t))}function vc({client:e,seed:t}){let{t:n,tx:r}=Z(),[i,a]=(0,h.useState)(t),[o,s]=(0,h.useState)(),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1);return(0,h.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),e.graph(i,n.signal).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,X.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,X.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,X.jsx)(ys,{value:o.coverage}),o&&(`kind`in o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,X.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ac,{client:e,cursor:gs(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,X.jsxs)(`article`,{children:[(0,X.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,X.jsx)(qs,{text:e.instructions}),(0,X.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,X.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function yc({client:e,seed:t,onScope:n}){let{t:r}=Z(),i=vs(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,h.useState)();return(0,X.jsxs)(`section`,{children:[(0,X.jsx)(oc,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,X.jsxs)(`article`,{children:[(0,X.jsx)(gc,{run:e.projection,historical:!0}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,X.jsx)(_c,{client:e,seed:o},o.graph.recordId)]})}function bc({onOpen:e,disabled:t}){let{t:n}=Z();return(0,X.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,X.jsx)(Ji,{"aria-hidden":`true`})})}function xc(e,t,n,r,i){let a=i??t,o=[],s=[],c=0;for(let i of e)n.has(i.id)||(r.has(i.id)?i.top<t.bottom&&i.bottom>t.top&&o.push(i.id):i.top<a.bottom&&i.bottom>a.top||(s.push(i.id),i.bottom<=a.top&&(c+=i.bottom-i.top)));return{show:o,hide:s,shrinkAbove:c}}function Sc(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function Cc(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??wc(n.role,n.customType)}return r}function wc(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`tool-result`:return 120;case`custom`:return t===`file`?96:72;default:return 60}}function Tc(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Ec(e,t,n=null,r=1800,i){let a=(0,h.useRef)(i);a.current=i;let o=(0,h.useRef)(null),[s,c]=(0,h.useState)(()=>new Set),l=(0,h.useRef)(s);l.current=s;let u=(0,h.useRef)(new Map),d=(0,h.useRef)(new Map),f=(0,h.useRef)(new Map),p=(0,h.useRef)(0),m=(0,h.useRef)(new Map);m.current=new Map(t.map(e=>[e.id,e.version]));let g=(0,h.useRef)(new Set);g.current=Cc(t,u.current,r),n!==null&&g.current.add(n);let _=(0,h.useCallback)((e,t)=>{let n=m.current.get(e);n!==void 0&&(d.current.set(e,{h:t,len:n}),u.current.set(e,t))},[]),v=(0,h.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of f.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),l.current.has(e)||_(e,n.height)}let i=xc(r,{top:n.top-1200,bottom:n.bottom+1200},g.current,l.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=f.current.get(e);t&&_(e,t.offsetHeight)}c(e=>Sc(e,i))},[_,e]),y=(0,h.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,v()})},[v]);return(0,h.useLayoutEffect)(()=>{t.length?v():c(new Set)},[v,t,n]),(0,h.useEffect)(()=>{let t=new ResizeObserver(()=>{y(),a.current?.()});o.current=t,e.current&&t.observe(e.current);for(let e of f.current.values())t.observe(e);return()=>{o.current=null,t.disconnect(),cancelAnimationFrame(p.current),p.current=0}},[y,e]),{hidden:s,scheduleSweep:y,recordMeasured:_,register:(0,h.useCallback)(e=>t=>{let n=f.current.get(e);n&&n!==t&&o.current?.unobserve(n),t?(f.current.set(e,t),o.current?.observe(t)):f.current.delete(e)},[]),placeholder:(0,h.useCallback)((e,t,n)=>Tc(e,t,d.current,n),[])}}function Dc(e,t){e&&t&&(e.scrollTop=e.scrollHeight)}function Oc(e,t,n){(0,h.useEffect)(()=>{let r=new ResizeObserver(()=>Dc(e.current,n.current));return t.current&&r.observe(t.current),()=>r.disconnect()},[e,t,n])}var kc=(0,h.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,h.useRef)(null);return(0,h.useLayoutEffect)(()=>{if(!t)return;let n=s.current;if(!n)return;let r=n.offsetHeight;r>0&&i?.(e,r)},[t,e,i]),t?(0,X.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,X.jsx)(`div`,{ref:s,children:o})}):(0,X.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Ac=(0,h.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=Z(),[a,o]=(0,h.useState)(!1);return(0,X.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,X.jsxs)(`header`,{className:`msg-meta`,children:[(0,X.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,X.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,X.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,X.jsx)(ja,{"aria-hidden":`true`}):(0,X.jsx)(ya,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,X.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,X.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,X.jsx)(`div`,{className:`msg-text`,children:(0,X.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,X.jsx)(ac,{compact:!0,client:t,cursor:gs(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,X.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,X.jsxs)(`div`,{className:`message-inspection`,children:[(0,X.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,X.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,X.jsxs)(`details`,{open:!0,children:[(0,X.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,X.jsx)(sc,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function jc({messages:e,client:t,seed:n}){let{t:r}=Z(),i=(0,h.useRef)(null),a=(0,h.useRef)(!0),o=(0,h.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=Ec(i,o);return(0,X.jsxs)(`div`,{className:`messages-wrap`,children:[(0,X.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,X.jsx)(kc,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,X.jsx)(Ac,{message:a,client:t,seed:n})},e))}),(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,X.jsx)(Ba,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Mc({client:e,seed:t}){let{t:n}=Z(),r=vs(e,{...t,reader:`messages`}),i=r.page;return(0,X.jsxs)(`section`,{className:`transcript`,children:[(0,X.jsx)(oc,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,X.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,X.jsxs)(X.Fragment,{children:[i.records.length===0&&(0,X.jsx)(`p`,{className:`empty-note panel-empty`,children:i.next?n(`No message records on this page; more history remains.`):n(`No message records on this page.`)}),(0,X.jsx)(jc,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Nc({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,X.jsxs)(`div`,{className:`chead ${n}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,X.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,X.jsx)(Pa,{}):(0,X.jsx)(Ma,{})}):c,(0,X.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,X.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Pc=(0,h.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=Z(),[a,o]=(0,h.useState)(!1),s=e.result?e.result.isError?r(`SDK tool error observed`):r(`SDK tool end observed`):e.startObserved?r(`Start observed; end not observed in this snapshot`):r(`No start observed`),c=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,X.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,X.jsx)(Nc,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,X.jsx)(Vi,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,X.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[(0,X.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:r(`Source ID`)}),(0,X.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,X.jsx)(`dt`,{children:r(`Declaration`)}),(0,X.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(`Recorded tool end (not parsed from output)`),e.result&&(0,X.jsx)(Vs,{text:JSON.stringify(e.result,null,2),className:`output-copy`})]}),(0,X.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,X.jsx)(`div`,{className:`toolcall-args`,children:(0,X.jsx)(sc,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Fc=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function Ic({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=Z(),s=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(Fc(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length),c=!!t||e?.completeness===`partial`;return!s?.length&&!c?null:(0,X.jsx)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:(0,X.jsxs)(`div`,{className:`lp-section-body`,children:[c&&(0,X.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),s?.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,X.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,X.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,X.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,X.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})})}function Lc(e){return e.replace(/(?:-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})+$/i,``)}function Rc(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var zc=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function Bc(e,t){return zc.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function Vc(e){let t=Rc(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function Hc(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>Lc(e.id)===n.id),...r?{artifact:r}:{}}})}var Uc=[`queued`,`running`];function Wc(e,t){let n=e=>Number(!Uc.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function Gc(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(Lc(t.id))):!1}var Kc=[`queued`,`running`];function qc({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=Z(),o=Rc(e),s=n?.runId===e.id?n.stepId:void 0,c=s===null;return(0,X.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,X.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${c?` active`:``}`,"aria-current":c||void 0,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,X.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,X.jsx)(`span`,{className:`agent-dock-run-state`,children:Bc(o,i)})]}),t.map(t=>{let n=s===t.id,o=Lc(t.id),c=e.tasks?.find(e=>e.id===o);return(0,X.jsxs)(`button`,{type:`button`,className:`agent-dock-row${n?` active`:``}`,"aria-current":n||void 0,title:c?`${c.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:o}),children:[(0,X.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,X.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,X.jsx)(`strong`,{children:`${a(t.kind)} · ${o}`}),c&&(0,X.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(c.state)})})]}),(0,X.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function Jc(e){let{t,tx:n}=Z(),[r,i]=(0,h.useState)(null),a=e.kind===`conversation`?e.groups.flatMap(e=>e.steps):[],o=e.kind===`task`?e.runs.flatMap(e=>e.childRunId?[{run:e,id:e.childRunId}]:[]).sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)):[],s=a.length+o.length,c=a.filter(e=>Kc.includes(e.status)).length+o.filter(({run:e})=>e.lifecycle!==`settled`).length,l=r??s>0;return(0,X.jsxs)(`section`,{className:`agent-dock${l?``:` collapsed`}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":l,onClick:()=>i(!l),children:[(0,X.jsx)(Pa,{}),(0,X.jsx)(wa,{}),(0,X.jsx)(`span`,{children:t(`Subagents`)}),(0,X.jsx)(`span`,{className:`lp-count${c?` live`:``}`,children:c?t(`{active} active · {total} total`,{active:c,total:s}):s||(e.unavailable?`—`:0)})]}),l&&(0,X.jsxs)(`div`,{className:`agent-dock-body`,children:[e.unavailable?(0,X.jsx)(`p`,{className:`panel-hint`,children:t(`Subagent roster unavailable`)}):s===0&&(0,X.jsx)(`p`,{className:`panel-hint`,children:t(`Cadence research, implementation and review agents appear here.`)}),e.kind===`conversation`?e.groups.map(({run:t,steps:n})=>(0,X.jsx)(qc,{run:t,steps:n,selected:e.selected,onOpen:e.onOpen},t.id)):o.map(({run:r,id:i})=>(0,X.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>e.onOpen(i,r.assignmentId??t(`Subagent`)),children:[(0,X.jsx)(`span`,{className:`agent-dot ${r.outcome??r.lifecycle}`}),(0,X.jsx)(`span`,{className:`agent-dock-label`,children:(0,X.jsx)(`strong`,{children:r.assignmentId??t(`Subagent`)})}),(0,X.jsx)(`span`,{className:`ep-state ${r.outcome??r.lifecycle}`,children:n(r.outcome??r.lifecycle)})]},i))]})]})}function Yc(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function Xc(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var Zc=e=>e.filter(e=>e.current);function Qc(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function $c(e,t,n,r,i){let[a,o]=(0,h.useState)();(0,h.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=ns(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,h.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,f]=(0,h.useState)();return(0,h.useEffect)(()=>{u&&f(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function el({view:e,onChosen:t}){let{t:n,locale:r}=Z(),[i,a]=(0,h.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,h.useMemo)(()=>Yc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,X.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,X.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,X.jsxs)(`label`,{className:`lp-filter`,children:[(0,X.jsx)(Ji,{"aria-hidden":`true`}),(0,X.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,X.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]}),(0,X.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,X.jsx)(Xi,{"aria-hidden":`true`})})]}),(0,X.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,X.jsxs)(`p`,{className:`branches-pinned`,children:[(0,X.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,X.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:nr(n,e.error)}),s?.truncated&&(0,X.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,X.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,X.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,X.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,X.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,X.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,X.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,X.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,X.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,X.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,X.jsx)(xa,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,X.jsx)(Ea,{"aria-hidden":`true`})})]},t.id))})]})}function tl(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function nl(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function rl(e,t){return Math.round(e/t*100)}var il=e=>e.trim().split(`
|
|
18
|
+
`,1)[0].slice(0,200);function al(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var ol=(e,t)=>e?e.entry:t,sl=(e,t)=>e!==null&&t>=e.from;function cl(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:on(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function ll(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function ul(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function dl(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function fl(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function pl(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}function ml(e){for(let t of e){if(!v.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function hl(e){ml([e]);let t=new Uint8Array(await e.arrayBuffer());return b(t,e.type),t}var gl=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)};async function _l(e,t,n,r){ml(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await hl(a);if(!r())throw Error(`stale`);let o=gl(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=_.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+_.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function vl(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>_.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==_.chunkChars)throw Error(`invalid`)}let i=y(n.join(``));return b(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var yl=e=>e.renderId??`legacy:${e.id}`;function bl(e,t){let n=new Map(e.map(e=>[yl(e),e])),r=new Set;return t.map(e=>{let t=yl(e);if(r.has(t))throw new Tl(`stale`);r.add(t);let i=n.get(t);return i&&JSON.stringify(i)===JSON.stringify(e)?i:e})}var xl=1e3,Sl=1e4,Cl=4,wl=e=>e===`starting`||e===`queued`||e===`running`,Tl=class extends Error{},El=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;cache;count=0;first=null;opening=null;turns=new Map;imageReaders=new Map;error=``;loadingEarlier=!1;inFlight;attachment=null;observation=null;again=!1;closed=!1;active=!1;timer;selection=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e,t=null){(this.active!==e||this.attachment!==t)&&(this.retireSync(),this.active=e,this.attachment=t,this.observation&&(this.observation=null,this.publish()),e&&this.tick())}retireSync(){clearTimeout(this.timer),this.inFlight?.abort(),this.inFlight=void 0,this.again=!1}close(){this.closed=!0,this.retireSync(),this.selection.abort()}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.retireSync(),this.selection.abort(),this.selection=new AbortController,this.observation=null,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{observation:this.observation,summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...this.cache?{cache:this.cache}:{},count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.inFlight){this.again=!0;return}let e=new AbortController;this.inFlight=e,clearTimeout(this.timer);let t=this.loadingEarlier;try{await this.sync(e.signal,this.attachment)}catch(t){if(e.signal.aborted)return;e.abort(),this.observation=null,this.error=t instanceof Tl?t.message:`unavailable`}if(this.inFlight!==e)return;if(this.inFlight=void 0,t&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=this.error===`stale`||wl(this.summary?.status)||[...this.turns.values()].some(e=>wl(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?xl:Sl)}async sync(e,t){let n=this.pinned,r=await this.read({kind:`conversation`,id:this.id,leaf:n,known:this.leaf},e);if(e.aborted)return;if(r.kind!==`conversation`)throw new Tl(`invalid`);let i=!r.continues||r.turns<this.count,a=r.leaf===this.leaf?this.count:this.count-1,o=Math.max(0,r.turns-2),s=Math.min((i?null:this.first)??this.opening??o,o),c=[];for(let e=s;e<r.turns;e++){let n=i?void 0:this.turns.get(e);(!n||e>=a||t!==this.observation&&e===r.turns-1||n.header.stable<n.header.steps||wl(n.header.status))&&c.push(e)}let l=await Promise.all(c.map(t=>this.load(t,r.leaf,e,i?void 0:this.turns.get(t))));if(!e.aborted){i&&this.forget(),this.leaf=r.leaf,this.branches=r.branches,this.runs=r.runs,this.attempt=r.attempt,this.pending=r.pending??[],this.undelivered=r.undelivered??[],this.commands=r.commands??[],this.context=r.context,this.cache=r.cache,this.summary=r.summary,this.observation=t,this.error=``,this.count=r.turns,this.first=Math.min(s,this.first??s),this.opening=null;for(let e of l)this.turns.set(e.ordinal,e)}}async load(e,t,n,r){let i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,a.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{let n=i.start+t;if(r?.header.id===a.id&&n<Math.min(r.header.stable,a.stable)&&yl(r.steps[n])!==yl(e))throw new Tl(`stale`);o[n]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n)))){if(JSON.stringify(r.turn)!==JSON.stringify(a))throw new Tl(`stale`);r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)})}if(n.aborted||o.includes(void 0))throw new Tl(`stale`);let l=bl(r?.steps??[],o);return r&&r.image===this.imageReader(t,this.selection.signal)&&JSON.stringify(r.header)===JSON.stringify(a)&&r.steps.length===l.length&&l.every((e,t)=>e===r.steps[t])?r:{ordinal:e,renderId:l.find(e=>e.role===`user`)?.renderId??a.id,header:a,steps:l,detail:this.detail(t,a.id,l,this.selection.signal),image:this.imageReader(t,this.selection.signal)}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new Tl(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=gr([t,r]);try{return await vl(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n,r){return async(i,a,o)=>{let s=n[i];if(!s)throw new Tl(`stale`);let c=await Promise.all(Array.from({length:a},async(n,a)=>{let c=gr([r,o]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:i,part:a},c.signal);if(n.kind!==`conversation-step`||n.part!==a||n.conversationId!==this.id||n.leaf!==e||n.turnId!==t||n.step!==i)throw new Tl(`invalid`);if(s.renderId&&n.item.renderId!==s.renderId||s.version&&n.item.version!==s.version)throw new Tl(`stale`);return n.item}finally{c.dispose()}}));return{text:c.map(e=>e.text).join(``),args:c.map(e=>e.args).join(``)}}}async read(e,t){this.reads>=Cl&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Tl(`stale`);let n=await this.client.workbenchRead(e,t);if(this.closed||t.aborted)throw new Tl(`stale`);if(n.kind===`error`)throw new Tl(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}},Dl=2e4;async function Ol(e,t,n,r){let i=gr([t],Dl);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function kl(e,t){if(t===`none`)return`Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.`;switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function Al(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function jl(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function Ml(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Nl(e){let t={commandId:crypto.randomUUID(),conversationId:Ye(e.id),head:e.head===null?null:on(e.head)},n=e.location?Xe(e.location):void 0;if(n&&n.id!==t.conversationId)throw new T(`stale`);let r=O(e.text,ln,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:A(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:A(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Pl(e.model))}:{}})}function Pl(e){return ce({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Fl(e,t){return Object.freeze({...e,model:Object.freeze(Pl(t))})}function Il(e,t){if(e.model&&H(e.model)!==H(Pl(t)))throw new T(`stale`)}function Ll(e,t){return Object.freeze({...e,preparedEpoch:L(t)})}function Rl(e,t,n){return Object.freeze({...Fl(e,t),installModel:!n})}function zl(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function Bl(e,t){return!!e&&e===t}async function Vl(e,t,n,r){if(!r())throw new T(`stale`);if(!t.installModel||!t.model)return n;if(!nt(n.entries,t.model))throw new T(`unsupported-context`);if(n.selected&&H(Pl(n.selected))===H(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new T(`stale`);if(i.kind===`error`)throw new T(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new T(`stale`);if(a.kind===`error`)throw new T(a.error.code);if(!a.value.selected||H(a.value.version)!==H(i.value.version)||H(a.value.selected)!==H(i.value.selected))throw new T(`stale`);return Il(t,a.value.selected),a.value}function Hl(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&H(e.location)!==H(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new T(`stale`);let n=xn(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new T(`invalid`);return n}function Ul(e,t,...n){let r=`cadence:draft:${e}:${t}`;try{let e=e=>[e,`${e}:pending`,`${e}:mode`].some(e=>sessionStorage.getItem(e)!==null);if(e(r))return r;for(let r of n){if(!r)continue;let n=`cadence:draft:${r}:${t}`;if(e(n))return n}}catch{}return r}function Wl(e,t,n,r,i=null){let a=(0,h.useMemo)(()=>({client:e,id:t,initialLeaf:i}),[e,t,i]),o=r?.epoch??null,s=r?.attachmentVersion??null,c=(0,h.useMemo)(()=>n&&o!==null&&s!==null?{epoch:o,attachmentVersion:s}:null,[n,o,s]),l=(0,h.useRef)(a);l.current=a;let[u,d]=(0,h.useState)();(0,h.useEffect)(()=>{let n=new El(e,t,()=>{l.current===a&&d({scope:a,reader:n,view:n.view()})});return n.choose(i),d({scope:a,reader:n,view:n.view()}),()=>n.close()},[e,t,i,a]);let f=u?.scope===a?u:void 0,p=f?.reader,m=f?.view;return(0,h.useLayoutEffect)(()=>{p?.setActive(n,c)},[p,n,c]),{...m??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},observation:m?.observation===c?c:null,refresh:p?.refresh??Gl,loadEarlier:p?.loadEarlier??Gl,showFrom:p?.showFrom??Gl,choose:p?.choose??Gl}}function Gl(){}function Kl(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`preparing`?r:void 0,[s,c]=(0,h.useState)(0),l=(0,h.useRef)(0),u=(0,h.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,preview:o}),[e,i,a,n,o]),d=(0,h.useRef)(null),f=(0,h.useMemo)(()=>({...u,revision:s,reload:d.current===u}),[u,s]),p=(0,h.useRef)(f);p.current=f;let m=(0,h.useRef)(!0);(0,h.useEffect)(()=>(m.current=!0,()=>{m.current=!1}),[]);let g=(0,h.useCallback)(()=>m.current&&(f.epoch!==null||!!f.preview)&&p.current===f&&l.current===f.revision,[f]),[_,v]=(0,h.useState)();(0,h.useEffect)(()=>{if(f.epoch===null&&!f.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&g();return f.preview?(f.preview(t.signal).then(e=>{n()&&v({scope:f,preview:e})}).catch(e=>{n()&&v({scope:f,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal,f.reload).then(e=>{n()&&(e.kind===`error`?v({scope:f,error:e.error.code}):e.value.version.epoch===f.epoch?v({scope:f,catalog:e.value}):v({scope:f,error:`stale`}))}).catch(()=>{n()&&v({scope:f,error:`unavailable`})}),()=>t.abort())},[e,f,g]);let y=_?.scope===f&&g()?_:void 0;return{catalog:y?.catalog,preview:y?.preview,error:y?.error,loading:(i!==null||!!o)&&!y,isCurrent:g,reread(e=!1){g()&&(d.current=e?u:null,c(++l.current))},accept(e){return!g()||e.version.epoch!==f.epoch?!1:(v({scope:f,catalog:e}),!0)}}}var ql=[`queued`,`running`],Jl=4,Yl=1e4,Xl={runs:new Map,unreadable:new Set,incomplete:!0,error:void 0};function Zl(e,t,n){let r=(0,h.useMemo)(()=>({client:e,conversationId:t,byId:new Map}),[e,t]),[i,a]=(0,h.useState)(),o=(0,h.useRef)(void 0),s=JSON.stringify([...new Set(n)]);return(0,h.useEffect)(()=>{let e=new AbortController,t,n=JSON.parse(s),i=new Set(n),{byId:c}=r;for(let e of c.keys())i.has(e)||c.delete(e);let l=new Map,u=()=>{let e,t=new Map,i=new Set(l.keys());for(let r of n){let n=c.get(r);n?(t.set(r,n.run),e??=n.error):n===null&&i.add(r)}return a({scope:r,runs:t,error:e,unreadable:i,incomplete:n.some(e=>!c.has(e))}),t},d=async t=>{let n=await r.client.workbenchRead({kind:`workflow`,id:t},e.signal);if(e.signal.aborted)return;let i=n.kind===`ok`&&n.value.kind===`workflow`&&n.value.response.type===`run`?n.value.response.run:null;if(i?.id===t)c.set(t,i.execution?.version.conversation?.id===r.conversationId?{run:i}:null),l.delete(t);else{let e=c.get(t);e?e.error=n.kind===`error`?n.error.code:`unavailable`:l.set(t,Date.now())}},f=!1,p=!1,m=async()=>{if(clearTimeout(t),f){p=!0;return}f=!0;let r=Date.now(),i=n.filter(e=>{let t=c.get(e);return t===void 0?r-(l.get(e)??-1/0)>=Yl:t!==null&&ql.includes(t.run.status)}).reverse();for(let t=0;t<i.length;t+=Jl){if(await Promise.all(i.slice(t,t+Jl).map(d)),e.signal.aborted)return;t+Jl<i.length&&u()}let a=u();f=!1,p?(p=!1,m()):[...a.values()].some(e=>ql.includes(e.status))?t=setTimeout(()=>void m(),1e3):l.size&&(t=setTimeout(()=>void m(),Yl))};return o.current=m,m(),()=>{o.current=void 0,e.abort(),clearTimeout(t)}},[s,r]),{...i?.scope===r?i:Xl,refresh:()=>o.current?.()}}function Ql(e,t,n,r=!1){return t?r||!n||H(n)!==H(e.model)?`validate`:`approve`:`restore`}async function $l(e){let t=structuredClone(e.state),n=t.proposal,r=structuredClone(e.context),i={id:r.id,cwd:r.cwd},a=structuredClone(e.model),o=e.head,s=crypto.randomUUID(),c=()=>!e.signal.aborted&&e.current();if(!n||!t.enabled||r.id!==t.id||!c()||(e.prepare&&await Ol(e.prepare,e.signal,i,e.progress??(()=>{})),!c()))throw Error(`stale`);let l=await e.client.models(e.signal,i);if(!c())throw Error(`stale`);if(l.kind!==`ok`)throw Error(l.error.code);let u=await e.client.workbenchCommand({kind:`cadence-revalidate`,commandId:s,conversationId:t.id,revision:t.revision,proposalId:n.id,digest:n.digest,head:o,context:r,model:a,expected:l.value.version});if(!c())throw Error(`stale`);if(u.kind!==`ok`)throw Error(u.error.code);if(u.value.kind!==`cadence-revalidated`||u.value.state.id!==t.id||u.value.state.revision!==t.revision+1||!u.value.state.enabled||u.value.state.head!==t.head||H(u.value.state.runs)!==H(t.runs)||u.value.state.proposal?.id!==s||u.value.state.proposal.revalidatedFrom!==n.id||u.value.state.proposal.epoch!==l.value.version.epoch||u.value.state.proposal.cwd!==r.cwd||H(u.value.state.proposal.model.conversation??null)!==H(i)||H(u.value.state.proposal.plan)!==H(n.plan))throw Error(`stale`);return u.value.state}async function eu(e){let t=e.state.proposal;if(!t||!e.state.enabled||!e.current())throw Error(`stale`);let n={conversationId:e.state.id,revision:e.state.revision,proposalId:t.id,digest:t.digest},r=await e.client.workbenchCommand({kind:`cadence-prepare`,commandId:crypto.randomUUID(),...n});if(r.kind!==`ok`)throw Error(r.error.code);if(r.value.kind!==`cadence-grant`||!e.current()||r.value.revision!==e.state.revision||H(r.value.proposal)!==H(t)||Date.now()>=r.value.expiresAt)throw Error(`stale`);let i=crypto.randomUUID();return e.submitting(i),e.client.workbenchCommand({kind:`cadence-approve`,commandId:i,...n,grant:r.value.grant})}function tu(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function nu(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var ru=e=>`cadence:prompt-history:${e}`;function iu(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function au(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function ou(e){try{let t=sessionStorage.getItem(ru(e));return t?iu(JSON.parse(t)):[]}catch{return[]}}function su(e,t){let n=t;for(;n;)try{sessionStorage.setItem(ru(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function cu(e,t){let n=ou(e),r=au(n,t);r!==n&&su(e,r)}var lu={index:-1,draft:``};function uu(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:lu,text:t.draft}}function du({known:e,active:t,armed:n}){return e?t?`on`:n?`armed`:`off`:`unknown`}var fu={unknown:`Cadence state unavailable`,on:`Cadence on`,armed:`Cadence on next Send`,off:`Cadence off`},pu={unknown:fu.unknown,on:`Cadence mode is on. Click to exit it.`,armed:`Your next message turns on Cadence mode. Click to cancel.`,off:`Turn on Cadence mode: agree on a plan before implementation.`},mu={unknown:fu.unknown,on:`Cadence stays on. Confirm one plan before implementation.`,armed:`Your next message turns on Cadence mode.`,off:null};function hu({disabled:e,onClick:t,...n}){let{t:r}=Z(),i=du(n),a=r(fu[i]);return(0,X.jsxs)(`button`,{type:`button`,className:`mode-toggle ${i}`,"aria-label":a,disabled:e||i===`unknown`,title:r(pu[i]),onClick:t,children:[(0,X.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),a]})}function gu(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function _u(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!gu(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function vu(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var yu=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function bu(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function xu(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function Su(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Cu=``;function wu(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function Tu(e,t){return{first:!e.slice(0,t).includes(`
|
|
19
19
|
`),last:!e.slice(t).includes(`
|
|
20
|
-
`)}}var Su=null;function Cu(){if(Su?.isConnected)return Su;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),Su=e,e}function wu(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function Tu(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=yu,e.appendChild(n),n.offsetTop}function Eu(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=xu(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Cu();if(wu(e,i)<=0)return r;let a=Tu(i,t.slice(0,n)),o=Tu(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:bu(a,o,vu(e))}var Du={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Ou={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed. Read the current list before choosing again.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. Read the current model before choosing again.`},ku=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Au=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function ju(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>ce.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function Mu(){let{t:e}=X();return(0,h.useCallback)(t=>`${t.model} · ${e(Du[t.thinking])}`,[e])}function Nu({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:f=`conversation`}){let{t:p}=X(),m=Mu(),g=t.status===`ready`,_=n.preview,v=g||!!_||n.loading&&t.status!==`preparing`,y=g?t.epoch:null,b=g?t.attachmentVersion:null,{error:x,loading:S,reread:C}=n,w=g?n.catalog:void 0,T=w??_,[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),M=(0,h.useRef)(null),N=(0,h.useRef)(null),P=(0,h.useRef)(null),F=(0,h.useRef)(null),I=(0,h.useRef)(c);I.current=c,(0,h.useEffect)(()=>{D(``)},[e,y,b]);let L=(0,h.useCallback)((e=!0,t)=>{t?I.current(!1,t):I.current(!1),j(``),D(``),e&&N.current?.focus({preventScroll:!0})},[]);(0,h.useEffect)(()=>{if(!s)return;v&&P.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||L(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,L,v]);let R=w?.selected??null,z=i??R??(_?r:null)??T?.remembered??null,ee=(0,h.useMemo)(()=>{let e=A.trim().toLowerCase(),t=new Map;for(let n of T?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[T,A]),te=T?.entries.find(e=>Au(e,z)),B=(g||!!_)&&!!T&&!S&&!x&&n.isCurrent(),ne=async(t,r)=>{if(!B||!n.isCurrent()||!T||!t.api||O||o)return;let i=le({provider:t.provider,model:t.model,api:t.api,thinking:r});if(_&&a)a(i),L(!0,`chosen`);else if(w&&e){if(R&&ku(R,i))L(!0,`chosen`),u?.(i);else{k(!0),D(``);try{let t=await e.chooseModel({expected:w.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){D(t.error.code),C();return}let r={...w,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),L(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(D(`uncertain`),C())}finally{k(!1)}}}},re=()=>[...F.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],ie=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=re(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?P.current?.focus():t[Math.min(n,t.length-1)]?.focus()},ae=t.status===`stopped`||t.status===`not-started`,oe=T?null:r,se=n.preview||n.loading&&a||x&&a?p(S?`Reading models…`:x?`Model list unavailable`:`Choose a model`):ae?p(`Choose a model`):t.status===`preparing`?p(`Preparing execution…`):t.status===`connecting`?p(`Checking execution state…`):t.status===`unavailable`?p(`Execution state unavailable`):p(S?`Reading models…`:x?`Model list unavailable`:`Choose a model`),ce=z?m(z):ae&&oe?p(`Last used: {model}`,{model:m(oe)}):se;return(0,Y.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,Y.jsxs)(`button`,{ref:N,type:`button`,className:`model-trigger${z&&!R||oe?` remembered`:``}${T&&!z?` empty`:``}`,"aria-label":p(`Model: {model}`,{model:ce}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?p(`Switch models after the current reply finishes.`):i?p(`Choose now; the model is verified when you send.`):oe?p(`Last used model; availability is checked when you send.`):z&&!R?p(`Last used model; it is used again when you send.`):z?`${z.provider}/${z.model} · ${z.api}`:se,onClick:()=>{s?L():(D(``),c(!0))},children:[(0,Y.jsx)(Ca,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`model-trigger-text`,children:ce}),(0,Y.jsx)(Na,{"aria-hidden":`true`})]}),s&&(0,Y.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":p(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),L())},children:[d&&(0,Y.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose a model; your message is sent right after.`)}),_&&(0,Y.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose now; the model is verified when you send.`)}),!v&&!x&&(0,Y.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?p(`Execution is being prepared for your Send. Models will load when it is ready.`):p(`Model selection is unavailable until the current conversation and execution state are observed.`)}),oe&&(0,Y.jsxs)(`p`,{className:`model-popover-lead`,children:[p(`Last used: {model}`,{model:m(oe)}),(0,Y.jsx)(`br`,{}),p(`Last used model; availability is checked when you send.`)]}),v&&(0,Y.jsxs)(`label`,{className:`model-search`,children:[(0,Y.jsx)(qi,{"aria-hidden":`true`}),(0,Y.jsx)(`input`,{ref:P,type:`search`,"aria-label":p(`Search models`),placeholder:p(`Search models…`),value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),re()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),re()[0]?.click())}})]}),v&&(0,Y.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":p(`Models`),ref:F,onKeyDown:ie,children:[S&&(0,Y.jsx)(`p`,{className:`model-empty`,role:`status`,children:p(`Reading models…`)}),ee.map(([e,t])=>(0,Y.jsxs)(`fieldset`,{className:`model-group`,children:[(0,Y.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=Au(e,z);return(0,Y.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!B||!t||O||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void ne(e,ju(e,z?.thinking??`medium`)),children:[(0,Y.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,Y.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?p(`Credentials unavailable`):p(`Not supported`)}),n&&(!R||!!i)&&(0,Y.jsx)(`span`,{className:`model-option-note`,children:p(`Used when you send`)}),n&&(0,Y.jsx)(Pa,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),T?.status===`complete`&&ee.length===0&&(0,Y.jsx)(`p`,{className:`model-empty`,children:A.trim()?p(`No matching models.`):p(_?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.`)})]}),v&&te&&te.thinking.length>1&&(0,Y.jsxs)(`div`,{className:`model-thinking`,children:[(0,Y.jsx)(`span`,{className:`model-thinking-label`,children:p(`Thinking`)}),te.thinking.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-label":p(`Thinking level: {level}`,{level:p(Du[e.level])}),"aria-pressed":z?.thinking===e.level,disabled:!B||!e.selectable||O||o,onClick:()=>void ne(te,e.level),children:p(Du[e.level])},e.level))]}),(0,Y.jsxs)(`div`,{className:`model-popover-notes`,children:[_&&!x&&(0,Y.jsx)(`button`,{type:`button`,className:`link`,disabled:S||O,onClick:()=>C(!0),children:p(`Refresh models`)}),o&&(0,Y.jsx)(`p`,{children:p(`Switch models after the current reply finishes.`)}),T?.status===`capacity`&&(0,Y.jsx)(`p`,{role:`alert`,children:p(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!T?.withheld&&(0,Y.jsx)(`p`,{role:`alert`,children:p(T.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.`,{count:T.withheld})}),(g||!!a)&&x&&(0,Y.jsxs)(`p`,{role:`alert`,children:[p(`The model list could not be read ({code}).`,{code:x}),` `,(0,Y.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>C(!0),children:p(`Read again`)})]}),E&&(0,Y.jsx)(`p`,{role:`alert`,children:Ou[E]?p(Ou[E]):p(`The model was not changed ({code}).`,{code:E})}),B&&(0,Y.jsx)(`p`,{className:`model-popover-scope`,children:p(O?`Switching model…`:f===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}var Pu=.1,Fu=(e,t)=>Math.max(Pu,Math.min(4,e*t));function Iu({blob:e,label:t,onClose:n}){let{t:r}=X(),i=(0,h.useRef)(null),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)({width:0,height:0}),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(null);(0,h.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,h.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let m=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;p(n=>Fu(n??t,e))},g=(e,t,n,r=!1)=>(0,Y.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,Y.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,Y.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,Y.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,Y.jsx)(`span`,{className:`img-lightbox-name`,children:t}),g(r(`Close`),(0,Y.jsx)(Ri,{"aria-hidden":`true`}),n)]}),(0,Y.jsxs)(`div`,{className:`img-lightbox-image${f===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,Y.jsx)(`img`,{ref:a,src:o,alt:t,style:f===null||!c.width?void 0:{width:c.width*f,height:c.height*f},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,Y.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,Y.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,Y.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),g(r(`Zoom out`),(0,Y.jsx)(Ii,{"aria-hidden":`true`}),()=>m(1/1.25),!c.width||f!==null&&f<=.1),g(r(`Actual size`),(0,Y.jsx)(ia,{"aria-hidden":`true`}),()=>p(1),!c.width||f===1),f!==null&&(0,Y.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(f*100),`%`]}),g(r(`Zoom in`),(0,Y.jsx)(Li,{"aria-hidden":`true`}),()=>m(1.25),!c.width||f!==null&&f>=4),g(r(`Fit to window`),(0,Y.jsx)(ta,{"aria-hidden":`true`}),()=>p(null),f===null)]})]})})}function Lu(){let[e,t]=(0,h.useState)([]),n=(0,h.useRef)(e),r=(0,h.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];hl(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,h.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),replace:(0,h.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function Ru(e){let[t,n]=(0,h.useState)(null);return{open:n,lightbox:t&&(0,Y.jsx)(Iu,{blob:t,label:e,onClose:()=>n(null)})}}function zu({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=X();return(0,Y.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,Y.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function Bu({file:e,disabled:t,remove:n}){let{t:r}=X(),[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(!1),{open:c,lightbox:l}=Ru(e.name);return(0,h.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),gl(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,Y.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,Y.jsx)(zu,{url:i,alt:e.name,onOpen:()=>c(e)}),o&&(0,Y.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid image.`)}),(0,Y.jsx)(`span`,{title:e.name,children:e.name}),(0,Y.jsx)(`button`,{type:`button`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function Vu({image:e,read:t}){let{t:n}=X(),[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(!1),{open:s,lightbox:c}=Ru(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:f}=e;return(0,h.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...f?{live:f}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,f]),(0,Y.jsxs)(Y.Fragment,{children:[a?(0,Y.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,Y.jsx)(zu,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,Y.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function Hu({images:e,turn:t}){return(0,Y.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,Y.jsx)(Vu,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var Uu=`cadence:composer-height`,Wu=16;function Gu(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var Ku=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,qu=()=>Ku(typeof window>`u`?0:window.innerHeight);function Ju({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:f,hint:p,running:m,flow:g,canStop:_,onStop:y,canSend:b,onSend:x,input:S,historyScope:C,files:w,onResized:T}){let{t:E}=X(),D=(0,h.useRef)(null),O=(0,h.useRef)(null),k=(0,h.useId)(),[A,j]=(0,h.useState)(()=>{try{return Gu(localStorage.getItem(Uu))}catch{return null}}),[M,N]=(0,h.useState)(64),[P,F]=(0,h.useState)(``);(0,h.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=qu();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(A===null?Math.max(r,64):A,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,N(i)},[t,A,P,e]);let I=(0,h.useRef)(T);I.current=T,(0,h.useEffect)(()=>{let e=D.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.offsetHeight,n=()=>{F(`${e.clientWidth}:${window.innerHeight}`),e.offsetHeight!==t&&(t=e.offsetHeight,I.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let L=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(j(n),t)try{n===null?localStorage.removeItem(Uu):localStorage.setItem(Uu,String(n))}catch{}},R=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>R.current?.(),[]);let z=(0,h.useRef)(au),ee=(0,h.useRef)(null);(0,h.useEffect)(()=>{t!==ee.current&&(z.current=au)},[t]);let te=(0,h.useRef)(null),[B,ne]=(0,h.useState)(-1);(0,h.useLayoutEffect)(()=>{let t=e.current;t&&te.current!==null&&(t.setSelectionRange(te.current,te.current),ne(te.current),te.current=null)},[t,e]);let re=e=>{ee.current=e,te.current=e.length,n(e)},[ie,ae]=(0,h.useState)(!1),[oe,se]=(0,h.useState)(-1),[ce,le]=(0,h.useState)(null),{location:ue}=w,de=ue&&ie&&!r&&ce===t?pu(t,B):null,fe=mu(de?.query??``),V=de!==null&&de.start!==oe&&hu(fe.folder),pe=es(w.client,V&&ue?{kind:`files`,path:fe.folder,location:ue}:null),me=pe.value?.kind===`files`?pe.value:void 0,H=me?gu(me.entries,fe.name):[],[he,ge]=(0,h.useState)(0),_e=de?`${de.start}:${de.query}`:``;(0,h.useEffect)(()=>{ge(0),_e||se(-1)},[_e]);let U=Math.min(he,H.length-1),W=H[U],ve=W?`${k}-${U}`:void 0;(0,h.useEffect)(()=>{ve&&document.getElementById(ve)?.scrollIntoView({block:`nearest`})},[ve]);let ye=e=>{if(!de)return;let r=_u(t,de,B,e);te.current=r.cursor,le(r.text),n(r.text)},be=e=>{if(!e.nativeEvent.isComposing){if(V){if(e.key===`Escape`){e.preventDefault(),se(de.start);return}if(W){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;ge((U+t+H.length)%H.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ye(W);return}}}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){let n=e.key===`ArrowUp`;if(!n&&z.current.index===-1)return;let r=Eu(e.currentTarget);if(n?!r.first:!r.last)return;let i=ou(nu(C),z.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),z.current=i.cursor,re(i.text)}else if(e.key===`Escape`&&z.current.index!==-1){e.preventDefault();let t=z.current.draft;z.current=au,re(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),m&&S?S.enabled&&S.onInput(e.altKey?`queue`:`steer`):x())}},xe=E(A===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,Y.jsxs)(`form`,{ref:D,className:`chat-composer`,"data-flow":g||void 0,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),m||x()},children:[(0,Y.jsx)(`input`,{type:`range`,className:`composer-resize${A===null?``:` is-manual`}`,min:64,max:320,step:Wu,value:Math.round(M),"aria-label":xe,title:xe,"aria-orientation":`vertical`,"aria-valuetext":A===null?E(`Automatic`):E(`{pixels} pixels`,{pixels:Math.round(M)}),onChange:e=>L(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),L(null,!0))},onDoubleClick:()=>L(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),R.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??M,i=null,a=e=>{i=Math.min(qu(),Math.max(64,r+(n-e.clientY))),L(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),R.current=void 0,i!==null&&L(i,!0)};R.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,Y.jsx)(`input`,{ref:O,type:`file`,accept:v.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":E(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,Y.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,Y.jsx)(Bu,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,Y.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),V&&(0,Y.jsx)(`div`,{className:`mention-menu`,id:k,role:`listbox`,"aria-label":E(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:(0,Y.jsxs)(`div`,{className:`mention-list`,children:[(0,Y.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,Y.jsx)(`span`,{className:`mention-menu-folder`,children:fe.folder?`@${fe.folder}`:E(`Files in the conversation folder`)}),(0,Y.jsx)(`span`,{children:E(`Enter inserts the path · Esc closes`)})]}),pe.error?(0,Y.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:tr(E,pe.error)}):me?H.length===0?(0,Y.jsx)(`p`,{className:`mention-menu-note`,children:E(`No matching files`)}):null:(0,Y.jsx)(`p`,{className:`mention-menu-note`,children:E(`Reading files…`)}),H.map((e,t)=>(0,Y.jsxs)(`button`,{type:`button`,role:`option`,id:`${k}-${t}`,className:`mention-item${e===W?` active`:``}`,"aria-selected":e===W,tabIndex:-1,title:e.path,onMouseEnter:()=>ge(t),onClick:()=>ye(e),children:[e.directory?(0,Y.jsx)(ha,{"aria-hidden":`true`}):(0,Y.jsx)(ga,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,Y.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),me?.limited&&(0,Y.jsx)(`p`,{className:`mention-menu-note`,children:E(`Bounded listing; narrow the directory to see more.`)})]})}),(0,Y.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":E(`Message`),"aria-autocomplete":ue?`list`:void 0,"aria-controls":V?k:void 0,"aria-activedescendant":V?ve:void 0,value:t,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{ne(e.target.selectionStart),le(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;ne(t===n?t:-1)},onFocus:()=>ae(!0),onBlur:()=>ae(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:be}),(0,Y.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>O.current?.click(),children:(0,Y.jsx)(ua,{"aria-hidden":`true`})}),(0,Y.jsx)(du,{...d}),(0,Y.jsx)(Nu,{...f}),(0,Y.jsx)(`span`,{className:`composer-hint`,children:p}),m&&S?.enabled&&(0,Y.jsxs)(`span`,{className:`composer-split`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":E(`Queue behind this reply`),title:E(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>S.onInput(`queue`),children:(0,Y.jsx)(oa,{"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":E(`Steer this reply`),title:E(`Steer: read at the model's next step (Enter)`),onClick:()=>S.onInput(`steer`),children:(0,Y.jsx)(Ia,{"aria-hidden":`true`})})]}),m?(0,Y.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":E(`Stop response`),title:E(`Stop response`),disabled:!_,onClick:y,children:(0,Y.jsx)(Ui,{"aria-hidden":`true`})}):(0,Y.jsx)(`button`,{"aria-label":E(`Send`),title:E(`Send`),type:`submit`,className:`primary`,disabled:!b,children:(0,Y.jsx)(Ia,{"aria-hidden":`true`})})]})]})}var Yu={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,py:`python`,rs:`rust`,go:`go`,java:`java`,kt:`kotlin`,swift:`swift`,rb:`ruby`,php:`php`,lua:`lua`,pl:`perl`,r:`r`,cs:`csharp`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,md:`markdown`,sql:`sql`,diff:`diff`,patch:`diff`,graphql:`graphql`,mk:`makefile`};function Xu(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(Yu,n)&&Yu[n]||`plaintext`}var Zu=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function Qu(e,t){let n={oldTokens:[{type:`del`,text:e}],newTokens:[{type:`add`,text:t}]};if(!e||!t||e.length>800||t.length>800)return n;let r=e.match(Zu)||[e],i=t.match(Zu)||[t],a=r.length,o=i.length;if(a*o>4e3)return n;let s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=r[e-1]===i[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);if(s[a][o]/Math.max(a,o)<.25)return n;let c=[],l=[],u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(c.push({type:`same`,text:r[u-1]}),l.push({type:`same`,text:i[d-1]}),u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l.push({type:`add`,text:i[d-1]}),d--):(c.push({type:`del`,text:r[u-1]}),u--);let f=e=>{let t=[];for(let n of e.reverse()){let e=t.at(-1);e?.type===n.type?e.text+=n.text:t.push({...n})}return t};return{oldTokens:f(c),newTokens:f(l)}}function $u(e){if(!e)return[];let t=e.split(`
|
|
21
|
-
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function ed(e){let t=0,n=0;return{hunks:e.map(({oldText:e,newText:r})=>{let i=$u(e),a=$u(r);n+=i.length,t+=a.length;let o=[];if(i.length===1&&a.length===1){let{oldTokens:e,newTokens:t}=Qu(i[0],a[0]);o.push({type:`del`,content:i[0],tokens:e}),o.push({type:`add`,content:a[0],tokens:t})}else{for(let e of i)o.push({type:`del`,content:e});for(let e of a)o.push({type:`add`,content:e})}return{removed:i.length,added:a.length,lines:o}}),additions:t,deletions:n}}var td=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function nd(e){return td(e)&&typeof e.oldText==`string`&&typeof e.newText==`string`}function rd(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!td(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:Xu(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=$u(n.content);return{...i,isWrite:!0,content:n.content,additions:e.length,deletions:0,hunks:[{removed:0,added:e.length,lines:e.map(e=>({type:`add`,content:e}))}]}}let a=`edits`in n?n.edits:[];return!Array.isArray(a)||((`oldText`in n||`newText`in n)&&a.push({oldText:n.oldText,newText:n.newText}),!a.length||!a.every(nd))?null:{...i,isWrite:!1,...ed(a)}}function id({line:e}){return(0,Y.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,Y.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,Y.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,Y.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function ad({data:e,failed:t=!1}){let{t:n}=X(),[r,i]=(0,h.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,Y.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,Y.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,Y.jsxs)(`div`,{className:`file-diff-info`,children:[(0,Y.jsx)(_a,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,Y.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,Y.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,Y.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,Y.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,Y.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,Y.jsx)(Ha,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]}),e.isWrite&&(0,Y.jsx)(zs,{text:e.content,className:`write-copy`,label:`${n(`Copy full retained field`)} · ${n(`Requested content`)}`})]}),(0,Y.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,Y.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,Y.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,Y.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,Y.jsx)(`div`,{className:`diff-hunk-header`,children:(0,Y.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,Y.jsx)(id,{line:e},t))]},r))})}),!r&&a>400&&(0,Y.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function od(e){let t=e.items.map(e=>({...gn(e,1),text:e.role===`tool`||e.role===`thinking`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,...e.retry?{retry:e.retry}:{},omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function sd(e){return e.state===`pending`||e.state===`streaming`||e.state===`running`}function cd(e,t,n,r){let i=`${e.renderId??e.header.id}:${bl(n)}`,a=JSON.stringify([t,n.parts,n.version,n.state,n.error,e.header.status]),{detail:o}=e,s=(0,h.useMemo)(()=>({identity:i,revision:a,detail:o,wanted:r}),[i,a,o,r]),c=(0,h.useRef)(s);c.current=s;let[l,u]=(0,h.useState)(),d=n.parts;return(0,h.useEffect)(()=>{if(!r||d===0)return;let e=new AbortController,n=()=>!e.signal.aborted&&c.current===s;return o(t,d,e.signal).then(e=>{n()&&u({identity:i,value:e})},e=>{n()&&u(t=>({identity:i,...t?.identity===i?{value:t.value}:{},error:e instanceof Error?e.message:`unavailable`}))}),()=>e.abort()},[s,o,t,d,r,i]),r&&d>0&&l?.identity===i?l:{}}function ld(e){let t=e.map((e,t)=>({step:e,index:t,key:bl(e)}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var ud={bash:[Vi,`exec`],powershell:[Vi,`exec`],read:[_a,`read`],ls:[ha,`read`],write:[ya,`edit`],edit:[ba,`edit`],grep:[qi,`search`],find:[Da,`search`]},dd=[Bi,`default`],fd=e=>Object.hasOwn(ud,e)?ud[e]:dd;function pd(e,t){let n=e.steps[t];return n?.error||n?.state===`failed`?`err`:n?.state===`completed`?`ok`:n&&sd(n)&&Tl(e.header.status)?`run`:`idle`}var md={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function hd(){return(0,Y.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,Y.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function gd({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,Y.jsx)(Gs,{text:e})}){let{t:a}=X(),o=t<e.header.stable,s=cd(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,Y.jsxs)(Y.Fragment,{children:[n.images?.length?(0,Y.jsx)(Hu,{images:n.images,turn:e}):null,c.trim()!==``&&(0,Y.jsxs)(`div`,{className:`msg-text single`,children:[(0,Y.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,Y.jsx)(zs,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,Y.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?tr(a,s.error):a(`Reading the rest of this message…`)})]})}function _d(e){try{let t=JSON.parse(e),n=t&&typeof t==`object`&&Object.hasOwn(t,`command`)?t.command:void 0;return typeof n==`string`&&n?n:void 0}catch{return}}function vd(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function yd({turn:e,index:t,step:n}){let{t:r}=X(),[i,a]=(0,h.useState)(!1),o=cd(e,t,n,i),[s,c]=fd(n.name),l=pd(e,t),u=r(md[l]),d=o.value?.args,f=d?_d(d):void 0,p=(0,h.useMemo)(()=>d?rd(n.name,d):null,[n.name,d]),m=d&&!p?f??vd(d):``;return(0,Y.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,Y.jsx)(jc,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,Y.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,Y.jsx)(Ri,{"aria-hidden":`true`}):l===`ok`?(0,Y.jsx)(Pa,{"aria-hidden":`true`}):l===`run`?(0,Y.jsx)(hd,{}):(0,Y.jsx)(ea,{"aria-hidden":`true`})}),n.target&&(0,Y.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,Y.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,Y.jsx)(zs,{text:n.target,label:r(`Copy tool summary`),className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,Y.jsxs)(`div`,{className:`toolcall-body`,children:[n.parts===0?(0,Y.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,Y.jsxs)(Y.Fragment,{children:[o.value.args&&(0,Y.jsx)(`div`,{className:`toolcall-args`,children:p?(0,Y.jsx)(ad,{data:p,failed:l===`err`}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(f?`Command`:`Arguments`),(0,Y.jsx)(zs,{text:m,label:r(f?`Copy command`:`Copy arguments`),className:`output-copy`})]}),f?(0,Y.jsxs)(`div`,{className:`termline`,children:[(0,Y.jsx)(Vi,{className:`termline-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`code`,{children:m})]}):(0,Y.jsx)(`pre`,{children:m})]})}),o.value.text&&(0,Y.jsxs)(`div`,{className:`toolcall-output`,children:[(0,Y.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(l===`err`?`Error output`:`Output`),` · `,u,(0,Y.jsx)(zs,{text:o.value.text,label:r(`Copy output`),className:`output-copy`})]}),(0,Y.jsx)(`pre`,{children:o.value.text})]})]}):(0,Y.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?tr(r,o.error):r(`Reading…`)}),o.value&&o.error&&(0,Y.jsx)(`p`,{className:`banner-notice`,children:tr(r,o.error)})]})]})}function bd({turn:e,index:t,step:n}){let{t:r}=X(),[i,a]=(0,h.useState)(!1),o=cd(e,t,n,i&&n.parts>0),s=sd(n)&&Tl(e.header.status);if(n.parts===0)return(0,Y.jsx)(`div`,{className:`thinking`,children:(0,Y.jsxs)(`div`,{className:`chead thinking-head`,title:r(`Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.`),children:[(0,Y.jsx)(Ca,{className:`thinking-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`thinking-label`,role:`status`,children:r(s?`Thinking activity observed`:n.state===`completed`?`Thinking activity ended`:`Thinking content unavailable`)}),s&&(0,Y.jsx)(hd,{})]})});let c=o.value?.text.trim()??``;return(0,Y.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,Y.jsx)(jc,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,Y.jsx)(Ca,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`toolcall-spacer`}),c&&(0,Y.jsx)(zs,{text:c,className:`chead-copy`})]}),children:r(`Thinking`)}),i&&(0,Y.jsx)(`div`,{className:`thinking-body`,children:c||(0,Y.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?tr(r,o.error):o.value?r(`No thinking text is recorded for this block.`):r(`Reading…`)})})]})}var xd=c().use(m).use(l).use(p).use(Cs);function Sd(e){return e.type===`definition`||e.type===`linkReference`||e.type===`imageReference`||e.type===`footnoteDefinition`||e.type===`footnoteReference`||(e.children?.some(Sd)??!1)}function Cd(e,t){if(e?.type!==`code`)return!1;let n=t.split(/\r\n|\r|\n/),r=/^ {0,3}(`{3,}|~{3,})/.exec(n[0]);if(!r)return!1;let i=r[1];return!n.slice(1).some(e=>{let t=/^ {0,3}(`{3,}|~{3,})[\t ]*$/.exec(e);return t&&t[1][0]===i[0]&&t[1].length>=i.length})}function wd(e){let{children:t}=xd.parse(e),n=e?[0]:[];for(let e=0;e<t.length;e++){let r=t[e],i=r.position?.start;if(e>0&&i?.offset!==void 0&&n.push(i.offset-(i.column-1)),Sd(r))break}let r=n.map((t,r)=>({start:t,text:e.slice(t,n[r+1])})),i=r.at(-1)?.text??``,a=t.at(-1),o=r.length===t.length&&Cd(a,e.slice(a?.position?.start.offset));return{segments:r,frozen:r.slice(0,-1).map(e=>e.text),active:i,inFence:o}}var Td=(0,h.memo)(function({text:e}){return(0,Y.jsx)(Ws,{text:e})}),Ed=(0,h.memo)(function({text:e}){let{segments:t}=(0,h.useMemo)(()=>wd(e),[e]);return(0,Y.jsx)(`div`,{className:`md`,children:t.map(e=>(0,Y.jsx)(Td,{text:e.text},`stream-offset:${e.start}`))})});function Dd(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
20
|
+
`)}}var Eu=null;function Du(){if(Eu?.isConnected)return Eu;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),Eu=e,e}function Ou(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function ku(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Cu,e.appendChild(n),n.offsetTop}function Au(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=Tu(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Du();if(Ou(e,i)<=0)return r;let a=ku(i,t.slice(0,n)),o=ku(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:wu(a,o,Su(e))}var ju={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Mu={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed. Read the current list before choosing again.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. Read the current model before choosing again.`},Nu=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Pu=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Fu(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>se.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function Iu(){let{t:e}=Z();return(0,h.useCallback)(t=>`${t.model} · ${e(ju[t.thinking])}`,[e])}function Lu({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:f=`conversation`}){let{t:p}=Z(),m=Iu(),g=t.status===`ready`,_=n.preview,v=g||!!_||n.loading&&t.status!==`preparing`,y=g?t.epoch:null,b=g?t.attachmentVersion:null,{error:x,loading:S,reread:C}=n,w=g?n.catalog:void 0,T=w??_,[E,D]=(0,h.useState)(``),[O,k]=(0,h.useState)(!1),[A,j]=(0,h.useState)(``),M=(0,h.useRef)(null),N=(0,h.useRef)(null),P=(0,h.useRef)(null),F=(0,h.useRef)(null),I=(0,h.useRef)(c);I.current=c,(0,h.useEffect)(()=>{D(``)},[e,y,b]);let L=(0,h.useCallback)((e=!0,t)=>{t?I.current(!1,t):I.current(!1),j(``),D(``),e&&N.current?.focus({preventScroll:!0})},[]);(0,h.useEffect)(()=>{if(!s)return;v&&P.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||L(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,L,v]);let R=w?.selected??null,z=i??R??(_?r:null)??T?.remembered??null,B=(0,h.useMemo)(()=>{let e=A.trim().toLowerCase(),t=new Map;for(let n of T?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[T,A]),V=T?.entries.find(e=>Pu(e,z)),ee=(g||!!_)&&!!T&&!S&&!x&&n.isCurrent(),H=async(t,r)=>{if(!ee||!n.isCurrent()||!T||!t.api||O||o)return;let i=ce({provider:t.provider,model:t.model,api:t.api,thinking:r});if(_&&a)a(i),L(!0,`chosen`);else if(w&&e){if(R&&Nu(R,i))L(!0,`chosen`),u?.(i);else{k(!0),D(``);try{let t=await e.chooseModel({expected:w.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){D(t.error.code),C();return}let r={...w,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),L(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(D(`uncertain`),C())}finally{k(!1)}}}},te=()=>[...F.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],ne=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=te(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?P.current?.focus():t[Math.min(n,t.length-1)]?.focus()},re=t.status===`stopped`||t.status===`not-started`,ie=T?null:r,ae=n.preview||n.loading&&a||x&&a?p(S?`Reading models…`:x?`Model list unavailable`:`Choose a model`):re?p(`Choose a model`):t.status===`preparing`?p(`Preparing execution…`):t.status===`connecting`?p(`Checking execution state…`):t.status===`unavailable`?p(`Execution state unavailable`):p(S?`Reading models…`:x?`Model list unavailable`:`Choose a model`),oe=z?m(z):re&&ie?p(`Last used: {model}`,{model:m(ie)}):ae;return(0,X.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,X.jsxs)(`button`,{ref:N,type:`button`,className:`model-trigger${z&&!R||ie?` remembered`:``}${T&&!z?` empty`:``}`,"aria-label":p(`Model: {model}`,{model:oe}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?p(`Switch models after the current reply finishes.`):i?p(`Choose now; the model is verified when you send.`):ie?p(`Last used model; availability is checked when you send.`):z&&!R?p(`Last used model; it is used again when you send.`):z?`${z.provider}/${z.model} · ${z.api}`:ae,onClick:()=>{s?L():(D(``),c(!0))},children:[(0,X.jsx)(wa,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`model-trigger-text`,children:oe}),(0,X.jsx)(Pa,{"aria-hidden":`true`})]}),s&&(0,X.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":p(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),L())},children:[d&&(0,X.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose a model; your message is sent right after.`)}),_&&(0,X.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose now; the model is verified when you send.`)}),!v&&!x&&(0,X.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?p(`Execution is being prepared for your Send. Models will load when it is ready.`):p(`Model selection is unavailable until the current conversation and execution state are observed.`)}),ie&&(0,X.jsxs)(`p`,{className:`model-popover-lead`,children:[p(`Last used: {model}`,{model:m(ie)}),(0,X.jsx)(`br`,{}),p(`Last used model; availability is checked when you send.`)]}),v&&(0,X.jsxs)(`label`,{className:`model-search`,children:[(0,X.jsx)(Ji,{"aria-hidden":`true`}),(0,X.jsx)(`input`,{ref:P,type:`search`,"aria-label":p(`Search models`),placeholder:p(`Search models…`),value:A,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),te()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),te()[0]?.click())}})]}),v&&(0,X.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":p(`Models`),ref:F,onKeyDown:ne,children:[S&&(0,X.jsx)(`p`,{className:`model-empty`,role:`status`,children:p(`Reading models…`)}),B.map(([e,t])=>(0,X.jsxs)(`fieldset`,{className:`model-group`,children:[(0,X.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=Pu(e,z);return(0,X.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!ee||!t||O||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void H(e,Fu(e,z?.thinking??`medium`)),children:[(0,X.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,X.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?p(`Credentials unavailable`):p(`Not supported`)}),n&&(!R||!!i)&&(0,X.jsx)(`span`,{className:`model-option-note`,children:p(`Used when you send`)}),n&&(0,X.jsx)(Fa,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),T?.status===`complete`&&B.length===0&&(0,X.jsx)(`p`,{className:`model-empty`,children:A.trim()?p(`No matching models.`):p(_?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.`)})]}),v&&V&&V.thinking.length>1&&(0,X.jsxs)(`div`,{className:`model-thinking`,children:[(0,X.jsx)(`span`,{className:`model-thinking-label`,children:p(`Thinking`)}),V.thinking.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-label":p(`Thinking level: {level}`,{level:p(ju[e.level])}),"aria-pressed":z?.thinking===e.level,disabled:!ee||!e.selectable||O||o,onClick:()=>void H(V,e.level),children:p(ju[e.level])},e.level))]}),(0,X.jsxs)(`div`,{className:`model-popover-notes`,children:[_&&!x&&(0,X.jsx)(`button`,{type:`button`,className:`link`,disabled:S||O,onClick:()=>C(!0),children:p(`Refresh models`)}),o&&(0,X.jsx)(`p`,{children:p(`Switch models after the current reply finishes.`)}),T?.status===`capacity`&&(0,X.jsx)(`p`,{role:`alert`,children:p(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!T?.withheld&&(0,X.jsx)(`p`,{role:`alert`,children:p(T.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; reopen the picker after editing models.json.`,{count:T.withheld})}),(g||!!a)&&x&&(0,X.jsxs)(`p`,{role:`alert`,children:[p(`The model list could not be read ({code}).`,{code:x}),` `,(0,X.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>C(!0),children:p(`Read again`)})]}),E&&(0,X.jsx)(`p`,{role:`alert`,children:Mu[E]?p(Mu[E]):p(`The model was not changed ({code}).`,{code:E})}),ee&&(0,X.jsx)(`p`,{className:`model-popover-scope`,children:p(O?`Switching model…`:f===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}var Ru=.1,zu=(e,t)=>Math.max(Ru,Math.min(4,e*t));function Bu({blob:e,label:t,onClose:n}){let{t:r}=Z(),i=(0,h.useRef)(null),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)({width:0,height:0}),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(null);(0,h.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,h.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let m=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;p(n=>zu(n??t,e))},g=(e,t,n,r=!1)=>(0,X.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,X.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,X.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,X.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,X.jsx)(`span`,{className:`img-lightbox-name`,children:t}),g(r(`Close`),(0,X.jsx)(zi,{"aria-hidden":`true`}),n)]}),(0,X.jsxs)(`div`,{className:`img-lightbox-image${f===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,X.jsx)(`img`,{ref:a,src:o,alt:t,style:f===null||!c.width?void 0:{width:c.width*f,height:c.height*f},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,X.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,X.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,X.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),g(r(`Zoom out`),(0,X.jsx)(Li,{"aria-hidden":`true`}),()=>m(1/1.25),!c.width||f!==null&&f<=.1),g(r(`Actual size`),(0,X.jsx)(aa,{"aria-hidden":`true`}),()=>p(1),!c.width||f===1),f!==null&&(0,X.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(f*100),`%`]}),g(r(`Zoom in`),(0,X.jsx)(Ri,{"aria-hidden":`true`}),()=>m(1.25),!c.width||f!==null&&f>=4),g(r(`Fit to window`),(0,X.jsx)(na,{"aria-hidden":`true`}),()=>p(null),f===null)]})]})})}function Vu(){let[e,t]=(0,h.useState)([]),n=(0,h.useRef)(e),r=(0,h.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];ml(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,h.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),replace:(0,h.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function Hu(e){let[t,n]=(0,h.useState)(null);return{open:n,lightbox:t&&(0,X.jsx)(Bu,{blob:t,label:e,onClose:()=>n(null)})}}function Uu({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=Z();return(0,X.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,X.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function Wu({file:e,disabled:t,remove:n}){let{t:r}=Z(),[i,a]=(0,h.useState)(``),[o,s]=(0,h.useState)(!1),{open:c,lightbox:l}=Hu(e.name);return(0,h.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),hl(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,X.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,X.jsx)(Uu,{url:i,alt:e.name,onOpen:()=>c(e)}),o&&(0,X.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid image.`)}),(0,X.jsx)(`span`,{title:e.name,children:e.name}),(0,X.jsx)(`button`,{type:`button`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function Gu({image:e,read:t}){let{t:n}=Z(),[r,i]=(0,h.useState)(null),[a,o]=(0,h.useState)(!1),{open:s,lightbox:c}=Hu(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:f}=e;return(0,h.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...f?{live:f}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,f]),(0,X.jsxs)(X.Fragment,{children:[a?(0,X.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,X.jsx)(Uu,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,X.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function Ku({images:e,turn:t}){return(0,X.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,X.jsx)(Gu,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var qu=`cadence:composer-height`,Ju=16;function Yu(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var Xu=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,Zu=()=>Xu(typeof window>`u`?0:window.innerHeight);function Qu({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:f,hint:p,running:m,flow:g,canStop:_,onStop:y,canSend:b,onSend:x,input:S,historyScope:C,files:w,onResized:T}){let{t:E}=Z(),D=(0,h.useRef)(null),O=(0,h.useRef)(null),k=(0,h.useId)(),[A,j]=(0,h.useState)(()=>{try{return Yu(localStorage.getItem(qu))}catch{return null}}),[M,N]=(0,h.useState)(64),[P,F]=(0,h.useState)(``);(0,h.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Zu();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(A===null?Math.max(r,64):A,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,N(i)},[t,A,P,e]);let I=(0,h.useRef)(T);I.current=T,(0,h.useEffect)(()=>{let e=D.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.offsetHeight,n=()=>{F(`${e.clientWidth}:${window.innerHeight}`),e.offsetHeight!==t&&(t=e.offsetHeight,I.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let L=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(j(n),t)try{n===null?localStorage.removeItem(qu):localStorage.setItem(qu,String(n))}catch{}},R=(0,h.useRef)(void 0);(0,h.useEffect)(()=>()=>R.current?.(),[]);let z=(0,h.useRef)(lu),B=(0,h.useRef)(null);(0,h.useEffect)(()=>{t!==B.current&&(z.current=lu)},[t]);let V=(0,h.useRef)(null),[ee,H]=(0,h.useState)(-1);(0,h.useLayoutEffect)(()=>{let t=e.current;t&&V.current!==null&&(t.setSelectionRange(V.current,V.current),H(V.current),V.current=null)},[t,e]);let te=e=>{B.current=e,V.current=e.length,n(e)},[ne,re]=(0,h.useState)(!1),[ie,ae]=(0,h.useState)(-1),[oe,se]=(0,h.useState)(null),{location:ce}=w,U=ce&&ne&&!r&&oe===t?_u(t,ee):null,le=vu(U?.query??``),ue=U!==null&&U.start!==ie&&yu(le.folder),W=ns(w.client,ue&&ce?{kind:`files`,path:le.folder,location:ce}:null),de=W.value?.kind===`files`?W.value:void 0,fe=de?bu(de.entries,le.name):[],[pe,G]=(0,h.useState)(0),me=U?`${U.start}:${U.query}`:``;(0,h.useEffect)(()=>{G(0),me||ae(-1)},[me]);let he=Math.min(pe,fe.length-1),ge=fe[he],_e=ge?`${k}-${he}`:void 0;(0,h.useEffect)(()=>{_e&&document.getElementById(_e)?.scrollIntoView({block:`nearest`})},[_e]);let ve=e=>{if(!U)return;let r=xu(t,U,ee,e);V.current=r.cursor,se(r.text),n(r.text)},ye=e=>{if(!e.nativeEvent.isComposing){if(ue){if(e.key===`Escape`){e.preventDefault(),ae(U.start);return}if(ge){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;G((he+t+fe.length)%fe.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),ve(ge);return}}}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){let n=e.key===`ArrowUp`;if(!n&&z.current.index===-1)return;let r=Au(e.currentTarget);if(n?!r.first:!r.last)return;let i=uu(ou(C),z.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),z.current=i.cursor,te(i.text)}else if(e.key===`Escape`&&z.current.index!==-1){e.preventDefault();let t=z.current.draft;z.current=lu,te(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),m&&S?S.enabled&&S.onInput(e.altKey?`queue`:`steer`):x())}},be=E(A===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,X.jsxs)(`form`,{ref:D,className:`chat-composer`,"data-flow":g||void 0,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),m||x()},children:[(0,X.jsx)(`input`,{type:`range`,className:`composer-resize${A===null?``:` is-manual`}`,min:64,max:320,step:Ju,value:Math.round(M),"aria-label":be,title:be,"aria-orientation":`vertical`,"aria-valuetext":A===null?E(`Automatic`):E(`{pixels} pixels`,{pixels:Math.round(M)}),onChange:e=>L(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),L(null,!0))},onDoubleClick:()=>L(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),R.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??M,i=null,a=e=>{i=Math.min(Zu(),Math.max(64,r+(n-e.clientY))),L(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),R.current=void 0,i!==null&&L(i,!0)};R.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,X.jsx)(`input`,{ref:O,type:`file`,accept:v.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":E(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,X.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,X.jsx)(Wu,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,X.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),ue&&(0,X.jsx)(`div`,{className:`mention-menu`,id:k,role:`listbox`,"aria-label":E(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:(0,X.jsxs)(`div`,{className:`mention-list`,children:[(0,X.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,X.jsx)(`span`,{className:`mention-menu-folder`,children:le.folder?`@${le.folder}`:E(`Files in the conversation folder`)}),(0,X.jsx)(`span`,{children:E(`Enter inserts the path · Esc closes`)})]}),W.error?(0,X.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:nr(E,W.error)}):de?fe.length===0?(0,X.jsx)(`p`,{className:`mention-menu-note`,children:E(`No matching files`)}):null:(0,X.jsx)(`p`,{className:`mention-menu-note`,children:E(`Reading files…`)}),fe.map((e,t)=>(0,X.jsxs)(`button`,{type:`button`,role:`option`,id:`${k}-${t}`,className:`mention-item${e===ge?` active`:``}`,"aria-selected":e===ge,tabIndex:-1,title:e.path,onMouseEnter:()=>G(t),onClick:()=>ve(e),children:[e.directory?(0,X.jsx)(ga,{"aria-hidden":`true`}):(0,X.jsx)(_a,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,X.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),de?.limited&&(0,X.jsx)(`p`,{className:`mention-menu-note`,children:E(`Bounded listing; narrow the directory to see more.`)})]})}),(0,X.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":E(`Message`),"aria-autocomplete":ce?`list`:void 0,"aria-controls":ue?k:void 0,"aria-activedescendant":ue?_e:void 0,value:t,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{H(e.target.selectionStart),se(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;H(t===n?t:-1)},onFocus:()=>re(!0),onBlur:()=>re(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:ye}),(0,X.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,X.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>O.current?.click(),children:(0,X.jsx)(da,{"aria-hidden":`true`})}),(0,X.jsx)(hu,{...d}),(0,X.jsx)(Lu,{...f}),(0,X.jsx)(`span`,{className:`composer-hint`,children:p}),m&&S?.enabled&&(0,X.jsxs)(`span`,{className:`composer-split`,children:[(0,X.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":E(`Queue behind this reply`),title:E(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>S.onInput(`queue`),children:(0,X.jsx)(sa,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":E(`Steer this reply`),title:E(`Steer: read at the model's next step (Enter)`),onClick:()=>S.onInput(`steer`),children:(0,X.jsx)(La,{"aria-hidden":`true`})})]}),m?(0,X.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":E(`Stop response`),title:E(`Stop response`),disabled:!_,onClick:y,children:(0,X.jsx)(Wi,{"aria-hidden":`true`})}):(0,X.jsx)(`button`,{"aria-label":E(`Send`),title:E(`Send`),type:`submit`,className:`primary`,disabled:!b,children:(0,X.jsx)(La,{"aria-hidden":`true`})})]})]})}var $u={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,py:`python`,rs:`rust`,go:`go`,java:`java`,kt:`kotlin`,swift:`swift`,rb:`ruby`,php:`php`,lua:`lua`,pl:`perl`,r:`r`,cs:`csharp`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,md:`markdown`,sql:`sql`,diff:`diff`,patch:`diff`,graphql:`graphql`,mk:`makefile`};function ed(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn($u,n)&&$u[n]||`plaintext`}var td=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function nd(e,t){let n={oldTokens:[{type:`del`,text:e}],newTokens:[{type:`add`,text:t}]};if(!e||!t||e.length>800||t.length>800)return n;let r=e.match(td)||[e],i=t.match(td)||[t],a=r.length,o=i.length;if(a*o>4e3)return n;let s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=r[e-1]===i[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);if(s[a][o]/Math.max(a,o)<.25)return n;let c=[],l=[],u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(c.push({type:`same`,text:r[u-1]}),l.push({type:`same`,text:i[d-1]}),u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l.push({type:`add`,text:i[d-1]}),d--):(c.push({type:`del`,text:r[u-1]}),u--);let f=e=>{let t=[];for(let n of e.reverse()){let e=t.at(-1);e?.type===n.type?e.text+=n.text:t.push({...n})}return t};return{oldTokens:f(c),newTokens:f(l)}}function rd(e){if(!e)return[];let t=e.split(`
|
|
21
|
+
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function id(e){let t=0,n=0;return{hunks:e.map(({oldText:e,newText:r})=>{let i=rd(e),a=rd(r);n+=i.length,t+=a.length;let o=[];if(i.length===1&&a.length===1){let{oldTokens:e,newTokens:t}=nd(i[0],a[0]);o.push({type:`del`,content:i[0],tokens:e}),o.push({type:`add`,content:a[0],tokens:t})}else{for(let e of i)o.push({type:`del`,content:e});for(let e of a)o.push({type:`add`,content:e})}return{removed:i.length,added:a.length,lines:o}}),additions:t,deletions:n}}var ad=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function od(e){return ad(e)&&typeof e.oldText==`string`&&typeof e.newText==`string`}function sd(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!ad(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:ed(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=rd(n.content);return{...i,isWrite:!0,content:n.content,additions:e.length,deletions:0,hunks:[{removed:0,added:e.length,lines:e.map(e=>({type:`add`,content:e}))}]}}let a=`edits`in n?n.edits:[];return!Array.isArray(a)||((`oldText`in n||`newText`in n)&&a.push({oldText:n.oldText,newText:n.newText}),!a.length||!a.every(od))?null:{...i,isWrite:!1,...id(a)}}function cd({line:e}){return(0,X.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,X.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,X.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,X.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function ld({data:e,failed:t=!1}){let{t:n}=Z(),[r,i]=(0,h.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,X.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,X.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,X.jsxs)(`div`,{className:`file-diff-info`,children:[(0,X.jsx)(va,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,X.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,X.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,X.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,X.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,X.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,X.jsx)(Ua,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]}),e.isWrite&&(0,X.jsx)(Vs,{text:e.content,className:`write-copy`,label:`${n(`Copy full retained field`)} · ${n(`Requested content`)}`})]}),(0,X.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,X.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,X.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,X.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,X.jsx)(`div`,{className:`diff-hunk-header`,children:(0,X.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,X.jsx)(cd,{line:e},t))]},r))})}),!r&&a>400&&(0,X.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function ud(e){let t=e.items.map(e=>({..._n(e,1),text:e.role===`tool`||e.role===`thinking`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,...e.retry?{retry:e.retry}:{},omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function dd(e){return e.state===`pending`||e.state===`streaming`||e.state===`running`}function fd(e,t,n,r){let i=`${e.renderId??e.header.id}:${yl(n)}`,a=JSON.stringify([t,n.parts,n.version,n.state,n.error,e.header.status]),{detail:o}=e,s=(0,h.useMemo)(()=>({identity:i,revision:a,detail:o,wanted:r}),[i,a,o,r]),c=(0,h.useRef)(s);c.current=s;let[l,u]=(0,h.useState)(),d=n.parts;return(0,h.useEffect)(()=>{if(!r||d===0)return;let e=new AbortController,n=()=>!e.signal.aborted&&c.current===s;return o(t,d,e.signal).then(e=>{n()&&u({identity:i,value:e})},e=>{n()&&u(t=>({identity:i,...t?.identity===i?{value:t.value}:{},error:e instanceof Error?e.message:`unavailable`}))}),()=>e.abort()},[s,o,t,d,r,i]),r&&d>0&&l?.identity===i?l:{}}function pd(e){let t=e.map((e,t)=>({step:e,index:t,key:yl(e)}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var md={bash:[Hi,`exec`],powershell:[Hi,`exec`],read:[va,`read`],ls:[ga,`read`],write:[ba,`edit`],edit:[xa,`edit`],grep:[Ji,`search`],find:[Oa,`search`]},hd=[Vi,`default`],gd=e=>Object.hasOwn(md,e)?md[e]:hd;function _d(e,t){let n=e.steps[t];return n?.error||n?.state===`failed`?`err`:n?.state===`completed`?`ok`:n&&dd(n)&&wl(e.header.status)?`run`:`idle`}var vd={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function yd(){return(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function bd({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,X.jsx)(qs,{text:e})}){let{t:a}=Z(),o=t<e.header.stable,s=fd(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,X.jsxs)(X.Fragment,{children:[n.images?.length?(0,X.jsx)(Ku,{images:n.images,turn:e}):null,c.trim()!==``&&(0,X.jsxs)(`div`,{className:`msg-text single`,children:[(0,X.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,X.jsx)(Vs,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,X.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?nr(a,s.error):a(`Reading the rest of this message…`)})]})}function xd(e){try{let t=JSON.parse(e),n=t&&typeof t==`object`&&Object.hasOwn(t,`command`)?t.command:void 0;return typeof n==`string`&&n?n:void 0}catch{return}}function Sd(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Cd({turn:e,index:t,step:n}){let{t:r}=Z(),[i,a]=(0,h.useState)(!1),o=fd(e,t,n,i),[s,c]=gd(n.name),l=_d(e,t),u=r(vd[l]),d=o.value?.args,f=d?xd(d):void 0,p=(0,h.useMemo)(()=>d?sd(n.name,d):null,[n.name,d]),m=d&&!p?f??Sd(d):``;return(0,X.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,X.jsx)(Nc,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,X.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,X.jsx)(zi,{"aria-hidden":`true`}):l===`ok`?(0,X.jsx)(Fa,{"aria-hidden":`true`}):l===`run`?(0,X.jsx)(yd,{}):(0,X.jsx)(ta,{"aria-hidden":`true`})}),n.target&&(0,X.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,X.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,X.jsx)(Vs,{text:n.target,label:r(`Copy tool summary`),className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,X.jsxs)(`div`,{className:`toolcall-body`,children:[n.parts===0?(0,X.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,X.jsxs)(X.Fragment,{children:[o.value.args&&(0,X.jsx)(`div`,{className:`toolcall-args`,children:p?(0,X.jsx)(ld,{data:p,failed:l===`err`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(f?`Command`:`Arguments`),(0,X.jsx)(Vs,{text:m,label:r(f?`Copy command`:`Copy arguments`),className:`output-copy`})]}),f?(0,X.jsxs)(`div`,{className:`termline`,children:[(0,X.jsx)(Hi,{className:`termline-icon`,"aria-hidden":`true`}),(0,X.jsx)(`code`,{children:m})]}):(0,X.jsx)(`pre`,{children:m})]})}),o.value.text&&(0,X.jsxs)(`div`,{className:`toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[r(l===`err`?`Error output`:`Output`),` · `,u,(0,X.jsx)(Vs,{text:o.value.text,label:r(`Copy output`),className:`output-copy`})]}),(0,X.jsx)(`pre`,{children:o.value.text})]})]}):(0,X.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?nr(r,o.error):r(`Reading…`)}),o.value&&o.error&&(0,X.jsx)(`p`,{className:`banner-notice`,children:nr(r,o.error)})]})]})}function wd({turn:e,index:t,step:n}){let{t:r}=Z(),[i,a]=(0,h.useState)(!1),o=fd(e,t,n,i&&n.parts>0),s=dd(n)&&wl(e.header.status);if(n.parts===0)return(0,X.jsx)(`div`,{className:`thinking`,children:(0,X.jsxs)(`div`,{className:`chead thinking-head`,title:r(`Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.`),children:[(0,X.jsx)(wa,{className:`thinking-icon`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`thinking-label`,role:`status`,children:r(s?`Thinking activity observed`:n.state===`completed`?`Thinking activity ended`:`Thinking content unavailable`)}),s&&(0,X.jsx)(yd,{})]})});let c=o.value?.text.trim()??``;return(0,X.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,X.jsx)(Nc,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,X.jsx)(wa,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`toolcall-spacer`}),c&&(0,X.jsx)(Vs,{text:c,className:`chead-copy`})]}),children:r(`Thinking`)}),i&&(0,X.jsx)(`div`,{className:`thinking-body`,children:c||(0,X.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?nr(r,o.error):o.value?r(`No thinking text is recorded for this block.`):r(`Reading…`)})})]})}var Td=c().use(m).use(l).use(p).use(Ts);function Ed(e){return e.type===`definition`||e.type===`linkReference`||e.type===`imageReference`||e.type===`footnoteDefinition`||e.type===`footnoteReference`||(e.children?.some(Ed)??!1)}function Dd(e,t){if(e?.type!==`code`)return!1;let n=t.split(/\r\n|\r|\n/),r=/^ {0,3}(`{3,}|~{3,})/.exec(n[0]);if(!r)return!1;let i=r[1];return!n.slice(1).some(e=>{let t=/^ {0,3}(`{3,}|~{3,})[\t ]*$/.exec(e);return t&&t[1][0]===i[0]&&t[1].length>=i.length})}function Od(e){let{children:t}=Td.parse(e),n=e?[0]:[];for(let e=0;e<t.length;e++){let r=t[e],i=r.position?.start;if(e>0&&i?.offset!==void 0&&n.push(i.offset-(i.column-1)),Ed(r))break}let r=n.map((t,r)=>({start:t,text:e.slice(t,n[r+1])})),i=r.at(-1)?.text??``,a=t.at(-1),o=r.length===t.length&&Dd(a,e.slice(a?.position?.start.offset));return{segments:r,frozen:r.slice(0,-1).map(e=>e.text),active:i,inFence:o}}var kd=(0,h.memo)(function({text:e}){return(0,X.jsx)(Ks,{text:e})}),Ad=(0,h.memo)(function({text:e}){let{segments:t}=(0,h.useMemo)(()=>Od(e),[e]);return(0,X.jsx)(`div`,{className:`md`,children:t.map(e=>(0,X.jsx)(kd,{text:e.text},`stream-offset:${e.start}`))})});function jd(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
22
22
|
|
|
23
|
-
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function
|
|
24
|
-
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:T}=u,E=m&&!f.some(({step:e})=>
|
|
25
|
-
`)}),!m&&u.status!==`completed`&&(0,
|
|
26
|
-
void main(){uv=p*.5+.5; gl_Position=vec4(p,0.,1.);}`,
|
|
23
|
+
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function Md({label:e,children:t}){return(0,X.jsx)(`div`,{className:`msg-actions`,role:`group`,"aria-label":e,children:t})}function Nd({icon:e,label:t,title:n=t,showLabel:r=!1,done:i=!1,onClick:a}){return(0,X.jsxs)(`button`,{type:`button`,className:`msg-action${r?` labelled`:``}${i?` done`:``}`,title:n,"aria-label":t,onClick:a,children:[e,r&&(0,X.jsx)(`span`,{className:`msg-action-label`,children:t})]})}function Pd({turn:e,parts:t}){let{t:n}=Z(),{copied:r,copy:i}=Ss();return(0,X.jsx)(Nd,{icon:r?(0,X.jsx)(Fa,{"aria-hidden":`true`}):(0,X.jsx)(Da,{"aria-hidden":`true`}),label:n(`Copy message`),done:r,onClick:()=>{let r=()=>Is(`error`,n(`Copy unavailable`)),a=e=>i(e).then(e=>{e||r()}),o=jd(e,t,new AbortController().signal);typeof o==`string`?a(o):o.then(a,r)}})}var Fd=(e,t)=>new Date(e).toLocaleTimeString(t===`zh`?`zh-CN`:`en-GB`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),Id=(0,h.memo)(function({turn:e,onContinue:t,onEdit:n,version:r=0,versions:i=0,onVersion:a,off:o=!1}){let{t:s,tx:c,locale:l}=Z(),{header:u}=e,{user:d,replies:f}=pd(e.steps),p=f.filter(({step:e})=>e.role===`assistant`&&!e.error),m=wl(u.status),g=t&&u.entry&&(0,X.jsx)(Nd,{icon:(0,X.jsx)(Ea,{"aria-hidden":`true`}),label:s(`Continue from here`),title:s(`Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.`),showLabel:!0,onClick:()=>t(u.id)}),_=n&&!m&&(0,X.jsx)(Nd,{icon:(0,X.jsx)(xa,{"aria-hidden":`true`}),label:s(`Edit and resend`),title:s(`Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.`),onClick:()=>n(u.id)}),[v,y]=(0,h.useState)(!1),{thinking:b,media:x,other:S}=u.omitted,C=[b&&s(`Thinking that could not be read is not shown.`),x&&s(`Media is not retained.`),S&&s(`Other content is not retained.`)].filter(e=>e!==!1),w=u.notice.split(`
|
|
24
|
+
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:T}=u,E=m&&!f.some(({step:e})=>dd(e)),D=u.at>0&&(0,X.jsx)(`time`,{className:`msg-time`,dateTime:new Date(u.at).toISOString(),children:Fd(u.at,l)}),O=f.length>0||m||C.length>0;return(0,X.jsxs)(`section`,{className:o?`chat-turn off-branch`:`chat-turn`,"aria-label":s(o?`Conversation turn, not in the new message's context`:`Conversation turn`),children:[d.map(({step:t,index:n,key:o},c)=>{let l=t.text.trim()!==``,f=c===0&&_,p=!O&&c===d.length-1&&g;return(0,X.jsxs)(`article`,{className:`msg msg-user`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:s(`You`)}),D,c===0&&i>1&&(0,X.jsxs)(`span`,{className:`msg-versions`,role:`group`,"aria-label":s(`Version {index} of {count}`,{index:r,count:i}),children:[(0,X.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Previous version`),title:s(`Previous version`),disabled:!a||r<=1,onClick:()=>a?.(u.id,-1),children:(0,X.jsx)(Na,{"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`msg-version-count`,"aria-hidden":`true`,children:[r,`/`,i]}),(0,X.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Next version`),title:s(`Next version`),disabled:!a||r>=i,onClick:()=>a?.(u.id,1),children:(0,X.jsx)(Ma,{"aria-hidden":`true`})})]})]}),(0,X.jsx)(`div`,{className:`msg-body`,children:(0,X.jsx)(bd,{turn:e,index:n,step:t,copy:!1})}),(l||f||p)&&(0,X.jsxs)(Md,{label:s(`Message actions`),children:[f,l&&(0,X.jsx)(Pd,{turn:e,parts:[{step:t,index:n,key:o}]}),p]})]},o)}),O&&(0,X.jsxs)(`article`,{className:`msg msg-assistant`,children:[(0,X.jsxs)(`div`,{className:`msg-meta`,children:[(0,X.jsx)(`span`,{className:`msg-role`,children:`Cadence`}),T&&(0,X.jsx)(`button`,{type:`button`,className:`msg-model`,"aria-expanded":v,title:s(`Context fixed at admission:`),onClick:()=>y(e=>!e),children:T.model?`${T.model.provider}/${T.model.model}`:s(`No model`)}),d.length===0&&D]}),T&&v&&(0,X.jsxs)(`p`,{className:`msg-context`,children:[s(`Context fixed at admission:`),` `,(0,X.jsx)(`code`,{children:T.cwd}),` · `,T.model?`${T.model.provider}/${T.model.model} · ${T.model.thinking}`:s(`No model`)]}),(0,X.jsxs)(`div`,{className:`msg-body`,children:[f.map(({step:t,index:n,key:r})=>t.role===`tool`?(0,X.jsx)(Cd,{turn:e,index:n,step:t},r):t.role===`thinking`?(0,X.jsx)(wd,{turn:e,index:n,step:t},r):(0,X.jsxs)(`div`,{className:`msg-part`,children:[t.error&&(0,X.jsx)(`span`,{className:`ep-state failed`,children:s(`Incomplete model response`)}),(0,X.jsx)(bd,{turn:e,index:n,step:t,render:e=>(0,X.jsx)(Ad,{text:e,streaming:m&&t.state===`streaming`})})]},r)),E&&(0,X.jsxs)(`p`,{className:`msg-working`,role:`status`,children:[(0,X.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),u.status===`running`?s(`Working…`):c(u.status)]}),C.map(e=>(0,X.jsx)(`p`,{className:`msg-omitted`,children:e},e))]}),!m&&(p.length>0||g)&&(0,X.jsxs)(Md,{label:s(`Message actions`),children:[p.length>0&&(0,X.jsx)(Pd,{turn:e,parts:p}),g]})]}),u.status===`running`&&u.retry&&(0,X.jsxs)(`p`,{className:`inspector-note chat-turn-retry`,role:`status`,children:[u.retry.phase===`waiting`?s(`Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts,seconds:Math.ceil(u.retry.delayMs/1e3)}):s(`Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts}),u.retry.reason&&` ${s(`The provider said: {reason}`,{reason:u.retry.reason})}`]}),w.length>0&&(0,X.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:w.map(e=>c(e)).join(`
|
|
25
|
+
`)}),!m&&u.status!==`completed`&&(0,X.jsx)(`p`,{className:`ep-state ${u.status}`,children:c(u.status)})]})});function Ld(e,t,n){let r=Math.min(1/3,Math.sqrt(n/Math.max(1,e*t)));return[Math.max(1,Math.floor(e*r)),Math.max(1,Math.floor(t*r))]}var Rd=`attribute vec2 p; varying vec2 uv;
|
|
26
|
+
void main(){uv=p*.5+.5; gl_Position=vec4(p,0.,1.);}`,zd=`precision mediump float;
|
|
27
27
|
varying vec2 uv; uniform vec2 origin, tilt; uniform vec3 silver, violet; uniform float phase, aspect;
|
|
28
28
|
void main(){
|
|
29
29
|
vec2 p=(uv-origin)*vec2(aspect,1.);
|
|
@@ -36,11 +36,11 @@ void main(){
|
|
|
36
36
|
float seed=fract(sin(dot(floor(cell),vec2(17.1,31.7)))*121.3);
|
|
37
37
|
float dust=step(.978,seed)*(1.-smoothstep(.03,.18,length(fract(cell)-.5)));
|
|
38
38
|
gl_FragColor=vec4(mix(silver,violet,smoothstep(-.35,.35,q.x)),flare*(.036+.032*arc+.024*dust));
|
|
39
|
-
}`;function Id(e){return(e.match(/[\d.]+/g)?.map(Number)??[]).slice(0,3).map(t=>e.startsWith(`color(srgb `)?t:t/255)}function Ld(e){let t;try{t=e.getContext(`webgl`,{antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,powerPreference:`low-power`})}catch{return null}if(!t)return null;let n=[],r=t.createProgram(),i=t.createBuffer(),a=()=>{t.useProgram(null);for(let e of n)t.deleteShader(e);t.deleteProgram(r),t.deleteBuffer(i)};try{if(!r||!i)throw Error();for(let[e,i]of[[t.VERTEX_SHADER,Pd],[t.FRAGMENT_SHADER,Fd]]){let a=t.createShader(e);if(!a)throw Error();n.push(a),t.shaderSource(a,i),t.compileShader(a),t.attachShader(r,a)}if(t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw Error();t.useProgram(r),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),t.STATIC_DRAW);let o=t.getAttribLocation(r,`p`);t.enableVertexAttribArray(o),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0);let s=e=>t.getUniformLocation(r,e),c=s(`silver`),l=s(`violet`),u=s(`aspect`),d=s(`phase`),f=s(`origin`),p=s(`tilt`);return{dispose:a,configure(n,r){let[i,a]=Nd(e.clientWidth,e.clientHeight,Number(n.getPropertyValue(`--ambient-pixels`))||256e3);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),t.viewport(0,0,i,a);let o=e.getBoundingClientRect(),s=r?(r.x+r.width/2-o.x)/o.width:.5,d=r?(r.y+r.height/2-o.y)/o.height:.38;t.uniform2f(f,s,1-d),t.uniform1f(u,i/a),t.uniform3fv(c,Id(n.color)),t.uniform3fv(l,Id(n.borderTopColor))},draw(e,n,r){t.uniform2f(p,n,r),t.uniform1f(d,e/6500%(2*Math.PI)),t.drawArrays(t.TRIANGLES,0,3)}}}catch{return a(),null}}function Rd(e,t=Ld,n=()=>null){let r=matchMedia(`(prefers-reduced-motion: reduce)`),i=matchMedia(`(prefers-color-scheme: dark)`),a,o,s,c=!1,l=!1,u=!0,d=-1/0,f=1e3/24,p=()=>{window.clearTimeout(o),s!==void 0&&cancelAnimationFrame(s),o=s=void 0},m=()=>!document.hidden&&!r.matches&&!c&&!l&&e.dataset.scene===`hero`,h=0,g=0,_=e=>{h=e.clientX/window.innerWidth-.5,g=.5-e.clientY/window.innerHeight},v=r=>{if(s=void 0,m()){if(r-d>=f){if(a??=t(e),!a){l=!0;return}if(u){let t=getComputedStyle(e);a.configure(t,n()?.getBoundingClientRect()),f=1e3/Math.min(24,Math.max(1,Number(t.getPropertyValue(`--ambient-fps`))||24)),u=!1}a.draw(r,h,g),d=r}o=window.setTimeout(()=>{o=void 0,m()&&(s=requestAnimationFrame(v))},Math.max(1,d+f-performance.now()))}},y=()=>{p(),u=!0,window.removeEventListener(`pointermove`,_),m()&&(window.addEventListener(`pointermove`,_,{passive:!0}),s=requestAnimationFrame(v))},b=e=>{e.preventDefault(),c=!0,a=null,y()},x=()=>{c=l=!1,y()},S=new MutationObserver(y);S.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),S.observe(e,{attributes:!0,attributeFilter:[`data-scene`]});let C=e.closest?.(`.app`)?.querySelector(`.main`),w=C?new ResizeObserver(y):null;C&&w?.observe(C),window.addEventListener(`resize`,y),document.addEventListener(`visibilitychange`,y);for(let e of[r,i])e.addEventListener(`change`,y);return e.addEventListener(`webglcontextlost`,b),e.addEventListener(`webglcontextrestored`,x),y(),()=>{p(),S.disconnect(),w?.disconnect(),window.removeEventListener(`pointermove`,_),window.removeEventListener(`resize`,y),document.removeEventListener(`visibilitychange`,y);for(let e of[r,i])e.removeEventListener(`change`,y);e.removeEventListener(`webglcontextlost`,b),e.removeEventListener(`webglcontextrestored`,x),a?.dispose()}}var zd=(0,h.createContext)(null);function Bd(e){let t=(0,h.useRef)(null),n=(0,h.useContext)(zd);return(0,h.useEffect)(()=>{if(e)return n?.(t.current),()=>n?.(null)},[n,e]),t}var Vd=`cadence-ambient-v1`;function Hd(){try{return localStorage.getItem(Vd)!==`off`}catch{return!0}}function Ud(e){try{localStorage.setItem(Vd,e?`on`:`off`)}catch{}}var Wd=(0,h.memo)(function({enabled:e,hero:t}){let n=(0,h.useRef)(null),r=(0,h.useRef)(t);return r.current=t,(0,h.useEffect)(()=>{if(e&&n.current)return Rd(n.current,void 0,()=>r.current)},[e]),(0,Y.jsx)(`div`,{className:`optical-field`,"aria-hidden":`true`,"data-enabled":e,"data-scene":t?`hero`:`reading`,children:(0,Y.jsx)(`canvas`,{ref:n,"data-scene":t?`hero`:`reading`})})});function Gd(){return(0,Y.jsxs)(`svg`,{viewBox:`0 0 36 36`,fill:`none`,"aria-hidden":`true`,children:[(0,Y.jsx)(`path`,{d:`m18 2 13 9-4 16-9 7-9-7-4-16Z`,fill:`currentColor`,opacity:`.12`}),(0,Y.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.4`,strokeLinejoin:`round`,children:[(0,Y.jsx)(`path`,{d:`m18 2 13 9-4 16-9 7-9-7-4-16Z`}),(0,Y.jsx)(`path`,{d:`m5 11 13 5 13-5M18 2v14l-9 11m9-11 9 11m-9-11v18`})]})]})}function Kd({visible:e=!0,hint:t,children:n}){let r=Bd(e),{t:i}=X();return(0,Y.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,Y.jsx)(`span`,{ref:r,className:`empty-logo`,"aria-hidden":`true`,children:(0,Y.jsx)(Gd,{})}),(0,Y.jsx)(`h2`,{children:i(`What would you like to work on?`)}),(0,Y.jsx)(`p`,{children:t}),n]})}function qd({draft:e,active:t,disabled:n,error:r,onEdit:i,onSubmit:a}){let{t:o}=X(),s=t&&!n&&!e.submitted,[c,l]=(0,h.useState)(s?`open`:`waiting`);(0,h.useEffect)(()=>{c===`waiting`&&s&&l(`open`)},[c,s]);let[u,d]=(0,h.useState)(``),[f,p]=(0,h.useState)(),m=e.questions.filter(t=>Jt(t,e.answers)),g=m.find(e=>e.id===u)??m[0],_=e.answers.find(e=>e.question===g.id),v=_&&`other`in _?_.other:``,y=f?.question===g.id?f.value:v,b=!!y.trim()&&y.trim()!==v,x=(0,h.useRef)(null),S=_&&`option`in _?_.option:null,C=t&&c===`open`;(0,h.useLayoutEffect)(()=>{g.id;let e=x.current;if(!C||!e||!S)return;let t=e.querySelector(`input:checked`)?.closest(`label`);if(!t)return;let n=()=>{e.style.setProperty(`--pill-y`,`${t.offsetTop}px`),e.style.setProperty(`--pill-h`,`${t.offsetHeight}px`)};n();let r=new ResizeObserver(n);for(let t of e.querySelectorAll(`label`))r.observe(t);return()=>r.disconnect()},[C,S,g.id]);let w=t=>i([...e.answers.filter(e=>e.question!==g.id),t]);return(0,Y.jsxs)(`section`,{className:`workflow-plan`,"aria-label":o(`Design choices`),children:[(0,Y.jsx)(`h3`,{children:o(`Design choices`)}),e.submitted?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`status`,children:o(`Design submitted`)}),(0,Y.jsx)(`dl`,{children:m.map(t=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`dt`,{children:t.question}),(0,Y.jsx)(`dd`,{children:Zt(t,e.answers.find(e=>e.question===t.id))})]},t.id))})]}):(0,Y.jsx)(`p`,{children:o(`{answered} of {total} questions answered`,{answered:e.answers.length,total:m.length})}),(0,Y.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,disabled:!t,onClick:()=>l(`open`),children:e.submitted?o(`Review choices`):o(`Choose answers`)}),C&&(0,Y.jsxs)(lc,{title:o(`Design choices`),onClose:()=>l(`closed`),children:[(0,Y.jsxs)(`section`,{className:`design-card`,children:[(0,Y.jsx)(`nav`,{"aria-label":o(`Questions`),children:m.map((t,n)=>(0,Y.jsxs)(`button`,{type:`button`,disabled:b&&t.id!==g.id,"aria-current":t.id===g.id?`step`:void 0,onClick:()=>d(t.id),children:[n+1,`. `,t.question,` ·`,` `,Zt(t,e.answers.find(e=>e.question===t.id))??`…`]},t.id))}),(0,Y.jsxs)(`fieldset`,{disabled:n,children:[(0,Y.jsx)(`legend`,{children:g.question}),(0,Y.jsx)(`div`,{className:`design-track`,ref:x,"data-selected":!!S,children:g.options.map(t=>(0,Y.jsxs)(`label`,{className:`design-option`,children:[(0,Y.jsx)(`input`,{type:`radio`,name:e.id+g.id,checked:!!_&&`option`in _&&_.option===t.id,onChange:()=>{p(void 0),w({question:g.id,option:t.id})}}),(0,Y.jsxs)(`span`,{children:[t.label,t.id===g.recommended?` · ${o(`Recommended`)}`:``,(0,Y.jsx)(`small`,{children:t.cost})]})]},t.id))}),(0,Y.jsx)(`p`,{children:g.reason}),(0,Y.jsxs)(`p`,{children:[o(`Acceptance`),` · `,g.acceptance]}),(0,Y.jsxs)(`label`,{className:_&&`other`in _?`design-custom chosen`:`design-custom`,children:[o(`Other idea`),` `,(0,Y.jsx)(`input`,{value:y,onChange:e=>p({question:g.id,value:e.target.value})})]}),(0,Y.jsx)(`button`,{type:`button`,disabled:!b,onClick:()=>void w({question:g.id,other:y.trim()}),children:o(`Use this answer`)}),b&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>p(void 0),children:o(`Discard typed answer`)})]}),r&&(0,Y.jsx)(`p`,{role:`alert`,children:r}),(0,Y.jsx)(`p`,{children:o(`Submitting answers requests a plan, not implementation.`)})]}),!e.submitted&&(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{type:`button`,disabled:n||b||e.answers.length===m.length,onClick:()=>void i(Yt(e.questions,e.answers,!0)),children:o(`Fill unanswered with recommendations`)}),(0,Y.jsx)(`button`,{type:`button`,className:`primary`,disabled:n||b,onClick:()=>{l(`closed`),a(en(e,e.answers,!0))},children:o(`Submit design and use recommendations for unanswered questions`)})]})]})]})}function Jd(e,t,n){let r=Math.max(0,t),i=Math.floor((r+4)/7),a=Math.min(e,i),o=Array.from({length:a},(t,r)=>{let i=Math.floor(r*e/a),o=Math.floor((r+1)*e/a)-1;return n>=i&&n<=o?n:r===a-1?o:i}),s=a>1?Math.min(27,(r-a*3)/(a-1)):0;return{indices:o,gap:s,many:e>a||a>1&&s<20}}function Yd({questions:e,active:t,reading:n,onJump:r}){let{t:i}=X(),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(0);(0,h.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>s(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let{indices:c,gap:l,many:u}=(0,h.useMemo)(()=>Jd(e.length,o,t),[e.length,o,t]),d=c.includes(t)?t:c.at(-1),f=e=>{let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t&&e.key!==`Home`&&e.key!==`End`)return;let n=[...e.currentTarget.querySelectorAll(u?`.qn-list-item`:`.qn-bar`)];if(!n.length)return;e.preventDefault();let r=document.activeElement,i=u?Number(r?.dataset.question??0):n.indexOf(r);n[e.key===`Home`?0:e.key===`End`?n.length-1:Math.min(n.length-1,Math.max(0,i+t))]?.focus()},p=()=>a.current?.querySelector(`.qn-list-item.active`)?.scrollIntoView({block:`nearest`}),m=(e,t)=>{e.detail>0&&e.currentTarget.blur(),r(t)},g=t=>`${t+1}. ${e[t].text}`;return(0,Y.jsxs)(`nav`,{className:`qn-rail${u?` many`:``}`,ref:a,"aria-label":i(`Questions in this conversation`),style:{"--rail-gap":`${l}px`},onKeyDown:f,onMouseEnter:p,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||p()},children:[c.map(r=>{let i=e[r];return(0,Y.jsx)(`button`,{type:`button`,className:`qn-bar${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===i.id||void 0,"data-question":r,tabIndex:r===d?0:-1,onClick:e=>m(e,i.id),children:(0,Y.jsx)(`span`,{className:`qn-bar-text`,children:g(r)})},i.id)}),u&&(0,Y.jsx)(`div`,{className:`qn-list`,children:e.map((e,r)=>(0,Y.jsxs)(`button`,{type:`button`,className:`qn-list-item${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===e.id||void 0,"data-question":r,tabIndex:-1,onClick:t=>m(t,e.id),children:[(0,Y.jsx)(`span`,{className:`qn-list-idx`,children:r+1}),(0,Y.jsx)(`span`,{className:`qn-list-text`,children:e.text||`…`})]},e.id))})]})}var Xd={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`},Zd=(e,t,n)=>new File([e],`image-${n+1}.${Xd[t.mimeType]??`img`}`,{type:t.mimeType});function Qd({draftKey:e,draft:t,setDraft:n,images:r,alive:i,onUnread:a}){let[o,s]=(0,h.useState)(()=>{try{return ll(sessionStorage.getItem(`${e}:anchor`))}catch{return null}}),c=(0,h.useRef)(o);c.current=o,(0,h.useEffect)(()=>{try{o?sessionStorage.setItem(`${e}:anchor`,JSON.stringify(o)):sessionStorage.removeItem(`${e}:anchor`)}catch{}},[e,o]);let l=(0,h.useRef)([]),u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=()=>{u.current?.abort(),u.current=null,f(!1)},m=()=>{p();let e=c.current;e&&(c.current=null,s(null),n(e.stash),r.replace(l.current),l.current=[])},g=(e,n,i)=>{p();let a=c.current;a||(l.current=r.files);let o=ld(e.steps).user[0],u={kind:n,entry:i,turnId:e.header.id,from:n===`edit`?e.ordinal:e.ordinal+1,label:al(o?.step.text??``),media:n===`edit`&&e.header.omitted.media,stash:a?a.stash:t};return c.current=u,s(u),r.replace([]),o};return{anchor:o,current:()=>c.current,attaching:d,release:m,continueAfter:e=>e.header.entry?(g(e,`continue`,e.header.entry),n(``),!0):!1,edit:(e,t)=>{let o=ol(e,t);if(o===void 0)return!1;let s=g(e,`edit`,o);if(n(s?.step.text??``),!s)return!0;let c=s.step.text,l=s.step.images??[],d=new AbortController,p=Dd(e,[s],d.signal);if(typeof p==`string`&&!l.length)return!0;u.current=d,f(!0);let{image:m}=e;return Promise.allSettled([p,...l.map((e,t)=>m?m(e,d.signal).then(n=>Zd(n,e,t)):Promise.reject(Error(`unavailable`)))]).then(([e,...t])=>{if(d.signal.aborted||!i.current)return;u.current=null,f(!1),e.status===`fulfilled`&&n(t=>t===c?e.value:t);let o=t.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);try{o.length&&r.add(o)}catch{o.length=0}(e.status===`rejected`||o.length<l.length)&&a()}),!0}}}function $d({pending:e,undelivered:t,canWithdraw:n,recallable:r,onWithdraw:i,onRestore:a}){let{t:o,tx:s}=X();return!e.length&&!t.length?null:(0,Y.jsxs)(`section`,{className:`chat-waiting-list`,"aria-label":o(`Waiting messages`),children:[e.map(e=>(0,Y.jsxs)(`article`,{className:`chat-waiting ${e.mode}`,children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`span`,{className:`chat-waiting-tag ${e.mode}`,children:e.mode===`steer`?o(`Steering: read at the model's next step`):o(`Queued: sent when this reply ends`)}),(0,Y.jsxs)(`span`,{className:`chat-waiting-actions`,children:[r(e)&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw and put back in the message box`),"aria-label":o(`Withdraw and put back in the message box`),onClick:()=>i(e,!0),children:(0,Y.jsx)(wa,{"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw`),"aria-label":o(`Withdraw`),onClick:()=>i(e,!1),children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]})]}),(0,Y.jsx)(`p`,{className:`chat-attempt-text`,children:e.text})]},e.commandId)),t.map(e=>(0,Y.jsxs)(`article`,{className:`chat-attempt chat-undelivered`,children:[(0,Y.jsx)(`p`,{className:`chat-attempt-text`,children:e.text}),(0,Y.jsxs)(`p`,{className:`inspector-note`,children:[(0,Y.jsx)(`span`,{className:`ep-state ${e.status}`,children:s(e.status)}),` `,e.notice?s(e.notice):o(`Not delivered.`)]}),(0,Y.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(e.text),children:[(0,Y.jsx)(wa,{"aria-hidden":`true`}),o(`Put back in the message box`)]})]},e.commandId))]})}function ef({file:e}){let{t}=X();return(0,Y.jsxs)(`div`,{className:`retained-result toolcall-output`,children:[(0,Y.jsxs)(`div`,{className:`toolcall-output-label`,children:[t(`Step result`),(0,Y.jsx)(zs,{text:e.text,label:t(`Copy output`),className:`output-copy`})]}),(0,Y.jsx)(`pre`,{className:`workflow-detail`,children:e.text}),e.limited&&(0,Y.jsx)(`p`,{children:t(`Preview is truncated.`)})]})}var tf=[`queued`,`running`],nf=e=>tf.includes(e.status);function rf(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function af(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function of(e,t,n){let r=[],i=[],a=new Map;if(!e.length)return{start:r,after:a,end:i};let o=e.filter(e=>e.header.at>0),s=e=>rf(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=rf(e),s=t===null?void 0:o.findLast(e=>e.header.at<=t);t===null||!o.length?i.push(e):s?a.set(s.header.id,[...a.get(s.header.id)??[],e]):n||r.push(e)}return{start:r,after:a,end:i}}function sf(e,t,n,r,i,a){if(t>=e.length)return t;let o=e.slice(-t);if(o.some(e=>!n.has(e)&&!r.has(e)))return t;let s=o.flatMap(e=>{let t=n.get(e),r=t?rf(t):null;return r===null?[]:[r]}),c=s.length?Math.min(...s):1/0;return a||i!==void 0&&c>=i?t+8:t}function cf(e,t){let n=e.diagnostics?.acceptedAt,r=e.diagnostics?.settledAt;if(!n||!r||r<n)return``;let i=Math.round((r-n)/1e3);return i<60?t(`{s}s`,{s:i}):i<3600?t(`{m}m {s}s`,{m:Math.floor(i/60),s:i%60}):t(`{h}h {m}m`,{h:Math.floor(i/3600),m:Math.floor(i%3600/60)})}function lf({client:e,run:t,canCancelWorkflow:n,onOpen:r,onChanged:i}){let{t:a,tx:o}=X(),s=(0,h.useId)(),[c,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(``),f=(0,h.useRef)(!0);(0,h.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let p=nf(t),m=p?zc(t):null,g=t.status===`completed`?t.deviations?.length??0:0,_=g?g===1?a(`delivered with 1 deviation`):a(`delivered with {count} deviations`,{count:g}):``,v=e=>e.filter(Boolean).join(` · `),y=v(p?[o(af(t)),m?Rc(m,a):t.steps.filter(e=>e.status===`running`).map(e=>Fc(e.id)).join(`, `)]:[o(t.status)]),b=p?``:v([t.mergedCommit?a(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,cf(t,a)]),x=p||t.status===`completed`?``:t.notice.split(`
|
|
40
|
-
`).find(e=>e.trim())??``,S=v([y,_,b]);return(0,Y.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":s,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:a(`Open workflow details`),onClick:r,children:[(0,Y.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`workflow-line-goal`,id:s,children:t.goal}),(0,Y.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:S,children:_?(0,Y.jsxs)(Y.Fragment,{children:[`${y} · `,(0,Y.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,Y.jsx)(Va,{"aria-hidden":`true`}),_]}),b&&` · ${b}`]}):S})]}),p&&(0,Y.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":a(`Cancel workflow — request stop`),title:a(`Cancel workflow — request stop`),disabled:c||!n?.(t),onClick:()=>{!c&&n?.(t)&&(l(!0),d(``),ff(e,t,n).then(e=>{f.current&&(d(e),i?.())}).finally(()=>{f.current&&l(!1)}))},children:[(0,Y.jsx)(Ui,{"aria-hidden":`true`}),a(`Stop`)]}),u?(0,Y.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:tr(a,u)}):x&&(0,Y.jsx)(`p`,{className:`workflow-line-reason`,title:x,children:o(x)})]})}function uf(e){if(e.pointerType!==`mouse`||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.currentTarget,n=t.getBoundingClientRect();t.style.setProperty(`--spot-x`,`${e.clientX-n.left}px`),t.style.setProperty(`--spot-y`,`${e.clientY-n.top}px`)}function df({proposal:e,canApprove:t,approvalHint:n,onApprove:r,action:i=`approve`,canValidate:a=!1,validating:o=!1,previous:s,onValidate:c}){let{t:l}=X();return(0,Y.jsxs)(`section`,{className:`workflow-plan`,"aria-label":l(`Current implementation plan`),children:[(0,Y.jsx)(`h3`,{children:l(`Current implementation plan`)}),e.revalidatedFrom&&(0,Y.jsx)(`p`,{role:`status`,children:l(`The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.`)}),s&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:l(`Previous execution context`)}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{children:s.cwd}),` · `,s.display?.model]}),(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{children:s.display?.branch}),` ·`,` `,(0,Y.jsx)(`code`,{children:s.display?.baseCommit})]}),s.display?.runtime&&(0,Y.jsx)(`p`,{children:s.display.runtime}),s.delivery&&(0,Y.jsx)(Gs,{text:jt(s.delivery)})]}),s&&s.observation!==e.observation&&(0,Y.jsx)(`p`,{role:`status`,children:l(`Repository or execution-environment evidence changed. Review the current context before confirming.`)}),(0,Y.jsx)(`p`,{children:l(`Tools and checks run on the service host, not in a sandbox.`)}),(0,Y.jsxs)(`div`,{className:`plan-context`,children:[(0,Y.jsxs)(`p`,{onPointerMove:uf,children:[(0,Y.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,Y.jsxs)(`p`,{onPointerMove:uf,children:[l(`Declared write paths use the checkout root:`),` `,(0,Y.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.runtime&&(0,Y.jsx)(`p`,{onPointerMove:uf,children:e.display.runtime}),e.display?.branch&&(0,Y.jsxs)(`p`,{children:[(0,Y.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,Y.jsx)(`code`,{children:e.display.baseCommit})]})]}),(0,Y.jsx)(`p`,{children:l(`Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.`)}),(0,Y.jsx)(Gs,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:l(`Complete delivery agreement`)}),(0,Y.jsxs)(`p`,{children:[l(`Plan identity`),` · `,(0,Y.jsx)(`code`,{children:e.digest})]}),(0,Y.jsx)(Gs,{text:zt(e.plan)})]}),e.delivery&&(0,Y.jsx)(Gs,{text:jt(e.delivery)}),(0,Y.jsx)(`button`,{type:`button`,className:`primary`,"aria-busy":o||void 0,disabled:o||(i===`approve`?!t:!a),onClick:i===`approve`?r:c,children:l(o?`Validating plan…`:i===`restore`?`Restore execution and validate plan`:i===`validate`?`Validate plan again`:e.revalidatedFrom?`Confirm implementation`:`Implement this plan`)}),i===`approve`&&c&&(0,Y.jsx)(`button`,{type:`button`,disabled:o||!a,onClick:c,children:l(`Validate plan again`)}),i!==`approve`&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:l(`Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.`)}),!t&&(i===`approve`||!a)&&(0,Y.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??l(`Plan approval is currently unavailable.`)}),(0,Y.jsx)(`p`,{children:l(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function ff(e,t,n){if(!n(t))return`stale`;let r=await e.workbenchCommand({kind:`workflow-cancel`,commandId:crypto.randomUUID(),epoch:t.epoch,runId:t.id});return r.kind===`error`?r.error.code:``}function pf({run:e}){let{tx:t}=X();return(0,Y.jsxs)(`span`,{children:[t(e.phase),` ·`,` `,(0,Y.jsx)(`span`,{className:`workflow-status ${e.status}`,children:t(e.status)})]})}function mf(e){return(0,Y.jsx)(hf,{...e},e.id)}function hf({client:e,id:t,onChanged:n,onOpenAgent:r,canCancelWorkflow:i}){let{t:a}=X(),[o,s]=(0,h.useState)(1e3),[c,l]=(0,h.useState)(),u=es(e,{kind:`workflow`,id:t},o),d=es(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),f=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,p=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,m=c===void 0?p:f,[g,_]=(0,h.useState)(null),v=es(e,g?{kind:`workflow-detail`,id:t,stepId:g}:null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(``),C=p&&[`queued`,`running`].includes(p.status),w=(0,h.useRef)(!0);return(0,h.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,h.useEffect)(()=>{p&&![`queued`,`running`].includes(p.status)&&s(0)},[p]),(0,Y.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":a(`Workflow progress`),children:[(0,Y.jsxs)(`header`,{children:[(0,Y.jsx)(`strong`,{children:p?.goal??a(`Observing workflow`)}),p&&(0,Y.jsx)(pf,{run:p})]}),(u.error||d.error||x)&&(0,Y.jsxs)(`p`,{role:`alert`,children:[x||u.error||d.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),p&&(0,Y.jsx)(vf,{run:p}),p?.execution&&(0,Y.jsxs)(`p`,{className:`inspector-note`,children:[a(`Context fixed at admission:`),` `,(0,Y.jsx)(`code`,{children:p.execution.cwd}),` ·`,` `,p.execution.model?`${p.execution.model.provider}/${p.execution.model.model} · ${p.execution.model.thinking}`:a(`No model`)]}),p?.notice&&(0,Y.jsx)(`p`,{children:p.notice}),p&&m&&(0,Y.jsx)(xf,{run:p,steps:m.steps,partial:(m.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:Fc(e.id)}))}),p&&((p.revision??0)>0||!!p.scope?.length)&&(0,Y.jsxs)(`section`,{className:`workflow-route`,"aria-label":a(`Route revisions`),children:[(p.revision??0)>0&&(0,Y.jsxs)(`p`,{children:[a(`Implementation route updates`),`: `,p.revision]}),!!p.scope?.length&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:a(`Paths added to the write scope after approval:`)}),(0,Y.jsx)(`ul`,{className:`workflow-scope`,children:p.scope.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(`code`,{children:e})},e))})]})]}),p?.delivery&&(0,Y.jsx)(Sf,{delivery:p.delivery}),p&&(0,Y.jsxs)(`details`,{children:[(0,Y.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,Y.jsx)(`pre`,{className:`workflow-detail`,children:Ut(p)})]}),p?.mergedCommit&&(0,Y.jsxs)(`p`,{children:[a(`Actual local merge commit:`),` `,(0,Y.jsx)(`code`,{children:p.mergedCommit})]}),p&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:a(`Agent review is not human review. Worktrees and retained results are preserved.`)}),p&&((m?.stepsBefore??0)>0||c!==void 0)&&(0,Y.jsxs)(`nav`,{className:`workflow-actions`,children:[(m?.stepsBefore??0)>0&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(m?.stepsBefore),children:a(`Earlier workflow steps`)}),c!==void 0&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:a(`Latest workflow steps`)})]}),m&&(0,Y.jsx)(gf,{steps:m.steps}),m?.steps.map(e=>(0,Y.jsxs)(`details`,{className:`chat-tool`,children:[(0,Y.jsx)(`summary`,{children:(0,Y.jsx)(_f,{run:p??m,step:e})}),e.exitCode!==null&&(0,Y.jsxs)(`p`,{children:[a(`Exit code`),`: `,e.exitCode]}),(0,Y.jsx)(Gs,{text:e.text}),e.childRunId&&r&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:Fc(e.id)}),children:a(`Open subagent context`)}),e.truncated&&(0,Y.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>_(e.id),children:a(`Read retained step result`)}),g===e.id&&v.value?.kind===`file`&&(0,Y.jsx)(ef,{file:v.value}),g===e.id&&v.error&&(0,Y.jsx)(`p`,{role:`alert`,children:v.error})]},e.id)),C&&(0,Y.jsx)(`button`,{type:`button`,className:`danger`,disabled:y||!i?.(p),onClick:()=>{!y&&i?.(p)&&(b(!0),ff(e,p,i).then(e=>{w.current&&(S(e),u.refresh(),n?.())}).finally(()=>{w.current&&b(!1)}))},children:a(`Cancel workflow — request stop`)}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:a(`Observe current state`)})]})}function gf({steps:e}){let{t}=X(),n=t=>e.filter(e=>e.status===t).length,r=n(`partial`),i=n(`blocked`);return!r&&!i?null:(0,Y.jsxs)(`p`,{className:`inspector-note`,children:[t(`Attempts shown: {partial} partial · {blocked} blocked · {failed} failed`,{partial:r,blocked:i,failed:n(`failed`)}),` · `,t(`Partial or blocked assignments preserve work; they are not process failures or delivery approval.`)]})}function _f({run:e,step:t}){let{t:n,tx:r}=X();return(0,Y.jsxs)(Y.Fragment,{children:[`${r(t.kind)} · ${Fc(t.id)} · `,(0,Y.jsx)(`span`,{className:`workflow-status ${t.status}`,children:r(t.status)}),Uc(e,t)&&(0,Y.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function vf({run:e}){let{t}=X(),n=e.deviations??[];return n.length?(0,Y.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,Y.jsxs)(`h3`,{children:[(0,Y.jsx)(Va,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,Y.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,Y.jsx)(`ol`,{children:n.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`dl`,{children:[(0,Y.jsx)(`dt`,{children:t(`Could not be met`)}),(0,Y.jsx)(`dd`,{children:e.item}),(0,Y.jsx)(`dt`,{children:t(`Why`)}),(0,Y.jsx)(`dd`,{children:e.reason}),(0,Y.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,Y.jsx)(`dd`,{children:e.delivered}),(0,Y.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,Y.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,Y.jsx)(`code`,{children:e},e)):t(`None`)}),(0,Y.jsx)(`dt`,{children:t(`Recorded at`)}),(0,Y.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function yf({state:e}){return e===`running`?(0,Y.jsx)(hd,{}):e===`completed`?(0,Y.jsx)(Fa,{"aria-hidden":`true`}):e===`failed`?(0,Y.jsx)(zi,{"aria-hidden":`true`}):e===`superseded`?(0,Y.jsx)(Wi,{"aria-hidden":`true`}):(0,Y.jsx)(Oa,{"aria-hidden":`true`})}function bf(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function xf({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=X(),o=Ic(e);return o?(0,Y.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,Y.jsxs)(`h3`,{children:[i(`Assignments`),(0,Y.jsx)(`span`,{className:`workflow-board-counts`,children:Rc(o,i)})]}),n&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,Y.jsx)(`ul`,{children:Bc(e,t).map(({task:e,steps:t,artifact:n})=>(0,Y.jsxs)(`li`,{className:`workflow-task`,onPointerMove:uf,children:[(0,Y.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,Y.jsx)(yf,{state:e.state}),a(e.state)]}),(0,Y.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,Y.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,Y.jsx)(`span`,{children:e.title}),(0,Y.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,Y.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,Y.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,Y.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,Y.jsx)(`span`,{className:`workflow-task-worktree`,children:bf(n,i)})]}),n?.state===`retained`&&(0,Y.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,Y.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,Y.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function Sf({delivery:e}){let{t,tx:n}=X(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${e.acceptance.waived?.length?t(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,Y.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,Y.jsx)(`dl`,{children:r.map(([e,t])=>(0,Y.jsxs)(h.Fragment,{children:[(0,Y.jsx)(`dt`,{children:e}),(0,Y.jsx)(`dd`,{children:(0,Y.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,Y.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,Y.jsx)(`p`,{children:e.cleanup.reason}),(0,Y.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var Cf=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function wf(e){return e.scrollHeight-e.scrollTop-e.clientHeight<80}function Tf(e,t){t&&e&&(e.scrollTop=e.scrollHeight)}function Ef(e,t){let{summary:n,observation:r}=e;if(!r||e.error||n===void 0||n&&(n.id!==t||n.status===`unknown`||n.live&&n.live.epoch!==r.epoch))return`unavailable`;if(!Tl(n?.status))return`idle`;let i=e.turns.at(-1);return i&&i.ordinal===e.count-1&&Tl(i.header.status)?i.header.at:0}function Df(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Of({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,viewer:u,access:d,readSelected:f,onDiagnostics:p,prepareForSend:m,prepareForPlan:g,legacyWorkspaceId:_,directoryNamespaces:v=[],available:y=c,canInterrupt:b=c,canCancelWorkflow:x,modelAvailability:S,previewModels:C,initialDraft:w,onDraftApplied:T,onModelChanged:D,onChanged:O,reference:k,onReferenceUsed:A,hidden:j=!1,observe:M=0,onOpenAgent:N,onWorkflowRuns:P,onBranches:F,onOpenBranches:I}){let{t:L,tx:R}=X(),[z]=(0,h.useState)(()=>Wl(n,t,_,...v)),[ee,te]=(0,h.useState)(()=>Df(z,w?.text));(0,h.useEffect)(()=>{w&&T?.()},[w,T]);let ne=Lu(),re=ne.remove,ie=(0,h.useRef)([]),ae=(0,h.useRef)(!0),oe=Qd({draftKey:z,draft:ee,setDraft:te,images:ne,alive:ae,onUnread:()=>U(L(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:se,attaching:ce}=oe,ue=oe.release,de=(0,h.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[fe,V]=(0,h.useState)(()=>Df(`${z}:mode`)===`cadence`?`cadence`:`chat`),[pe,me]=(0,h.useState)(!1),[H,he]=(0,h.useState)(``),ge=`conversation:${t}`,_e=()=>{he(``),Is(ge)},U=e=>Ps(`error`,e,ge);(0,h.useEffect)(()=>()=>Is(ge),[ge]);let[W,ve]=(0,h.useState)(()=>Df(`${z}:pending`)),[ye,be]=(0,h.useState)(()=>Df(`${z}:model-command`)),[xe,Se]=(0,h.useState)(!1),[Ce,G]=(0,h.useState)(!1),[we,Te]=(0,h.useState)(!1),[Ee,De]=(0,h.useState)(0),Oe=(0,h.useRef)(null),ke=(0,h.useRef)(void 0),Ae=(0,h.useRef)(!1),je=(0,h.useRef)(0),Me=(0,h.useRef)(new AbortController),Ne=Me.current.signal,[Pe,Fe]=(0,h.useState)(!1),[Ie,Le]=(0,h.useState)(()=>{try{let e=sessionStorage.getItem(`${z}:model`);if(e)return le(JSON.parse(e))}catch{}return w?.model??null});(0,h.useEffect)(()=>{try{Ie?sessionStorage.setItem(`${z}:model`,JSON.stringify(Ie)):sessionStorage.removeItem(`${z}:model`)}catch{}},[z,Ie]);let Re=(0,h.useMemo)(()=>({async workbenchRead(t,n){let r=hr([n,d?.signal]);try{if(r.signal.aborted||f?.()===!1)return{kind:`error`,error:E(`stale`)};let n=await e.workbenchRead(t,r.signal);return r.signal.aborted||f?.()===!1?{kind:`error`,error:E(`stale`)}:(n.kind===`error`&&Jo(n.error.code)&&d?.refuse(`viewer`,n.error.code),n)}finally{r.dispose()}}}),[e,f,d]),ze=es(Re,y&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),Be=ze.value?.kind===`conversation-context`?ze.value.context:void 0,Ve=!!Be&&!ze.error,He=Be?.cwd??r,Ue=(0,h.useMemo)(()=>({models:(n,r)=>He?e.models(n,{id:t,cwd:He},r):Promise.resolve({kind:`error`,error:E(`unavailable`)})}),[e,t,He]),We=(0,h.useMemo)(()=>({chooseModel:n=>He&&l&&(!u||u.current()&&n.expected.epoch===u.epoch)?e.chooseModel(n,{id:t,cwd:He}):Promise.resolve({kind:`error`,error:E(`stale`)})}),[e,l,He,u,t]),Ge=Pe?{status:`preparing`}:S.status===`ready`&&(!y||!Ve)?{status:ze.error?`unavailable`:`connecting`}:S,Ke=(0,h.useRef)(Ge);Ke.current=Ge;let qe=ql(Ue,Ge,`${Ee}:${Be?.revision??`unobserved`}`,C),Je=()=>{Oe.current=null,G(!1),Te(!1)},Ye=(e,t)=>{e?qe.reread(!0):!e&&t!==`chosen`&&Je(),Se(e)},Xe=(e,t)=>{Le(t?null:e);let n=Oe.current;Ce&&n&&(Bl(n,Ke.current)===`cancel`?(Je(),U(L(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Oe.current=zl(n,e,t),G(!1),_e(),Te(!0)))},Ze=(0,h.useRef)(o);Ze.current=o,(0,h.useEffect)(()=>{Ve&&He&&Ze.current?.({id:t,cwd:He})},[Ve,t,He]);let[Qe]=(0,h.useState)(()=>typeof window<`u`&&Vn()===t?qn(window.location.hash,t).leaf:i),K=Gl(Re,t,y,S.status===`ready`?S:null,Qe),{turns:$e}=K,et=K.summary!==void 0,tt=es(Re,y?{kind:`cadence-conversation`,id:t}:null,1e3),[nt,rt]=(0,h.useState)(),it=tt.value?.kind===`cadence-conversation`?tt.value.state:void 0,q=it&&nt?.id===t&&nt.revision>it.revision?nt:it,at=q?.enabled===!0,ot=!!q||!!tt.error,J=!!q&&!tt.error&&!q.notice,st=(0,h.useRef)(q);st.current=q;let[ct,lt]=(0,h.useState)(()=>Df(`${z}:approval`,``)),ut=(0,h.useRef)(ct),dt=(0,h.useRef)(!1),[ft,pt]=(0,h.useState)(!1),[mt,ht]=(0,h.useState)(``),[gt,_t]=(0,h.useState)(),vt=(0,h.useCallback)(e=>{ut.current=e,lt(e);try{e?sessionStorage.setItem(`${z}:approval`,e):sessionStorage.removeItem(`${z}:approval`)}catch{}},[z]),yt=ts(ee,at?`cadence`:fe),bt={active:at,armed:yt.mode===`cadence`,known:J},xt=uu[su(bt)],St=c&&!(a&&!K.summary)&&Ve&&et&&!K.error&&ot&&!(at&&(tt.error||q?.notice))&&!pe&&!Ce&&!W,Ct=K.summary??void 0,wt=Ct?.status,Tt=Tl(wt),Et=!!Ct&&Ct.status!==`completed`&&!Tt,Dt=$e.at(-1)?.header,Ot=Ef(K,t),{tokens:kt,provider:At,model:jt}=K.context??{},Mt=qe.catalog?.entries??qe.preview?.entries,Nt=(0,h.useMemo)(()=>kt===void 0||At===void 0||jt===void 0?void 0:nl({tokens:kt,provider:At,model:jt},Mt),[kt,At,jt,Mt]),{input:Pt,read:Ft,write:It}=K.cache??{},Lt=(0,h.useMemo)(()=>Pt===void 0||Ft===void 0||It===void 0?void 0:{input:Pt,read:Ft,write:It},[Pt,Ft,It]),Rt=K.refresh;(0,h.useEffect)(()=>{M&&Rt()},[M,Rt]);let zt=(0,h.useRef)(s);zt.current=s,(0,h.useLayoutEffect)(()=>{zt.current?.({id:t,turns:K.count,replyClock:Ot,...Nt?{context:Nt}:{},...Lt?{cache:Lt}:{}})},[t,K.count,Ot,Nt,Lt]);let Bt=$e.at(-1),Vt=Tl(Bt?.header.status),Ht=el(e,t,K.leaf,[Bt?.header.id??``,K.count,K.branches,Vt].join(),y&&!!Ct),{tree:Ut}=Ht,Wt=(0,h.useMemo)(()=>Zc(Ut??{nodes:[],truncated:!1}),[Ut]),Gt=(0,h.useMemo)(()=>{let e=Qc(Ut?.nodes??[]).map(e=>({id:e.id,text:e.text}));if(!Bt||!Vt||e.some(e=>e.id===Bt.header.id))return e;let t=ld(Bt.steps).user[0]?.step.text??``;return[...e,{id:Bt.header.id,text:al(t)}]},[Ut,Bt,Vt]),[Kt,qt]=(0,h.useState)(null),[Jt,Yt]=(0,h.useState)(null),[Xt,Zt]=(0,h.useState)(null),Qt=!!m&&c&&(!!K.error||!!ze.error)&&K.error!==`retired-conversation`&&ze.error!==`retired-conversation`&&!q?.notice&&!Tt&&!pe&&!W&&!Ce,en=(l||!!m)&&Ve&&et&&J&&!K.error&&!pe&&!W&&!Tt,tn=!!Ie&&B(Ie)!==B(Be?.model??null),nn=!!q?.proposal&&!!Ct&&!Tt&&Ct.status!==`unknown`,rn=q?.proposal?Jl(q.proposal,l,qe.catalog?.version,tn||mt===q.proposal.id):`approve`,an=!!gt&&!!q&&q.revision<gt.after.revision,on=!!q?.proposal&&St&&J&&nn&&!ct&&!ft&&!an&&(!!g||l)&&!!(Ie??Be?.model),sn=ft?L(`Preparing execution and validating the plan; no implementation is approved.`):an?L(`Reading the validated plan…`):tn?L(`Validate the plan with this model before approving it.`):Ct?.status===`unknown`?L(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?J?Tt?L(`Wait for the current reply before approving this plan.`):ct?L(`Observing plan approval…`):St?void 0:L(`Read the current conversation context before approving this plan.`):L(`Cadence state unavailable`):L(`Read the current execution state before approving this plan.`),cn=(0,h.useRef)(null),ln=(0,h.useRef)(null),un=(0,h.useRef)(0),dn=(0,h.useRef)(!0),[fn,pn]=(0,h.useState)(!1),mn=(0,h.useRef)(null),hn=(0,h.useRef)(null),gn=(0,h.useCallback)((e=!1)=>{let t=ln.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;dn.current&&(e||n!==hn.current)&&(Tf(t,!0),mn.current=t.scrollTop),hn.current=n},[]);(0,h.useLayoutEffect)(()=>{!j&&ln.current&&!dn.current&&(ln.current.scrollTop=un.current)},[j]);let _n=(0,h.useRef)(``),vn=(0,h.useRef)(ee);(0,h.useEffect)(()=>(ae.current=!0,Me.current.signal.aborted&&(Me.current=new AbortController),()=>{ae.current=!1,Me.current.abort()}),[]),(0,h.useEffect)(()=>{try{sessionStorage.setItem(`${z}:mode`,fe)}catch{}},[z,fe]),(0,h.useEffect)(()=>{try{sessionStorage.setItem(z,ee)}catch{}},[ee,z]),(0,h.useEffect)(()=>{try{W?sessionStorage.setItem(`${z}:pending`,W):sessionStorage.removeItem(`${z}:pending`)}catch{}},[z,W]),(0,h.useEffect)(()=>{try{W&&ye===W?sessionStorage.setItem(`${z}:model-command`,ye):sessionStorage.removeItem(`${z}:model-command`)}catch{}},[z,W,ye]),(0,h.useEffect)(()=>{k&&(te(e=>`${e}${e?`
|
|
41
|
-
`:``}@${k}`),A(),cn.current?.focus())},[k,A]),(0,h.useEffect)(()=>{let e=Ct?`${Ct.leaf}:${Ct.status}`:``;e&&_n.current!==e&&(_n.current=e,O()),ut.current&&q?.runs.includes(ut.current)&&(vt(``),he(``)),W&&(Ct?.live?.commandId===W||K.attempt?.commandId===W||$e.some(e=>e.header.id===W)||K.commands.includes(W))&&(ve(``),Vl(W,ye)&&Le(null),be(``),re(ie.current),te(e=>e===vn.current?``:e),Vl(W,ye)&&iu(n,vn.current),de.current.followAnchor(),O())},[Ct,$e,W,ye,O,q,K,re,n,vt]);let yn=(0,h.useMemo)(()=>$e.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[$e]),bn=wc(ln,yn,Jt?.id??null,void 0,gn),{earlier:xn,loadEarlier:Sn}=K,Cn=()=>{let e=ln.current;e&&!j&&xn&&e.scrollTop<1200&&Sn()};(0,h.useEffect)(Cn);let wn=(0,h.useRef)(0),Tn=()=>{wn.current||=requestAnimationFrame(()=>{wn.current=0;let e=ln.current;if(!e)return;let t=null;if(!dn.current){let n=e.getBoundingClientRect().top+140;for(let r of e.querySelectorAll(`[data-lazy-id]`)){if(t!==null&&r.getBoundingClientRect().top>n)break;t=r.dataset.lazyId??null}}Zt(t)})};(0,h.useEffect)(()=>()=>{wn.current&&cancelAnimationFrame(wn.current)},[]),(0,h.useEffect)(()=>{if(!Jt)return;let e=requestAnimationFrame(()=>{let e=[...ln.current?.querySelectorAll(`[data-lazy-id]`)??[]].find(e=>e.dataset.lazyId===Jt.id);e&&(dn.current=!1,e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),Zt(Jt.id))});return()=>cancelAnimationFrame(e)},[Jt]);let En=$e[0]?.ordinal,Dn=(0,h.useRef)({height:0});(0,h.useLayoutEffect)(()=>{let e=ln.current;if(!e)return;let t=Dn.current;!Cf&&!dn.current&&t.ordinal!==void 0&&En!==void 0&&En<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),j||gn(),Dn.current={ordinal:En,height:e.scrollHeight}}),(0,h.useEffect)(()=>{try{sessionStorage.removeItem(`${z}:approval`)}catch{}},[z]);let On=(0,h.useMemo)(()=>[...new Set([...K.runs,...q?.runs??[]])],[K.runs,q?.runs]),kn=JSON.stringify(On.slice(-4));(0,h.useEffect)(()=>{P?.(JSON.parse(kn))},[kn,P]);let[An,jn]=(0,h.useState)({terminal:8,browser:8}),Mn=(0,h.useMemo)(()=>[...new Set([...K.runs.slice(-An.terminal),...(q?.runs??[]).slice(-An.browser),...ct?[ct]:[]])],[K.runs,q?.runs,An,ct]),Nn=qc(Re,y?Mn:[],1e3),Pn=y?ze.error:void 0,Fn=y&&K.error||void 0,In=y?tt.error:void 0,Ln=y?Nn.error:void 0,Rn=(0,h.useRef)(()=>{});Rn.current=()=>{ae.current&&!d?.signal.aborted&&(Pn&&ze.refresh(),Fn&&K.refresh(),tt.error&&tt.refresh(),Ln&&Nn.refresh())},(0,h.useEffect)(()=>{p?.({context:Pn,head:Fn,prepareOnly:Qt,workflow:In,runs:Ln,retry:()=>Rn.current()})},[Pn,Fn,In,Ln,Qt,p]);let zn=$e.find(e=>e.header.at>0)?.header.at,Bn=!xn&&$e.length>0;(0,h.useEffect)(()=>{if(!y)return;let e=(e,t)=>sf(e,t,Nn.runs,Nn.unreadable,zn,Bn),t=e(K.runs,An.terminal),n=e(q?.runs??[],An.browser);(t!==An.terminal||n!==An.browser)&&jn({terminal:t,browser:n})},[y,K.runs,q?.runs,An,Nn,zn,Bn]);let Hn=(0,h.useMemo)(()=>of($e,Nn.runs.values(),xn),[$e,Nn.runs,xn]),Un=t=>(0,Y.jsx)(lf,{client:e,run:t,canCancelWorkflow:x,onOpen:()=>N?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{tt.refresh(),O()}},t.id),Wn=async()=>{if(!on||!q?.proposal||!Be||dt.current)return;let t=Ie??Be.model;if(!t)return;let n=q.proposal,r=q,i=je.current,a=u,o=l?void 0:g,s=!o,c=()=>ae.current&&!Ne.aborted&&je.current===i&&(s?!a||a.current():!u?.allocation?.aborted);if(c()){dt.current=!0,me(!0),pt(!0),_e();try{let l=await Yl({client:e,state:r,context:Be,model:t,head:K.leaf,signal:Me.current.signal,current:c,prepare:o?async(...e)=>{if(a=await o(...e)||void 0,u&&!a)throw Error(`stale`);s=!0}:void 0});if(!ae.current||je.current!==i)return;_t({before:n,after:l}),ht(``),Le(e=>B(e)===B(t)?null:e)}catch(e){ae.current&&je.current===i&&he(L(`Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{ae.current&&je.current===i&&(dt.current=!1,me(!1),pt(!1),De(e=>e+1),ze.refresh(),tt.refresh(),K.refresh(),O())}}},Gn=async()=>{if(!q?.proposal){U(L(`No plan is awaiting approval.`));return}if(rn!==`approve`){await Wn();return}if(dt.current||an||tn||!l||!J||!St||Tt||ct||!nn)return;let t=q.proposal,n=q,r=je.current;dt.current=!0,me(!0),_e();try{let i=await Xl({client:e,state:n,current:()=>ae.current&&je.current===r&&!Ne.aborted&&(!u||u.current())&&st.current?.revision===n.revision&&st.current?.enabled===!0,submitting:vt});if(!ae.current||je.current!==r)return;i.kind===`error`?(he(i.error.code),i.error.effect===`none`&&(vt(``),i.error.code===`stale`&&ht(t.id))):te(e=>Ql(e)?``:e)}catch(e){ae.current&&je.current===r&&(he(e instanceof Error?e.message:`unavailable`),!ut.current&&e instanceof Error&&e.message===`stale`&&ht(t.id))}finally{ae.current&&je.current===r&&(dt.current=!1,me(!1),tt.refresh(),K.refresh(),O())}},Kn=async n=>{if(!q?.design||dt.current||Ne.aborted)return;if(!l||u&&!u.current()||st.current?.revision!==q.revision){tt.refresh();return}_e();let r=je.current;dt.current=!0,me(!0);try{let i=await e.workbenchCommand({kind:`cadence-design-edit`,commandId:crypto.randomUUID(),conversationId:t,revision:q.revision,designId:q.design.id,answers:n});if(!ae.current||r!==je.current)return;if(i.kind!==`ok`){if(i.error.code===`stale`&&i.error.effect===`none`){rt(void 0),U(L(`The choices changed before this answer was saved.`));return}throw Error(i.error.code)}if(i.value.kind!==`cadence-conversation`||i.value.state.id!==t)throw Error(`stale`);rt(i.value.state)}catch(e){ae.current&&r===je.current&&he(e instanceof Error?e.message:`unavailable`)}finally{ae.current&&r===je.current&&(dt.current=!1,me(!1),tt.refresh())}},Jn=async(r,i,a=!1)=>{let o=i?.text??r??ee,s=i?.images??(r?[]:ne.files),c=i?i.command.kind===`cadence-exit`:at&&Zl(o);if(!(c?en:St)&&!Qt||Tt||ce&&!i||!o.trim()&&!s.length||i&&(!St||Bl(i,Ke.current)!==`ready`))return;if(c&&s.length){U(L(`Remove images before exiting Cadence.`));return}if(!s.length&&!i&&!r&&at&&Ql(o)){await Gn();return}let l=ts(o,fe).mode===`cadence`;if(!Qt&&(at||l)&&!J){U(L(`Cadence state unavailable. Observe the conversation before sending.`));return}if(Ae.current||!ae.current||Ne.aborted||u?.allocation?.aborted||(!m||i)&&u&&!u.current()||i&&ke.current?.allocation!==u?.allocation)return;Ae.current=!0,me(!0),_e();let d=je.current,f=()=>ae.current&&je.current===d,p=u,h=()=>f()&&(!p||p.current()),g=e=>{if(!h()||e&&p&&p.epoch!==e)throw Error(`stale`)},_=!1,v=`not-dispatched`,y=(e,t)=>{let n=L(Ml(t),{code:e});t===`none`?U(n):he(n)},b=e=>{f()&&(ve(e),be(e&&!c?e:``))},x=async e=>{m&&(Fe(!0),await kl(async(...e)=>{if(p=await m(...e)||void 0,u&&!p)throw Error(`stale`)},Me.current.signal,e,e=>{v=e}),f()&&(Fe(!1),De(e=>e+1)))};try{if(Qt){if(await x(Be?{id:t,cwd:Be.cwd}:void 0),!f())return;K.refresh(),ze.refresh(),tt.refresh(),O(),he(L(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let u=i??Pl({id:t,head:c?K.leaf:sl(se,K.leaf),text:o,images:s,revision:q?.revision??0,location:Be?{id:t,cwd:Be.cwd}:void 0,installModel:!!Ie,model:Ie??(qe.catalog?.selected?Fl(qe.catalog.selected):qe.catalog?.remembered??Be?.model??qe.preview?.remembered??void 0),intent:a?`design`:c?`exit`:at?`message`:l?`enter`:`ordinary`});if(i){if(Bl(i,Ke.current)!==`ready`)throw Error(`stale`)}else await x(u.location);if(!f())return;if(g(),u.command.kind===`cadence-exit`){let t=Ul(u);vn.current=o,_=!0;let n=await Nl(e,t,b);if(!f())return;n.kind===`error`?y(n.error.code,n.error.effect):(ve(``),V(`chat`),te(e=>e===o?``:e)),tt.refresh(),K.refresh(),O();return}let d=e=>{let t=Ke.current,n=e??(t.status===`ready`?t.epoch:void 0);n&&Bl(Rl(u,n),t)!==`cancel`?(ke.current=p,Oe.current=Rl(u,n),G(!0)):(Je(),U(L(`The connection changed. Your model choice and draft are kept; send again when ready.`))),Ye(!0)},m=await e.models(void 0,u.location);if(!f())return;if(g(m.kind===`ok`?m.value.version.epoch:void 0),u.preparedEpoch&&m.kind===`ok`&&m.value.version.epoch!==u.preparedEpoch)throw Error(`stale`);let v=m.kind===`ok`?m.value.selected??m.value.remembered:null;if(!u.model&&v&&(u=Il(u,v)),u.installModel&&m.kind===`ok`){if(m={kind:`ok`,value:await Hl(e,u,m.value,h)},!f())return;De(e=>e+1)}let S=u.model??(m.kind===`ok`?m.value.remembered:null);if(m.kind===`ok`&&!m.value.selected&&S){g(m.value.version.epoch);let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:m.value.version.epoch,...u.location?{location:u.location,expected:m.value.version,choice:S}:{}});if(!f())return;if(t.kind===`error`){he(t.error.code),d(m.value.version.epoch);return}if(m=await e.models(void 0,u.location),!f())return;De(e=>e+1)}if(m.kind!==`ok`||!m.value.selected){d(m.kind===`ok`?m.value.version.epoch:void 0);return}g(m.value.version.epoch),Ll(u,m.value.selected);let C=Ul(u,m.value.version);if(u.images.length){let t=m.value.selected;if(!m.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){U(L(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(C.kind===`cadence-exit`)throw Error(`invalid`);if(C=await vl(e,C,u.images,h),!f())return}g(m.value.version.epoch),ie.current=u.images,vn.current=o,_=!0;let w=await Nl(e,C,b);if(!f())return;w.kind===`error`?y(w.error.code,w.error.effect):(re(ie.current),Le(null),te(e=>e===vn.current?``:e),ve(``),C.kind===`cadence-send`&&V(`chat`),r||iu(n,o),dr(null)),tt.refresh(),K.refresh(),O()}catch(e){if(f()){let t=e instanceof Error?e.message:`unavailable`,n=jl(e),r=L(_?Ml():Al(v,n),{code:t});!_&&(v===`not-dispatched`||n===`none`)?U(r):he(r)}}finally{je.current===d&&(Ae.current=!1),f()&&(me(!1),Fe(!1))}},Xn=(0,h.useRef)(Jn);Xn.current=Jn,(0,h.useEffect)(()=>{let e=Oe.current;if(!e||!we&&!Ce)return;let t=Bl(e,Ge);t===`cancel`?(Oe.current=null,G(!1),Te(!1),Ps(`error`,L(`The connection changed. Your model choice and draft are kept; send again when ready.`),ge)):we&&t===`ready`&&St&&!Tt&&(Te(!1),Oe.current=null,Xn.current(void 0,e))},[we,Ce,St,Tt,Ge,L,ge]),(0,h.useEffect)(()=>{if(!we)return;let e=setTimeout(()=>{Te(!1),Oe.current=null},1e4);return()=>clearTimeout(e)},[we]);let Zn=typeof Ot==`number`&&Ct?.status===`running`&&$e.at(-1)?.ordinal===K.count-1&&Dt?.status===`running`&&(Dt.activity?.kind===`tool`||Dt.activity?.kind===`thinking`),Qn=Tt?Ct?.live:void 0,$n=(0,h.useRef)(new Map),er=ul({images:ne.files.length,modeChange:at?Zl(ee):yt.mode===`cadence`,anchored:!!se,waiting:K.pending.length}),nr=(0,h.useRef)(Qn);nr.current=Qn;let rr=(0,h.useRef)(K.pending);rr.current=K.pending;let ir=()=>!!Qn&&ae.current&&!Ne.aborted&&b&&(!u||u.attached(Qn.epoch))&&nr.current?.commandId===Qn.commandId&&nr.current?.epoch===Qn.epoch,ar=()=>ir()&&l&&(!u||u.current()),or=ar()&&!pe&&!W&&!ce,sr=async r=>{if(!Qn||!or||!ar()||er||!ee.trim())return;_e(),me(!0);let i=ee,a=dl(t,Qn,r,i),o=ml(await e.workbenchCommand(a));ae.current&&(me(!1),o.kind===`accepted`?($n.current.set(a.commandId,i),iu(n,i),te(``)):o.kind===`refused`?U(L(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:tr(L,o.code)})):he(o.code),K.refresh())},cr=async(n,r)=>{if(!Qn||pe||!ar()||!rr.current.some(e=>e.commandId===n.commandId))return;me(!0);let i=ml(await e.workbenchCommand(fl(t,Qn,n.commandId)));if(ae.current){if(me(!1),i.kind===`accepted`){let e=$n.current.get(n.commandId)??n.text;$n.current.delete(n.commandId),r&&te(t=>t.trim()?t:e)}else i.kind===`refused`?U(i.code===`conflict`?L(`That message has already been handed to the model and can no longer be withdrawn.`):L(`The message was not withdrawn ({reason}).`,{reason:tr(L,i.code)})):he(i.code);K.refresh()}},lr=e=>{te(t=>t.trim()?`${t}\n${e}`:e),cn.current?.focus()},ur=async()=>{let n=Ct?.live;if(!n||pe||!ir())return;me(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});ae.current&&(r.kind===`error`&&he(r.error.code),me(!1),K.refresh())},dr=(e,n)=>{++je.current,Me.current.abort(),Me.current=new AbortController,Oe.current=null,Ae.current=!1,dt.current=!1,pt(!1),_t(void 0),G(!1),Te(!1),Se(!1),me(!1),Fe(!1),ue(),K.choose(e,n),Yn(t,e)},fr=!Tt&&!pe&&!W&&!Ce,pr=()=>{_e(),cn.current?.focus()},mr=e=>{fr&&e.header.entry&&(e.ordinal>=K.count-1?ue():oe.continueAfter(e),pr())},gr=e=>{if(!fr)return;let t=$e.find(t=>t.ordinal===e.ordinal-1);oe.edit(e,t)?pr():U(L(`This message cannot be rewritten from here: the entry it continued is not known.`))},_r=(e,t)=>qt({id:e,then:t});de.current={chooseBranch:dr,followAnchor(){oe.current()&&dr(null)},show:_r,stepVersion:(e,t)=>{let n=Wt.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(dr(r.leaf===Ct?.leaf?null:r.leaf,$e.find(t=>t.header.id===e)?.ordinal),_r(r.id,`show`))}};let vr=(0,h.useCallback)(e=>de.current.show(e,`continue`),[]),yr=(0,h.useCallback)(e=>de.current.show(e,`edit`),[]),br=(0,h.useCallback)((e,t)=>de.current.stepVersion(e,t),[]),xr=(0,h.useCallback)(e=>de.current.show(e,`show`),[]);(0,h.useEffect)(()=>{if(!Kt)return;let e=$e.find(e=>e.header.id===Kt.id);if(e){qt(null),Kt.then===`edit`?gr(e):Kt.then===`continue`&&mr(e),Yt({id:e.header.id});return}let t=e=>{qt(null),U(e)};if(K.error)return qt(null);if(!et||!$e.length&&K.count>0)return;if(!Ht.current){Ht.error&&!Ht.loading&&t(tr(L,Ht.error));return}let n=Ut?.nodes.find(e=>e.id===Kt.id);if(n&&!n.current&&!Kt.switched)return dr(n.leaf===Ct?.leaf?null:n.leaf),qt({...Kt,switched:!0});let r=$c(Gt,Kt.id,$e,K.count,Vt);if(r===void 0||$e.some(e=>e.ordinal===r))return t(L(`That message could not be found in this conversation.`));K.showFrom(r)});let Sr=pe||Ce||!!W||Tt||ce,Z=e=>{if(!Sr)try{ne.add(e),_e()}catch(e){U(R(e instanceof Error?e.message:`unavailable`))}},Cr=(0,h.useRef)(F);Cr.current=F;let wr=(0,h.useMemo)(()=>({onShow:e=>de.current.show(e.id,`show`),onEdit:e=>de.current.show(e.id,`edit`),onContinue:e=>de.current.show(e.id,`continue`),onLatest:()=>de.current.chooseBranch(null)}),[]),{error:Tr,loading:Er,refresh:Dr}=Ht,{pinned:Or}=K;(0,h.useEffect)(()=>{Cr.current?.({id:t,tree:Ut,error:Tr,loading:Er,pinned:Or,canAct:fr,onRefresh:Dr,...wr})},[t,Ut,Tr,Er,Or,fr,Dr,wr]);let kr=se!==null&&($e.some(e=>e.header.id===se.turnId)||Gt.some(e=>e.id===se.turnId))?se:null,Ar=kr?yn.find(({turn:e})=>cl(kr,e.ordinal))?.id:void 0,jr=Xt===null?Gt.length-1:Gt.findIndex(e=>e.id===Xt),Mr=se?(0,Y.jsxs)(`div`,{className:`composer-anchor`,children:[se.kind===`edit`?(0,Y.jsx)(ba,{"aria-hidden":`true`}):(0,Y.jsx)(Ta,{"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,Y.jsx)(`strong`,{children:se.kind===`edit`?L(`Rewriting a message`):L(`Continuing after an earlier turn`)}),se.label&&(0,Y.jsx)(`span`,{className:`composer-anchor-quote`,children:se.label}),(0,Y.jsxs)(`span`,{children:[se.kind===`edit`?L(`Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.`):L(`Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.`),` `,L(`Only the conversation is rewound: files on disk stay as they are.`)]}),ce&&(0,Y.jsx)(`span`,{children:L(`Reading the message's images…`)}),se.media&&(0,Y.jsx)(`span`,{children:L(`Attachments that were not retained are not attached again.`)})]}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,title:L(`Cancel and restore the draft that was here`),disabled:pe||!!W,onClick:()=>{ue(),cn.current?.focus()},children:L(`Cancel`)})]}):Or&&!Tt?(0,Y.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,Y.jsx)(ma,{"aria-hidden":`true`}),(0,Y.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,Y.jsx)(`span`,{children:L(`A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.`)})})]}):void 0;return(0,Y.jsxs)(`section`,{className:`chat-workspace`,hidden:j,"aria-label":L(J?at?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,Y.jsxs)(`header`,{className:`conversation-header`,title:Fn&&et?L(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`):void 0,children:[(0,Y.jsxs)(`div`,{className:`conversation-heading`,children:[(0,Y.jsx)(na,{"aria-hidden":`true`}),(0,Y.jsx)(`h2`,{children:Ct?.title??(a?L(`Discovered session`):K.summary===null?L(`New conversation`):L(`Conversation`))})]}),(0,Y.jsxs)(`div`,{className:`conversation-branch`,children:[(0,Y.jsxs)(`span`,{className:`conversation-meta`,children:[J?L(at?`Cadence on`:`Ordinary`):tt.error?L(`Cadence state unavailable`):``,Ct&&` · ${Ct.origin===`terminal`?L(`Started in the terminal`):L(`Started in the WebUI`)}`]}),wt===`starting`&&(0,Y.jsx)(`span`,{className:`ep-state starting`,children:R(wt)}),Ct?.archived&&(0,Y.jsx)(`span`,{className:`conversation-badge`,children:L(`Archived`)}),I&&(K.branches>1||Or)&&(0,Y.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-label":L(`Branches ({count})`,{count:K.branches}),title:L(`Branches ({count})`,{count:K.branches}),onClick:I,children:[(0,Y.jsx)(ma,{"aria-hidden":`true`}),K.branches]}),Or&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>dr(null),children:L(`Show the latest`)}),at&&!Tt&&!Et&&!!q?.proposal&&(0,Y.jsx)(`span`,{className:`ep-state`,children:L(`Awaiting plan approval`)})]})]}),(0,Y.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,Y.jsxs)(`div`,{className:`chat-messages`,ref:ln,onScroll:()=>{let e=ln.current;e&&!j&&(un.current=e.scrollTop,(!dn.current||un.current!==mn.current)&&(dn.current=wf(e)),mn.current=null,pn(!dn.current),Cn(),Tn())},children:[a&&!K.summary&&(0,Y.jsx)(`p`,{role:`status`,className:`panel-hint`,children:L(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!y&&!et&&(0,Y.jsx)(`p`,{role:`status`,className:`panel-hint`,children:L(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),y&&K.count===0&&!$e.length&&K.summary===null&&!K.attempt&&K.pending.length===0&&K.undelivered.length===0&&!K.error&&!a&&(0,Y.jsx)(Kd,{visible:!j,hint:L(xt??`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),y&&!K.error&&(!et||$e.length===0&&K.count>0)&&(0,Y.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:L(`Reading this conversation…`)}),$e.length>0&&xn&&(0,Y.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:K.loadingEarlier&&L(`Reading earlier messages…`)}),Hn.start.map(Un),yn.map(({id:e,version:t,turn:n},r)=>{let i=Wt.get(e);return(0,Y.jsxs)(h.Fragment,{children:[e===Ar&&(0,Y.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,Y.jsx)(ma,{"aria-hidden":`true`}),L(`From here on, the turns stay on their branch: the message being written will not have them in its context.`)]}),(0,Y.jsx)(Dc,{id:e,show:!bn.hidden.has(e)||e===Jt?.id,height:bn.placeholder(e,t,320),containerRef:ln,onMeasured:bn.recordMeasured,lazyRef:bn.register(e),children:(0,Y.jsx)(Md,{turn:n,onContinue:fr&&n.header.entry&&n.ordinal<K.count-1?vr:void 0,onEdit:fr&&ol(n,yn[r-1]?.turn)!==void 0?yr:void 0,version:i?i.findIndex(t=>t.id===e)+1:0,versions:i?.length??0,onVersion:br,off:cl(kr,n.ordinal)})}),Hn.after.get(e)?.map(Un)]},n.renderId??n.header.id)}),Hn.end.map(Un),K.attempt&&(0,Y.jsxs)(`article`,{className:`chat-attempt`,"aria-label":L(`Message`),children:[(0,Y.jsx)(`p`,{className:`chat-attempt-text`,children:K.attempt.text}),(0,Y.jsxs)(`p`,{className:`inspector-note`,children:[(0,Y.jsx)(`span`,{className:`ep-state ${K.attempt.status}`,children:R(K.attempt.status)}),` `,K.attempt.notice?R(K.attempt.notice):``]})]}),(0,Y.jsx)($d,{pending:K.pending,undelivered:K.undelivered,canWithdraw:ar()&&!pe,recallable:e=>$n.current.has(e.commandId)||pl(e.text),onWithdraw:(e,t)=>void cr(e,t),onRestore:lr}),ct&&(0,Y.jsx)(`p`,{role:`status`,children:L(`Observing approval request {id}; no approval is replayed.`,{id:ct})}),q?.enabled&&q.design&&(0,Y.jsx)(qd,{draft:q.design,active:!j,error:H?tr(L,H):void 0,disabled:!!Or||!!se||ce||pe||!!Tt||!l||!St||!J||!!ct,onEdit:Kn,onSubmit:e=>void Jn($t(e,16384),void 0,!0)},q.design.id),q?.enabled&&q.proposal&&(0,Y.jsx)(df,{proposal:q.proposal,canApprove:!tn&&l&&St&&J&&nn&&!Tt&&!ct&&!an&&rn===`approve`,action:rn,canValidate:on,validating:ft,previous:gt?.after.proposal?.id===q.proposal.id?gt.before:void 0,approvalHint:sn,onValidate:()=>void Wn(),onApprove:()=>void Gn()}),J&&q?.enabled&&!q.proposal&&On.length===0&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:L(`Cadence stays on for this conversation until you explicitly exit.`)}),q?.notice&&(0,Y.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:R(q.notice)}),H&&(0,Y.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:tr(L,H)}),W&&(0,Y.jsxs)(`p`,{className:`inspector-note`,children:[L(`Send outcome not yet observed:`),` `,(0,Y.jsx)(`code`,{children:W}),` `,(0,Y.jsx)(`button`,{type:`button`,onClick:K.refresh,children:L(`Observe current state`)})]})]}),fn&&(0,Y.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{dn.current=!0,gn(!0),pn(!1)},children:[(0,Y.jsx)(za,{"aria-hidden":`true`}),L(`Latest messages`)]}),Kt&&(0,Y.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:L(`Reading earlier messages…`)}),Gt.length>1&&(0,Y.jsx)(Yd,{questions:Gt,active:jr,reading:Kt?.id??null,onJump:xr})]}),(0,Y.jsx)(`div`,{className:`composer-dock`,children:(0,Y.jsx)(Ju,{flow:Zn,inputRef:cn,draft:ee,onDraft:te,locked:pe||!!W||Ce,images:ne.files,imageKey:ne.key,imagesLocked:Sr,onAddImages:Z,onRemoveImage:e=>re([e]),anchor:Mr,status:Pe?L(`Preparing execution for this Send…`):Qn&&ee.trim()&&er?L(er===`images`?`A message into a running reply carries no images. Remove them, or send after the reply ends.`:er===`mode`?`Cadence mode is not changed by a message into a running reply. Send this after the reply ends.`:er===`full`?`Eight messages already wait for this reply. Withdraw one, or wait.`:`A message into a running reply continues that reply, not another entry.`):Tt||Qt||St?void 0:L(W?`The last Send is not yet confirmed. No message is resent.`:Ce?`Choose a model; your message is sent right after.`:pe?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`),cadence:{...bt,disabled:at?!en:!!Tt||pe||!!W||Ce,onClick:()=>{at?Jn(`exit cadence`):yt.mode===`cadence`?(V(`chat`),ts(ee,`chat`).mode===`cadence`&&te(yt.text)):V(`cadence`)}},model:{client:We,availability:Ge,read:{...qe,isCurrent:()=>qe.isCurrent()&&(Ge.status!==`ready`||!u||u.current())},lastModel:Be?.model,draftModel:Ie,onPreviewChoice:C?e=>Xe(e,!1):void 0,locked:!!Tt||pe||!!W||Ge.status===`ready`&&!l,open:xe,onOpenChange:Ye,onChanged:()=>{ze.refresh(),D()},onChosen:e=>Xe(e,!0),awaitingSend:Ce},hint:J&&Qn&&or&&!er&&ee.trim()?L(`Enter steers this reply · Alt+Enter queues behind it`):xt?L(xt):``,running:!!Tt,canStop:!pe&&ir(),onStop:()=>void ur(),canSend:((at&&Zl(ee)?en:St)||Qt)&&!ce&&(!!ee.trim()||ne.files.length>0),onSend:()=>void Jn(),input:Qn?{enabled:or&&!er&&!!ee.trim(),onInput:e=>void sr(e)}:void 0,historyScope:n,files:{client:e,location:y&&Ve&&Be?{id:t,cwd:Be.cwd}:void 0},onResized:gn})})]})}function kf(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Af(e){let t=[],n=0,r=0,i=``;for(;;){let a=await e(n);if(a.kind!==`file-part`)throw Error(`invalid`);if(n===0)({size:r,version:i}=a);else if(a.size!==r||a.version!==i)throw Error(`stale`);let o=kf(a.data),s=n+o.length;if(a.next===null?s!==r:a.next!==s||o.length!==196608)throw Error(`invalid`);if(t.push(o),a.next===null)break;n=a.next}return new Blob(t,{type:`application/octet-stream`})}var jf=/[<>:"/\\|?*\u0000-\u001f]/g,Mf=/[. ]+$/,Nf=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Pf(e){let t=e.replace(jf,`_`).replace(Mf,``);return t?Nf.test(t)?`_${t}`:t:`_`}function Ff(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function If(e,t){let n=/windows/i.test(navigator.userAgent)?Pf(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return Ff(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(Ff(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Lf(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
39
|
+
}`;function Bd(e){return(e.match(/[\d.]+/g)?.map(Number)??[]).slice(0,3).map(t=>e.startsWith(`color(srgb `)?t:t/255)}function Vd(e){let t;try{t=e.getContext(`webgl`,{antialias:!1,depth:!1,stencil:!1,premultipliedAlpha:!1,powerPreference:`low-power`})}catch{return null}if(!t)return null;let n=[],r=t.createProgram(),i=t.createBuffer(),a=()=>{t.useProgram(null);for(let e of n)t.deleteShader(e);t.deleteProgram(r),t.deleteBuffer(i)};try{if(!r||!i)throw Error();for(let[e,i]of[[t.VERTEX_SHADER,Rd],[t.FRAGMENT_SHADER,zd]]){let a=t.createShader(e);if(!a)throw Error();n.push(a),t.shaderSource(a,i),t.compileShader(a),t.attachShader(r,a)}if(t.linkProgram(r),!t.getProgramParameter(r,t.LINK_STATUS))throw Error();t.useProgram(r),t.bindBuffer(t.ARRAY_BUFFER,i),t.bufferData(t.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),t.STATIC_DRAW);let o=t.getAttribLocation(r,`p`);t.enableVertexAttribArray(o),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0);let s=e=>t.getUniformLocation(r,e),c=s(`silver`),l=s(`violet`),u=s(`aspect`),d=s(`phase`),f=s(`origin`),p=s(`tilt`);return{dispose:a,configure(n,r){let[i,a]=Ld(e.clientWidth,e.clientHeight,Number(n.getPropertyValue(`--ambient-pixels`))||256e3);(e.width!==i||e.height!==a)&&(e.width=i,e.height=a),t.viewport(0,0,i,a);let o=e.getBoundingClientRect(),s=r?(r.x+r.width/2-o.x)/o.width:.5,d=r?(r.y+r.height/2-o.y)/o.height:.38;t.uniform2f(f,s,1-d),t.uniform1f(u,i/a),t.uniform3fv(c,Bd(n.color)),t.uniform3fv(l,Bd(n.borderTopColor))},draw(e,n,r){t.uniform2f(p,n,r),t.uniform1f(d,e/6500%(2*Math.PI)),t.drawArrays(t.TRIANGLES,0,3)}}}catch{return a(),null}}function Hd(e,t=Vd,n=()=>null){let r=matchMedia(`(prefers-reduced-motion: reduce)`),i=matchMedia(`(prefers-color-scheme: dark)`),a,o,s,c=!1,l=!1,u=!0,d=-1/0,f=1e3/24,p=()=>{window.clearTimeout(o),s!==void 0&&cancelAnimationFrame(s),o=s=void 0},m=()=>!document.hidden&&!r.matches&&!c&&!l&&e.dataset.scene===`hero`,h=0,g=0,_=e=>{h=e.clientX/window.innerWidth-.5,g=.5-e.clientY/window.innerHeight},v=r=>{if(s=void 0,m()){if(r-d>=f){if(a??=t(e),!a){l=!0;return}if(u){let t=getComputedStyle(e);a.configure(t,n()?.getBoundingClientRect()),f=1e3/Math.min(24,Math.max(1,Number(t.getPropertyValue(`--ambient-fps`))||24)),u=!1}a.draw(r,h,g),d=r}o=window.setTimeout(()=>{o=void 0,m()&&(s=requestAnimationFrame(v))},Math.max(1,d+f-performance.now()))}},y=()=>{p(),u=!0,window.removeEventListener(`pointermove`,_),m()&&(window.addEventListener(`pointermove`,_,{passive:!0}),s=requestAnimationFrame(v))},b=e=>{e.preventDefault(),c=!0,a=null,y()},x=()=>{c=l=!1,y()},S=new MutationObserver(y);S.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),S.observe(e,{attributes:!0,attributeFilter:[`data-scene`]});let C=e.closest?.(`.app`)?.querySelector(`.main`),w=C?new ResizeObserver(y):null;C&&w?.observe(C),window.addEventListener(`resize`,y),document.addEventListener(`visibilitychange`,y);for(let e of[r,i])e.addEventListener(`change`,y);return e.addEventListener(`webglcontextlost`,b),e.addEventListener(`webglcontextrestored`,x),y(),()=>{p(),S.disconnect(),w?.disconnect(),window.removeEventListener(`pointermove`,_),window.removeEventListener(`resize`,y),document.removeEventListener(`visibilitychange`,y);for(let e of[r,i])e.removeEventListener(`change`,y);e.removeEventListener(`webglcontextlost`,b),e.removeEventListener(`webglcontextrestored`,x),a?.dispose()}}var Ud=(0,h.createContext)(null);function Wd(e){let t=(0,h.useRef)(null),n=(0,h.useContext)(Ud);return(0,h.useEffect)(()=>{if(e)return n?.(t.current),()=>n?.(null)},[n,e]),t}var Gd=`cadence-ambient-v1`;function Kd(){try{return localStorage.getItem(Gd)!==`off`}catch{return!0}}function qd(e){try{localStorage.setItem(Gd,e?`on`:`off`)}catch{}}var Jd=(0,h.memo)(function({enabled:e,hero:t}){let n=(0,h.useRef)(null),r=(0,h.useRef)(t);return r.current=t,(0,h.useEffect)(()=>{if(e&&n.current)return Hd(n.current,void 0,()=>r.current)},[e]),(0,X.jsx)(`div`,{className:`optical-field`,"aria-hidden":`true`,"data-enabled":e,"data-scene":t?`hero`:`reading`,children:(0,X.jsx)(`canvas`,{ref:n,"data-scene":t?`hero`:`reading`})})});function Yd(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 36 36`,fill:`none`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`m18 2 13 9-4 16-9 7-9-7-4-16Z`,fill:`currentColor`,opacity:`.12`}),(0,X.jsxs)(`g`,{stroke:`currentColor`,strokeWidth:`1.4`,strokeLinejoin:`round`,children:[(0,X.jsx)(`path`,{d:`m18 2 13 9-4 16-9 7-9-7-4-16Z`}),(0,X.jsx)(`path`,{d:`m5 11 13 5 13-5M18 2v14l-9 11m9-11 9 11m-9-11v18`})]})]})}function Xd({visible:e=!0,hint:t,children:n}){let r=Wd(e),{t:i}=Z();return(0,X.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,X.jsx)(`span`,{ref:r,className:`empty-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Yd,{})}),(0,X.jsx)(`h2`,{children:i(`What would you like to work on?`)}),(0,X.jsx)(`p`,{children:t}),n]})}function Zd({draft:e,active:t,disabled:n,error:r,onEdit:i,onSubmit:a}){let{t:o}=Z(),s=t&&!n&&!e.submitted,[c,l]=(0,h.useState)(s?`open`:`waiting`);(0,h.useEffect)(()=>{c===`waiting`&&s&&l(`open`)},[c,s]);let[u,d]=(0,h.useState)(``),[f,p]=(0,h.useState)(),m=e.questions.filter(t=>Yt(t,e.answers)),g=m.find(e=>e.id===u)??m[0],_=e.answers.find(e=>e.question===g.id),v=_&&`other`in _?_.other:``,y=f?.question===g.id?f.value:v,b=!!y.trim()&&y.trim()!==v,x=(0,h.useRef)(null),S=_&&`option`in _?_.option:null,C=t&&c===`open`;(0,h.useLayoutEffect)(()=>{g.id;let e=x.current;if(!C||!e||!S)return;let t=e.querySelector(`input:checked`)?.closest(`label`);if(!t)return;let n=()=>{e.style.setProperty(`--pill-y`,`${t.offsetTop}px`),e.style.setProperty(`--pill-h`,`${t.offsetHeight}px`)};n();let r=new ResizeObserver(n);for(let t of e.querySelectorAll(`label`))r.observe(t);return()=>r.disconnect()},[C,S,g.id]);let w=t=>i([...e.answers.filter(e=>e.question!==g.id),t]);return(0,X.jsxs)(`section`,{className:`workflow-plan`,"aria-label":o(`Design choices`),children:[(0,X.jsx)(`h3`,{children:o(`Design choices`)}),e.submitted?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{role:`status`,children:o(`Design submitted`)}),(0,X.jsx)(`dl`,{children:m.map(t=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:t.question}),(0,X.jsx)(`dd`,{children:Qt(t,e.answers.find(e=>e.question===t.id))})]},t.id))})]}):(0,X.jsx)(`p`,{children:o(`{answered} of {total} questions answered`,{answered:e.answers.length,total:m.length})}),(0,X.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,disabled:!t,onClick:()=>l(`open`),children:e.submitted?o(`Review choices`):o(`Choose answers`)}),C&&(0,X.jsxs)(dc,{title:o(`Design choices`),onClose:()=>l(`closed`),children:[(0,X.jsxs)(`section`,{className:`design-card`,children:[(0,X.jsx)(`nav`,{"aria-label":o(`Questions`),children:m.map((t,n)=>(0,X.jsxs)(`button`,{type:`button`,disabled:b&&t.id!==g.id,"aria-current":t.id===g.id?`step`:void 0,onClick:()=>d(t.id),children:[n+1,`. `,t.question,` ·`,` `,Qt(t,e.answers.find(e=>e.question===t.id))??`…`]},t.id))}),(0,X.jsxs)(`fieldset`,{disabled:n,children:[(0,X.jsx)(`legend`,{children:g.question}),(0,X.jsx)(`div`,{className:`design-track`,ref:x,"data-selected":!!S,children:g.options.map(t=>(0,X.jsxs)(`label`,{className:`design-option`,children:[(0,X.jsx)(`input`,{type:`radio`,name:e.id+g.id,checked:!!_&&`option`in _&&_.option===t.id,onChange:()=>{p(void 0),w({question:g.id,option:t.id})}}),(0,X.jsxs)(`span`,{children:[t.label,t.id===g.recommended?` · ${o(`Recommended`)}`:``,(0,X.jsx)(`small`,{children:t.cost})]})]},t.id))}),(0,X.jsx)(`p`,{children:g.reason}),(0,X.jsxs)(`p`,{children:[o(`Acceptance`),` · `,g.acceptance]}),(0,X.jsxs)(`label`,{className:_&&`other`in _?`design-custom chosen`:`design-custom`,children:[o(`Other idea`),` `,(0,X.jsx)(`input`,{value:y,onChange:e=>p({question:g.id,value:e.target.value})})]}),(0,X.jsx)(`button`,{type:`button`,disabled:!b,onClick:()=>void w({question:g.id,other:y.trim()}),children:o(`Use this answer`)}),b&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>p(void 0),children:o(`Discard typed answer`)})]}),r&&(0,X.jsx)(`p`,{role:`alert`,children:r}),(0,X.jsx)(`p`,{children:o(`Submitting answers requests a plan, not implementation.`)})]}),!e.submitted&&(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:n||b||e.answers.length===m.length,onClick:()=>void i(Xt(e.questions,e.answers,!0)),children:o(`Fill unanswered with recommendations`)}),(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:n||b,onClick:()=>{l(`closed`),a(tn(e,e.answers,!0))},children:o(`Submit design and use recommendations for unanswered questions`)})]})]})]})}function Qd(e,t,n){let r=Math.max(0,t),i=Math.floor((r+4)/7),a=Math.min(e,i),o=Array.from({length:a},(t,r)=>{let i=Math.floor(r*e/a),o=Math.floor((r+1)*e/a)-1;return n>=i&&n<=o?n:r===a-1?o:i}),s=a>1?Math.min(27,(r-a*3)/(a-1)):0;return{indices:o,gap:s,many:e>a||a>1&&s<20}}function $d({questions:e,active:t,reading:n,onJump:r}){let{t:i}=Z(),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(0);(0,h.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>s(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let{indices:c,gap:l,many:u}=(0,h.useMemo)(()=>Qd(e.length,o,t),[e.length,o,t]),d=c.includes(t)?t:c.at(-1),f=e=>{let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t&&e.key!==`Home`&&e.key!==`End`)return;let n=[...e.currentTarget.querySelectorAll(u?`.qn-list-item`:`.qn-bar`)];if(!n.length)return;e.preventDefault();let r=document.activeElement,i=u?Number(r?.dataset.question??0):n.indexOf(r);n[e.key===`Home`?0:e.key===`End`?n.length-1:Math.min(n.length-1,Math.max(0,i+t))]?.focus()},p=()=>a.current?.querySelector(`.qn-list-item.active`)?.scrollIntoView({block:`nearest`}),m=(e,t)=>{e.detail>0&&e.currentTarget.blur(),r(t)},g=t=>`${t+1}. ${e[t].text}`;return(0,X.jsxs)(`nav`,{className:`qn-rail${u?` many`:``}`,ref:a,"aria-label":i(`Questions in this conversation`),style:{"--rail-gap":`${l}px`},onKeyDown:f,onMouseEnter:p,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||p()},children:[c.map(r=>{let i=e[r];return(0,X.jsx)(`button`,{type:`button`,className:`qn-bar${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===i.id||void 0,"data-question":r,tabIndex:r===d?0:-1,onClick:e=>m(e,i.id),children:(0,X.jsx)(`span`,{className:`qn-bar-text`,children:g(r)})},i.id)}),u&&(0,X.jsx)(`div`,{className:`qn-list`,children:e.map((e,r)=>(0,X.jsxs)(`button`,{type:`button`,className:`qn-list-item${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===e.id||void 0,"data-question":r,tabIndex:-1,onClick:t=>m(t,e.id),children:[(0,X.jsx)(`span`,{className:`qn-list-idx`,children:r+1}),(0,X.jsx)(`span`,{className:`qn-list-text`,children:e.text||`…`})]},e.id))})]})}var ef={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`},tf=(e,t,n)=>new File([e],`image-${n+1}.${ef[t.mimeType]??`img`}`,{type:t.mimeType});function nf({draftKey:e,draft:t,setDraft:n,images:r,alive:i,onUnread:a}){let[o,s]=(0,h.useState)(()=>{try{return cl(sessionStorage.getItem(`${e}:anchor`))}catch{return null}}),c=(0,h.useRef)(o);c.current=o,(0,h.useEffect)(()=>{try{o?sessionStorage.setItem(`${e}:anchor`,JSON.stringify(o)):sessionStorage.removeItem(`${e}:anchor`)}catch{}},[e,o]);let l=(0,h.useRef)([]),u=(0,h.useRef)(null),[d,f]=(0,h.useState)(!1),p=()=>{u.current?.abort(),u.current=null,f(!1)},m=()=>{p();let e=c.current;e&&(c.current=null,s(null),n(e.stash),r.replace(l.current),l.current=[])},g=(e,n,i)=>{p();let a=c.current;a||(l.current=r.files);let o=pd(e.steps).user[0],u={kind:n,entry:i,turnId:e.header.id,from:n===`edit`?e.ordinal:e.ordinal+1,label:il(o?.step.text??``),media:n===`edit`&&e.header.omitted.media,stash:a?a.stash:t};return c.current=u,s(u),r.replace([]),o};return{anchor:o,current:()=>c.current,attaching:d,release:m,continueAfter:e=>e.header.entry?(g(e,`continue`,e.header.entry),n(``),!0):!1,edit:(e,t)=>{let o=al(e,t);if(o===void 0)return!1;let s=g(e,`edit`,o);if(n(s?.step.text??``),!s)return!0;let c=s.step.text,l=s.step.images??[],d=new AbortController,p=jd(e,[s],d.signal);if(typeof p==`string`&&!l.length)return!0;u.current=d,f(!0);let{image:m}=e;return Promise.allSettled([p,...l.map((e,t)=>m?m(e,d.signal).then(n=>tf(n,e,t)):Promise.reject(Error(`unavailable`)))]).then(([e,...t])=>{if(d.signal.aborted||!i.current)return;u.current=null,f(!1),e.status===`fulfilled`&&n(t=>t===c?e.value:t);let o=t.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);try{o.length&&r.add(o)}catch{o.length=0}(e.status===`rejected`||o.length<l.length)&&a()}),!0}}}function rf({pending:e,undelivered:t,canWithdraw:n,recallable:r,onWithdraw:i,onRestore:a}){let{t:o,tx:s}=Z();return!e.length&&!t.length?null:(0,X.jsxs)(`section`,{className:`chat-waiting-list`,"aria-label":o(`Waiting messages`),children:[e.map(e=>(0,X.jsxs)(`article`,{className:`chat-waiting ${e.mode}`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{className:`chat-waiting-tag ${e.mode}`,children:e.mode===`steer`?o(`Steering: read at the model's next step`):o(`Queued: sent when this reply ends`)}),(0,X.jsxs)(`span`,{className:`chat-waiting-actions`,children:[r(e)&&(0,X.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw and put back in the message box`),"aria-label":o(`Withdraw and put back in the message box`),onClick:()=>i(e,!0),children:(0,X.jsx)(Ta,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw`),"aria-label":o(`Withdraw`),onClick:()=>i(e,!1),children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]})]}),(0,X.jsx)(`p`,{className:`chat-attempt-text`,children:e.text})]},e.commandId)),t.map(e=>(0,X.jsxs)(`article`,{className:`chat-attempt chat-undelivered`,children:[(0,X.jsx)(`p`,{className:`chat-attempt-text`,children:e.text}),(0,X.jsxs)(`p`,{className:`inspector-note`,children:[(0,X.jsx)(`span`,{className:`ep-state ${e.status}`,children:s(e.status)}),` `,e.notice?s(e.notice):o(`Not delivered.`)]}),(0,X.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(e.text),children:[(0,X.jsx)(Ta,{"aria-hidden":`true`}),o(`Put back in the message box`)]})]},e.commandId))]})}function af({file:e}){let{t}=Z();return(0,X.jsxs)(`div`,{className:`retained-result toolcall-output`,children:[(0,X.jsxs)(`div`,{className:`toolcall-output-label`,children:[t(`Step result`),(0,X.jsx)(Vs,{text:e.text,label:t(`Copy output`),className:`output-copy`})]}),(0,X.jsx)(`pre`,{className:`workflow-detail`,children:e.text}),e.limited&&(0,X.jsx)(`p`,{children:t(`Preview is truncated.`)})]})}var of=[`queued`,`running`],sf=e=>of.includes(e.status);function cf(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function lf(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function uf(e,t,n){let r=[],i=[],a=new Map;if(!e.length)return{start:r,after:a,end:i};let o=e.filter(e=>e.header.at>0),s=e=>cf(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=cf(e),s=t===null?void 0:o.findLast(e=>e.header.at<=t);t===null||!o.length?i.push(e):s?a.set(s.header.id,[...a.get(s.header.id)??[],e]):n||r.push(e)}return{start:r,after:a,end:i}}function df(e,t,n,r,i,a){if(t>=e.length)return t;let o=e.slice(-t);if(o.some(e=>!n.has(e)&&!r.has(e)))return t;let s=o.flatMap(e=>{let t=n.get(e),r=t?cf(t):null;return r===null?[]:[r]}),c=s.length?Math.min(...s):1/0;return a||i!==void 0&&c>=i?t+8:t}function ff(e,t){let n=e.diagnostics?.acceptedAt,r=e.diagnostics?.settledAt;if(!n||!r||r<n)return``;let i=Math.round((r-n)/1e3);return i<60?t(`{s}s`,{s:i}):i<3600?t(`{m}m {s}s`,{m:Math.floor(i/60),s:i%60}):t(`{h}h {m}m`,{h:Math.floor(i/3600),m:Math.floor(i%3600/60)})}function pf({client:e,run:t,canCancelWorkflow:n,onOpen:r,onChanged:i}){let{t:a,tx:o}=Z(),s=(0,h.useId)(),[c,l]=(0,h.useState)(!1),[u,d]=(0,h.useState)(``),f=(0,h.useRef)(!0);(0,h.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let p=sf(t),m=p?Vc(t):null,g=t.status===`completed`?t.deviations?.length??0:0,_=g?g===1?a(`delivered with 1 deviation`):a(`delivered with {count} deviations`,{count:g}):``,v=e=>e.filter(Boolean).join(` · `),y=v(p?[o(lf(t)),m?Bc(m,a):t.steps.filter(e=>e.status===`running`).map(e=>Lc(e.id)).join(`, `)]:[o(t.status)]),b=p?``:v([t.mergedCommit?a(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,ff(t,a)]),x=p||t.status===`completed`?``:t.notice.split(`
|
|
40
|
+
`).find(e=>e.trim())??``,S=v([y,_,b]);return(0,X.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":s,children:[(0,X.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:a(`Open workflow details`),onClick:r,children:[(0,X.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`workflow-line-goal`,id:s,children:t.goal}),(0,X.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:S,children:_?(0,X.jsxs)(X.Fragment,{children:[`${y} · `,(0,X.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,X.jsx)(Ha,{"aria-hidden":`true`}),_]}),b&&` · ${b}`]}):S})]}),p&&(0,X.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":a(`Cancel workflow — request stop`),title:a(`Cancel workflow — request stop`),disabled:c||!n?.(t),onClick:()=>{!c&&n?.(t)&&(l(!0),d(``),gf(e,t,n).then(e=>{f.current&&(d(e),i?.())}).finally(()=>{f.current&&l(!1)}))},children:[(0,X.jsx)(Wi,{"aria-hidden":`true`}),a(`Stop`)]}),u?(0,X.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:nr(a,u)}):x&&(0,X.jsx)(`p`,{className:`workflow-line-reason`,title:x,children:o(x)})]})}function mf(e){if(e.pointerType!==`mouse`||matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=e.currentTarget,n=t.getBoundingClientRect();t.style.setProperty(`--spot-x`,`${e.clientX-n.left}px`),t.style.setProperty(`--spot-y`,`${e.clientY-n.top}px`)}function hf({proposal:e,canApprove:t,approvalHint:n,onApprove:r,action:i=`approve`,canValidate:a=!1,validating:o=!1,previous:s,onValidate:c}){let{t:l}=Z();return(0,X.jsxs)(`section`,{className:`workflow-plan`,"aria-label":l(`Current implementation plan`),children:[(0,X.jsx)(`h3`,{children:l(`Current implementation plan`)}),e.revalidatedFrom&&(0,X.jsx)(`p`,{role:`status`,children:l(`The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.`)}),s&&(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:l(`Previous execution context`)}),(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`code`,{children:s.cwd}),` · `,s.display?.model]}),(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`code`,{children:s.display?.branch}),` ·`,` `,(0,X.jsx)(`code`,{children:s.display?.baseCommit})]}),s.display?.runtime&&(0,X.jsx)(`p`,{children:s.display.runtime}),s.delivery&&(0,X.jsx)(qs,{text:jt(s.delivery)})]}),s&&s.observation!==e.observation&&(0,X.jsx)(`p`,{role:`status`,children:l(`Repository or execution-environment evidence changed. Review the current context before confirming.`)}),(0,X.jsx)(`p`,{children:l(`Tools and checks run on the service host, not in a sandbox.`)}),(0,X.jsxs)(`div`,{className:`plan-context`,children:[(0,X.jsxs)(`p`,{onPointerMove:mf,children:[(0,X.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,X.jsxs)(`p`,{onPointerMove:mf,children:[l(`Declared write paths use the checkout root:`),` `,(0,X.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.runtime&&(0,X.jsx)(`p`,{onPointerMove:mf,children:e.display.runtime}),e.display?.branch&&(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,X.jsx)(`code`,{children:e.display.baseCommit})]})]}),(0,X.jsx)(`p`,{children:l(`Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.`)}),(0,X.jsx)(qs,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:l(`Complete delivery agreement`)}),(0,X.jsxs)(`p`,{children:[l(`Plan identity`),` · `,(0,X.jsx)(`code`,{children:e.digest})]}),(0,X.jsx)(qs,{text:Bt(e.plan)})]}),e.delivery&&(0,X.jsx)(qs,{text:jt(e.delivery)}),(0,X.jsx)(`button`,{type:`button`,className:`primary`,"aria-busy":o||void 0,disabled:o||(i===`approve`?!t:!a),onClick:i===`approve`?r:c,children:l(o?`Validating plan…`:i===`restore`?`Restore execution and validate plan`:i===`validate`?`Validate plan again`:e.revalidatedFrom?`Confirm implementation`:`Implement this plan`)}),i===`approve`&&c&&(0,X.jsx)(`button`,{type:`button`,disabled:o||!a,onClick:c,children:l(`Validate plan again`)}),i!==`approve`&&(0,X.jsx)(`p`,{className:`inspector-note`,children:l(`Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.`)}),!t&&(i===`approve`||!a)&&(0,X.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??l(`Plan approval is currently unavailable.`)}),(0,X.jsx)(`p`,{children:l(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function gf(e,t,n){if(!n(t))return`stale`;let r=await e.workbenchCommand({kind:`workflow-cancel`,commandId:crypto.randomUUID(),epoch:t.epoch,runId:t.id});return r.kind===`error`?r.error.code:``}function _f({run:e}){let{tx:t}=Z();return(0,X.jsxs)(`span`,{children:[t(e.phase),` ·`,` `,(0,X.jsx)(`span`,{className:`workflow-status ${e.status}`,children:t(e.status)})]})}function vf(e){return(0,X.jsx)(yf,{...e},e.id)}function yf({client:e,id:t,onChanged:n,onOpenAgent:r,canCancelWorkflow:i}){let{t:a}=Z(),[o,s]=(0,h.useState)(1e3),[c,l]=(0,h.useState)(),u=ns(e,{kind:`workflow`,id:t},o),d=ns(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),f=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,p=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,m=c===void 0?p:f,[g,_]=(0,h.useState)(null),v=ns(e,g?{kind:`workflow-detail`,id:t,stepId:g}:null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(``),C=p&&[`queued`,`running`].includes(p.status),w=(0,h.useRef)(!0);return(0,h.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]),(0,h.useEffect)(()=>{p&&![`queued`,`running`].includes(p.status)&&s(0)},[p]),(0,X.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":a(`Workflow progress`),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`strong`,{children:p?.goal??a(`Observing workflow`)}),p&&(0,X.jsx)(_f,{run:p})]}),(u.error||d.error||x)&&(0,X.jsxs)(`p`,{role:`alert`,children:[x||u.error||d.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),p&&(0,X.jsx)(Sf,{run:p}),p?.execution&&(0,X.jsxs)(`p`,{className:`inspector-note`,children:[a(`Context fixed at admission:`),` `,(0,X.jsx)(`code`,{children:p.execution.cwd}),` ·`,` `,p.execution.model?`${p.execution.model.provider}/${p.execution.model.model} · ${p.execution.model.thinking}`:a(`No model`)]}),p?.notice&&(0,X.jsx)(`p`,{children:p.notice}),p&&m&&(0,X.jsx)(Tf,{run:p,steps:m.steps,partial:(m.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:Lc(e.id)}))}),p&&((p.revision??0)>0||!!p.scope?.length)&&(0,X.jsxs)(`section`,{className:`workflow-route`,"aria-label":a(`Route revisions`),children:[(p.revision??0)>0&&(0,X.jsxs)(`p`,{children:[a(`Implementation route updates`),`: `,p.revision]}),!!p.scope?.length&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:a(`Paths added to the write scope after approval:`)}),(0,X.jsx)(`ul`,{className:`workflow-scope`,children:p.scope.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`code`,{children:e})},e))})]})]}),p?.delivery&&(0,X.jsx)(Ef,{delivery:p.delivery,status:p.status}),p&&(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,X.jsx)(`pre`,{className:`workflow-detail`,children:Wt(p)})]}),p?.mergedCommit&&(0,X.jsxs)(`p`,{children:[a(`Actual local merge commit:`),` `,(0,X.jsx)(`code`,{children:p.mergedCommit})]}),p&&(0,X.jsx)(`p`,{className:`inspector-note`,children:a(`Agent review is not human review. Worktrees and retained results are preserved.`)}),p&&((m?.stepsBefore??0)>0||c!==void 0)&&(0,X.jsxs)(`nav`,{className:`workflow-actions`,children:[(m?.stepsBefore??0)>0&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(m?.stepsBefore),children:a(`Earlier workflow steps`)}),c!==void 0&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:a(`Latest workflow steps`)})]}),m&&(0,X.jsx)(bf,{steps:m.steps}),m?.steps.map(e=>(0,X.jsxs)(`details`,{className:`chat-tool`,children:[(0,X.jsx)(`summary`,{children:(0,X.jsx)(xf,{run:p??m,step:e})}),e.exitCode!==null&&(0,X.jsxs)(`p`,{children:[a(`Exit code`),`: `,e.exitCode]}),(0,X.jsx)(qs,{text:e.text}),e.childRunId&&r&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:Lc(e.id)}),children:a(`Open subagent context`)}),e.truncated&&(0,X.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>_(e.id),children:a(`Read retained step result`)}),g===e.id&&v.value?.kind===`file`&&(0,X.jsx)(af,{file:v.value}),g===e.id&&v.error&&(0,X.jsx)(`p`,{role:`alert`,children:v.error})]},e.id)),C&&(0,X.jsx)(`button`,{type:`button`,className:`danger`,disabled:y||!i?.(p),onClick:()=>{!y&&i?.(p)&&(b(!0),gf(e,p,i).then(e=>{w.current&&(S(e),u.refresh(),n?.())}).finally(()=>{w.current&&b(!1)}))},children:a(`Cancel workflow — request stop`)}),(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:a(`Observe current state`)})]})}function bf({steps:e}){let{t}=Z(),n=t=>e.filter(e=>e.status===t).length,r=n(`partial`),i=n(`blocked`);return!r&&!i?null:(0,X.jsxs)(`p`,{className:`inspector-note`,children:[t(`Attempts shown: {partial} partial · {blocked} blocked · {failed} failed`,{partial:r,blocked:i,failed:n(`failed`)}),` · `,t(`Partial or blocked assignments preserve work; they are not process failures or delivery approval.`)]})}function xf({run:e,step:t}){let{t:n,tx:r}=Z();return(0,X.jsxs)(X.Fragment,{children:[`${r(t.kind)} · ${Lc(t.id)} · `,(0,X.jsx)(`span`,{className:`workflow-status ${t.status}`,children:r(t.status)}),Gc(e,t)&&(0,X.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function Sf({run:e}){let{t}=Z(),n=e.deviations??[];return n.length?(0,X.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,X.jsxs)(`h3`,{children:[(0,X.jsx)(Ha,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,X.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,X.jsx)(`ol`,{children:n.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:t(`Could not be met`)}),(0,X.jsx)(`dd`,{children:e.item}),(0,X.jsx)(`dt`,{children:t(`Why`)}),(0,X.jsx)(`dd`,{children:e.reason}),(0,X.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,X.jsx)(`dd`,{children:e.delivered}),(0,X.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,X.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,X.jsx)(`code`,{children:e},e)):t(`None`)}),(0,X.jsx)(`dt`,{children:t(`Recorded at`)}),(0,X.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function Cf({state:e}){return e===`running`?(0,X.jsx)(yd,{}):e===`completed`?(0,X.jsx)(Ia,{"aria-hidden":`true`}):e===`failed`?(0,X.jsx)(Bi,{"aria-hidden":`true`}):e===`superseded`?(0,X.jsx)(Gi,{"aria-hidden":`true`}):(0,X.jsx)(ka,{"aria-hidden":`true`})}function wf(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function Tf({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=Z(),o=Rc(e);return o?(0,X.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,X.jsxs)(`h3`,{children:[i(`Assignments`),(0,X.jsx)(`span`,{className:`workflow-board-counts`,children:Bc(o,i)})]}),n&&(0,X.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,X.jsx)(`ul`,{children:Hc(e,t).map(({task:e,steps:t,artifact:n})=>(0,X.jsxs)(`li`,{className:`workflow-task`,onPointerMove:mf,children:[(0,X.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,X.jsx)(Cf,{state:e.state}),a(e.state)]}),(0,X.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,X.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,X.jsx)(`span`,{children:e.title}),(0,X.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,X.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,X.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,X.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,X.jsx)(`span`,{className:`workflow-task-worktree`,children:wf(n,i)})]}),n?.state===`retained`&&(0,X.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,X.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,X.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,X.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function Ef({delivery:e,status:t}){let{t:n,tx:r}=Z(),i=Mt(e,t),a=[[n(`Task branch`),e.taskBranch],[n(`Task worktree`),e.worktreeRoot],[n(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[n(`Worktree preparation`),r(i.preparation)],[n(`Candidate commit`),e.candidate??n(i.missingCandidate)],[n(`Candidate acceptance`),e.acceptance?`${e.acceptance.waived?.length?n(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):n(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:n(i.missingCandidate)],[n(`Local integration`),`${r(i.integration)}${e.integration.after?` · ${e.integration.after}`:``}`],[n(`Post-merge checks`),r(e.postChecks)],[n(`Worktree cleanup`),r(i.cleanup)]];return(0,X.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":n(`Task branch delivery`),children:[(0,X.jsx)(`dl`,{children:a.map(([e,t])=>(0,X.jsxs)(h.Fragment,{children:[(0,X.jsx)(`dt`,{children:e}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,X.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,X.jsx)(`p`,{children:e.cleanup.reason}),(0,X.jsx)(`p`,{children:n(`Policy: keep the task branch; no push or deployment.`)})]})}var Df=[],Of=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function kf(e){return e.scrollHeight-e.scrollTop-e.clientHeight<80}function Af(e,t){t&&e&&(e.scrollTop=e.scrollHeight)}function jf(e,t){let{summary:n,observation:r}=e;if(!r||e.error||n===void 0||n&&(n.id!==t||n.status===`unknown`||n.live&&n.live.epoch!==r.epoch))return`unavailable`;if(!wl(n?.status))return`idle`;let i=e.turns.at(-1);return i&&i.ordinal===e.count-1&&wl(i.header.status)?i.header.at:0}function Mf(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Nf({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,viewer:u,access:d,readSelected:f,onDiagnostics:p,prepareForSend:m,prepareForPlan:g,legacyWorkspaceId:_,directoryNamespaces:v=[],available:y=c,canInterrupt:b=c,canCancelWorkflow:x,modelAvailability:S,previewModels:C,initialDraft:w,onDraftApplied:T,onModelChanged:D,onChanged:O,reference:k,onReferenceUsed:A,hidden:j=!1,observe:M=0,onOpenAgent:N,activeWorkflowIds:P=Df,onAgents:F,onBranches:I,onOpenBranches:L}){let{t:R,tx:z}=Z(),[B]=(0,h.useState)(()=>Ul(n,t,_,...v)),[V,ee]=(0,h.useState)(()=>Mf(B,w?.text));(0,h.useEffect)(()=>{w&&T?.()},[w,T]);let te=Vu(),ne=te.remove,re=(0,h.useRef)([]),ie=(0,h.useRef)(!0),ae=nf({draftKey:B,draft:V,setDraft:ee,images:te,alive:ie,onUnread:()=>ge(R(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:oe,attaching:se}=ae,U=ae.release,le=(0,h.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[ue,W]=(0,h.useState)(()=>Mf(`${B}:mode`)===`cadence`?`cadence`:`chat`),[de,fe]=(0,h.useState)(!1),[pe,G]=(0,h.useState)(``),me=`conversation:${t}`,he=()=>{G(``),Rs(me)},ge=e=>Is(`error`,e,me);(0,h.useEffect)(()=>()=>Rs(me),[me]);let[_e,ve]=(0,h.useState)(()=>Mf(`${B}:pending`)),[ye,be]=(0,h.useState)(()=>Mf(`${B}:model-command`)),[K,xe]=(0,h.useState)(!1),[Se,Ce]=(0,h.useState)(!1),[we,Te]=(0,h.useState)(!1),[Ee,De]=(0,h.useState)(0),Oe=(0,h.useRef)(null),ke=(0,h.useRef)(void 0),Ae=(0,h.useRef)(!1),je=(0,h.useRef)(0),Me=(0,h.useRef)(new AbortController),Ne=Me.current.signal,[Pe,Fe]=(0,h.useState)(!1),[Ie,Le]=(0,h.useState)(()=>{try{let e=sessionStorage.getItem(`${B}:model`);if(e)return ce(JSON.parse(e))}catch{}return w?.model??null});(0,h.useEffect)(()=>{try{Ie?sessionStorage.setItem(`${B}:model`,JSON.stringify(Ie)):sessionStorage.removeItem(`${B}:model`)}catch{}},[B,Ie]);let Re=(0,h.useMemo)(()=>({async workbenchRead(t,n){let r=gr([n,d?.signal]);try{if(r.signal.aborted||f?.()===!1)return{kind:`error`,error:E(`stale`)};let n=await e.workbenchRead(t,r.signal);return r.signal.aborted||f?.()===!1?{kind:`error`,error:E(`stale`)}:(n.kind===`error`&&Xo(n.error.code)&&d?.refuse(`viewer`,n.error.code),n)}finally{r.dispose()}}}),[e,f,d]),ze=ns(Re,y&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),Be=ze.value?.kind===`conversation-context`?ze.value.context:void 0,Ve=!!Be&&!ze.error,He=Be?.cwd??r,Ue=(0,h.useMemo)(()=>({models:(n,r)=>He?e.models(n,{id:t,cwd:He},r):Promise.resolve({kind:`error`,error:E(`unavailable`)})}),[e,t,He]),We=(0,h.useMemo)(()=>({chooseModel:n=>He&&l&&(!u||u.current()&&n.expected.epoch===u.epoch)?e.chooseModel(n,{id:t,cwd:He}):Promise.resolve({kind:`error`,error:E(`stale`)})}),[e,l,He,u,t]),Ge=Pe?{status:`preparing`}:S.status===`ready`&&(!y||!Ve)?{status:ze.error?`unavailable`:`connecting`}:S,Ke=(0,h.useRef)(Ge);Ke.current=Ge;let qe=Kl(Ue,Ge,`${Ee}:${Be?.revision??`unobserved`}`,C),Je=()=>{Oe.current=null,Ce(!1),Te(!1)},Ye=(e,t)=>{e?qe.reread(!0):!e&&t!==`chosen`&&Je(),xe(e)},Xe=(e,t)=>{Le(t?null:e);let n=Oe.current;Se&&n&&(zl(n,Ke.current)===`cancel`?(Je(),ge(R(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Oe.current=Rl(n,e,t),Ce(!1),he(),Te(!0)))},Ze=(0,h.useRef)(o);Ze.current=o,(0,h.useEffect)(()=>{Ve&&He&&Ze.current?.({id:t,cwd:He})},[Ve,t,He]);let[Qe]=(0,h.useState)(()=>typeof window<`u`&&Hn()===t?Jn(window.location.hash,t).leaf:i),q=Wl(Re,t,y,S.status===`ready`?S:null,Qe),{turns:$e}=q,et=q.summary!==void 0,tt=ns(Re,y?{kind:`cadence-conversation`,id:t}:null,1e3),[nt,rt]=(0,h.useState)(),it=tt.value?.kind===`cadence-conversation`?tt.value.state:void 0,J=it&&nt?.id===t&&nt.revision>it.revision?nt:it,at=J?.enabled===!0,ot=!!J||!!tt.error,Y=!!J&&!tt.error&&!J.notice,st=(0,h.useRef)(J);st.current=J;let[ct,lt]=(0,h.useState)(()=>Mf(`${B}:approval`,``)),ut=(0,h.useRef)(ct),dt=(0,h.useRef)(!1),[ft,pt]=(0,h.useState)(!1),[mt,ht]=(0,h.useState)(``),[gt,_t]=(0,h.useState)(),vt=(0,h.useCallback)(e=>{ut.current=e,lt(e);try{e?sessionStorage.setItem(`${B}:approval`,e):sessionStorage.removeItem(`${B}:approval`)}catch{}},[B]),yt=rs(V,at?`cadence`:ue),bt={active:at,armed:yt.mode===`cadence`,known:Y},xt=mu[du(bt)],St=c&&!(a&&!q.summary)&&Ve&&et&&!q.error&&ot&&!(at&&(tt.error||J?.notice))&&!de&&!Se&&!_e,Ct=q.summary??void 0,wt=Ct?.status,Tt=wl(wt),Et=!!Ct&&Ct.status!==`completed`&&!Tt,Dt=$e.at(-1)?.header,Ot=jf(q,t),{tokens:kt,provider:At,model:jt}=q.context??{},Mt=qe.catalog?.entries??qe.preview?.entries,Nt=(0,h.useMemo)(()=>kt===void 0||At===void 0||jt===void 0?void 0:tl({tokens:kt,provider:At,model:jt},Mt),[kt,At,jt,Mt]),{input:Pt,read:Ft,write:It}=q.cache??{},Lt=(0,h.useMemo)(()=>Pt===void 0||Ft===void 0||It===void 0?void 0:{input:Pt,read:Ft,write:It},[Pt,Ft,It]),Rt=q.refresh;(0,h.useEffect)(()=>{M&&Rt()},[M,Rt]);let zt=(0,h.useRef)(s);zt.current=s,(0,h.useLayoutEffect)(()=>{zt.current?.({id:t,turns:q.count,replyClock:Ot,...Nt?{context:Nt}:{},...Lt?{cache:Lt}:{}})},[t,q.count,Ot,Nt,Lt]);let Bt=$e.at(-1),Vt=wl(Bt?.header.status),Ht=$c(e,t,q.leaf,[Bt?.header.id??``,q.count,q.branches,Vt].join(),y&&!!Ct),{tree:Ut}=Ht,Wt=(0,h.useMemo)(()=>Xc(Ut??{nodes:[],truncated:!1}),[Ut]),Gt=(0,h.useMemo)(()=>{let e=Zc(Ut?.nodes??[]).map(e=>({id:e.id,text:e.text}));if(!Bt||!Vt||e.some(e=>e.id===Bt.header.id))return e;let t=pd(Bt.steps).user[0]?.step.text??``;return[...e,{id:Bt.header.id,text:il(t)}]},[Ut,Bt,Vt]),[Kt,qt]=(0,h.useState)(null),[Jt,Yt]=(0,h.useState)(null),[Xt,Zt]=(0,h.useState)(null),Qt=!!m&&c&&(!!q.error||!!ze.error)&&q.error!==`retired-conversation`&&ze.error!==`retired-conversation`&&!J?.notice&&!Tt&&!de&&!_e&&!Se,$t=(l||!!m)&&Ve&&et&&Y&&!q.error&&!de&&!_e&&!Tt,tn=!!Ie&&H(Ie)!==H(Be?.model??null),nn=!!J?.proposal&&!!Ct&&!Tt&&Ct.status!==`unknown`,rn=J?.proposal?Ql(J.proposal,l,qe.catalog?.version,tn||mt===J.proposal.id):`approve`,an=!!gt&&!!J&&J.revision<gt.after.revision,on=!!J?.proposal&&St&&Y&&nn&&!ct&&!ft&&!an&&(!!g||l)&&!!(Ie??Be?.model),sn=ft?R(`Preparing execution and validating the plan; no implementation is approved.`):an?R(`Reading the validated plan…`):tn?R(`Validate the plan with this model before approving it.`):Ct?.status===`unknown`?R(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?Y?Tt?R(`Wait for the current reply before approving this plan.`):ct?R(`Observing plan approval…`):St?void 0:R(`Read the current conversation context before approving this plan.`):R(`Cadence state unavailable`):R(`Read the current execution state before approving this plan.`),cn=(0,h.useRef)(null),ln=(0,h.useRef)(null),un=(0,h.useRef)(0),dn=(0,h.useRef)(!0),[fn,pn]=(0,h.useState)(!1),mn=(0,h.useRef)(null),hn=(0,h.useRef)(null),gn=(0,h.useCallback)((e=!1)=>{let t=ln.current;if(!t)return;let n=t.scrollHeight-t.clientHeight;dn.current&&(e||n!==hn.current)&&(Af(t,!0),mn.current=t.scrollTop),hn.current=n},[]);(0,h.useLayoutEffect)(()=>{!j&&ln.current&&!dn.current&&(ln.current.scrollTop=un.current)},[j]);let _n=(0,h.useRef)(``),vn=(0,h.useRef)(V);(0,h.useEffect)(()=>(ie.current=!0,Me.current.signal.aborted&&(Me.current=new AbortController),()=>{ie.current=!1,Me.current.abort()}),[]),(0,h.useEffect)(()=>{try{sessionStorage.setItem(`${B}:mode`,ue)}catch{}},[B,ue]),(0,h.useEffect)(()=>{try{sessionStorage.setItem(B,V)}catch{}},[V,B]),(0,h.useEffect)(()=>{try{_e?sessionStorage.setItem(`${B}:pending`,_e):sessionStorage.removeItem(`${B}:pending`)}catch{}},[B,_e]),(0,h.useEffect)(()=>{try{_e&&ye===_e?sessionStorage.setItem(`${B}:model-command`,ye):sessionStorage.removeItem(`${B}:model-command`)}catch{}},[B,_e,ye]),(0,h.useEffect)(()=>{k&&(ee(e=>`${e}${e?`
|
|
41
|
+
`:``}@${k}`),A(),cn.current?.focus())},[k,A]),(0,h.useEffect)(()=>{let e=Ct?`${Ct.leaf}:${Ct.status}`:``;e&&_n.current!==e&&(_n.current=e,O()),ut.current&&J?.runs.includes(ut.current)&&(vt(``),G(``)),_e&&(Ct?.live?.commandId===_e||q.attempt?.commandId===_e||$e.some(e=>e.header.id===_e)||q.commands.includes(_e))&&(ve(``),Bl(_e,ye)&&Le(null),be(``),ne(re.current),ee(e=>e===vn.current?``:e),Bl(_e,ye)&&cu(n,vn.current),le.current.followAnchor(),O())},[Ct,$e,_e,ye,O,J,q,ne,n,vt]);let yn=(0,h.useMemo)(()=>$e.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[$e]),bn=Ec(ln,yn,Jt?.id??null,void 0,gn),{earlier:xn,loadEarlier:Sn}=q,Cn=()=>{let e=ln.current;e&&!j&&xn&&e.scrollTop<1200&&Sn()};(0,h.useEffect)(Cn);let wn=(0,h.useRef)(0),Tn=()=>{wn.current||=requestAnimationFrame(()=>{wn.current=0;let e=ln.current;if(!e)return;let t=null;if(!dn.current){let n=e.getBoundingClientRect().top+140;for(let r of e.querySelectorAll(`[data-lazy-id]`)){if(t!==null&&r.getBoundingClientRect().top>n)break;t=r.dataset.lazyId??null}}Zt(t)})};(0,h.useEffect)(()=>()=>{wn.current&&cancelAnimationFrame(wn.current)},[]),(0,h.useEffect)(()=>{if(!Jt)return;let e=requestAnimationFrame(()=>{let e=[...ln.current?.querySelectorAll(`[data-lazy-id]`)??[]].find(e=>e.dataset.lazyId===Jt.id);e&&(dn.current=!1,e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),Zt(Jt.id))});return()=>cancelAnimationFrame(e)},[Jt]);let En=$e[0]?.ordinal,Dn=(0,h.useRef)({height:0});(0,h.useLayoutEffect)(()=>{let e=ln.current;if(!e)return;let t=Dn.current;!Of&&!dn.current&&t.ordinal!==void 0&&En!==void 0&&En<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),j||gn(),Dn.current={ordinal:En,height:e.scrollHeight}}),(0,h.useEffect)(()=>{try{sessionStorage.removeItem(`${B}:approval`)}catch{}},[B]);let On=(0,h.useMemo)(()=>[...new Set([...q.runs,...J?.runs??[]])],[q.runs,J?.runs]),[kn,An]=(0,h.useState)({terminal:8,browser:8}),jn=(0,h.useMemo)(()=>[...new Set([...P,...q.runs.slice(-kn.terminal),...(J?.runs??[]).slice(-kn.browser),...ct?[ct]:[]])],[P,q.runs,J?.runs,kn,ct]),Mn=Zl(Re,t,y?jn:[]),Nn=!y||!et||!!q.error||!Y||!!Mn.error||Mn.incomplete;(0,h.useEffect)(()=>{if(!F)return;let e=On.filter(e=>Mn.runs.has(e)).slice(-4);F({groups:Wc([...P,...e],Mn.runs),unavailable:Nn})},[On,P,Mn.runs,Nn,F]);let Pn=y?ze.error:void 0,Fn=y&&q.error||void 0,In=y?tt.error:void 0,Ln=y?Mn.error:void 0,Rn=(0,h.useRef)(()=>{});Rn.current=()=>{ie.current&&!d?.signal.aborted&&(Pn&&ze.refresh(),Fn&&q.refresh(),tt.error&&tt.refresh(),Ln&&Mn.refresh())},(0,h.useEffect)(()=>{p?.({context:Pn,head:Fn,prepareOnly:Qt,workflow:In,runs:Ln,retry:()=>Rn.current()})},[Pn,Fn,In,Ln,Qt,p]);let zn=$e.find(e=>e.header.at>0)?.header.at,Bn=!xn&&$e.length>0;(0,h.useEffect)(()=>{if(!y)return;let e=(e,t)=>df(e,t,Mn.runs,Mn.unreadable,zn,Bn),t=e(q.runs,kn.terminal),n=e(J?.runs??[],kn.browser);(t!==kn.terminal||n!==kn.browser)&&An({terminal:t,browser:n})},[y,q.runs,J?.runs,kn,Mn,zn,Bn]);let Vn=(0,h.useMemo)(()=>uf($e,Mn.runs.values(),xn),[$e,Mn.runs,xn]),Un=t=>(0,X.jsx)(pf,{client:e,run:t,canCancelWorkflow:x,onOpen:()=>N?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{tt.refresh(),O()}},t.id),Wn=async()=>{if(!on||!J?.proposal||!Be||dt.current)return;let t=Ie??Be.model;if(!t)return;let n=J.proposal,r=J,i=je.current,a=u,o=l?void 0:g,s=!o,c=()=>ie.current&&!Ne.aborted&&je.current===i&&(s?!a||a.current():!u?.allocation?.aborted);if(c()){dt.current=!0,fe(!0),pt(!0),he();try{let l=await $l({client:e,state:r,context:Be,model:t,head:q.leaf,signal:Me.current.signal,current:c,prepare:o?async(...e)=>{if(a=await o(...e)||void 0,u&&!a)throw Error(`stale`);s=!0}:void 0});if(!ie.current||je.current!==i)return;_t({before:n,after:l}),ht(``),Le(e=>H(e)===H(t)?null:e)}catch(e){ie.current&&je.current===i&&G(R(`Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{ie.current&&je.current===i&&(dt.current=!1,fe(!1),pt(!1),De(e=>e+1),ze.refresh(),tt.refresh(),q.refresh(),O())}}},Gn=async()=>{if(!J?.proposal){ge(R(`No plan is awaiting approval.`));return}if(rn!==`approve`){await Wn();return}if(dt.current||an||tn||!l||!Y||!St||Tt||ct||!nn)return;let t=J.proposal,n=J,r=je.current;dt.current=!0,fe(!0),he();try{let i=await eu({client:e,state:n,current:()=>ie.current&&je.current===r&&!Ne.aborted&&(!u||u.current())&&st.current?.revision===n.revision&&st.current?.enabled===!0,submitting:vt});if(!ie.current||je.current!==r)return;i.kind===`error`?(G(i.error.code),i.error.effect===`none`&&(vt(``),i.error.code===`stale`&&ht(t.id))):ee(e=>nu(e)?``:e)}catch(e){ie.current&&je.current===r&&(G(e instanceof Error?e.message:`unavailable`),!ut.current&&e instanceof Error&&e.message===`stale`&&ht(t.id))}finally{ie.current&&je.current===r&&(dt.current=!1,fe(!1),tt.refresh(),q.refresh(),O())}},Kn=async n=>{if(!J?.design||dt.current||Ne.aborted)return;if(!l||u&&!u.current()||st.current?.revision!==J.revision){tt.refresh();return}he();let r=je.current;dt.current=!0,fe(!0);try{let i=await e.workbenchCommand({kind:`cadence-design-edit`,commandId:crypto.randomUUID(),conversationId:t,revision:J.revision,designId:J.design.id,answers:n});if(!ie.current||r!==je.current)return;if(i.kind!==`ok`){if(i.error.code===`stale`&&i.error.effect===`none`){rt(void 0),ge(R(`The choices changed before this answer was saved.`));return}throw Error(i.error.code)}if(i.value.kind!==`cadence-conversation`||i.value.state.id!==t)throw Error(`stale`);rt(i.value.state)}catch(e){ie.current&&r===je.current&&G(e instanceof Error?e.message:`unavailable`)}finally{ie.current&&r===je.current&&(dt.current=!1,fe(!1),tt.refresh())}},qn=async(r,i,a=!1)=>{let o=i?.text??r??V,s=i?.images??(r?[]:te.files),c=i?i.command.kind===`cadence-exit`:at&&tu(o);if(!(c?$t:St)&&!Qt||Tt||se&&!i||!o.trim()&&!s.length||i&&(!St||zl(i,Ke.current)!==`ready`))return;if(c&&s.length){ge(R(`Remove images before exiting Cadence.`));return}if(!s.length&&!i&&!r&&at&&nu(o)){await Gn();return}let l=rs(o,ue).mode===`cadence`;if(!Qt&&(at||l)&&!Y){ge(R(`Cadence state unavailable. Observe the conversation before sending.`));return}if(Ae.current||!ie.current||Ne.aborted||u?.allocation?.aborted||(!m||i)&&u&&!u.current()||i&&ke.current?.allocation!==u?.allocation)return;Ae.current=!0,fe(!0),he();let d=je.current,f=()=>ie.current&&je.current===d,p=u,h=()=>f()&&(!p||p.current()),g=e=>{if(!h()||e&&p&&p.epoch!==e)throw Error(`stale`)},_=!1,v=`not-dispatched`,y=(e,t)=>{let n=R(jl(t),{code:e});t===`none`?ge(n):G(n)},b=e=>{f()&&(ve(e),be(e&&!c?e:``))},x=async e=>{m&&(Fe(!0),await Ol(async(...e)=>{if(p=await m(...e)||void 0,u&&!p)throw Error(`stale`)},Me.current.signal,e,e=>{v=e}),f()&&(Fe(!1),De(e=>e+1)))};try{if(Qt){if(await x(Be?{id:t,cwd:Be.cwd}:void 0),!f())return;q.refresh(),ze.refresh(),tt.refresh(),O(),G(R(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let u=i??Nl({id:t,head:c?q.leaf:ol(oe,q.leaf),text:o,images:s,revision:J?.revision??0,location:Be?{id:t,cwd:Be.cwd}:void 0,installModel:!!Ie,model:Ie??(qe.catalog?.selected?Pl(qe.catalog.selected):qe.catalog?.remembered??Be?.model??qe.preview?.remembered??void 0),intent:a?`design`:c?`exit`:at?`message`:l?`enter`:`ordinary`});if(i){if(zl(i,Ke.current)!==`ready`)throw Error(`stale`)}else await x(u.location);if(!f())return;if(g(),u.command.kind===`cadence-exit`){let t=Hl(u);vn.current=o,_=!0;let n=await Ml(e,t,b);if(!f())return;n.kind===`error`?y(n.error.code,n.error.effect):(ve(``),W(`chat`),ee(e=>e===o?``:e)),tt.refresh(),q.refresh(),O();return}let d=e=>{let t=Ke.current,n=e??(t.status===`ready`?t.epoch:void 0);n&&zl(Ll(u,n),t)!==`cancel`?(ke.current=p,Oe.current=Ll(u,n),Ce(!0)):(Je(),ge(R(`The connection changed. Your model choice and draft are kept; send again when ready.`))),Ye(!0)},m=await e.models(void 0,u.location);if(!f())return;if(g(m.kind===`ok`?m.value.version.epoch:void 0),u.preparedEpoch&&m.kind===`ok`&&m.value.version.epoch!==u.preparedEpoch)throw Error(`stale`);let v=m.kind===`ok`?m.value.selected??m.value.remembered:null;if(!u.model&&v&&(u=Fl(u,v)),u.installModel&&m.kind===`ok`){if(m={kind:`ok`,value:await Vl(e,u,m.value,h)},!f())return;De(e=>e+1)}let S=u.model??(m.kind===`ok`?m.value.remembered:null);if(m.kind===`ok`&&!m.value.selected&&S){g(m.value.version.epoch);let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:m.value.version.epoch,...u.location?{location:u.location,expected:m.value.version,choice:S}:{}});if(!f())return;if(t.kind===`error`){G(t.error.code),d(m.value.version.epoch);return}if(m=await e.models(void 0,u.location),!f())return;De(e=>e+1)}if(m.kind!==`ok`||!m.value.selected){d(m.kind===`ok`?m.value.version.epoch:void 0);return}g(m.value.version.epoch),Il(u,m.value.selected);let C=Hl(u,m.value.version);if(u.images.length){let t=m.value.selected;if(!m.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){ge(R(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(C.kind===`cadence-exit`)throw Error(`invalid`);if(C=await _l(e,C,u.images,h),!f())return}g(m.value.version.epoch),re.current=u.images,vn.current=o,_=!0;let w=await Ml(e,C,b);if(!f())return;w.kind===`error`?y(w.error.code,w.error.effect):(ne(re.current),Le(null),ee(e=>e===vn.current?``:e),ve(``),C.kind===`cadence-send`&&W(`chat`),r||cu(n,o),dr(null)),tt.refresh(),q.refresh(),O()}catch(e){if(f()){let t=e instanceof Error?e.message:`unavailable`,n=Al(e),r=R(_?jl():kl(v,n),{code:t});!_&&(v===`not-dispatched`||n===`none`)?ge(r):G(r)}}finally{je.current===d&&(Ae.current=!1),f()&&(fe(!1),Fe(!1))}},Yn=(0,h.useRef)(qn);Yn.current=qn,(0,h.useEffect)(()=>{let e=Oe.current;if(!e||!we&&!Se)return;let t=zl(e,Ge);t===`cancel`?(Oe.current=null,Ce(!1),Te(!1),Is(`error`,R(`The connection changed. Your model choice and draft are kept; send again when ready.`),me)):we&&t===`ready`&&St&&!Tt&&(Te(!1),Oe.current=null,Yn.current(void 0,e))},[we,Se,St,Tt,Ge,R,me]),(0,h.useEffect)(()=>{if(!we)return;let e=setTimeout(()=>{Te(!1),Oe.current=null},1e4);return()=>clearTimeout(e)},[we]);let Zn=typeof Ot==`number`&&Ct?.status===`running`&&$e.at(-1)?.ordinal===q.count-1&&Dt?.status===`running`&&(Dt.activity?.kind===`tool`||Dt.activity?.kind===`thinking`),Qn=Tt?Ct?.live:void 0,$n=(0,h.useRef)(new Map),er=ll({images:te.files.length,modeChange:at?tu(V):yt.mode===`cadence`,anchored:!!oe,waiting:q.pending.length}),tr=(0,h.useRef)(Qn);tr.current=Qn;let rr=(0,h.useRef)(q.pending);rr.current=q.pending;let ir=()=>!!Qn&&ie.current&&!Ne.aborted&&b&&(!u||u.attached(Qn.epoch))&&tr.current?.commandId===Qn.commandId&&tr.current?.epoch===Qn.epoch,ar=()=>ir()&&l&&(!u||u.current()),or=ar()&&!de&&!_e&&!se,sr=async r=>{if(!Qn||!or||!ar()||er||!V.trim())return;he(),fe(!0);let i=V,a=ul(t,Qn,r,i),o=pl(await e.workbenchCommand(a));ie.current&&(fe(!1),o.kind===`accepted`?($n.current.set(a.commandId,i),cu(n,i),ee(``)):o.kind===`refused`?ge(R(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:nr(R,o.code)})):G(o.code),q.refresh())},cr=async(n,r)=>{if(!Qn||de||!ar()||!rr.current.some(e=>e.commandId===n.commandId))return;fe(!0);let i=pl(await e.workbenchCommand(dl(t,Qn,n.commandId)));if(ie.current){if(fe(!1),i.kind===`accepted`){let e=$n.current.get(n.commandId)??n.text;$n.current.delete(n.commandId),r&&ee(t=>t.trim()?t:e)}else i.kind===`refused`?ge(i.code===`conflict`?R(`That message has already been handed to the model and can no longer be withdrawn.`):R(`The message was not withdrawn ({reason}).`,{reason:nr(R,i.code)})):G(i.code);q.refresh()}},lr=e=>{ee(t=>t.trim()?`${t}\n${e}`:e),cn.current?.focus()},ur=async()=>{let n=Ct?.live;if(!n||de||!ir())return;fe(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});ie.current&&(r.kind===`error`&&G(r.error.code),fe(!1),q.refresh())},dr=(e,n)=>{++je.current,Me.current.abort(),Me.current=new AbortController,Oe.current=null,Ae.current=!1,dt.current=!1,pt(!1),_t(void 0),Ce(!1),Te(!1),xe(!1),fe(!1),Fe(!1),U(),q.choose(e,n),Xn(t,e)},fr=!Tt&&!de&&!_e&&!Se,pr=()=>{he(),cn.current?.focus()},mr=e=>{fr&&e.header.entry&&(e.ordinal>=q.count-1?U():ae.continueAfter(e),pr())},hr=e=>{if(!fr)return;let t=$e.find(t=>t.ordinal===e.ordinal-1);ae.edit(e,t)?pr():ge(R(`This message cannot be rewritten from here: the entry it continued is not known.`))},_r=(e,t)=>qt({id:e,then:t});le.current={chooseBranch:dr,followAnchor(){ae.current()&&dr(null)},show:_r,stepVersion:(e,t)=>{let n=Wt.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(dr(r.leaf===Ct?.leaf?null:r.leaf,$e.find(t=>t.header.id===e)?.ordinal),_r(r.id,`show`))}};let vr=(0,h.useCallback)(e=>le.current.show(e,`continue`),[]),yr=(0,h.useCallback)(e=>le.current.show(e,`edit`),[]),br=(0,h.useCallback)((e,t)=>le.current.stepVersion(e,t),[]),xr=(0,h.useCallback)(e=>le.current.show(e,`show`),[]);(0,h.useEffect)(()=>{if(!Kt)return;let e=$e.find(e=>e.header.id===Kt.id);if(e){qt(null),Kt.then===`edit`?hr(e):Kt.then===`continue`&&mr(e),Yt({id:e.header.id});return}let t=e=>{qt(null),ge(e)};if(q.error)return qt(null);if(!et||!$e.length&&q.count>0)return;if(!Ht.current){Ht.error&&!Ht.loading&&t(nr(R,Ht.error));return}let n=Ut?.nodes.find(e=>e.id===Kt.id);if(n&&!n.current&&!Kt.switched)return dr(n.leaf===Ct?.leaf?null:n.leaf),qt({...Kt,switched:!0});let r=Qc(Gt,Kt.id,$e,q.count,Vt);if(r===void 0||$e.some(e=>e.ordinal===r))return t(R(`That message could not be found in this conversation.`));q.showFrom(r)});let Sr=de||Se||!!_e||Tt||se,Cr=e=>{if(!Sr)try{te.add(e),he()}catch(e){ge(z(e instanceof Error?e.message:`unavailable`))}},Q=(0,h.useRef)(I);Q.current=I;let wr=(0,h.useMemo)(()=>({onShow:e=>le.current.show(e.id,`show`),onEdit:e=>le.current.show(e.id,`edit`),onContinue:e=>le.current.show(e.id,`continue`),onLatest:()=>le.current.chooseBranch(null)}),[]),{error:Tr,loading:Er,refresh:Dr}=Ht,{pinned:Or}=q;(0,h.useEffect)(()=>{Q.current?.({id:t,tree:Ut,error:Tr,loading:Er,pinned:Or,canAct:fr,onRefresh:Dr,...wr})},[t,Ut,Tr,Er,Or,fr,Dr,wr]);let kr=oe!==null&&($e.some(e=>e.header.id===oe.turnId)||Gt.some(e=>e.id===oe.turnId))?oe:null,Ar=kr?yn.find(({turn:e})=>sl(kr,e.ordinal))?.id:void 0,jr=Xt===null?Gt.length-1:Gt.findIndex(e=>e.id===Xt),Mr=oe?(0,X.jsxs)(`div`,{className:`composer-anchor`,children:[oe.kind===`edit`?(0,X.jsx)(xa,{"aria-hidden":`true`}):(0,X.jsx)(Ea,{"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,X.jsx)(`strong`,{children:oe.kind===`edit`?R(`Rewriting a message`):R(`Continuing after an earlier turn`)}),oe.label&&(0,X.jsx)(`span`,{className:`composer-anchor-quote`,children:oe.label}),(0,X.jsxs)(`span`,{children:[oe.kind===`edit`?R(`Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.`):R(`Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.`),` `,R(`Only the conversation is rewound: files on disk stay as they are.`)]}),se&&(0,X.jsx)(`span`,{children:R(`Reading the message's images…`)}),oe.media&&(0,X.jsx)(`span`,{children:R(`Attachments that were not retained are not attached again.`)})]}),(0,X.jsx)(`button`,{type:`button`,className:`ghost`,title:R(`Cancel and restore the draft that was here`),disabled:de||!!_e,onClick:()=>{U(),cn.current?.focus()},children:R(`Cancel`)})]}):Or&&!Tt?(0,X.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,X.jsx)(ha,{"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,X.jsx)(`span`,{children:R(`A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.`)})})]}):void 0;return(0,X.jsxs)(`section`,{className:`chat-workspace`,hidden:j,"aria-label":R(Y?at?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,X.jsxs)(`header`,{className:`conversation-header`,title:Fn&&et?R(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`):void 0,children:[(0,X.jsxs)(`div`,{className:`conversation-heading`,children:[(0,X.jsx)(ra,{"aria-hidden":`true`}),(0,X.jsx)(`h2`,{children:Ct?.title??(a?R(`Discovered session`):q.summary===null?R(`New conversation`):R(`Conversation`))})]}),(0,X.jsxs)(`div`,{className:`conversation-branch`,children:[(0,X.jsxs)(`span`,{className:`conversation-meta`,children:[Y?R(at?`Cadence on`:`Ordinary`):tt.error?R(`Cadence state unavailable`):``,Ct&&` · ${Ct.origin===`terminal`?R(`Started in the terminal`):R(`Started in the WebUI`)}`]}),wt===`starting`&&(0,X.jsx)(`span`,{className:`ep-state starting`,children:z(wt)}),Ct?.archived&&(0,X.jsx)(`span`,{className:`conversation-badge`,children:R(`Archived`)}),L&&(q.branches>1||Or)&&(0,X.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-label":R(`Branches ({count})`,{count:q.branches}),title:R(`Branches ({count})`,{count:q.branches}),onClick:L,children:[(0,X.jsx)(ha,{"aria-hidden":`true`}),q.branches]}),Or&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>dr(null),children:R(`Show the latest`)}),at&&!Tt&&!Et&&!!J?.proposal&&(0,X.jsx)(`span`,{className:`ep-state`,children:R(`Awaiting plan approval`)})]})]}),(0,X.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,X.jsxs)(`div`,{className:`chat-messages`,ref:ln,onScroll:()=>{let e=ln.current;e&&!j&&(un.current=e.scrollTop,(!dn.current||un.current!==mn.current)&&(dn.current=kf(e)),mn.current=null,pn(!dn.current),Cn(),Tn())},children:[a&&!q.summary&&(0,X.jsx)(`p`,{role:`status`,className:`panel-hint`,children:R(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!y&&!et&&(0,X.jsx)(`p`,{role:`status`,className:`panel-hint`,children:R(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),y&&q.count===0&&!$e.length&&q.summary===null&&!q.attempt&&q.pending.length===0&&q.undelivered.length===0&&!q.error&&!a&&(0,X.jsx)(Xd,{visible:!j,hint:R(xt??`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),y&&!q.error&&(!et||$e.length===0&&q.count>0)&&(0,X.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:R(`Reading this conversation…`)}),$e.length>0&&xn&&(0,X.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:q.loadingEarlier&&R(`Reading earlier messages…`)}),Vn.start.map(Un),yn.map(({id:e,version:t,turn:n},r)=>{let i=Wt.get(e);return(0,X.jsxs)(h.Fragment,{children:[e===Ar&&(0,X.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,X.jsx)(ha,{"aria-hidden":`true`}),R(`From here on, the turns stay on their branch: the message being written will not have them in its context.`)]}),(0,X.jsx)(kc,{id:e,show:!bn.hidden.has(e)||e===Jt?.id,height:bn.placeholder(e,t,320),containerRef:ln,onMeasured:bn.recordMeasured,lazyRef:bn.register(e),children:(0,X.jsx)(Id,{turn:n,onContinue:fr&&n.header.entry&&n.ordinal<q.count-1?vr:void 0,onEdit:fr&&al(n,yn[r-1]?.turn)!==void 0?yr:void 0,version:i?i.findIndex(t=>t.id===e)+1:0,versions:i?.length??0,onVersion:br,off:sl(kr,n.ordinal)})}),Vn.after.get(e)?.map(Un)]},n.renderId??n.header.id)}),Vn.end.map(Un),q.attempt&&(0,X.jsxs)(`article`,{className:`chat-attempt`,"aria-label":R(`Message`),children:[(0,X.jsx)(`p`,{className:`chat-attempt-text`,children:q.attempt.text}),(0,X.jsxs)(`p`,{className:`inspector-note`,children:[(0,X.jsx)(`span`,{className:`ep-state ${q.attempt.status}`,children:z(q.attempt.status)}),` `,q.attempt.notice?z(q.attempt.notice):``]})]}),(0,X.jsx)(rf,{pending:q.pending,undelivered:q.undelivered,canWithdraw:ar()&&!de,recallable:e=>$n.current.has(e.commandId)||fl(e.text),onWithdraw:(e,t)=>void cr(e,t),onRestore:lr}),ct&&(0,X.jsx)(`p`,{role:`status`,children:R(`Observing approval request {id}; no approval is replayed.`,{id:ct})}),J?.enabled&&J.design&&(0,X.jsx)(Zd,{draft:J.design,active:!j,error:pe?nr(R,pe):void 0,disabled:!!Or||!!oe||se||de||!!Tt||!l||!St||!Y||!!ct,onEdit:Kn,onSubmit:e=>void qn(en(e,16384),void 0,!0)},J.design.id),J?.enabled&&J.proposal&&(0,X.jsx)(hf,{proposal:J.proposal,canApprove:!tn&&l&&St&&Y&&nn&&!Tt&&!ct&&!an&&rn===`approve`,action:rn,canValidate:on,validating:ft,previous:gt?.after.proposal?.id===J.proposal.id?gt.before:void 0,approvalHint:sn,onValidate:()=>void Wn(),onApprove:()=>void Gn()}),Y&&J?.enabled&&!J.proposal&&On.length===0&&(0,X.jsx)(`p`,{className:`inspector-note`,children:R(`Cadence stays on for this conversation until you explicitly exit.`)}),J?.notice&&(0,X.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:z(J.notice)}),pe&&(0,X.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:nr(R,pe)}),_e&&(0,X.jsxs)(`p`,{className:`inspector-note`,children:[R(`Send outcome not yet observed:`),` `,(0,X.jsx)(`code`,{children:_e}),` `,(0,X.jsx)(`button`,{type:`button`,onClick:q.refresh,children:R(`Observe current state`)})]})]}),fn&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{dn.current=!0,gn(!0),pn(!1)},children:[(0,X.jsx)(Ba,{"aria-hidden":`true`}),R(`Latest messages`)]}),Kt&&(0,X.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:R(`Reading earlier messages…`)}),Gt.length>1&&(0,X.jsx)($d,{questions:Gt,active:jr,reading:Kt?.id??null,onJump:xr})]}),(0,X.jsx)(`div`,{className:`composer-dock`,children:(0,X.jsx)(Qu,{flow:Zn,inputRef:cn,draft:V,onDraft:ee,locked:de||!!_e||Se,images:te.files,imageKey:te.key,imagesLocked:Sr,onAddImages:Cr,onRemoveImage:e=>ne([e]),anchor:Mr,status:Pe?R(`Preparing execution for this Send…`):Qn&&V.trim()&&er?R(er===`images`?`A message into a running reply carries no images. Remove them, or send after the reply ends.`:er===`mode`?`Cadence mode is not changed by a message into a running reply. Send this after the reply ends.`:er===`full`?`Eight messages already wait for this reply. Withdraw one, or wait.`:`A message into a running reply continues that reply, not another entry.`):Tt||Qt||St?void 0:R(_e?`The last Send is not yet confirmed. No message is resent.`:Se?`Choose a model; your message is sent right after.`:de?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`),cadence:{...bt,disabled:at?!$t:!!Tt||de||!!_e||Se,onClick:()=>{at?qn(`exit cadence`):yt.mode===`cadence`?(W(`chat`),rs(V,`chat`).mode===`cadence`&&ee(yt.text)):W(`cadence`)}},model:{client:We,availability:Ge,read:{...qe,isCurrent:()=>qe.isCurrent()&&(Ge.status!==`ready`||!u||u.current())},lastModel:Be?.model,draftModel:Ie,onPreviewChoice:C?e=>Xe(e,!1):void 0,locked:!!Tt||de||!!_e||Ge.status===`ready`&&!l,open:K,onOpenChange:Ye,onChanged:()=>{ze.refresh(),D()},onChosen:e=>Xe(e,!0),awaitingSend:Se},hint:Y&&Qn&&or&&!er&&V.trim()?R(`Enter steers this reply · Alt+Enter queues behind it`):xt?R(xt):``,running:!!Tt,canStop:!de&&ir(),onStop:()=>void ur(),canSend:((at&&tu(V)?$t:St)||Qt)&&!se&&(!!V.trim()||te.files.length>0),onSend:()=>void qn(),input:Qn?{enabled:or&&!er&&!!V.trim(),onInput:e=>void sr(e)}:void 0,historyScope:n,files:{client:e,location:y&&Ve&&Be?{id:t,cwd:Be.cwd}:void 0},onResized:gn})})]})}function Pf(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Ff(e){let t=[],n=0,r=0,i=``;for(;;){let a=await e(n);if(a.kind!==`file-part`)throw Error(`invalid`);if(n===0)({size:r,version:i}=a);else if(a.size!==r||a.version!==i)throw Error(`stale`);let o=Pf(a.data),s=n+o.length;if(a.next===null?s!==r:a.next!==s||o.length!==196608)throw Error(`invalid`);if(t.push(o),a.next===null)break;n=a.next}return new Blob(t,{type:`application/octet-stream`})}var If=/[<>:"/\\|?*\u0000-\u001f]/g,Lf=/[. ]+$/,Rf=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function zf(e){let t=e.replace(If,`_`).replace(Lf,``);return t?Rf.test(t)?`_${t}`:t:`_`}function Bf(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function Vf(e,t){let n=/windows/i.test(navigator.userAgent)?zf(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return Bf(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(Bf(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Hf(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
42
42
|
`)?``:`
|
|
43
|
-
`}${r}`}var
|
|
44
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function
|
|
45
|
-
`);return(0,h.useLayoutEffect)(()=>{if(t!==`markdown`)return;if(!e){l([]);return}let n=Array.from(p.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=
|
|
46
|
-
`):e})]}),(0,Y.jsx)(`p`,{className:`fp-notice`,children:r(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,Y.jsx)(`div`,{style:{fontSize:`${o}em`},children:t===`markdown`?(0,Y.jsxs)(`div`,{className:`fp-toc-layout`,children:[Jf(c)&&(0,Y.jsx)(`nav`,{className:`fp-toc`,"aria-label":r(`Page headings`),children:c.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,Y.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,"data-retained-field":!0,children:(0,Y.jsx)(Gs,{text:e})})]}):t===`diff`?(0,Y.jsx)(Xf,{text:e}):(0,Y.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Yf(e).map(({text:e,number:t,key:n})=>(0,Y.jsxs)(`div`,{className:`fp-line ${u&&t>=u.start&&t<=u.end?`sel`:``}`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":r(`Select page line {line}`,{line:t}),onClick:e=>{e.shiftKey||(f.current=t),d({start:Math.min(f.current,t),end:Math.max(f.current,t)})},children:t}),(0,Y.jsx)(`span`,{className:`fp-code-text`,"data-retained-field":e?!0:void 0,children:e||` `})]},n))})}),u&&(0,Y.jsxs)(`footer`,{className:`fp-foot`,children:[r(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:r(`Clear selection`)})]})]})}function Qf({client:e,seed:t}){let{t:n,tx:r}=X(),i=gs(e,t),[a,o]=(0,h.useState)(),[s,c]=(0,h.useState)(`raw`),l=i.page;return(0,Y.jsxs)(`section`,{className:`scm-body`,children:[(0,Y.jsx)(ic,{pager:i}),(0,Y.jsx)(`p`,{children:n(`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`)}),(0,Y.jsx)(`div`,{className:`scm-files-list`,children:l&&!(`kind`in l)&&l.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,i=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,Y.jsxs)(`article`,{className:`scm-file`,children:[(0,Y.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,Y.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{l.request.scope.kind!==`workspace`&&l.request.snapshotSeq!==null&&(c(`raw`),o(ms(l.request.storeId,l.request.scope,l.request.snapshotSeq,i)))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,Y.jsx)(rc,{client:e,cursor:a,preview:{view:s,render:e=>(0,Y.jsx)(Zf,{text:e,view:s,setView:c})}},`${a.recordId}:${a.recordVersion}`)]})}var $f=[`contents`,`checks`,`changes`,`reviews`];function ep({client:e,seed:t}){let{t:n,tx:r}=X(),[i,a]=(0,h.useState)(`contents`);return(0,Y.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,Y.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,Y.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:$f.map(e=>(0,Y.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,Y.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,Y.jsx)(ac,{client:e,seed:t}):(0,Y.jsx)(Qf,{client:e,seed:{...t,reader:i}},i)})]})}var tp={relative:`Enter a full path, for example ~/project.`,invalid:`This folder does not exist. Check the path.`,forbidden:`This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).`,unavailable:`This folder could not be read right now; it may lack read permission. Try again.`},np=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function rp(e,t){let n=e.startsWith(`/`)?`/`:`\\`,r=(e,t)=>e.endsWith(n)?e+t:e+n+t,i=!!t&&(e===t||e.startsWith(r(t,``))),a=i?t:/^(?:\\\\[^\\]+\\[^\\]+|[A-Za-z]:\\|\/)/.exec(e)?.[0]??``;if(!a)return{inside:i,trail:[{name:e,path:e}]};let o=i?[]:[{name:a===`/`?`/`:a.replace(/\\$/,``),path:a}],s=a;for(let t of e.slice(a.length).split(/[\\/]/).filter(Boolean))s=r(s,t),o.push({name:t,path:s});return{inside:i,trail:o}}function ip({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=X(),[u,d]=(0,h.useState)(),[f,p]=(0,h.useState)(n??t),[m,g]=(0,h.useState)(!1),[_,v]=(0,h.useState)(``),[y,b]=(0,h.useState)(!0),[x,S]=(0,h.useState)(!0),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)(null),D=(0,h.useRef)(!0),O=(0,h.useRef)(void 0),k=(0,h.useRef)(n??t),A=(0,h.useRef)(null),j=(0,h.useRef)(null),M=async t=>{O.current?.abort();let n=new AbortController;O.current=n,b(!0),E(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&D.current){if(O.current=void 0,b(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),p(r.value.path),g(!1),v(``),r.value;E({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,h.useRef)(M);(0,h.useEffect)(()=>(D.current=!0,N.current(k.current).then(()=>{D.current&&S(!1)}),()=>{D.current=!1,O.current?.abort()}),[]),(0,h.useEffect)(()=>{m&&A.current?.select()},[m]),(0,h.useEffect)(()=>{j.current&&(j.current.scrollLeft=j.current.scrollWidth)});let P=e=>{C||M(e)},F=()=>{let e=f.trim();C||(np(e)?M(e):E({step:`read`,code:`relative`}))},I=(m||!u)&&f.trim()||u?.path||``,L=!C&&!y&&!!I,R=async n=>{if(C||!n||y&&n===u?.path)return;if(n!==u?.path&&!np(n)){E({step:`read`,code:`relative`});return}w(!0),E(null);let r=n===u?.path?u.path:(await M(n))?.path;if(!D.current)return;if(!r){w(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),D.current&&a()}catch(e){D.current&&(E({step:`open`,code:e instanceof Error?e.message:`unavailable`}),w(!1))}return}if(!e.workbenchCommand){E({step:`open`,code:`unavailable`}),w(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(D.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(E({step:`open`,code:`unsupported-context`}),w(!1))}else E({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),w(!1)}},z=u?rp(u.path,r):void 0,ee=_.trim().toLowerCase(),te=u?.entries.filter(e=>e.name.toLowerCase().includes(ee))??[],B=T&&(T.step===`read`&&tp[T.code]?l(tp[T.code]):tr(l,T.code));return(0,Y.jsxs)(lc,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,Y.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,Y.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,Y.jsx)(`h3`,{children:l(`Recent folders`)}),(0,Y.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,Y.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:C,onClick:()=>e.current?a():void R(e.path),children:[(0,Y.jsx)(ha,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,Y.jsxs)(`div`,{className:`cwd-location`,children:[z&&!m?(0,Y.jsxs)(`nav`,{ref:j,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:C,onClick:()=>P(`~`),children:[(0,Y.jsx)(da,{"aria-hidden":`true`}),z.inside&&(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),z.trail.map((e,t)=>(0,Y.jsxs)(h.Fragment,{children:[(t>0||z.inside)&&(0,Y.jsx)(ja,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,Y.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:C,onClick:()=>P(e.path),children:e.name})]},e.path))]}):x?(0,Y.jsx)(`div`,{className:`cwd-crumbs`}):(0,Y.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),F()},children:(0,Y.jsx)(`input`,{ref:A,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:f,disabled:C,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{p(e.target.value),T?.step===`read`&&E(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),g(!1),p(u.path),E(null))}})}),u&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":m,disabled:C,onClick:()=>{p(u.path),g(!m),E(null)},children:(0,Y.jsx)(ba,{"aria-hidden":`true`})})]}),u&&(0,Y.jsxs)(`label`,{className:`cwd-filter`,children:[(0,Y.jsx)(qi,{"aria-hidden":`true`}),(0,Y.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:_,disabled:C,spellCheck:!1,autoComplete:`off`,onChange:e=>v(e.target.value)})]}),(0,Y.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":y||void 0,children:[y&&(0,Y.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,Y.jsxs)(`button`,{type:`button`,disabled:C,onClick:()=>P(u.parent),children:[(0,Y.jsx)(Ia,{}),l(`Parent folder`)]}),te.map(e=>(0,Y.jsxs)(`button`,{type:`button`,disabled:C,onClick:()=>P(e.path),children:[(0,Y.jsx)(ha,{}),(0,Y.jsx)(`span`,{children:e.name})]},e.path)),u&&!y&&te.length===0&&(0,Y.jsx)(`p`,{className:`cwd-picker-note`,children:l(ee?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,Y.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),B&&(0,Y.jsxs)(`p`,{role:`alert`,children:[B,T?.code===`registry-locked`&&(0,Y.jsxs)(Y.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,Y.jsxs)(`footer`,{className:`cwd-footer`,children:[I&&(0,Y.jsxs)(`p`,{className:`cwd-target`,children:[(0,Y.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,Y.jsx)(`code`,{children:I})]}),(0,Y.jsx)(`button`,{type:`button`,className:`primary`,disabled:!L,"aria-busy":C||void 0,onClick:()=>void R(I),children:l(C?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function ap(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var op=[`today`,`yesterday`,`earlier`];function sp(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function cp(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=sp(t(i),n);r.set(e,[...r.get(e)??[],i])}return op.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function lp(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function up(e,t,n=Date.now()){let r=new Date(e);return sp(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function dp({onConversation:e,disabled:t=!1}){let{t:n}=X();return(0,Y.jsx)(`div`,{className:`lp-new`,children:(0,Y.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,Y.jsx)(Xi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function fp(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var pp=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),mp=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function hp(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var gp={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},_p={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},vp={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},yp=e=>`conversation-row:${e}`;function bp(e,t){return t.kind===`refused`?{refusal:{text:_p[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function xp(e,t){let{t:n}=X(),[r,i]=(0,h.useState)(()=>new Map),a=(0,h.useRef)(!0);(0,h.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Is(yp(c)),l({pending:o}),hp(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=bp(o,e);l(r),i&&Ps(`error`,n(i.text,{code:i.code}),yp(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,pp(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,mp(e,t))}}function Sp({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=X(),d=u===`zh`?`zh-CN`:`en-GB`,[f,p]=(0,h.useState)(null),m=f!==null,g=(0,h.useRef)(null),_=(0,h.useRef)(null),v=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=g.current;if(!m||!e){v.current&&_.current?.focus({preventScroll:!0}),v.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),v.current=!0,p(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[m]);let y=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),b=(0,Y.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":y,title:y,children:e.origin===`terminal`?(0,Y.jsx)(Vi,{"aria-hidden":`true`}):(0,Y.jsx)(na,{"aria-hidden":`true`})}),x=()=>{if(f===null)return;let t=fp(f);t===null?Ps(`error`,l(`A name can have at most {count} characters.`,{count:100}),yp(e.id)):(v.current=!0,p(null),t!==e.title&&s?.(t))},S=!!o||!!a?.pending,C=a?.pending?l(gp[a.pending]):a?.unknown?l(vp[a.unknown.action],{code:a.unknown.code}):``;return m?(0,Y.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),x()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},children:[(0,Y.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[b,(0,Y.jsx)(`input`,{ref:g,className:`session-rename-input`,value:f,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>p(e.target.value)})]}),(0,Y.jsxs)(`span`,{className:`session-actions`,children:[(0,Y.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,Y.jsx)(Pa,{"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{v.current=!0,p(null)},children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]})]}):(0,Y.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[b,(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,Y.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,Y.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:up(e.updatedAt,d)})]}),c&&(0,Y.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,Y.jsx)(`button`,{ref:_,type:`button`,className:`session-action`,disabled:S,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>p(e.title),children:(0,Y.jsx)(ba,{"aria-hidden":`true`})}),(0,Y.jsx)(`button`,{type:`button`,className:`session-action`,disabled:S,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,Y.jsx)(Ji,{"aria-hidden":`true`}):(0,Y.jsx)(Ba,{"aria-hidden":`true`})})]}),C&&(0,Y.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:C})]})}function Cp({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=X(),a=e.value?.entries??[];return(0,Y.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,Y.jsx)(Ra,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,Y.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,Y.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,Y.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,tr(i,e.error)]}),e.loading&&(0,Y.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,Y.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,Y.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,Y.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var wp={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function Tp({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,h.useState)(!0);return(0,Y.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,Y.jsxs)(`header`,{className:`lp-section-header`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,Y.jsx)(Na,{"aria-hidden":`true`}):(0,Y.jsx)(ja,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,Y.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,Y.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,Y.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function Ep({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=X(),[o,s]=(0,h.useState)(new Set),c=ap(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,Y.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,Y.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,Y.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,Y.jsx)(ja,{"aria-hidden":`true`}):(0,Y.jsx)(Na,{"aria-hidden":`true`})}):(0,Y.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,Y.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,Y.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,Y.jsx)(Ca,{"aria-hidden":`true`}):(0,Y.jsx)(na,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,Y.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,Y.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,Y.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Dp({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=X(),a=e.page;return(0,Y.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Ep,{runs:a.records.flatMap(e=>e.kind===`run`&&!r.includes(e.projection.runId)?[e.projection]:[]),scope:t,snapshot:a.request.snapshotSeq??void 0,onScope:n}),a.records.length===0&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,Y.jsx)(ic,{pager:e,compact:!0})]})}function Op({client:e,workspace:t,retained:n,executionStopped:r=!1,taskId:i,scope:a,runs:o,snapshot:s,activeRuns:c,canCancel:l,canceling:u,onCancel:d,onTask:f,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,actionCurrent:C=()=>!S,onConversationsChanged:w,workflows:T,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:A,canCancelWorkflow:j,onCancelWorkflow:M}){let{t:N,tx:P}=X(),[F,I]=(0,h.useState)(``),[L,R]=(0,h.useState)(!1),z=ns(e,L,!0),ee=z.refresh,te=xp(e,e=>{ee(),w?.(e)}),B=n?.workspace??t,ne=n?.client??e,re=B?{reader:`tasks`,storeId:B.storeId,scope:{kind:`workspace`,id:B.workspaceId},snapshotSeq:n?.workspace.committedSeq??null,after:null,limit:50}:null,ie=gs(ne,re),ae=gs(ne,i&&re&&B?{...re,reader:`runs`,scope:{kind:`task`,id:i},snapshotSeq:s??B.committedSeq}:null),oe=ie.page&&!(`kind`in ie.page)?ie.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],se=c?.status===`complete`?c.runs:[],ce=oe.filter(e=>!se.some(t=>t.taskId===e.owner.taskId)),le=i&&(0,Y.jsxs)(`section`,{className:`task-conversations`,"aria-label":N(`Task conversations`),children:[(0,Y.jsx)(`h3`,{children:N(`Task conversations`)}),(0,Y.jsx)(Dp,{pager:ae,scope:a,onScope:p,exclude:se.map(e=>e.runId)},i)]}),[ue,de]=(0,h.useState)(()=>new Set),fe=e=>{let t=E.find(t=>t.runId===e.id)?.conversationId??null;return(0,Y.jsxs)(`div`,{className:`conversation-group`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>A?.(e,t),title:e.goal,children:[(0,Y.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,Y.jsxs)(`span`,{className:`session-sub`,children:[N(`Cadence workflow`),` · `,P(e.phase),` · `,P(e.status)]})]})]}),M&&(0,Y.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:ue.has(e.id)||!j?.(e),onClick:()=>{!ue.has(e.id)&&j?.(e)&&(de(t=>new Set(t).add(e.id)),M(e).finally(()=>de(t=>{let n=new Set(t);return n.delete(e.id),n})))},children:[(0,Y.jsx)(Ui,{"aria-hidden":`true`}),N(`Cancel workflow — request stop`)]})]},e.id)},V=m.filter(e=>Tl(e.status)),pe=m.filter(e=>!V.includes(e)),me=e=>T?.findLast(t=>E.some(n=>n.runId===t.id&&n.conversationId===e.id)),H=e=>{let t=Tl(e.status),n=t&&e.status!==`starting`,r=n||e.status===`completed`?me(e):void 0,i=r?P(af(r)):e.cadence&&n?N(`Discussing`):e.status===`completed`?``:P(e.status);return(0,Y.jsx)(Sp,{chat:e,selected:e.id===y,state:i,tone:r?`running`:e.status,onOpen:()=>b?.(e.id),row:te.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>{C()&&te.archive(e.id,t)},onRename:t||e.archived?void 0:t=>{C()&&te.rename(e.id,t)}},e.id)},he=pe.filter(e=>lp(e.title,F)),ge=ce.filter(e=>lp(e.goal,F));return(0,Y.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,Y.jsx)(Pc,{...O,represented:!r&&O.project?[...(T??[]).map(e=>Nc(O.project,`workflow`,e.id,e.epoch)),...V.flatMap(e=>e.live?[Nc(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,Y.jsx)(dp,{onConversation:x}),!r&&(0,Y.jsxs)(Tp,{title:N(`Running work`),count:c?.status===`complete`&&T&&!D&&g?String(se.length+V.length+T.length):N(`Not observed`),className:`running-conversations`,children:[c?.status!==`complete`&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:N(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:N(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:N(`Conversation activity unavailable.`)}),V.map(H),T?.map(fe),c?.status===`complete`&&se.length===0&&V.length===0&&T?.length===0&&!D&&g&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:N(`No active runs`)}),se.map(e=>{let t=oe.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,Y.jsxs)(`div`,{className:`conversation-group`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`session-item${i===e.taskId&&a?.kind===`task`?` active`:``}`,onClick:()=>f(e.taskId,t),title:e.runId,children:[(0,Y.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:t??N(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,Y.jsxs)(`span`,{className:`session-sub`,children:[P(e.kind),` · `,P(e.stage)]})]})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!l||u.has(e.runId),onClick:()=>d(e.runId),children:[(0,Y.jsx)(Ui,{"aria-hidden":`true`}),N(`Cancel run — request stop`)]}),i===e.taskId&&(0,Y.jsx)(Ep,{runs:o.filter(t=>t.runId===e.runId),scope:a,onScope:p})]},e.runId)})]}),(0,Y.jsxs)(Tp,{title:N(L?`Archived conversations`:`Conversation history`),count:L?z.value?`${z.value.entries.length}${z.value.next||z.canPrevious?`+`:``}`:N(`Not observed`):B?ie.page&&!(`kind`in ie.page)?`${pe.length+ce.length}${ie.page.next||ie.canPrevious||_?`+`:``}`:N(`Not observed`):`${pe.length}${_?`+`:``}`,className:`grow`,actions:(0,Y.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":L,title:N(L?`Back to history`:`Show archived`),"aria-label":N(L?`Back to history`:`Show archived`),onClick:()=>R(e=>!e),children:(0,Y.jsx)(Ba,{"aria-hidden":`true`})}),children:[L&&(0,Y.jsx)(Cp,{list:z,unavailable:S,onBack:()=>R(!1),row:H}),(0,Y.jsxs)(`nav`,{"aria-label":N(`Tasks`),className:`task-list`,hidden:L,children:[(pe.length>0||ce.length>0)&&(0,Y.jsxs)(`label`,{className:`lp-filter`,children:[(0,Y.jsx)(qi,{"aria-hidden":`true`}),(0,Y.jsx)(`input`,{type:`search`,value:F,placeholder:N(`Filter conversations…`),"aria-label":N(`Filter conversations…`),onChange:e=>I(e.target.value)}),F&&(0,Y.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:N(`Clear filter`),"aria-label":N(`Clear filter`),onClick:()=>I(``),children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]}),S&&pe.length>0&&(0,Y.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),cp(he,e=>e.updatedAt).map(e=>(0,Y.jsxs)(`div`,{className:`lp-time-group`,children:[(0,Y.jsx)(`h3`,{className:`lp-time-label`,children:N(wp[e.key])}),e.items.map(H)]},e.key)),ge.length>0&&(0,Y.jsx)(`h3`,{className:`lp-time-label`,children:N(`Tasks`)}),ge.map(e=>(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===i&&a?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===i&&a?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>f(e.owner.taskId,e.goal),children:[(0,Y.jsx)(`span`,{className:`session-icon`,children:(0,Y.jsx)(na,{"aria-hidden":`true`})}),(0,Y.jsxs)(`span`,{className:`session-info`,children:[(0,Y.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,Y.jsx)(`span`,{className:`session-sub`,children:N(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===i&&le]},e.owner.taskId)),he.length===0&&ge.length===0&&(pe.length>0||ce.length>0)&&(0,Y.jsx)(`p`,{className:`panel-hint`,role:`status`,children:N(`No listed conversation matches. Pages not loaded are not searched.`)}),ie.page&&!(`kind`in ie.page)&&ce.length===0&&pe.length===0&&!_&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:N(`No conversations yet.`)}),v,B&&(0,Y.jsx)(ic,{pager:ie,compact:!0})]}),!L&&!ge.some(e=>e.owner.taskId===i)&&le]})]})}var kp=[`queued`,`running`];function Ap(e){let t=(0,h.useRef)({client:e.client,generation:0});return t.current.client!==e.client&&(t.current={client:e.client,generation:t.current.generation+1}),(0,Y.jsx)(jp,{...e},`${t.current.generation}:${e.agent.runId}:${e.agent.stepId??``}`)}function jp({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i,canCancelWorkflow:a}){let{t:o,tx:s}=X(),[c,l]=(0,h.useState)(1e3),u=es(e,{kind:`workflow`,id:t.runId},c),d=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,f=t.stepId?d?.steps.find(e=>e.id===t.stepId):void 0,p=f?kp.includes(f.status):!1;(0,h.useEffect)(()=>{d&&!kp.includes(d.status)&&l(0)},[d]);let m=es(e,t.stepId&&(!d||f?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!d?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,h.useMemo)(()=>g?od(g):null,[g]),[v,y]=(0,h.useState)(!1),b=es(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null,v&&p?1e3:0),x=(0,h.useRef)(null),S=(0,h.useRef)(!0),C=(0,h.useRef)(null),[w,T]=(0,h.useState)(!1),E=(0,h.useRef)(0);return Ec(x,C,S),(0,Y.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":o(`Subagent context`),children:[(0,Y.jsxs)(`header`,{className:`conversation-header`,children:[(0,Y.jsxs)(`div`,{className:`conversation-heading`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,Y.jsx)(Ca,{"aria-hidden":`true`}),(0,Y.jsx)(`h2`,{title:t.stepId??t.runId,children:f?`${s(f.kind)} · ${t.label}`:t.label}),(0,Y.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?o(`Subagent`):o(`Workflow`)})]}),(f??d)&&(0,Y.jsx)(`span`,{className:`ep-state ${(f??d)?.status}`,children:s((f??d)?.status??``)})]}),(0,Y.jsx)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current&&t.scrollTop<E.current&&t.scrollHeight-t.scrollTop-t.clientHeight>=80&&(S.current=!1,T(!0)),E.current=t.scrollTop},children:(0,Y.jsxs)(`div`,{ref:C,children:[u.error&&(0,Y.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[u.error,` ·`,` `,o(`State unavailable is not completion. No automatic resubmission.`)]}),d&&t.stepId&&(0,Y.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[o(`Workflow`),`: `,d.goal,` · `,s(d.phase),` · `,s(d.status)]}),!t.stepId&&(0,Y.jsx)(mf,{client:e,id:t.runId,canCancelWorkflow:a,onOpenAgent:i}),t.stepId&&m.error&&(0,Y.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,Y.jsx)(Md,{turn:_}):(0,Y.jsx)(`p`,{className:`inspector-note`,children:o(`No retained transcript observed yet; absence is not proof of no activity.`)})),f&&(0,Y.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":o(`Step result`),children:[(0,Y.jsx)(`h3`,{children:o(`Step result`)}),f.exitCode!==null&&(0,Y.jsxs)(`p`,{children:[o(`Exit code`),`: `,f.exitCode]}),f.text?(0,Y.jsx)(Gs,{text:f.text}):(0,Y.jsx)(`p`,{className:`inspector-note`,children:o(`No result yet.`)}),f.truncated&&(0,Y.jsx)(`p`,{children:o(`Preview is truncated.`)}),(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,"aria-expanded":v,onClick:()=>y(e=>!e),children:o(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,Y.jsx)(ef,{file:b.value}),v&&b.error&&(0,Y.jsx)(`p`,{role:`alert`,children:b.error})]})]})}),w&&(0,Y.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{S.current=!0,Tc(x.current,!0),E.current=x.current?.scrollTop??0,T(!1)},children:[(0,Y.jsx)(za,{"aria-hidden":`true`}),o(`Latest messages`)]})]})}function Mp({path:e,disabled:t=!1,onClick:n}){let{t:r}=X(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,Y.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,Y.jsx)(ha,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Np({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,Y.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,Y.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,Y.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,Y.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function Pp({dot:e,tip:t,latency:n,children:r}){let{t:i}=X(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,Y.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,Y.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,Y.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function Fp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function Ip({clock:e}){let{t}=X();return e===`unavailable`?(0,Y.jsx)(Np,{tone:`faint`,role:`status`,children:t(`Conversation activity unavailable.`)}):e===`idle`?null:(0,Y.jsx)(Lp,{since:e,label:t(`Working`)})}function Lp({since:e,label:t}){let[n,r]=(0,h.useState)(Date.now);(0,h.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?Fp(n-e):``;return(0,Y.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,Y.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,Y.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}var Rp={folder:`Choose a working folder`,connecting:`Connection`,updating:`Connection`,chat:`Chat ready`,task:`Task up to date`,stopped:`Execution stopped`,"not-started":`Execution not started`,independent:`Browsing only`};function zp(e){return Jo(e)||e===`Access revoked; explicit token re-entry required.`}function Bp({phase:e,entryError:t,projectStatus:n,projectError:r,viewerError:i,historyError:a,readErrors:o=[],prepareOnly:s,retained:c,latency:l,onRefresh:u}){let{t:d,tx:f}=X(),p=e=>{let t=e===`socket-timeout`?d(`No recent update from the task connection`):e===`socket-closed`?d(`The task connection closed`):f(e);return t!==e&&/^[a-z][a-z-]*$/.test(e)?`${t} (${e})`:t},m=e===`updating`||e===`connecting`,g=(0,h.useRef)(void 0);t||r||i||a?g.current={entryError:t,projectError:r,viewerError:i,historyError:a}:m||(g.current=void 0);let _=g.current,v=zp(_?.entryError)||zp(_?.projectError)||zp(_?.viewerError),y=!!_||o.some(([,e])=>e),b=d(v?`Sign-in required`:y?`Connection`:Rp[e]),x=v?`error`:m||y?``:e===`task`||e===`chat`?`ok`:``;return(0,Y.jsxs)(`details`,{className:`workspace-connection`,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,Y.jsxs)(`summary`,{"aria-label":d(`Connection status: {state}`,{state:b}),children:[(0,Y.jsx)(Pp,{dot:x,tip:d(`Connection freshness is not execution outcome.`),latency:m||y?null:l,children:b}),(0,Y.jsx)(Aa,{"aria-hidden":`true`})]}),(0,Y.jsxs)(`div`,{className:`connection-details`,children:[(0,Y.jsx)(`strong`,{children:d(`Observation status`)}),n&&(0,Y.jsx)(`p`,{children:d(`Execution service: {status}`,{status:f(n)})}),e===`independent`&&(0,Y.jsx)(`p`,{children:d(`This owner is running independently. Browsing history does not connect it to this workbench.`)}),(e===`stopped`||e===`not-started`)&&(0,Y.jsx)(`p`,{children:d(`Ready to prepare execution`)}),y&&c&&(0,Y.jsx)(`p`,{children:d(`Last known state`)}),_?.entryError&&(0,Y.jsx)(`p`,{children:d(`Workbench observation: {code}.`,{code:p(_.entryError)})}),_?.projectError&&(0,Y.jsx)(`p`,{children:d(`Project observation: {code}.`,{code:p(_.projectError)})}),_?.historyError&&(0,Y.jsx)(`p`,{children:d(`Recorded history unavailable: {reason}.`,{reason:p(_.historyError)})}),s&&(0,Y.jsx)(`p`,{children:d(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),o.map(([e,t])=>t&&(0,Y.jsx)(`p`,{children:d(e,{code:p(t)})},e)),_?.viewerError&&(0,Y.jsx)(`p`,{children:d(`Viewer observation: {code}.`,{code:p(_.viewerError)})}),(_?.viewerError===`stale`||_?.projectError===`stale`)&&(0,Y.jsx)(`p`,{children:d(`Context changed. Read the current state before confirming a plan.`)}),m&&!_&&(0,Y.jsx)(`p`,{children:d(`Waiting for current state from this connection.`)}),v?(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{Wn(),window.location.reload()},children:d(`Sign in again`)}):(0,Y.jsx)(`button`,{type:`button`,onClick:u,children:d(`Observe current state`)})]})]})}function Vp(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Bn();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:L(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,z(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Hp(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=L(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(ne(r)):void 0,o=i?z(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(ne(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Up=.4,Wp=1.05;function Gp(e,t=`left`){return t===`left`?Math.min(300,e*.86):Math.min(380,e*.92)}function Kp(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function qp(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Jp(e,t){return e===`left`?t:-t}function Yp(e,t){return Math.max(-e,Math.min(0,-e+t))}function Xp(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Zp(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Xp(r*Wp,n,t)>=Up}var Qp=`cadence-panel-layout-v1`,$p={left:260,right:360,navigation:!0,inspector:!1};function em(e,t=600){return Math.max(220,Math.min(t,e))}function tm(e){let t={...$p};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=em(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function nm(e,t){let n=e<=900,r=n?Gp(e,`left`):em(t.left,e-560),i=n?Gp(e,`right`):em(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:em(e-560-s),rightMaximum:em(e-560-a)}}function rm({side:e,width:t,onResize:n,maximum:r}){let{t:i}=X(),a=(0,h.useRef)(void 0);return(0,h.useEffect)(()=>()=>a.current?.(),[]),(0,Y.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(em(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(em(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(em(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var im=[],am={error:Ha,warning:Va,info:la};function om({toast:e}){let{t}=X(),[n,r]=(0,h.useState)(!1),[i,a]=(0,h.useState)(!1),o=n||i,s=Ds(e.level);(0,h.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Fs(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=am[e.level];return(0,Y.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,Y.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,Y.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,Y.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Fs(e.id),children:(0,Y.jsx)(Ri,{"aria-hidden":`true`})})]})}function sm(){let e=(0,h.useSyncExternalStore)(Ls,Rs,()=>im);return(0,Y.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,Y.jsx)(om,{toast:e},e.id))})}function cm(e,t,n,r){(0,h.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var lm=new Set([`auto`,`scroll`,`overlay`]);function um(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&lm.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function dm(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function fm(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,h.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=Kp(r.clientX,window.innerWidth,n);i&&!um(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=qp(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Gp(window.innerWidth,r),h=m*Wp;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=Jp(r,d);let b=Yp(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Xp(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Zp({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(dm(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var pm={system:[$i,`System`],light:[Hi,`Light`],dark:[Qi,`Dark`]};function mm({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:f,content:p}){let{t:m,locale:g,setLocale:_}=X(),[v,y]=(0,h.useState)(Hd),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(fr),[w,T]=pm[S],E=m(`Theme: {current}. Switch to {next}.`,{current:m(T),next:m(pm[mr(S)][1])}),{mobile:D,overlay:O,closeDrawer:k}=e,A=(0,h.useRef)(null),j=(0,h.useRef)(null),M=()=>{j.current&&(j.current.open=!1)};return fm({enabled:D,open:O,onOpenChange:e.setDrawer,container:A}),cm(A,O,!!O,k),(0,Y.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,Y.jsx)(Wd,{enabled:v,hero:b}),(0,Y.jsxs)(`header`,{className:`topbar`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":m(`Toggle conversation navigation`),"aria-expanded":D?O===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,Y.jsx)(ra,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`topbar-flow`,children:[(0,Y.jsxs)(`span`,{className:`brand`,children:[(0,Y.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:(0,Y.jsx)(Gd,{})}),(0,Y.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,Y.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,Y.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,Y.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,Y.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>_(g===`zh`?`en`:`zh`),children:[(0,Y.jsx)(pa,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,Y.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":E,"data-tip":E,onClick:()=>{let e=mr(S);pr(e),C(e)},children:(0,Y.jsx)(w,{"aria-hidden":`true`})}),(0,Y.jsxs)(`details`,{className:`more-menu`,ref:j,onKeyDown:e=>{e.key===`Escape`&&j.current&&(j.current.open=!1,j.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,Y.jsx)(`summary`,{className:`chip`,"aria-label":m(`More`),title:m(`More`),children:(0,Y.jsx)(Zi,{"aria-hidden":`true`})}),(0,Y.jsxs)(`div`,{className:`more-menu-items`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":v,onClick:()=>{Ud(!v),y(!v)},children:[(0,Y.jsx)(Hi,{"aria-hidden":`true`}),g===`zh`?`环境光`:`Ambient light`,(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:v?`●`:`○`})]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":m(`Observe current state`),onClick:()=>{M(),u()},children:[(0,Y.jsx)(Yi,{"aria-hidden":`true`}),m(`Refresh status`)]}),f&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":m(`Cadence service`),onClick:()=>{M(),f()},children:[(0,Y.jsx)(Ki,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`more-menu-text`,children:[m(`Cadence service`),(0,Y.jsx)(`small`,{children:m(`Version, restart and upgrade.`)})]})]}),d&&(0,Y.jsxs)(`button`,{type:`button`,"aria-label":m(`Disconnect this page`),title:m(`Return — accepted work continues`),onClick:()=>{M(),k(),d()},children:[(0,Y.jsx)(aa,{"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`more-menu-text`,children:[m(`Disconnect this page`),(0,Y.jsx)(`small`,{children:m(`Started work keeps running.`)})]})]}),(0,Y.jsx)(`div`,{className:`more-menu-build`,title:so?.buildId??m(`unbuilt source`),children:(0,Y.jsx)(nr,{text:m(`Local browser build: {build}.`),slots:{build:(0,Y.jsx)(`code`,{children:so?.buildId??m(`unbuilt source`)})}})})]})]})]})]}),(0,Y.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":m(`Toggle workspace panels`),"aria-expanded":D?O===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,Y.jsx)(Gi,{"aria-hidden":`true`}),(0,Y.jsx)(`span`,{children:r??m(`Files`)})]})]}),s,(0,Y.jsxs)(`div`,{ref:A,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,Y.jsx)(`button`,{type:`button`,"aria-label":m(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${O?` on`:``}`,onClick:k}),(0,Y.jsx)(`section`,{className:`panel-drawer drawer-left${O===`left`?` open`:``}`,"aria-label":m(`Conversation navigation`),tabIndex:-1,inert:D?O!==`left`:!e.navigation||O===`right`,children:t}),(0,Y.jsx)(rm,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,Y.jsx)(`main`,{className:`main`,inert:O!==null,children:(0,Y.jsx)(zd.Provider,{value:x,children:p})}),(0,Y.jsx)(rm,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,Y.jsx)(`section`,{className:`panel-drawer drawer-right${O===`right`?` open`:``}`,"aria-label":m(`Files and history drawer`),tabIndex:-1,inert:D?O!==`right`:!e.inspector,children:(0,Y.jsxs)(`div`,{className:`workbench-right`,children:[(0,Y.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":m(`Workspace panels`),children:[i??(0,Y.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,Y.jsx)(ha,{"aria-hidden":`true`}),m(`Files`)]}),(0,Y.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":m(`Collapse panel`),title:m(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,Y.jsx)(ja,{"aria-hidden":`true`})})]}),(0,Y.jsx)(`div`,{className:`workbench-right-body`,children:n})]})})]}),(0,Y.jsxs)(`footer`,{className:`statusbar`,children:[(0,Y.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,Y.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,Y.jsx)(sm,{})]})}function hm(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function gm({cache:e}){let{t}=X(),n=e?hm(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:rl(r.read),write:rl(r.write),miss:rl(r.miss),input:rl(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,Y.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,Y.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,Y.jsx)(Sa,{})}),(0,Y.jsxs)(`span`,{className:`bar-item-text`,children:[(0,Y.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,Y.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var _m=31.42;function vm({usage:e}){let{t}=X(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?il(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:rl(n),window:rl(r),percent:i}):t(`Context {used} tokens`,{used:rl(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,Y.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,Y.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,Y.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:_m,strokeDashoffset:+(_m*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,Y.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,Y.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,Y.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,Y.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`ctx-val`,children:rl(n)}),r&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,Y.jsx)(`span`,{className:`ctx-max`,children:rl(r)})]})]})})]})}function ym(){let[e,t]=(0,h.useState)(()=>{try{return tm(localStorage.getItem(Qp))}catch{return tm(null)}}),[n,r]=(0,h.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=nm(n,e),s=(0,h.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Qp,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,h.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}var bm=({epoch:e,runId:t,childRunId:n},r)=>JSON.stringify([e,t,n,r]);function xm(e,t,n,r,i=`en`){let a=(e,t)=>$n(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=new Map;for(let e of o){if(e.kind!==`capture-fact`)continue;let t=e.capture.event;if(t.kind!==`tool-start`&&t.kind!==`tool-end`||!t.name)continue;let n=bm(e.link,t.callId);s.has(n)?s.get(n)!==t.name&&s.set(n,null):s.set(n,t.name)}let c=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.capture.event:null,o=r?.kind===`tool-start`||r?.kind===`tool-end`?r.name:e.kind===`capture-fact`&&r?.kind===`tool-update`?s.get(bm(e.link,r.callId)):void 0,c=e.kind===`capture-fact`?e.link.childRunId:null,l=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,...o?{meta:{tool:o}}:{},lane:l,group:`${c??`owner`}:${l}`,groupLabel:`${c??a(`Owner`)} · ${$n(i,l)}`,kind:l===`tools`?`tool`:l===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:c??a(`owner`)}),status:a(`recorded fact`),clock:e.kind===`capture-fact`?a(`Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.`,{child:e.link.childRunId,first:e.capture.source.firstObservedMs,last:e.capture.source.lastObservedMs}):a(`Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.`,{epoch:e.link.epoch,ms:e.observedMs}),...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),l;return{lang:i,onData(e){return l=e,()=>{l=void 0}},readState(){l?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:c.length}],activeId:e})},readSegments(t){t===e&&l?.({kind:`segs`,convId:t,segs:c,reset:!0})},readSegment(t,n){let r=c.findIndex(e=>e.key===n);t!==e||r<0||l?.({kind:`seg_detail`,convId:t,key:n,seg:c[r],detail:JSON.stringify(o[r],null,2),analysis:{position:a(`Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.`,{seq:o[r].committedSeq,ordinal:r+1})}})},openDetail(t,r){let i=o.find(e=>e.recordId===r);t===e&&i&&n(i)},searchHistory:r}}var Sm=`modulepreload`,Cm=function(e){return`/ui/3764a5306a520843e6a002ac856e53096112fc0143de6464ec20cf428a331fcc/`+e},wm={},Tm=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Cm(t,n),t=s(t),t in wm)return;wm[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Sm,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function Em({client:e,seed:t,onSearch:n}){let{t:r}=X(),i=gs(e,{...t,reader:`events`}),a=i.page;return(0,Y.jsxs)(`section`,{className:`timeline-view`,children:[(0,Y.jsx)(`p`,{children:r(`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`)}),(0,Y.jsx)(ic,{pager:i}),a&&!(`kind`in a)&&(0,Y.jsx)(Dm,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Dm({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=X(),o=(0,h.useRef)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(!1),d=(0,h.useRef)(r);return d.current=r,(0,h.useEffect)(()=>{let e=!1,r;return Tm(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,xm(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,Y.jsxs)(Y.Fragment,{children:[l&&(0,Y.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,Y.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,Y.jsx)(ac,{client:e,seed:t})]})}var Om=[[`tools`,Bi],[`context`,ca],[`timeline`,Oa],[`runs`,ma]];function km({api:e,onOpenProject:t,entryObservation:n,projectAccess:r,homeFolder:i,projectEntries:a,notices:o,discovery:s,onOpenService:c,project:l,onChooseFolder:u,onPrepareExecution:d,directoryNamespaces:f,previewModels:p,initialDraft:m,onDraftApplied:g}){let{t:_,tx:v}=X(),[y]=(0,h.useState)(()=>e??co(l?.id)),[b,x]=(0,h.useState)(()=>typeof window>`u`?``:window.location.hash),[S,C]=(0,h.useState)(!1),[w]=(0,h.useState)(Hp),[T,E]=(0,h.useState)(w?.taskId??null),[D,O]=(0,h.useState)(()=>w?null:Vn()??crypto.randomUUID()),k=qn(b,D??``),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)([]),[P,F]=(0,h.useState)(null),[I,L]=(0,h.useState)(w?`task`:`files`),[R,z]=(0,h.useState)(),[te,ne]=(0,h.useState)(),[re,ie]=(0,h.useState)(),[ae,oe]=(0,h.useState)(),[se,ce]=(0,h.useState)(0),[le,ue]=(0,h.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Vn();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[de]=(0,h.useState)(()=>crypto.randomUUID()),fe=(0,h.useCallback)(()=>ne(void 0),[]),[V,pe]=(0,h.useState)(w?w.scope??{kind:`task`,id:w.taskId}:null),[me]=(0,h.useState)(()=>new Zo),H=r??me,he=(0,h.useSyncExternalStore)(H.subscribe,H.snapshot,H.snapshot),ge=he?.source===`entry`?he.code:n?.error,_e=zp(ge),U=as(_e?void 0:l?.id,l?.epoch,H),W=!!l&&U.readiness===`running`,ve=W&&U.association===`unassociated`,ye=!l||W&&U.association===`associated`&&!!U.value?.epoch,be=!!l&&(U.readiness===`stopped`||U.readiness===`not-started`),xe=(0,h.useRef)(null);l&&(ye&&U.value?.epoch?xe.current={projectId:l.id,selected:l.epoch,epoch:U.value.epoch}:(xe.current?.projectId!==l.id||xe.current.selected!==l.epoch||W||be||he||zp(U.error))&&(xe.current=null));let Se=xe.current?.epoch??null,Ce=!_e&&!he&&(!l||Se!==null),G=ls(y,T?{kind:`task`,id:T}:null,!S&&Ce,Se,H),[we,Te]=(0,h.useState)(0),Ee=U.value?.workspaceId,De=!!l&&G.epoch===Se&&!!Ee&&[G.workspace,G.activeRuns].some(e=>e&&e.workspaceId!==Ee),Oe=!S&&!n?.pending&&!ge&&Ce&&!we&&!De&&G.attached&&!zp(G.error)&&(!l||G.epoch===Se),ke=(he?.source===`project`?he.code:void 0)??U.error??(U.value?.status===`unavailable`?`unavailable`:W&&!ye&&!ve?`Viewer access not confirmed`:void 0),Ae=(he?.source===`viewer`?he.code:void 0)??(Ce?G.error??(De?`stale`:void 0):void 0),je=(0,h.useRef)(!0);(G.workspace||G.observation||ke||Ae||ve||be)&&(je.current=!1);let Me=!!(l&&(U.value||U.error||he)),Ne=!!he||_e||zp(ke)||zp(Ae),Pe=!S&&!Ne&&!!(G.workspace||Me),Fe=ss(ve&&!S&&!Ne?l?.id:void 0,T,U.value?.workspaceId,U.value?.epoch,H),Ie=Ce&&!De&&!Ne&&(!l||G.workspace?.epoch===Se)?G.workspace:void 0,Le=ve?Fe.history?.workspace:Ie,Re=Fe.history?.client??y.client,ze=`${ve?`retained`:`viewer`}:${l?.id??`direct`}:${Le?.epoch??``}:${Le?.storeId??``}`,Be=(0,h.useRef)(null);(G.workspace||U.value?.workspaceId)&&(Be.current=G.workspace?.workspaceId??U.value?.workspaceId??null);let Ve=ns(y.client,Pe),He=G.attached&&G.workspace&&!S&&!Ne,Ue=es(y.client,He?{kind:`conversation-active`}:null,1e3,H,G.attachmentVersion,G.allocationSignal),We=Ue.value?.kind===`conversation-active`?Ue.value.entries:[],Ge=[...We,...(Ve.value?.entries??[]).filter(e=>!We.some(t=>t.id===e.id))],Ke=es(y.client,Ce&&G.attached&&!S&&!Ne?{kind:`workflow-active`}:null,2e3,H,G.attachmentVersion,G.allocationSignal),qe=Ke.value?.kind===`workflow-active`?Ke.value:void 0,Je=(0,h.useMemo)(()=>[...new Set([...qe?.runs.map(e=>e.id)??[],...M])],[qe,M]),Ye=es(y.client,!l&&He?{kind:`projects`}:null,0,H,G.attachmentVersion,G.allocationSignal),Xe=le??l?.cwd??(Ye.value?.kind===`projects`?Ye.value.entries.find(e=>e.current)?.path:void 0),Ze=re?.id===D?re:void 0,Qe=(!l||Me)&&ae?.id===D?ae:void 0,K=yo();(0,h.useEffect)(()=>{Ze&&Vn()===Ze.id&&history.replaceState({...history.state,cadenceCwd:Ze.cwd,cadenceConversationId:Ze.id},``,location.href)},[Ze]);let $e=D?Ze:Xe?{id:de,cwd:Xe}:void 0,et=Ze?.cwd??Xe??(Ye.value?.kind===`projects`?Ye.value.entries.find(e=>e.current)?.path:void 0)??G.workspace?.rootLabel,tt=G.observation?.snapshot,nt=tt?.scope.kind===`task`&&tt.scope.id===T&&tt.storeId===Ie?.storeId&&tt.epoch===G.epoch&&(!l||tt.epoch===Se)?G.observation:void 0,rt=ym(),{closeDrawer:it}=rt,q=I===`branches`&&!!D,at=!q&&(I!==`task`||!V),ot=()=>{L(`branches`),rt.mobile?rt.setDrawer(`right`):rt.inspector||rt.toggle(`right`)},[J,st]=(0,h.useState)(w?.snapshotSeq),[ct,lt]=(0,h.useState)(``),[ut,dt]=(0,h.useState)(``),ft=(0,h.useRef)(null),[pt,mt]=(0,h.useState)(`messages`),[ht,gt]=(0,h.useState)(!1),[_t,vt]=(0,h.useState)(!1),[yt,bt]=(0,h.useState)(),[xt,St]=(0,h.useState)(w?.cursor),[Ct,wt]=(0,h.useState)(``),[Tt,Et]=(0,h.useState)([]),[Dt,Ot]=(0,h.useState)(new Set),kt=(0,h.useRef)(!0),At=e=>{kt.current&&Et(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?$o(t,e):t)})},jt=(0,h.useRef)(new us),Mt=(0,h.useRef)(0),Nt=(0,h.useCallback)(()=>{Mt.current++,jt.current.depart()},[]),Pt=B({taskId:T,chatId:D,leaf:k.leaf??null,scope:V,selectedSnapshot:J??null,detached:S,project:l?.id??null,selectedEpoch:l?.epoch??null,viewerEpoch:G.epoch??null,attached:Oe,attachment:G.attachmentVersion,workspaceContext:G.workspace?.context??null,observationError:G.error??null});jt.current.select(Pt),(0,h.useEffect)(()=>(kt.current=!0,()=>{kt.current=!1,Nt()}),[Nt]);let Ft=e=>{x(``);let t=e??crypto.randomUUID();e||ue(et??Xe),j(null),t!==D&&(N([]),ne(void 0)),Nt(),O(t),E(null),pe(null),lt(``),dt(``),bt(void 0),St(void 0),st(void 0),mt(`messages`),L(e=>e===`task`?`files`:e),it();let n=t===D?qn(location.hash,t).leaf:null;history.replaceState({cadenceCwd:et??Xe,cadenceConversationId:t},``,`${location.pathname}${location.search}${Jn(`#chat=${t}`,n)}`)};(0,h.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let It=(e,t)=>{j(null),N([]),O(null),L(`task`),lt(t??``),dt(``),st(void 0),Nt(),E(e),pe({kind:`task`,id:e}),bt(void 0),St(void 0),mt(`messages`),it(),history.replaceState(null,``,Vp(e))};(0,h.useEffect)(()=>{let e=()=>{let e=Hp();if(e)j(null),N([]),O(null),L(`task`),Nt(),st(e.snapshotSeq),lt(``),dt(``),E(e.taskId),pe(e.scope??{kind:`task`,id:e.taskId}),bt(void 0),St(e.cursor),mt(`messages`),it();else{let e=Vn();if(e){x(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&ue(t),ne(void 0),j(null),N([]),O(e),E(null),pe(null),L(e=>e===`task`?`files`:e),Nt(),it()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[it,Nt]);let Lt=(e,t,n)=>{j(null),st(t),dt(n??``),Nt(),pe(e),bt(void 0),St(void 0),mt(`messages`),it(),T&&history.replaceState(null,``,Vp(T,void 0,{scope:e,snapshotSeq:t}))},Rt=Fe.history?.workspace,zt=Rt&&(J&&ee(J,Rt.committedSeq)>0||xt&&(xt.storeId!==Rt.storeId||xt.scope.kind!==V?.kind||xt.scope.id!==V?.id||ee(xt.snapshotSeq,Rt.committedSeq)>0)),Bt=Fe.error??(zt?`History anchor does not match the selected workspace`:void 0),Vt=Le&&!zt?J??nt?.snapshot.committedSeq??Le.committedSeq:void 0,Ht=Le?.storeId,Ut=Bt??ge??ke??Ae??(Ne?`Sign-in required`:be?U.readiness===`stopped`?`Execution stopped`:`Execution not started`:void 0),Wt=Ut?_(`Recorded history unavailable: {reason}.`,{reason:v(Ut)}):_(`Reading recorded history…`),Gt=V&&Ht&&Vt?{storeId:Ht,scope:V,snapshotSeq:Vt,reader:`messages`,after:null,limit:50}:null,Kt=V&&Ht&&Vt?{storeId:Ht,scope:V,snapshotSeq:Vt,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,qt=nt?.snapshot.runs??[],Jt=jt.current.ticket(),Yt=G.allocationSignal,Xt=G.activeRuns,Zt=Xt?.status===`complete`?Xt.runs:[],Qt=Oe&&G.readCurrent&&!!G.epoch&&G.workspace?.epoch===G.epoch&&!G.error&&G.transportStatus===`current`&&(T?nt?.connection===`current`:!G.observation),$t=ye&&Qt,en=(0,h.useCallback)(()=>kt.current&&jt.current.current(Jt)&&!H.signal.aborted,[Jt,H]),tn=(0,h.useCallback)(e=>en()&&Yt?.aborted===!1&&Oe&&!!G.epoch&&G.epoch===e,[en,Yt,Oe,G.epoch]),nn=$t&&G.actions,rn=(0,h.useRef)(new us);rn.current.select(String(nn));let an=rn.current.ticket(),on=(0,h.useMemo)(()=>({allocation:Yt,epoch:G.epoch,attached:tn,current:()=>nn&&rn.current.current(an)&&tn(G.epoch)}),[Yt,G.epoch,tn,nn,an]),sn=e=>tn(e.epoch)&&nf(e),cn=(0,h.useRef)(Xt);cn.current=Xt;let ln=(0,h.useRef)(void 0);(0,h.useLayoutEffect)(()=>{let e=ln.current;e&&e.epoch===on.epoch&&e.previous!==on.allocation&&on.current()&&e.accept(on)});let un=e=>d&&!Ne?async(t,n,r)=>{if(H.check(),t.aborted||!en()||!rn.current.current(an)||Yt?.aborted||we||ln.current)throw Error(`stale`);let i=Mt.current,a=()=>t.aborted||Mt.current!==i;jt.current.depart(),Te(e=>e+1);try{let i=await d(e,t,n,r);if(H.check(),a())throw Error(`stale`);U.prepared(i);let o=G.reconnect();if(await G.whenReady(i,t,o),H.check(),a())throw Error(`stale`);return new Promise((e,n)=>{let r=()=>{ln.current=void 0,t.removeEventListener(`abort`,a),H.signal.removeEventListener(`abort`,a)},a=()=>{r(),n(Error(`stale`))};t.addEventListener(`abort`,a,{once:!0}),H.signal.addEventListener(`abort`,a,{once:!0}),ln.current={epoch:i,previous:Yt,accept(t){r(),e(t)}}}).then(async e=>{if(a()||!e.current()||(await G.whenReady(i,t,o),a()||!e.current()))throw Error(`stale`);return e})}finally{Te(e=>e-1)}}:void 0,dn=un(`send`),fn=un(`plan-validation`),pn=e=>{At(e),e.receipt&&jt.current.current(Jt)&&(rn.current.depart(),G.refresh())},mn=e=>{let t=Zt.find(t=>t.runId===e),n=cn.current;if(!t||!tn(t.epoch)||n?.status!==`complete`||n.epoch!==t.epoch||!n.runs.some(n=>n.runId===e&&n.taskId===t.taskId&&n.operationId===t.operationId&&n.epoch===t.epoch)||Dt.has(e))return;let r=crypto.randomUUID(),i=t.epoch;Ot(t=>new Set(t).add(e)),At({commandId:r,error:_(`Stop requested; settlement is not yet confirmed.`)}),y.client.cancel({commandId:r,epoch:i,runId:e}).then(e=>{pn(e.kind===`ok`?{commandId:r,receipt:e.value}:{commandId:r,error:_(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>At({commandId:r,error:_(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{kt.current&&Ot(t=>{let n=new Set(t);return n.delete(e),n})})},hn=JSON.stringify([l?.id,D,k.leaf,l?.epoch,U.value?.epoch??G.epoch]),gn=(0,h.useRef)(hn);gn.current=hn;let _n=Mt.current,vn=(0,h.useCallback)(()=>kt.current&&!H.signal.aborted&&Mt.current===_n&&gn.current===hn,[hn,_n,H]),[yn,bn]=(0,h.useState)(),xn=(0,h.useCallback)(e=>{vn()&&bn({key:hn,diagnostics:e})},[hn,vn]),Sn=yn?.key===hn&&Pe?yn.diagnostics:void 0;if(S)return(0,Y.jsxs)(`main`,{className:`entry`,children:[(0,Y.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,Y.jsx)(`h1`,{children:_(`Detached`)}),(0,Y.jsx)(`p`,{children:_(`Accepted service work continues. No Cancel was requested.`)}),Tt.map(e=>(0,Y.jsxs)(`p`,{children:[_(`Observe command after reconnect:`),` `,(0,Y.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,Y.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>C(!1),children:_(`Reconnect as a viewer`)})]});let Cn=je.current&&!ke&&!Ae,wn=be?{status:U.readiness===`not-started`?`not-started`:`stopped`}:$t&&G.epoch?{status:`ready`,epoch:G.epoch,attachmentVersion:G.attachmentVersion}:{status:!ke&&!Ae&&!ve?`connecting`:`unavailable`},Tn=()=>{vn()&&!_e&&(rn.current.depart(),Sn?.retry(),Ke.error&&Ke.refresh(),Ue.error&&Ue.refresh(),Ye.error&&Ye.refresh(),n?.refresh(),Fe.refresh(),Ce&&G.refresh(),U.refresh())};return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(mm,{panels:rt,onOpenService:c,onRefresh:Tn,onDisconnect:()=>{gt(!1),vt(!1),Nt(),C(!0)},inspectorLabel:_(V&&I===`task`?`History details`:q?`Branches`:`Files`),toolbar:V&&(0,Y.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":_(`Recorded views`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":pt===`messages`&&!xt,onClick:()=>{St(void 0),bt(void 0),mt(`messages`)},children:[(0,Y.jsx)(na,{"aria-hidden":`true`}),_(`Conversation`)]}),(0,Y.jsxs)(`details`,{className:`view-menu`,ref:ft,onKeyDown:e=>{e.key===`Escape`&&ft.current&&(ft.current.open=!1,ft.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,Y.jsxs)(`summary`,{className:`chip`,children:[pt===`messages`?_(`Details`):v(pt),(0,Y.jsx)(Na,{"aria-hidden":`true`})]}),(0,Y.jsxs)(`div`,{className:`view-menu-items`,children:[Om.map(([e,t])=>(0,Y.jsxs)(`button`,{type:`button`,"aria-pressed":pt===e,onClick:()=>{St(void 0),bt(void 0),mt(e),ft.current&&(ft.current.open=!1,ft.current.querySelector(`summary`)?.focus())},children:[(0,Y.jsx)(t,{"aria-hidden":`true`}),v(e)]},e)),(0,Y.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,Y.jsxs)(`button`,{type:`button`,"aria-label":_(`Export selected scope`),disabled:!Gt,onClick:()=>{ft.current&&(ft.current.open=!1,ft.current.querySelector(`summary`)?.focus()),vt(!0)},children:[(0,Y.jsx)(xa,{"aria-hidden":`true`}),_(`Export selected scope`)]}),(0,Y.jsxs)(`button`,{type:`button`,"aria-label":_(`Copy token-free link`),disabled:!T,onClick:()=>{T&&ys(Vp(T,xt,V?{scope:V,snapshotSeq:J}:void 0)).then(e=>e?Ps(`info`,_(`Link copied.`)):Ps(`error`,_(`Link copy unavailable.`)))},children:[(0,Y.jsx)(sa,{"aria-hidden":`true`}),_(`Copy token-free link`)]})]})]})]})]}),actions:V&&(0,Y.jsx)(vc,{disabled:!Kt,onOpen:()=>gt(!0)}),notices:(0,Y.jsxs)(Y.Fragment,{children:[o,Ct&&(0,Y.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:Ct})]}),navigation:(0,Y.jsxs)(Y.Fragment,{children:[!Pe&&!qe?.runs.length&&(0,Y.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[s&&(0,Y.jsx)(Pc,{...s}),Zt.length>0&&(0,Y.jsx)(`section`,{className:`run-strip`,"aria-label":_(`Execution and cancellation`),children:Zt.map(e=>(0,Y.jsxs)(`div`,{className:`run-strip-row`,children:[(0,Y.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,Y.jsxs)(`span`,{className:`run-strip-label`,children:[v(e.kind),` `,e.runId,` · `,v(e.stage)]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>It(e.taskId),children:_(`Open active task`)}),(0,Y.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Oe||Dt.has(e.runId),onClick:()=>mn(e.runId),children:[(0,Y.jsx)(Ui,{"aria-hidden":`true`}),_(`Cancel run — request stop`)]})]},e.runId))}),(0,Y.jsx)(`p`,{className:`panel-empty`,role:`status`,children:_(ke||Ae?`Conversation history could not be read. This is not an empty history.`:`Reading conversation history…`)})]}),(Pe||!!qe?.runs.length)&&(0,Y.jsx)(Op,{discovery:s,client:y.client,workspace:Ie,retained:Fe.history,executionStopped:be,taskId:T,scope:V,runs:qt,snapshot:nt?.snapshot.committedSeq,activeRuns:G.activeRuns,canCancel:Oe,canceling:Dt,onCancel:mn,chats:Ge,chatActivityKnown:Ue.value?.kind===`conversation-active`&&!Ue.error,chatHistoryPartial:Ve.loading||Ve.canPrevious||!!Ve.value?.next,chatHistoryControls:(0,Y.jsxs)(Y.Fragment,{children:[Ve.error&&(0,Y.jsx)(`p`,{role:`alert`,children:Ve.error}),Ve.loading&&(0,Y.jsx)(`p`,{className:`panel-hint`,children:_(`Reading conversation history…`)}),Ve.canPrevious&&(0,Y.jsx)(`button`,{type:`button`,disabled:Ve.loading,onClick:Ve.previous,children:_(`Newer conversations`)}),Ve.value?.next&&(0,Y.jsx)(`button`,{type:`button`,disabled:Ve.loading,onClick:Ve.next,children:_(`Older conversations`)}),Ve.canPrevious&&(0,Y.jsx)(`button`,{type:`button`,onClick:Ve.first,children:_(`Latest conversations`)}),Ve.error&&(0,Y.jsx)(`button`,{type:`button`,onClick:Ve.refresh,children:_(`Observe current state`)})]}),conversationId:D,onConversation:Ft,onNewConversation:()=>Ft(),actionCurrent:on.current,actionsUnavailable:nn?``:_(be?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{Ve.refresh(),e===D&&ce(e=>e+1)},workflows:qe?.runs,workflowLinks:qe?.links,workflowError:!!Ke.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?Ft(t):(j({runId:e.id,stepId:null,label:e.goal}),it())},canCancelWorkflow:sn,onCancelWorkflow:async e=>{sn(e)&&(wt(await ff(y.client,e,sn)),Ke.refresh())},onTask:It,onScope:Lt},`${ze}:${ve?T??`chat`:``}`),G.workspace&&(0,Y.jsx)(Yc,{client:y.client,active:G.activeRuns,taskId:T,runs:qt,snapshot:Vt,workflowRuns:Je,selected:A,onOpenWorkflow:e=>{j(e),it()},onOpen:(e,t,n,r)=>{It(e),pe({kind:`child`,id:t}),dt(r),st(n),history.replaceState(null,``,Vp(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,Y.jsxs)(Y.Fragment,{children:[D&&l&&!Me&&(0,Y.jsx)(`p`,{className:`panel-empty`,role:`status`,children:_(`Reading this conversation…`)}),A&&!Ne&&(0,Y.jsx)(Ap,{client:y.client,agent:A,canCancelWorkflow:sn,backLabel:_(D?`Back to conversation`:T?`Back to task`:`Back`),onBack:()=>j(null),onOpenAgent:j},`${A.runId}:${A.stepId??``}`),D&&(!l||Me)&&(0,Y.jsx)(Of,{client:y.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Xe,onLocation:ie,onActivity:oe,hidden:!!A,onOpenAgent:j,onWorkflowRuns:N,onBranches:z,onOpenBranches:ot,workspaceId:l?`checkout:${l.path}`:Be.current??`connecting`,directoryNamespaces:f,legacyWorkspaceId:l?U.value?.workspaceId??void 0:void 0,prepareForSend:dn,prepareForPlan:fn,actionsReady:nn,viewer:on,access:H,readSelected:vn,onDiagnostics:xn,observe:se,available:Pe,canInterrupt:Oe,canCancelWorkflow:sn,enabled:dn?Pe&&!we:nn,modelAvailability:wn,previewModels:Ne?void 0:p,initialDraft:m?.conversationId===D?m:void 0,onDraftApplied:()=>g?.(D),onModelChanged:()=>{Tn()},onChanged:()=>{Ve.refresh(),rn.current.depart(),G.refresh()},reference:te,onReferenceUsed:fe},`${l?.id??Be.current??`connecting`}:${D}:${k.leaf??``}`),V&&!A&&(0,Y.jsxs)(`header`,{className:`conversation-header`,children:[(0,Y.jsxs)(`div`,{className:`conversation-heading`,children:[V.kind!==`task`&&T&&(0,Y.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>It(T,ct),children:_(`Back to task`)}),(0,Y.jsx)(`h2`,{title:ct||V.id,children:V.kind===`task`?ct||_(`Task {id}`,{id:V.id.slice(0,8)}):ut||_(`{kind} {id}`,{kind:v(V.kind),id:V.id.slice(0,8)})}),V.kind===`child`&&(0,Y.jsx)(`span`,{className:`conversation-badge`,children:_(`Subagent`)})]}),(0,Y.jsxs)(`details`,{className:`conversation-info`,children:[(0,Y.jsxs)(`summary`,{children:[_(`Recorded conversation`),` ·`,` `,_(`snapshot {seq}`,{seq:Vt??``})]}),(0,Y.jsx)(`code`,{children:V.id}),(0,Y.jsx)(`p`,{children:_(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,Y.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!A,children:[!Gt&&(0,Y.jsxs)(`section`,{className:`empty-state`,children:[(0,Y.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:(0,Y.jsx)(Gd,{})}),(0,Y.jsx)(`h2`,{children:Wt}),(0,Y.jsx)(`p`,{children:_(`History is readonly. Start new work in a conversation with /cadence.`)})]}),Gt&&xt?(0,Y.jsxs)(`div`,{className:`tab-body`,children:[yt&&(yt.owner.entity.kind===`task`||yt.owner.entity.kind===`message`||yt.owner.entity.kind===`tool`)&&(0,Y.jsx)(oc,{client:Re,seed:{storeId:xt.storeId,scope:xt.scope,snapshotSeq:xt.snapshotSeq,kind:yt.owner.entity.kind,id:yt.owner.entity.id,version:yt.owner.entity.version}},`${yt.owner.entity.id}:${yt.owner.entity.version}`),(0,Y.jsx)(rc,{client:Re,cursor:xt,highlight:yt?.range},`${xt.recordId}:${xt.recordVersion}`)]}):Gt&&(0,Y.jsxs)(`div`,{className:pt===`messages`||pt===`tools`?`tab-body transcript-body`:`tab-body`,children:[pt===`messages`&&(0,Y.jsx)(Ac,{client:Re,seed:Gt}),pt===`tools`&&(0,Y.jsx)(Am,{client:Re,seed:Gt}),pt===`context`&&(0,Y.jsx)(ac,{client:Re,seed:Gt}),pt===`timeline`&&(0,Y.jsx)(Em,{client:Re,seed:Gt,onSearch:()=>gt(!0)}),pt===`runs`&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{className:`run-current`,children:[(0,Y.jsx)(`h3`,{children:_(`Runs in the current snapshot`)}),qt.length>0?qt.map(e=>(0,Y.jsx)(mc,{run:e},e.childRunId??e.runId)):(0,Y.jsx)(`p`,{className:`panel-empty`,children:_(nt?`No owner run projection in this snapshot.`:`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,Y.jsx)(`h3`,{children:_(`Retained runs`)}),(0,Y.jsx)(_c,{client:Re,seed:{...Gt,scope:{kind:`task`,id:T??Gt.scope.id}},onScope:Lt},T)]})]},`${V?.kind}:${V?.id}:${J??`current`}`)]},`${ze}:${T??`chat`}`),G.workspace&&Tt.length>0&&(0,Y.jsx)(`div`,{className:`receipt-dock`,children:Tt.map(e=>(0,Y.jsx)(ds,{client:y.client,value:e,onChange:At},e.commandId))})]}),inspectorTabs:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":at,onClick:()=>L(`files`),children:[(0,Y.jsx)(ha,{"aria-hidden":`true`}),_(`Files`)]}),D&&(0,Y.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":q,onClick:()=>L(`branches`),children:[(0,Y.jsx)(ma,{"aria-hidden":`true`}),_(`Branches`)]}),V&&(0,Y.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":I===`task`,disabled:!Gt,onClick:()=>L(`task`),children:[(0,Y.jsx)(ca,{"aria-hidden":`true`}),_(`History details`)]})]}),inspector:q?(0,Y.jsx)(tl,{view:R?.id===D?R:void 0,onChosen:it}):at?(0,Y.jsx)(Uf,{location:$e,client:y.client,enabled:Pe&&!!$e,observed:`${U.readiness}:${U.value?.epoch??``}`,onReference:e=>{D||Ft(de);let t=!D&&$e?`${$e.cwd.replace(/[\\/]+$/,``)}${$e.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;ne(t),it()}},$e?.cwd??`owner`):Gt?(0,Y.jsx)(ep,{client:Re,seed:{...Gt,scope:{kind:`task`,id:T??Gt.scope.id}}},`${ze}:${T}`):(0,Y.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Wt}),status:(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Bp,{phase:n?.pending?`updating`:be?U.readiness===`not-started`?`not-started`:`stopped`:ve?`independent`:$t?T?`task`:`chat`:Cn?`connecting`:`updating`,entryError:ge,projectStatus:l&&U.readiness,projectError:ke,viewerError:Ae,prepareOnly:Sn?.prepareOnly,readErrors:[[`Project directories: {code}.`,Ye.error],[`Conversation activity: {code}.`,Ue.error],[`Workflow activity: {code}.`,Ke.error],[`Conversation context: {code}.`,Sn?.context],[`Conversation read: {code}.`,Sn?.head],[`Workflow observation: {code}.`,Sn?.workflow],[`Recorded workflows: {code}.`,Sn?.runs]],historyError:Bt,retained:!!G.workspace||U.readiness===`stale`&&!!U.value&&U.value.status!==`unavailable`,latency:K,onRefresh:Tn},`${hn}:${T??`chat`}`),Qe&&(0,Y.jsx)(vm,{usage:Qe.context}),Qe&&(0,Y.jsx)(gm,{cache:Qe.cache}),Qe&&Qe.turns>0&&(0,Y.jsx)(Np,{icon:(0,Y.jsx)(na,{}),tip:_(`Turns in this conversation: {count}`,{count:Qe.turns}),children:Qe.turns}),D&&(0,Y.jsx)(Ip,{clock:Qe?.replyClock??`unavailable`}),Xt?.status===`complete`&&Zt.length>0&&(0,Y.jsx)(Np,{tone:`warn`,children:_($t?Zt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:Zt.length})})]}),folder:(G.workspace||l)&&(0,Y.jsx)(Mp,{path:et,onClick:()=>u?u(et):F(``)})}),P!==null&&G.workspace&&(0,Y.jsx)(ip,{onOpen:t,projects:a??(Ye.value?.kind===`projects`?Ye.value.entries:[]),client:y.client,current:et??G.workspace.rootLabel,initial:P||void 0,home:i,epoch:G.workspace.epoch,onClose:()=>F(null)}),ht&&Kt&&(0,Y.jsx)(pc,{client:Re,seed:Kt,onClose:()=>gt(!1),onHit:e=>{bt(e),St(e.cursor),T&&history.replaceState(null,``,Vp(T,e.cursor,V?{scope:V,snapshotSeq:J}:void 0))}},`${ze}:${V?.id}`),_t&&Kt&&(0,Y.jsx)(uc,{request:{storeId:Kt.storeId,scope:Kt.scope,snapshotSeq:Kt.snapshotSeq,format:`ndjson`},onClose:()=>vt(!1)},`${ze}:${V?.id}`)]})}function Am({client:e,seed:t}){let n=gs(e,{...t,reader:`tools`}),r=n.page;return(0,Y.jsxs)(`section`,{className:`tools-list`,children:[(0,Y.jsx)(ic,{pager:n}),(0,Y.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,Y.jsx)(Mc,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var jm=`cadence:folder-draft`,Mm=()=>({text:``,model:null});function Nm(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Mm();let t=null;try{e.model!=null&&(t=le(e.model))}catch{}return{text:e.text,model:t}}catch{return Mm()}}function Pm(e){try{e.text||e.model?sessionStorage.setItem(jm,JSON.stringify(e)):sessionStorage.removeItem(jm)}catch{}}function Fm(e,t,n){let r=Wl(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(jm)}catch{}return{...n,conversationId:t}}var Im=`cadence-last-project`;function Lm(){try{let e=localStorage.getItem(Im);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Rm(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Im,e)}catch{}}function zm(e){let t=Lm();return t?e.projects.find(e=>e.id===t):void 0}async function Bm(e,t){let n=await Xo(`/workbench/v1/projects/${e}`,t,xo);return n.workspaceId!==null||n.status===`not-started`}async function Vm(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await zo(n);if(!n.ok)throw Error(Bo(r));return rt(r)}async function Hm(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await zo(t);if(!t.ok)throw Error(Bo(n));return Eo(n)}async function Um(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await zo(s);if(!s.ok)throw Vo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Bo(c));let l=bo(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Wm(e,t){let n=await Hm(t);return Um(`/workbench/v1/select`,{path:e},n,t)}async function Gm(e,t,n,r,i){let a=await Hm(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await Um(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function Km(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Wm(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var qm=[`turn`,`starting`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Jm(e){let t=F(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:L(t.id),source:M(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:Ye(t.sessionId),cwd:O(t.cwd,4096,!0),leaf:t.leaf===null?null:O(t.leaf,128,!0),history:M(t.history,[`shared`,`unavailable`]),phase:M(t.phase,qm),freshness:M(t.freshness,[`current`,`stale`,`unknown`]),observedAt:A(t.observedAt,0),epoch:t.epoch===null?null:L(t.epoch),instance:t.instance===null?null:L(t.instance),executionCwd:t.executionCwd===null?null:O(t.executionCwd,4096,!0)}}function Ym(e){let t=F(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:N(t.kind,`activity-discovery`),epoch:L(t.epoch),observedAt:A(t.observedAt,0),completeness:M(t.completeness,[`complete`,`partial`]),unavailable:A(t.unavailable,0,1e4),projects:I(t.projects,128,e=>{let t=F(e,[`path`,`activities`]);return{path:O(t.path,4096,!0),activities:I(t.activities,256,Jm)}})}}async function Xm(e){return Xo(`/workbench/v1/activity`,e,Ym)}function Zm(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function Qm(e,t,n,r=Xm){let i=new AbortController,a,o,s,c=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw s!==a.epoch&&(s=a.epoch,n()),Error(`stale`);s=void 0,o=a,t(o,``)}catch(e){if(i.signal.aborted)return;let r=e instanceof Error?e.message:`unavailable`;if(Jo(r)){i.abort(),n(r),t(void 0,r);return}o=o?Zm(o,Date.now()):void 0,t(o,r)}finally{i.signal.aborted||(a=setTimeout(c,3e3))}};return c(),()=>{i.abort(),clearTimeout(a)}}function $m(e,t){let[n,r]=(0,h.useState)(),[i,a]=(0,h.useState)(``);return(0,h.useEffect)(()=>{if(r(void 0),a(``),e)return Qm(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}async function eh(e){try{return await Xo(`/workbench/v1`,e,Eo)}catch(e){if(e instanceof Yo&&e.status===400&&e.message===`invalid`)return null;throw e}}function th({ready:e,previewModels:t,draft:n=Mm(),onDraftChange:r,restoring:i,missing:a,pending:o=!e,entryError:s,restoreError:c,onChooseFolder:l,onRefresh:u,onOpenService:d,notices:f,discovery:p}){let{t:m}=X(),g=ym(),[_,v]=(0,h.useState)(!1),y=ql(null,{status:`not-started`},`folder-setup`,t),b=()=>{g.closeDrawer(),l()};return(0,Y.jsx)(mm,{panels:g,onRefresh:u,onOpenService:d,notices:f,navigation:(0,Y.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,Y.jsx)(dp,{disabled:!e,onConversation:b}),p&&(0,Y.jsx)(Pc,{...p}),(0,Y.jsxs)(`section`,{className:`lp-section grow`,children:[(0,Y.jsx)(`header`,{className:`lp-section-header`,children:(0,Y.jsx)(`span`,{className:`lp-section-title`,children:m(`Conversation history`)})}),(0,Y.jsx)(`div`,{className:`lp-section-body`,children:(0,Y.jsx)(`p`,{className:`panel-hint`,role:`status`,children:m(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,Y.jsxs)(`section`,{className:`chat-workspace`,"aria-label":m(`Ordinary conversation`),children:[(0,Y.jsx)(`div`,{className:`chat-messages`,children:(0,Y.jsxs)(Kd,{visible:e&&!(i&&o),hint:m(`Choose a working folder to start. You can write a draft below.`),children:[(0,Y.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:b,children:[(0,Y.jsx)(ha,{"aria-hidden":`true`}),m(`Choose a folder…`)]}),a&&(0,Y.jsx)(`p`,{className:`panel-hint`,role:`status`,children:m(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),(0,Y.jsx)(`div`,{className:`composer-dock`,children:(0,Y.jsxs)(`div`,{className:`chat-composer`,children:[(0,Y.jsx)(`textarea`,{"aria-label":m(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:m(`Write a message. Choose a folder before sending…`)}),(0,Y.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,Y.jsx)(Nu,{scope:`next-conversation`,availability:{status:`not-started`},read:y,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:_,onOpenChange:e=>{e&&y.reread(),v(e)},onChanged:()=>{}}),(0,Y.jsx)(`span`,{className:`composer-hint`,children:m(`Choose a folder before sending.`)}),(0,Y.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":m(`Send`),title:m(`Send`),disabled:!0,children:(0,Y.jsx)(Ia,{"aria-hidden":`true`})})]})]})})]}),inspector:(0,Y.jsx)(`aside`,{className:`panel files-panel`,children:(0,Y.jsx)(`p`,{className:`panel-hint`,children:m(`Files appear here after you open a working folder.`)})}),status:(0,Y.jsx)(Bp,{phase:o?e?`updating`:`connecting`:`folder`,entryError:s,projectError:c,retained:e&&!i,latency:null,onRefresh:u}),folder:(0,Y.jsx)(Mp,{disabled:!e,onClick:b})})}var nh={restart:18e4,upgrade:12e5},rh=1e3,ih={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`};function ah(e,t){let n=t.job;if(n?.id===e.id&&n.state!==`running`)return e.action===`upgrade`&&n.state===`ready`&&!ch(n)?n.action===`upgrade`&&n.version===e.to&&t.version===e.to?`reload`:`changed`:n}var oh=e=>e instanceof Error?e.message:`unavailable`;function sh(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(ih[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function ch(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function lh(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function uh({epoch:e,csrf:t,onClose:n}){let{t:r}=X(),[i,a]=(0,h.useState)(),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(!1),[m,g]=(0,h.useState)(!1),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(),[C,w]=(0,h.useState)(0),E=i?.work??null,D=i?.unit&&!E&&(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`p`,{role:`alert`,children:r(`Cadence could not confirm which work would stop. Refresh the service status to continue.`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>e+1),children:r(`Refresh status`)})]});(0,h.useEffect)(()=>{let e=new AbortController;return Uo(e.signal).then(a,t=>{e.signal.aborted||s(oh(t))}),()=>e.abort()},[C]),(0,h.useEffect)(()=>{if(!_)return;let{job:e,since:t}=_,n=new AbortController,r,i=async()=>{if(Date.now()-t>nh[e.action])return S(`timeout`);try{let t=await Uo(n.signal);if(n.signal.aborted)return;let r=ah(e,t);if(r===`reload`)return window.location.reload();if(r!==void 0)return S(r)}catch(e){if(n.signal.aborted)return;if(e instanceof T||e instanceof Error&&e.message===`invalid`)return S(`changed`);b(!0)}r=setTimeout(i,rh)};return r=setTimeout(i,rh),()=>{n.abort(),clearTimeout(r)}},[_]);let O=async()=>{l(`checking`),s(``);let e=await Wo().catch(()=>`failed`);try{a(await Uo()),l(e)}catch(e){s(oh(e)),l(`failed`)}},k=n=>{i&&E&&!m&&(g(!0),s(``),Go({action:n===null?`restart`:`upgrade`,from:i.version,to:n,work:E.digest,epoch:e},t).then(e=>v({job:e,since:Date.now()})).catch(e=>{s(oh(e)),a({...i,work:null}),p(!1),w(e=>e+1)}).finally(()=>g(!1)))};if(_){let{job:e}=_,t=x!==void 0&&(typeof x==`string`||x.state!==`ready`),a=typeof x==`object`&&ch(x),o=i?.unit;return(0,Y.jsxs)(lc,{title:r(`Cadence service`),onClose:x?n:void 0,children:[(0,Y.jsxs)(`section`,{className:`service-progress`,children:[x===void 0?(0,Y.jsxs)(`p`,{role:`status`,children:[(0,Y.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(y?`Cadence is starting again…`:`Stopping Cadence…`):r(y?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,Y.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,Y.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),x===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:nh[e.action]/6e4}):x===`changed`?r(`Cadence answered with a different version.`):sh(r,x)]}),(0,Y.jsx)(`p`,{children:r(x===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,Y.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,Y.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,Y.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),x!==void 0&&(0,Y.jsx)(`footer`,{children:a?(0,Y.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,Y.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=E?.items??[];return(0,Y.jsxs)(lc,{title:r(`Cadence service`),onClose:m?void 0:n,children:[(0,Y.jsxs)(`section`,{children:[(0,Y.jsx)(`h3`,{children:r(`Restart Cadence?`)}),(0,Y.jsx)(`p`,{children:r(`The service stops in order and starts again; this page waits for the result.`)}),e.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(dh,{items:e,t:r}),(0,Y.jsxs)(`label`,{className:`service-confirm`,children:[(0,Y.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),D,o&&(0,Y.jsx)(`p`,{role:`alert`,children:tr(r,o)}),(0,Y.jsxs)(`footer`,{children:[(0,Y.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>{d(!1),p(!1),s(``)},children:r(`Back`)}),(0,Y.jsx)(`button`,{type:`button`,className:e.length>0?`danger`:`primary`,disabled:m||!E||e.length>0&&!f,onClick:()=>k(null),children:r(`Restart now`)})]})]})}let A=i&&c&&typeof c==`object`?Ro(c.version,i.version)>0:!1;return(0,Y.jsxs)(lc,{title:r(`Cadence service`),onClose:m?void 0:n,children:[i?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`section`,{className:`service-info`,children:[(0,Y.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,Y.jsx)(`p`,{children:lh(r,i.upgrade)}),(0,Y.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,Y.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:sh(r,i.job)})})]}),i.unit&&(0,Y.jsxs)(`section`,{className:`service-info`,children:[(0,Y.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,Y.jsxs)(Y.Fragment,{children:[c===`failed`&&(0,Y.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,Y.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):A?c.deprecated?(0,Y.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Po(i.upgrade)?E?(0,Y.jsx)(fh,{version:c.version,work:E.items,sending:m,onUpgrade:k,t:r}):null:(0,Y.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,Y.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),D,o&&(0,Y.jsx)(`p`,{role:`alert`,children:tr(r,o)})]}):(0,Y.jsx)(`p`,{role:o?`alert`:`status`,children:o?tr(r,o):r(`Reading the service…`)}),(0,Y.jsx)(`footer`,{children:(0,Y.jsxs)(`button`,{type:`button`,disabled:!i?.unit||!E||m||c===`checking`,onClick:()=>d(!0),children:[(0,Y.jsx)(Yi,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function dh({items:e,t}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`alert`,children:t(`{count} running workflows or conversations will be stopped.`,{count:e.length})}),(0,Y.jsx)(`ul`,{className:`service-work`,children:e.map(({project:e,source:n,id:r,sessionId:i})=>(0,Y.jsxs)(`li`,{children:[e,` · `,t(n===`turn`?`Owner turn`:`Owner workflow`),` `,(0,Y.jsx)(`code`,{children:r}),i&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,t(`Conversation {id}`,{id:i})]})]},JSON.stringify([e,n,r])))})]})}function fh({version:e,work:t,sending:n,onUpgrade:r,t:i}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{children:i(`Cadence downloads the update before stopping. If startup fails, it tries to restore the previous version. After a successful upgrade, this page reloads automatically; unsent images must be attached again.`)}),t.length>0&&(0,Y.jsx)(dh,{items:t,t:i}),(0,Y.jsxs)(`button`,{type:`button`,className:t.length>0?`danger`:`primary`,disabled:n,onClick:()=>r(e),children:[(0,Y.jsx)(La,{"aria-hidden":`true`}),i(t.length>0?`Stop work and upgrade to {version}`:`Upgrade to {version}`,{version:e})]})]})}function ph(){let{t:e}=X(),[t,n]=(0,h.useState)(),[r,i]=(0,h.useState)(Nm),[a,o]=(0,h.useState)(),s=(0,h.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,h.useState)(Bn),u=(0,h.useCallback)(e=>Vm(c??void 0,e),[c]),[d,f]=(0,h.useState)(null),[p,m]=(0,h.useState)(null),[g,_]=(0,h.useState)(``),[v,y]=(0,h.useState)(!1),[b,x]=(0,h.useState)({pending:!0}),S=(0,h.useRef)(null),C=(0,h.useRef)(new Map),D=(0,h.useRef)(!c&&!r.text&&!r.model),[O,k]=(0,h.useState)(!1),A=(0,h.useRef)(null),j=(0,h.useCallback)(()=>{A.current?.abort(),A.current=null},[]),M=(0,h.useRef)(!1),N=(0,h.useRef)(void 0),P=(0,h.useRef)(null);(!P.current||!N.current&&P.current.selected!==c)&&(P.current={selected:c,access:new Zo});let{access:F}=P.current,I=(0,h.useCallback)((e,t)=>{N.current||(N.current=e,j(),S.current?.abort(),P.current?.access.refuse(`entry`,e),x({pending:!1,entryError:t?void 0:e,restoreError:t?e:void 0,restoring:t}))},[j]),L=(0,h.useCallback)(()=>{if(N.current)return;j();let e=new AbortController;A.current=e;let t,r=()=>{t!==void 0&&a()};window.addEventListener(`online`,r);let i=()=>{clearTimeout(t),window.removeEventListener(`online`,r)};e.signal.addEventListener(`abort`,i,{once:!0});let a=async()=>{if(clearTimeout(t),t=void 0,e.signal.aborted)return;x(e=>({...e,restoring:void 0,pending:!0}));let r;try{let t=await eh(e.signal);if(e.signal.aborted)return;M.current=!1,n(t);let a=D.current&&t?zm(t):void 0;if(a){r=a.cwd,x(e=>({...e,entryError:void 0,restoring:r,pending:!0}));let t=await Bm(a.id,e.signal);if(e.signal.aborted)return;if(!t)throw Error(`unavailable`);D.current=!1,history.replaceState(null,``,`/app?project=${a.id}`),l(a.id)}x({pending:!1,missing:!!(t&&D.current&&Lm()&&!a)}),i(),A.current=null}catch(n){if(e.signal.aborted)return;let i=n instanceof Error?n.message:`unavailable`;if(Jo(i))return I(i,r);x({pending:!1,entryError:r?void 0:i,restoreError:r?i:void 0,restoring:r}),t=setTimeout(a,qo)}};a()},[j,I]),R=Jo(b.entryError)||Jo(b.restoreError),z=(0,h.useCallback)(e=>{if(e&&Jo(e))return I(e);M.current||(M.current=!0,L())},[L,I]),ee=$m(R?void 0:t?.epoch,z);(0,h.useEffect)(()=>{L();let e=()=>{S.current?.abort(),D.current=!1,k(!1),l(Bn()),L()},t=()=>{D.current&&A.current&&e()};return window.addEventListener(`hashchange`,t),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,t),window.removeEventListener(`popstate`,e),j(),S.current?.abort()}},[L,j]);let te=()=>{D.current=!1,k(!0),!(R||O)&&(t&&b.restoring?(j(),x({pending:!1})):A.current&&L())},B=(0,h.useCallback)(e=>{if(N.current)throw Error(N.current);j(),M.current=!1,x({pending:!1}),n(e)},[j]),ne=(0,h.useCallback)((e,n)=>{D.current=!1,k(!1),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&C.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=(O||!t?.projects.some(e=>e.id===c))&&!n&&!!(r.text||r.model);s?(o(Fm(e.path,a,r)),i(Mm())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:C.current.get(e.id)??`#chat=${a}`}`),l(e.id),f(null),window.dispatchEvent(new Event(`hashchange`))},[c,O,t,r]),re=(0,h.useCallback)(async e=>{if(N.current)throw Error(N.current);S.current?.abort();let t=new AbortController;S.current=t;let n=await Wm(e,t.signal);t.signal.aborted||(B(n.entry),ne(n.project))},[ne,B]),ie=t&&!R?{value:ee.value,error:ee.error,opening:!!p,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,n)=>{S.current?.abort(),le||te();let r=new AbortController;S.current=r,m(n.cwd),_(``),Km(t,n,r.signal).then(e=>{r.signal.aborted||(B(e.entry),ne(e.project,n))}).catch(t=>{r.signal.aborted||_(tr(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{S.current===r&&m(null)})}}:void 0,ae=async(e,n,r,i)=>{if(F.check(),N.current)throw Error(N.current);let a=t?.projects.find(e=>e.id===c);if(!a)throw Error(`unavailable`);let o=hr([n,F.signal]);try{let t=await Gm(a,e,o.signal,r,i);if(F.check(),o.signal.aborted||P.current?.access!==F)throw Error(`stale`);return B(t.entry),t.project.epoch}finally{o.dispose()}},oe=(0,h.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new T(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await zo(n);if(!n.ok){let e=Bo(r);return{kind:`error`,error:E(w.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Rn(r)}}catch{return{kind:`error`,error:E(`unavailable`)}}}}),[]),se=t?.epoch,ce=(0,h.useMemo)(()=>c?co(c):void 0,[c,se]),le=O?void 0:t?.projects.find(e=>e.id===c);(0,h.useEffect)(()=>{le&&Rm(le.id)},[le]);let ue={pending:b.pending,error:b.entryError??b.restoreError,refresh:L};if(t===null)return(0,Y.jsx)(km,{entryObservation:ue,projectAccess:F});let de=t&&v&&(0,Y.jsx)(uh,{epoch:t.epoch,csrf:t.csrf,onClose:()=>y(!1)}),fe=()=>y(!0),V=t&&d!==null&&(0,Y.jsx)(ip,{selectOnly:!0,client:oe,current:le?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>f(null),onOpen:re});return t&&le&&ce?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(km,{entryObservation:ue,projectAccess:F,api:ce,project:le,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===le.path).map(e=>e.id).sort(),discovery:ie,onPrepareExecution:ae,onChooseFolder:e=>{S.current?.abort(),A.current&&!R&&L(),f(e??le.cwd)},onOpenProject:re,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:g&&(0,Y.jsx)(`p`,{role:`alert`,children:g}),onOpenService:fe},`${t.epoch}:${le.id}`),de,V]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(th,{discovery:ie,ready:!!t&&!R,previewModels:t&&!R?u:void 0,draft:r,onDraftChange:e=>{te(),i(e),Pm(e)},restoring:b.restoring,missing:!b.pending&&!b.entryError&&!b.restoreError&&(b.missing||!(O||!c||le||!t)),pending:b.pending,entryError:b.entryError,restoreError:b.restoreError,onRefresh:L,onOpenService:t?fe:void 0,onChooseFolder:()=>{te(),_(``),S.current?.abort(),f(t?.home??``)},notices:g&&(0,Y.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g})}),V,de]})}function mh(){let{t:e}=X();return(0,Y.jsxs)(`main`,{className:`entry`,children:[(0,Y.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,Y.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var hh=class extends h.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,Y.jsx)(mh,{}):this.props.children}};Gn(),dr(ur());var gh=document.getElementById(`root`);if(!gh)throw Error(`Application root unavailable`);(0,g.createRoot)(gh).render((0,Y.jsx)(or,{children:(0,Y.jsx)(hh,{children:(0,Y.jsx)(ph,{})})}));export{Tm as t};
|
|
43
|
+
`}${r}`}var Uf=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function Wf(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}function Gf(e,t){let n=e.startsWith(`/`)?`/`:`\\`;return`${e.replace(/[\\/]+$/,``)}${n}${t.split(`/`).join(n)}`}var Kf=`file-download`,qf=(0,h.memo)(function({path:e,text:t}){return(0,X.jsx)(qs,{text:Hf(t,ed(e))})});function Jf({client:e,enabled:t,location:n,observed:r=``,onReference:i}){let{t:a}=Z(),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(null),[f,p]=(0,h.useState)(``),[m,g]=(0,h.useState)(!1),{copied:_,copy:v}=Ss(),[y,b]=(0,h.useState)(null),x=(0,h.useRef)(null),S=n?.cwd,C=n?.id;(0,h.useEffect)(()=>()=>{x.current?.abort(),x.current=null,b(null)},[e,S,C]);let w=ns(e,t?{kind:`files`,path:o,...n?{location:n}:{}}:null),T=ns(e,t&&c?{kind:`file`,path:c,...n?{location:n}:{}}:null),{refresh:E}=w,{refresh:D}=T,O=(0,h.useRef)(r);(0,h.useEffect)(()=>{O.current!==r&&(O.current=r,E(),D())},[r,E,D]);let k=w.value?.kind===`files`?w.value:void 0,A=e=>{s(e),d(null)},j=(e,t)=>{p(e),v(t).then(e=>{e||Is(`error`,a(`Copy unavailable`))})},M=t=>{let r=new AbortController;x.current=r,b(t.path),Rs(Kf),Ff(async i=>{let a=await e.workbenchRead({kind:`file-part`,path:t.path,offset:i,...n?{location:n}:{}},r.signal);if(r.signal.aborted)throw Error(`unavailable`);if(a.kind===`error`)throw Error(a.error.code);return a.value}).then(e=>{if(!r.signal.aborted)return Vf(e,t.name)}).catch(e=>{if(r.signal.aborted)return;let n=e instanceof Error?e.message:String(e);Is(`error`,a(`Download of {path} failed: {error}`,{path:t.name,error:n===`oversize`?a(`the file is larger than the 64 MiB download limit`):nr(a,n)}),Kf)}).finally(()=>{x.current===r&&(x.current=null,b(null))})},N=u?.trim().toLowerCase()??``,P=k?.entries.filter(e=>!N||e.name.toLowerCase().includes(N));return(0,X.jsxs)(`div`,{className:`files-panel`,children:[(0,X.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,X.jsx)(`button`,{type:`button`,className:`crumb${o?``:` active`}`,title:n?`${a(`Conversation folder:`)} ${n.cwd}`:void 0,disabled:!n,onClick:()=>A(``),children:n?Uf(n.cwd):a(`Not observed`)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb`,title:a(`Refresh files`),"aria-label":a(`Refresh files`),disabled:!t,onClick:()=>{w.refresh(),T.refresh()},children:(0,X.jsx)(Xi,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`crumb${u===null?``:` active`}`,"aria-label":a(`Filter this folder…`),title:a(`Filter this folder…`),"aria-pressed":u!==null,disabled:!k,onClick:()=>d(u===null?``:null),children:(0,X.jsx)(Ji,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`crumb${m?` active`:``}`,"aria-label":a(`About this panel`),title:a(`About this panel`),"aria-expanded":m,onClick:()=>g(e=>!e),children:(0,X.jsx)(pa,{"aria-hidden":`true`})}),Wf(o).map(e=>(0,X.jsxs)(`span`,{className:`crumb-seg`,children:[(0,X.jsx)(Ma,{"aria-hidden":`true`}),(0,X.jsx)(`button`,{type:`button`,className:`crumb${e.path===o?` active`:``}`,title:e.path,onClick:()=>A(e.path),children:e.label})]},e.path))]}),m&&(0,X.jsx)(`p`,{className:`files-policy`,children:a(`Readonly preview · references send paths, not file contents · a download is the file's own bytes, unredacted`)}),u!==null&&(0,X.jsxs)(`label`,{className:`file-filter`,children:[(0,X.jsx)(Ji,{"aria-hidden":`true`}),(0,X.jsx)(`input`,{autoFocus:!0,value:u,"aria-label":a(`Filter this folder…`),placeholder:a(`Filter this folder…`),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&d(null)}}),(0,X.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close`),onClick:()=>d(null),children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]}),w.error&&(0,X.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:nr(a,w.error)}),(0,X.jsxs)(`section`,{className:`file-list`,"aria-label":a(`File list`),children:[t?!k&&!w.error?(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(`Reading files…`)}):null:(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(n?`Files appear once this folder has been observed.`:`The conversation folder has not been observed.`)}),k&&k.parent!=null&&!N&&(0,X.jsxs)(`button`,{type:`button`,className:`file-item dir`,"aria-label":a(`Parent folder`),title:a(`Parent folder`),onClick:()=>A(k.parent??``),children:[(0,X.jsx)(ga,{className:`file-icon`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`file-name`,children:`..`})]}),P?.map(e=>(0,X.jsxs)(`div`,{className:`file-item ${e.directory?`dir`:`file`}${c===e.path?` selected`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`file-main`,"aria-current":c===e.path?`true`:void 0,title:e.path,onClick:()=>{e.directory?A(e.path):c!==e.path&&(l(e.path),D())},children:[e.directory?(0,X.jsx)(ga,{className:`file-icon`,"aria-hidden":`true`}):(0,X.jsx)(_a,{className:`file-icon`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`file-name`,children:e.name})]}),!e.directory&&(0,X.jsx)(`button`,{type:`button`,className:`file-attach download${y===e.path?` busy`:``}`,"aria-label":a(`Download file {path}`,{path:e.name}),title:a(`Download file {path}`,{path:e.name}),"aria-busy":y===e.path,disabled:!t||!!w.error||y!==null,onClick:()=>M(e),children:(0,X.jsx)(Sa,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach ref`,"aria-label":a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),title:a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),disabled:!t||!!w.error,onClick:()=>i(e.path),children:(0,X.jsx)(ca,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${_&&f===`name:${e.path}`?` copied`:``}`,"aria-label":a(`Copy name {path}`,{path:e.name}),title:a(`Copy name {path}`,{path:e.name}),onClick:()=>j(`name:${e.path}`,e.name),children:_&&f===`name:${e.path}`?(0,X.jsx)(Fa,{"aria-hidden":`true`}):(0,X.jsx)(Da,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`file-attach copy${_&&f===`path:${e.path}`?` copied`:``}`,"aria-label":a(`Copy path {path}`,{path:e.name}),title:a(`Copy path {path}`,{path:e.name}),onClick:()=>j(`path:${e.path}`,n?Gf(n.cwd,e.path):e.path),children:_&&f===`path:${e.path}`?(0,X.jsx)(Fa,{"aria-hidden":`true`}):(0,X.jsx)(Aa,{"aria-hidden":`true`})})]},e.path)),t&&!w.error&&P?.length===0&&(N?(0,X.jsx)(`p`,{className:`panel-empty`,children:a(`No matching files`)}):(0,X.jsx)(`p`,{className:`panel-empty`,children:a(`No visible files`)})),k?.limited&&(0,X.jsx)(`p`,{className:`inspector-note`,children:a(`Bounded listing; narrow the directory to see more.`)})]}),(0,X.jsx)(Yf,{path:t?c:null,preview:T,onClose:()=>l(null)})]})}function Yf({path:e,preview:t,onClose:n}){let{t:r}=Z();if(!e)return null;let i=t.value?.kind===`file`&&t.value.path===e?t.value:void 0;return(0,X.jsxs)(`section`,{className:`file-preview`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(_a,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{title:e,children:Uf(e)}),(0,X.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":r(`Close preview`),title:r(`Close preview`),onClick:n,children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]}),t.loading&&(0,X.jsx)(`p`,{role:`status`,children:r(`Reading…`)}),!t.loading&&t.error&&(0,X.jsx)(`p`,{role:`alert`,children:nr(r,t.error)}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(qf,{path:i.path,text:i.text}),i.limited&&(0,X.jsx)(`p`,{className:`inspector-note`,children:r(`File preview is limited; this is not the complete file.`)})]})]})}var Xf=`未命名章节`;function Zf(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Qf(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Zf(r||Xf),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Xf}})}function $f(e){return e.length>=2}function ep(e){let t=0,n=0;return e.split(`
|
|
44
|
+
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function tp({text:e}){return(0,X.jsx)(`pre`,{className:`scm-diff-pre`,children:ep(e).map(({text:e,key:t})=>{let n=``;return[`diff --git`,`index `,`new file`,`deleted file`,`old mode`,`new mode`,`similarity index`,`rename `,`copy `,`Binary files`,`---`,`+++`].some(t=>e.startsWith(t))?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,X.jsx)(`div`,{className:`scm-diff-line ${n}`,"data-retained-field":e?!0:void 0,children:e||` `},t)})})}function np({text:e,view:t,setView:n}){let{t:r}=Z(),[i,a]=(0,h.useState)(!0),[o,s]=(0,h.useState)(1),[c,l]=(0,h.useState)([]),[u,d]=(0,h.useState)(null),f=(0,h.useRef)(1),p=(0,h.useRef)(null),m=e.split(`
|
|
45
|
+
`);return(0,h.useLayoutEffect)(()=>{if(t!==`markdown`)return;if(!e){l([]);return}let n=Array.from(p.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=Qf(n.map(e=>({level:Number(e.tagName[1]),label:e.textContent??``})));r.forEach((e,t)=>{n[t].id=`preview-${e.id}`}),l(r)},[e,t]),(0,X.jsxs)(`div`,{className:`fp-preview`,children:[(0,X.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,X.jsxs)(`label`,{children:[r(`View`),(0,X.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,X.jsx)(`option`,{value:`raw`,children:r(`Raw text / lines`)}),(0,X.jsx)(`option`,{value:`markdown`,children:r(`Safe Markdown`)}),(0,X.jsx)(`option`,{value:`diff`,children:r(`Observed diff`)})]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),children:r(i?`Wrap: on`:`Wrap: off`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.min(2,e+.1)),children:r(`Zoom +`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.max(.8,e-.1)),children:r(`Zoom −`)}),(0,X.jsx)(Vs,{className:`output-copy`,text:u?m.slice(u.start-1,u.end).join(`
|
|
46
|
+
`):e})]}),(0,X.jsx)(`p`,{className:`fp-notice`,children:r(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,X.jsx)(`div`,{style:{fontSize:`${o}em`},children:t===`markdown`?(0,X.jsxs)(`div`,{className:`fp-toc-layout`,children:[$f(c)&&(0,X.jsx)(`nav`,{className:`fp-toc`,"aria-label":r(`Page headings`),children:c.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,X.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,"data-retained-field":!0,children:(0,X.jsx)(qs,{text:e})})]}):t===`diff`?(0,X.jsx)(tp,{text:e}):(0,X.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:ep(e).map(({text:e,number:t,key:n})=>(0,X.jsxs)(`div`,{className:`fp-line ${u&&t>=u.start&&t<=u.end?`sel`:``}`,children:[(0,X.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":r(`Select page line {line}`,{line:t}),onClick:e=>{e.shiftKey||(f.current=t),d({start:Math.min(f.current,t),end:Math.max(f.current,t)})},children:t}),(0,X.jsx)(`span`,{className:`fp-code-text`,"data-retained-field":e?!0:void 0,children:e||` `})]},n))})}),u&&(0,X.jsxs)(`footer`,{className:`fp-foot`,children:[r(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:r(`Clear selection`)})]})]})}function rp({client:e,seed:t}){let{t:n,tx:r}=Z(),i=vs(e,t),[a,o]=(0,h.useState)(),[s,c]=(0,h.useState)(`raw`),l=i.page;return(0,X.jsxs)(`section`,{className:`scm-body`,children:[(0,X.jsx)(oc,{pager:i}),(0,X.jsx)(`p`,{children:n(`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`)}),(0,X.jsx)(`div`,{className:`scm-files-list`,children:l&&!(`kind`in l)&&l.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,i=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,X.jsxs)(`article`,{className:`scm-file`,children:[(0,X.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,X.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>{l.request.scope.kind!==`workspace`&&l.request.snapshotSeq!==null&&(c(`raw`),o(gs(l.request.storeId,l.request.scope,l.request.snapshotSeq,i)))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,X.jsx)(ac,{client:e,cursor:a,preview:{view:s,render:e=>(0,X.jsx)(np,{text:e,view:s,setView:c})}},`${a.recordId}:${a.recordVersion}`)]})}var ip=[`contents`,`checks`,`changes`,`reviews`];function ap({client:e,seed:t}){let{t:n,tx:r}=Z(),[i,a]=(0,h.useState)(`contents`);return(0,X.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,X.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,X.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:ip.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,X.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,X.jsx)(sc,{client:e,seed:t}):(0,X.jsx)(rp,{client:e,seed:{...t,reader:i}},i)})]})}var op={relative:`Enter a full path, for example ~/project.`,invalid:`This folder does not exist. Check the path.`,forbidden:`This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).`,unavailable:`This folder could not be read right now; it may lack read permission. Try again.`},sp=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function cp(e,t){let n=e.startsWith(`/`)?`/`:`\\`,r=(e,t)=>e.endsWith(n)?e+t:e+n+t,i=!!t&&(e===t||e.startsWith(r(t,``))),a=i?t:/^(?:\\\\[^\\]+\\[^\\]+|[A-Za-z]:\\|\/)/.exec(e)?.[0]??``;if(!a)return{inside:i,trail:[{name:e,path:e}]};let o=i?[]:[{name:a===`/`?`/`:a.replace(/\\$/,``),path:a}],s=a;for(let t of e.slice(a.length).split(/[\\/]/).filter(Boolean))s=r(s,t),o.push({name:t,path:s});return{inside:i,trail:o}}function lp({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=Z(),[u,d]=(0,h.useState)(),[f,p]=(0,h.useState)(n??t),[m,g]=(0,h.useState)(!1),[_,v]=(0,h.useState)(``),[y,b]=(0,h.useState)(!0),[x,S]=(0,h.useState)(!0),[C,w]=(0,h.useState)(!1),[T,E]=(0,h.useState)(null),D=(0,h.useRef)(!0),O=(0,h.useRef)(void 0),k=(0,h.useRef)(n??t),A=(0,h.useRef)(null),j=(0,h.useRef)(null),M=async t=>{O.current?.abort();let n=new AbortController;O.current=n,b(!0),E(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&D.current){if(O.current=void 0,b(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),p(r.value.path),g(!1),v(``),r.value;E({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,h.useRef)(M);(0,h.useEffect)(()=>(D.current=!0,N.current(k.current).then(()=>{D.current&&S(!1)}),()=>{D.current=!1,O.current?.abort()}),[]),(0,h.useEffect)(()=>{m&&A.current?.select()},[m]),(0,h.useEffect)(()=>{j.current&&(j.current.scrollLeft=j.current.scrollWidth)});let P=e=>{C||M(e)},F=()=>{let e=f.trim();C||(sp(e)?M(e):E({step:`read`,code:`relative`}))},I=(m||!u)&&f.trim()||u?.path||``,L=!C&&!y&&!!I,R=async n=>{if(C||!n||y&&n===u?.path)return;if(n!==u?.path&&!sp(n)){E({step:`read`,code:`relative`});return}w(!0),E(null);let r=n===u?.path?u.path:(await M(n))?.path;if(!D.current)return;if(!r){w(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),D.current&&a()}catch(e){D.current&&(E({step:`open`,code:e instanceof Error?e.message:`unavailable`}),w(!1))}return}if(!e.workbenchCommand){E({step:`open`,code:`unavailable`}),w(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(D.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(E({step:`open`,code:`unsupported-context`}),w(!1))}else E({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),w(!1)}},z=u?cp(u.path,r):void 0,B=_.trim().toLowerCase(),V=u?.entries.filter(e=>e.name.toLowerCase().includes(B))??[],ee=T&&(T.step===`read`&&op[T.code]?l(op[T.code]):nr(l,T.code));return(0,X.jsxs)(dc,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,X.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,X.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,X.jsx)(`h3`,{children:l(`Recent folders`)}),(0,X.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,X.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:C,onClick:()=>e.current?a():void R(e.path),children:[(0,X.jsx)(ga,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,X.jsxs)(`div`,{className:`cwd-location`,children:[z&&!m?(0,X.jsxs)(`nav`,{ref:j,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:C,onClick:()=>P(`~`),children:[(0,X.jsx)(fa,{"aria-hidden":`true`}),z.inside&&(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),z.trail.map((e,t)=>(0,X.jsxs)(h.Fragment,{children:[(t>0||z.inside)&&(0,X.jsx)(Ma,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,X.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:C,onClick:()=>P(e.path),children:e.name})]},e.path))]}):x?(0,X.jsx)(`div`,{className:`cwd-crumbs`}):(0,X.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),F()},children:(0,X.jsx)(`input`,{ref:A,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:f,disabled:C,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{p(e.target.value),T?.step===`read`&&E(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),g(!1),p(u.path),E(null))}})}),u&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":m,disabled:C,onClick:()=>{p(u.path),g(!m),E(null)},children:(0,X.jsx)(xa,{"aria-hidden":`true`})})]}),u&&(0,X.jsxs)(`label`,{className:`cwd-filter`,children:[(0,X.jsx)(Ji,{"aria-hidden":`true`}),(0,X.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:_,disabled:C,spellCheck:!1,autoComplete:`off`,onChange:e=>v(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":y||void 0,children:[y&&(0,X.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,X.jsxs)(`button`,{type:`button`,disabled:C,onClick:()=>P(u.parent),children:[(0,X.jsx)(La,{}),l(`Parent folder`)]}),V.map(e=>(0,X.jsxs)(`button`,{type:`button`,disabled:C,onClick:()=>P(e.path),children:[(0,X.jsx)(ga,{}),(0,X.jsx)(`span`,{children:e.name})]},e.path)),u&&!y&&V.length===0&&(0,X.jsx)(`p`,{className:`cwd-picker-note`,children:l(B?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,X.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),ee&&(0,X.jsxs)(`p`,{role:`alert`,children:[ee,T?.code===`registry-locked`&&(0,X.jsxs)(X.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,X.jsxs)(`footer`,{className:`cwd-footer`,children:[I&&(0,X.jsxs)(`p`,{className:`cwd-target`,children:[(0,X.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,X.jsx)(`code`,{children:I})]}),(0,X.jsx)(`button`,{type:`button`,className:`primary`,disabled:!L,"aria-busy":C||void 0,onClick:()=>void R(I),children:l(C?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function up(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var dp=[`today`,`yesterday`,`earlier`];function fp(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function pp(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=fp(t(i),n);r.set(e,[...r.get(e)??[],i])}return dp.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function mp(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function hp(e,t,n=Date.now()){let r=new Date(e);return fp(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function gp({onConversation:e,disabled:t=!1}){let{t:n}=Z();return(0,X.jsx)(`div`,{className:`lp-new`,children:(0,X.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,X.jsx)(Zi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function _p(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var vp=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),yp=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function bp(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var xp={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},Sp={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},Cp={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},wp=e=>`conversation-row:${e}`;function Tp(e,t){return t.kind===`refused`?{refusal:{text:Sp[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function Ep(e,t){let{t:n}=Z(),[r,i]=(0,h.useState)(()=>new Map),a=(0,h.useRef)(!0);(0,h.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Rs(wp(c)),l({pending:o}),bp(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=Tp(o,e);l(r),i&&Is(`error`,n(i.text,{code:i.code}),wp(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,vp(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,yp(e,t))}}function Dp({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=Z(),d=u===`zh`?`zh-CN`:`en-GB`,[f,p]=(0,h.useState)(null),m=f!==null,g=(0,h.useRef)(null),_=(0,h.useRef)(null),v=(0,h.useRef)(!1);(0,h.useEffect)(()=>{let e=g.current;if(!m||!e){v.current&&_.current?.focus({preventScroll:!0}),v.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),v.current=!0,p(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[m]);let y=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),b=(0,X.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":y,title:y,children:e.origin===`terminal`?(0,X.jsx)(Hi,{"aria-hidden":`true`}):(0,X.jsx)(ra,{"aria-hidden":`true`})}),x=()=>{if(f===null)return;let t=_p(f);t===null?Is(`error`,l(`A name can have at most {count} characters.`,{count:100}),wp(e.id)):(v.current=!0,p(null),t!==e.title&&s?.(t))},S=!!o||!!a?.pending,C=a?.pending?l(xp[a.pending]):a?.unknown?l(Cp[a.unknown.action],{code:a.unknown.code}):``;return m?(0,X.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),x()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},children:[(0,X.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[b,(0,X.jsx)(`input`,{ref:g,className:`session-rename-input`,value:f,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>p(e.target.value)})]}),(0,X.jsxs)(`span`,{className:`session-actions`,children:[(0,X.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,X.jsx)(Fa,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{v.current=!0,p(null)},children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]})]}):(0,X.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[b,(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,X.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,X.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:hp(e.updatedAt,d)})]}),c&&(0,X.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,X.jsx)(`button`,{ref:_,type:`button`,className:`session-action`,disabled:S,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>p(e.title),children:(0,X.jsx)(xa,{"aria-hidden":`true`})}),(0,X.jsx)(`button`,{type:`button`,className:`session-action`,disabled:S,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,X.jsx)(Yi,{"aria-hidden":`true`}):(0,X.jsx)(Va,{"aria-hidden":`true`})})]}),C&&(0,X.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:C})]})}function Op({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=Z(),a=e.value?.entries??[];return(0,X.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,X.jsx)(za,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,X.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,X.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,X.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,nr(i,e.error)]}),e.loading&&(0,X.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,X.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,X.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,X.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,X.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var kp={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function Ap({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,h.useState)(!0);return(0,X.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,X.jsxs)(`header`,{className:`lp-section-header`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,X.jsx)(Pa,{"aria-hidden":`true`}):(0,X.jsx)(Ma,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,X.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,X.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,X.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function jp({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=Z(),[o,s]=(0,h.useState)(new Set),c=up(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,X.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,X.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,X.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,X.jsx)(Ma,{"aria-hidden":`true`}):(0,X.jsx)(Pa,{"aria-hidden":`true`})}):(0,X.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,X.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,X.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,X.jsx)(wa,{"aria-hidden":`true`}):(0,X.jsx)(ra,{"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,X.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,X.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,X.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Mp({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=Z(),a=e.page;return(0,X.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(jp,{runs:a.records.flatMap(e=>e.kind===`run`&&!r.includes(e.projection.runId)?[e.projection]:[]),scope:t,snapshot:a.request.snapshotSeq??void 0,onScope:n}),a.records.length===0&&(0,X.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,X.jsx)(oc,{pager:e,compact:!0})]})}function Np({client:e,workspace:t,retained:n,executionStopped:r=!1,taskId:i,scope:a,runs:o,snapshot:s,activeRuns:c,canCancel:l,canceling:u,onCancel:d,onTask:f,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,actionCurrent:C=()=>!S,onConversationsChanged:w,workflows:T,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:A,canCancelWorkflow:j,onCancelWorkflow:M}){let{t:N,tx:P}=Z(),[F,I]=(0,h.useState)(``),[L,R]=(0,h.useState)(!1),z=is(e,L,!0),B=z.refresh,V=Ep(e,e=>{B(),w?.(e)}),ee=n?.workspace??t,H=n?.client??e,te=ee?{reader:`tasks`,storeId:ee.storeId,scope:{kind:`workspace`,id:ee.workspaceId},snapshotSeq:n?.workspace.committedSeq??null,after:null,limit:50}:null,ne=vs(H,te),re=vs(H,i&&te&&ee?{...te,reader:`runs`,scope:{kind:`task`,id:i},snapshotSeq:s??ee.committedSeq}:null),ie=ne.page&&!(`kind`in ne.page)?ne.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],ae=c?.status===`complete`?c.runs:[],oe=ie.filter(e=>!ae.some(t=>t.taskId===e.owner.taskId)),se=i&&(0,X.jsxs)(`section`,{className:`task-conversations`,"aria-label":N(`Task conversations`),children:[(0,X.jsx)(`h3`,{children:N(`Task conversations`)}),(0,X.jsx)(Mp,{pager:re,scope:a,onScope:p,exclude:ae.map(e=>e.runId)},i)]}),[ce,U]=(0,h.useState)(()=>new Set),le=e=>{let t=E.find(t=>t.runId===e.id)?.conversationId??null;return(0,X.jsxs)(`div`,{className:`conversation-group`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>A?.(e,t),title:e.goal,children:[(0,X.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,X.jsxs)(`span`,{className:`session-sub`,children:[N(`Cadence workflow`),` · `,P(e.phase),` · `,P(e.status)]})]})]}),M&&(0,X.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:ce.has(e.id)||!j?.(e),onClick:()=>{!ce.has(e.id)&&j?.(e)&&(U(t=>new Set(t).add(e.id)),M(e).finally(()=>U(t=>{let n=new Set(t);return n.delete(e.id),n})))},children:[(0,X.jsx)(Wi,{"aria-hidden":`true`}),N(`Cancel workflow — request stop`)]})]},e.id)},ue=m.filter(e=>wl(e.status)),W=m.filter(e=>!ue.includes(e)),de=e=>T?.findLast(t=>E.some(n=>n.runId===t.id&&n.conversationId===e.id)),fe=e=>{let t=wl(e.status),n=t&&e.status!==`starting`,r=n||e.status===`completed`?de(e):void 0,i=r?P(lf(r)):e.cadence&&n?N(`Discussing`):e.status===`completed`?``:P(e.status);return(0,X.jsx)(Dp,{chat:e,selected:e.id===y,state:i,tone:r?`running`:e.status,onOpen:()=>b?.(e.id),row:V.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>{C()&&V.archive(e.id,t)},onRename:t||e.archived?void 0:t=>{C()&&V.rename(e.id,t)}},e.id)},pe=W.filter(e=>mp(e.title,F)),G=oe.filter(e=>mp(e.goal,F));return(0,X.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,X.jsx)(Ic,{...O,represented:!r&&O.project?[...(T??[]).map(e=>Fc(O.project,`workflow`,e.id,e.epoch)),...ue.flatMap(e=>e.live?[Fc(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,X.jsx)(gp,{onConversation:x}),!r&&(0,X.jsxs)(Ap,{title:N(`Running work`),count:c?.status===`complete`&&T&&!D&&g?String(ae.length+ue.length+T.length):N(`Not observed`),className:`running-conversations`,children:[c?.status!==`complete`&&(0,X.jsx)(`p`,{className:`panel-hint`,children:N(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,X.jsx)(`p`,{className:`panel-hint`,children:N(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,X.jsx)(`p`,{className:`panel-hint`,children:N(`Conversation activity unavailable.`)}),ue.map(fe),T?.map(le),c?.status===`complete`&&ae.length===0&&ue.length===0&&T?.length===0&&!D&&g&&(0,X.jsx)(`p`,{className:`panel-hint`,children:N(`No active runs`)}),ae.map(e=>{let t=ie.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,X.jsxs)(`div`,{className:`conversation-group`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item${i===e.taskId&&a?.kind===`task`?` active`:``}`,onClick:()=>f(e.taskId,t),title:e.runId,children:[(0,X.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:t??N(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,X.jsxs)(`span`,{className:`session-sub`,children:[P(e.kind),` · `,P(e.stage)]})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!l||u.has(e.runId),onClick:()=>d(e.runId),children:[(0,X.jsx)(Wi,{"aria-hidden":`true`}),N(`Cancel run — request stop`)]}),i===e.taskId&&(0,X.jsx)(jp,{runs:o.filter(t=>t.runId===e.runId),scope:a,onScope:p})]},e.runId)})]}),(0,X.jsxs)(Ap,{title:N(L?`Archived conversations`:`Conversation history`),count:L?z.value?`${z.value.entries.length}${z.value.next||z.canPrevious?`+`:``}`:N(`Not observed`):ee?ne.page&&!(`kind`in ne.page)?`${W.length+oe.length}${ne.page.next||ne.canPrevious||_?`+`:``}`:N(`Not observed`):`${W.length}${_?`+`:``}`,className:`grow`,actions:(0,X.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":L,title:N(L?`Back to history`:`Show archived`),"aria-label":N(L?`Back to history`:`Show archived`),onClick:()=>R(e=>!e),children:(0,X.jsx)(Va,{"aria-hidden":`true`})}),children:[L&&(0,X.jsx)(Op,{list:z,unavailable:S,onBack:()=>R(!1),row:fe}),(0,X.jsxs)(`nav`,{"aria-label":N(`Tasks`),className:`task-list`,hidden:L,children:[(W.length>0||oe.length>0)&&(0,X.jsxs)(`label`,{className:`lp-filter`,children:[(0,X.jsx)(Ji,{"aria-hidden":`true`}),(0,X.jsx)(`input`,{type:`search`,value:F,placeholder:N(`Filter conversations…`),"aria-label":N(`Filter conversations…`),onChange:e=>I(e.target.value)}),F&&(0,X.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:N(`Clear filter`),"aria-label":N(`Clear filter`),onClick:()=>I(``),children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]}),S&&W.length>0&&(0,X.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),pp(pe,e=>e.updatedAt).map(e=>(0,X.jsxs)(`div`,{className:`lp-time-group`,children:[(0,X.jsx)(`h3`,{className:`lp-time-label`,children:N(kp[e.key])}),e.items.map(fe)]},e.key)),G.length>0&&(0,X.jsx)(`h3`,{className:`lp-time-label`,children:N(`Tasks`)}),G.map(e=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===i&&a?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===i&&a?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>f(e.owner.taskId,e.goal),children:[(0,X.jsx)(`span`,{className:`session-icon`,children:(0,X.jsx)(ra,{"aria-hidden":`true`})}),(0,X.jsxs)(`span`,{className:`session-info`,children:[(0,X.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,X.jsx)(`span`,{className:`session-sub`,children:N(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===i&&se]},e.owner.taskId)),pe.length===0&&G.length===0&&(W.length>0||oe.length>0)&&(0,X.jsx)(`p`,{className:`panel-hint`,role:`status`,children:N(`No listed conversation matches. Pages not loaded are not searched.`)}),ne.page&&!(`kind`in ne.page)&&oe.length===0&&W.length===0&&!_&&(0,X.jsx)(`p`,{className:`panel-hint`,children:N(`No conversations yet.`)}),v,ee&&(0,X.jsx)(oc,{pager:ne,compact:!0})]}),!L&&!G.some(e=>e.owner.taskId===i)&&se]})]})}var Pp=[`queued`,`running`];function Fp(e){let t=(0,h.useRef)({client:e.client,generation:0});return t.current.client!==e.client&&(t.current={client:e.client,generation:t.current.generation+1}),(0,X.jsx)(Ip,{...e},`${t.current.generation}:${e.agent.runId}:${e.agent.stepId??``}`)}function Ip({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i,canCancelWorkflow:a}){let{t:o,tx:s}=Z(),[c,l]=(0,h.useState)(1e3),u=ns(e,{kind:`workflow`,id:t.runId},c),d=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,f=t.stepId?d?.steps.find(e=>e.id===t.stepId):void 0,p=f?Pp.includes(f.status):!1;(0,h.useEffect)(()=>{d&&!Pp.includes(d.status)&&l(0)},[d]);let m=ns(e,t.stepId&&(!d||f?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!d?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,h.useMemo)(()=>g?ud(g):null,[g]),[v,y]=(0,h.useState)(!1),b=ns(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null,v&&p?1e3:0),x=(0,h.useRef)(null),S=(0,h.useRef)(!0),C=(0,h.useRef)(null),[w,T]=(0,h.useState)(!1),E=(0,h.useRef)(0);return Oc(x,C,S),(0,X.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":o(`Subagent context`),children:[(0,X.jsxs)(`header`,{className:`conversation-header`,children:[(0,X.jsxs)(`div`,{className:`conversation-heading`,children:[(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,X.jsx)(wa,{"aria-hidden":`true`}),(0,X.jsx)(`h2`,{title:t.stepId??t.runId,children:f?`${s(f.kind)} · ${t.label}`:t.label}),(0,X.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?o(`Subagent`):o(`Workflow`)})]}),(f??d)&&(0,X.jsx)(`span`,{className:`ep-state ${(f??d)?.status}`,children:s((f??d)?.status??``)})]}),(0,X.jsx)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current&&t.scrollTop<E.current&&t.scrollHeight-t.scrollTop-t.clientHeight>=80&&(S.current=!1,T(!0)),E.current=t.scrollTop},children:(0,X.jsxs)(`div`,{ref:C,children:[u.error&&(0,X.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[u.error,` ·`,` `,o(`State unavailable is not completion. No automatic resubmission.`)]}),d&&t.stepId&&(0,X.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[o(`Workflow`),`: `,d.goal,` · `,s(d.phase),` · `,s(d.status)]}),!t.stepId&&(0,X.jsx)(vf,{client:e,id:t.runId,canCancelWorkflow:a,onOpenAgent:i}),t.stepId&&m.error&&(0,X.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,X.jsx)(Id,{turn:_}):(0,X.jsx)(`p`,{className:`inspector-note`,children:o(`No retained transcript observed yet; absence is not proof of no activity.`)})),f&&(0,X.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":o(`Step result`),children:[(0,X.jsx)(`h3`,{children:o(`Step result`)}),f.exitCode!==null&&(0,X.jsxs)(`p`,{children:[o(`Exit code`),`: `,f.exitCode]}),f.text?(0,X.jsx)(qs,{text:f.text}):(0,X.jsx)(`p`,{className:`inspector-note`,children:o(`No result yet.`)}),f.truncated&&(0,X.jsx)(`p`,{children:o(`Preview is truncated.`)}),(0,X.jsx)(`button`,{type:`button`,className:`ghost`,"aria-expanded":v,onClick:()=>y(e=>!e),children:o(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,X.jsx)(af,{file:b.value}),v&&b.error&&(0,X.jsx)(`p`,{role:`alert`,children:b.error})]})]})}),w&&(0,X.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{S.current=!0,Dc(x.current,!0),E.current=x.current?.scrollTop??0,T(!1)},children:[(0,X.jsx)(Ba,{"aria-hidden":`true`}),o(`Latest messages`)]})]})}function Lp({path:e,disabled:t=!1,onClick:n}){let{t:r}=Z(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,X.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,X.jsx)(ga,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Rp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,X.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,X.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,X.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function zp({dot:e,tip:t,latency:n,children:r}){let{t:i}=Z(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,X.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,X.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,X.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function Bp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function Vp({clock:e}){let{t}=Z();return e===`unavailable`?(0,X.jsx)(Rp,{tone:`faint`,role:`status`,children:t(`Conversation activity unavailable.`)}):e===`idle`?null:(0,X.jsx)(Hp,{since:e,label:t(`Working`)})}function Hp({since:e,label:t}){let[n,r]=(0,h.useState)(Date.now);(0,h.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?Bp(n-e):``;return(0,X.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,X.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,X.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}var Up={folder:`Choose a working folder`,connecting:`Connection`,updating:`Connection`,chat:`Chat ready`,task:`Task up to date`,stopped:`Execution stopped`,"not-started":`Execution not started`,independent:`Browsing only`};function Wp(e){return Xo(e)||e===`Access revoked; explicit token re-entry required.`}function Gp({phase:e,entryError:t,projectStatus:n,projectError:r,viewerError:i,historyError:a,readErrors:o=[],prepareOnly:s,retained:c,latency:l,onRefresh:u}){let{t:d,tx:f}=Z(),p=e=>{let t=e===`socket-timeout`?d(`No recent update from the task connection`):e===`socket-closed`?d(`The task connection closed`):f(e);return t!==e&&/^[a-z][a-z-]*$/.test(e)?`${t} (${e})`:t},m=e===`updating`||e===`connecting`,g=(0,h.useRef)(void 0);t||r||i||a?g.current={entryError:t,projectError:r,viewerError:i,historyError:a}:m||(g.current=void 0);let _=g.current,v=Wp(_?.entryError)||Wp(_?.projectError)||Wp(_?.viewerError),y=!!_||o.some(([,e])=>e),b=d(v?`Sign-in required`:y?`Connection`:Up[e]),x=v?`error`:m||y?``:e===`task`||e===`chat`?`ok`:``;return(0,X.jsxs)(`details`,{className:`workspace-connection`,onKeyDown:e=>{e.key===`Escape`&&e.currentTarget.open&&(e.currentTarget.open=!1,e.currentTarget.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,X.jsxs)(`summary`,{"aria-label":d(`Connection status: {state}`,{state:b}),children:[(0,X.jsx)(zp,{dot:x,tip:d(`Connection freshness is not execution outcome.`),latency:m||y?null:l,children:b}),(0,X.jsx)(ja,{"aria-hidden":`true`})]}),(0,X.jsxs)(`div`,{className:`connection-details`,children:[(0,X.jsx)(`strong`,{children:d(`Observation status`)}),n&&(0,X.jsx)(`p`,{children:d(`Execution service: {status}`,{status:f(n)})}),e===`independent`&&(0,X.jsx)(`p`,{children:d(`This owner is running independently. Browsing history does not connect it to this workbench.`)}),(e===`stopped`||e===`not-started`)&&(0,X.jsx)(`p`,{children:d(`Ready to prepare execution`)}),y&&c&&(0,X.jsx)(`p`,{children:d(`Last known state`)}),_?.entryError&&(0,X.jsx)(`p`,{children:d(`Workbench observation: {code}.`,{code:p(_.entryError)})}),_?.projectError&&(0,X.jsx)(`p`,{children:d(`Project observation: {code}.`,{code:p(_.projectError)})}),_?.historyError&&(0,X.jsx)(`p`,{children:d(`Recorded history unavailable: {reason}.`,{reason:p(_.historyError)})}),s&&(0,X.jsx)(`p`,{children:d(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),o.map(([e,t])=>t&&(0,X.jsx)(`p`,{children:d(e,{code:p(t)})},e)),_?.viewerError&&(0,X.jsx)(`p`,{children:d(`Viewer observation: {code}.`,{code:p(_.viewerError)})}),(_?.viewerError===`stale`||_?.projectError===`stale`)&&(0,X.jsx)(`p`,{children:d(`Context changed. Read the current state before confirming a plan.`)}),m&&!_&&(0,X.jsx)(`p`,{children:d(`Waiting for current state from this connection.`)}),v?(0,X.jsx)(`button`,{type:`button`,onClick:()=>{Gn(),window.location.reload()},children:d(`Sign in again`)}):(0,X.jsx)(`button`,{type:`button`,onClick:u,children:d(`Observe current state`)})]})]})}function Kp(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Vn();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:L(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,B(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function qp(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=L(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(te(r)):void 0,o=i?B(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(te(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Jp=.4,Yp=1.05;function Xp(e,t=`left`){return t===`left`?Math.min(300,e*.86):Math.min(380,e*.92)}function Zp(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Qp(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function $p(e,t){return e===`left`?t:-t}function em(e,t){return Math.max(-e,Math.min(0,-e+t))}function tm(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function nm(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:tm(r*Yp,n,t)>=Jp}var rm=`cadence-panel-layout-v1`,im={left:260,right:360,navigation:!0,inspector:!1};function am(e,t=600){return Math.max(220,Math.min(t,e))}function om(e){let t={...im};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=am(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function sm(e,t){let n=e<=900,r=n?Xp(e,`left`):am(t.left,e-560),i=n?Xp(e,`right`):am(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:am(e-560-s),rightMaximum:am(e-560-a)}}function cm({side:e,width:t,onResize:n,maximum:r}){let{t:i}=Z(),a=(0,h.useRef)(void 0);return(0,h.useEffect)(()=>()=>a.current?.(),[]),(0,X.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(am(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(am(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(am(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var lm=[],um={error:Ua,warning:Ha,info:ua};function dm({toast:e}){let{t}=Z(),[n,r]=(0,h.useState)(!1),[i,a]=(0,h.useState)(!1),o=n||i,s=ks(e.level);(0,h.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Ls(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=um[e.level];return(0,X.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,X.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,X.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Ls(e.id),children:(0,X.jsx)(zi,{"aria-hidden":`true`})})]})}function fm(){let e=(0,h.useSyncExternalStore)(zs,Bs,()=>lm);return(0,X.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,X.jsx)(dm,{toast:e},e.id))})}function pm(e,t,n,r){(0,h.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var mm=new Set([`auto`,`scroll`,`overlay`]);function hm(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&mm.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function gm(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function _m(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,h.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=Zp(r.clientX,window.innerWidth,n);i&&!hm(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=Qp(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Xp(window.innerWidth,r),h=m*Yp;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=$p(r,d);let b=em(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(tm(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?nm({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(gm(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var vm={system:[ea,`System`],light:[Ui,`Light`],dark:[$i,`Dark`]};function ym({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:f,content:p}){let{t:m,locale:g,setLocale:_}=Z(),[v,y]=(0,h.useState)(Kd),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(pr),[w,T]=vm[S],E=m(`Theme: {current}. Switch to {next}.`,{current:m(T),next:m(vm[hr(S)][1])}),{mobile:D,overlay:O,closeDrawer:k}=e,A=(0,h.useRef)(null),j=(0,h.useRef)(null),M=()=>{j.current&&(j.current.open=!1)};return _m({enabled:D,open:O,onOpenChange:e.setDrawer,container:A}),pm(A,O,!!O,k),(0,X.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,X.jsx)(Jd,{enabled:v,hero:b}),(0,X.jsxs)(`header`,{className:`topbar`,children:[(0,X.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":m(`Toggle conversation navigation`),"aria-expanded":D?O===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,X.jsx)(ia,{"aria-hidden":`true`})}),(0,X.jsxs)(`div`,{className:`topbar-flow`,children:[(0,X.jsxs)(`span`,{className:`brand`,children:[(0,X.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Yd,{})}),(0,X.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,X.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,X.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>_(g===`zh`?`en`:`zh`),children:[(0,X.jsx)(ma,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,X.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":E,"data-tip":E,onClick:()=>{let e=hr(S);mr(e),C(e)},children:(0,X.jsx)(w,{"aria-hidden":`true`})}),(0,X.jsxs)(`details`,{className:`more-menu`,ref:j,onKeyDown:e=>{e.key===`Escape`&&j.current&&(j.current.open=!1,j.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,X.jsx)(`summary`,{className:`chip`,"aria-label":m(`More`),title:m(`More`),children:(0,X.jsx)(Qi,{"aria-hidden":`true`})}),(0,X.jsxs)(`div`,{className:`more-menu-items`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":v,onClick:()=>{qd(!v),y(!v)},children:[(0,X.jsx)(Ui,{"aria-hidden":`true`}),g===`zh`?`环境光`:`Ambient light`,(0,X.jsx)(`span`,{"aria-hidden":`true`,children:v?`●`:`○`})]}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":m(`Observe current state`),onClick:()=>{M(),u()},children:[(0,X.jsx)(Xi,{"aria-hidden":`true`}),m(`Refresh status`)]}),f&&(0,X.jsxs)(`button`,{type:`button`,"aria-label":m(`Cadence service`),onClick:()=>{M(),f()},children:[(0,X.jsx)(qi,{"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`more-menu-text`,children:[m(`Cadence service`),(0,X.jsx)(`small`,{children:m(`Version, restart and upgrade.`)})]})]}),d&&(0,X.jsxs)(`button`,{type:`button`,"aria-label":m(`Disconnect this page`),title:m(`Return — accepted work continues`),onClick:()=>{M(),k(),d()},children:[(0,X.jsx)(oa,{"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`more-menu-text`,children:[m(`Disconnect this page`),(0,X.jsx)(`small`,{children:m(`Started work keeps running.`)})]})]}),(0,X.jsx)(`div`,{className:`more-menu-build`,title:lo?.buildId??m(`unbuilt source`),children:(0,X.jsx)(rr,{text:m(`Local browser build: {build}.`),slots:{build:(0,X.jsx)(`code`,{children:lo?.buildId??m(`unbuilt source`)})}})})]})]})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":m(`Toggle workspace panels`),"aria-expanded":D?O===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,X.jsx)(Ki,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r??m(`Files`)})]})]}),s,(0,X.jsxs)(`div`,{ref:A,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":m(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${O?` on`:``}`,onClick:k}),(0,X.jsx)(`section`,{className:`panel-drawer drawer-left${O===`left`?` open`:``}`,"aria-label":m(`Conversation navigation`),tabIndex:-1,inert:D?O!==`left`:!e.navigation||O===`right`,children:t}),(0,X.jsx)(cm,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,X.jsx)(`main`,{className:`main`,inert:O!==null,children:(0,X.jsx)(Ud.Provider,{value:x,children:p})}),(0,X.jsx)(cm,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,X.jsx)(`section`,{className:`panel-drawer drawer-right${O===`right`?` open`:``}`,"aria-label":m(`Files and history drawer`),tabIndex:-1,inert:D?O!==`right`:!e.inspector,children:(0,X.jsxs)(`div`,{className:`workbench-right`,children:[(0,X.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":m(`Workspace panels`),children:[i??(0,X.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,X.jsx)(ga,{"aria-hidden":`true`}),m(`Files`)]}),(0,X.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":m(`Collapse panel`),title:m(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,X.jsx)(Ma,{"aria-hidden":`true`})})]}),(0,X.jsx)(`div`,{className:`workbench-right-body`,children:n})]})})]}),(0,X.jsxs)(`footer`,{className:`statusbar`,children:[(0,X.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,X.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,X.jsx)(fm,{})]})}function bm(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function xm({cache:e}){let{t}=Z(),n=e?bm(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:nl(r.read),write:nl(r.write),miss:nl(r.miss),input:nl(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,X.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,X.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Ca,{})}),(0,X.jsxs)(`span`,{className:`bar-item-text`,children:[(0,X.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,X.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var Sm=31.42;function Cm({usage:e}){let{t}=Z(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?rl(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:nl(n),window:nl(r),percent:i}):t(`Context {used} tokens`,{used:nl(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,X.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,X.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:Sm,strokeDashoffset:+(Sm*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,X.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,X.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,X.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`ctx-val`,children:nl(n)}),r&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,X.jsx)(`span`,{className:`ctx-max`,children:nl(r)})]})]})})]})}function wm(){let[e,t]=(0,h.useState)(()=>{try{return om(localStorage.getItem(rm))}catch{return om(null)}}),[n,r]=(0,h.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=sm(n,e),s=(0,h.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(rm,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,h.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}var Tm=({epoch:e,runId:t,childRunId:n},r)=>JSON.stringify([e,t,n,r]);function Em(e,t,n,r,i=`en`){let a=(e,t)=>er(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=new Map;for(let e of o){if(e.kind!==`capture-fact`)continue;let t=e.capture.event;if(t.kind!==`tool-start`&&t.kind!==`tool-end`||!t.name)continue;let n=Tm(e.link,t.callId);s.has(n)?s.get(n)!==t.name&&s.set(n,null):s.set(n,t.name)}let c=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.capture.event:null,o=r?.kind===`tool-start`||r?.kind===`tool-end`?r.name:e.kind===`capture-fact`&&r?.kind===`tool-update`?s.get(Tm(e.link,r.callId)):void 0,c=e.kind===`capture-fact`?e.link.childRunId:null,l=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,...o?{meta:{tool:o}}:{},lane:l,group:`${c??`owner`}:${l}`,groupLabel:`${c??a(`Owner`)} · ${er(i,l)}`,kind:l===`tools`?`tool`:l===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:c??a(`owner`)}),status:a(`recorded fact`),clock:e.kind===`capture-fact`?a(`Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.`,{child:e.link.childRunId,first:e.capture.source.firstObservedMs,last:e.capture.source.lastObservedMs}):a(`Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.`,{epoch:e.link.epoch,ms:e.observedMs}),...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),l;return{lang:i,onData(e){return l=e,()=>{l=void 0}},readState(){l?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:c.length}],activeId:e})},readSegments(t){t===e&&l?.({kind:`segs`,convId:t,segs:c,reset:!0})},readSegment(t,n){let r=c.findIndex(e=>e.key===n);t!==e||r<0||l?.({kind:`seg_detail`,convId:t,key:n,seg:c[r],detail:JSON.stringify(o[r],null,2),analysis:{position:a(`Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.`,{seq:o[r].committedSeq,ordinal:r+1})}})},openDetail(t,r){let i=o.find(e=>e.recordId===r);t===e&&i&&n(i)},searchHistory:r}}var Dm=`modulepreload`,Om=function(e){return`/ui/e88fdf359f1d74065570ec097fb5bd5f4ad647ecf4ba7d3c53f1c69aec37550a/`+e},km={},Am=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Om(t,n),t=s(t),t in km)return;km[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Dm,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function jm({client:e,seed:t,onSearch:n}){let{t:r}=Z(),i=vs(e,{...t,reader:`events`}),a=i.page;return(0,X.jsxs)(`section`,{className:`timeline-view`,children:[(0,X.jsx)(`p`,{children:r(`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`)}),(0,X.jsx)(oc,{pager:i}),a&&!(`kind`in a)&&(0,X.jsx)(Mm,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Mm({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=Z(),o=(0,h.useRef)(null),[s,c]=(0,h.useState)(!1),[l,u]=(0,h.useState)(!1),d=(0,h.useRef)(r);return d.current=r,(0,h.useEffect)(()=>{let e=!1,r;return Am(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Em(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,X.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,X.jsx)(sc,{client:e,seed:t})]})}var Nm=[[`tools`,Vi],[`context`,la],[`timeline`,ka],[`runs`,ha]];function Pm({api:e,onOpenProject:t,entryObservation:n,projectAccess:r,homeFolder:i,projectEntries:a,notices:o,discovery:s,onOpenService:c,project:l,onChooseFolder:u,onPrepareExecution:d,directoryNamespaces:f,previewModels:p,initialDraft:m,onDraftApplied:g}){let{t:_,tx:v}=Z(),[y]=(0,h.useState)(()=>e??uo(l?.id)),[b,x]=(0,h.useState)(()=>typeof window>`u`?``:window.location.hash),[S,C]=(0,h.useState)(!1),[w]=(0,h.useState)(qp),[T,E]=(0,h.useState)(w?.taskId??null),[D,O]=(0,h.useState)(()=>w?null:Hn()??crypto.randomUUID()),k=Jn(b,D??``),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(null),[P,F]=(0,h.useState)(w?`task`:`files`),[I,L]=(0,h.useState)(),[R,z]=(0,h.useState)(),[B,ee]=(0,h.useState)(),[te,ne]=(0,h.useState)(),[re,ie]=(0,h.useState)(0),[ae,oe]=(0,h.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Hn();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[se]=(0,h.useState)(()=>crypto.randomUUID()),ce=(0,h.useCallback)(()=>z(void 0),[]),[U,le]=(0,h.useState)(w?w.scope??{kind:`task`,id:w.taskId}:null),[ue]=(0,h.useState)(()=>new $o),W=r??ue,de=(0,h.useSyncExternalStore)(W.subscribe,W.snapshot,W.snapshot),fe=de?.source===`entry`?de.code:n?.error,pe=Wp(fe),G=ss(pe?void 0:l?.id,l?.epoch,W),me=!!l&&G.readiness===`running`,he=me&&G.association===`unassociated`,ge=!l||me&&G.association===`associated`&&!!G.value?.epoch,_e=!!l&&(G.readiness===`stopped`||G.readiness===`not-started`),ve=(0,h.useRef)(null);l&&(ge&&G.value?.epoch?ve.current={projectId:l.id,selected:l.epoch,epoch:G.value.epoch}:(ve.current?.projectId!==l.id||ve.current.selected!==l.epoch||me||_e||de||Wp(G.error))&&(ve.current=null));let ye=ve.current?.epoch??null,be=!pe&&!de&&(!l||ye!==null),K=ds(y,T?{kind:`task`,id:T}:null,!S&&be,ye,W),[xe,Se]=(0,h.useState)(0),Ce=G.value?.workspaceId,we=!!l&&K.epoch===ye&&!!Ce&&[K.workspace,K.activeRuns].some(e=>e&&e.workspaceId!==Ce),Te=!S&&!n?.pending&&!fe&&be&&!xe&&!we&&K.attached&&!Wp(K.error)&&(!l||K.epoch===ye),Ee=(de?.source===`project`?de.code:void 0)??G.error??(G.value?.status===`unavailable`?`unavailable`:me&&!ge&&!he?`Viewer access not confirmed`:void 0),De=(de?.source===`viewer`?de.code:void 0)??(be?K.error??(we?`stale`:void 0):void 0),Oe=(0,h.useRef)(!0);(K.workspace||K.observation||Ee||De||he||_e)&&(Oe.current=!1);let ke=!!(l&&(G.value||G.error||de)),Ae=!!de||pe||Wp(Ee)||Wp(De),je=!S&&!Ae&&!!(K.workspace||ke),Me=ls(he&&!S&&!Ae?l?.id:void 0,T,G.value?.workspaceId,G.value?.epoch,W),Ne=be&&!we&&!Ae&&(!l||K.workspace?.epoch===ye)?K.workspace:void 0,Pe=he?Me.history?.workspace:Ne,Fe=Me.history?.client??y.client,Ie=`${he?`retained`:`viewer`}:${l?.id??`direct`}:${Pe?.epoch??``}:${Pe?.storeId??``}`,Le=(0,h.useRef)(null);(K.workspace||G.value?.workspaceId)&&(Le.current=K.workspace?.workspaceId??G.value?.workspaceId??null);let Re=is(y.client,je),ze=K.attached&&K.workspace&&!S&&!Ae,Be=ns(y.client,ze?{kind:`conversation-active`}:null,1e3,W,K.attachmentVersion,K.allocationSignal),Ve=Be.value?.kind===`conversation-active`?Be.value.entries:[],He=[...Ve,...(Re.value?.entries??[]).filter(e=>!Ve.some(t=>t.id===e.id))],Ue=ns(y.client,be&&K.attached&&!S&&!Ae?{kind:`workflow-active`}:null,2e3,W,K.attachmentVersion,K.allocationSignal),We=Ue.value?.kind===`workflow-active`?Ue.value:void 0,Ge=(0,h.useMemo)(()=>We?.links?.filter(e=>e.conversationId===D).map(e=>e.runId)??[],[We,D]),Ke=ns(y.client,!l&&ze?{kind:`projects`}:null,0,W,K.attachmentVersion,K.allocationSignal),qe=ae??l?.cwd??(Ke.value?.kind===`projects`?Ke.value.entries.find(e=>e.current)?.path:void 0),Je=B?.id===D?B:void 0,Ye=(!l||ke)&&te?.id===D?te:void 0,Xe=xo();(0,h.useEffect)(()=>{Je&&Hn()===Je.id&&history.replaceState({...history.state,cadenceCwd:Je.cwd,cadenceConversationId:Je.id},``,location.href)},[Je]);let Ze=D?Je:qe?{id:se,cwd:qe}:void 0,Qe=Je?.cwd??qe??(Ke.value?.kind===`projects`?Ke.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,q=K.observation?.snapshot,$e=q?.scope.kind===`task`&&q.scope.id===T&&q.storeId===Ne?.storeId&&q.epoch===K.epoch&&(!l||q.epoch===ye)?K.observation:void 0,et=wm(),{closeDrawer:tt}=et,nt=P===`branches`&&!!D,rt=!nt&&(P!==`task`||!U),it=()=>{F(`branches`),et.mobile?et.setDrawer(`right`):et.inspector||et.toggle(`right`)},[J,at]=(0,h.useState)(w?.snapshotSeq),[ot,Y]=(0,h.useState)(``),[st,ct]=(0,h.useState)(``),lt=(0,h.useRef)(null),[ut,dt]=(0,h.useState)(`messages`),[ft,pt]=(0,h.useState)(!1),[mt,ht]=(0,h.useState)(!1),[gt,_t]=(0,h.useState)(),[vt,yt]=(0,h.useState)(w?.cursor),[bt,xt]=(0,h.useState)(``),[St,Ct]=(0,h.useState)([]),[wt,Tt]=(0,h.useState)(new Set),Et=(0,h.useRef)(!0),Dt=e=>{Et.current&&Ct(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?ts(t,e):t)})},Ot=(0,h.useRef)(new fs),kt=(0,h.useRef)(0),At=(0,h.useCallback)(()=>{kt.current++,Ot.current.depart()},[]),jt=H({taskId:T,chatId:D,leaf:k.leaf??null,scope:U,selectedSnapshot:J??null,detached:S,project:l?.id??null,selectedEpoch:l?.epoch??null,viewerEpoch:K.epoch??null,attached:Te,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});Ot.current.select(jt),(0,h.useEffect)(()=>(Et.current=!0,()=>{Et.current=!1,At()}),[At]);let Mt=e=>{x(``);let t=e??crypto.randomUUID();e||oe(Qe??qe),j(null),t!==D&&z(void 0),At(),O(t),E(null),le(null),Y(``),ct(``),_t(void 0),yt(void 0),at(void 0),dt(`messages`),F(e=>e===`task`?`files`:e),tt();let n=t===D?Jn(location.hash,t).leaf:null;history.replaceState({cadenceCwd:Qe??qe,cadenceConversationId:t},``,`${location.pathname}${location.search}${Yn(`#chat=${t}`,n)}`)};(0,h.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let Nt=(e,t)=>{j(null),O(null),F(`task`),Y(t??``),ct(``),at(void 0),At(),E(e),le({kind:`task`,id:e}),_t(void 0),yt(void 0),dt(`messages`),tt(),history.replaceState(null,``,Kp(e))};(0,h.useEffect)(()=>{let e=()=>{let e=qp();if(e)j(null),O(null),F(`task`),At(),at(e.snapshotSeq),Y(``),ct(``),E(e.taskId),le(e.scope??{kind:`task`,id:e.taskId}),_t(void 0),yt(e.cursor),dt(`messages`),tt();else{let e=Hn();if(e){x(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&oe(t),z(void 0),j(null),O(e),E(null),le(null),F(e=>e===`task`?`files`:e),At(),tt()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[tt,At]);let Pt=(e,t,n)=>{j(null),at(t),ct(n??``),At(),le(e),_t(void 0),yt(void 0),dt(`messages`),tt(),T&&history.replaceState(null,``,Kp(T,void 0,{scope:e,snapshotSeq:t}))},Ft=Me.history?.workspace,It=Ft&&(J&&V(J,Ft.committedSeq)>0||vt&&(vt.storeId!==Ft.storeId||vt.scope.kind!==U?.kind||vt.scope.id!==U?.id||V(vt.snapshotSeq,Ft.committedSeq)>0)),Lt=Me.error??(It?`History anchor does not match the selected workspace`:void 0),Rt=Pe&&!It?J??$e?.snapshot.committedSeq??Pe.committedSeq:void 0,zt=Pe?.storeId,Bt=Lt??fe??Ee??De??(Ae?`Sign-in required`:_e?G.readiness===`stopped`?`Execution stopped`:`Execution not started`:void 0),Vt=Bt?_(`Recorded history unavailable: {reason}.`,{reason:v(Bt)}):_(`Reading recorded history…`),Ht=U&&zt&&Rt?{storeId:zt,scope:U,snapshotSeq:Rt,reader:`messages`,after:null,limit:50}:null,Ut=U&&zt&&Rt?{storeId:zt,scope:U,snapshotSeq:Rt,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,Wt=$e?.snapshot.runs??[],Gt=Ot.current.ticket(),Kt=K.allocationSignal,qt=K.activeRuns,Jt=qt?.status===`complete`?qt.runs:[],Yt=Te&&K.readCurrent&&!!K.epoch&&K.workspace?.epoch===K.epoch&&!K.error&&K.transportStatus===`current`&&(T?$e?.connection===`current`:!K.observation),Xt=ge&&Yt,Zt=(0,h.useCallback)(()=>Et.current&&Ot.current.current(Gt)&&!W.signal.aborted,[Gt,W]),Qt=(0,h.useCallback)(e=>Zt()&&Kt?.aborted===!1&&Te&&!!K.epoch&&K.epoch===e,[Zt,Kt,Te,K.epoch]),$t=Xt&&K.actions,en=(0,h.useRef)(new fs);en.current.select(String($t));let tn=en.current.ticket(),nn=(0,h.useMemo)(()=>({allocation:Kt,epoch:K.epoch,attached:Qt,current:()=>$t&&en.current.current(tn)&&Qt(K.epoch)}),[Kt,K.epoch,Qt,$t,tn]),rn=e=>Qt(e.epoch)&&sf(e),an=(0,h.useRef)(qt);an.current=qt;let on=(0,h.useRef)(void 0);(0,h.useLayoutEffect)(()=>{let e=on.current;e&&e.epoch===nn.epoch&&e.previous!==nn.allocation&&nn.current()&&e.accept(nn)});let sn=e=>d&&!Ae?async(t,n,r)=>{if(W.check(),t.aborted||!Zt()||!en.current.current(tn)||Kt?.aborted||xe||on.current)throw Error(`stale`);let i=kt.current,a=()=>t.aborted||kt.current!==i;Ot.current.depart(),Se(e=>e+1);try{let i=await d(e,t,n,r);if(W.check(),a())throw W.waitError(t,`stale`);G.prepared(i);let o=K.reconnect();if(await K.whenReady(i,t,o),W.check(),a())throw W.waitError(t,`stale`);return new Promise((e,n)=>{let r=()=>{on.current=void 0,t.removeEventListener(`abort`,a),W.signal.removeEventListener(`abort`,a)},a=()=>{r(),n(W.waitError(t,`stale`))};t.addEventListener(`abort`,a,{once:!0}),W.signal.addEventListener(`abort`,a,{once:!0}),on.current={epoch:i,previous:Kt,accept(t){r(),e(t)}}}).then(async e=>{if(a()||!e.current()||(await K.whenReady(i,t,o),a()||!e.current()))throw W.waitError(t,`stale`);return e})}finally{Se(e=>e-1)}}:void 0,cn=sn(`send`),ln=sn(`plan-validation`),un=e=>{Dt(e),e.receipt&&Ot.current.current(Gt)&&(en.current.depart(),K.refresh())},dn=e=>{let t=Jt.find(t=>t.runId===e),n=an.current;if(!t||!Qt(t.epoch)||n?.status!==`complete`||n.epoch!==t.epoch||!n.runs.some(n=>n.runId===e&&n.taskId===t.taskId&&n.operationId===t.operationId&&n.epoch===t.epoch)||wt.has(e))return;let r=crypto.randomUUID(),i=t.epoch;Tt(t=>new Set(t).add(e)),Dt({commandId:r,error:_(`Stop requested; settlement is not yet confirmed.`)}),y.client.cancel({commandId:r,epoch:i,runId:e}).then(e=>{un(e.kind===`ok`?{commandId:r,receipt:e.value}:{commandId:r,error:_(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>Dt({commandId:r,error:_(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Et.current&&Tt(t=>{let n=new Set(t);return n.delete(e),n})})},fn=JSON.stringify([l?.id,D,k.leaf,l?.epoch,G.value?.epoch??K.epoch]),pn=(0,h.useRef)(fn);pn.current=fn;let mn=kt.current,hn=(0,h.useCallback)(()=>Et.current&&!W.signal.aborted&&kt.current===mn&&pn.current===fn,[fn,mn,W]),[gn,_n]=(0,h.useState)(),vn=(0,h.useCallback)(e=>{hn()&&_n({key:fn,agents:e})},[fn,hn]),yn=gn?.key===fn&&je?gn.agents:void 0,[bn,xn]=(0,h.useState)(),Sn=(0,h.useCallback)(e=>{hn()&&xn({key:fn,diagnostics:e})},[fn,hn]),Cn=bn?.key===fn&&je?bn.diagnostics:void 0;if(S)return(0,X.jsxs)(`main`,{className:`entry`,children:[(0,X.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,X.jsx)(`h1`,{children:_(`Detached`)}),(0,X.jsx)(`p`,{children:_(`Accepted service work continues. No Cancel was requested.`)}),St.map(e=>(0,X.jsxs)(`p`,{children:[_(`Observe command after reconnect:`),` `,(0,X.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,X.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>C(!1),children:_(`Reconnect as a viewer`)})]});let wn=Oe.current&&!Ee&&!De,Tn=_e?{status:G.readiness===`not-started`?`not-started`:`stopped`}:Xt&&K.epoch?{status:`ready`,epoch:K.epoch,attachmentVersion:K.attachmentVersion}:{status:!Ee&&!De&&!he?`connecting`:`unavailable`},En=()=>{hn()&&!pe&&(en.current.depart(),Cn?.retry(),Ue.error&&Ue.refresh(),Be.error&&Be.refresh(),Ke.error&&Ke.refresh(),n?.refresh(),Me.refresh(),be&&K.refresh(),G.refresh())};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ym,{panels:et,onOpenService:c,onRefresh:En,onDisconnect:()=>{pt(!1),ht(!1),At(),C(!0)},inspectorLabel:_(U&&P===`task`?`History details`:nt?`Branches`:`Files`),toolbar:U&&(0,X.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":_(`Recorded views`),children:[(0,X.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":ut===`messages`&&!vt,onClick:()=>{yt(void 0),_t(void 0),dt(`messages`)},children:[(0,X.jsx)(ra,{"aria-hidden":`true`}),_(`Conversation`)]}),(0,X.jsxs)(`details`,{className:`view-menu`,ref:lt,onKeyDown:e=>{e.key===`Escape`&<.current&&(lt.current.open=!1,lt.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,X.jsxs)(`summary`,{className:`chip`,children:[ut===`messages`?_(`Details`):v(ut),(0,X.jsx)(Pa,{"aria-hidden":`true`})]}),(0,X.jsxs)(`div`,{className:`view-menu-items`,children:[Nm.map(([e,t])=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":ut===e,onClick:()=>{yt(void 0),_t(void 0),dt(e),lt.current&&(lt.current.open=!1,lt.current.querySelector(`summary`)?.focus())},children:[(0,X.jsx)(t,{"aria-hidden":`true`}),v(e)]},e)),(0,X.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-label":_(`Export selected scope`),disabled:!Ht,onClick:()=>{lt.current&&(lt.current.open=!1,lt.current.querySelector(`summary`)?.focus()),ht(!0)},children:[(0,X.jsx)(Sa,{"aria-hidden":`true`}),_(`Export selected scope`)]}),(0,X.jsxs)(`button`,{type:`button`,"aria-label":_(`Copy token-free link`),disabled:!T,onClick:()=>{T&&xs(Kp(T,vt,U?{scope:U,snapshotSeq:J}:void 0)).then(e=>e?Is(`info`,_(`Link copied.`)):Is(`error`,_(`Link copy unavailable.`)))},children:[(0,X.jsx)(ca,{"aria-hidden":`true`}),_(`Copy token-free link`)]})]})]})]})]}),actions:U&&(0,X.jsx)(bc,{disabled:!Ut,onOpen:()=>pt(!0)}),notices:(0,X.jsxs)(X.Fragment,{children:[o,bt&&(0,X.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:bt})]}),navigation:(0,X.jsxs)(X.Fragment,{children:[!je&&!We?.runs.length&&(0,X.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[s&&(0,X.jsx)(Ic,{...s}),Jt.length>0&&(0,X.jsx)(`section`,{className:`run-strip`,"aria-label":_(`Execution and cancellation`),children:Jt.map(e=>(0,X.jsxs)(`div`,{className:`run-strip-row`,children:[(0,X.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`run-strip-label`,children:[v(e.kind),` `,e.runId,` · `,v(e.stage)]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>Nt(e.taskId),children:_(`Open active task`)}),(0,X.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Te||wt.has(e.runId),onClick:()=>dn(e.runId),children:[(0,X.jsx)(Wi,{"aria-hidden":`true`}),_(`Cancel run — request stop`)]})]},e.runId))}),(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:_(Ee||De?`Conversation history could not be read. This is not an empty history.`:`Reading conversation history…`)})]}),(je||!!We?.runs.length)&&(0,X.jsx)(Np,{discovery:s,client:y.client,workspace:Ne,retained:Me.history,executionStopped:_e,taskId:T,scope:U,runs:Wt,snapshot:$e?.snapshot.committedSeq,activeRuns:K.activeRuns,canCancel:Te,canceling:wt,onCancel:dn,chats:He,chatActivityKnown:Be.value?.kind===`conversation-active`&&!Be.error,chatHistoryPartial:Re.loading||Re.canPrevious||!!Re.value?.next,chatHistoryControls:(0,X.jsxs)(X.Fragment,{children:[Re.error&&(0,X.jsx)(`p`,{role:`alert`,children:Re.error}),Re.loading&&(0,X.jsx)(`p`,{className:`panel-hint`,children:_(`Reading conversation history…`)}),Re.canPrevious&&(0,X.jsx)(`button`,{type:`button`,disabled:Re.loading,onClick:Re.previous,children:_(`Newer conversations`)}),Re.value?.next&&(0,X.jsx)(`button`,{type:`button`,disabled:Re.loading,onClick:Re.next,children:_(`Older conversations`)}),Re.canPrevious&&(0,X.jsx)(`button`,{type:`button`,onClick:Re.first,children:_(`Latest conversations`)}),Re.error&&(0,X.jsx)(`button`,{type:`button`,onClick:Re.refresh,children:_(`Observe current state`)})]}),conversationId:D,onConversation:Mt,onNewConversation:()=>Mt(),actionCurrent:nn.current,actionsUnavailable:$t?``:_(_e?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{Re.refresh(),e===D&&ie(e=>e+1)},workflows:We?.runs,workflowLinks:We?.links,workflowError:!!Ue.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?Mt(t):(j({runId:e.id,stepId:null,label:e.goal}),tt())},canCancelWorkflow:rn,onCancelWorkflow:async e=>{rn(e)&&(xt(await gf(y.client,e,rn)),Ue.refresh())},onTask:Nt,onScope:Pt},`${Ie}:${he?T??`chat`:``}`),K.workspace&&!Ae&&(D?(0,X.jsx)(Jc,{kind:`conversation`,groups:yn?.groups??[],unavailable:!We||!!Ue.error||!yn||yn.unavailable,selected:A,onOpen:e=>{hn()&&(j(e),tt())}},`chat:${D}`):T&&(0,X.jsx)(Jc,{kind:`task`,runs:Wt,unavailable:!$e||!!K.error,onOpen:(e,t)=>Pt({kind:`child`,id:e},$e?.snapshot.committedSeq,t)},`task:${T}`))]}),content:(0,X.jsxs)(X.Fragment,{children:[D&&l&&!ke&&(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:_(`Reading this conversation…`)}),A&&!Ae&&(0,X.jsx)(Fp,{client:y.client,agent:A,canCancelWorkflow:rn,backLabel:_(D?`Back to conversation`:T?`Back to task`:`Back`),onBack:()=>j(null),onOpenAgent:j},`${A.runId}:${A.stepId??``}`),D&&(!l||ke)&&(0,X.jsx)(Nf,{client:y.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:qe,onLocation:ee,onActivity:ne,hidden:!!A,onOpenAgent:j,activeWorkflowIds:Ge,onAgents:vn,onBranches:L,onOpenBranches:it,workspaceId:l?`checkout:${l.path}`:Le.current??`connecting`,directoryNamespaces:f,legacyWorkspaceId:l?G.value?.workspaceId??void 0:void 0,prepareForSend:cn,prepareForPlan:ln,actionsReady:$t,viewer:nn,access:W,readSelected:hn,onDiagnostics:Sn,observe:re,available:je,canInterrupt:Te,canCancelWorkflow:rn,enabled:cn?je&&!xe:$t,modelAvailability:Tn,previewModels:Ae?void 0:p,initialDraft:m?.conversationId===D?m:void 0,onDraftApplied:()=>g?.(D),onModelChanged:()=>{En()},onChanged:()=>{Re.refresh(),en.current.depart(),K.refresh()},reference:R,onReferenceUsed:ce},`${l?.id??Le.current??`connecting`}:${D}:${k.leaf??``}`),U&&!A&&(0,X.jsxs)(`header`,{className:`conversation-header`,children:[(0,X.jsxs)(`div`,{className:`conversation-heading`,children:[U.kind!==`task`&&T&&(0,X.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Nt(T,ot),children:_(`Back to task`)}),(0,X.jsx)(`h2`,{title:ot||U.id,children:U.kind===`task`?ot||_(`Task {id}`,{id:U.id.slice(0,8)}):st||_(`{kind} {id}`,{kind:v(U.kind),id:U.id.slice(0,8)})}),U.kind===`child`&&(0,X.jsx)(`span`,{className:`conversation-badge`,children:_(`Subagent`)})]}),(0,X.jsxs)(`details`,{className:`conversation-info`,children:[(0,X.jsxs)(`summary`,{children:[_(`Recorded conversation`),` ·`,` `,_(`snapshot {seq}`,{seq:Rt??``})]}),(0,X.jsx)(`code`,{children:U.id}),(0,X.jsx)(`p`,{children:_(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,X.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!A,children:[!Ht&&(0,X.jsxs)(`section`,{className:`empty-state`,children:[(0,X.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:(0,X.jsx)(Yd,{})}),(0,X.jsx)(`h2`,{children:Vt}),(0,X.jsx)(`p`,{children:_(`History is readonly. Start new work in a conversation with /cadence.`)})]}),Ht&&vt?(0,X.jsxs)(`div`,{className:`tab-body`,children:[gt&&(gt.owner.entity.kind===`task`||gt.owner.entity.kind===`message`||gt.owner.entity.kind===`tool`)&&(0,X.jsx)(cc,{client:Fe,seed:{storeId:vt.storeId,scope:vt.scope,snapshotSeq:vt.snapshotSeq,kind:gt.owner.entity.kind,id:gt.owner.entity.id,version:gt.owner.entity.version}},`${gt.owner.entity.id}:${gt.owner.entity.version}`),(0,X.jsx)(ac,{client:Fe,cursor:vt,highlight:gt?.range},`${vt.recordId}:${vt.recordVersion}`)]}):Ht&&(0,X.jsxs)(`div`,{className:ut===`messages`||ut===`tools`?`tab-body transcript-body`:`tab-body`,children:[ut===`messages`&&(0,X.jsx)(Mc,{client:Fe,seed:Ht}),ut===`tools`&&(0,X.jsx)(Fm,{client:Fe,seed:Ht}),ut===`context`&&(0,X.jsx)(sc,{client:Fe,seed:Ht}),ut===`timeline`&&(0,X.jsx)(jm,{client:Fe,seed:Ht,onSearch:()=>pt(!0)}),ut===`runs`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`run-current`,children:[(0,X.jsx)(`h3`,{children:_(`Runs in the current snapshot`)}),Wt.length>0?Wt.map(e=>(0,X.jsx)(gc,{run:e},e.childRunId??e.runId)):(0,X.jsx)(`p`,{className:`panel-empty`,children:_($e?`No owner run projection in this snapshot.`:`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,X.jsx)(`h3`,{children:_(`Retained runs`)}),(0,X.jsx)(yc,{client:Fe,seed:{...Ht,scope:{kind:`task`,id:T??Ht.scope.id}},onScope:Pt},T)]})]},`${U?.kind}:${U?.id}:${J??`current`}`)]},`${Ie}:${T??`chat`}`),K.workspace&&St.length>0&&(0,X.jsx)(`div`,{className:`receipt-dock`,children:St.map(e=>(0,X.jsx)(ps,{client:y.client,value:e,onChange:Dt},e.commandId))})]}),inspectorTabs:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":rt,onClick:()=>F(`files`),children:[(0,X.jsx)(ga,{"aria-hidden":`true`}),_(`Files`)]}),D&&(0,X.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":nt,onClick:()=>F(`branches`),children:[(0,X.jsx)(ha,{"aria-hidden":`true`}),_(`Branches`)]}),U&&(0,X.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":P===`task`,disabled:!Ht,onClick:()=>F(`task`),children:[(0,X.jsx)(la,{"aria-hidden":`true`}),_(`History details`)]})]}),inspector:nt?(0,X.jsx)(el,{view:I?.id===D?I:void 0,onChosen:tt}):rt?(0,X.jsx)(Jf,{location:Ze,client:y.client,enabled:je&&!!Ze,observed:`${G.readiness}:${G.value?.epoch??``}`,onReference:e=>{D||Mt(se);let t=!D&&Ze?`${Ze.cwd.replace(/[\\/]+$/,``)}${Ze.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;z(t),tt()}},Ze?.cwd??`owner`):Ht?(0,X.jsx)(ap,{client:Fe,seed:{...Ht,scope:{kind:`task`,id:T??Ht.scope.id}}},`${Ie}:${T}`):(0,X.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Vt}),status:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Gp,{phase:n?.pending?`updating`:_e?G.readiness===`not-started`?`not-started`:`stopped`:he?`independent`:Xt?T?`task`:`chat`:wn?`connecting`:`updating`,entryError:fe,projectStatus:l&&G.readiness,projectError:Ee,viewerError:De,prepareOnly:Cn?.prepareOnly,readErrors:[[`Project directories: {code}.`,Ke.error],[`Conversation activity: {code}.`,Be.error],[`Workflow activity: {code}.`,Ue.error],[`Conversation context: {code}.`,Cn?.context],[`Conversation read: {code}.`,Cn?.head],[`Workflow observation: {code}.`,Cn?.workflow],[`Recorded workflows: {code}.`,Cn?.runs]],historyError:Lt,retained:!!K.workspace||G.readiness===`stale`&&!!G.value&&G.value.status!==`unavailable`,latency:Xe,onRefresh:En},`${fn}:${T??`chat`}`),Ye&&(0,X.jsx)(Cm,{usage:Ye.context}),Ye&&(0,X.jsx)(xm,{cache:Ye.cache}),Ye&&Ye.turns>0&&(0,X.jsx)(Rp,{icon:(0,X.jsx)(ra,{}),tip:_(`Turns in this conversation: {count}`,{count:Ye.turns}),children:Ye.turns}),D&&(0,X.jsx)(Vp,{clock:Ye?.replyClock??`unavailable`}),qt?.status===`complete`&&Jt.length>0&&(0,X.jsx)(Rp,{tone:`warn`,children:_(Xt?Jt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:Jt.length})})]}),folder:(K.workspace||l)&&(0,X.jsx)(Lp,{path:Qe,onClick:()=>u?u(Qe):N(``)})}),M!==null&&K.workspace&&(0,X.jsx)(lp,{onOpen:t,projects:a??(Ke.value?.kind===`projects`?Ke.value.entries:[]),client:y.client,current:Qe??K.workspace.rootLabel,initial:M||void 0,home:i,epoch:K.workspace.epoch,onClose:()=>N(null)}),ft&&Ut&&(0,X.jsx)(hc,{client:Fe,seed:Ut,onClose:()=>pt(!1),onHit:e=>{_t(e),yt(e.cursor),T&&history.replaceState(null,``,Kp(T,e.cursor,U?{scope:U,snapshotSeq:J}:void 0))}},`${Ie}:${U?.id}`),mt&&Ut&&(0,X.jsx)(fc,{request:{storeId:Ut.storeId,scope:Ut.scope,snapshotSeq:Ut.snapshotSeq,format:`ndjson`},onClose:()=>ht(!1)},`${Ie}:${U?.id}`)]})}function Fm({client:e,seed:t}){let n=vs(e,{...t,reader:`tools`}),r=n.page;return(0,X.jsxs)(`section`,{className:`tools-list`,children:[(0,X.jsx)(oc,{pager:n}),(0,X.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,X.jsx)(Pc,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Im=`cadence:folder-draft`,Lm=()=>({text:``,model:null});function Rm(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Lm();let t=null;try{e.model!=null&&(t=ce(e.model))}catch{}return{text:e.text,model:t}}catch{return Lm()}}function zm(e){try{e.text||e.model?sessionStorage.setItem(Im,JSON.stringify(e)):sessionStorage.removeItem(Im)}catch{}}function Bm(e,t,n){let r=Ul(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(Im)}catch{}return{...n,conversationId:t}}var Vm=`cadence-last-project`;function Hm(){try{let e=localStorage.getItem(Vm);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Um(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Vm,e)}catch{}}function Wm(e){let t=Hm();return t?e.projects.find(e=>e.id===t):void 0}async function Gm(e,t){let n=await Qo(`/workbench/v1/projects/${e}`,t,Co);return n.workspaceId!==null||n.status===`not-started`}async function Km(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await Vo(n);if(!n.ok)throw Error(Ho(r));return rt(r)}async function qm(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Vo(t);if(!t.ok)throw Error(Ho(n));return Oo(n)}async function Jm(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await Vo(s);if(!s.ok)throw Uo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Ho(c));let l=So(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Ym(e,t){let n=await qm(t);return Jm(`/workbench/v1/select`,{path:e},n,t)}async function Xm(e,t,n,r,i){let a=await qm(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await Jm(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function Zm(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Ym(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Qm=[`turn`,`starting`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function $m(e){let t=F(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:L(t.id),source:M(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:Ye(t.sessionId),cwd:O(t.cwd,4096,!0),leaf:t.leaf===null?null:O(t.leaf,128,!0),history:M(t.history,[`shared`,`unavailable`]),phase:M(t.phase,Qm),freshness:M(t.freshness,[`current`,`stale`,`unknown`]),observedAt:A(t.observedAt,0),epoch:t.epoch===null?null:L(t.epoch),instance:t.instance===null?null:L(t.instance),executionCwd:t.executionCwd===null?null:O(t.executionCwd,4096,!0)}}function eh(e){let t=F(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:N(t.kind,`activity-discovery`),epoch:L(t.epoch),observedAt:A(t.observedAt,0),completeness:M(t.completeness,[`complete`,`partial`]),unavailable:A(t.unavailable,0,1e4),projects:I(t.projects,128,e=>{let t=F(e,[`path`,`activities`]);return{path:O(t.path,4096,!0),activities:I(t.activities,256,$m)}})}}async function th(e){return Qo(`/workbench/v1/activity`,e,eh)}function nh(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function rh(e,t,n,r=th){let i=new AbortController,a,o,s,c=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw s!==a.epoch&&(s=a.epoch,n()),Error(`stale`);s=void 0,o=a,t(o,``)}catch(e){if(i.signal.aborted)return;let r=e instanceof Error?e.message:`unavailable`;if(Xo(r)){i.abort(),n(r),t(void 0,r);return}o=o?nh(o,Date.now()):void 0,t(o,r)}finally{i.signal.aborted||(a=setTimeout(c,3e3))}};return c(),()=>{i.abort(),clearTimeout(a)}}function ih(e,t){let[n,r]=(0,h.useState)(),[i,a]=(0,h.useState)(``);return(0,h.useEffect)(()=>{if(r(void 0),a(``),e)return rh(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}async function ah(e){try{return await Qo(`/workbench/v1`,e,Oo)}catch(e){if(e instanceof Zo&&e.status===400&&e.message===`invalid`)return null;throw e}}function oh({ready:e,previewModels:t,draft:n=Lm(),onDraftChange:r,restoring:i,missing:a,pending:o=!e,entryError:s,restoreError:c,onChooseFolder:l,onRefresh:u,onOpenService:d,notices:f,discovery:p}){let{t:m}=Z(),g=wm(),[_,v]=(0,h.useState)(!1),y=Kl(null,{status:`not-started`},`folder-setup`,t),b=()=>{g.closeDrawer(),l()};return(0,X.jsx)(ym,{panels:g,onRefresh:u,onOpenService:d,notices:f,navigation:(0,X.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,X.jsx)(gp,{disabled:!e,onConversation:b}),p&&(0,X.jsx)(Ic,{...p}),(0,X.jsxs)(`section`,{className:`lp-section grow`,children:[(0,X.jsx)(`header`,{className:`lp-section-header`,children:(0,X.jsx)(`span`,{className:`lp-section-title`,children:m(`Conversation history`)})}),(0,X.jsx)(`div`,{className:`lp-section-body`,children:(0,X.jsx)(`p`,{className:`panel-hint`,role:`status`,children:m(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,X.jsxs)(`section`,{className:`chat-workspace`,"aria-label":m(`Ordinary conversation`),children:[(0,X.jsx)(`div`,{className:`chat-messages`,children:(0,X.jsxs)(Xd,{visible:e&&!(i&&o),hint:m(`Choose a working folder to start. You can write a draft below.`),children:[(0,X.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:b,children:[(0,X.jsx)(ga,{"aria-hidden":`true`}),m(`Choose a folder…`)]}),a&&(0,X.jsx)(`p`,{className:`panel-hint`,role:`status`,children:m(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),(0,X.jsx)(`div`,{className:`composer-dock`,children:(0,X.jsxs)(`div`,{className:`chat-composer`,children:[(0,X.jsx)(`textarea`,{"aria-label":m(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:m(`Write a message. Choose a folder before sending…`)}),(0,X.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,X.jsx)(Lu,{scope:`next-conversation`,availability:{status:`not-started`},read:y,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:_,onOpenChange:e=>{e&&y.reread(),v(e)},onChanged:()=>{}}),(0,X.jsx)(`span`,{className:`composer-hint`,children:m(`Choose a folder before sending.`)}),(0,X.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":m(`Send`),title:m(`Send`),disabled:!0,children:(0,X.jsx)(La,{"aria-hidden":`true`})})]})]})})]}),inspector:(0,X.jsx)(`aside`,{className:`panel files-panel`,children:(0,X.jsx)(`p`,{className:`panel-hint`,children:m(`Files appear here after you open a working folder.`)})}),status:(0,X.jsx)(Gp,{phase:o?e?`updating`:`connecting`:`folder`,entryError:s,projectError:c,retained:e&&!i,latency:null,onRefresh:u}),folder:(0,X.jsx)(Lp,{disabled:!e,onClick:b})})}var sh={restart:18e4,upgrade:12e5},ch=1e3,lh={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`};function uh(e,t){let n=t.job;if(n?.id===e.id&&n.state!==`running`)return e.action===`upgrade`&&n.state===`ready`&&!ph(n)?n.action===`upgrade`&&n.version===e.to&&t.version===e.to?`reload`:`changed`:n}var dh=e=>e instanceof Error?e.message:`unavailable`;function fh(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(lh[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function ph(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function mh(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function hh({epoch:e,csrf:t,onClose:n}){let{t:r}=Z(),[i,a]=(0,h.useState)(),[o,s]=(0,h.useState)(``),[c,l]=(0,h.useState)(),[u,d]=(0,h.useState)(!1),[f,p]=(0,h.useState)(!1),[m,g]=(0,h.useState)(!1),[_,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(),[C,w]=(0,h.useState)(0),E=i?.work??null,D=i?.unit&&!E&&(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`p`,{role:`alert`,children:r(`Cadence could not confirm which work would stop. Refresh the service status to continue.`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>w(e=>e+1),children:r(`Refresh status`)})]});(0,h.useEffect)(()=>{let e=new AbortController;return Go(e.signal).then(a,t=>{e.signal.aborted||s(dh(t))}),()=>e.abort()},[C]),(0,h.useEffect)(()=>{if(!_)return;let{job:e,since:t}=_,n=new AbortController,r,i=async()=>{if(Date.now()-t>sh[e.action])return S(`timeout`);try{let t=await Go(n.signal);if(n.signal.aborted)return;let r=uh(e,t);if(r===`reload`)return window.location.reload();if(r!==void 0)return S(r)}catch(e){if(n.signal.aborted)return;if(e instanceof T||e instanceof Error&&e.message===`invalid`)return S(`changed`);b(!0)}r=setTimeout(i,ch)};return r=setTimeout(i,ch),()=>{n.abort(),clearTimeout(r)}},[_]);let O=async()=>{l(`checking`),s(``);let e=await Ko().catch(()=>`failed`);try{a(await Go()),l(e)}catch(e){s(dh(e)),l(`failed`)}},k=n=>{i&&E&&!m&&(g(!0),s(``),qo({action:n===null?`restart`:`upgrade`,from:i.version,to:n,work:E.digest,epoch:e},t).then(e=>v({job:e,since:Date.now()})).catch(e=>{s(dh(e)),a({...i,work:null}),p(!1),w(e=>e+1)}).finally(()=>g(!1)))};if(_){let{job:e}=_,t=x!==void 0&&(typeof x==`string`||x.state!==`ready`),a=typeof x==`object`&&ph(x),o=i?.unit;return(0,X.jsxs)(dc,{title:r(`Cadence service`),onClose:x?n:void 0,children:[(0,X.jsxs)(`section`,{className:`service-progress`,children:[x===void 0?(0,X.jsxs)(`p`,{role:`status`,children:[(0,X.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(y?`Cadence is starting again…`:`Stopping Cadence…`):r(y?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,X.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),x===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:sh[e.action]/6e4}):x===`changed`?r(`Cadence answered with a different version.`):fh(r,x)]}),(0,X.jsx)(`p`,{children:r(x===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,X.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,X.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,X.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),x!==void 0&&(0,X.jsx)(`footer`,{children:a?(0,X.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,X.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=E?.items??[];return(0,X.jsxs)(dc,{title:r(`Cadence service`),onClose:m?void 0:n,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{children:r(`Restart Cadence?`)}),(0,X.jsx)(`p`,{children:r(`The service stops in order and starts again; this page waits for the result.`)}),e.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(gh,{items:e,t:r}),(0,X.jsxs)(`label`,{className:`service-confirm`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),D,o&&(0,X.jsx)(`p`,{role:`alert`,children:nr(r,o)}),(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>{d(!1),p(!1),s(``)},children:r(`Back`)}),(0,X.jsx)(`button`,{type:`button`,className:e.length>0?`danger`:`primary`,disabled:m||!E||e.length>0&&!f,onClick:()=>k(null),children:r(`Restart now`)})]})]})}let A=i&&c&&typeof c==`object`?Bo(c.version,i.version)>0:!1;return(0,X.jsxs)(dc,{title:r(`Cadence service`),onClose:m?void 0:n,children:[i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`section`,{className:`service-info`,children:[(0,X.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,X.jsx)(`p`,{children:mh(r,i.upgrade)}),(0,X.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,X.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:fh(r,i.job)})})]}),i.unit&&(0,X.jsxs)(`section`,{className:`service-info`,children:[(0,X.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,X.jsxs)(X.Fragment,{children:[c===`failed`&&(0,X.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,X.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,X.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):A?c.deprecated?(0,X.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Io(i.upgrade)?E?(0,X.jsx)(_h,{version:c.version,work:E.items,sending:m,onUpgrade:k,t:r}):null:(0,X.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,X.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),D,o&&(0,X.jsx)(`p`,{role:`alert`,children:nr(r,o)})]}):(0,X.jsx)(`p`,{role:o?`alert`:`status`,children:o?nr(r,o):r(`Reading the service…`)}),(0,X.jsx)(`footer`,{children:(0,X.jsxs)(`button`,{type:`button`,disabled:!i?.unit||!E||m||c===`checking`,onClick:()=>d(!0),children:[(0,X.jsx)(Xi,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function gh({items:e,t}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{role:`alert`,children:t(`{count} running workflows or conversations will be stopped.`,{count:e.length})}),(0,X.jsx)(`ul`,{className:`service-work`,children:e.map(({project:e,source:n,id:r,sessionId:i})=>(0,X.jsxs)(`li`,{children:[e,` · `,t(n===`turn`?`Owner turn`:`Owner workflow`),` `,(0,X.jsx)(`code`,{children:r}),i&&(0,X.jsxs)(X.Fragment,{children:[` · `,t(`Conversation {id}`,{id:i})]})]},JSON.stringify([e,n,r])))})]})}function _h({version:e,work:t,sending:n,onUpgrade:r,t:i}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:i(`Cadence downloads the update before stopping. If startup fails, it tries to restore the previous version. After a successful upgrade, this page reloads automatically; unsent images must be attached again.`)}),t.length>0&&(0,X.jsx)(gh,{items:t,t:i}),(0,X.jsxs)(`button`,{type:`button`,className:t.length>0?`danger`:`primary`,disabled:n,onClick:()=>r(e),children:[(0,X.jsx)(Ra,{"aria-hidden":`true`}),i(t.length>0?`Stop work and upgrade to {version}`:`Upgrade to {version}`,{version:e})]})]})}function vh(){let{t:e}=Z(),[t,n]=(0,h.useState)(),[r,i]=(0,h.useState)(Rm),[a,o]=(0,h.useState)(),s=(0,h.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,h.useState)(Vn),u=(0,h.useCallback)(e=>Km(c??void 0,e),[c]),[d,f]=(0,h.useState)(null),[p,m]=(0,h.useState)(null),[g,_]=(0,h.useState)(``),[v,y]=(0,h.useState)(!1),[b,x]=(0,h.useState)({pending:!0}),S=(0,h.useRef)(null),C=(0,h.useRef)(new Map),D=(0,h.useRef)(!c&&!r.text&&!r.model),[O,k]=(0,h.useState)(!1),A=(0,h.useRef)(null),j=(0,h.useCallback)(()=>{A.current?.abort(),A.current=null},[]),M=(0,h.useRef)(!1),N=(0,h.useRef)(void 0),P=(0,h.useRef)(null);(!P.current||!N.current&&P.current.selected!==c)&&(P.current={selected:c,access:new $o});let{access:F}=P.current,I=(0,h.useCallback)((e,t)=>{N.current||(N.current=e,j(),S.current?.abort(),P.current?.access.refuse(`entry`,e),x({pending:!1,entryError:t?void 0:e,restoreError:t?e:void 0,restoring:t}))},[j]),L=(0,h.useCallback)(()=>{if(N.current)return;j();let e=new AbortController;A.current=e;let t,r=()=>{t!==void 0&&a()};window.addEventListener(`online`,r);let i=()=>{clearTimeout(t),window.removeEventListener(`online`,r)};e.signal.addEventListener(`abort`,i,{once:!0});let a=async()=>{if(clearTimeout(t),t=void 0,e.signal.aborted)return;x(e=>({...e,restoring:void 0,pending:!0}));let r;try{let t=await ah(e.signal);if(e.signal.aborted)return;M.current=!1,n(t);let a=D.current&&t?Wm(t):void 0;if(a){r=a.cwd,x(e=>({...e,entryError:void 0,restoring:r,pending:!0}));let t=await Gm(a.id,e.signal);if(e.signal.aborted)return;if(!t)throw Error(`unavailable`);D.current=!1,history.replaceState(null,``,`/app?project=${a.id}`),l(a.id)}x({pending:!1,missing:!!(t&&D.current&&Hm()&&!a)}),i(),A.current=null}catch(n){if(e.signal.aborted)return;let i=n instanceof Error?n.message:`unavailable`;if(Xo(i))return I(i,r);x({pending:!1,entryError:r?void 0:i,restoreError:r?i:void 0,restoring:r}),t=setTimeout(a,Yo)}};a()},[j,I]),R=Xo(b.entryError)||Xo(b.restoreError),z=(0,h.useCallback)(e=>{if(e&&Xo(e))return I(e);M.current||(M.current=!0,L())},[L,I]),B=ih(R?void 0:t?.epoch,z);(0,h.useEffect)(()=>{L();let e=()=>{S.current?.abort(),D.current=!1,k(!1),l(Vn()),L()},t=()=>{D.current&&A.current&&e()};return window.addEventListener(`hashchange`,t),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,t),window.removeEventListener(`popstate`,e),j(),S.current?.abort()}},[L,j]);let V=()=>{D.current=!1,k(!0),!(R||O)&&(t&&b.restoring?(j(),x({pending:!1})):A.current&&L())},ee=(0,h.useCallback)(e=>{if(N.current)throw Error(N.current);j(),M.current=!1,x({pending:!1}),n(e)},[j]),H=(0,h.useCallback)((e,n)=>{D.current=!1,k(!1),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&C.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=(O||!t?.projects.some(e=>e.id===c))&&!n&&!!(r.text||r.model);s?(o(Bm(e.path,a,r)),i(Lm())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:C.current.get(e.id)??`#chat=${a}`}`),l(e.id),f(null),window.dispatchEvent(new Event(`hashchange`))},[c,O,t,r]),te=(0,h.useCallback)(async e=>{if(N.current)throw Error(N.current);S.current?.abort();let t=new AbortController;S.current=t;let n=await Ym(e,t.signal);t.signal.aborted||(ee(n.entry),H(n.project))},[H,ee]),ne=t&&!R?{value:B.value,error:B.error,opening:!!p,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,n)=>{S.current?.abort(),se||V();let r=new AbortController;S.current=r,m(n.cwd),_(``),Zm(t,n,r.signal).then(e=>{r.signal.aborted||(ee(e.entry),H(e.project,n))}).catch(t=>{r.signal.aborted||_(nr(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{S.current===r&&m(null)})}}:void 0,re=async(e,n,r,i)=>{if(F.check(),N.current)throw Error(N.current);let a=t?.projects.find(e=>e.id===c);if(!a)throw Error(`unavailable`);let o=gr([n,F.signal]);try{let t=await Xm(a,e,o.signal,r,i);if(F.check(),o.signal.aborted||P.current?.access!==F)throw Error(`stale`);return ee(t.entry),t.project.epoch}finally{o.dispose()}},ie=(0,h.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new T(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Vo(n);if(!n.ok){let e=Ho(r);return{kind:`error`,error:E(w.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:zn(r)}}catch{return{kind:`error`,error:E(`unavailable`)}}}}),[]),ae=t?.epoch,oe=(0,h.useMemo)(()=>c?uo(c):void 0,[c,ae]),se=O?void 0:t?.projects.find(e=>e.id===c);(0,h.useEffect)(()=>{se&&Um(se.id)},[se]);let ce={pending:b.pending,error:b.entryError??b.restoreError,refresh:L};if(t===null)return(0,X.jsx)(Pm,{entryObservation:ce,projectAccess:F});let U=t&&v&&(0,X.jsx)(hh,{epoch:t.epoch,csrf:t.csrf,onClose:()=>y(!1)}),le=()=>y(!0),ue=t&&d!==null&&(0,X.jsx)(lp,{selectOnly:!0,client:ie,current:se?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>f(null),onOpen:te});return t&&se&&oe?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Pm,{entryObservation:ce,projectAccess:F,api:oe,project:se,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===se.path).map(e=>e.id).sort(),discovery:ne,onPrepareExecution:re,onChooseFolder:e=>{S.current?.abort(),A.current&&!R&&L(),f(e??se.cwd)},onOpenProject:te,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:g&&(0,X.jsx)(`p`,{role:`alert`,children:g}),onOpenService:le},`${t.epoch}:${se.id}`),U,ue]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oh,{discovery:ne,ready:!!t&&!R,previewModels:t&&!R?u:void 0,draft:r,onDraftChange:e=>{V(),i(e),zm(e)},restoring:b.restoring,missing:!b.pending&&!b.entryError&&!b.restoreError&&(b.missing||!(O||!c||se||!t)),pending:b.pending,entryError:b.entryError,restoreError:b.restoreError,onRefresh:L,onOpenService:t?le:void 0,onChooseFolder:()=>{V(),_(``),S.current?.abort(),f(t?.home??``)},notices:g&&(0,X.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g})}),ue,U]})}function yh(){let{t:e}=Z();return(0,X.jsxs)(`main`,{className:`entry`,children:[(0,X.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,X.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var bh=class extends h.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,X.jsx)(yh,{}):this.props.children}};Kn(),fr(dr());var xh=document.getElementById(`root`);if(!xh)throw Error(`Application root unavailable`);(0,g.createRoot)(xh).render((0,X.jsx)(sr,{children:(0,X.jsx)(bh,{children:(0,X.jsx)(vh,{})})}));export{Am as t};
|