@abelxiaoxing/cadence 2.0.34 → 2.0.35

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.
@@ -1,22 +1,24 @@
1
- import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./react.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}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 f=e(n(),1),p=t(),m={"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 is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.":`当前执行服务无法接受此计划审批。请先发送消息以刷新会话;未批准任何实施。`,"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 to start chatting.":`选择工作目录后即可开始对话。`,"Choose a working folder. Execution is prepared only when you send.":`选择工作目录;仅在发送消息时准备执行服务。`,"Conversations stay with their folder. Select one to read its history; Send prepares execution.":`会话按目录保留。选择目录即可查看历史;发送时才准备执行服务。`,"Selecting a folder does not start execution. Send prepares it when needed.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Execution will be prepared when you send. Browsing does not start it.":`发送消息时会按需准备执行服务,浏览不会启动服务。`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"The message was not sent ({code}). Its draft is kept; preparation may have started an execution service.":`消息尚未发送({code})。草稿已保留;准备过程中可能已启动执行服务。`,"Connection unavailable. Existing work may continue; no message is replayed automatically.":`连接当前不可用。已接纳的工作可能仍在运行;不会自动重发任何消息。`,"Execution compatibility not observed":`尚未读取执行服务兼容性`,"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":`历史详情`,"Select retained history to inspect":`选择保留的历史记录查看`,"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":`等待批准计划`,"Ready for conversation":`可以继续对话`,"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 only this plan: implementation, checks, bounded repairs and the displayed local delivery. 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.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"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 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"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.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,"Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.":`暂时无法发送。请检查消息是否超过 16 KiB;如有待确认的命令,请先观察其结果,不要重复发送。`,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":`停止回复`,"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:":`尚未观察到此次发送的结果:`,"Observe this send before sending again. No automatic retry.":`请先观察此次发送的结果,不会自动重试。`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Reference {path}":`引用 {path}`,"Copy path {path}":`复制路径 {path}`,"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":`只读预览 · 引用只发送路径,不自动注入文件内容`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking is not retained.":`思考过程不保留。`,"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":`重新加载观察`,"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 projects":`最近项目`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Running conversations":`运行的对话`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"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}。`,"Context changed. Observe again and request a fresh confirmation.":`上下文已变化。请重新观察并请求新的确认。`,"Explicit service guidance: {status} / {start}. No service is started by this page.":`显式服务操作:{status} / {start}。本页面不会启动任何服务。`,"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}。`,"Shared compatibility: {state}.":`共享兼容性:{state}。`,compatible:`兼容`,"unavailable / mismatch — reload built assets; normal actions disabled":`不可用 / 不匹配——请重新加载构建产物;常规操作已禁用`,"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 or detach unconfirmed; explicit re-entry required.":`观察不可用或断开未确认;需要显式重新进入。`,"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; restart the service 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; restart the service 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}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"{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.":`未观察到活动或近期的执行轮次。`,"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:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,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.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"The model list changed and was read again. Choose once more.":`模型列表已变化并已重新读取,请再选一次。`,"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.":`不支持此模型或思考级别。`,"The choice was not confirmed. The list was read again; check the current model before choosing again.":`未能确认这次选择,列表已重新读取;请先确认当前模型再重新选择。`,"Model unavailable":`模型不可用`,"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 restart the service.":`还没有配置模型。请在 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…":`正在切换模型…`,"Every conversation in this project uses this 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}),结束后再试。`,"This page was out of date ({code}) and has been read again. Try once more.":`页面状态已过期({code}),已重新读取,请再试一次。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"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.":`还没有对话。`,"The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.":`无法读取 {name} 的历史会话。请明确选择目录;没有启动任何服务。`,"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 workbench was not started by Cadence's 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}`,Updates:`更新`,"npm could not be reached.":`无法连接 npm。`,"Check for updates":`检查更新`,"Asking npm for the latest version…":`正在向 npm 查询最新版本…`,"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 copy was not installed with npm install -g; upgrade it the way you installed it.":`{version} 可用,但当前副本不是通过 npm install -g 安装的;请按原安装方式升级。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`npm 会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade 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.":`正在运行的服务没有确认有序停止。`,"npm could not install the release.":`npm 无法安装该版本。`,"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})`,"Show the latest":`查看最新`,"Show the conversation up to here. The next message starts a new branch; nothing is deleted.":`只显示到这里为止的对话。下一条消息会从这里开始一个新分支,不会删除任何内容。`,"Continue from here":`从这里继续`,"You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.":`你正在查看这段对话较早的位置。现在发送的消息会从这里开始一个新分支,其余内容仍保留在会话中。`,Terminal:`终端`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},h=r(),g=`cadence-locale`,_=new Map(Object.entries(m));function v(e,t,n){let r=e===`zh`?_.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var y={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`This page was out of date ({code}) and has been read again. Try once more.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"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 b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);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 C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,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}),A=[`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`],j=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function ee(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 M(){throw new j}function N(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&M(),P(e)>t)throw new j(`oversize`);return e}function P(e){return new TextEncoder().encode(e).length}function F(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&M(),e}function I(e){return typeof e!=`boolean`&&M(),e}function L(e,t){return(typeof e!=`string`||!t.includes(e))&&M(),e}function R(e,t){return e!==t&&M(),t}function z(e,t){return e===null?null:t(e)}function B(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&M();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&M();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&M(),r[n]=t.value}return r}function V(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&M();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&M(),r.push(n(i.value))}return r}function H(e){let t=N(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)||M(),t}function U(e){let t=N(e,64);return/^[0-9a-f]{64}$/.test(t)||M(),t}function W(e){let t=N(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||M(),t}function te(e,t){return W(e),W(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ne(e){let t=N(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||M(),t}function G(e,t=k.controlBytes){let n=t,r=e=>{if(n-=P(e),n<0)throw new j(`oversize`);return e};function i(e,n){if(n>64&&M(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return N(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||M(),r(JSON.stringify(e));if(Array.isArray(e)){let a=V(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`)&&M();let a=t.sort(),o=B(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 M()}return i(e,0)}function re(e,t=k.controlBytes){N(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 N(JSON.parse(e.slice(r,n)),t)}catch{return M()}i=!i&&a===`\\`}return M()}function a(t){if(t>64&&M(),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]!==`"`&&M(),d=i(),u.has(d)&&M(),u.add(d),r(),e[n++]!==`:`&&M());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&M()}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||M(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&M(),s}let o=a(0);return r(),n!==e.length&&M(),o}function ie(e){let t=B(e,[`code`,`effect`,`recovery`]);return{code:L(t.code,A),effect:L(t.effect,[`none`,`accepted`,`uncertain`]),recovery:L(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var K=[`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 q(e){let t=B(e,[`provider`,`model`,`api`,`thinking`]);return{provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:L(t.api,se),thinking:L(t.thinking,ce)}}function le(e){let{sourceSelectionId:t,...n}=B(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:H(t),...q(n)}}function ue(e){let t=B(e,[`role`,`sha256`]);return{role:L(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:U(t.sha256)}}function J(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function Y(e){let t=B(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:H(t.recordId),version:F(t.version,1),field:L(t.field,K),bytes:F(t.bytes,0,k.detailBytes),sha256:U(t.sha256)}}function de(e){let t=B(e,[`start`,`end`]),n=F(t.start);return{start:n,end:F(t.end,n+1,k.detailBytes)}}function fe(e){let t=B(e,[`source`,`range`,`requireCompleteObservation`]),n=X(t.source),r;if(n===`current`)r={kind:n,assignmentId:ne(B(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=B(t.source,[`kind`,`runId`,`childRunId`,`result`]);R(n,`historical`);let i=Y(e.result);R(i.field,`final-text`),r={kind:`historical`,runId:H(e.runId),childRunId:H(e.childRunId),result:i}}let i=z(t.range,de);return r.kind===`historical`&&i&&i.end>r.result.bytes&&M(),{source:r,range:i,requireCompleteObservation:I(t.requireCompleteObservation)}}function X(e,t=`kind`){(typeof e!=`object`||!e)&&M();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&M(),N(n.value,64,!0)}function pe(e){G(e,k.graphBytes);let t=B(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=Y(t.plan);R(n.field,`plan`);let r=F(t.planRevision,1);n.version!==r&&M();let i={schema:R(t.schema,D),taskId:H(t.taskId),taskKind:L(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:F(t.taskRevision,1),revision:F(t.revision,1),planRevision:r,plan:n,assignments:V(t.assignments,k.assignments,e=>{let t=B(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ne(t.id),purpose:L(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:N(t.instructions,k.instructionsBytes,!0),expectedOutput:N(t.expectedOutput,k.expectedOutputBytes,!0),role:ue(t.role),model:le(t.model),dependencies:V(t.dependencies,k.assignments,fe)}})};i.assignments.length||M();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&M();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&M(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&M(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||M(),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!==J(e.purpose))throw new j(`forbidden`);c(e)}return i}function me(e){let t=B(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=z(t.graphRevision,e=>F(e,1)),r=z(t.graphIdentity,U);return n===null!=(r===null)&&M(),{id:H(t.id),kind:L(t.kind,[`code`,`research`,`diagnosis`]),revision:F(t.revision,1),identity:U(t.identity),graphRevision:n,graphIdentity:r}}function he(e){let t=B(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=B(t.observation,[`identity`,`complete`]);return{epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),configRev:F(t.configRev,1),controlRev:F(t.controlRev,1),workspaceId:H(t.workspaceId),cwdId:H(t.cwdId),model:le(t.model),checkEnvGeneration:F(t.checkEnvGeneration,1),checkoutGeneration:F(t.checkoutGeneration),observation:{identity:U(n.identity),complete:I(n.complete)},task:z(t.task,me)}}function ge(e){let t=B(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:L(t.kind,[`configured`,`manual`]),name:N(t.name,128,!0),command:N(t.command,4096,!0),timeoutMs:F(t.timeoutMs,100,k.workerMs)},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`)&&M(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&M(),n}function _e(e){switch(G(e),X(e)){case`create`:{let t=B(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:L(t.taskKind,[`code`,`research`,`diagnosis`]),goal:N(t.goal,8192,!0)}}case`save-plan`:{let t=B(e,[`kind`,`taskId`,`plan`,`graph`]),n=pe(t.graph),r=H(t.taskId);return n.taskId!==r&&M(),{kind:`save-plan`,taskId:r,plan:N(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:X(e),taskId:H(B(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=B(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:H(t.taskId),check:ge(t.check)}}case`review`:{let t=B(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:H(t.taskId),runId:H(t.runId),changesIdentity:U(t.changesIdentity),checksRevision:F(t.checksRevision),acceptIssues:I(t.acceptIssues)}}default:return M()}}function ve(e){G(e);let t=B(e,[`expected`,`action`]);return{expected:he(t.expected),action:_e(t.action)}}function ye(e){G(e);let t=B(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:H(t.commandId),grant:H(t.grant),expected:he(t.expected),action:_e(t.action)}}function be(e){if(G(e),X(e)===`action`){let t=B(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:he(t.expected),action:_e(t.action)}}let t=B(e,[`kind`,`epoch`,`runId`]);return R(t.kind,`cancel`),{kind:`cancel`,epoch:H(t.epoch),runId:H(t.runId)}}function xe(e){let t=B(e,[`commandId`,`epoch`,`runId`]);return{commandId:H(t.commandId),epoch:H(t.epoch),runId:H(t.runId)}}function Se(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=B(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=V(n.configuredChecks,32,ge);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&M(),{...t?{checkEnvironmentPolicy:R(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:F(n.checksRevision),reviewRunId:z(n.reviewRunId,H),version:he(n.version),action:_e(n.action),rootLabel:N(n.rootLabel,4096,!0),cwdLabel:N(n.cwdLabel,4096,!0),readablePlan:N(n.readablePlan,32768),graph:z(n.graph,pe),activeRunId:z(n.activeRunId,H),issues:V(n.issues,7,e=>L(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ce(e){G(e);let t=B(e,[`grant`,`expiresAt`,`preview`]),n=N(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)&&M(),{grant:H(t.grant),expiresAt:n,preview:Se(t.preview)}}function we(e){let t=B(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:L(t.observed,[`complete`,`incomplete`]),source:L(t.source,[`complete`,`limited`,`unavailable`]),redacted:I(t.redacted),omissions:V(t.omissions,6,e=>L(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`))&&M(),n}function Te(e){let t=B(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:F(t.graphRevision,1),inputs:V(t.inputs,k.assignments,e=>{let t=B(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=Y(t.result);R(i.field,`final-text`);let a=z(t.range,de);a&&a.end>i.bytes&&M();let o=N(t.text,k.predecessorBytes);if(n+=P(o),n>k.handoffBytes)throw new j(`oversize`);let s=F(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&M(),r.add(s),P(o)!==(a?a.end-a.start:i.bytes)&&M(),{assignmentId:ne(t.assignmentId),dependencyIndex:s,runId:H(t.runId),childRunId:H(t.childRunId),result:i,range:a,text:o,coverage:we(t.coverage)}})}}function Ee(e){let t=B(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:L(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:L(t.closure,oe),exitCode:z(t.exitCode,e=>F(e,-2147483648,4294967295)),signal:z(t.signal,e=>N(e,32,!0)),durationMs:F(t.durationMs),stdin:L(t.stdin,[`delivered`,`failed`,`not-required`]),final:L(t.final,[`valid`,`missing`,`invalid`]),cleanup:L(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:we(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&M(),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`)&&M(),n}function De(e){let t=B(e,[`kind`,`id`]);return{kind:L(t.kind,[`task`,`run`,`child`]),id:H(t.id)}}function Oe(e){let t=N(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||M(),t}function ke(e){G(e);let t=B(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:H(t.storeId),scope:De(t.scope),query:z(t.query,e=>{let t=N(e,k.queryBytes);return t.length||M(),t}),snapshotSeq:W(t.snapshotSeq),recordId:z(t.recordId,H),recordVersion:z(t.recordVersion,e=>F(e,1)),field:z(t.field,e=>L(e,K)),offset:F(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&M(),n}function Ae(e){let t=B(e,[`disposition`,`value`]),n=L(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&M(),{disposition:n,value:r}}function je(e){let t=B(e,[`messageId`,`blockId`]);return{messageId:H(t.messageId),blockId:H(t.blockId)}}function Me(e){let t=X(e);if(t===`message-final`)return{kind:t,messageId:H(B(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:L(B(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=B(e,[`kind`,`dependencyIndex`,`source`]),r=Y(n.source);return R(r.field,`final-text`),{kind:t,dependencyIndex:F(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=B(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:H(n.messageId),blockId:H(n.blockId),index:F(n.index,0,k.dataFrames),stage:L(n.stage,[`stream`,`final`])}}let n=B(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return R(t,`tool`),{kind:`tool`,callId:H(n.callId),blockId:H(n.blockId),index:F(n.index,0,k.dataFrames),stage:L(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=B(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=L(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=L(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`))&&M(),{owner:n,field:r,encoding:i}}function Pe(e){let t=B(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=L(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=L(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=z(t.mimeType,e=>N(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)))&&M(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=N(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||M(),t}function Ie(e){let t=X(e);switch(t){case`ready`:{let n=B(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:R(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=B(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:N(e.sdkVersion,128,!0),workerHash:U(e.workerHash)}})()}}}case`message-start`:{let n=B(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=L(n.role,[`user`,`assistant`,`tool-result`]),i=z(n.resultCallId,H);return r!==`tool-result`&&i!==null&&M(),{kind:t,messageId:H(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=B(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:H(n.detailId)}}case`message-end`:{let n=B(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:H(n.messageId),finalDetailId:z(n.finalDetailId,H),finalBlockCount:F(n.finalBlockCount,0,k.dataFrames),stopReason:L(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=B(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:H(n.callId),declaration:je(n.declaration),index:F(n.index,0,k.dataFrames),source:Ae(n.source),name:N(n.name,128,!0),argsDetailId:z(n.argsDetailId,H),stage:L(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=B(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:H(n.callId),declaration:z(n.declaration,je),source:Ae(n.source),name:N(n.name,128,!0),argsDetailId:z(n.argsDetailId,H)}}case`tool-update`:{let n=B(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:H(n.callId),detailId:H(n.detailId),semantics:R(n.semantics,`snapshot`)}}case`tool-end`:{let n=B(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=L(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=z(n.declaration,je),a=I(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&M(),{kind:t,callId:H(n.callId),declaration:i,source:Ae(n.source),name:N(n.name,128,!0),resultDetailId:H(n.resultDetailId),isError:I(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(B(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=B(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:H(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=B(e,[`kind`,`detailId`,`offset`,`text`]),r=N(n.text,k.chunkBytes),i=F(n.offset,0,k.detailBytes);return i+P(r)>k.detailBytes&&M(),{kind:t,detailId:H(n.detailId),offset:i,text:r}}case`detail-end`:{let n=B(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:H(n.detailId),bytes:F(n.bytes,0,k.detailBytes),sha256:U(n.sha256),coverage:we(n.coverage)}}case`capture-status`:return{kind:t,coverage:we(B(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:L(B(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=B(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:H(n.messageId),detailId:H(n.detailId),stopReason:R(n.stopReason,`stop`)}}default:return M()}}function Le(e){let t=B(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:L(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:L(t.closure,oe),exitCode:z(t.exitCode,e=>F(e,-2147483648,4294967295)),signal:z(t.signal,e=>N(e,32,!0)),durationMs:F(t.durationMs),stdin:R(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))&&M(),n}function Re(e){let t=B(e,[`messageId`,`detailId`]);return{messageId:H(t.messageId),detailId:H(t.detailId)}}function ze(e){let t=B(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=W(t.committedSeq);return n===`0`&&M(),{childRunId:H(t.childRunId),detailId:H(t.detailId),content:Y(t.content),committedSeq:n}}function Be(e){let t=X(e,`status`);if(t===`committed`){let n=B(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&M(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=B(e,[`status`,`selected`,`error`]);return{status:t,selected:z(n.selected,Re),error:ie(n.error)}}let n=B(e,[`status`,`selected`]);return{status:L(t,[`pending`,`uncertain`]),selected:z(n.selected,Re)}}function Ve(e,t){let n=z(e,W);return(n===`0`||n!==null&&t.status===`committed`&&te(n,t.detail.committedSeq)<0)&&M(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=X(e);if(t===`sdk`){let n=B(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=B(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=z(n.settlementSeq,W);return r===`0`&&M(),{kind:t,native:Le(n.native),capture:we(n.capture),settlementSeq:r}}let n=B(e,[`kind`,`outcome`,`required`]);R(t,`parent`);let r=V(n.required,k.assignments,e=>{let t=B(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=H(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&M(),{assignmentId:ne(t.assignmentId),childRunId:n,native:z(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=L(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(He))&&M(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=B(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=F(t.first,1,k.dataFrames+k.controlFrames),r=F(t.last,n,k.dataFrames+k.controlFrames),i=F(t.firstObservedMs),a=F(t.lastObservedMs,i);return n===r&&i!==a&&M(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=B(e,[`source`,`event`]),n=Ge(t.source),r=X(t.event);if(r===`stored-chunk`){let e=B(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:H(e.detailId),text:N(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=B(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:H(e.detailId),coverage:we(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&M(),{source:n,event:i}}function qe(e){let t=B(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:H(t.epoch),taskId:H(t.taskId),runId:H(t.runId),childRunId:H(t.childRunId)}}function Je(e){G({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=B(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:H(n.storeId),workspaceId:H(n.workspaceId),epoch:H(n.epoch)};if(!t)return R(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=V(n.runs,k.episodes,e=>{let t=B(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:H(t.taskId),runId:H(t.runId),operationId:H(t.operationId),epoch:H(t.epoch),kind:L(t.kind,[`start`,`generate-plan`,`check`]),stage:L(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)&&M(),{...r,status:`complete`,runs:i}}function Ye(e){let t=ie(e);return R(t.effect,`none`),t}function Xe(e){let t=B(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:U(t.sourceHash),contractHash:U(t.contractHash),buildId:U(t.buildId)}}function Ze(e){let t=L(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=B(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:U(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=B(e,[`contractHash`,`assets`]);return{contractHash:U(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){G(e);let t=B(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:H(t.commandId),operationId:H(t.operationId),runId:z(t.runId,H),admission:L(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:W(t.committedSeq),execution:z(t.execution,e=>L(e,ae)),settlement:z(t.settlement,We),created:z(t.created,e=>{let t=B(e,[`kind`,`taskId`,`state`]);return{kind:R(t.kind,`task`),taskId:H(t.taskId),state:L(t.state,[`reserved`,`published`])}}),publication:L(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&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&M(),n}function tt(e){G(e);let t=B(e,[`identity`,`receipt`]),n=be(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&M();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&M(),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`))&&M()}return{identity:n,receipt:r}}function Z(e,t){if(X(e)===`ok`)return{kind:`ok`,value:t(B(e,[`kind`,`value`]).value)};let n=B(e,[`kind`,`error`]);return R(n.kind,`error`),{kind:`error`,error:ie(n.error)}}function nt(e){switch(G(e),X(e,`status`)){case`found`:return{status:`found`,receipt:et(B(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:W(B(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ie(B(e,[`status`,`error`]).error)};default:return M()}}function rt(e){let t=B(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:H(t.runId),taskId:H(t.taskId),childRunId:z(t.childRunId,H),assignmentId:z(t.assignmentId,ne),admission:pt(t.admission),lifecycle:L(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:z(t.outcome,e=>L(e,ae)),settlement:z(t.settlement,We),reason:z(t.reason,e=>L(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:L(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:we(t.coverage),result:z(t.result,Y)};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`&&G(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==G(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&G(n.result)!==G(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&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&M(),n}function it(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function at(e,t,n){return it(e,t)&&e.taskId===gt(n)&&e.admission.context.workspaceId===ht(n)}function ot(e){G(e,k.pageBytes);let t=B(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:R(t.protocol,1),storeId:H(t.storeId),epoch:H(t.epoch),scope:De(t.scope),committedSeq:W(t.committedSeq),context:mt(t.context),runs:V(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||G(n.horizon.historicalRuns.scope)!==G(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&M(),n}function st(e){G(e,k.pageBytes);let t=X(e),n=B(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:H(n.storeId),epoch:H(n.epoch),scope:De(n.scope),committedSeq:W(n.committedSeq)};if(t===`update`){let e=W(n.previousSeq);te(r.committedSeq,e)<=0&&M();let i=mt(n.context);_t(i,r.epoch,r.scope)||M();let a=V(n.runs,k.maxPageEntries,rt),o=V(n.removed,k.maxPageEntries,H),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&M(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return R(t,`heartbeat`),{kind:`heartbeat`,...r}}function ct(e){let{navigation:t,...n}=e;return n}function lt(e,t){(!t.navigation||t.navigation===e.navigation||G(ct(e))!==G(ct(t)))&&M()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:we(t.coverage)}}function dt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:Y(t.content),range:z(t.range,de),text:N(t.text,k.detailPageBytes),next:z(t.next,ke),coverage:we(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!==P(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&M(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&M(),n.next&&(n.next.offset!==n.range?.end||G(ct({...n.next,offset:n.cursor.offset}))!==G(ct(n.cursor)))&&M(),n}function ft(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||M();let r=P(n.query),i=V(t.hits,k.maxPageEntries,e=>{let t=B(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=Y(t.content),a=bt(t.owner);xt(a,n.scope)||M();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||G(s.scope)!==G(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&M(),{content:i,owner:a,range:o,preview:N(t.preview,k.previewBytes),cursor:s}}),a=z(t.next,ke);return a&&(a.storeId!==n.storeId||G(a.scope)!==G(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)))&&M(),{cursor:n,hits:i,next:a,coverage:we(t.coverage)}}function pt(e){let t=B(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=he(t.context),r=z(t.graph,e=>{let t=B(e,[`recordId`,`revision`,`sha256`]);return{recordId:H(t.recordId),revision:F(t.revision,1),sha256:U(t.sha256)}}),i=L(t.kind,[`start`,`generate-plan`,`check`]),a=V(t.assignments,k.assignments,e=>{let t=B(e,[`assignmentId`,`childRunId`]);return{assignmentId:ne(t.assignmentId),childRunId:H(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)&&M(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&M(),{operationId:H(t.operationId),commandId:H(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(X(e,`status`)===`available`)return{status:`available`,version:he(B(e,[`status`,`version`]).version)};let t=B(e,[`status`,`workspaceId`,`taskId`,`error`]);R(t.status,`unavailable`);let n=ie(t.error);return R(n.effect,`none`),{status:`unavailable`,workspaceId:H(t.workspaceId),taskId:z(t.taskId,H),error:n}}function ht(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function gt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function _t(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||gt(e)===n.id)}function vt(e){let t=B(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=B(t.capabilities,[`actions`,`manualChecks`,`history`]),r=L(t.authority,[`browser`,`local`]),i=z(t.csrf,H),a={actions:I(n.actions),manualChecks:I(n.manualChecks),history:I(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&M(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:R(t.protocol,1),storeId:H(t.storeId),epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:H(t.workspaceId),storeId:H(t.storeId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),rootLabel:N(t.rootLabel,4096,!0),context:mt(t.context),models:V(t.models,k.maxPageEntries,le)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&M(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&M(),n}function bt(e){let t=B(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=B(t.entity,[`kind`,`id`,`version`]),r={taskId:H(t.taskId),runId:z(t.runId,H),childRunId:z(t.childRunId,H),entity:{kind:L(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:H(n.id),version:F(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)&&M(),r}function xt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function St(e){let t=B(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:U(t.identity),complete:I(t.complete),checkoutGeneration:F(t.checkoutGeneration)}}function Ct(e){G(e,k.controlBytes);let t=X(e);switch(t){case`assignment-state`:{let n=B(e,[`kind`,`childRunId`,`state`,`reason`]),r=L(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=z(n.reason,e=>L(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&M(),(r===`ready`||r===`preparing`)&&i!==null&&M(),{kind:t,childRunId:H(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:L(B(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=B(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:H(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=B(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&M(),{kind:t,runId:H(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=B(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:H(r.reservationId)}:{},lane:L(r.lane,[`reader`,`writer`,`check`]),state:L(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:F(r.checkoutGeneration)}}case`handoff`:{let n=B(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:H(n.childRunId),handoff:Te(n.handoff),observation:St(n.observation)}}case`changes`:{let n=B(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=Y(n.content);return R(r.field,`changes`),{kind:t,observationId:H(n.observationId),stage:L(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=B(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:H(n.checkId),selection:ge(n.selection),cwdId:H(n.cwdId),cwdLabel:N(n.cwdLabel,4096,!0),checkEnvGeneration:F(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=B(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=B(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:H(e.operationId),reservationId:H(e.reservationId),from:F(e.from),to:F(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&M()}let a=Le(r.native),o=L(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=z(r.output,Y),u=we(r.coverage);return l&&l.field!==`check`&&M(),o===`passed`&&(a.outcome!==`completed`||G({...s,checkoutGeneration:c.checkoutGeneration})!==G(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&M(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&M(),{kind:t,...i?{ownAdvance:i}:{},checkId:H(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=B(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=I(n.acceptIssues),i=L(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=Y(n.content);return R(a.field,`review`),i===`reviewed-with-issues`&&!r&&M(),{kind:t,reviewId:H(n.reviewId),runId:H(n.runId),checksRevision:F(n.checksRevision),changesIdentity:U(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=B(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=F(n.expectedRevision),i=z(n.expectedIdentity,U),a=F(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&M(),{kind:t,publicationId:H(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:U(n.nextIdentity)}}case`publication-settled`:{let n=B(e,[`kind`,`publicationId`,`status`,`observed`]),r=L(n.status,[`published`,`conflict`,`uncertain`]),i=z(n.observed,e=>{let t=B(e,[`revision`,`identity`]);return{revision:F(t.revision,1),identity:U(t.identity)}});return r===`published`&&i===null&&M(),{kind:t,publicationId:H(n.publicationId),status:r,observed:i}}default:return M()}}function wt(e){let t=B(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:H(t.epoch),operationId:H(t.operationId),taskId:H(t.taskId),runId:z(t.runId,H)}}function Tt(e){G(e,k.ownerQueueBytes);let t=B(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=V(t.events,k.ownerQueueFrames,e=>{let t=X(e);if(t===`fact`){let r=Ct(B(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)&&M(),{kind:t,fact:r}}if(t===`content-begin`){let r=B(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=L(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))&&M(),{kind:t,detailId:H(r.detailId),owner:i,field:a,encoding:R(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=B(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:H(n.detailId),text:N(n.text,k.chunkBytes)}}let r=B(e,[`kind`,`detailId`,`coverage`]);return R(t,`content-end`),{kind:`content-end`,detailId:H(r.detailId),coverage:we(r.coverage)}});return{observedMs:F(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=B(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=L(t.reader,Et),r=B(t.scope,[`kind`,`id`]),i={kind:L(r.kind,[`workspace`,`task`,`run`,`child`]),id:H(r.id)},a=z(t.snapshotSeq,W),o=z(t.after,e=>{let t=B(e,[`recordId`,`version`,`offset`]);return{recordId:H(t.recordId),version:F(t.version,1),offset:F(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&M(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:i,snapshotSeq:a,after:o,limit:F(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=B(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&M(),{policy:R(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=X(e);if(t===`run`)return{kind:t,projection:rt(B(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=B(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=W(n.committedSeq);return r===`0`&&M(),{kind:t,recordId:H(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=B(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Tt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&M();let a=W(n.committedSeq);return a===`0`&&M(),{kind:t,recordId:H(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=B(e,[...n,...r]),a=bt(i.owner),o=F(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&M(),t===`task`){let e=z(i.plan,Y);return e&&e.field!==`plan`&&M(),{kind:t,owner:a,version:o,goal:N(i.goal,8192,!0),plan:e}}if(t===`message`){let e=L(i.role,[`user`,`assistant`,`tool-result`]),n=L(i.state,[`partial`,`final`]),r=z(i.finalBlockCount,e=>F(e,0,k.dataFrames)),s=z(i.finalText,Y),c=z(i.resultCallId,H);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&M(),{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=z(i.declaration,je),n=z(i.declarationStage,e=>L(e,[`partial`,`final`])),r=I(i.startObserved),s=z(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&M(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&M(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:N(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=Y(i.content);return(e.field!==n.field||!At(e.owner,a))&&M(),{kind:t,owner:a,version:o,detailId:H(i.detailId),descriptor:e,content:n,coverage:we(i.coverage)}}R(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||M(),{kind:`omitted`,owner:a,version:o,block:s}}function At(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 jt(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 Mt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&M();let r=V(t.records,n.limit,kt),i=z(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||G(ct({...i,after:n.after}))!==G(ct(n))||G(i.after)===G(n.after)))&&M(),{request:n,records:r,next:i,coverage:we(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||G(ct({...r,snapshotSeq:null}))!==G(ct(n)))&&M(),{kind:`snapshot`,request:n,next:r,coverage:we(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:we(t.coverage)}}function Pt(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=B(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),graph:{recordId:H(n.recordId),revision:F(n.revision,1),sha256:U(n.sha256)}}}function It(e){G({kind:`ok`,value:e});let t=B(e,[`request`,`graph`]),n=Ft(t.request),r=pe(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&M(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:we(t.coverage)}}function Rt(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),format:L(t.format,[`ndjson`,`markdown`])}}function zt(e){G(e,k.controlBytes);let t=B(e,[`exportId`,`ordinal`,`event`]),n=X(t.event),r;switch(n){case`manifest`:{let e=B(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=B(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:U(i.exporterBuildSha256),capturePolicy:R(i.capturePolicy,`public-text-tools/2`)},schema:R(e.schema,O),request:Rt(e.request),coverage:we(e.coverage),serviceProtocol:R(e.serviceProtocol,1),workerProtocol:R(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(B(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(B(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=B(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=Y(e.content),a=z(e.range,de),o=N(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==P(o):i.bytes!==0||o!==``)&&M(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:we(e.coverage)};break}case`markdown`:r={kind:n,text:N(B(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=B(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=we(e.coverage),a=I(e.complete);a&&i.observed!==`complete`&&M(),r={kind:n,complete:a,frames:F(e.frames,1),encodedBytes:F(e.encodedBytes),sha256:U(e.sha256),committedSeq:W(e.committedSeq),coverage:i};break}default:return M()}return{exportId:H(t.exportId),ordinal:F(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&M(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var Vt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Rt(e)}receive(e){let t=zt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&M(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&M():n.kind===`manifest`&&M(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&M(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&M(),this.request.format===`ndjson`&&n.kind===`markdown`&&M(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&M(),n.kind===`graph`&&(G(n.graph.request.scope)!==G(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&M(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&M(),this.bytes+=P(Bt(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 Ht(e,t){return e.kind===`run`?it(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:xt(e.owner,t)}function Ut(e){let t=B(e,[`taskId`,`revision`,`definitions`]),n=V(t.definitions,32,e=>{let t=B(e,[`selection`,`status`,`checkId`]),n=ge(t.selection),r=L(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=z(t.checkId,H);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&M(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&M(),{taskId:H(t.taskId),revision:F(t.revision),definitions:n}}function Wt(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),kind:L(t.kind,[`task`,`message`,`tool`]),id:H(t.id),version:F(t.version,1)}}function Gt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`record`]),n=Wt(t.request),r=kt(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||!xt(r.owner,n.scope))&&M(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:we(t.coverage)}}var qt=e=>{let t=ie(e);return R(t.effect,`none`),t};function Jt(e){let t=B(e,[`storeId`,`taskId`]);return{storeId:H(t.storeId),taskId:z(t.taskId,H)}}function Yt(e){let t=Jt(e);return t.taskId===null&&M(),t}function Xt(e){let t=B(e,[`id`,`kind`,`revision`,`identity`]);return{id:H(t.id),kind:L(t.kind,[`code`,`research`,`diagnosis`]),revision:F(t.revision,1),identity:U(t.identity)}}function Zt(e){let t=V(e,3,ue);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&M(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return B(e,[`status`]),{status:t};if(t===`saved`){let n=B(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:F(n.planRevision,1)}}let n=B(e,[`status`,`error`]);return R(n.status,`unavailable`),{status:`unavailable`,error:qt(n.error)}}function $t(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||ht(e.context)!==e.workspaceId||gt(e.context)!==e.request.taskId)&&M(),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))&&M()}}function en(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:H(t.workspaceId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),context:mt(t.context),task:z(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:z(t.readablePlan,e=>{let t=B(e,[`source`,`text`,`editable`,`coverage`]),n=we(t.coverage),r=I(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&M(),{source:R(t.source,`current-v1`),text:N(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&M();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))&&M(),r.status===`unavailable`&&n.context.status===`available`&&M(),n}function tn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=B(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:H(t.workspaceId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:U(n.identity),complete:I(n.complete),checkoutGeneration:F(n.checkoutGeneration,0)},text:N(t.text,131072),git:I(t.git),coverage:we(t.coverage)};if($t(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)&&M()}return r}function nn(e){let t=N(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||M(),t}function rn(e){let t=B(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:N(t.cwd,4096,!0)}}function an(e){let t=B(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:N(t.cwd,4096,!0),revision:F(t.revision,0,2**53-1-1),model:z(t.model,q)}}function on(e){let t=B(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:N(t.cwd,4096,!0),checkoutRoot:N(t.checkoutRoot,4096,!0),version:sn(t.version),model:z(t.model,le)}}function sn(e){let t=B(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),configRev:F(t.configRev,1),catalogId:H(t.catalogId)}}function cn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`version`,`selected`]);return{version:sn(t.version),selected:z(t.selected,le)}}function ln(e){G(e);let t=B(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:q(t.choice)}}function un(e){let t=B(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:z(t.api,e=>L(e,se)),thinking:V(t.thinking,7,e=>{let t=B(e,[`level`,`selectable`]);return{level:L(t.level,ce),selectable:I(t.selectable)}}),eligibility:L(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))&&M(),n}function dn(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 fn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=V(t.entries,k.maxPageEntries,un),r=z(t.remembered,q),i=L(t.status,[`complete`,`capacity`]),a=F(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length||r&&!dn(n,r))&&M(),{version:sn(t.version),selected:z(t.selected,le),status:i,entries:n,withheld:a,remembered:r}}function pn(e){let t=B(e,[`id`,`path`,`cwd`,`epoch`]);return{id:U(t.id),path:N(t.path,4096,!0),cwd:N(t.cwd,4096,!0),epoch:t.epoch===null?null:H(t.epoch)}}function mn(e){let t=B(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:R(t.kind,`project-observation`),status:L(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:H(t.epoch),workspaceId:t.workspaceId===null?null:H(t.workspaceId)}}var hn=[`registry`,`workbench`,`project`],gn=[`reboot`,`crash`,`restart`,`storage`],_n=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function vn(e){let t=B(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:H(t.id),at:F(t.at,0),scope:L(t.scope,hn),path:t.path===null?null:N(t.path,4096,!0),cause:L(t.cause,gn),actions:V(t.actions,_n.length,e=>L(e,_n)),workers:F(t.workers,0,1e6),archived:I(t.archived)}}function yn(e){let t=B(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:R(t.kind,`workbench`),epoch:H(t.epoch),csrf:H(t.csrf),home:N(t.home,4096,!0),projects:V(t.projects,128,pn),recoveries:V(t.recoveries,20,vn),build:Qe(t.build)}}var bn=[`restart`,`upgrade`],xn=[`running`,`ready`,`failed`,`rolled-back`],Sn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Cn=/^(?: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 wn(e){let t=N(e,96,!0);if(!Cn.test(t))throw new j(`invalid`);return t}function Tn(e){let t=B(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:H(t.id),action:L(t.action,bn),from:wn(t.from),to:t.to===null?null:wn(t.to),state:L(t.state,xn),reason:t.reason===null?null:L(t.reason,Sn),version:t.version===null?null:wn(t.version),at:F(t.at,0),endedAt:t.endedAt===null?null:F(t.endedAt,0)}}var En=[`npm`,`not-npm-global`,`not-writable`];function Dn(e){let t=B(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=B(t.unit,[`name`,`scope`]);n={name:N(e.name,96,!0),scope:L(e.scope,[`user`,`system`])}}return{kind:R(t.kind,`service`),version:wn(t.version),unit:n,upgrade:L(t.upgrade,En),work:F(t.work,0,1e6),job:t.job===null?null:Tn(t.job)}}function On(e){let t=B(e,[`kind`,`version`,`deprecated`]);return{kind:R(t.kind,`release`),version:wn(t.version),deprecated:I(t.deprecated)}}function kn(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}var An={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function jn(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Mn(e,t=!1){let n=N(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(`Invalid workflow file path`);return n}var Nn=(e,t=!1)=>{let n=N(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function Pn(e){let t=B(e,[`name`,`command`,`timeoutMs`]);return{name:N(t.name,128,!0),command:N(t.command,4096,!0),timeoutMs:F(t.timeoutMs,100,12e5)}}function Fn(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate task id`);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(`Missing dependency or cyclic plan`);n.push(r),t.add(r.id)}return n}function In(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 Fn(e),r(t),Fn(e).filter(e=>n.has(e.id))}function Ln(e,t={}){let n=t.strict===!0;G(e,An.bytes);let r=B(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=V(r.tasks,An.tasks,e=>{let t=B(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Nn(t.id,n),title:N(t.title,256,!0),instructions:N(t.instructions,8192,!0),writes:V(t.writes,128,e=>Mn(e,n)),after:V(t.after,An.tasks,e=>Nn(e,n))}});if(!i.length||i.some(e=>!e.writes.length||new Set(e.writes).size!==e.writes.length||new Set(e.after).size!==e.after.length))throw Error(`Empty or duplicate task scope`);Fn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||In(i,e.id).some(e=>e.id===t.id)||In(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>jn(t.writes,e))||t.writes.some(t=>jn(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=V(r.checks,An.checks,Pn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:N(r.goal,8192,!0),design:N(r.design,32768,!0),decisions:N(r.decisions,16384),acceptance:N(r.acceptance,16384,!0),projectContext:N(r.projectContext,16384),tasks:i,checks:a,setup:V(r.setup,4,Pn),baselineChecks:V(r.baselineChecks,An.checks,Pn),repairAttempts:F(r.repairAttempts,0,An.repairs),delivery:L(r.delivery,[`local-merge`,`working-copy`])};Rn(o),N(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
2
- `&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function Rn(e){return N(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function zn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=B(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...t?[`display`]:[]]);return{id:H(n.id),epoch:H(n.epoch),digest:U(n.digest),observation:U(n.observation),model:sn(n.model),plan:Ln(n.plan),cwd:N(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:N(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=B(n.display,[`model`,`branch`,`baseCommit`]);return{model:N(e.model,1024,!0),branch:N(e.branch,1024),baseCommit:N(e.baseCommit,64)}})()}:{}}}function Bn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=B(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=V(n.questions,An.parallel,e=>N(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:V(n.roots,8,e=>N(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:N(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:sn(n.model)}}if(t===`propose`){let n=B(e,[`action`,`plan`,`model`]);return{action:t,plan:Ln(n.plan),model:sn(n.model)}}if(t===`prepare`||t===`execute`){let n=B(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:H(n.proposalId),digest:U(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:H(n.grant)}}let n=B(e,[`action`,`runId`]);return{action:L(n.action,[`cancel`]),runId:H(n.runId)}}function Vn(e){let t=B(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),n=e=>L(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Kn(t.diagnostics)},id:H(t.id),epoch:H(t.epoch),goal:N(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:L(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:N(t.notice,2048),mergedCommit:z(t.mergedCommit,e=>N(e,64,!0)),humanReviewed:!1,steps:V(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=B(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:Gn(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=B(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:N(e.sdkVersion,128,!0),workerHash:U(e.workerHash)}})()},id:N(r.id,160,!0),...t?{childRunId:H(r.childRunId)}:{},kind:L(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:N(r.text,65536),exitCode:z(r.exitCode,e=>F(e,-2147483648,2147483647)),truncated:I(r.truncated)}})}}function Hn(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Vn(B(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:zn(B(e,[`type`,`proposal`]).proposal)};let n=B(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:L(n.type,[`grant`]),proposal:zn(n.proposal),grant:H(n.grant),expiresAt:F(n.expiresAt,0)}}function Un(e){return`# ${e.goal}\n\n## Design\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${Fn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
1
+ import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./react.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}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 f=e(n(),1),p=t(),m={"Invalid or oversized 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.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"PNG, JPEG or WebP · {count} images · {each} MiB each · {total} MiB total. Unsent images stay in this tab.":`PNG、JPEG 或 WebP · 最多 {count} 张 · 单张 {each} MiB · 总计 {total} MiB。未发送图片仅保留在当前页面。`,"Too many images or total image size exceeded.":`图片数量或总大小超出限制。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty or too large.":`图片为空或超过大小限制。`,"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 is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.":`当前执行服务无法接受此计划审批。请先发送消息以刷新会话;未批准任何实施。`,"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 to start chatting.":`选择工作目录后即可开始对话。`,"Choose a working folder. Execution is prepared only when you send.":`选择工作目录;仅在发送消息时准备执行服务。`,"Conversations stay with their folder. Select one to read its history; Send prepares execution.":`会话按目录保留。选择目录即可查看历史;发送时才准备执行服务。`,"Selecting a folder does not start execution. Send prepares it when needed.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Execution will be prepared when you send. Browsing does not start it.":`发送消息时会按需准备执行服务,浏览不会启动服务。`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"The message was not sent ({code}). Its draft is kept; preparation may have started an execution service.":`消息尚未发送({code})。草稿已保留;准备过程中可能已启动执行服务。`,"Connection unavailable. Existing work may continue; no message is replayed automatically.":`连接当前不可用。已接纳的工作可能仍在运行;不会自动重发任何消息。`,"Execution compatibility not observed":`尚未读取执行服务兼容性`,"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":`历史详情`,"Select retained history to inspect":`选择保留的历史记录查看`,"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":`等待批准计划`,"Ready for conversation":`可以继续对话`,"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 only this plan: implementation, checks, bounded repairs and the displayed local delivery. 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.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"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 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"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.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,"Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.":`暂时无法发送。请检查消息是否超过 16 KiB;如有待确认的命令,请先观察其结果,不要重复发送。`,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":`停止回复`,"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:":`尚未观察到此次发送的结果:`,"Observe this send before sending again. No automatic retry.":`请先观察此次发送的结果,不会自动重试。`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Reference {path}":`引用 {path}`,"Copy path {path}":`复制路径 {path}`,"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":`只读预览 · 引用只发送路径,不自动注入文件内容`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking is not retained.":`思考过程不保留。`,"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":`重新加载观察`,"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 projects":`最近项目`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Running conversations":`运行的对话`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"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}。`,"Context changed. Observe again and request a fresh confirmation.":`上下文已变化。请重新观察并请求新的确认。`,"Explicit service guidance: {status} / {start}. No service is started by this page.":`显式服务操作:{status} / {start}。本页面不会启动任何服务。`,"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}。`,"Shared compatibility: {state}.":`共享兼容性:{state}。`,compatible:`兼容`,"unavailable / mismatch — reload built assets; normal actions disabled":`不可用 / 不匹配——请重新加载构建产物;常规操作已禁用`,"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 or detach unconfirmed; explicit re-entry required.":`观察不可用或断开未确认;需要显式重新进入。`,"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; restart the service 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; restart the service 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}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"{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.":`未观察到活动或近期的执行轮次。`,"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:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,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.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"The model list changed and was read again. Choose once more.":`模型列表已变化并已重新读取,请再选一次。`,"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.":`不支持此模型或思考级别。`,"The choice was not confirmed. The list was read again; check the current model before choosing again.":`未能确认这次选择,列表已重新读取;请先确认当前模型再重新选择。`,"Model unavailable":`模型不可用`,"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 restart the service.":`还没有配置模型。请在 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…":`正在切换模型…`,"Every conversation in this project uses this 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}),结束后再试。`,"This page was out of date ({code}) and has been read again. Try once more.":`页面状态已过期({code}),已重新读取,请再试一次。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"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.":`还没有对话。`,"The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.":`无法读取 {name} 的历史会话。请明确选择目录;没有启动任何服务。`,"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 workbench was not started by Cadence's 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}`,Updates:`更新`,"npm could not be reached.":`无法连接 npm。`,"Check for updates":`检查更新`,"Asking npm for the latest version…":`正在向 npm 查询最新版本…`,"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 copy was not installed with npm install -g; upgrade it the way you installed it.":`{version} 可用,但当前副本不是通过 npm install -g 安装的;请按原安装方式升级。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`npm 会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade 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.":`正在运行的服务没有确认有序停止。`,"npm could not install the release.":`npm 无法安装该版本。`,"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})`,"Show the latest":`查看最新`,"Show the conversation up to here. The next message starts a new branch; nothing is deleted.":`只显示到这里为止的对话。下一条消息会从这里开始一个新分支,不会删除任何内容。`,"Continue from here":`从这里继续`,"You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.":`你正在查看这段对话较早的位置。现在发送的消息会从这里开始一个新分支,其余内容仍保留在会话中。`,Terminal:`终端`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},h=r(),g=`cadence-locale`,_=new Map(Object.entries(m));function v(e,t,n){let r=e===`zh`?_.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var y={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`This page was out of date ({code}) and has been read again. Try once more.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"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 b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);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 C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,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}),ee=[`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`],A=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function te(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 j(){throw new A}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new A(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(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)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function ne(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function re(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=k.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new A(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(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`)&&j();let a=t.sort(),o=z(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 j()}return i(e,0)}function ie(e,t=k.controlBytes){M(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 M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),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]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}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||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function ae(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,ee),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var G=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],oe=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],se=[`not-launched`,`direct-child-closed`,`unconfirmed`],ce=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],le=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function K(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,ce),thinking:I(t.thinking,le)}}function ue(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...K(n)}}function de(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function pe(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,G),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function me(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function he(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:re(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=pe(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,me);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function ge(e){W(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,D),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:re(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,k.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,k.expectedOutputBytes,!0),role:de(t.role),model:ue(t.model),dependencies:B(t.dependencies,k.assignments,he)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),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 A(`forbidden`);c(e)}return i}function _e(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function ve(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:ue(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,_e)}}function J(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,k.workerMs)},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`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function Y(e){switch(W(e),q(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=ge(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:q(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:J(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function ye(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:ve(t.expected),action:Y(t.action)}}function be(e){W(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:ve(t.expected),action:Y(t.action)}}function xe(e){if(W(e),q(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:Y(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function Se(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function Ce(e){W(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,J);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:ve(n.version),action:Y(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,ge),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function we(e){W(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(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)&&j(),{grant:V(t.grant),expiresAt:n,preview:Ce(t.preview)}}function X(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(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`))&&j(),n}function Te(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=pe(t.result);L(i.field,`final-text`);let a=R(t.range,me);a&&a.end>i.bytes&&j();let o=M(t.text,k.predecessorBytes);if(n+=N(o),n>k.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:re(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:X(t.coverage)}})}}function Ee(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:X(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),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`)&&j(),n}function De(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Oe(e){let t=M(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function ke(e){W(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:De(t.scope),query:R(t.query,e=>{let t=M(e,k.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,G)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Ae(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function je(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Me(e){let t=q(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=pe(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(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`))&&j(),{owner:n,field:r,encoding:i}}function Pe(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(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)))&&j(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Ie(e){let t=q(e);switch(t){case`ready`:{let n=z(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:L(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=z(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()}}}case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,k.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:je(n.declaration),index:P(n.index,0,k.dataFrames),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,je),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,je),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Ae(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+N(r)>k.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,k.detailBytes),sha256:H(n.sha256),coverage:X(n.coverage)}}case`capture-status`:return{kind:t,coverage:X(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Le(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(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))&&j(),n}function Re(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function ze(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:pe(t.content),committedSeq:n}}function Be(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Re),error:ae(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Re)}}function Ve(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&ne(n,t.detail.committedSeq)<0)&&j(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:X(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:re(t.assignmentId),childRunId:n,native:R(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,oe);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(He))&&j(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=z(e,[`source`,`event`]),n=Ge(t.source),r=q(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:X(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function qe(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Je(e){W({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=B(n.runs,k.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(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)&&j(),{...r,status:`complete`,runs:i}}function Ye(e){let t=ae(e);return L(t.effect,`none`),t}function Xe(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ze(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){W(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,oe)),settlement:R(t.settlement,We),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(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&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function tt(e){W(e);let t=z(e,[`identity`,`receipt`]),n=xe(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),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`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(q(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:ae(n.error)}}function nt(e){switch(W(e),q(e,`status`)){case`found`:return{status:`found`,receipt:et(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ae(z(e,[`status`,`error`]).error)};default:return j()}}function rt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,re),admission:pt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,oe)),settlement:R(t.settlement,We),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:X(t.coverage),result:R(t.result,pe)};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`&&W(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==W(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&W(n.result)!==W(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&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function it(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function at(e,t,n){return it(e,t)&&e.taskId===gt(n)&&e.admission.context.workspaceId===ht(n)}function ot(e){W(e,k.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:De(t.scope),committedSeq:U(t.committedSeq),context:mt(t.context),runs:B(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||W(n.horizon.historicalRuns.scope)!==W(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function st(e){W(e,k.pageBytes);let t=q(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:De(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);ne(r.committedSeq,e)<=0&&j();let i=mt(n.context);_t(i,r.epoch,r.scope)||j();let a=B(n.runs,k.maxPageEntries,rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function ct(e){let{navigation:t,...n}=e;return n}function lt(e,t){(!t.navigation||t.navigation===e.navigation||W(ct(e))!==W(ct(t)))&&j()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:X(t.coverage)}}function dt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:pe(t.content),range:R(t.range,me),text:M(t.text,k.detailPageBytes),next:R(t.next,ke),coverage:X(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!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||W(ct({...n.next,offset:n.cursor.offset}))!==W(ct(n.cursor)))&&j(),n}function ft(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=pe(t.content),a=bt(t.owner);xt(a,n.scope)||j();let o=me(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||W(s.scope)!==W(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,ke);return a&&(a.storeId!==n.storeId||W(a.scope)!==W(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)))&&j(),{cursor:n,hits:i,next:a,coverage:X(t.coverage)}}function pt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:re(t.assignmentId),childRunId:V(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)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(q(e,`status`)===`available`)return{status:`available`,version:ve(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=ae(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function ht(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function gt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function _t(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||gt(e)===n.id)}function vt(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:mt(t.context),models:B(t.models,k.maxPageEntries,ue)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function bt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(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)&&j(),r}function xt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function St(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function Ct(e){W(e,k.controlBytes);let t=q(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:Te(n.handoff),observation:St(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=pe(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:J(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Le(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=R(r.output,pe),u=X(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||W({...s,checkoutGeneration:c.checkoutGeneration})!==W(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=pe(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function wt(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Tt(e){W(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=Ct(z(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)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=I(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))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:X(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,Et),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=z(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=q(e);if(t===`run`)return{kind:t,projection:rt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Tt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(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=z(e,[...n,...r]),a=bt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,pe);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,k.dataFrames)),s=R(i.finalText,pe),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{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=R(i.declaration,je),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||W(s.declaration)!==W(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=pe(i.content);return(e.field!==n.field||!At(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:X(i.coverage)}}L(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function At(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 jt(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 Mt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,kt),i=R(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||W(ct({...i,after:n.after}))!==W(ct(n))||W(i.after)===W(n.after)))&&j(),{request:n,records:r,next:i,coverage:X(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(ct({...r,snapshotSeq:null}))!==W(ct(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:X(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Pt(e,t){return W({...t.request,snapshotSeq:e.snapshotSeq})===W(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function It(e){W({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Ft(t.request),r=ge(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Rt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,O),request:Rt(e.request),coverage:X(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=pe(e.content),a=R(e.range,me),o=M(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:X(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=X(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${W(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${W(n)}\n\`\`\`\n`)}var Vt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Rt(e)}receive(e){let t=zt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||W(n.request)!==W(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(W(n.graph.request.scope)!==W(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&j(),this.bytes+=N(Bt(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 Ht(e,t){return e.kind===`run`?it(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:xt(e.owner,t)}function Ut(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=J(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Wt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Gt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Wt(t.request),r=kt(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||!xt(r.owner,n.scope))&&j(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}var qt=e=>{let t=ae(e);return L(t.effect,`none`),t};function Jt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function Yt(e){let t=Jt(e);return t.taskId===null&&j(),t}function Xt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Zt(e){let t=B(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:qt(n.error)}}function $t(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||ht(e.context)!==e.workspaceId||gt(e.context)!==e.request.taskId)&&j(),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))&&j()}}function en(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:R(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=X(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&j();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))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function tn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:X(t.coverage)};if($t(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)&&j()}return r}function nn(e){let t=M(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||j(),t}function rn(e){let t=z(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0)}}function an(e){let t=z(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0),revision:P(t.revision,0,2**53-1-1),model:R(t.model,K)}}function on(e){let t=z(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:M(t.cwd,4096,!0),checkoutRoot:M(t.checkoutRoot,4096,!0),version:sn(t.version),model:R(t.model,ue)}}function sn(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function cn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:sn(t.version),selected:R(t.selected,ue)}}function ln(e){W(e);let t=z(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:K(t.choice)}}function un(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]),n={...t.images===void 0?{}:{images:F(t.images)},provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,ce)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,le),selectable:F(t.selectable)}}),eligibility:I(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))&&j(),n}function dn(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 fn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=B(t.entries,k.maxPageEntries,un),r=R(t.remembered,K),i=I(t.status,[`complete`,`capacity`]),a=P(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>W([e.provider,e.model]))).size!==n.length||r&&!dn(n,r))&&j(),{version:sn(t.version),selected:R(t.selected,ue),status:i,entries:n,withheld:a,remembered:r}}function pn(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:t.epoch===null?null:V(t.epoch)}}function mn(e){let t=z(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:L(t.kind,`project-observation`),status:I(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:V(t.epoch),workspaceId:t.workspaceId===null?null:V(t.workspaceId)}}var hn=[`registry`,`workbench`,`project`],gn=[`reboot`,`crash`,`restart`,`storage`],_n=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function vn(e){let t=z(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:V(t.id),at:P(t.at,0),scope:I(t.scope,hn),path:t.path===null?null:M(t.path,4096,!0),cause:I(t.cause,gn),actions:B(t.actions,_n.length,e=>I(e,_n)),workers:P(t.workers,0,1e6),archived:F(t.archived)}}function yn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,pn),recoveries:B(t.recoveries,20,vn),build:Qe(t.build)}}var bn=[`restart`,`upgrade`],xn=[`running`,`ready`,`failed`,`rolled-back`],Sn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Cn=/^(?: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 wn(e){let t=M(e,96,!0);if(!Cn.test(t))throw new A(`invalid`);return t}function Tn(e){let t=z(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:V(t.id),action:I(t.action,bn),from:wn(t.from),to:t.to===null?null:wn(t.to),state:I(t.state,xn),reason:t.reason===null?null:I(t.reason,Sn),version:t.version===null?null:wn(t.version),at:P(t.at,0),endedAt:t.endedAt===null?null:P(t.endedAt,0)}}var En=[`npm`,`not-npm-global`,`not-writable`];function Dn(e){let t=z(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=z(t.unit,[`name`,`scope`]);n={name:M(e.name,96,!0),scope:I(e.scope,[`user`,`system`])}}return{kind:L(t.kind,`service`),version:wn(t.version),unit:n,upgrade:I(t.upgrade,En),work:P(t.work,0,1e6),job:t.job===null?null:Tn(t.job)}}function On(e){let t=z(e,[`kind`,`version`,`deprecated`]);return{kind:L(t.kind,`release`),version:wn(t.version),deprecated:F(t.deprecated)}}function kn(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}var An=Object.freeze({count:4,bytes:4194304,totalBytes:8388608,chunkChars:262144,stagedBytes:67108864,stagedCount:64,idleMs:6e5,pixels:33554432,dimension:16384,wireBytes:12582912}),jn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Mn(e,t=An.bytes){if(typeof e!=`string`||!e.length||e.length%4||e.length>4*Math.ceil(t/3)||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let n=atob(e);if(n.length>t)throw Error(`Image is too large`);let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function Nn(e,t){if(!jn.includes(t)||!e.length||e.length>An.bytes)throw Error(`Unsupported image or size`);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
+ 
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||i>An.dimension||a>An.dimension||i*a>An.pixels)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Pn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function Fn(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function In(e,t=!1){let n=M(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(`Invalid workflow file path`);return n}var Ln=(e,t=!1)=>{let n=M(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function Rn(e){let t=z(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,12e5)}}function zn(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate task id`);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(`Missing dependency or cyclic plan`);n.push(r),t.add(r.id)}return n}function Bn(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 zn(e),r(t),zn(e).filter(e=>n.has(e.id))}function Vn(e,t={}){let n=t.strict===!0;W(e,Pn.bytes);let r=z(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=B(r.tasks,Pn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Ln(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>In(e,n)),after:B(t.after,Pn.tasks,e=>Ln(e,n))}});if(!i.length||i.some(e=>!e.writes.length||new Set(e.writes).size!==e.writes.length||new Set(e.after).size!==e.after.length))throw Error(`Empty or duplicate task scope`);zn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||Bn(i,e.id).some(e=>e.id===t.id)||Bn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>Fn(t.writes,e))||t.writes.some(t=>Fn(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=B(r.checks,Pn.checks,Rn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:M(r.goal,8192,!0),design:M(r.design,32768,!0),decisions:M(r.decisions,16384),acceptance:M(r.acceptance,16384,!0),projectContext:M(r.projectContext,16384),tasks:i,checks:a,setup:B(r.setup,4,Rn),baselineChecks:B(r.baselineChecks,Pn.checks,Rn),repairAttempts:P(r.repairAttempts,0,Pn.repairs),delivery:I(r.delivery,[`local-merge`,`working-copy`])};Hn(o),M(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
4
+ `&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function Hn(e){return M(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function Un(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=z(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...t?[`display`]:[]]);return{id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:sn(n.model),plan:Vn(n.plan),cwd:M(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:M(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=z(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function Wn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=z(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=B(n.questions,Pn.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:B(n.roots,8,e=>M(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:M(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:sn(n.model)}}if(t===`propose`){let n=z(e,[`action`,`plan`,`model`]);return{action:t,plan:Vn(n.plan),model:sn(n.model)}}if(t===`prepare`||t===`execute`){let n=z(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:V(n.proposalId),digest:H(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:V(n.grant)}}let n=z(e,[`action`,`runId`]);return{action:I(n.action,[`cancel`]),runId:V(n.runId)}}function Gn(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),n=e=>I(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Xn(t.diagnostics)},id:V(t.id),epoch:V(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:I(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:R(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:B(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=z(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:Yn(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=z(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()},id:M(r.id,160,!0),...t?{childRunId:V(r.childRunId)}:{},kind:I(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function Kn(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Gn(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Un(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:Un(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function qn(e){return`# ${e.goal}\n\n## Design\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${zn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
3
5
 
4
6
  `)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
5
7
  `)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
6
8
  `)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
7
- `)}\n\n## Automation boundary\nAt most ${e.repairAttempts} repair rounds. ${e.delivery===`local-merge`?`Authorize isolated task worktrees, local task commits and fast-forward integration into the current branch.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Generated project context and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project context\n${e.projectContext}\n`}var Wn=e=>F(e,0,864e13);function Gn(e){let t=B(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:Wn(t.createdAt),preparedAt:z(t.preparedAt,Wn),startedAt:z(t.startedAt,Wn),stopRequestedAt:z(t.stopRequestedAt,Wn),closedAt:z(t.closedAt,Wn),settledAt:z(t.settledAt,Wn),timeoutMs:F(t.timeoutMs,100,12e5),stopReason:z(t.stopReason,e=>N(e,32,!0))}}function Kn(e){let t=B(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=B(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Wn(t.acceptedAt),acquiredAt:z(t.acquiredAt,Wn),settledAt:z(t.settledAt,Wn),owner:{version:N(n.version,128,!0),build:N(n.build,64,!0),entry:N(n.entry,4096,!0),pid:F(n.pid,1),node:N(n.node,128,!0),platform:N(n.platform,32,!0),startedAt:Wn(n.startedAt)}}}function qn(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`}. Runs share an exclusive checkout; questions within one research run may overlap.`,...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)} · total process budget ${e.timing.timeoutMs}ms${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
8
- `)}function Jn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=B(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:nn(n.id),revision:F(n.revision,0),enabled:I(n.enabled),head:z(n.head,H),proposal:z(n.proposal,zn),runs:V(n.runs,200,H),...t?{notice:N(n.notice,1024,!0)}:{}}}function Yn(e){let t=N(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new j(`invalid`);return t}var Xn=16384,Zn=1e3,Qn=16384,$n=1024;function er(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 tr(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(`
9
- `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function nr(e,t,n=!1){let r=e.role===`tool`,i=r?``:er(e.text,Qn);return{id:e.id,role:e.role,text:i,clipped:!r&&(n||i!==e.text),name:e.name,target:r?er(tr(e.args),$n):``,error:e.error,parts:t}}function rr(e){let t=B(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:F(t.updatedAt,0)}}var ir=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function ar(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:rn(B(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=B(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:nn(n.id),leaf:z(n.leaf,Yn),ordinal:F(n.ordinal,0),before:z(n.before,e=>F(e,0))}}case`conversation-step`:{let n=B(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:z(n.leaf,Yn),turnId:Yn(n.turnId),step:F(n.step,0),part:F(n.part,0)}}case`cadence-conversation`:return{kind:t,id:nn(B(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=B(e,[`kind`,`id`,`leaf`]);return{kind:t,id:nn(n.id),leaf:z(n.leaf,Yn)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=B(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:z(r.after,H),...n?{scan:H(r.scan)}:{}}}case`workflow-active`:return B(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=B(e,[`kind`,`id`,`stepId`]);return{kind:t,id:H(n.id),stepId:N(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:H(B(e,[`kind`,`id`]).id)};case`conversations`:{let n=Object.hasOwn(e,`after`),r=B(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:z(r.after,rr)}:{}}}case`conversation-active`:case`projects`:return B(e,[`kind`]),{kind:t};case`conversation`:{let n=B(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:nn(n.id),leaf:z(n.leaf,Yn),known:z(n.known,Yn)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=B(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:L(r.kind,[`files`,`file`,`directories`]),path:N(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function or(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=B(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:H(n.commandId),location:rn(n.location),expected:sn(n.expected),choice:q(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=B(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 j(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:H(n.commandId),epoch:H(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:rn(n.location)},...r?{expected:sn(n.expected),choice:q(n.choice)}:{}}:{kind:t,...i,runId:H(n.runId)}}if(t===`cadence-exit`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:rn(n.location)},commandId:H(n.commandId),conversationId:nn(n.conversationId),head:z(n.head,Yn),revision:F(n.revision,0)}}if(t===`cadence-send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`,`revision`,`intent`]);return{kind:t,commandId:H(n.commandId),conversationId:nn(n.conversationId),head:z(n.head,Yn),text:N(n.text,Xn,!0),model:sn(n.model),revision:F(n.revision,0),intent:L(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=B(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:H(r.commandId),conversationId:nn(r.conversationId),revision:F(r.revision,0),proposalId:H(r.proposalId),digest:U(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:H(r.grant)}}if(t===`workflow`){let n=B(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:H(n.commandId),epoch:H(n.epoch),request:Bn(n.request)}}if(t===`send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:H(n.commandId),conversationId:nn(n.conversationId),head:z(n.head,Yn),text:N(n.text,Xn,!0),model:sn(n.model)}}if(t===`interrupt`){let n=B(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:H(n.commandId),conversationId:nn(n.conversationId),turnId:H(n.turnId),epoch:H(n.epoch)}}let n=B(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:L(n.kind,[`open-project`]),commandId:H(n.commandId),path:N(n.path,4096,!0),epoch:H(n.epoch)}}function sr(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=B(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),a=r?B(i.transcript,[`pages`]):null,o=n?B(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:on(i.execution)},id:H(i.id),epoch:H(i.epoch),status:L(i.status,ir),notice:N(i.notice,1024),...a?{transcript:{pages:F(a.pages,0)}}:{},omitted:{thinking:o?I(o.thinking):!1,media:o?I(o.media):!1,other:o?I(o.other):!1},items:V(i.items,256,cr)}}function cr(e){let t=B(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:N(t.id,160,!0),role:L(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,262144),name:N(t.name,128),args:N(t.args,65536),error:I(t.error)}}function lr(e){let t=B(e,[`id`,`role`,`text`,`clipped`,`name`,`target`,`error`,`parts`]),n={id:N(t.id,160,!0),role:L(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,Qn),clipped:I(t.clipped),name:N(t.name,128),target:N(t.target,$n),error:I(t.error),parts:F(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new j(`invalid`);return n}function ur(e){let t=B(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],`entry`,`at`]),n=B(t.omitted,[`thinking`,`media`,`other`]),r=F(t.steps,0);return{...t.execution===void 0?{}:{execution:on(t.execution)},id:Yn(t.id),entry:z(t.entry,Yn),at:F(t.at,0),status:L(t.status,ir),notice:N(t.notice,1024),omitted:{thinking:I(n.thinking),media:I(n.media),other:I(n.other)},steps:r,stable:F(t.stable,0,r)}}function dr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=B(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[]]),r=t(`live`)?B(n.live,[`commandId`,`epoch`]):null;return{id:nn(n.id),title:N(n.title,512,!0),leaf:z(n.leaf,Yn),status:L(n.status,ir),updatedAt:F(n.updatedAt,0),origin:L(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:I(n.cadence)}:{},...r?{live:{commandId:H(r.commandId),epoch:H(r.epoch)}}:{}}}function fr(e){let t=B(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:H(t.commandId),text:N(t.text,16384),status:L(t.status,ir),notice:N(t.notice,1024)}}function pr(e){let t=B(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:Yn(t.id),parent:z(t.parent,Yn),text:N(t.text,1024),at:F(t.at,0),leaf:Yn(t.leaf),current:I(t.current)}}function mr(e){G(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-context`)return{kind:t,context:an(B(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:fn(B(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=B(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:H(n.commandId),choice:cn(n.choice)}}if(t===`workflow-transcript`){let n=B(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:H(n.runId),stepId:N(n.stepId,160,!0),turn:z(n.turn,sr)}}if(t===`cadence-conversation`)return{kind:t,state:Jn(B(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=B(e,[`kind`,`after`,`scan`]);return{kind:t,after:z(n.after,H),scan:H(n.scan)}}if(t===`workflow-history`){let n=B(e,[`kind`,`entries`,`next`]),r=V(n.entries,An.historyPage,e=>{let t=B(e,[`id`,`run`]),n=H(t.id),r=z(t.run,Vn);if(r&&r.id!==n)throw new j(`invalid`);return{id:n,run:r}}),i=z(n.next,H);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new j(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=B(e,[`kind`,`runs`,...n?[`links`]:[]]),i=V(r.runs,4,Vn),a=n?V(r.links,4,e=>{let t=B(e,[`runId`,`conversationId`]);return{runId:H(t.runId),conversationId:nn(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 j(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=B(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:H(n.commandId),grant:H(n.grant),expiresAt:F(n.expiresAt,0),revision:F(n.revision,0),proposal:zn(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=B(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:z(t.commandId,H),response:Hn(t.response)}}if(n===`conversation-active`)return{kind:n,entries:V(B(e,[`kind`,`entries`]).entries,8,dr)};if(n===`conversations`){let t=B(e,[`kind`,`entries`,`next`]);return{kind:n,entries:V(t.entries,200,dr),next:z(t.next,rr)}}if(n===`conversation`){let t=B(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=z(t.summary,dr),i=F(t.turns,0);if(!r&&i)throw new j(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:V(t.commands,64,H)},summary:r,leaf:z(t.leaf,Yn),continues:I(t.continues),turns:i,branches:F(t.branches,0),runs:V(t.runs,200,H),attempt:z(t.attempt,fr)}}if(n===`conversation-tree`){let t=B(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:V(t.nodes,Zn,pr),truncated:I(t.truncated)}}if(n===`conversation-turn`){let t=B(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=ur(t.turn),i=F(t.start,0),a=V(t.steps,24,lr);if(i+a.length>r.steps)throw new j(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:z(t.leaf,Yn),ordinal:F(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=B(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:nn(t.conversationId),leaf:z(t.leaf,Yn),turnId:Yn(t.turnId),step:F(t.step,0),part:F(t.part,0),item:cr(t.item)}}if(n===`files`||n===`directories`){let t=B(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:N(t.path,4096),parent:z(t.parent,e=>N(e,4096)),limited:I(t.limited),entries:V(t.entries,200,e=>{let t=B(e,[`name`,`path`,`directory`]);return{name:N(t.name,1024,!0),path:N(t.path,4096,!0),directory:I(t.directory)}})}}if(n===`file`){let t=B(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:N(t.path,4096),text:N(t.text,262144),limited:I(t.limited)}}if(n===`projects`)return{kind:n,entries:V(B(e,[`kind`,`entries`]).entries,128,e=>{let t=B(e,[`path`,`current`]);return{path:N(t.path,4096,!0),current:I(t.current)}})};if(n===`accepted`)return{kind:n,commandId:H(B(e,[`kind`,`commandId`]).commandId)};let r=B(e,[`kind`,`commandId`,`path`,`link`]);return{kind:L(r.kind,[`project`]),commandId:H(r.commandId),path:N(r.path,4096,!0),link:N(r.link,8192,!0)}}var hr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},gr=f.createContext&&f.createContext(hr),_r=[`attr`,`size`,`title`];function vr(e,t){if(e==null)return{};var n,r,i=yr(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 yr(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 br(){return br=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},br.apply(null,arguments)}function xr(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 Sr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xr(Object(n),!0).forEach(function(t){Cr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Cr(e,t,n){return(t=wr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wr(e){var t=Tr(e,`string`);return typeof t==`symbol`?t:t+``}function Tr(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 Er(e){return e&&e.map((e,t)=>f.createElement(e.tag,Sr({key:t},e.attr),Er(e.child)))}function Q(e){return t=>f.createElement(Dr,br({attr:Sr({},e.attr)},t),Er(e.child))}function Dr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=vr(e,_r),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,br({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Sr(Sr({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return gr===void 0?t(hr):f.createElement(gr.Consumer,null,e=>t(e))}function Or(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 kr(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 Ar(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 jr(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 Mr(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 Nr(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 Pr(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 Fr(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 Ir(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 Lr(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 Rr(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 zr(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 Br(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 Vr(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 Hr(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 Ur(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 Wr(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 Gr(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 Kr(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 qr(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 Jr(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 Yr(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 Xr(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 Zr(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 Qr(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 $r(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 ei(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 ti(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 ni(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 ri(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 ii(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 ai(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 oi(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)}var $=e=>({kind:`error`,error:ee(`unavailable`,e?`uncertain`:`none`)}),si=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=ar(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),mr);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=or(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),mr);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Jt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),en);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Yt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),tn);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),Je):$(!1)}catch{return $(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:$(!1)}return this.transport.models?Z(await this.transport.models(e),fn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=ln(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),cn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(G(i)!==G(n.choice)||G(e.value.version.conversation??null)!==G(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){H(e);try{let n=Z(await this.transport.checkObligations(e,t),Ut);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=Wt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Kt);return e.kind===`ok`&&G(e.value.request)!==G(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),vt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),yt)}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=Dt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Nt);return t.kind===`ok`&&!Pt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Ft(e);try{let e=Z(await this.transport.graph(n,t),Lt);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new j(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new j(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new j(`unavailable`);yield i}catch{throw new j(`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`&&(G(e.value.preview.version)!==G(n.expected)||G(e.value.preview.action)!==G(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:ee(`invalid`)};try{let e=Z(await this.transport.command(n),et);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);tt({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),et);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);tt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){H(e);try{let n=nt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:ee(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Z(await this.transport.snapshot(n,t),ot);return e.kind===`ok`&&G(e.value.scope)!==G(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),ut);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),ft);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}},ci=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&te(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>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.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=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||G(i.scope)!==G(a.scope))return this.resync();let o=te(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||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(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||G(t.admission)!==G(e.admission))return this.resync();s[n]=e}}if(s.length>k.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{ot(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`}},li={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`},ui=`/api/v1/events`,di=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function fi(e,t){if(di.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 k.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 k.pageBytes}return k.controlBytes}function pi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function mi(e,t){switch(e){case`workbenchRead`:return ar(t);case`workbenchCommand`:return or(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new j(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new j(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return H(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return ve(t);case`command`:return ye(t);case`cancel`:return xe(t)}}function hi(e,t){if(di.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,mr);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,fn);case`chooseModel`:return Z(t,cn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,Ce);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new j(`invalid`);return null});default:throw new j(`invalid`)}}function gi(e){return[...di,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function _i(e,t){let n=li[e];return t===null||pi(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function vi(e,t){let n=mi(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?li[e]:_i(e,n);return pi(e)||gi(e)&&(r||P(i)>k.headerBytes/4)?{path:li[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function yi(e){G(e,k.viewerBytes);let t=L(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(B(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(B(e,[`kind`,`event`]).event)}:(B(e,[`kind`]),{kind:t})}var bi=class{options;attachment;csrf=null;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))throw new j(`invalid`);this.origin=e.origin,e.build&&=Ze(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){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=G(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new j(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=vi(e,mi(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:this.options.requestTimeoutMs===void 0?n:AbortSignal.any([...n?[n]:[],AbortSignal.timeout(this.options.requestTimeoutMs)]),...i?{body:r.body}:{}}),o;try{e===`session`&&a.ok&&(o=H(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await xi(a,fi(e)),c=re(s);if(P(s)>fi(e,c))throw new j(`oversize`);let l=hi(e,c);if(e===`session`){let e=Z(l,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new j(`forbidden`);this.attachment=o??H(a.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return l}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`,ln(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,H(e),t)}entity(e,t){return this.request(`entity`,Wt(e),t)}tasks(e,t){return this.request(`tasks`,Dt(e),t)}runs(e,t){return this.request(`runs`,Dt(e),t)}messages(e,t){return this.request(`messages`,Dt(e),t)}tools(e,t){return this.request(`tools`,Dt(e),t)}contents(e,t){return this.request(`contents`,Dt(e),t)}events(e,t){return this.request(`events`,Dt(e),t)}checks(e,t){return this.request(`checks`,Dt(e),t)}changes(e,t){return this.request(`changes`,Dt(e),t)}reviews(e,t){return this.request(`reviews`,Dt(e),t)}graph(e,t){return this.request(`graph`,Ft(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`,H(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=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new j(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new j(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=vi(`export`,Rt(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 j(`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 j(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
10
- `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(re(e,k.controlBytes)),r=o.indexOf(`
11
- `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new j(`oversize`)}if(n){if(o)throw new j(`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 j(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${ui}?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(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(G({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new j(`invalid`);let n=yi(re(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function xi(e,t){if(!e.body)throw new j(`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 j(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Si={sourceHash:`693769f17518f5c7045fc22eaebb5296f5875d603f650291fb252f22e76bfa54`,contractHash:`641cf7f91bc6f38839e9bb82e9db67d733ab0cded0a2eee0deb0d1ec29539ae1`,buildId:`e5666bb68b78c85011896cf0e0af2cfd0212338c74b23264f80e962254b90702`};function Ci(e){let t=new bi({origin:window.location.origin,...e?{project:e}:{},...Si?{build:{kind:`browser`,...Si}}:{},socket:e=>new WebSocket(e)});return{client:new si(t),transport:t}}function wi(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&&te(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&&G(t.settlement)!==G(r.settlement))?i=!0:(!r||te(t.committedSeq,r.committedSeq)>0||G(r)===G(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 Ti(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(ar(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function Ei(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 Di(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Ti(e,t?{kind:`conversations`,after:n}:null,n===null?2e3:0),s=o.value?.kind===`conversations`?o.value:void 0;return{value:s,error:o.error,loading:t&&!s&&!o.error,refresh:o.refresh,canPrevious:i.length>0,first:()=>{r(null),a([])},previous:()=>{i.length&&(r(i.at(-1)??null),a(e=>e.slice(0,-1)))},next:()=>{s?.next&&(a(e=>[...e,n]),r(s.next))}}}async function Oi(e){return re(await xi(e,1048576),1048576)}function ki(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`}async function Ai(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Oi(r);if(!r.ok)throw Error(ki(i));return t(i)}function ji(e){return Ai(`/workbench/v1/service`,Dn,e)}function Mi(e){return Ai(`/workbench/v1/service/release`,On,e)}async function Ni(e,t){if(!Si)throw Error(`unavailable`);let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Si})},body:JSON.stringify(e)}),r=await Oi(n);if(!n.ok)throw Error(ki(r));let i=B(r,[`kind`,`job`]);return R(i.kind,`service-job`),Tn(i.job)}function Pi(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),[a,o]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let t=++i.current,n=new AbortController,r=()=>!n.signal.aborted&&i.current===t,a,s=async()=>{if(r()){try{let t=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n.signal}),i=await Oi(t);if(!t.ok)throw Error(ki(i));r()&&o({id:e,value:mn(i)})}catch(t){r()&&o(n=>({id:e,value:n.id===e?n.value:void 0,error:t instanceof Error?t.message:`unavailable`}))}r()&&(a=setTimeout(()=>void s(),5e3))}};return s(),()=>{n.abort(),clearTimeout(a)}},[e,n,t]);let s=(0,f.useCallback)(()=>{++i.current,r(e=>e+1)},[]),c=t=>{s(),o(n=>({id:e,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:n.id===e?n.value?.workspaceId??null:null}}))};return{...a.id===e?a:{},refresh:s,prepared:c}}var Fi=e=>e===`unauthenticated`||e===`forbidden`,Ii=class{api;serial=Promise.resolve();version=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),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new ci,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new ci,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,Fi(e.error.code)&&w(),!1):(T(e.value),!0)};if(t&&!await i())return;e||(_.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(a.kind===`ok`)_.activeRuns=a.value;else if(Fi(a.error.code)){w();return}else _.activeRuns=void 0;y();let o=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(o.kind===`error`){_.error=o.error.code,Fi(o.error.code)&&w();return}if(!t&&G(_.workspace?.models??[])!==G(o.value.models)&&!await i())return;if(_.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,Fi(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new ci,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Si?{kind:`browser`,...Si}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new ci,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new ci,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function Li(e,t,n,r){let i=(0,f.useMemo)(()=>new Ii(e),[e]),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,f.useEffect)(()=>{if(c({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:(e=!1)=>i.refresh(e),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var Ri=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 zi({client:e,value:t,onChange:n}){let{t:r,tx:i}=T(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.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 Bi(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 Vi(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 Hi(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 Ui(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=Bi(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 Wi(e,t){let n=t?G({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),Vi(e,l,n.signal).then(e=>{t===m.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===m.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),m.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&p(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),p(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),p([]),u(t?{...t}:null)}}}function Gi({value:e,compact:t=!1}){let{t:n,tx:r}=T();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(Gi,{value:e})]}):(0,h.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 Ki(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 qi(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Ki(e)}return Ki(e)}function Ji(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(!1),s=(0,f.useRef)(null),c=(0,f.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,f.useCallback)(()=>{c(),o(!1)},[c]);return(0,f.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,f.useCallback)(async e=>{let a=!1;try{a=await qi(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}}function Yi(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
12
- `).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,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Xi=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Zi(!0)},text:{92:Zi(!1)}});let t={enter:{backslashMathInline:Qi,backslashMathDisplay:Qi,backslashMathBlock:Qi},exit:{backslashMathInline:$i,backslashMathDisplay:$i,backslashMathBlock:$i}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Zi(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 Qi=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)},$i=function(e){this.exit(e)},ea=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=Ji();return(0,h.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:t(`Copy displayed text`),"aria-label":t(`Copy displayed text`),onClick:()=>{r(!1),a(e).then(e=>r(!e))},children:[i?(0,h.jsx)(ri,{}):(0,h.jsx)(Qr,{}),n&&t(`Copy unavailable`)]})}),ta=[s,d,Xi],na=[s,l,d,Xi],ra=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function ia(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 aa({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?na:ta,rehypePlugins:t?[i,o,...ra]:ra,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ca,a:sa,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var oa=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(aa,{...e})})});function sa({href:e,children:t}){let n=e&&ia(e);return n?(0,h.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,h.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function ca({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Yi(r).map(e=>{let t=`code-offset:${i}`;return i+=la(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,h.jsxs)(`div`,{className:`codeblock`,children:[(0,h.jsx)(ea,{text:la(e)}),(0,h.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,h.jsxs)(`div`,{className:`code-line`,children:[o&&(0,h.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,h.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function la(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(la).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return la(t?.children)}return``}function ua(e,t){let n=[],r=t;if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=e.textContent??``;if(!e.parentElement?.closest(`[data-retained-field]`))continue;let 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 da=new Map;function fa(e,t){t.length?da.set(e,t):da.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...da].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 pa(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 ma(e,t){let n=t.startContainer.parentElement;for(let r of pa(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 ha({container:e,version:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(0),l=(0,f.useRef)([]),u=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?ua(n,r):[];return l.current=i,c(i.length),o(0),fa(u,i),()=>fa(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(ma(e.current,l.current[n]),fa(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>fa(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function ga({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=G(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await Ui(e,t,n.signal);if(n.signal.aborted)return;let i=await qi(r.text);if(n.signal.aborted)return;w(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||w(a(`Full-field copy refused/incomplete.`))}finally{E.current===n&&(E.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,h.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,h.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,h.jsx)(`summary`,{children:a(`Field details`)}),(0,h.jsxs)(`div`,{className:`detail-identity`,children:[(0,h.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,h.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!!E.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!E.current&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{E.current?.abort(),E.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,h.jsx)(`p`,{role:`status`,children:C}),y&&(0,h.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),_&&(0,h.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,h.jsx)(Gi,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,h.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,h.jsxs)(h.Fragment,{children:[(!i||k.next)&&(0,h.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:k.range?.start??0,end:k.range?.end??0,total:k.content.bytes}),` `,k.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,h.jsx)(ha,{container:D,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,h.jsx)(oa,{text:k.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!k||!n||!k.range)return k?.text;let e=Math.max(n.start,k.range.start)-k.range.start,t=Math.min(n.end,k.range.end)-k.range.start;if(t<=e)return k.text;let r=new TextEncoder().encode(k.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,h.jsxs)(h.Fragment,{children:[i(0,e),(0,h.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||m.length>0||d?.next)&&(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.length,onClick:()=>{u(m[m.length-1]),g(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!d?.next,onClick:()=>{d?.next&&(g(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function _a({pager:e,compact:t=!1}){let{t:n,tx:r}=T(),{page:i,busy:a,error:o}=e;return(0,h.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,h.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,h.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,h.jsx)(Gi,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.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,h.jsx)(Pr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function va({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=Wi(e,{...t,reader:`contents`}),[o,s]=(0,f.useState)(),c=a.page;return(0,h.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,h.jsx)(_a,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(x,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,h.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,h.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,h.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,h.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,h.jsx)(Gi,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Hi(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,h.jsx)(ga,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function ya({client:e,seed:t}){return(0,h.jsx)(ba,{client:e,seed:t},G(t))}function ba({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.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,h.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,h.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,h.jsx)(Gi,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function xa(e=typeof window>`u`?``:window.location.search){let t=new URLSearchParams(e).get(`project`);return t&&/^[a-f0-9]{64}$/.test(t)?t:null}function Sa(){let e=xa();return e?`/projects/${e}`:``}function Ca(e){let t=vi(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Sa()+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 wa({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.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,h.jsx)(Or,{"aria-hidden":`true`})})]}),t]})}function Ta({request:e,onClose:t}){let{t:n,tx:r}=T(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(wa,{title:n(`Export retained history`),onClose:t,children:[(0,h.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,h.jsxs)(`label`,{children:[n(`Format`),(0,h.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,h.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,h.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,h.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,h.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,h.jsx)(`button`,{type:`button`,onClick:()=>{try{Ca({...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,h.jsx)(`p`,{role:`status`,children:s})]})}function Ea(e,t){if(!t||P(t)>k.queryBytes)throw Error(`Query must be 1–${k.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 Da(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 Oa({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=T(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=Ea(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(wa,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(Nr,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.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,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Gi,{value:m.coverage}),(0,h.jsxs)(`div`,{className:`gs-section`,children:[(0,h.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:m.hits.length})}),m.hits.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>p(t),onClick:()=>{r(e),n()},children:[(0,h.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,h.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,h.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})]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),m.hits.length===0&&(0,h.jsx)(`p`,{children:a(Da(m))})]}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.next,onClick:()=>{m.next&&S(m.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,h.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function ka({run:e,historical:t=!1}){let{t:n,tx:r}=T();return(0,h.jsxs)(`article`,{className:`run-summary`,children:[(0,h.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,h.jsx)(`p`,{children:(0,h.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,h.jsx)(`dd`,{children:r(e.lifecycle)}),(0,h.jsx)(`dt`,{children:n(`Execution`)}),(0,h.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,h.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,h.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,h.jsx)(`dt`,{children:n(`Summary publication`)}),(0,h.jsx)(`dd`,{children:r(e.publication)})]}),(0,h.jsx)(Gi,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Aa({client:e,seed:t}){return(0,h.jsx)(ja,{client:e,seed:t},G(t))}function ja({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.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,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,h.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,h.jsx)(Gi,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ga,{client:e,cursor:Hi(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,h.jsx)(oa,{text:e.instructions}),(0,h.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function Ma({client:e,seed:t,onScope:n}){let{t:r}=T(),i=Wi(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(_a,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(ka,{run:e.projection,historical:!0}),(0,h.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,h.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,h.jsx)(Aa,{client:e,seed:o},o.graph.recordId)]})}function Na({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.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,h.jsx)(Nr,{"aria-hidden":`true`})})}function Pa(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 Fa(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 Ia(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)??La(n.role,n.customType)}return r}function La(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 Ra(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function za(e,t,n=1800){let[r,i]=(0,f.useState)(()=>new Set),a=(0,f.useRef)(r);a.current=r;let o=(0,f.useRef)(new Map),s=(0,f.useRef)(new Map),c=(0,f.useRef)(new Map),l=(0,f.useRef)(0),u=(0,f.useRef)(new Map);u.current=new Map(t.map(e=>[e.id,e.version]));let d=(0,f.useRef)(new Set);d.current=Ia(t,o.current,n);let p=(0,f.useCallback)((e,t)=>{let n=u.current.get(e);n!==void 0&&(s.current.set(e,{h:t,len:n}),o.current.set(e,t))},[]),m=(0,f.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of c.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),a.current.has(e)||p(e,n.height)}let o=Pa(r,{top:n.top-1200,bottom:n.bottom+1200},d.current,a.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of o.hide){let t=c.current.get(e);t&&p(e,t.offsetHeight)}i(e=>Fa(e,o))},[p,e]),h=(0,f.useCallback)(()=>{l.current||=requestAnimationFrame(()=>{l.current=0,m()})},[m]);return(0,f.useLayoutEffect)(()=>{t.length?m():i(new Set)},[m,t]),(0,f.useEffect)(()=>{let t=new ResizeObserver(h);return e.current&&t.observe(e.current),()=>{t.disconnect(),cancelAnimationFrame(l.current)}},[h,e]),{hidden:r,scheduleSweep:h,recordMeasured:p,register:(0,f.useCallback)(e=>t=>{t?c.current.set(e,t):c.current.delete(e)},[]),placeholder:(0,f.useCallback)((e,t,n)=>Ra(e,t,s.current,n),[])}}var Ba=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null);return(0,f.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,h.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,h.jsx)(`div`,{ref:s,children:o})}):(0,h.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Va=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(ei,{"aria-hidden":`true`}):(0,h.jsx)(qr,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(ga,{compact:!0,client:t,cursor:Hi(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.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,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(va,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Ha({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),o=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=za(i,o);return(0,h.jsxs)(`div`,{className:`messages-wrap`,children:[(0,h.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,h.jsx)(Ba,{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,h.jsx)(Va,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Ua({client:e,seed:t}){let{t:n}=T(),r=Wi(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(_a,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,h.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,h.jsxs)(h.Fragment,{children:[i.records.length===0&&(0,h.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,h.jsx)(Ha,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Wa({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,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(ni,{}):(0,h.jsx)(ti,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Ga=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.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,h.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,h.jsx)(Wa,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(kr,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.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,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(va,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Ka=[`queued`,`running`];function qa(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,``)}var Ja=4,Ya=1e4;function Xa(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,f.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?Ka.includes(t.status):i-(u.get(e)??0)>=Ya}).reverse();for(let n=0;n<a.length;n+=Ja){let r=await Promise.all(a.slice(n,n+Ja).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+Ja<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>Ka.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),Ya))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function Za({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=Xa(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,f.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(b)){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||(g(i),v(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,b]);let x=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],S=[...m,...x.filter(e=>!m.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=[...new Set(a)].flatMap(e=>{let t=y.runs.get(e);return t?t.steps.filter(e=>e.childRunId).map(e=>({run:t,step:e})):[]}).reverse().sort((e,t)=>Number(!Ka.includes(e.step.status))-Number(!Ka.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>Ka.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,D=d??(w>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${D?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":D,onClick:()=>p(!D),children:[(0,h.jsx)(ni,{}),(0,h.jsx)(Xr,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:w}):w})]}),D&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),w===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,step:t})=>{let n=qa(t.id);return(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row${o?.runId===e.id&&o.stepId===t.id?` active`:``}`,title:e.goal,onClick:()=>c?.({runId:e.id,stepId:t.id,label:n}),children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsxs)(`strong`,{children:[u(t.kind),` · `,n]}),(0,h.jsx)(`small`,{children:e.goal})]}),(0,h.jsx)(`span`,{className:`ep-state ${t.status}`,children:u(t.status)})]},t.childRunId)}),S.map(e=>(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,h.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,h.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}var Qa=2e4;function $a(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:Yn(e.head)},n=e.location?rn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new j(`stale`);let r=N(e.text,Xn,!0),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:F(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:F(e.revision,0)};return Object.freeze({text:r,command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(eo(e.model))}:{}})}function eo(e){return q({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function to(e,t){return Object.freeze({...e,model:Object.freeze(eo(t))})}function no(e,t){if(e.model&&G(e.model)!==G(eo(t)))throw new j(`stale`)}function ro(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&G(e.location)!==G(t?.conversation??null))throw new j(`stale`);return or(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t})}function io(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}var ao=1e3,oo=1e4,so=4,co=e=>e===`queued`||e===`running`,lo=class extends Error{},uo=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;commands=[];count=0;first=null;turns=new Map;details=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=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){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=e=>{this.closed||this.pinned===e||(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.error=``,this.forget(),this.publish(),this.tick())};forget(){this.turns.clear(),this.details.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())};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{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,commands:this.commands,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.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof lo?e.message:`unavailable`)}finally{this.running=!1}if(e&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=co(this.summary?.status)||[...this.turns.values()].some(e=>co(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?ao:oo)}async sync(e){let t=this.pinned,n=await this.read({kind:`conversation`,id:this.id,leaf:t,known:this.leaf},e);if(e.aborted)return;if(n.kind!==`conversation`)throw new lo(`invalid`);(!n.continues||n.turns<this.count)&&this.forget();let r=n.leaf===this.leaf?this.count:this.count-1;this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.commands=n.commands??[],this.summary=n.summary,this.count=n.turns,this.first=Math.min(this.first??Math.max(0,n.turns-2),n.turns),this.publish();let i=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||co(t.header.status))&&i.push(e)}await Promise.all(i.map(t=>this.load(t,n.leaf,e)))}async load(e,t,n){let r=this.turns.get(e),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,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{o[i.start+t]=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))))r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)});if(!n.aborted){if(o.some(e=>!e))throw new lo(`stale`);this.turns.set(e,{ordinal:e,header:a,steps:o,detail:this.detail(t,a.id,n)})}}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 lo(`invalid`);return i}detail(e,t,n){let r=`${e??``}:${t}`,i=this.details.get(r);return i||(i=async(r,i,a)=>{let o=await Promise.all(Array.from({length:i},async(i,o)=>{let s=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},AbortSignal.any([n,a]));if(s.kind!==`conversation-step`||s.part!==o)throw new lo(`invalid`);return s.item}));return{text:o.map(e=>e.text).join(``),args:o.map(e=>e.args).join(``)}},this.details.set(r,i)),i}async read(e,t=this.abort.signal){this.reads>=so&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new lo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new lo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function fo(e,t,n){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new uo(e,t,()=>o(n.view()));return i(n),o(n.view()),()=>n.close()},[e,t]),(0,f.useEffect)(()=>{r?.setActive(n)},[r,n]),{...a??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:r?.refresh??po,loadEarlier:r?.loadEarlier??po,choose:r?.choose??po}}function po(){}async function mo(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||G(r.value.proposal)!==G(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 ho(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function go(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var _o={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},vo={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed and was read again. Choose once more.`,"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. The list was read again; check the current model before choosing again.`},yo=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,bo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function xo(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 So(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(_o[t.thinking])}`,[e])}function Co({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,onObserved:c,awaitingSend:l=!1}){let{t:u}=T(),d=So(),p=(0,f.useRef)(c);p.current=c;let[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(``),[E,D]=(0,f.useState)(0),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(null),j=(0,f.useRef)(null),ee=(0,f.useCallback)(()=>D(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(g(e.value),p.current?.(e.value),v(``)):v(e.error.code))}).catch(()=>{t.signal.aborted||v(`unavailable`)}),()=>t.abort()},[e,r,E]),(0,f.useEffect)(()=>{i&&ee()},[i,ee]);let M=(0,f.useCallback)((e=!0)=>{a(!1),w(``),e&&k.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;b(``),A.current?.focus({preventScroll:!0});let e=e=>{O.current?.contains(e.target)||M(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,M]);let N=m?.selected??null,P=N??m?.remembered??null,F=(0,f.useMemo)(()=>{let e=C.trim().toLowerCase(),t=new Map;for(let n of m?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[m,C]),I=m?.entries.find(e=>bo(e,P)),L=async(t,r)=>{if(!m||!t.api||x||n)return;let i=q({provider:t.provider,model:t.model,api:t.api,thinking:r});if(N&&yo(N,i))M(),s?.(i);else{S(!0),b(``);try{let t=await e.chooseModel({expected:m.version,choice:i});if(t.kind===`error`){b(t.error.code),ee();return}let n={...m,version:t.value.version,selected:t.value.selected};g(n),p.current?.(n),o(),M(),s?.(i)}catch{b(`uncertain`),ee()}finally{S(!1)}}},R=()=>[...j.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],z=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=R(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?A.current?.focus():t[Math.min(n,t.length-1)]?.focus()},B=!t||!m&&!!_,V=m?P?d(P):u(`Choose a model`):u(_?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:O,children:[(0,h.jsxs)(`button`,{ref:k,type:`button`,className:`model-trigger${P&&!N?` remembered`:``}${m&&!P?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:V}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?u(`Switch models after the current reply finishes.`):P&&!N?u(`Last used model; it is used again when you send.`):P?`${P.provider}/${P.model} · ${P.api}`:void 0,onClick:()=>i?M():a(!0),children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:V}),(0,h.jsx)(ni,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":u(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),M())},children:[l&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:u(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(Nr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:A,type:`search`,"aria-label":u(`Search models`),placeholder:u(`Search models…`),value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),R()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),R()[0]?.click())}})]}),(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":u(`Models`),ref:j,onKeyDown:z,children:[!m&&!_&&(0,h.jsx)(`p`,{className:`model-empty`,children:u(`Reading models…`)}),F.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,r=bo(e,P);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||x||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void L(e,xo(e,P?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?u(`Credentials unavailable`):u(`Not supported`)}),r&&!N&&(0,h.jsx)(`span`,{className:`model-option-note`,children:u(`Used when you send`)}),r&&(0,h.jsx)(ri,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),m?.status===`complete`&&F.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:C.trim()?u(`No matching models.`):u(`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),I&&I.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:u(`Thinking`)}),I.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":u(`Thinking level: {level}`,{level:u(_o[e.level])}),"aria-pressed":P?.thinking===e.level,disabled:!e.selectable||x||n,onClick:()=>void L(I,e.level),children:u(_o[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:u(`Switch models after the current reply finishes.`)}),m?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:u(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!m?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:u(m.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; restart the service 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; restart the service after editing models.json.`,{count:m.withheld})}),_&&(0,h.jsxs)(`p`,{role:`alert`,children:[u(`The model list could not be read ({code}).`,{code:_}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:ee,children:u(`Read again`)})]}),y&&(0,h.jsx)(`p`,{role:`alert`,children:vo[y]?u(vo[y]):u(`The model was not changed ({code}).`,{code:y})}),!B&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(x?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}function wo(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 To({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Ti(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>wo(s?.nodes??[]),[s]);return(0,h.jsxs)(`section`,{className:`branch-tree`,"aria-label":a(`Conversation branches`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h3`,{children:a(`Conversation branches`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":a(`Close`),onClick:i,children:(0,h.jsx)(Or,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),o.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,o.error)}),!s&&!o.error&&(0,h.jsx)(`p`,{children:a(`Reading…`)}),s?.truncated&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Only the newest messages are listed.`)}),(0,h.jsx)(`ol`,{className:`branch-rows`,children:c.map(({node:e,depth:t})=>(0,h.jsx)(`li`,{style:{paddingInlineStart:`${t*16}px`},children:(0,h.jsxs)(`button`,{type:`button`,className:`branch-row${e.current?` current`:``}`,"aria-current":e.current?`true`:void 0,title:e.text,onClick:()=>r(e.leaf),children:[(0,h.jsx)(`span`,{className:`branch-text`,children:e.text||`…`}),e.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})},e.id))})]})}var Eo=/^\s{0,3}(`{3,}|~{3,})/,Do=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Oo(e){return e.trim()===``}function ko(e){let t=Eo.exec(e);return t?t[1]:null}function Ao(e){let t=e.split(`
13
- `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=ko(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=ko(a);if(o&&!Oo(a))i=o,r.push(a);else if(Oo(a)){let i=e;for(;i<t.length&&Oo(t[i]);)i++;if(!(i<t.length&&Do.test(t[i]))&&r.length>0){n.push(r.join(`
9
+ `)}\n\n## Automation boundary\nAt most ${e.repairAttempts} repair rounds. ${e.delivery===`local-merge`?`Authorize isolated task worktrees, local task commits and fast-forward integration into the current branch.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Generated project context and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project context\n${e.projectContext}\n`}var Jn=e=>P(e,0,864e13);function Yn(e){let t=z(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:Jn(t.createdAt),preparedAt:R(t.preparedAt,Jn),startedAt:R(t.startedAt,Jn),stopRequestedAt:R(t.stopRequestedAt,Jn),closedAt:R(t.closedAt,Jn),settledAt:R(t.settledAt,Jn),timeoutMs:P(t.timeoutMs,100,12e5),stopReason:R(t.stopReason,e=>M(e,32,!0))}}function Xn(e){let t=z(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=z(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Jn(t.acceptedAt),acquiredAt:R(t.acquiredAt,Jn),settledAt:R(t.settledAt,Jn),owner:{version:M(n.version,128,!0),build:M(n.build,64,!0),entry:M(n.entry,4096,!0),pid:P(n.pid,1),node:M(n.node,128,!0),platform:M(n.platform,32,!0),startedAt:Jn(n.startedAt)}}}function Zn(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`}. Runs share an exclusive checkout; questions within one research run may overlap.`,...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)} · total process budget ${e.timing.timeoutMs}ms${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
10
+ `)}function Qn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=z(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:nn(n.id),revision:P(n.revision,0),enabled:F(n.enabled),head:R(n.head,V),proposal:R(n.proposal,Un),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}function $n(e){let t=M(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new A(`invalid`);return t}var er=16384,tr=1e3,nr=16384,rr=1024;function ir(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 ar(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(`
11
+ `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function or(e,t,n=!1){let r=e.role===`tool`,i=r?``:ir(e.text,nr);return{id:e.id,role:e.role,text:i,...e.images?.length?{images:e.images}:{},clipped:!r&&(n||i!==e.text),name:e.name,target:r?ir(ar(e.args),rr):``,error:e.error,parts:t}}function sr(e){let t=z(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:P(t.updatedAt,0)}}var cr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function lr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:rn(z(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=z(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),ordinal:P(n.ordinal,0),before:R(n.before,e=>P(e,0))}}case`conversation-image`:{let n=z(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=P(n.offset,0,4*Math.ceil(An.bytes/3));if(r%An.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),...n.live===void 0?{}:{live:!0},entry:$n(n.entry),index:P(n.index,0,1024),offset:r}}case`conversation-step`:{let n=z(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),turnId:$n(n.turnId),step:P(n.step,0),part:P(n.part,0)}}case`cadence-conversation`:return{kind:t,id:nn(z(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=z(e,[`kind`,`id`,`leaf`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=z(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:R(r.after,V),...n?{scan:V(r.scan)}:{}}}case`workflow-active`:return z(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=z(e,[`kind`,`id`,`stepId`]);return{kind:t,id:V(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`conversations`:{let n=Object.hasOwn(e,`after`),r=z(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:R(r.after,sr)}:{}}}case`conversation-active`:case`projects`:return z(e,[`kind`]),{kind:t};case`conversation`:{let n=z(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),known:R(n.known,$n)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=z(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:I(r.kind,[`files`,`file`,`directories`]),path:M(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function ur(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:V(n.commandId),location:rn(n.location),expected:sn(n.expected),choice:K(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=z(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 A(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:V(n.commandId),epoch:V(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:rn(n.location)},...r?{expected:sn(n.expected),choice:K(n.choice)}:{}}:{kind:t,...i,runId:V(n.runId)}}if(t===`cadence-exit`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:rn(n.location)},commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),revision:P(n.revision,0)}}if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new A(`invalid`);let r=ur(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new A(`invalid`);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),send:r,mimeType:I(n.mimeType,jn),size:P(n.size,1,An.bytes),offset:P(n.offset,0,4*Math.ceil(An.bytes/3)),data:M(n.data,An.chunkChars,!0)}}if(t===`cadence-send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),text:M(n.text,er),...n.images===void 0?{}:{images:B(n.images,An.count,V)},model:sn(n.model),revision:P(n.revision,0),intent:I(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=z(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:V(r.commandId),conversationId:nn(r.conversationId),revision:P(r.revision,0),proposalId:V(r.proposalId),digest:H(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:V(r.grant)}}if(t===`workflow`){let n=z(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),request:Wn(n.request)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),text:M(n.text,er),...n.images===void 0?{}:{images:B(n.images,An.count,V)},model:sn(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function dr(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=z(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),a=r?z(i.transcript,[`pages`]):null,o=n?z(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:on(i.execution)},id:V(i.id),epoch:V(i.epoch),status:I(i.status,cr),notice:M(i.notice,1024),...a?{transcript:{pages:P(a.pages,0)}}:{},omitted:{thinking:o?F(o.thinking):!1,media:o?F(o.media):!1,other:o?F(o.other):!1},items:B(i.items,256,pr)}}function fr(e){return B(e,An.count,e=>{let t=z(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new A(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:$n(t.entry),index:P(t.index,0,1024),mimeType:I(t.mimeType,jn)}})}function pr(e){let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:fr(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}}function mr(e){let t=z(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:fr(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,nr),clipped:F(t.clipped),name:M(t.name,128),target:M(t.target,rr),error:F(t.error),parts:P(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function hr(e){let t=z(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],`entry`,`at`]),n=z(t.omitted,[`thinking`,`media`,`other`]),r=P(t.steps,0);return{...t.execution===void 0?{}:{execution:on(t.execution)},id:$n(t.id),entry:R(t.entry,$n),at:P(t.at,0),status:I(t.status,cr),notice:M(t.notice,1024),omitted:{thinking:F(n.thinking),media:F(n.media),other:F(n.other)},steps:r,stable:P(t.stable,0,r)}}function gr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=z(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[]]),r=t(`live`)?z(n.live,[`commandId`,`epoch`]):null;return{id:nn(n.id),title:M(n.title,512,!0),leaf:R(n.leaf,$n),status:I(n.status,cr),updatedAt:P(n.updatedAt,0),origin:I(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:F(n.cadence)}:{},...r?{live:{commandId:V(r.commandId),epoch:V(r.epoch)}}:{}}}function _r(e){let t=z(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:V(t.commandId),text:M(t.text,16384),status:I(t.status,cr),notice:M(t.notice,1024)}}function vr(e){let t=z(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:$n(t.id),parent:R(t.parent,$n),text:M(t.text,1024),at:P(t.at,0),leaf:$n(t.leaf),current:F(t.current)}}function yr(e){W(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),offset:P(n.offset,0,4*Math.ceil(An.bytes/3))}}if(t===`conversation-image`){let n=z(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:I(n.mimeType,jn),data:M(n.data,An.chunkChars,!0),next:R(n.next,e=>P(e,0,4*Math.ceil(An.bytes/3)))}}if(t===`conversation-context`)return{kind:t,context:an(z(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:fn(z(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:V(n.commandId),choice:cn(n.choice)}}if(t===`workflow-transcript`){let n=z(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:V(n.runId),stepId:M(n.stepId,160,!0),turn:R(n.turn,dr)}}if(t===`cadence-conversation`)return{kind:t,state:Qn(z(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=z(e,[`kind`,`after`,`scan`]);return{kind:t,after:R(n.after,V),scan:V(n.scan)}}if(t===`workflow-history`){let n=z(e,[`kind`,`entries`,`next`]),r=B(n.entries,Pn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,Gn);if(r&&r.id!==n)throw new A(`invalid`);return{id:n,run:r}}),i=R(n.next,V);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new A(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=z(e,[`kind`,`runs`,...n?[`links`]:[]]),i=B(r.runs,4,Gn),a=n?B(r.links,4,e=>{let t=z(e,[`runId`,`conversationId`]);return{runId:V(t.runId),conversationId:nn(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 A(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=z(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:V(n.commandId),grant:V(n.grant),expiresAt:P(n.expiresAt,0),revision:P(n.revision,0),proposal:Un(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=z(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:R(t.commandId,V),response:Kn(t.response)}}if(n===`conversation-active`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,8,gr)};if(n===`conversations`){let t=z(e,[`kind`,`entries`,`next`]);return{kind:n,entries:B(t.entries,200,gr),next:R(t.next,sr)}}if(n===`conversation`){let t=z(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=R(t.summary,gr),i=P(t.turns,0);if(!r&&i)throw new A(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:B(t.commands,64,V)},summary:r,leaf:R(t.leaf,$n),continues:F(t.continues),turns:i,branches:P(t.branches,0),runs:B(t.runs,200,V),attempt:R(t.attempt,_r)}}if(n===`conversation-tree`){let t=z(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:B(t.nodes,tr,vr),truncated:F(t.truncated)}}if(n===`conversation-turn`){let t=z(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=hr(t.turn),i=P(t.start,0),a=B(t.steps,24,mr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,$n),ordinal:P(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=z(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,$n),turnId:$n(t.turnId),step:P(t.step,0),part:P(t.part,0),item:pr(t.item)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:R(t.parent,e=>M(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:F(t.limited)}}if(n===`projects`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(n===`accepted`)return{kind:n,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let r=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(r.kind,[`project`]),commandId:V(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var br={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xr=f.createContext&&f.createContext(br),Sr=[`attr`,`size`,`title`];function Cr(e,t){if(e==null)return{};var n,r,i=wr(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 wr(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 Tr(){return Tr=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},Tr.apply(null,arguments)}function Er(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 Dr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Er(Object(n),!0).forEach(function(t){Or(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Er(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Or(e,t,n){return(t=kr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kr(e){var t=Ar(e,`string`);return typeof t==`symbol`?t:t+``}function Ar(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 jr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Dr({key:t},e.attr),jr(e.child)))}function Q(e){return t=>f.createElement(Mr,Tr({attr:Dr({},e.attr)},t),jr(e.child))}function Mr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Cr(e,Sr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Tr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Dr(Dr({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return xr===void 0?t(br):f.createElement(xr.Consumer,null,e=>t(e))}function Nr(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 Pr(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 Fr(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 Ir(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 Lr(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 Rr(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 zr(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 Br(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 Vr(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 Hr(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 Ur(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 Wr(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 Gr(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 Kr(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 qr(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 Jr(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 Yr(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 Xr(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 Zr(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 Qr(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 $r(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 ei(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 ti(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 ni(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 ri(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 ii(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 ai(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 oi(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 si(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 ci(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 li(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 ui(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 di(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 fi(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)}var $=e=>({kind:`error`,error:te(`unavailable`,e?`uncertain`:`none`)}),pi=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=lr(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),yr);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=ur(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),yr);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Jt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),en);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Yt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),tn);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),Je):$(!1)}catch{return $(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:$(!1)}return this.transport.models?Z(await this.transport.models(e),fn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=ln(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),cn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(W(i)!==W(n.choice)||W(e.value.version.conversation??null)!==W(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){V(e);try{let n=Z(await this.transport.checkObligations(e,t),Ut);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=Wt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Kt);return e.kind===`ok`&&W(e.value.request)!==W(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),vt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),yt)}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=Dt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Nt);return t.kind===`ok`&&!Pt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Ft(e);try{let e=Z(await this.transport.graph(n,t),Lt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new A(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new A(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new A(`unavailable`);yield i}catch{throw new A(`unavailable`)}}async preflight(e,t){let n=ye({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),we);return e.kind===`ok`&&(W(e.value.preview.version)!==W(n.expected)||W(e.value.preview.action)!==W(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=be(t);if(n.action.kind!==e)return{kind:`error`,error:te(`invalid`)};try{let e=Z(await this.transport.command(n),et);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);tt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Se(e);try{let e=Z(await this.transport.cancel(t),et);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);tt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=nt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:te(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Z(await this.transport.snapshot(n,t),ot);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),ut);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),ft);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},mi=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ne(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>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.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=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ne(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||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(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||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>k.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{ot(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`}},hi={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`},gi=`/api/v1/events`,_i=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function vi(e,t){if(_i.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 k.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 k.pageBytes}return k.controlBytes}function yi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function bi(e,t){switch(e){case`workbenchRead`:return lr(t);case`workbenchCommand`:return ur(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new A(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new A(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return ye(t);case`command`:return be(t);case`cancel`:return Se(t)}}function xi(e,t){if(_i.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,yr);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,fn);case`chooseModel`:return Z(t,cn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,we);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function Si(e){return[..._i,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ci(e,t){let n=hi[e];return t===null||yi(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function wi(e,t){let n=bi(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?hi[e]:Ci(e,n);return yi(e)||Si(e)&&(r||N(i)>k.headerBytes/4)?{path:hi[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Ti(e){W(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Ei=class{options;attachment;csrf=null;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))throw new A(`invalid`);this.origin=e.origin,e.build&&=Ze(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){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=W(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new A(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=wi(e,bi(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:this.options.requestTimeoutMs===void 0?n:AbortSignal.any([...n?[n]:[],AbortSignal.timeout(this.options.requestTimeoutMs)]),...i?{body:r.body}:{}}),o;try{e===`session`&&a.ok&&(o=V(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await Di(a,vi(e)),c=ie(s);if(N(s)>vi(e,c))throw new A(`oversize`);let l=xi(e,c);if(e===`session`){let e=Z(l,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`forbidden`);this.attachment=o??V(a.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return l}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`,ln(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Wt(e),t)}tasks(e,t){return this.request(`tasks`,Dt(e),t)}runs(e,t){return this.request(`runs`,Dt(e),t)}messages(e,t){return this.request(`messages`,Dt(e),t)}tools(e,t){return this.request(`tools`,Dt(e),t)}contents(e,t){return this.request(`contents`,Dt(e),t)}events(e,t){return this.request(`events`,Dt(e),t)}checks(e,t){return this.request(`checks`,Dt(e),t)}changes(e,t){return this.request(`changes`,Dt(e),t)}reviews(e,t){return this.request(`reviews`,Dt(e),t)}graph(e,t){return this.request(`graph`,Ft(e),t)}preflight(e){return this.request(`preflight`,ye(e))}command(e){return this.request(`command`,be(e))}cancel(e){return this.request(`cancel`,Se(e))}receipt(e,t){return this.request(`receipt`,V(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=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new A(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new A(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=wi(`export`,Rt(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 A(`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 A(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
12
+ `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(ie(e,k.controlBytes)),r=o.indexOf(`
13
+ `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new A(`oversize`)}if(n){if(o)throw new A(`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 A(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${gi}?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(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new A(`invalid`);let n=Ti(ie(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Di(e,t){if(!e.body)throw new A(`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 A(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Oi={sourceHash:`82a8422e426417f4a1b7251eff5a9cae21935453eedc465dd878a3aaa8418898`,contractHash:`5a3413139ef41a84946446d38615ce5216dfe0638fb20e0f7335c5e6cfc82d93`,buildId:`24a5dcae16a58c07e21d565dd356c5362d75c91b8486567ad2c8cfd16c09ef4b`};function ki(e){let t=new Ei({origin:window.location.origin,...e?{project:e}:{},...Oi?{build:{kind:`browser`,...Oi}}:{},socket:e=>new WebSocket(e)});return{client:new pi(t),transport:t}}function Ai(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&&ne(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&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ne(t.committedSeq,r.committedSeq)>0||W(r)===W(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 ji(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(lr(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function Mi(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 Ni(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=ji(e,t?{kind:`conversations`,after:n}:null,n===null?2e3:0),s=o.value?.kind===`conversations`?o.value:void 0;return{value:s,error:o.error,loading:t&&!s&&!o.error,refresh:o.refresh,canPrevious:i.length>0,first:()=>{r(null),a([])},previous:()=>{i.length&&(r(i.at(-1)??null),a(e=>e.slice(0,-1)))},next:()=>{s?.next&&(a(e=>[...e,n]),r(s.next))}}}async function Pi(e){return ie(await Di(e,1048576),1048576)}function Fi(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`}async function Ii(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Pi(r);if(!r.ok)throw Error(Fi(i));return t(i)}function Li(e){return Ii(`/workbench/v1/service`,Dn,e)}function Ri(e){return Ii(`/workbench/v1/service/release`,On,e)}async function zi(e,t){if(!Oi)throw Error(`unavailable`);let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Oi})},body:JSON.stringify(e)}),r=await Pi(n);if(!n.ok)throw Error(Fi(r));let i=z(r,[`kind`,`job`]);return L(i.kind,`service-job`),Tn(i.job)}function Bi(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),[a,o]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let t=++i.current,n=new AbortController,r=()=>!n.signal.aborted&&i.current===t,a,s=async()=>{if(r()){try{let t=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n.signal}),i=await Pi(t);if(!t.ok)throw Error(Fi(i));r()&&o({id:e,value:mn(i)})}catch(t){r()&&o(n=>({id:e,value:n.id===e?n.value:void 0,error:t instanceof Error?t.message:`unavailable`}))}r()&&(a=setTimeout(()=>void s(),5e3))}};return s(),()=>{n.abort(),clearTimeout(a)}},[e,n,t]);let s=(0,f.useCallback)(()=>{++i.current,r(e=>e+1)},[]),c=t=>{s(),o(n=>({id:e,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:n.id===e?n.value?.workspaceId??null:null}}))};return{...a.id===e?a:{},refresh:s,prepared:c}}var Vi=e=>e===`unauthenticated`||e===`forbidden`,Hi=class{api;serial=Promise.resolve();version=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),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new mi,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new mi,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,Vi(e.error.code)&&w(),!1):(T(e.value),!0)};if(t&&!await i())return;e||(_.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(a.kind===`ok`)_.activeRuns=a.value;else if(Vi(a.error.code)){w();return}else _.activeRuns=void 0;y();let o=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(o.kind===`error`){_.error=o.error.code,Vi(o.error.code)&&w();return}if(!t&&W(_.workspace?.models??[])!==W(o.value.models)&&!await i())return;if(_.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,Vi(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new mi,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Oi?{kind:`browser`,...Oi}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new mi,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new mi,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function Ui(e,t,n,r){let i=(0,f.useMemo)(()=>new Hi(e),[e]),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,f.useEffect)(()=>{if(c({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:(e=!1)=>i.refresh(e),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var Wi=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 Gi({client:e,value:t,onChange:n}){let{t:r,tx:i}=T(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.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 Ki(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 qi(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 Ji(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 Yi(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=Ki(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 Xi(e,t){let n=t?W({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),qi(e,l,n.signal).then(e=>{t===m.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===m.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),m.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&p(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),p(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),p([]),u(t?{...t}:null)}}}function Zi({value:e,compact:t=!1}){let{t:n,tx:r}=T();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(Zi,{value:e})]}):(0,h.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 Qi(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 $i(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Qi(e)}return Qi(e)}function ea(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(!1),s=(0,f.useRef)(null),c=(0,f.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,f.useCallback)(()=>{c(),o(!1)},[c]);return(0,f.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,f.useCallback)(async e=>{let a=!1;try{a=await $i(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}}function ta(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
14
+ `).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,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var na=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ra(!0)},text:{92:ra(!1)}});let t={enter:{backslashMathInline:ia,backslashMathDisplay:ia,backslashMathBlock:ia},exit:{backslashMathInline:aa,backslashMathDisplay:aa,backslashMathBlock:aa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ra(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 ia=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)},aa=function(e){this.exit(e)},oa=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ea();return(0,h.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:t(`Copy displayed text`),"aria-label":t(`Copy displayed text`),onClick:()=>{r(!1),a(e).then(e=>r(!e))},children:[i?(0,h.jsx)(li,{}):(0,h.jsx)(ii,{}),n&&t(`Copy unavailable`)]})}),sa=[s,d,na],ca=[s,l,d,na],la=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function ua(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 da({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?ca:sa,rehypePlugins:t?[i,o,...la]:la,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ma,a:pa,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var fa=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(da,{...e})})});function pa({href:e,children:t}){let n=e&&ua(e);return n?(0,h.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,h.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function ma({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=ta(r).map(e=>{let t=`code-offset:${i}`;return i+=ha(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,h.jsxs)(`div`,{className:`codeblock`,children:[(0,h.jsx)(oa,{text:ha(e)}),(0,h.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,h.jsxs)(`div`,{className:`code-line`,children:[o&&(0,h.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,h.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function ha(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(ha).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return ha(t?.children)}return``}function ga(e,t){let n=[],r=t;if(!r)return n;let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode(e){let t=e.parentElement;return!t||t.closest(`.search-bar`)||t.closest(`.msg-collapsed`)?NodeFilter.FILTER_REJECT:(e.textContent??``).includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let e=i.nextNode();e;e=i.nextNode()){let t=e.textContent??``;if(!e.parentElement?.closest(`[data-retained-field]`))continue;let 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 _a=new Map;function va(e,t){t.length?_a.set(e,t):_a.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[..._a].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 ya(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 ba(e,t){let n=t.startContainer.parentElement;for(let r of ya(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 xa({container:e,version:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(0),l=(0,f.useRef)([]),u=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?ga(n,r):[];return l.current=i,c(i.length),o(0),va(u,i),()=>va(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(ba(e.current,l.current[n]),va(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>va(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function Sa({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await Yi(e,t,n.signal);if(n.signal.aborted)return;let i=await $i(r.text);if(n.signal.aborted)return;w(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||w(a(`Full-field copy refused/incomplete.`))}finally{E.current===n&&(E.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,h.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,h.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,h.jsx)(`summary`,{children:a(`Field details`)}),(0,h.jsxs)(`div`,{className:`detail-identity`,children:[(0,h.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,h.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!!E.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!E.current&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{E.current?.abort(),E.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,h.jsx)(`p`,{role:`status`,children:C}),y&&(0,h.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),_&&(0,h.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,h.jsx)(Zi,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,h.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,h.jsxs)(h.Fragment,{children:[(!i||k.next)&&(0,h.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:k.range?.start??0,end:k.range?.end??0,total:k.content.bytes}),` `,k.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,h.jsx)(xa,{container:D,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,h.jsx)(fa,{text:k.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!k||!n||!k.range)return k?.text;let e=Math.max(n.start,k.range.start)-k.range.start,t=Math.min(n.end,k.range.end)-k.range.start;if(t<=e)return k.text;let r=new TextEncoder().encode(k.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,h.jsxs)(h.Fragment,{children:[i(0,e),(0,h.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||m.length>0||d?.next)&&(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.length,onClick:()=>{u(m[m.length-1]),g(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!d?.next,onClick:()=>{d?.next&&(g(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function Ca({pager:e,compact:t=!1}){let{t:n,tx:r}=T(),{page:i,busy:a,error:o}=e;return(0,h.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,h.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,h.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,h.jsx)(Zi,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.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,h.jsx)(zr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function wa({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=Xi(e,{...t,reader:`contents`}),[o,s]=(0,f.useState)(),c=a.page;return(0,h.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,h.jsx)(Ca,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(x,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,h.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,h.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,h.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,h.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,h.jsx)(Zi,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Ji(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,h.jsx)(Sa,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ta({client:e,seed:t}){return(0,h.jsx)(Ea,{client:e,seed:t},W(t))}function Ea({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.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,h.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,h.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,h.jsx)(Zi,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function Da(e=typeof window>`u`?``:window.location.search){let t=new URLSearchParams(e).get(`project`);return t&&/^[a-f0-9]{64}$/.test(t)?t:null}function Oa(){let e=Da();return e?`/projects/${e}`:``}function ka(e){let t=wi(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Oa()+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 Aa({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.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,h.jsx)(Nr,{"aria-hidden":`true`})})]}),t]})}function ja({request:e,onClose:t}){let{t:n,tx:r}=T(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(Aa,{title:n(`Export retained history`),onClose:t,children:[(0,h.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,h.jsxs)(`label`,{children:[n(`Format`),(0,h.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,h.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,h.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,h.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,h.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,h.jsx)(`button`,{type:`button`,onClick:()=>{try{ka({...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,h.jsx)(`p`,{role:`status`,children:s})]})}function Ma(e,t){if(!t||N(t)>k.queryBytes)throw Error(`Query must be 1–${k.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 Na(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 Pa({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=T(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=Ma(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(Aa,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(Rr,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.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,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Zi,{value:m.coverage}),(0,h.jsxs)(`div`,{className:`gs-section`,children:[(0,h.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:m.hits.length})}),m.hits.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>p(t),onClick:()=>{r(e),n()},children:[(0,h.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,h.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,h.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})]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),m.hits.length===0&&(0,h.jsx)(`p`,{children:a(Na(m))})]}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.next,onClick:()=>{m.next&&S(m.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,h.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Fa({run:e,historical:t=!1}){let{t:n,tx:r}=T();return(0,h.jsxs)(`article`,{className:`run-summary`,children:[(0,h.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,h.jsx)(`p`,{children:(0,h.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,h.jsx)(`dd`,{children:r(e.lifecycle)}),(0,h.jsx)(`dt`,{children:n(`Execution`)}),(0,h.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,h.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,h.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,h.jsx)(`dt`,{children:n(`Summary publication`)}),(0,h.jsx)(`dd`,{children:r(e.publication)})]}),(0,h.jsx)(Zi,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Ia({client:e,seed:t}){return(0,h.jsx)(La,{client:e,seed:t},W(t))}function La({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.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,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,h.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,h.jsx)(Zi,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Sa,{client:e,cursor:Ji(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,h.jsx)(fa,{text:e.instructions}),(0,h.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function Ra({client:e,seed:t,onScope:n}){let{t:r}=T(),i=Xi(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ca,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Fa,{run:e.projection,historical:!0}),(0,h.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,h.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,h.jsx)(Ia,{client:e,seed:o},o.graph.recordId)]})}function za({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.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,h.jsx)(Rr,{"aria-hidden":`true`})})}function Ba(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 Va(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 Ha(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)??Ua(n.role,n.customType)}return r}function Ua(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 Wa(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Ga(e,t,n=1800){let[r,i]=(0,f.useState)(()=>new Set),a=(0,f.useRef)(r);a.current=r;let o=(0,f.useRef)(new Map),s=(0,f.useRef)(new Map),c=(0,f.useRef)(new Map),l=(0,f.useRef)(0),u=(0,f.useRef)(new Map);u.current=new Map(t.map(e=>[e.id,e.version]));let d=(0,f.useRef)(new Set);d.current=Ha(t,o.current,n);let p=(0,f.useCallback)((e,t)=>{let n=u.current.get(e);n!==void 0&&(s.current.set(e,{h:t,len:n}),o.current.set(e,t))},[]),m=(0,f.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of c.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),a.current.has(e)||p(e,n.height)}let o=Ba(r,{top:n.top-1200,bottom:n.bottom+1200},d.current,a.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of o.hide){let t=c.current.get(e);t&&p(e,t.offsetHeight)}i(e=>Va(e,o))},[p,e]),h=(0,f.useCallback)(()=>{l.current||=requestAnimationFrame(()=>{l.current=0,m()})},[m]);return(0,f.useLayoutEffect)(()=>{t.length?m():i(new Set)},[m,t]),(0,f.useEffect)(()=>{let t=new ResizeObserver(h);return e.current&&t.observe(e.current),()=>{t.disconnect(),cancelAnimationFrame(l.current)}},[h,e]),{hidden:r,scheduleSweep:h,recordMeasured:p,register:(0,f.useCallback)(e=>t=>{t?c.current.set(e,t):c.current.delete(e)},[]),placeholder:(0,f.useCallback)((e,t,n)=>Wa(e,t,s.current,n),[])}}var Ka=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null);return(0,f.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,h.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,h.jsx)(`div`,{ref:s,children:o})}):(0,h.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),qa=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(oi,{"aria-hidden":`true`}):(0,h.jsx)($r,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(Sa,{compact:!0,client:t,cursor:Ji(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.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,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(wa,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Ja({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),o=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=Ga(i,o);return(0,h.jsxs)(`div`,{className:`messages-wrap`,children:[(0,h.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,h.jsx)(Ka,{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,h.jsx)(qa,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(fi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Ya({client:e,seed:t}){let{t:n}=T(),r=Xi(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ca,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,h.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,h.jsxs)(h.Fragment,{children:[i.records.length===0&&(0,h.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,h.jsx)(Ja,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Xa({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,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(ci,{}):(0,h.jsx)(si,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Za=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.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,h.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,h.jsx)(Xa,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Pr,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.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,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(wa,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Qa=[`queued`,`running`];function $a(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,``)}var eo=4,to=1e4;function no(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,f.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?Qa.includes(t.status):i-(u.get(e)??0)>=to}).reverse();for(let n=0;n<a.length;n+=eo){let r=await Promise.all(a.slice(n,n+eo).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+eo<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>Qa.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),to))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function ro({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=no(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,f.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(b)){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||(g(i),v(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,b]);let x=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],S=[...m,...x.filter(e=>!m.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=[...new Set(a)].flatMap(e=>{let t=y.runs.get(e);return t?t.steps.filter(e=>e.childRunId).map(e=>({run:t,step:e})):[]}).reverse().sort((e,t)=>Number(!Qa.includes(e.step.status))-Number(!Qa.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>Qa.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,D=d??(w>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${D?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":D,onClick:()=>p(!D),children:[(0,h.jsx)(ci,{}),(0,h.jsx)(ni,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:w}):w})]}),D&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),w===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,step:t})=>{let n=$a(t.id);return(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row${o?.runId===e.id&&o.stepId===t.id?` active`:``}`,title:e.goal,onClick:()=>c?.({runId:e.id,stepId:t.id,label:n}),children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsxs)(`strong`,{children:[u(t.kind),` · `,n]}),(0,h.jsx)(`small`,{children:e.goal})]}),(0,h.jsx)(`span`,{className:`ep-state ${t.status}`,children:u(t.status)})]},t.childRunId)}),S.map(e=>(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,h.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,h.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}var io=2e4;function ao(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:$n(e.head)},n=e.location?rn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new A(`stale`);let r=M(e.text,er,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:P(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:P(e.revision,0)};return Object.freeze({text:r,images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(oo(e.model))}:{}})}function oo(e){return K({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function so(e,t){return Object.freeze({...e,model:Object.freeze(oo(t))})}function co(e,t){if(e.model&&W(e.model)!==W(oo(t)))throw new A(`stale`)}function lo(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null))throw new A(`stale`);let n=ur(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 A(`invalid`);return n}function uo(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 fo(e){if(e.length>An.count||e.reduce((e,t)=>e+t.size,0)>An.totalBytes)throw Error(`Too many images or total image size exceeded.`);for(let t of e){if(!jn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size||t.size>An.bytes)throw Error(`Image is empty or too large.`)}}async function po(e){fo([e]);let t=new Uint8Array(await e.arrayBuffer());return Nn(t,e.type),t}var mo=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 ho(e,t,n,r){fo(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await po(a);if(!r())throw Error(`stale`);let o=mo(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=An.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+An.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 go(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>An.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,r>4*Math.ceil(An.bytes/3))throw Error(`capacity`);if(i.next===null)break;if(i.next!==r||i.data.length!==An.chunkChars)throw Error(`invalid`)}let i=Mn(n.join(``));return Nn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var _o=1e3,vo=1e4,yo=4,bo=e=>e===`queued`||e===`running`,xo=class extends Error{},So=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;commands=[];count=0;first=null;turns=new Map;imageReaders=new Map;details=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=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){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=e=>{this.closed||this.pinned===e||(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.error=``,this.forget(),this.publish(),this.tick())};forget(){this.turns.clear(),this.details.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())};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{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,commands:this.commands,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.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof xo?e.message:`unavailable`)}finally{this.running=!1}if(e&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=bo(this.summary?.status)||[...this.turns.values()].some(e=>bo(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?_o:vo)}async sync(e){let t=this.pinned,n=await this.read({kind:`conversation`,id:this.id,leaf:t,known:this.leaf},e);if(e.aborted)return;if(n.kind!==`conversation`)throw new xo(`invalid`);(!n.continues||n.turns<this.count)&&this.forget();let r=n.leaf===this.leaf?this.count:this.count-1;this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.commands=n.commands??[],this.summary=n.summary,this.count=n.turns,this.first=Math.min(this.first??Math.max(0,n.turns-2),n.turns),this.publish();let i=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||bo(t.header.status))&&i.push(e)}await Promise.all(i.map(t=>this.load(t,n.leaf,e)))}async load(e,t,n){let r=this.turns.get(e),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,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{o[i.start+t]=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))))r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)});if(!n.aborted){if(o.some(e=>!e))throw new xo(`stale`);this.turns.set(e,{ordinal:e,header:a,steps:o,detail:this.detail(t,a.id,n),image:this.imageReader(t,n)})}}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 xo(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=(n,r)=>go(n,i=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:i},AbortSignal.any([t,r]))),this.imageReaders.set(n,r)),r}detail(e,t,n){let r=`${e??``}:${t}`,i=this.details.get(r);return i||(i=async(r,i,a)=>{let o=await Promise.all(Array.from({length:i},async(i,o)=>{let s=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},AbortSignal.any([n,a]));if(s.kind!==`conversation-step`||s.part!==o)throw new xo(`invalid`);return s.item}));return{text:o.map(e=>e.text).join(``),args:o.map(e=>e.args).join(``)}},this.details.set(r,i)),i}async read(e,t=this.abort.signal){this.reads>=yo&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new xo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new xo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Co(e,t,n){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new So(e,t,()=>o(n.view()));return i(n),o(n.view()),()=>n.close()},[e,t]),(0,f.useEffect)(()=>{r?.setActive(n)},[r,n]),{...a??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:r?.refresh??wo,loadEarlier:r?.loadEarlier??wo,choose:r?.choose??wo}}function wo(){}async function To(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||W(r.value.proposal)!==W(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 Eo(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Do(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Oo={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},ko={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed and was read again. Choose once more.`,"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. The list was read again; check the current model before choosing again.`},Ao=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,jo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Mo(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>le.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function No(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Oo[t.thinking])}`,[e])}function Po({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,onObserved:c,awaitingSend:l=!1}){let{t:u}=T(),d=No(),p=(0,f.useRef)(c);p.current=c;let[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(``),[E,D]=(0,f.useState)(0),O=(0,f.useRef)(null),k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=(0,f.useRef)(null),te=(0,f.useCallback)(()=>D(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(g(e.value),p.current?.(e.value),v(``)):v(e.error.code))}).catch(()=>{t.signal.aborted||v(`unavailable`)}),()=>t.abort()},[e,r,E]),(0,f.useEffect)(()=>{i&&te()},[i,te]);let j=(0,f.useCallback)((e=!0)=>{a(!1),w(``),e&&k.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;b(``),ee.current?.focus({preventScroll:!0});let e=e=>{O.current?.contains(e.target)||j(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,j]);let M=m?.selected??null,N=M??m?.remembered??null,P=(0,f.useMemo)(()=>{let e=C.trim().toLowerCase(),t=new Map;for(let n of m?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[m,C]),F=m?.entries.find(e=>jo(e,N)),I=async(t,r)=>{if(!m||!t.api||x||n)return;let i=K({provider:t.provider,model:t.model,api:t.api,thinking:r});if(M&&Ao(M,i))j(),s?.(i);else{S(!0),b(``);try{let t=await e.chooseModel({expected:m.version,choice:i});if(t.kind===`error`){b(t.error.code),te();return}let n={...m,version:t.value.version,selected:t.value.selected};g(n),p.current?.(n),o(),j(),s?.(i)}catch{b(`uncertain`),te()}finally{S(!1)}}},L=()=>[...A.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],R=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=L(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?ee.current?.focus():t[Math.min(n,t.length-1)]?.focus()},z=!t||!m&&!!_,B=m?N?d(N):u(`Choose a model`):u(_?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:O,children:[(0,h.jsxs)(`button`,{ref:k,type:`button`,className:`model-trigger${N&&!M?` remembered`:``}${m&&!N?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:B}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?u(`Switch models after the current reply finishes.`):N&&!M?u(`Last used model; it is used again when you send.`):N?`${N.provider}/${N.model} · ${N.api}`:void 0,onClick:()=>i?j():a(!0),children:[(0,h.jsx)(ni,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:B}),(0,h.jsx)(ci,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":u(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),j())},children:[l&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:u(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(Rr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:ee,type:`search`,"aria-label":u(`Search models`),placeholder:u(`Search models…`),value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),L()[0]?.click())}})]}),(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":u(`Models`),ref:A,onKeyDown:R,children:[!m&&!_&&(0,h.jsx)(`p`,{className:`model-empty`,children:u(`Reading models…`)}),P.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,r=jo(e,N);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||x||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void I(e,Mo(e,N?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?u(`Credentials unavailable`):u(`Not supported`)}),r&&!M&&(0,h.jsx)(`span`,{className:`model-option-note`,children:u(`Used when you send`)}),r&&(0,h.jsx)(li,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),m?.status===`complete`&&P.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:C.trim()?u(`No matching models.`):u(`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),F&&F.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:u(`Thinking`)}),F.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":u(`Thinking level: {level}`,{level:u(Oo[e.level])}),"aria-pressed":N?.thinking===e.level,disabled:!e.selectable||x||n,onClick:()=>void I(F,e.level),children:u(Oo[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:u(`Switch models after the current reply finishes.`)}),m?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:u(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!m?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:u(m.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; restart the service 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; restart the service after editing models.json.`,{count:m.withheld})}),_&&(0,h.jsxs)(`p`,{role:`alert`,children:[u(`The model list could not be read ({code}).`,{code:_}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:te,children:u(`Read again`)})]}),y&&(0,h.jsx)(`p`,{role:`alert`,children:ko[y]?u(ko[y]):u(`The model was not changed ({code}).`,{code:y})}),!z&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(x?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}function Fo(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 Io({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=ji(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>Fo(s?.nodes??[]),[s]);return(0,h.jsxs)(`section`,{className:`branch-tree`,"aria-label":a(`Conversation branches`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h3`,{children:a(`Conversation branches`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":a(`Close`),onClick:i,children:(0,h.jsx)(Nr,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),o.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,o.error)}),!s&&!o.error&&(0,h.jsx)(`p`,{children:a(`Reading…`)}),s?.truncated&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Only the newest messages are listed.`)}),(0,h.jsx)(`ol`,{className:`branch-rows`,children:c.map(({node:e,depth:t})=>(0,h.jsx)(`li`,{style:{paddingInlineStart:`${t*16}px`},children:(0,h.jsxs)(`button`,{type:`button`,className:`branch-row${e.current?` current`:``}`,"aria-current":e.current?`true`:void 0,title:e.text,onClick:()=>r(e.leaf),children:[(0,h.jsx)(`span`,{className:`branch-text`,children:e.text||`…`}),e.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})},e.id))})]})}function Lo(){let[e,t]=(0,f.useState)([]),n=(0,f.useRef)(e),r=(0,f.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];fo(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,f.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),key:e=>r.current.get(e)}}function Ro({file:e,disabled:t,remove:n}){let{t:r}=T(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),po(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,h.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,h.jsx)(`img`,{src:i,alt:e.name}),o&&(0,h.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid or oversized image.`)}),(0,h.jsx)(`span`,{title:e.name,children:e.name}),(0,h.jsx)(`button`,{type:`button`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`})]})}function zo({image:e,read:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(!1),{entry:s,index:c,mimeType:l,live:u}=e;return(0,f.useEffect)(()=>{let e=new AbortController,n=``;if(i(``),o(!1),!t)o(!0);else return t({entry:s,index:c,mimeType:l,...u?{live:u}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i(n))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,s,c,l,u]),a?(0,h.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,h.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,"aria-label":n(`Open image`),children:(0,h.jsx)(`img`,{src:r,alt:n(`Attached image`),loading:`lazy`,onError:()=>o(!0)})}):(0,h.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)})}function Bo({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(zo,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var Vo=/^\s{0,3}(`{3,}|~{3,})/,Ho=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Uo(e){return e.trim()===``}function Wo(e){let t=Vo.exec(e);return t?t[1]:null}function Go(e){let t=e.split(`
15
+ `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Wo(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Wo(a);if(o&&!Uo(a))i=o,r.push(a);else if(Uo(a)){let i=e;for(;i<t.length&&Uo(t[i]);)i++;if(!(i<t.length&&Ho.test(t[i]))&&r.length>0){n.push(r.join(`
14
16
  `)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
15
- `),inFence:i!==null}}function jo(e,t,n=!1){let r=e.length;if(t>=r)return r;t<0&&(t=0);let i=r-t,a;a=n?i<=16?Math.max(2,Math.ceil(i/6)):Math.ceil(i/8):i<=32?1:i<=90?2:Math.ceil(i<=240?i/28:i/18);let o=Math.min(r,t+a);if(o<r){let t=e.charCodeAt(o-1);t>=55296&&t<=56319&&(o=Math.min(r,o+1))}return o}var Mo=(0,f.memo)(function({text:e}){return(0,h.jsx)(aa,{text:e})}),No=22,Po=14,Fo=()=>typeof document<`u`&&document.hidden;function Io(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||Fo()||e.length>1500?e.length:0),o=(0,f.useRef)(e);o.current=e;let s=(0,f.useRef)(i);s.current=i;let c=(0,f.useRef)(n);c.current=n;let l=(0,f.useRef)(r);return l.current=r,(0,f.useEffect)(()=>{if(typeof document>`u`)return;let e=()=>{document.hidden,s.current=o.current.length,a(o.current.length),(c.current||!t)&&l.current?.()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]),(0,f.useEffect)(()=>{if(!t){s.current!==e.length&&(s.current=e.length,a(e.length));return}if(Fo()){s.current!==e.length&&(s.current=e.length,a(e.length)),(n||s.current>=e.length)&&l.current?.();return}if(e.length<s.current){s.current=e.length,a(e.length);return}if(s.current>=e.length){l.current?.();return}let r=0,i=0,u=e=>{let t=c.current?Po:No;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=jo(n,s.current,c.current);d!==s.current&&(s.current=d,a(d)),d<n.length?r=requestAnimationFrame(u):l.current?.()};return r=requestAnimationFrame(u),()=>cancelAnimationFrame(r)},[e,t,n]),!t||i>=e.length?e:e.slice(0,i)}var Lo=600,Ro=32;function zo({text:e,inFence:t}){let n=!t&&e.length>=Lo,[r,i]=(0,f.useState)(e),a=(0,f.useRef)(0),o=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(!n)return;let t=Date.now()-a.current,r=()=>{a.current=Date.now(),i(e)};if(t>=Ro)r();else return o.current=setTimeout(r,Ro-t),()=>{o.current&&clearTimeout(o.current)}},[e,n]),t?(0,h.jsx)(`div`,{className:`codeblock`,children:(0,h.jsx)(`pre`,{children:(0,h.jsx)(`code`,{children:e})})}):(0,h.jsx)(aa,{text:n?r:e})}var Bo=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=Io(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>Ao(r),[r]),s=0,c=i.map(e=>{let t=`stream-offset:${s}`;return s+=e.length,{key:t,text:e}});return(0,h.jsxs)(`div`,{className:`md`,children:[c.map(({text:e,key:t})=>(0,h.jsx)(Mo,{text:e},t)),a.length>0&&(0,h.jsx)(zo,{text:a,inFence:o},i.length)]})});function Vo(e){let t=e.items.map(e=>({...nr(e,1),text:e.role===`tool`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,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 Ho(e,t,n,r){let i=`${e.header.id}:${t}:${n.id}:${n.parts}`,[a,o]=(0,f.useState)({key:``}),{detail:s}=e,c=n.parts;return(0,f.useEffect)(()=>{if(!r||c===0)return;let e=new AbortController;return s(t,c,e.signal).then(e=>o({key:i,value:e}),t=>{e.signal.aborted||o({key:i,error:t instanceof Error?t.message:`unavailable`})}),()=>e.abort()},[s,t,c,r,i]),a.key===i?a:{}}function Uo(e){let t=e.map((e,t)=>({step:e,index:t})),n=t.filter(({step:e})=>e.role!==`user`),r=n.findLastIndex(({step:e})=>e.role===`tool`),i=({step:e})=>e.role===`tool`||e.text.trim()!==``;return{user:t.filter(({step:e})=>e.role===`user`),steps:n.slice(0,r+1).filter(i),answer:n.slice(r+1).filter(i)}}var Wo={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Go=e=>Object.hasOwn(Wo,e)?Wo[e]:`other`,Ko={read:[`Read 1 file`,`Read {n} files`],list:[`Listed 1 directory`,`Listed {n} directories`],search:[`Searched once`,`Searched {n} times`],run:[`Ran 1 command`,`Ran {n} commands`],edit:[`Edited 1 file`,`Edited {n} files`],other:[`Used 1 tool`,`Used {n} tools`]},qo=new Set([`read`,`list`,`edit`]);function Jo(e,t){return qo.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function Yo({turn:e,steps:t,live:n,answered:r,toggled:i=null,onToggle:a}){let{t:o}=T(),[s,c]=(0,f.useState)(i),l=s??(!n&&!r),u=t.map(({step:e})=>e).filter(e=>e.role===`tool`),d=u.filter(e=>e.error).length,{thinking:p,media:m,other:g}=e.header.omitted,_=[p&&o(`Thinking is not retained.`),m&&o(`Media is not retained.`),g&&o(`Other content is not retained.`)].filter(e=>e!==!1),v;if(n){let e=u.at(-1);v=e?`${o(`Working…`)} ${e.name||o(`Tool`)} ${e.target}`.trim():o(`Working…`)}else{let e=new Map;for(let t of u){let n=Go(t.name);e.set(n,(e.get(n)??new Set).add(Jo(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(Ko[e][0]):o(Ko[e][1],{n:t.size})).join(` · `)||(p?o(`Thought`):m?o(`Media not retained`):g?o(`Content not retained`):``)}let y=(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(`span`,{className:`chat-steps-live`,"aria-hidden":`true`}):(0,h.jsx)(ti,{className:`chat-steps-chevron`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chat-steps-title`,children:v}),d>0&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:o(`{n} failed`,{n:d})})]});return t.length===0&&_.length===0?(0,h.jsx)(`div`,{className:`chat-steps`,role:`status`,children:(0,h.jsx)(`div`,{className:`chat-steps-head`,children:y})}):(0,h.jsxs)(`details`,{className:`chat-steps`,"aria-label":o(`Working steps`),open:l,onToggle:e=>{let t=e.currentTarget.open;t!==l&&(c(t),a?.(t))},children:[(0,h.jsx)(`summary`,{className:`chat-steps-head`,children:y}),t.length>0&&(0,h.jsx)(`ol`,{className:`chat-steps-list`,children:t.map(({step:t,index:n})=>(0,h.jsx)(`li`,{children:t.role===`tool`?(0,h.jsx)(Zo,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(Xo,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function Xo({turn:e,index:t,step:n,render:r=e=>(0,h.jsx)(oa,{text:e})}){let{t:i}=T(),a=t<e.header.stable,o=Ho(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[r(o.value?.text??n.text),n.clipped&&a&&!o.value&&(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(i,o.error):i(`Reading the rest of this message…`)})]})}function Zo({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=Ho(e,t,n,i);return(0,h.jsxs)(`details`,{className:`chat-tool`,open:i,onToggle:e=>a(e.currentTarget.open),children:[(0,h.jsxs)(`summary`,{children:[(0,h.jsx)(`span`,{className:`chat-tool-name`,children:n.name||r(`Tool`)}),n.target&&(0,h.jsx)(`span`,{className:`chat-tool-target`,title:n.target,children:n.target}),n.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:r(`failed`)})]}),i&&n.parts>0&&(o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`pre`,{children:o.value.args}),o.value.text&&(0,h.jsx)(`pre`,{children:o.value.text})]}):(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):r(`Reading…`)}))]})}var Qo=(0,f.memo)(function({turn:e,toggled:t,onToggle:n}){let{t:r,tx:i}=T(),{header:a}=e,{user:o,steps:s,answer:c}=Uo(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
16
- `).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":r(`Conversation turn`),children:[o.map(({step:t,index:n})=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:r(`You`)}),(0,h.jsx)(Xo,{turn:e,index:n,step:t})]},n)),(u||c.length>0)&&(0,h.jsxs)(`article`,{className:`chat-message assistant`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:`Cadence`}),u&&(0,h.jsx)(Yo,{turn:e,steps:s,live:l,answered:c.length>0,toggled:t,onToggle:e=>n?.(a.id,e)}),c.map(({step:t,index:n})=>(0,h.jsx)(Xo,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(Bo,{text:e}):void 0},n))]}),a.execution&&(0,h.jsxs)(`details`,{className:`inspector-note`,children:[(0,h.jsx)(`summary`,{children:r(`Context fixed at admission:`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:a.execution.cwd}),` ·`,` `,a.execution.model?`${a.execution.model.provider}/${a.execution.model.model} · ${a.execution.model.thinking}`:r(`No model`)]})]}),d.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:d.map(e=>i(e)).join(`
17
- `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function $o({hint:e,children:t}){let{t:n}=T();return(0,h.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e}),t]})}var es=[`queued`,`running`],ts=e=>es.includes(e.status);function ns(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function rs(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function is(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=>ns(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=ns(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 as(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?ns(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 os(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 ss({client:e,run:t,onOpen:n,onChanged:r}){let{t:i,tx:a}=T(),o=(0,f.useId)(),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(``),d=(0,f.useRef)(!0);(0,f.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=ts(t),m=p?[a(rs(t)),t.steps.filter(e=>e.status===`running`).map(e=>qa(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,os(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
18
- `).find(e=>e.trim())??``,_=m.filter(Boolean).join(` · `);return(0,h.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,h.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,h.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:_,children:_})]}),p&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),ls(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Ar,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):g&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:g,children:a(g)})]})}function cs({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan banner-notice`,"aria-label":i(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:i(`Current implementation plan`)}),(0,h.jsx)(`p`,{children:i(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,h.jsxs)(`p`,{children:[i(`Declared write paths use the checkout root:`),` `,(0,h.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:e.display.baseCommit})]}),(0,h.jsx)(`p`,{children:i(`Approval covers only this plan: implementation, checks, bounded repairs and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(oa,{text:Un(e.plan)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function ls(e,t){let n=await e.workbenchCommand({kind:`workflow-cancel`,commandId:crypto.randomUUID(),epoch:t.epoch,runId:t.id});return n.kind===`error`?n.error.code:``}function us({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),c=Ti(e,{kind:`workflow`,id:t},o),l=c.value?.kind===`workflow`&&c.value.response.type===`run`?c.value.response.run:null,[u,d]=(0,f.useState)(null),p=Ti(e,u?{kind:`workflow-detail`,id:t,stepId:u}:null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(``),y=l&&[`queued`,`running`].includes(l.status),b=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,f.useEffect)(()=>{l&&![`queued`,`running`].includes(l.status)&&s(0)},[l]),(0,h.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`strong`,{children:l?.goal??i(`Observing workflow`)}),l&&(0,h.jsxs)(`span`,{className:`ep-state ${l.status}`,children:[a(l.phase),` · `,a(l.status)]})]}),(c.error||_)&&(0,h.jsxs)(`p`,{role:`alert`,children:[_||c.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),l?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:l.execution.cwd}),` ·`,` `,l.execution.model?`${l.execution.model.provider}/${l.execution.model.model} · ${l.execution.model.thinking}`:i(`No model`)]}),l?.notice&&(0,h.jsx)(`p`,{children:l.notice}),l&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:qn(l)})]}),l?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:l.mergedCommit})]}),l&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),l?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,qa(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(oa,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:qa(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,h.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>d(e.id),children:i(`Read retained step result`)}),u===e.id&&p.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:p.value.text}),u===e.id&&p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error})]},e.id)),y&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:m,onClick:()=>{l&&(g(!0),ls(e,l).then(e=>{b.current&&(v(e),c.refresh(),n?.())}).finally(()=>{b.current&&g(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:c.refresh,children:i(`Observe current state`)})]})}var ds=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function fs(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function ps({client:e,id:t,workspaceId:n,initialCwd:r,onLocation:i,enabled:a,actionsReady:o=a,prepareForSend:s,legacyWorkspaceId:c,directoryNamespaces:l=[],available:u=a,canInterrupt:d=a,modelEnabled:p=a,onModelChanged:m,onChanged:g,reference:_,onReferenceUsed:v,hidden:y=!1,onOpenAgent:x,onWorkflowRuns:S}){let{t:C,tx:w}=T(),[E]=(0,f.useState)(()=>io(n,t,c,...l)),[D,O]=(0,f.useState)(()=>fs(E)),[k,A]=(0,f.useState)(()=>fs(`${E}:mode`)===`cadence`?`cadence`:`chat`),[j,M]=(0,f.useState)(!1),[N,P]=(0,f.useState)(``),[F,I]=(0,f.useState)(()=>fs(`${E}:pending`)),[L,R]=(0,f.useState)(!1),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)(!1),[U,W]=(0,f.useState)(0),te=(0,f.useRef)(null),ne=(0,f.useRef)(!1),G=(0,f.useRef)(0),re=(0,f.useRef)(new AbortController),[ie,K]=(0,f.useState)(!1),ae=Ti(e,u&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),oe=ae.value?.kind===`conversation-context`?ae.value.context:void 0,se=!!oe&&!ae.error,ce=oe?.cwd??r,q=(0,f.useRef)(null),le=(0,f.useMemo)(()=>({models:n=>ce?e.models(n,{id:t,cwd:ce}):Promise.resolve({kind:`error`,error:ee(`unavailable`)}),chooseModel:n=>ce?e.chooseModel(n,{id:t,cwd:ce}):Promise.resolve({kind:`error`,error:ee(`unavailable`)})}),[e,t,ce]),ue=(0,f.useRef)(i);ue.current=i,(0,f.useEffect)(()=>{se&&ce&&ue.current?.({id:t,cwd:ce})},[se,t,ce]);let J=fo(e,t,u),{turns:Y}=J,de=J.summary!==void 0,fe=Ti(e,u?{kind:`cadence-conversation`,id:t}:null,1e3),X=fe.value?.kind===`cadence-conversation`?fe.value.state:void 0,pe=X?.enabled===!0,me=!!X||!!fe.error,he=!!X&&!fe.error&&!X.notice,ge=(0,f.useRef)(X);ge.current=X;let[_e,ve]=(0,f.useState)(``),ye=(0,f.useRef)(``),be=Ei(D,pe?`cadence`:k),xe=a&&se&&de&&!J.error&&me&&!(pe&&(fe.error||X?.notice))&&!j&&!z&&!F,Se=J.summary??void 0,Ce=Se&&(Se.status===`queued`||Se.status===`running`),we=!!Se&&Se.status!==`completed`&&!Ce,[Te,Ee]=(0,f.useState)(!1),De=!!s&&a&&(!!J.error||!!ae.error)&&J.error!==`retired-conversation`&&ae.error!==`retired-conversation`&&!X?.notice&&!Ce&&!j&&!F&&!z,Oe=(d||!!s)&&se&&de&&he&&!J.error&&!j&&!F&&!Ce,ke=!!X?.proposal&&!!Se&&!Ce&&Se.status!==`unknown`,Ae=X?.proposal&&Se?.status===`unknown`?C(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,je=(0,f.useRef)(null),Me=(0,f.useRef)(null),Ne=(0,f.useRef)(0),Pe=(0,f.useRef)(!0),[Fe,Ie]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!y&&Me.current&&!Pe.current&&(Me.current.scrollTop=Ne.current)},[y]);let Le=(0,f.useRef)(!0),Re=(0,f.useRef)(``),ze=(0,f.useRef)(D);(0,f.useEffect)(()=>(Le.current=!0,re.current.signal.aborted&&(re.current=new AbortController),()=>{Le.current=!1,re.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${E}:mode`,k)}catch{}},[E,k]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(E,D)}catch{}},[D,E]),(0,f.useEffect)(()=>{try{F?sessionStorage.setItem(`${E}:pending`,F):sessionStorage.removeItem(`${E}:pending`)}catch{}},[E,F]),(0,f.useEffect)(()=>{_&&(O(e=>`${e}${e?`
19
- `:``}@${_}`),v(),je.current?.focus())},[_,v]),(0,f.useEffect)(()=>{let e=Se?`${Se.leaf}:${Se.status}`:``;e&&Re.current!==e&&(Re.current=e,g()),ye.current&&X?.runs.includes(ye.current)&&(ye.current=``,ve(``),P(``)),F&&(Se?.live?.commandId===F||J.attempt?.commandId===F||Y.some(e=>e.header.id===F)||J.commands.includes(F))&&(I(``),O(e=>e===ze.current?``:e),g()),Pe.current&&Me.current&&(Me.current.scrollTop=Me.current.scrollHeight)},[Se,Y,F,g,X,J]);let Be=(0,f.useMemo)(()=>Y.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})),[Y]),Ve=za(Me,Be),He=(0,f.useRef)(new Map),Ue=(0,f.useCallback)((e,t)=>{He.current.set(e,t)},[]),{earlier:We,loadEarlier:Ge}=J,Ke=()=>{let e=Me.current;e&&!y&&We&&e.scrollTop<1200&&Ge()};(0,f.useEffect)(Ke);let qe=Y[0]?.ordinal,Je=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Me.current;if(!e)return;let t=Je.current;!ds&&!Pe.current&&t.ordinal!==void 0&&qe!==void 0&&qe<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Je.current={ordinal:qe,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${E}:approval`)}catch{}},[E]);let Ye=(0,f.useMemo)(()=>[...new Set([...J.runs,...X?.runs??[]])],[J.runs,X?.runs]),Xe=JSON.stringify(Ye.slice(-4));(0,f.useEffect)(()=>{S?.(JSON.parse(Xe))},[Xe,S]);let[Ze,Qe]=(0,f.useState)({terminal:8,browser:8}),$e=(0,f.useMemo)(()=>[...new Set([...J.runs.slice(-Ze.terminal),...(X?.runs??[]).slice(-Ze.browser)])],[J.runs,X?.runs,Ze]),et=Xa(e,u?$e:[],1e3),tt=Y.find(e=>e.header.at>0)?.header.at,Z=!We&&Y.length>0;(0,f.useEffect)(()=>{if(!u)return;let e=(e,t)=>as(e,t,et.runs,et.unreadable,tt,Z),t=e(J.runs,Ze.terminal),n=e(X?.runs??[],Ze.browser);(t!==Ze.terminal||n!==Ze.browser)&&Qe({terminal:t,browser:n})},[u,J.runs,X?.runs,Ze,et,tt,Z]);let nt=(0,f.useMemo)(()=>is(Y,et.runs.values(),We),[Y,et.runs,We]),rt=[...et.runs.values()].filter(ts).at(-1),it=[...et.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{it&&Pe.current&&Me.current&&(Me.current.scrollTop=Me.current.scrollHeight)},[it]);let at=t=>(0,h.jsx)(ss,{client:e,run:t,onOpen:()=>x?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{fe.refresh(),g()}},t.id),ot=async()=>{if(!X?.proposal){P(C(`No plan is awaiting approval.`));return}if(!o||!he||!xe||Ce||_e||!ke)return;let t=X,n=G.current;M(!0),P(``);try{let r=await mo({client:e,state:t,current:()=>Le.current&&G.current===n&&ge.current?.revision===t.revision&&ge.current?.enabled===!0,submitting:e=>{ye.current=e,ve(e)}});if(!Le.current||G.current!==n)return;r.kind===`error`?(P(r.error.code),ve(``)):O(e=>go(e)?``:e)}catch(e){Le.current&&G.current===n&&P(e instanceof Error?e.message:`unavailable`)}finally{Le.current&&G.current===n&&(M(!1),fe.refresh(),J.refresh(),g())}},st=async(n,r)=>{let i=r?.text??n??D,a=r?r.command.kind===`cadence-exit`:pe&&ho(i);if(!(a?Oe:xe)&&!De||Ce||!i.trim())return;if(!r&&!n&&pe&&go(i)){o?await ot():P(C(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let c=Ei(i,k).mode===`cadence`;if(!De&&(pe||c)&&!he){P(C(`Cadence state unavailable. Observe the conversation before sending.`));return}if(ne.current)return;ne.current=!0,M(!0),P(``);let l=G.current,u=()=>Le.current&&G.current===l,d=!1,f=!1,p=async e=>{s&&(f=!0,K(!0),await s(AbortSignal.any([re.current.signal,AbortSignal.timeout(Qa)]),e),u()&&(K(!1),W(e=>e+1)))};try{if(De){if(await p(oe?{id:t,cwd:oe.cwd}:void 0),!u())return;J.refresh(),ae.refresh(),fe.refresh(),g(),P(C(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let n=r??$a({id:t,head:J.leaf,text:i,revision:X?.revision??0,location:oe?{id:t,cwd:oe.cwd}:void 0,model:q.current??oe?.model??void 0,intent:a?`exit`:pe?`message`:c?`enter`:`ordinary`});if(await p(n.location),!u())return;if(n.command.kind===`cadence-exit`){let t=n.command.commandId;ze.current=i,I(t),d=!0;let r=await e.workbenchCommand(ro(n));if(!u())return;r.kind===`error`?(P(r.error.code),r.error.effect===`none`&&I(``)):(I(``),A(`chat`),O(e=>e===i?``:e)),fe.refresh(),J.refresh(),g();return}let o=()=>{te.current=n,B(!0),R(!0)},s=await e.models(void 0,n.location);if(!u())return;let l=s.kind===`ok`?s.value.selected??s.value.remembered:null;!n.model&&l&&(n=to(n,l));let f=n.model??(s.kind===`ok`?s.value.remembered:null);if(s.kind===`ok`&&!s.value.selected&&f){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:s.value.version.epoch,...n.location?{location:n.location,expected:s.value.version,choice:f}:{}});if(!u())return;if(t.kind===`error`){P(t.error.code),o();return}if(s=await e.models(void 0,n.location),!u())return;W(e=>e+1)}if(s.kind!==`ok`||!s.value.selected){o();return}no(n,s.value.selected);let m=ro(n,s.value.version);ze.current=i,I(m.commandId),d=!0;let h=await e.workbenchCommand(m);if(!u())return;h.kind===`error`?(P(`${h.error.code}. ${C(`Observe this send before sending again. No automatic retry.`)}`),h.error.effect===`none`&&I(``)):(O(e=>e===ze.current?``:e),I(``),m.kind===`cadence-send`&&A(`chat`),ut(null)),fe.refresh(),J.refresh(),g()}catch(e){u()&&P(d?C(`Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.`):C(f?`The message was not sent ({code}). Its draft is kept; preparation may have started an execution service.`:`The message was not sent ({code}). Its draft is kept.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{G.current===l&&(ne.current=!1),u()&&(M(!1),K(!1))}},ct=(0,f.useRef)(st);ct.current=st,(0,f.useEffect)(()=>{if(V&&xe&&!Ce){H(!1);let e=te.current;te.current=null,e&&ct.current(void 0,e)}},[V,xe,Ce]),(0,f.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>{H(!1),te.current=null},1e4);return()=>clearTimeout(e)},[V]);let lt=async()=>{let n=Se?.live;if(!n||j)return;M(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Le.current&&(r.kind===`error`&&P(r.error.code),M(!1),J.refresh())},ut=e=>{++G.current,re.current.abort(),re.current=new AbortController,te.current=null,ne.current=!1,B(!1),H(!1),R(!1),M(!1),K(!1),J.choose(e),Ee(!1)};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:y,"aria-label":C(pe?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Lr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:Se?.title??C(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:C(pe?`Cadence on`:`Ordinary`)}),Se&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:Se.origin===`terminal`?C(`Started in the terminal`):C(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(J.branches>1||J.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":Te,onClick:()=>Ee(e=>!e),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),C(`Branches ({count})`,{count:J.branches})]}),J.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ut(null),children:C(`Show the latest`)}),rt&&(0,h.jsx)(`span`,{className:`ep-state running`,children:w(rs(rt))}),Se&&(!rt||we||pe&&!Ce&&!!X?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${Se.status}`,children:pe?Ce?C(`Discussing`):we?w(Se.status):X?.proposal?C(`Awaiting plan approval`):C(`Ready for conversation`):w(Se.status)})]})]}),ae.error&&!De&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(C,ae.error)}),De&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),ie&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Preparing execution for this Send…`)}),Te&&(0,h.jsx)(To,{client:e,id:t,leaf:J.leaf,onChoose:ut,onClose:()=>Ee(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Me,onScroll:()=>{let e=Me.current;e&&!y&&(Ne.current=e.scrollTop,Pe.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Ie(!Pe.current),Ke())},children:[J.summary===null&&(0,h.jsx)($o,{hint:C(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),u&&!J.error&&(!de||Y.length===0&&J.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:C(`Reading this conversation…`)}),Y.length>0&&We&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:J.loadingEarlier&&C(`Reading earlier messages…`)}),nt.start.map(at),Be.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(Ba,{id:e,show:!Ve.hidden.has(e),height:Ve.placeholder(e,t,320),containerRef:Me,onMeasured:Ve.recordMeasured,lazyRef:Ve.register(e),children:(0,h.jsx)(Qo,{turn:n,toggled:He.current.get(e)??null,onToggle:Ue})}),nt.after.get(e)?.map(at),n.header.entry&&n.ordinal<J.count-1&&!Ce&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:C(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>ut(n.header.entry),children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),C(`Continue from here`)]})]},e)),nt.end.map(at),J.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":C(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:J.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${J.attempt.status}`,children:w(J.attempt.status)}),` `,J.attempt.notice?w(J.attempt.notice):``]})]}),X?.enabled&&X.proposal&&(0,h.jsx)(cs,{proposal:X.proposal,canApprove:o&&xe&&he&&ke&&!Ce&&!_e,approvalHint:Ae,onApprove:()=>void ot()}),X?.enabled&&!X.proposal&&Ye.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`Cadence stays on for this conversation until you explicitly exit.`)}),et.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:C(`Workflow activity unavailable; retained work may still be running.`)}),X?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:w(X.notice)}),(N||J.error||fe.error)&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(C,N||J.error||fe.error||``)}),F&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[C(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:F}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:J.refresh,children:C(`Observe current state`)})]}),J.pinned&&!Ce&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),Fe&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":C(`Latest messages`),onClick:()=>{Me.current&&(Me.current.scrollTop=Me.current.scrollHeight),Pe.current=!0},children:(0,h.jsx)(oi,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onSubmit:e=>{e.preventDefault(),st()},children:[(0,h.jsx)(`textarea`,{ref:je,disabled:!a&&!(pe&&d)||!De&&(!de||!me||!!J.error)||j||!!F,"aria-label":C(`Message`),value:D,placeholder:C(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),st())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${pe||be.mode===`cadence`?` on`:``}`,"aria-label":C(`Cadence mode`),"aria-pressed":pe||be.mode===`cadence`,disabled:pe?!Oe:Ce||j,title:pe?C(`Cadence mode is on. Click to exit it.`):be.mode===`cadence`?C(`Your next message turns on Cadence mode. Click to cancel.`):C(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{pe?st(`exit cadence`):be.mode===`cadence`?(A(`chat`),Ei(D,`chat`).mode===`cadence`&&O(be.text)):A(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(Co,{client:le,onObserved:e=>{q.current=e.selected?eo(e.selected):e.remembered},enabled:p&&u&&se,locked:!!Ce,refresh:String(U),open:L,onOpenChange:e=>{R(e),e||B(!1)},onChanged:()=>{ae.refresh(),m()},onChosen:e=>{z&&te.current&&(te.current=to(te.current,e),B(!1),P(``),H(!0))},awaitingSend:z}),(0,h.jsx)(`span`,{className:`composer-hint`,children:pe?C(`Cadence stays on. Confirm one plan before implementation.`):be.mode===`cadence`?C(`Your next message turns on Cadence mode.`):``}),Ce?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:j||!d,onClick:()=>void lt(),children:[(0,h.jsx)(Ar,{}),C(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(pe&&ho(D)?Oe:xe)&&!De||!D.trim(),children:[(0,h.jsx)(ii,{}),C(`Send`)]})]})]})]})}function ms({client:e,enabled:t,location:n,onReference:r}){let{t:i}=T(),[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),d=Ti(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Ti(e,t&&s?{kind:`file`,path:s,...n?{location:n}:{}}:null),m=d.value?.kind===`files`?d.value:void 0,g=p.value?.kind===`file`?p.value:void 0;return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Parent folder`),disabled:m?.parent==null,onClick:()=>{m?.parent!=null&&o(m.parent)},children:(0,h.jsx)(ii,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:a,children:a||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(Pr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:d.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[m?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${s===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?o(e.path):c(e.path),children:[e.directory?(0,h.jsx)(Gr,{}):(0,h.jsx)(Kr,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),onClick:()=>r(e.path),children:(0,h.jsx)(Fr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void qi(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(Qr,{})})]},e.path)),m?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No visible files`)}),m?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Bounded listing; narrow the directory to see more.`)})]}),s&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:s,children:s}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Close preview`),onClick:()=>c(null),children:(0,h.jsx)(Or,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error}),g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:g.text}),g.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`File preview is limited; this is not the complete file.`)})]})]}),l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(`p`,{className:`files-policy`,children:i(`Readonly preview · references send paths, not file contents`)})]})}var hs=`未命名章节`;function gs(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 _s(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=gs(r||hs),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||hs}})}function vs(e){return e.length>=2}function ys(e){let t=0,n=0;return e.split(`
20
- `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function bs({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:ys(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,h.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})}function xs({text:e}){let{t}=T(),[n,r]=(0,f.useState)(`raw`),[i,a]=(0,f.useState)(!0),[o,s]=(0,f.useState)(1),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(null),p=(0,f.useRef)(1),m=(0,f.useRef)(null),g=e.split(`
21
- `);return(0,f.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(m.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=_s(t.map(e=>({level:Number(e.tagName[1]),label:e.textContent??``})));r.forEach((e,n)=>{t[n].id=`preview-${e.id}`}),l(r)},[e,n]),(0,h.jsxs)(`div`,{className:`fp-preview`,children:[(0,h.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,h.jsxs)(`label`,{children:[t(`View`),(0,h.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,h.jsx)(`option`,{value:`raw`,children:t(`Raw text / lines`)}),(0,h.jsx)(`option`,{value:`markdown`,children:t(`Safe Markdown`)}),(0,h.jsx)(`option`,{value:`diff`,children:t(`Observed diff`)})]})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),children:t(i?`Wrap: on`:`Wrap: off`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.min(2,e+.1)),children:t(`Zoom +`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.max(.8,e-.1)),children:t(`Zoom −`)}),(0,h.jsx)(ea,{text:u?g.slice(u.start-1,u.end).join(`
22
- `):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[vs(c)&&(0,h.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>m.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,h.jsx)(`div`,{className:`fp-markdown-zoom`,ref:m,children:(0,h.jsx)(oa,{text:e})})]}):n===`diff`?(0,h.jsx)(bs,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:ys(e).map(({text:e,number:n,key:r})=>(0,h.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,h.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(p.current=n),d({start:Math.min(p.current,n),end:Math.max(p.current,n)})},children:n}),(0,h.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,h.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Ss({client:e,seed:t}){let{t:n,tx:r}=T(),i=Wi(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(_a,{pager:i}),(0,h.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,h.jsx)(`div`,{className:`scm-files-list`,children:s&&!(`kind`in s)&&s.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,h.jsxs)(`article`,{className:`scm-file`,children:[(0,h.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(Hi(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,h.jsx)(ga,{client:e,cursor:a,render:e=>(0,h.jsx)(xs,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Cs=[`contents`,`checks`,`changes`,`reviews`];function ws(){let{t:e}=T();return(0,h.jsx)(`aside`,{className:`panel panel-right`,children:(0,h.jsx)(`p`,{className:`panel-empty`,children:e(`Select retained history to inspect`)})})}function Ts({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(`contents`);return(0,h.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,h.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:Cs.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(va,{client:e,seed:t}):(0,h.jsx)(Ss,{client:e,seed:{...t,reader:i}},i)})]})}var Es={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.`},Ds=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Os(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 ks({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(n??t),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),A=(0,f.useRef)(!0),j=(0,f.useRef)(void 0),ee=(0,f.useRef)(n??t),M=(0,f.useRef)(null),N=(0,f.useRef)(null),P=async t=>{j.current?.abort();let n=new AbortController;j.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&A.current){if(j.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return p(r.value),g(r.value.path),v(!1),b(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},F=(0,f.useRef)(P);(0,f.useEffect)(()=>(A.current=!0,F.current(ee.current).then(()=>{A.current&&w(!1)}),()=>{A.current=!1,j.current?.abort()}),[]),(0,f.useEffect)(()=>{_&&M.current?.select()},[_]),(0,f.useEffect)(()=>{N.current&&(N.current.scrollLeft=N.current.scrollWidth)});let I=e=>{E||P(e)},L=()=>{let e=m.trim();E||(Ds(e)?P(e):k({step:`read`,code:`relative`}))},R=(_||!d)&&m.trim()||d?.path||``,z=!E&&!x&&!!R,B=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!Ds(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await P(n))?.path;if(!A.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),A.current&&a()}catch(e){A.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(A.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):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},V=d?Os(d.path,r):void 0,H=y.trim().toLowerCase(),U=d?.entries.filter(e=>e.name.toLowerCase().includes(H))??[],W=O&&(O.step===`read`&&Es[O.code]?l(Es[O.code]):u(O.code));return(0,h.jsxs)(wa,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Selecting a folder does not start execution. Send prepares it when needed.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:l(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void B(e.path),children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[V&&!_?(0,h.jsxs)(`nav`,{ref:N,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&d?.path===r?`location`:void 0,disabled:E,onClick:()=>I(`~`),children:[(0,h.jsx)(Hr,{"aria-hidden":`true`}),V.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),V.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||V.inside)&&(0,h.jsx)(ti,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===d?.path?`location`:void 0,disabled:E,onClick:()=>I(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),L()},children:(0,h.jsx)(`input`,{ref:M,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:m,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{g(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),k(null))}})}),d&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":_,disabled:E,onClick:()=>{g(d.path),v(!_),k(null)},children:(0,h.jsx)(Jr,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Nr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:y,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>b(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),d?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>I(d.parent),children:[(0,h.jsx)(ii,{}),l(`Parent folder`)]}),U.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>I(e.path),children:[(0,h.jsx)(Gr,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&U.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(H?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),W&&(0,h.jsxs)(`p`,{role:`alert`,children:[W,O?.code===`registry-locked`&&(0,h.jsxs)(h.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,h.jsxs)(`footer`,{className:`cwd-footer`,children:[R&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:R})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!z,onClick:()=>void B(R),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function As(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}function js({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function Ms({title:e,children:t,className:n=``,count:r}){let[i,a]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${i?``:` collapsed`}`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,h.jsx)(ni,{"aria-hidden":`true`}):(0,h.jsx)(ti,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]})}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!i,children:t})]})}function Ns({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=As(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,h.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,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.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,h.jsx)(ti,{"aria-hidden":`true`}):(0,h.jsx)(ni,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.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,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(Xr,{"aria-hidden":`true`}):(0,h.jsx)(Lr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.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,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Ps({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=T(),a=e.page;return(0,h.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ns,{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,h.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,h.jsx)(_a,{pager:e,compact:!0})]})}function Fs({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,cancelCompatible:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,workflows:S,workflowLinks:C=[],workflowError:w=!1,selectedWorkflow:E,onWorkflow:D,onCancelWorkflow:O}){let{t:k,tx:A}=T(),j=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,ee=Wi(e,j),M=Wi(e,r&&j&&t?{...j,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),N=ee.page&&!(`kind`in ee.page)?ee.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],P=s?.status===`complete`?s.runs:[],F=N.filter(e=>!P.some(t=>t.taskId===e.owner.taskId)),I=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":k(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:k(`Task conversations`)}),(0,h.jsx)(Ps,{pager:M,scope:i,onScope:p,exclude:P.map(e=>e.runId)},r)]}),[L,R]=(0,f.useState)(()=>new Set),z=e=>{let t=C.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${E===e.id||t&&t===y?` active`:``}`,onClick:()=>D?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[k(`Cadence workflow`),` · `,A(e.phase),` · `,A(e.status)]})]})]}),O&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:L.has(e.id),onClick:()=>{R(t=>new Set(t).add(e.id)),O(e).finally(()=>R(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ar,{"aria-hidden":`true`}),k(`Cancel workflow — request stop`)]})]},e.id)},B=m.filter(e=>e.status===`running`||e.status===`queued`),V=m.filter(e=>!B.includes(e)),H=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),U=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?H(e):void 0;return(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===y?` active`:``}`,onClick:()=>b?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Lr,{})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[e.origin===`terminal`?k(`Terminal`):`WebUI`,` ·`,` `,e.cadence?k(`Cadence on`):k(`Ordinary`),` ·`,` `,t?A(rs(t)):e.cadence&&[`running`,`queued`].includes(e.status)?k(`Discussing`):e.cadence&&e.status===`completed`?k(`Ready for conversation`):A(e.status)]})]})]},e.id)};return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(js,{onConversation:x}),!n&&(0,h.jsxs)(Ms,{title:k(`Running conversations`),count:s?.status===`complete`&&S&&!w&&g?String(P.length+B.length+S.length):`?`,className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Active roster unavailable; absence is not proof of settlement.`)}),w&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Conversation activity unavailable.`)}),B.map(U),S?.map(z),s?.status===`complete`&&P.length===0&&B.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No active runs`)}),P.map(e=>{let t=N.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??k(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[A(e.kind),` · `,A(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Ar,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Ns,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(Ms,{title:k(`Conversation history`),count:t?ee.page&&!(`kind`in ee.page)?`${V.length+F.length}${ee.page.next||ee.canPrevious||_?`+`:``}`:`?`:`${V.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[V.map(U),F.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Lr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:k(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&I]},e.owner.taskId)),ee.page&&!(`kind`in ee.page)&&F.length===0&&V.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(_a,{pager:ee,compact:!0})]}),!F.some(e=>e.owner.taskId===r)&&I]})]})}var Is=[`queued`,`running`];function Ls({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Ti(e,{kind:`workflow`,id:t.runId},s),u=l.value?.kind===`workflow`&&l.value.response.type===`run`?l.value.response.run:null,d=t.stepId?u?.steps.find(e=>e.id===t.stepId):void 0,p=d?Is.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Is.includes(u.status)&&c(0)},[u]);let m=Ti(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!u?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,f.useMemo)(()=>g?Vo(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Ti(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(us,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,h.jsx)(Qo,{turn:_}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,h.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,h.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,h.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,h.jsx)(oa,{text:d.text}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,h.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>y(!0),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,h.jsx)(`p`,{role:`alert`,children:b.error})]})]})]})}function Rs({path:e,disabled:t=!1,onClick:n}){let{t:r}=T();return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Open working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(ni,{"aria-hidden":`true`})]})}function zs(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=xa();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:H(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,W(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Bs(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=H(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(re(r)):void 0,o=i?W(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(re(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function Vs(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Hs({side:e,width:t,onResize:n}){let{t:r}=T(),i=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>i.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":r(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:r=>{r.preventDefault(),i.current?.();let a=r.clientX,o=window.innerWidth,s=r=>{let i=Vs({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),i.current=void 0};i.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function Us(e,t,n,r){(0,f.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 Ws=.4,Gs=1.05;function Ks(e){return Math.min(300,e*.86)}function qs(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Js(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Ys(e,t){return e===`left`?t:-t}function Xs(e,t){return Math.max(-e,Math.min(0,-e+t))}function Zs(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Qs(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Zs(r*Gs,n,t)>=Ws}var $s=new Set([`auto`,`scroll`,`overlay`]);function ec(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&$s.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function tc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function nc(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.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=qs(r.clientX,window.innerWidth,n);i&&!ec(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=Js(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Ks(window.innerWidth),h=m*Gs;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=Ys(r,d);let b=Xs(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Zs(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Qs({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(tc(),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])}function rc(e,t,n,r,i=`en`){let a=(e,t)=>v(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,o=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:o,group:`${r??`owner`}:${o}`,groupLabel:`${r??a(`Owner`)} · ${v(i,o)}`,kind:o===`tools`?`tool`:o===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:r??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}}),c;return{lang:i,onData(e){return c=e,()=>{c=void 0}},readState(){c?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:s.length}],activeId:e})},readSegments(t){t===e&&c?.({kind:`segs`,convId:t,segs:s,reset:!0})},readSegment(t,n){let r=s.findIndex(e=>e.key===n);t!==e||r<0||c?.({kind:`seg_detail`,convId:t,key:n,seg:s[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 ic=`modulepreload`,ac=function(e){return`/`+e},oc={},sc=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=ac(t,n),t=s(t),t in oc)return;oc[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`:ic,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 cc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=Wi(e,{...t,reader:`events`}),a=i.page;return(0,h.jsxs)(`section`,{className:`timeline-view`,children:[(0,h.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,h.jsx)(_a,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(lc,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function lc({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=T(),o=(0,f.useRef)(null),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(!1),d=(0,f.useRef)(r);return d.current=r,(0,f.useEffect)(()=>{let e=!1,r;return sc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,rc(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(va,{client:e,seed:t})]})}function uc(){let e=new URLSearchParams(window.location.hash?.slice(1)).get(`chat`);try{return e?nn(e):null}catch{return null}}var dc=[[`tools`,kr],[`context`,Vr],[`timeline`,$r],[`runs`,Wr]];function fc({error:e,observationError:t,onDemand:n=!1}){let{t:r,tx:i}=T();return!e&&!t?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[r(`{message}.`,{message:i(t)}),` `,t===`stale`?r(`Context changed. Observe again and request a fresh confirmation.`):n?r(`Connection unavailable. Existing work may continue; no message is replayed automatically.`):(0,h.jsx)(x,{text:r(`Explicit service guidance: {status} / {start}. No service is started by this page.`),slots:{status:(0,h.jsx)(`code`,{children:`cadence-service status`}),start:(0,h.jsx)(`code`,{children:`cadence-service start --workspace <path>`})}})]})]})}function pc({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareSend:l,directoryNamespaces:u}){let{t:d,tx:p,locale:m,setLocale:g}=T(),[_]=(0,f.useState)(()=>e??Ci()),[v,y]=(0,f.useState)(!1),[b]=(0,f.useState)(Bs),[S,C]=(0,f.useState)(b?.taskId??null),[w,E]=(0,f.useState)(()=>b?null:uc()??crypto.randomUUID()),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)([]),[j,ee]=(0,f.useState)(null),[M,N]=(0,f.useState)(b?`task`:`files`),[P,F]=(0,f.useState)(),[I,L]=(0,f.useState)(),[R,z]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=uc();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[B]=(0,f.useState)(()=>crypto.randomUUID()),V=(0,f.useCallback)(()=>F(void 0),[]),[H,U]=(0,f.useState)(b?b.scope??{kind:`task`,id:b.taskId}:null),W=Pi(s?.id,s?.epoch),te=!s||s.epoch!==null&&!W.error&&W.value?.status===`running`,ne=!!s&&!W.error&&(W.value?.status===`stopped`||W.value?.status===`not-started`),re=(0,f.useRef)(null);W.value?.status===`running`&&W.value.epoch&&(re.current=W.value.epoch);let ie=!s||s.epoch!==null&&!!W.value&&![`stopped`,`not-started`].includes(W.value.status),K=Li(_,S?{kind:`task`,id:S}:null,!v&&ie,re.current),ae=!!(s&&(W.value||W.error)),oe=!v&&!!(K.workspace||ae),se=(0,f.useRef)(null);(K.workspace||W.value?.workspaceId)&&(se.current=K.workspace?.workspaceId??W.value?.workspaceId??null);let ce=l?async(e,t)=>{let n=await l(e,t);if(e.aborted)throw Error(`stale`);W.prepared(n);let r=K.reconnect();await K.whenReady(n,e,r)}:void 0,q=Di(_.client,oe),le=Ti(_.client,K.workspace&&!v?{kind:`conversation-active`}:null,1e3),ue=le.value?.kind===`conversation-active`?le.value.entries:[],J=[...ue,...(q.value?.entries??[]).filter(e=>!ue.some(t=>t.id===e.id))],Y=Ti(_.client,K.workspace&&!v?{kind:`workflow-active`}:null,2e3),de=Y.value?.kind===`workflow-active`?Y.value:void 0,fe=(0,f.useMemo)(()=>[...new Set([...de?.runs.map(e=>e.id)??[],...k])],[de,k]),X=Ti(_.client,!s&&K.workspace&&!v?{kind:`projects`}:null),pe=R??s?.cwd??(X.value?.kind===`projects`?X.value.entries.find(e=>e.current)?.path:void 0),me=I?.id===w?I:void 0;(0,f.useEffect)(()=>{me&&uc()===me.id&&history.replaceState({...history.state,cadenceCwd:me.cwd,cadenceConversationId:me.id},``,location.href)},[me]);let he=w?me:pe?{id:B,cwd:pe}:void 0,ge=me?.cwd??pe??(X.value?.kind===`projects`?X.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,_e={state:K.observation,transportStatus:K.transportStatus,error:K.error,refresh:K.refresh},ve=_e.state?.snapshot.scope.kind===`task`&&_e.state.snapshot.scope.id===S?_e.state.snapshot.context:void 0,[ye,be]=(0,f.useState)(null),[xe,Se]=(0,f.useState)(!1),Ce=(0,f.useRef)(null),[we,Te]=(0,f.useState)(260),[Ee,De]=(0,f.useState)(360),Oe=(0,f.useCallback)(()=>be(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>Se(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),nc({enabled:xe&&!v,open:ye,onOpenChange:be,container:Ce}),Us(Ce,ye,xe&&!v,Oe);let[ke,Ae]=(0,f.useState)(b?.snapshotSeq),[je,Me]=(0,f.useState)(``),[Ne,Pe]=(0,f.useState)(``),[Fe,Ie]=(0,f.useState)(!0),Le=(0,f.useRef)(null),Re=(0,f.useRef)(null),ze=()=>{Re.current&&(Re.current.open=!1)},[Be,Ve]=(0,f.useState)(`messages`),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(),[Je,Ye]=(0,f.useState)(b?.cursor),[Xe,Ze]=(0,f.useState)(``),[Qe,$e]=(0,f.useState)([]),[et,tt]=(0,f.useState)(new Set),Z=(0,f.useRef)(!0),nt=e=>{Z.current&&$e(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?wi(t,e):t)})},rt=(0,f.useRef)(new Ri),it=G({taskId:S,scope:H,selectedSnapshot:ke??null,detached:v,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});rt.current.select(it),(0,f.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1,rt.current.depart()}),[]);let at=e=>{let t=e??crypto.randomUUID();e||z(ge??pe),O(null),t!==w&&(A([]),F(void 0)),rt.current.depart(),E(t),C(null),U(null),Me(``),Pe(``),qe(void 0),Ye(void 0),Ae(void 0),Ve(`messages`),N(`files`),Oe(),history.replaceState({cadenceCwd:ge??pe,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{w&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${w}`)},[w]);let ot=(e,t)=>{O(null),A([]),E(null),N(`task`),Me(t??``),Pe(``),Ae(void 0),rt.current.depart(),C(e),U({kind:`task`,id:e}),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),history.replaceState(null,``,zs(e))};(0,f.useEffect)(()=>{let e=()=>{let e=Bs();if(e)O(null),A([]),E(null),N(`task`),rt.current.depart(),Ae(e.snapshotSeq),Me(``),Pe(``),C(e.taskId),U(e.scope??{kind:`task`,id:e.taskId}),qe(void 0),Ye(e.cursor),Ve(`messages`),Oe();else{let e=uc();if(e){let t=history.state?.cadenceCwd;typeof t==`string`&&z(t),F(void 0),O(null),A([]),E(e),C(null),U(null),N(`files`),rt.current.depart(),Oe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Oe]);let st=(e,t,n)=>{O(null),Ae(t),Pe(n??``),rt.current.depart(),U(e),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),S&&history.replaceState(null,``,zs(S,void 0,{scope:e,snapshotSeq:t}))},ct=ke??_e.state?.snapshot.committedSeq??K.workspace?.committedSeq,lt=K.workspace?.storeId,ut=H&&lt&&ct?{storeId:lt,scope:H,snapshotSeq:ct,reader:`messages`,after:null,limit:50}:null,dt=H&&lt&&ct?{storeId:lt,scope:H,snapshotSeq:ct,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ft=ve?_e.state?.snapshot.runs??[]:[],pt=rt.current.ticket(),mt=e=>{nt(e),e.receipt&&rt.current.current(pt)&&K.refresh()},ht=e=>{if(et.has(e)||!K.cancelCompatible||!K.activeRuns)return;let t=crypto.randomUUID(),n=K.activeRuns.epoch;tt(t=>new Set(t).add(e)),nt({commandId:t,error:d(`Stop requested; settlement is not yet confirmed.`)}),_.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{mt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:d(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>nt({commandId:t,error:d(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Z.current&&tt(t=>{let n=new Set(t);return n.delete(e),n})})};if(v)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:d(`Detached`)}),(0,h.jsx)(`p`,{children:d(`Accepted service work continues. No Cancel was requested.`)}),Qe.map(e=>(0,h.jsxs)(`p`,{children:[d(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>y(!1),children:d(`Reconnect as a viewer`)})]});let gt=K.activeRuns,_t=gt?.status===`complete`?gt.runs:[],vt=_e.state?.connection??(ne?`Ready to prepare on Send`:K.workspace?S?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${Fe?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":d(`Tasks`),onClick:()=>be(e=>e===`left`?null:`left`),children:(0,h.jsx)(Rr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":d(`Workbench projects`),title:d(`Workbench projects`),onClick:n,children:(0,h.jsx)(Gr,{})}),(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),H&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":d(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Be===`messages`&&!Je,onClick:()=>{Ye(void 0),qe(void 0),Ve(`messages`)},children:[(0,h.jsx)(Lr,{"aria-hidden":`true`}),d(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Le,onKeyDown:e=>{e.key===`Escape`&&Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Be===`messages`?d(`Details`):p(Be),(0,h.jsx)(ni,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[dc.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Be===e,onClick:()=>{Ye(void 0),qe(void 0),Ve(e),Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),p(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Export selected scope`),disabled:!ut,onClick:()=>{Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus()),Ge(!0)},children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),d(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Copy token-free link`),disabled:!S,onClick:()=>{S&&qi(zs(S,Je,H?{scope:H,snapshotSeq:ke}:void 0)).then(e=>Ze(e?``:d(`Link copy unavailable.`)))},children:[(0,h.jsx)(Br,{"aria-hidden":`true`}),d(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[(0,h.jsx)(Na,{disabled:!dt,onOpen:()=>Ue(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:m===`zh`?`en`:`zh-CN`,"aria-label":m===`zh`?`Switch to English`:`切换到中文`,"data-tip":m===`zh`?`Switch to English`:`切换到中文`,onClick:()=>g(m===`zh`?`en`:`zh`),children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:m===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Re,onKeyDown:e=>{e.key===`Escape`&&Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":d(`More`),title:d(`More`),children:(0,h.jsx)(Ir,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Observe current state`),onClick:()=>{ze(),K.refresh(),_e.refresh()},children:[(0,h.jsx)(Pr,{"aria-hidden":`true`}),d(`Refresh status`)]}),o&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{ze(),o()},children:[(0,h.jsx)(Mr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Cadence service`),(0,h.jsx)(`small`,{children:d(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Disconnect this page`),title:d(`Return — accepted work continues`),onClick:()=>{ze(),be(null),Ue(!1),Ge(!1),rt.current.depart(),y(!0)},children:[(0,h.jsx)(zr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Disconnect this page`),(0,h.jsx)(`small`,{children:d(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${K.compatible===!1?` warn`:``}`,title:Si?.buildId??d(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:d(`Shared compatibility: {state}.`,{state:K.compatible===void 0?d(`Execution compatibility not observed`):K.compatible?d(`compatible`):d(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:d(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Si?.buildId??d(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":d(`Files / history`),"aria-expanded":xe?ye===`right`:Fe,onClick:()=>xe?be(e=>e===`right`?null:`right`):Ie(e=>!e),children:[(0,h.jsx)(jr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:d(w?`Files`:`History`)})]})]}),!K.workspace&&_t.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":d(`Execution and cancellation`),children:_t.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[p(e.kind),` `,e.runId,` · `,p(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ot(e.taskId),children:d(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!K.cancelCompatible||et.has(e.runId),onClick:()=>ht(e.runId),children:[(0,h.jsx)(Ar,{"aria-hidden":`true`}),d(`Cancel run — request stop`)]})]},e.runId))}),a,ne&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`status`,children:d(`Execution will be prepared when you send. Browsing does not start it.`)}),(0,h.jsx)(fc,{onDemand:!!ce,error:Xe||W.error,observationError:te?K.error:void 0}),(0,h.jsxs)(`div`,{ref:Ce,className:`layout`,style:{"--left-w":`${we}px`,"--right-w":`${Ee}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":d(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${ye?` on`:``}`,onClick:Oe}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${ye===`left`?` open`:``}`,"aria-label":d(`Task navigation drawer`),tabIndex:-1,inert:xe&&ye!==`left`,children:[oe&&(0,h.jsx)(Fs,{client:_.client,workspace:K.workspace,executionStopped:ne,taskId:S,scope:H,runs:ft,snapshot:_e.state?.snapshot.committedSeq,activeRuns:K.activeRuns,cancelCompatible:!!K.cancelCompatible,canceling:et,onCancel:ht,chats:J,chatActivityKnown:le.value?.kind===`conversation-active`&&!le.error,chatHistoryPartial:q.loading||q.canPrevious||!!q.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[q.error&&(0,h.jsx)(`p`,{role:`alert`,children:q.error}),q.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:d(`Reading conversation history…`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.previous,children:d(`Newer conversations`)}),q.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.next,children:d(`Older conversations`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:q.first,children:d(`Latest conversations`)}),q.error&&(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:d(`Observe current state`)})]}),conversationId:w,onConversation:at,onNewConversation:()=>at(),workflows:de?.runs,workflowLinks:de?.links,workflowError:!!Y.error,selectedWorkflow:D?.runId,onWorkflow:(e,t)=>{t?at(t):(O({runId:e.id,stepId:null,label:e.goal}),Oe())},onCancelWorkflow:async e=>{let t=await ls(_.client,e);t&&Ze(t),Y.refresh()},onTask:ot,onScope:st}),K.workspace&&(0,h.jsx)(Za,{client:_.client,active:K.activeRuns,taskId:S,runs:ft,snapshot:ct,workflowRuns:fe,selected:D,onOpenWorkflow:e=>{O(e),Oe()},onOpen:(e,t,n,r)=>{ot(e),U({kind:`child`,id:t}),Pe(r),Ae(n),history.replaceState(null,``,zs(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Hs,{side:`left`,width:we,onResize:Te}),(0,h.jsxs)(`main`,{className:`main`,inert:xe&&ye!==null,children:[D&&(0,h.jsx)(Ls,{client:_.client,agent:D,backLabel:d(w?`Back to conversation`:S?`Back to task`:`Back`),onBack:()=>O(null),onOpenAgent:O},`${D.runId}:${D.stepId??``}`),w&&(!s||ae)&&(0,h.jsx)(ps,{client:_.client,id:w,initialCwd:pe,onLocation:L,hidden:!!D,onOpenAgent:O,onWorkflowRuns:A,workspaceId:s?`checkout:${s.path}`:se.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?W.value?.workspaceId??void 0:void 0,prepareForSend:ce,actionsReady:te&&!!K.workspace&&!!K.compatible&&!K.error,available:oe,canInterrupt:!!K.cancelCompatible,enabled:ce?oe:!!K.workspace&&!!K.compatible&&!K.error,modelEnabled:te&&!!K.compatible&&K.transportStatus===`current`&&!K.error,onModelChanged:()=>{rt.current.depart(),K.refresh(!0),W.refresh()},onChanged:()=>{q.refresh(),K.refresh()},reference:P,onReferenceUsed:V},`${s?.id??se.current??`connecting`}:${w}`),H&&!D&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[H.kind!==`task`&&S&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ot(S,je),children:d(`Back to task`)}),(0,h.jsx)(`h2`,{title:je||H.id,children:H.kind===`task`?je||d(`Task {id}`,{id:H.id.slice(0,8)}):Ne||d(`{kind} {id}`,{kind:p(H.kind),id:H.id.slice(0,8)})}),H.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:d(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[d(`Recorded conversation`),` ·`,` `,d(`snapshot {seq}`,{seq:ct??``})]}),(0,h.jsx)(`code`,{children:H.id}),(0,h.jsx)(`p`,{children:d(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!w||!!D,children:[!ut&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:d(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:d(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ut&&Je?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Ke&&(Ke.owner.entity.kind===`task`||Ke.owner.entity.kind===`message`||Ke.owner.entity.kind===`tool`)&&(0,h.jsx)(ya,{client:_.client,seed:{storeId:Je.storeId,scope:Je.scope,snapshotSeq:Je.snapshotSeq,kind:Ke.owner.entity.kind,id:Ke.owner.entity.id,version:Ke.owner.entity.version}},`${Ke.owner.entity.id}:${Ke.owner.entity.version}`),(0,h.jsx)(ga,{client:_.client,cursor:Je,highlight:Ke?.range},`${Je.recordId}:${Je.recordVersion}`)]}):ut&&(0,h.jsxs)(`div`,{className:Be===`messages`||Be===`tools`?`tab-body transcript-body`:`tab-body`,children:[Be===`messages`&&(0,h.jsx)(Ua,{client:_.client,seed:ut}),Be===`tools`&&(0,h.jsx)(mc,{client:_.client,seed:ut}),Be===`context`&&(0,h.jsx)(va,{client:_.client,seed:ut}),Be===`timeline`&&(0,h.jsx)(cc,{client:_.client,seed:ut,onSearch:()=>Ue(!0)}),Be===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:d(`Runs in the current snapshot`)}),ft.length>0?ft.map(e=>(0,h.jsx)(ka,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:ve&&_e.state?d(`No owner run projection in this snapshot.`):d(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:d(`Retained runs`)}),(0,h.jsx)(Ma,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}},onScope:st},S)]})]},`${H?.kind}:${H?.id}:${ke??`current`}`)]}),K.workspace&&Qe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Qe.map(e=>(0,h.jsx)(zi,{client:_.client,value:e,onChange:nt},e.commandId))})]}),(0,h.jsx)(Hs,{side:`right`,width:Ee,onResize:De}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${ye===`right`?` open`:``}`,"aria-label":d(`Files and history drawer`),tabIndex:-1,inert:xe&&ye!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":d(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":M===`files`,onClick:()=>N(`files`),children:[(0,h.jsx)(Gr,{}),d(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":M===`task`,disabled:!ut,onClick:()=>N(`task`),children:[(0,h.jsx)(Vr,{}),d(`History details`)]})]}),M===`files`?(0,h.jsx)(ms,{location:he,client:_.client,enabled:!!K.workspace&&!!he,onReference:e=>{w||at(B);let t=!w&&he?`${he.cwd.replace(/[\\/]+$/,``)}${he.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;F(t),Oe()}},he?.cwd??`owner`):ut?(0,h.jsx)(Ts,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}}},S):(0,h.jsx)(ws,{})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsxs)(`div`,{className:`statusbar-left`,children:[(0,h.jsxs)(`span`,{className:`status-item`,role:`status`,title:d(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${ne?``:_e.error||!K.workspace?`error`:_e.transportStatus===`current`?_e.state?_e.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),p(vt),!ne&&_e.transportStatus!==`current`&&d(` · transport {status}`,{status:p(_e.transportStatus)}),_e.error?` · ${p(_e.error)}`:``]}),gt?.status===`complete`?_t.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(_t.length===1?`{count} active run`:`{count} active runs`,{count:_t.length})}):!ne&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(K.workspace||s)&&(0,h.jsx)(Rs,{path:ge,onClick:()=>c?c(ge):ee(``)}),K.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),j!==null&&K.workspace&&(0,h.jsx)(ks,{onOpen:t,projects:i??(X.value?.kind===`projects`?X.value.entries:[]),client:_.client,current:ge??K.workspace.rootLabel,initial:j||void 0,home:r,epoch:K.workspace.epoch,onClose:()=>ee(null)}),He&&dt&&(0,h.jsx)(Oa,{client:_.client,seed:dt,onClose:()=>Ue(!1),onHit:e=>{qe(e),Ye(e.cursor),S&&history.replaceState(null,``,zs(S,e.cursor,H?{scope:H,snapshotSeq:ke}:void 0))}}),We&&dt&&(0,h.jsx)(Ta,{request:{storeId:dt.storeId,scope:dt.scope,snapshotSeq:dt.snapshotSeq,format:`ndjson`},onClose:()=>Ge(!1)})]})}function mc({client:e,seed:t}){let n=Wi(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(_a,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Ga,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var hc=`cadence-last-project`;function gc(){try{let e=localStorage.getItem(hc);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function _c(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(hc,e)}catch{}}function vc(e){let t=gc();return t?e.projects.find(e=>e.id===t):void 0}async function yc(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=mn(await Oi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function bc(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Oi(t);if(!t.ok)throw Error(ki(n));return yn(n)}async function xc(e,t,n,r){if(!Si)throw Error(`unsupported-context`);let i=await fetch(e,{method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Si})},body:JSON.stringify({...t,epoch:n.epoch})}),a=await Oi(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(ki(a));let o=pn(a.project);return{project:o,entry:{...n,projects:[...n.projects.filter(e=>e.id!==o.id),o]}}}async function Sc(e){let t=await bc();return xc(`/workbench/v1/select`,{path:e},t)}async function Cc(e,t,n){let r=await bc(t),i=r.projects.find(t=>t.id===e.id);if(!i||i.path!==e.path||i.cwd!==e.cwd)throw Error(`stale`);let a=await xc(`/workbench/v1/prepare-send`,{projectId:e.id,commandId:crypto.randomUUID(),...n?{location:n}:{}},r,t);if(!a.project.epoch||a.project.id!==e.id||a.project.path!==e.path||a.project.cwd!==e.cwd)throw Error(`stale`);return a}var wc=`cadence-recovery-dismissed`,Tc={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},Ec={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function Dc(){try{let e=JSON.parse(localStorage.getItem(wc)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Oc(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function kc({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Dc),[a,o]=(0,f.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(wc,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:Oc(e.path)}):e.scope===`workbench`?n(`Workbench`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Tc[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,h.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:u(e)}),` `,(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Ec[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Ac={restart:18e4,upgrade:12e5},jc=1e3,Mc={"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":`npm 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.`},Nc=e=>e instanceof Error?e.message:`unavailable`;function Pc(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(Mc[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 Fc(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Ic({epoch:e,csrf:t,onClose:n}){let{t:r}=T(),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(null),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(),[E,D]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return ji(e.signal).then(a,t=>{e.signal.aborted||s(Nc(t))}),()=>e.abort()},[E]),(0,f.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Ac[e.action])return w(`timeout`);try{let t=await ji(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof j||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,jc)};return r=setTimeout(i,jc),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Mi().then(l,()=>l(`failed`))},k=n=>{i&&(_(!0),s(``),Ni({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(Nc(e)),m(!1),D(e=>e+1)}).finally(()=>_(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&Fc(C),o=i?.unit;return(0,h.jsxs)(wa,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,h.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(x?`Cadence is starting again…`:`Stopping Cadence…`):r(x?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,h.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Ac[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Pc(r,C)]}),(0,h.jsx)(`p`,{children:r(C===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,h.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,h.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,h.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,h.jsx)(`footer`,{children:a?(0,h.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,h.jsxs)(wa,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let A=i&&c&&typeof c==`object`?kn(c.version,i.version)>0:!1;return(0,h.jsxs)(wa,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Pc(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`npm could not be reached.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking npm for the latest version…`)}):A?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):i.upgrade===`npm`?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.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 copy was not installed with npm install -g; upgrade it the way you installed it.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(Pr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Lc({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s}){let{t:c,locale:l,setLocale:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!0),y=(0,f.useRef)(null),b=(0,f.useCallback)(()=>p(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>g(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),nc({enabled:m,open:d,onOpenChange:p,container:y}),Us(y,d,m,b);let x=e=>{b(),i(e)},S=e=>{b(),a?a(e):i(e)},C=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${_?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":c(`Tasks`),onClick:()=>p(e=>e===`left`?null:`left`),children:(0,h.jsx)(Rr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":c(`Cadence service`),"data-tip":c(`Cadence service`),onClick:o,children:(0,h.jsx)(Mr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,onClick:()=>u(l===`zh`?`en`:`zh`),"aria-label":l===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":c(`Files`),"aria-expanded":m?d===`right`:_,onClick:()=>m?p(e=>e===`right`?null:`right`):v(e=>!e),children:[(0,h.jsx)(jr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:y,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":c(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${d?` on`:``}`,onClick:b}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${d===`left`?` open`:``}`,"aria-label":c(`Task navigation drawer`),tabIndex:-1,inert:m&&d!==`left`,children:(0,h.jsx)(`aside`,{className:`panel panel-left lp-panel`,children:(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:c(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?c(`Returning to your last project {name}…`,{name:C(n.path)}):n?.status===`unavailable`?c(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:C(n.path)}):t.length?c(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):c(`Choose a working folder to see its conversation history.`)}),t.map(t=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item project-item`,title:t,disabled:!e||!!r,"aria-busy":r===t,onClick:()=>S(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Gr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:C(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?c(`Selecting folder…`):t})]})]},t))]})]})})}),(0,h.jsx)(`main`,{className:`main`,inert:m&&d!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":c(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)($o,{hint:c(`Choose a working folder. Execution is prepared only when you send.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>x(),children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),c(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":c(`Message`),rows:3,placeholder:c(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:c(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),c(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${d===`right`?` open`:``}`,"aria-label":c(`Files`),tabIndex:-1,inert:m&&d!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),c(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:c(`Files appear here after you open a working folder.`)})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:(0,h.jsx)(`span`,{className:`status-item faint`,children:c(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(Rs,{disabled:!e,onClick:()=>x()})})]})]})}function Rc(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(xa),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(``),[m,g]=(0,f.useState)(0),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(null),x=(0,f.useRef)(new Map),S=(0,f.useRef)(!r),C=(0,f.useRef)(null),w=(0,f.useCallback)(()=>{C.current&&(C.current.abort(),C.current=null,b(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await Oi(t);t.status===400&&ki(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(ki(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{w(),b(null),i(xa())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[w]),(0,f.useEffect)(()=>{if(!t||!S.current)return;S.current=!1;let e=vc(t);if(!e)return;let n=new AbortController;C.current=n,b({status:`checking`,path:e.cwd}),yc(e.id,n.signal).then(t=>{n.signal.aborted||(C.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let E=(0,f.useCallback)(e=>{w(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&x.current.set(r,window.location.hash),history.pushState({cadenceCwd:e?.cwd},``,e?`/app?project=${e.id}${x.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,w,t]),D=(0,f.useCallback)(async e=>{let t=await Sc(e);n(t.entry),E(t.project)},[E]),O=async(e,i)=>{let a=t?.projects.find(e=>e.id===r);if(!a)throw Error(`unavailable`);let o=await Cc(a,e,i);if(e.aborted)throw Error(`stale`);return n(o.entry),o.project.epoch},k=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new j(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Oi(n);if(!n.ok){let e=ki(r);return{kind:`error`,error:ee(A.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:mr(r)}}catch{return{kind:`error`,error:ee(`unavailable`)}}}}),[]),M=(0,f.useMemo)(()=>r?Ci(r):void 0,[r]),N=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{N&&_c(N.id)},[N]),t===null)return(0,h.jsx)(pc,{});let P=t&&_&&(0,h.jsx)(Ic,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),F=()=>v(!0),I=t&&a!==null&&(0,h.jsx)(ks,{selectOnly:!0,client:k,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:D});return t&&N&&M?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(pc,{api:M,project:N,directoryNamespaces:t?.projects.filter(e=>e.path===N.path).map(e=>e.id).sort(),onPrepareSend:O,onChooseFolder:e=>o(e??N.cwd),onOpenProject:D,onWorkbenchHome:()=>E(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(kc,{notices:t.recoveries,project:N.path}),onOpenService:F},N.id),P,I]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Lc,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?F:void 0,onOpenFolder:e=>{w(),u(``),o(e??t?.home??``)},onOpenProject:t=>{s||(w(),u(``),c(t),D(t).catch(n=>u(e(`{path} could not be opened ({code}).`,{path:t,code:n instanceof Error?n.message:`unavailable`}))).finally(()=>c(null)))},children:[l&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:l}),t&&(0,h.jsx)(kc,{notices:t.recoveries}),d&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[d,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>g(e=>e+1),children:e(`Reload observation`)})]}),r&&!N&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),I,P]})}function zc(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var Bc=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(zc,{}):this.props.children}},Vc=document.getElementById(`root`);if(!Vc)throw Error(`Application root unavailable`);(0,p.createRoot)(Vc).render((0,h.jsx)(E,{children:(0,h.jsx)(Bc,{children:(0,h.jsx)(Rc,{})})}));export{sc as t};
17
+ `),inFence:i!==null}}function Ko(e,t,n=!1){let r=e.length;if(t>=r)return r;t<0&&(t=0);let i=r-t,a;a=n?i<=16?Math.max(2,Math.ceil(i/6)):Math.ceil(i/8):i<=32?1:i<=90?2:Math.ceil(i<=240?i/28:i/18);let o=Math.min(r,t+a);if(o<r){let t=e.charCodeAt(o-1);t>=55296&&t<=56319&&(o=Math.min(r,o+1))}return o}var qo=(0,f.memo)(function({text:e}){return(0,h.jsx)(da,{text:e})}),Jo=22,Yo=14,Xo=()=>typeof document<`u`&&document.hidden;function Zo(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||Xo()||e.length>1500?e.length:0),o=(0,f.useRef)(e);o.current=e;let s=(0,f.useRef)(i);s.current=i;let c=(0,f.useRef)(n);c.current=n;let l=(0,f.useRef)(r);return l.current=r,(0,f.useEffect)(()=>{if(typeof document>`u`)return;let e=()=>{document.hidden,s.current=o.current.length,a(o.current.length),(c.current||!t)&&l.current?.()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]),(0,f.useEffect)(()=>{if(!t){s.current!==e.length&&(s.current=e.length,a(e.length));return}if(Xo()){s.current!==e.length&&(s.current=e.length,a(e.length)),(n||s.current>=e.length)&&l.current?.();return}if(e.length<s.current){s.current=e.length,a(e.length);return}if(s.current>=e.length){l.current?.();return}let r=0,i=0,u=e=>{let t=c.current?Yo:Jo;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=Ko(n,s.current,c.current);d!==s.current&&(s.current=d,a(d)),d<n.length?r=requestAnimationFrame(u):l.current?.()};return r=requestAnimationFrame(u),()=>cancelAnimationFrame(r)},[e,t,n]),!t||i>=e.length?e:e.slice(0,i)}var Qo=600,$o=32;function es({text:e,inFence:t}){let n=!t&&e.length>=Qo,[r,i]=(0,f.useState)(e),a=(0,f.useRef)(0),o=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(!n)return;let t=Date.now()-a.current,r=()=>{a.current=Date.now(),i(e)};if(t>=$o)r();else return o.current=setTimeout(r,$o-t),()=>{o.current&&clearTimeout(o.current)}},[e,n]),t?(0,h.jsx)(`div`,{className:`codeblock`,children:(0,h.jsx)(`pre`,{children:(0,h.jsx)(`code`,{children:e})})}):(0,h.jsx)(da,{text:n?r:e})}var ts=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=Zo(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>Go(r),[r]),s=0,c=i.map(e=>{let t=`stream-offset:${s}`;return s+=e.length,{key:t,text:e}});return(0,h.jsxs)(`div`,{className:`md`,children:[c.map(({text:e,key:t})=>(0,h.jsx)(qo,{text:e},t)),a.length>0&&(0,h.jsx)(es,{text:a,inFence:o},i.length)]})});function ns(e){let t=e.items.map(e=>({...or(e,1),text:e.role===`tool`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,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 rs(e,t,n,r){let i=`${e.header.id}:${t}:${n.id}:${n.parts}`,[a,o]=(0,f.useState)({key:``}),{detail:s}=e,c=n.parts;return(0,f.useEffect)(()=>{if(!r||c===0)return;let e=new AbortController;return s(t,c,e.signal).then(e=>o({key:i,value:e}),t=>{e.signal.aborted||o({key:i,error:t instanceof Error?t.message:`unavailable`})}),()=>e.abort()},[s,t,c,r,i]),a.key===i?a:{}}function is(e){let t=e.map((e,t)=>({step:e,index:t})),n=t.filter(({step:e})=>e.role!==`user`),r=n.findLastIndex(({step:e})=>e.role===`tool`),i=({step:e})=>e.role===`tool`||e.text.trim()!==``;return{user:t.filter(({step:e})=>e.role===`user`),steps:n.slice(0,r+1).filter(i),answer:n.slice(r+1).filter(i)}}var as={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},os=e=>Object.hasOwn(as,e)?as[e]:`other`,ss={read:[`Read 1 file`,`Read {n} files`],list:[`Listed 1 directory`,`Listed {n} directories`],search:[`Searched once`,`Searched {n} times`],run:[`Ran 1 command`,`Ran {n} commands`],edit:[`Edited 1 file`,`Edited {n} files`],other:[`Used 1 tool`,`Used {n} tools`]},cs=new Set([`read`,`list`,`edit`]);function ls(e,t){return cs.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function us({turn:e,steps:t,live:n,answered:r,toggled:i=null,onToggle:a}){let{t:o}=T(),[s,c]=(0,f.useState)(i),l=s??(!n&&!r),u=t.map(({step:e})=>e).filter(e=>e.role===`tool`),d=u.filter(e=>e.error).length,{thinking:p,media:m,other:g}=e.header.omitted,_=[p&&o(`Thinking is not retained.`),m&&o(`Media is not retained.`),g&&o(`Other content is not retained.`)].filter(e=>e!==!1),v;if(n){let e=u.at(-1);v=e?`${o(`Working…`)} ${e.name||o(`Tool`)} ${e.target}`.trim():o(`Working…`)}else{let e=new Map;for(let t of u){let n=os(t.name);e.set(n,(e.get(n)??new Set).add(ls(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(ss[e][0]):o(ss[e][1],{n:t.size})).join(` · `)||(p?o(`Thought`):m?o(`Media not retained`):g?o(`Content not retained`):``)}let y=(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(`span`,{className:`chat-steps-live`,"aria-hidden":`true`}):(0,h.jsx)(si,{className:`chat-steps-chevron`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chat-steps-title`,children:v}),d>0&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:o(`{n} failed`,{n:d})})]});return t.length===0&&_.length===0?(0,h.jsx)(`div`,{className:`chat-steps`,role:`status`,children:(0,h.jsx)(`div`,{className:`chat-steps-head`,children:y})}):(0,h.jsxs)(`details`,{className:`chat-steps`,"aria-label":o(`Working steps`),open:l,onToggle:e=>{let t=e.currentTarget.open;t!==l&&(c(t),a?.(t))},children:[(0,h.jsx)(`summary`,{className:`chat-steps-head`,children:y}),t.length>0&&(0,h.jsx)(`ol`,{className:`chat-steps-list`,children:t.map(({step:t,index:n})=>(0,h.jsx)(`li`,{children:t.role===`tool`?(0,h.jsx)(fs,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(ds,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function ds({turn:e,index:t,step:n,render:r=e=>(0,h.jsx)(fa,{text:e})}){let{t:i}=T(),a=t<e.header.stable,o=rs(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(Bo,{images:n.images,turn:e}):null,r(o.value?.text??n.text),n.clipped&&a&&!o.value&&(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(i,o.error):i(`Reading the rest of this message…`)})]})}function fs({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=rs(e,t,n,i);return(0,h.jsxs)(`details`,{className:`chat-tool`,open:i,onToggle:e=>a(e.currentTarget.open),children:[(0,h.jsxs)(`summary`,{children:[(0,h.jsx)(`span`,{className:`chat-tool-name`,children:n.name||r(`Tool`)}),n.target&&(0,h.jsx)(`span`,{className:`chat-tool-target`,title:n.target,children:n.target}),n.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:r(`failed`)})]}),i&&n.parts>0&&(o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`pre`,{children:o.value.args}),o.value.text&&(0,h.jsx)(`pre`,{children:o.value.text})]}):(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):r(`Reading…`)}))]})}var ps=(0,f.memo)(function({turn:e,toggled:t,onToggle:n}){let{t:r,tx:i}=T(),{header:a}=e,{user:o,steps:s,answer:c}=is(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
18
+ `).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":r(`Conversation turn`),children:[o.map(({step:t,index:n})=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:r(`You`)}),(0,h.jsx)(ds,{turn:e,index:n,step:t})]},n)),(u||c.length>0)&&(0,h.jsxs)(`article`,{className:`chat-message assistant`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:`Cadence`}),u&&(0,h.jsx)(us,{turn:e,steps:s,live:l,answered:c.length>0,toggled:t,onToggle:e=>n?.(a.id,e)}),c.map(({step:t,index:n})=>(0,h.jsx)(ds,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(ts,{text:e}):void 0},n))]}),a.execution&&(0,h.jsxs)(`details`,{className:`inspector-note`,children:[(0,h.jsx)(`summary`,{children:r(`Context fixed at admission:`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:a.execution.cwd}),` ·`,` `,a.execution.model?`${a.execution.model.provider}/${a.execution.model.model} · ${a.execution.model.thinking}`:r(`No model`)]})]}),d.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:d.map(e=>i(e)).join(`
19
+ `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function ms({hint:e,children:t}){let{t:n}=T();return(0,h.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e}),t]})}var hs=[`queued`,`running`],gs=e=>hs.includes(e.status);function _s(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function vs(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function ys(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=>_s(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=_s(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 bs(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?_s(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 xs(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 Ss({client:e,run:t,onOpen:n,onChanged:r}){let{t:i,tx:a}=T(),o=(0,f.useId)(),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(``),d=(0,f.useRef)(!0);(0,f.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=gs(t),m=p?[a(vs(t)),t.steps.filter(e=>e.status===`running`).map(e=>$a(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,xs(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
20
+ `).find(e=>e.trim())??``,_=m.filter(Boolean).join(` · `);return(0,h.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,h.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,h.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:_,children:_})]}),p&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),ws(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):g&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:g,children:a(g)})]})}function Cs({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan banner-notice`,"aria-label":i(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:i(`Current implementation plan`)}),(0,h.jsx)(`p`,{children:i(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,h.jsxs)(`p`,{children:[i(`Declared write paths use the checkout root:`),` `,(0,h.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:e.display.baseCommit})]}),(0,h.jsx)(`p`,{children:i(`Approval covers only this plan: implementation, checks, bounded repairs and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(fa,{text:qn(e.plan)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function ws(e,t){let n=await e.workbenchCommand({kind:`workflow-cancel`,commandId:crypto.randomUUID(),epoch:t.epoch,runId:t.id});return n.kind===`error`?n.error.code:``}function Ts({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),c=ji(e,{kind:`workflow`,id:t},o),l=c.value?.kind===`workflow`&&c.value.response.type===`run`?c.value.response.run:null,[u,d]=(0,f.useState)(null),p=ji(e,u?{kind:`workflow-detail`,id:t,stepId:u}:null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(``),y=l&&[`queued`,`running`].includes(l.status),b=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,f.useEffect)(()=>{l&&![`queued`,`running`].includes(l.status)&&s(0)},[l]),(0,h.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`strong`,{children:l?.goal??i(`Observing workflow`)}),l&&(0,h.jsxs)(`span`,{className:`ep-state ${l.status}`,children:[a(l.phase),` · `,a(l.status)]})]}),(c.error||_)&&(0,h.jsxs)(`p`,{role:`alert`,children:[_||c.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),l?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:l.execution.cwd}),` ·`,` `,l.execution.model?`${l.execution.model.provider}/${l.execution.model.model} · ${l.execution.model.thinking}`:i(`No model`)]}),l?.notice&&(0,h.jsx)(`p`,{children:l.notice}),l&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:Zn(l)})]}),l?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:l.mergedCommit})]}),l&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),l?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,$a(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(fa,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:$a(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,h.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>d(e.id),children:i(`Read retained step result`)}),u===e.id&&p.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:p.value.text}),u===e.id&&p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error})]},e.id)),y&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:m,onClick:()=>{l&&(g(!0),ws(e,l).then(e=>{b.current&&(v(e),c.refresh(),n?.())}).finally(()=>{b.current&&g(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:c.refresh,children:i(`Observe current state`)})]})}var Es=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Ds(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function Os({client:e,id:t,workspaceId:n,initialCwd:r,onLocation:i,enabled:a,actionsReady:o=a,prepareForSend:s,legacyWorkspaceId:c,directoryNamespaces:l=[],available:u=a,canInterrupt:d=a,modelEnabled:p=a,onModelChanged:m,onChanged:g,reference:_,onReferenceUsed:v,hidden:y=!1,onOpenAgent:x,onWorkflowRuns:S}){let{t:C,tx:w}=T(),[E]=(0,f.useState)(()=>uo(n,t,c,...l)),[D,O]=(0,f.useState)(()=>Ds(E)),k=Lo(),ee=k.remove,A=(0,f.useRef)([]),j=(0,f.useRef)(null),[M,N]=(0,f.useState)(()=>Ds(`${E}:mode`)===`cadence`?`cadence`:`chat`),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(``),[R,z]=(0,f.useState)(()=>Ds(`${E}:pending`)),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!1),[ne,re]=(0,f.useState)(!1),[W,ie]=(0,f.useState)(0),ae=(0,f.useRef)(null),G=(0,f.useRef)(!1),oe=(0,f.useRef)(0),se=(0,f.useRef)(new AbortController),[ce,le]=(0,f.useState)(!1),K=ji(e,u&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),ue=K.value?.kind===`conversation-context`?K.value.context:void 0,de=!!ue&&!K.error,fe=ue?.cwd??r,pe=(0,f.useRef)(null),me=(0,f.useMemo)(()=>({models:n=>fe?e.models(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>fe?e.chooseModel(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,fe]),he=(0,f.useRef)(i);he.current=i,(0,f.useEffect)(()=>{de&&fe&&he.current?.({id:t,cwd:fe})},[de,t,fe]);let q=Co(e,t,u),{turns:ge}=q,_e=q.summary!==void 0,ve=ji(e,u?{kind:`cadence-conversation`,id:t}:null,1e3),J=ve.value?.kind===`cadence-conversation`?ve.value.state:void 0,Y=J?.enabled===!0,ye=!!J||!!ve.error,be=!!J&&!ve.error&&!J.notice,xe=(0,f.useRef)(J);xe.current=J;let[Se,Ce]=(0,f.useState)(``),we=(0,f.useRef)(``),X=Mi(D,Y?`cadence`:M),Te=a&&de&&_e&&!q.error&&ye&&!(Y&&(ve.error||J?.notice))&&!P&&!H&&!R,Ee=q.summary??void 0,De=Ee&&(Ee.status===`queued`||Ee.status===`running`),Oe=!!Ee&&Ee.status!==`completed`&&!De,[ke,Ae]=(0,f.useState)(!1),je=!!s&&a&&(!!q.error||!!K.error)&&q.error!==`retired-conversation`&&K.error!==`retired-conversation`&&!J?.notice&&!De&&!P&&!R&&!H,Me=(d||!!s)&&de&&_e&&be&&!q.error&&!P&&!R&&!De,Ne=!!J?.proposal&&!!Ee&&!De&&Ee.status!==`unknown`,Pe=J?.proposal&&Ee?.status===`unknown`?C(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,Fe=(0,f.useRef)(null),Ie=(0,f.useRef)(null),Le=(0,f.useRef)(0),Re=(0,f.useRef)(!0),[ze,Be]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!y&&Ie.current&&!Re.current&&(Ie.current.scrollTop=Le.current)},[y]);let Ve=(0,f.useRef)(!0),He=(0,f.useRef)(``),Ue=(0,f.useRef)(D);(0,f.useEffect)(()=>(Ve.current=!0,se.current.signal.aborted&&(se.current=new AbortController),()=>{Ve.current=!1,se.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${E}:mode`,M)}catch{}},[E,M]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(E,D)}catch{}},[D,E]),(0,f.useEffect)(()=>{try{R?sessionStorage.setItem(`${E}:pending`,R):sessionStorage.removeItem(`${E}:pending`)}catch{}},[E,R]),(0,f.useEffect)(()=>{_&&(O(e=>`${e}${e?`
21
+ `:``}@${_}`),v(),Fe.current?.focus())},[_,v]),(0,f.useEffect)(()=>{let e=Ee?`${Ee.leaf}:${Ee.status}`:``;e&&He.current!==e&&(He.current=e,g()),we.current&&J?.runs.includes(we.current)&&(we.current=``,Ce(``),L(``)),R&&(Ee?.live?.commandId===R||q.attempt?.commandId===R||ge.some(e=>e.header.id===R)||q.commands.includes(R))&&(z(``),ee(A.current),O(e=>e===Ue.current?``:e),g()),Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[Ee,ge,R,g,J,q,ee]);let We=(0,f.useMemo)(()=>ge.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})),[ge]),Ge=Ga(Ie,We),Ke=(0,f.useRef)(new Map),qe=(0,f.useCallback)((e,t)=>{Ke.current.set(e,t)},[]),{earlier:Je,loadEarlier:Ye}=q,Xe=()=>{let e=Ie.current;e&&!y&&Je&&e.scrollTop<1200&&Ye()};(0,f.useEffect)(Xe);let Ze=ge[0]?.ordinal,Qe=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Ie.current;if(!e)return;let t=Qe.current;!Es&&!Re.current&&t.ordinal!==void 0&&Ze!==void 0&&Ze<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Qe.current={ordinal:Ze,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${E}:approval`)}catch{}},[E]);let $e=(0,f.useMemo)(()=>[...new Set([...q.runs,...J?.runs??[]])],[q.runs,J?.runs]),et=JSON.stringify($e.slice(-4));(0,f.useEffect)(()=>{S?.(JSON.parse(et))},[et,S]);let[tt,Z]=(0,f.useState)({terminal:8,browser:8}),nt=(0,f.useMemo)(()=>[...new Set([...q.runs.slice(-tt.terminal),...(J?.runs??[]).slice(-tt.browser)])],[q.runs,J?.runs,tt]),rt=no(e,u?nt:[],1e3),it=ge.find(e=>e.header.at>0)?.header.at,at=!Je&&ge.length>0;(0,f.useEffect)(()=>{if(!u)return;let e=(e,t)=>bs(e,t,rt.runs,rt.unreadable,it,at),t=e(q.runs,tt.terminal),n=e(J?.runs??[],tt.browser);(t!==tt.terminal||n!==tt.browser)&&Z({terminal:t,browser:n})},[u,q.runs,J?.runs,tt,rt,it,at]);let ot=(0,f.useMemo)(()=>ys(ge,rt.runs.values(),Je),[ge,rt.runs,Je]),st=[...rt.runs.values()].filter(gs).at(-1),ct=[...rt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{ct&&Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[ct]);let lt=t=>(0,h.jsx)(Ss,{client:e,run:t,onOpen:()=>x?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{ve.refresh(),g()}},t.id),ut=async()=>{if(!J?.proposal){L(C(`No plan is awaiting approval.`));return}if(!o||!be||!Te||De||Se||!Ne)return;let t=J,n=oe.current;F(!0),L(``);try{let r=await To({client:e,state:t,current:()=>Ve.current&&oe.current===n&&xe.current?.revision===t.revision&&xe.current?.enabled===!0,submitting:e=>{we.current=e,Ce(e)}});if(!Ve.current||oe.current!==n)return;r.kind===`error`?(L(r.error.code),Ce(``)):O(e=>Do(e)?``:e)}catch(e){Ve.current&&oe.current===n&&L(e instanceof Error?e.message:`unavailable`)}finally{Ve.current&&oe.current===n&&(F(!1),ve.refresh(),q.refresh(),g())}},dt=async(n,r)=>{let i=r?.text??n??D,a=r?.images??(n?[]:k.files),c=r?r.command.kind===`cadence-exit`:Y&&Eo(i);if(!(c?Me:Te)&&!je||De||!i.trim()&&!a.length)return;if(c&&a.length){L(C(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Y&&Do(i)){o?await ut():L(C(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let l=Mi(i,M).mode===`cadence`;if(!je&&(Y||l)&&!be){L(C(`Cadence state unavailable. Observe the conversation before sending.`));return}if(G.current)return;G.current=!0,F(!0),L(``);let u=oe.current,d=()=>Ve.current&&oe.current===u,f=!1,p=!1,m=async e=>{s&&(p=!0,le(!0),await s(AbortSignal.any([se.current.signal,AbortSignal.timeout(io)]),e),d()&&(le(!1),ie(e=>e+1)))};try{if(je){if(await m(ue?{id:t,cwd:ue.cwd}:void 0),!d())return;q.refresh(),K.refresh(),ve.refresh(),g(),L(C(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let n=r??ao({id:t,head:q.leaf,text:i,images:a,revision:J?.revision??0,location:ue?{id:t,cwd:ue.cwd}:void 0,model:pe.current??ue?.model??void 0,intent:c?`exit`:Y?`message`:l?`enter`:`ordinary`});if(await m(n.location),!d())return;if(n.command.kind===`cadence-exit`){let t=n.command.commandId;Ue.current=i,z(t),f=!0;let r=await e.workbenchCommand(lo(n));if(!d())return;r.kind===`error`?(L(r.error.code),r.error.effect===`none`&&z(``)):(z(``),N(`chat`),O(e=>e===i?``:e)),ve.refresh(),q.refresh(),g();return}let o=()=>{ae.current=n,U(!0),V(!0)},s=await e.models(void 0,n.location);if(!d())return;let u=s.kind===`ok`?s.value.selected??s.value.remembered:null;!n.model&&u&&(n=so(n,u));let p=n.model??(s.kind===`ok`?s.value.remembered:null);if(s.kind===`ok`&&!s.value.selected&&p){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:s.value.version.epoch,...n.location?{location:n.location,expected:s.value.version,choice:p}:{}});if(!d())return;if(t.kind===`error`){L(t.error.code),o();return}if(s=await e.models(void 0,n.location),!d())return;ie(e=>e+1)}if(s.kind!==`ok`||!s.value.selected){o();return}co(n,s.value.selected);let h=lo(n,s.value.version);if(n.images.length){let t=s.value.selected;if(!s.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){L(C(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(h.kind===`cadence-exit`)throw Error(`invalid`);if(h=await ho(e,h,n.images,d),!d())return}A.current=n.images,Ue.current=i,z(h.commandId),f=!0;let _=await e.workbenchCommand(h);if(!d())return;_.kind===`error`?(L(`${_.error.code}. ${C(`Observe this send before sending again. No automatic retry.`)}`),_.error.effect===`none`&&z(``)):(ee(A.current),O(e=>e===Ue.current?``:e),z(``),h.kind===`cadence-send`&&N(`chat`),mt(null)),ve.refresh(),q.refresh(),g()}catch(e){d()&&L(f?C(`Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.`):C(p?`The message was not sent ({code}). Its draft is kept; preparation may have started an execution service.`:`The message was not sent ({code}). Its draft is kept.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{oe.current===u&&(G.current=!1),d()&&(F(!1),le(!1))}},ft=(0,f.useRef)(dt);ft.current=dt,(0,f.useEffect)(()=>{if(ne&&Te&&!De){re(!1);let e=ae.current;ae.current=null,e&&ft.current(void 0,e)}},[ne,Te,De]),(0,f.useEffect)(()=>{if(!ne)return;let e=setTimeout(()=>{re(!1),ae.current=null},1e4);return()=>clearTimeout(e)},[ne]);let pt=async()=>{let n=Ee?.live;if(!n||P)return;F(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Ve.current&&(r.kind===`error`&&L(r.error.code),F(!1),q.refresh())},mt=e=>{++oe.current,se.current.abort(),se.current=new AbortController,ae.current=null,G.current=!1,U(!1),re(!1),V(!1),F(!1),le(!1),q.choose(e),Ae(!1)},ht=P||H||!!R||!!De,gt=e=>{if(!ht)try{k.add(e),L(``)}catch(e){L(w(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:y,"aria-label":C(Y?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Hr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:Ee?.title??C(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:C(Y?`Cadence on`:`Ordinary`)}),Ee&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:Ee.origin===`terminal`?C(`Started in the terminal`):C(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(q.branches>1||q.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":ke,onClick:()=>Ae(e=>!e),children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),C(`Branches ({count})`,{count:q.branches})]}),q.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>mt(null),children:C(`Show the latest`)}),st&&(0,h.jsx)(`span`,{className:`ep-state running`,children:w(vs(st))}),Ee&&(!st||Oe||Y&&!De&&!!J?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${Ee.status}`,children:Y?De?C(`Discussing`):Oe?w(Ee.status):J?.proposal?C(`Awaiting plan approval`):C(`Ready for conversation`):w(Ee.status)})]})]}),K.error&&!je&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(C,K.error)}),je&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),ce&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Preparing execution for this Send…`)}),ke&&(0,h.jsx)(Io,{client:e,id:t,leaf:q.leaf,onChoose:mt,onClose:()=>Ae(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Ie,onScroll:()=>{let e=Ie.current;e&&!y&&(Le.current=e.scrollTop,Re.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Be(!Re.current),Xe())},children:[q.summary===null&&(0,h.jsx)(ms,{hint:C(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),u&&!q.error&&(!_e||ge.length===0&&q.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:C(`Reading this conversation…`)}),ge.length>0&&Je&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:q.loadingEarlier&&C(`Reading earlier messages…`)}),ot.start.map(lt),We.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(Ka,{id:e,show:!Ge.hidden.has(e),height:Ge.placeholder(e,t,320),containerRef:Ie,onMeasured:Ge.recordMeasured,lazyRef:Ge.register(e),children:(0,h.jsx)(ps,{turn:n,toggled:Ke.current.get(e)??null,onToggle:qe})}),ot.after.get(e)?.map(lt),n.header.entry&&n.ordinal<q.count-1&&!De&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:C(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>mt(n.header.entry),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),C(`Continue from here`)]})]},e)),ot.end.map(lt),q.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":C(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:q.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${q.attempt.status}`,children:w(q.attempt.status)}),` `,q.attempt.notice?w(q.attempt.notice):``]})]}),J?.enabled&&J.proposal&&(0,h.jsx)(Cs,{proposal:J.proposal,canApprove:o&&Te&&be&&Ne&&!De&&!Se,approvalHint:Pe,onApprove:()=>void ut()}),J?.enabled&&!J.proposal&&$e.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`Cadence stays on for this conversation until you explicitly exit.`)}),rt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:C(`Workflow activity unavailable; retained work may still be running.`)}),J?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:w(J.notice)}),(I||q.error||ve.error)&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(C,I||q.error||ve.error||``)}),R&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[C(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:R}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:C(`Observe current state`)})]}),q.pinned&&!De&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),ze&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":C(`Latest messages`),onClick:()=>{Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight),Re.current=!0},children:(0,h.jsx)(fi,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),gt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),dt()},children:[(0,h.jsx)(`input`,{ref:j,type:`file`,accept:jn.join(`,`),multiple:!0,hidden:!0,disabled:ht,"aria-label":C(`Add images`),onChange:e=>{gt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),k.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:k.files.map(e=>(0,h.jsx)(Ro,{file:e,disabled:ht,remove:()=>ee([e])},k.key(e)))}),(0,h.jsx)(`textarea`,{ref:Fe,disabled:!a&&!(Y&&d)||!je&&(!_e||!ye||!!q.error)||P||!!R,"aria-label":C(`Message`),value:D,placeholder:C(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>O(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),gt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),dt())}}),(0,h.jsx)(`p`,{className:`composer-image-help`,children:C(`PNG, JPEG or WebP · {count} images · {each} MiB each · {total} MiB total. Unsent images stay in this tab.`,{count:An.count,each:An.bytes/1024/1024,total:An.totalBytes/1024/1024})}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:ht,"aria-label":C(`Add images`),title:C(`Add images`),onClick:()=>j.current?.click(),children:(0,h.jsx)(qr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${Y||X.mode===`cadence`?` on`:``}`,"aria-label":C(`Cadence mode`),"aria-pressed":Y||X.mode===`cadence`,disabled:Y?!Me:De||P,title:Y?C(`Cadence mode is on. Click to exit it.`):X.mode===`cadence`?C(`Your next message turns on Cadence mode. Click to cancel.`):C(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{Y?dt(`exit cadence`):X.mode===`cadence`?(N(`chat`),Mi(D,`chat`).mode===`cadence`&&O(X.text)):N(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(Po,{client:me,onObserved:e=>{pe.current=e.selected?oo(e.selected):e.remembered},enabled:p&&u&&de,locked:!!De,refresh:String(W),open:B,onOpenChange:e=>{V(e),e||U(!1)},onChanged:()=>{K.refresh(),m()},onChosen:e=>{H&&ae.current&&(ae.current=so(ae.current,e),U(!1),L(``),re(!0))},awaitingSend:H}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Y?C(`Cadence stays on. Confirm one plan before implementation.`):X.mode===`cadence`?C(`Your next message turns on Cadence mode.`):``}),De?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:P||!d,onClick:()=>void pt(),children:[(0,h.jsx)(Fr,{}),C(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(Y&&Eo(D)?Me:Te)&&!je||!D.trim()&&!k.files.length,children:[(0,h.jsx)(ui,{}),C(`Send`)]})]})]})]})}function ks({client:e,enabled:t,location:n,onReference:r}){let{t:i}=T(),[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),d=ji(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=ji(e,t&&s?{kind:`file`,path:s,...n?{location:n}:{}}:null),m=d.value?.kind===`files`?d.value:void 0,g=p.value?.kind===`file`?p.value:void 0;return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Parent folder`),disabled:m?.parent==null,onClick:()=>{m?.parent!=null&&o(m.parent)},children:(0,h.jsx)(ui,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:a,children:a||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(zr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:d.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[m?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${s===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?o(e.path):c(e.path),children:[e.directory?(0,h.jsx)(Zr,{}):(0,h.jsx)(Qr,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),onClick:()=>r(e.path),children:(0,h.jsx)(Br,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void $i(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(ii,{})})]},e.path)),m?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No visible files`)}),m?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Bounded listing; narrow the directory to see more.`)})]}),s&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:s,children:s}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Close preview`),onClick:()=>c(null),children:(0,h.jsx)(Nr,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error}),g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:g.text}),g.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`File preview is limited; this is not the complete file.`)})]})]}),l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(`p`,{className:`files-policy`,children:i(`Readonly preview · references send paths, not file contents`)})]})}var As=`未命名章节`;function js(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 Ms(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=js(r||As),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||As}})}function Ns(e){return e.length>=2}function Ps(e){let t=0,n=0;return e.split(`
22
+ `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function Fs({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:Ps(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,h.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})}function Is({text:e}){let{t}=T(),[n,r]=(0,f.useState)(`raw`),[i,a]=(0,f.useState)(!0),[o,s]=(0,f.useState)(1),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(null),p=(0,f.useRef)(1),m=(0,f.useRef)(null),g=e.split(`
23
+ `);return(0,f.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(m.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=Ms(t.map(e=>({level:Number(e.tagName[1]),label:e.textContent??``})));r.forEach((e,n)=>{t[n].id=`preview-${e.id}`}),l(r)},[e,n]),(0,h.jsxs)(`div`,{className:`fp-preview`,children:[(0,h.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,h.jsxs)(`label`,{children:[t(`View`),(0,h.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,h.jsx)(`option`,{value:`raw`,children:t(`Raw text / lines`)}),(0,h.jsx)(`option`,{value:`markdown`,children:t(`Safe Markdown`)}),(0,h.jsx)(`option`,{value:`diff`,children:t(`Observed diff`)})]})]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),children:t(i?`Wrap: on`:`Wrap: off`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.min(2,e+.1)),children:t(`Zoom +`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.max(.8,e-.1)),children:t(`Zoom −`)}),(0,h.jsx)(oa,{text:u?g.slice(u.start-1,u.end).join(`
24
+ `):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ns(c)&&(0,h.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>m.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,h.jsx)(`div`,{className:`fp-markdown-zoom`,ref:m,children:(0,h.jsx)(fa,{text:e})})]}):n===`diff`?(0,h.jsx)(Fs,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Ps(e).map(({text:e,number:n,key:r})=>(0,h.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,h.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(p.current=n),d({start:Math.min(p.current,n),end:Math.max(p.current,n)})},children:n}),(0,h.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,h.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Ls({client:e,seed:t}){let{t:n,tx:r}=T(),i=Xi(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ca,{pager:i}),(0,h.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,h.jsx)(`div`,{className:`scm-files-list`,children:s&&!(`kind`in s)&&s.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,h.jsxs)(`article`,{className:`scm-file`,children:[(0,h.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(Ji(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,h.jsx)(Sa,{client:e,cursor:a,render:e=>(0,h.jsx)(Is,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Rs=[`contents`,`checks`,`changes`,`reviews`];function zs(){let{t:e}=T();return(0,h.jsx)(`aside`,{className:`panel panel-right`,children:(0,h.jsx)(`p`,{className:`panel-empty`,children:e(`Select retained history to inspect`)})})}function Bs({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(`contents`);return(0,h.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,h.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:Rs.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(wa,{client:e,seed:t}):(0,h.jsx)(Ls,{client:e,seed:{...t,reader:i}},i)})]})}var Vs={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.`},Hs=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Us(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 Ws({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(n??t),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),te=(0,f.useRef)(n??t),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return p(r.value),g(r.value.path),v(!1),b(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},P=(0,f.useRef)(N);(0,f.useEffect)(()=>(ee.current=!0,P.current(te.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{_&&j.current?.select()},[_]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let F=e=>{E||N(e)},I=()=>{let e=m.trim();E||(Hs(e)?N(e):k({step:`read`,code:`relative`}))},L=(_||!d)&&m.trim()||d?.path||``,R=!E&&!x&&!!L,z=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!Hs(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await N(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.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):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},B=d?Us(d.path,r):void 0,V=y.trim().toLowerCase(),H=d?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],U=O&&(O.step===`read`&&Vs[O.code]?l(Vs[O.code]):u(O.code));return(0,h.jsxs)(Aa,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Selecting a folder does not start execution. Send prepares it when needed.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:l(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void z(e.path),children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[B&&!_?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&d?.path===r?`location`:void 0,disabled:E,onClick:()=>F(`~`),children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),B.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),B.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||B.inside)&&(0,h.jsx)(si,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===d?.path?`location`:void 0,disabled:E,onClick:()=>F(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),I()},children:(0,h.jsx)(`input`,{ref:j,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:m,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{g(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),k(null))}})}),d&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":_,disabled:E,onClick:()=>{g(d.path),v(!_),k(null)},children:(0,h.jsx)(ei,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Rr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:y,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>b(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),d?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(d.parent),children:[(0,h.jsx)(ui,{}),l(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(e.path),children:[(0,h.jsx)(Zr,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&H.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(V?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),U&&(0,h.jsxs)(`p`,{role:`alert`,children:[U,O?.code===`registry-locked`&&(0,h.jsxs)(h.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,h.jsxs)(`footer`,{className:`cwd-footer`,children:[L&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:L})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!R,onClick:()=>void z(L),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function Gs(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}function Ks({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Br,{"aria-hidden":`true`}),n(`New conversation`)]})})}function qs({title:e,children:t,className:n=``,count:r}){let[i,a]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${i?``:` collapsed`}`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,h.jsx)(ci,{"aria-hidden":`true`}):(0,h.jsx)(si,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]})}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!i,children:t})]})}function Js({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=Gs(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,h.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,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.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,h.jsx)(si,{"aria-hidden":`true`}):(0,h.jsx)(ci,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.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,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(ni,{"aria-hidden":`true`}):(0,h.jsx)(Hr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.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,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Ys({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=T(),a=e.page;return(0,h.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Js,{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,h.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,h.jsx)(Ca,{pager:e,compact:!0})]})}function Xs({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,cancelCompatible:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,workflows:S,workflowLinks:C=[],workflowError:w=!1,selectedWorkflow:E,onWorkflow:D,onCancelWorkflow:O}){let{t:k,tx:ee}=T(),A=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,te=Xi(e,A),j=Xi(e,r&&A&&t?{...A,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),M=te.page&&!(`kind`in te.page)?te.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],N=s?.status===`complete`?s.runs:[],P=M.filter(e=>!N.some(t=>t.taskId===e.owner.taskId)),F=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":k(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:k(`Task conversations`)}),(0,h.jsx)(Ys,{pager:j,scope:i,onScope:p,exclude:N.map(e=>e.runId)},r)]}),[I,L]=(0,f.useState)(()=>new Set),R=e=>{let t=C.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${E===e.id||t&&t===y?` active`:``}`,onClick:()=>D?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[k(`Cadence workflow`),` · `,ee(e.phase),` · `,ee(e.status)]})]})]}),O&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:I.has(e.id),onClick:()=>{L(t=>new Set(t).add(e.id)),O(e).finally(()=>L(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),k(`Cancel workflow — request stop`)]})]},e.id)},z=m.filter(e=>e.status===`running`||e.status===`queued`),B=m.filter(e=>!z.includes(e)),V=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),H=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?V(e):void 0;return(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===y?` active`:``}`,onClick:()=>b?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Hr,{})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[e.origin===`terminal`?k(`Terminal`):`WebUI`,` ·`,` `,e.cadence?k(`Cadence on`):k(`Ordinary`),` ·`,` `,t?ee(vs(t)):e.cadence&&[`running`,`queued`].includes(e.status)?k(`Discussing`):e.cadence&&e.status===`completed`?k(`Ready for conversation`):ee(e.status)]})]})]},e.id)};return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(Ks,{onConversation:x}),!n&&(0,h.jsxs)(qs,{title:k(`Running conversations`),count:s?.status===`complete`&&S&&!w&&g?String(N.length+z.length+S.length):`?`,className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Active roster unavailable; absence is not proof of settlement.`)}),w&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Conversation activity unavailable.`)}),z.map(H),S?.map(R),s?.status===`complete`&&N.length===0&&z.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No active runs`)}),N.map(e=>{let t=M.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??k(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[ee(e.kind),` · `,ee(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Js,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(qs,{title:k(`Conversation history`),count:t?te.page&&!(`kind`in te.page)?`${B.length+P.length}${te.page.next||te.canPrevious||_?`+`:``}`:`?`:`${B.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[B.map(H),P.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Hr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:k(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&F]},e.owner.taskId)),te.page&&!(`kind`in te.page)&&P.length===0&&B.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(Ca,{pager:te,compact:!0})]}),!P.some(e=>e.owner.taskId===r)&&F]})]})}var Zs=[`queued`,`running`];function Qs({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=ji(e,{kind:`workflow`,id:t.runId},s),u=l.value?.kind===`workflow`&&l.value.response.type===`run`?l.value.response.run:null,d=t.stepId?u?.steps.find(e=>e.id===t.stepId):void 0,p=d?Zs.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Zs.includes(u.status)&&c(0)},[u]);let m=ji(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!u?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,f.useMemo)(()=>g?ns(g):null,[g]),[v,y]=(0,f.useState)(!1),b=ji(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(ni,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(Ts,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,h.jsx)(ps,{turn:_}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,h.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,h.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,h.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,h.jsx)(fa,{text:d.text}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,h.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>y(!0),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,h.jsx)(`p`,{role:`alert`,children:b.error})]})]})]})}function $s({path:e,disabled:t=!1,onClick:n}){let{t:r}=T();return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Open working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(ci,{"aria-hidden":`true`})]})}function ec(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Da();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function tc(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(ie(r)):void 0,o=i?U(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(ie(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function nc(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function rc({side:e,width:t,onResize:n}){let{t:r}=T(),i=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>i.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":r(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:r=>{r.preventDefault(),i.current?.();let a=r.clientX,o=window.innerWidth,s=r=>{let i=nc({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),i.current=void 0};i.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function ic(e,t,n,r){(0,f.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 ac=.4,oc=1.05;function sc(e){return Math.min(300,e*.86)}function cc(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function lc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function uc(e,t){return e===`left`?t:-t}function dc(e,t){return Math.max(-e,Math.min(0,-e+t))}function fc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function pc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:fc(r*oc,n,t)>=ac}var mc=new Set([`auto`,`scroll`,`overlay`]);function hc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&mc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function gc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function _c(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.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=cc(r.clientX,window.innerWidth,n);i&&!hc(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=lc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=sc(window.innerWidth),h=m*oc;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=uc(r,d);let b=dc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(fc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?pc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(gc(),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])}function vc(e,t,n,r,i=`en`){let a=(e,t)=>v(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,o=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:o,group:`${r??`owner`}:${o}`,groupLabel:`${r??a(`Owner`)} · ${v(i,o)}`,kind:o===`tools`?`tool`:o===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:r??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}}),c;return{lang:i,onData(e){return c=e,()=>{c=void 0}},readState(){c?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:s.length}],activeId:e})},readSegments(t){t===e&&c?.({kind:`segs`,convId:t,segs:s,reset:!0})},readSegment(t,n){let r=s.findIndex(e=>e.key===n);t!==e||r<0||c?.({kind:`seg_detail`,convId:t,key:n,seg:s[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 yc=`modulepreload`,bc=function(e){return`/`+e},xc={},Sc=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=bc(t,n),t=s(t),t in xc)return;xc[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`:yc,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 Cc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=Xi(e,{...t,reader:`events`}),a=i.page;return(0,h.jsxs)(`section`,{className:`timeline-view`,children:[(0,h.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,h.jsx)(Ca,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(wc,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function wc({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=T(),o=(0,f.useRef)(null),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(!1),d=(0,f.useRef)(r);return d.current=r,(0,f.useEffect)(()=>{let e=!1,r;return Sc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,vc(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(wa,{client:e,seed:t})]})}function Tc(){let e=new URLSearchParams(window.location.hash?.slice(1)).get(`chat`);try{return e?nn(e):null}catch{return null}}var Ec=[[`tools`,Pr],[`context`,Kr],[`timeline`,ai],[`runs`,Xr]];function Dc({error:e,observationError:t,onDemand:n=!1}){let{t:r,tx:i}=T();return!e&&!t?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[r(`{message}.`,{message:i(t)}),` `,t===`stale`?r(`Context changed. Observe again and request a fresh confirmation.`):n?r(`Connection unavailable. Existing work may continue; no message is replayed automatically.`):(0,h.jsx)(x,{text:r(`Explicit service guidance: {status} / {start}. No service is started by this page.`),slots:{status:(0,h.jsx)(`code`,{children:`cadence-service status`}),start:(0,h.jsx)(`code`,{children:`cadence-service start --workspace <path>`})}})]})]})}function Oc({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareSend:l,directoryNamespaces:u}){let{t:d,tx:p,locale:m,setLocale:g}=T(),[_]=(0,f.useState)(()=>e??ki()),[v,y]=(0,f.useState)(!1),[b]=(0,f.useState)(tc),[S,C]=(0,f.useState)(b?.taskId??null),[w,E]=(0,f.useState)(()=>b?null:Tc()??crypto.randomUUID()),[D,O]=(0,f.useState)(null),[k,ee]=(0,f.useState)([]),[A,te]=(0,f.useState)(null),[j,M]=(0,f.useState)(b?`task`:`files`),[N,P]=(0,f.useState)(),[F,I]=(0,f.useState)(),[L,R]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Tc();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[z]=(0,f.useState)(()=>crypto.randomUUID()),B=(0,f.useCallback)(()=>P(void 0),[]),[V,H]=(0,f.useState)(b?b.scope??{kind:`task`,id:b.taskId}:null),U=Bi(s?.id,s?.epoch),ne=!s||s.epoch!==null&&!U.error&&U.value?.status===`running`,re=!!s&&!U.error&&(U.value?.status===`stopped`||U.value?.status===`not-started`),ie=(0,f.useRef)(null);U.value?.status===`running`&&U.value.epoch&&(ie.current=U.value.epoch);let ae=!s||s.epoch!==null&&!!U.value&&![`stopped`,`not-started`].includes(U.value.status),G=Ui(_,S?{kind:`task`,id:S}:null,!v&&ae,ie.current),oe=!!(s&&(U.value||U.error)),se=!v&&!!(G.workspace||oe),ce=(0,f.useRef)(null);(G.workspace||U.value?.workspaceId)&&(ce.current=G.workspace?.workspaceId??U.value?.workspaceId??null);let le=l?async(e,t)=>{let n=await l(e,t);if(e.aborted)throw Error(`stale`);U.prepared(n);let r=G.reconnect();await G.whenReady(n,e,r)}:void 0,K=Ni(_.client,se),ue=ji(_.client,G.workspace&&!v?{kind:`conversation-active`}:null,1e3),de=ue.value?.kind===`conversation-active`?ue.value.entries:[],fe=[...de,...(K.value?.entries??[]).filter(e=>!de.some(t=>t.id===e.id))],pe=ji(_.client,G.workspace&&!v?{kind:`workflow-active`}:null,2e3),me=pe.value?.kind===`workflow-active`?pe.value:void 0,he=(0,f.useMemo)(()=>[...new Set([...me?.runs.map(e=>e.id)??[],...k])],[me,k]),q=ji(_.client,!s&&G.workspace&&!v?{kind:`projects`}:null),ge=L??s?.cwd??(q.value?.kind===`projects`?q.value.entries.find(e=>e.current)?.path:void 0),_e=F?.id===w?F:void 0;(0,f.useEffect)(()=>{_e&&Tc()===_e.id&&history.replaceState({...history.state,cadenceCwd:_e.cwd,cadenceConversationId:_e.id},``,location.href)},[_e]);let ve=w?_e:ge?{id:z,cwd:ge}:void 0,J=_e?.cwd??ge??(q.value?.kind===`projects`?q.value.entries.find(e=>e.current)?.path:void 0)??G.workspace?.rootLabel,Y={state:G.observation,transportStatus:G.transportStatus,error:G.error,refresh:G.refresh},ye=Y.state?.snapshot.scope.kind===`task`&&Y.state.snapshot.scope.id===S?Y.state.snapshot.context:void 0,[be,xe]=(0,f.useState)(null),[Se,Ce]=(0,f.useState)(!1),we=(0,f.useRef)(null),[X,Te]=(0,f.useState)(260),[Ee,De]=(0,f.useState)(360),Oe=(0,f.useCallback)(()=>xe(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>Ce(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),_c({enabled:Se&&!v,open:be,onOpenChange:xe,container:we}),ic(we,be,Se&&!v,Oe);let[ke,Ae]=(0,f.useState)(b?.snapshotSeq),[je,Me]=(0,f.useState)(``),[Ne,Pe]=(0,f.useState)(``),[Fe,Ie]=(0,f.useState)(!0),Le=(0,f.useRef)(null),Re=(0,f.useRef)(null),ze=()=>{Re.current&&(Re.current.open=!1)},[Be,Ve]=(0,f.useState)(`messages`),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(),[Je,Ye]=(0,f.useState)(b?.cursor),[Xe,Ze]=(0,f.useState)(``),[Qe,$e]=(0,f.useState)([]),[et,tt]=(0,f.useState)(new Set),Z=(0,f.useRef)(!0),nt=e=>{Z.current&&$e(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Ai(t,e):t)})},rt=(0,f.useRef)(new Wi),it=W({taskId:S,scope:V,selectedSnapshot:ke??null,detached:v,attachment:G.attachmentVersion,workspaceContext:G.workspace?.context??null,observationError:G.error??null});rt.current.select(it),(0,f.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1,rt.current.depart()}),[]);let at=e=>{let t=e??crypto.randomUUID();e||R(J??ge),O(null),t!==w&&(ee([]),P(void 0)),rt.current.depart(),E(t),C(null),H(null),Me(``),Pe(``),qe(void 0),Ye(void 0),Ae(void 0),Ve(`messages`),M(`files`),Oe(),history.replaceState({cadenceCwd:J??ge,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{w&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${w}`)},[w]);let ot=(e,t)=>{O(null),ee([]),E(null),M(`task`),Me(t??``),Pe(``),Ae(void 0),rt.current.depart(),C(e),H({kind:`task`,id:e}),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),history.replaceState(null,``,ec(e))};(0,f.useEffect)(()=>{let e=()=>{let e=tc();if(e)O(null),ee([]),E(null),M(`task`),rt.current.depart(),Ae(e.snapshotSeq),Me(``),Pe(``),C(e.taskId),H(e.scope??{kind:`task`,id:e.taskId}),qe(void 0),Ye(e.cursor),Ve(`messages`),Oe();else{let e=Tc();if(e){let t=history.state?.cadenceCwd;typeof t==`string`&&R(t),P(void 0),O(null),ee([]),E(e),C(null),H(null),M(`files`),rt.current.depart(),Oe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Oe]);let st=(e,t,n)=>{O(null),Ae(t),Pe(n??``),rt.current.depart(),H(e),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),S&&history.replaceState(null,``,ec(S,void 0,{scope:e,snapshotSeq:t}))},ct=ke??Y.state?.snapshot.committedSeq??G.workspace?.committedSeq,lt=G.workspace?.storeId,ut=V&&lt&&ct?{storeId:lt,scope:V,snapshotSeq:ct,reader:`messages`,after:null,limit:50}:null,dt=V&&lt&&ct?{storeId:lt,scope:V,snapshotSeq:ct,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ft=ye?Y.state?.snapshot.runs??[]:[],pt=rt.current.ticket(),mt=e=>{nt(e),e.receipt&&rt.current.current(pt)&&G.refresh()},ht=e=>{if(et.has(e)||!G.cancelCompatible||!G.activeRuns)return;let t=crypto.randomUUID(),n=G.activeRuns.epoch;tt(t=>new Set(t).add(e)),nt({commandId:t,error:d(`Stop requested; settlement is not yet confirmed.`)}),_.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{mt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:d(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>nt({commandId:t,error:d(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Z.current&&tt(t=>{let n=new Set(t);return n.delete(e),n})})};if(v)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:d(`Detached`)}),(0,h.jsx)(`p`,{children:d(`Accepted service work continues. No Cancel was requested.`)}),Qe.map(e=>(0,h.jsxs)(`p`,{children:[d(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>y(!1),children:d(`Reconnect as a viewer`)})]});let gt=G.activeRuns,_t=gt?.status===`complete`?gt.runs:[],vt=Y.state?.connection??(re?`Ready to prepare on Send`:G.workspace?S?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${Fe?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":d(`Tasks`),onClick:()=>xe(e=>e===`left`?null:`left`),children:(0,h.jsx)(Ur,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":d(`Workbench projects`),title:d(`Workbench projects`),onClick:n,children:(0,h.jsx)(Zr,{})}),(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),V&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":d(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Be===`messages`&&!Je,onClick:()=>{Ye(void 0),qe(void 0),Ve(`messages`)},children:[(0,h.jsx)(Hr,{"aria-hidden":`true`}),d(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Le,onKeyDown:e=>{e.key===`Escape`&&Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Be===`messages`?d(`Details`):p(Be),(0,h.jsx)(ci,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Ec.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Be===e,onClick:()=>{Ye(void 0),qe(void 0),Ve(e),Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),p(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Export selected scope`),disabled:!ut,onClick:()=>{Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus()),Ge(!0)},children:[(0,h.jsx)(ti,{"aria-hidden":`true`}),d(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Copy token-free link`),disabled:!S,onClick:()=>{S&&$i(ec(S,Je,V?{scope:V,snapshotSeq:ke}:void 0)).then(e=>Ze(e?``:d(`Link copy unavailable.`)))},children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),d(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[(0,h.jsx)(za,{disabled:!dt,onOpen:()=>Ue(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:m===`zh`?`en`:`zh-CN`,"aria-label":m===`zh`?`Switch to English`:`切换到中文`,"data-tip":m===`zh`?`Switch to English`:`切换到中文`,onClick:()=>g(m===`zh`?`en`:`zh`),children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:m===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Re,onKeyDown:e=>{e.key===`Escape`&&Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":d(`More`),title:d(`More`),children:(0,h.jsx)(Vr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Observe current state`),onClick:()=>{ze(),G.refresh(),Y.refresh()},children:[(0,h.jsx)(zr,{"aria-hidden":`true`}),d(`Refresh status`)]}),o&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{ze(),o()},children:[(0,h.jsx)(Lr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Cadence service`),(0,h.jsx)(`small`,{children:d(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Disconnect this page`),title:d(`Return — accepted work continues`),onClick:()=>{ze(),xe(null),Ue(!1),Ge(!1),rt.current.depart(),y(!0)},children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Disconnect this page`),(0,h.jsx)(`small`,{children:d(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${G.compatible===!1?` warn`:``}`,title:Oi?.buildId??d(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:d(`Shared compatibility: {state}.`,{state:G.compatible===void 0?d(`Execution compatibility not observed`):G.compatible?d(`compatible`):d(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:d(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Oi?.buildId??d(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":d(`Files / history`),"aria-expanded":Se?be===`right`:Fe,onClick:()=>Se?xe(e=>e===`right`?null:`right`):Ie(e=>!e),children:[(0,h.jsx)(Ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:d(w?`Files`:`History`)})]})]}),!G.workspace&&_t.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":d(`Execution and cancellation`),children:_t.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[p(e.kind),` `,e.runId,` · `,p(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ot(e.taskId),children:d(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!G.cancelCompatible||et.has(e.runId),onClick:()=>ht(e.runId),children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),d(`Cancel run — request stop`)]})]},e.runId))}),a,re&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`status`,children:d(`Execution will be prepared when you send. Browsing does not start it.`)}),(0,h.jsx)(Dc,{onDemand:!!le,error:Xe||U.error,observationError:ne?G.error:void 0}),(0,h.jsxs)(`div`,{ref:we,className:`layout`,style:{"--left-w":`${X}px`,"--right-w":`${Ee}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":d(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${be?` on`:``}`,onClick:Oe}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${be===`left`?` open`:``}`,"aria-label":d(`Task navigation drawer`),tabIndex:-1,inert:Se&&be!==`left`,children:[se&&(0,h.jsx)(Xs,{client:_.client,workspace:G.workspace,executionStopped:re,taskId:S,scope:V,runs:ft,snapshot:Y.state?.snapshot.committedSeq,activeRuns:G.activeRuns,cancelCompatible:!!G.cancelCompatible,canceling:et,onCancel:ht,chats:fe,chatActivityKnown:ue.value?.kind===`conversation-active`&&!ue.error,chatHistoryPartial:K.loading||K.canPrevious||!!K.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[K.error&&(0,h.jsx)(`p`,{role:`alert`,children:K.error}),K.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:d(`Reading conversation history…`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.previous,children:d(`Newer conversations`)}),K.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.next,children:d(`Older conversations`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:K.first,children:d(`Latest conversations`)}),K.error&&(0,h.jsx)(`button`,{type:`button`,onClick:K.refresh,children:d(`Observe current state`)})]}),conversationId:w,onConversation:at,onNewConversation:()=>at(),workflows:me?.runs,workflowLinks:me?.links,workflowError:!!pe.error,selectedWorkflow:D?.runId,onWorkflow:(e,t)=>{t?at(t):(O({runId:e.id,stepId:null,label:e.goal}),Oe())},onCancelWorkflow:async e=>{let t=await ws(_.client,e);t&&Ze(t),pe.refresh()},onTask:ot,onScope:st}),G.workspace&&(0,h.jsx)(ro,{client:_.client,active:G.activeRuns,taskId:S,runs:ft,snapshot:ct,workflowRuns:he,selected:D,onOpenWorkflow:e=>{O(e),Oe()},onOpen:(e,t,n,r)=>{ot(e),H({kind:`child`,id:t}),Pe(r),Ae(n),history.replaceState(null,``,ec(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(rc,{side:`left`,width:X,onResize:Te}),(0,h.jsxs)(`main`,{className:`main`,inert:Se&&be!==null,children:[D&&(0,h.jsx)(Qs,{client:_.client,agent:D,backLabel:d(w?`Back to conversation`:S?`Back to task`:`Back`),onBack:()=>O(null),onOpenAgent:O},`${D.runId}:${D.stepId??``}`),w&&(!s||oe)&&(0,h.jsx)(Os,{client:_.client,id:w,initialCwd:ge,onLocation:I,hidden:!!D,onOpenAgent:O,onWorkflowRuns:ee,workspaceId:s?`checkout:${s.path}`:ce.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?U.value?.workspaceId??void 0:void 0,prepareForSend:le,actionsReady:ne&&!!G.workspace&&!!G.compatible&&!G.error,available:se,canInterrupt:!!G.cancelCompatible,enabled:le?se:!!G.workspace&&!!G.compatible&&!G.error,modelEnabled:ne&&!!G.compatible&&G.transportStatus===`current`&&!G.error,onModelChanged:()=>{rt.current.depart(),G.refresh(!0),U.refresh()},onChanged:()=>{K.refresh(),G.refresh()},reference:N,onReferenceUsed:B},`${s?.id??ce.current??`connecting`}:${w}`),V&&!D&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[V.kind!==`task`&&S&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ot(S,je),children:d(`Back to task`)}),(0,h.jsx)(`h2`,{title:je||V.id,children:V.kind===`task`?je||d(`Task {id}`,{id:V.id.slice(0,8)}):Ne||d(`{kind} {id}`,{kind:p(V.kind),id:V.id.slice(0,8)})}),V.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:d(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[d(`Recorded conversation`),` ·`,` `,d(`snapshot {seq}`,{seq:ct??``})]}),(0,h.jsx)(`code`,{children:V.id}),(0,h.jsx)(`p`,{children:d(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!w||!!D,children:[!ut&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:d(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:d(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ut&&Je?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Ke&&(Ke.owner.entity.kind===`task`||Ke.owner.entity.kind===`message`||Ke.owner.entity.kind===`tool`)&&(0,h.jsx)(Ta,{client:_.client,seed:{storeId:Je.storeId,scope:Je.scope,snapshotSeq:Je.snapshotSeq,kind:Ke.owner.entity.kind,id:Ke.owner.entity.id,version:Ke.owner.entity.version}},`${Ke.owner.entity.id}:${Ke.owner.entity.version}`),(0,h.jsx)(Sa,{client:_.client,cursor:Je,highlight:Ke?.range},`${Je.recordId}:${Je.recordVersion}`)]}):ut&&(0,h.jsxs)(`div`,{className:Be===`messages`||Be===`tools`?`tab-body transcript-body`:`tab-body`,children:[Be===`messages`&&(0,h.jsx)(Ya,{client:_.client,seed:ut}),Be===`tools`&&(0,h.jsx)(kc,{client:_.client,seed:ut}),Be===`context`&&(0,h.jsx)(wa,{client:_.client,seed:ut}),Be===`timeline`&&(0,h.jsx)(Cc,{client:_.client,seed:ut,onSearch:()=>Ue(!0)}),Be===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:d(`Runs in the current snapshot`)}),ft.length>0?ft.map(e=>(0,h.jsx)(Fa,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:ye&&Y.state?d(`No owner run projection in this snapshot.`):d(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:d(`Retained runs`)}),(0,h.jsx)(Ra,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}},onScope:st},S)]})]},`${V?.kind}:${V?.id}:${ke??`current`}`)]}),G.workspace&&Qe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Qe.map(e=>(0,h.jsx)(Gi,{client:_.client,value:e,onChange:nt},e.commandId))})]}),(0,h.jsx)(rc,{side:`right`,width:Ee,onResize:De}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${be===`right`?` open`:``}`,"aria-label":d(`Files and history drawer`),tabIndex:-1,inert:Se&&be!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":d(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`files`,onClick:()=>M(`files`),children:[(0,h.jsx)(Zr,{}),d(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`task`,disabled:!ut,onClick:()=>M(`task`),children:[(0,h.jsx)(Kr,{}),d(`History details`)]})]}),j===`files`?(0,h.jsx)(ks,{location:ve,client:_.client,enabled:!!G.workspace&&!!ve,onReference:e=>{w||at(z);let t=!w&&ve?`${ve.cwd.replace(/[\\/]+$/,``)}${ve.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;P(t),Oe()}},ve?.cwd??`owner`):ut?(0,h.jsx)(Bs,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}}},S):(0,h.jsx)(zs,{})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsxs)(`div`,{className:`statusbar-left`,children:[(0,h.jsxs)(`span`,{className:`status-item`,role:`status`,title:d(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${re?``:Y.error||!G.workspace?`error`:Y.transportStatus===`current`?Y.state?Y.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),p(vt),!re&&Y.transportStatus!==`current`&&d(` · transport {status}`,{status:p(Y.transportStatus)}),Y.error?` · ${p(Y.error)}`:``]}),gt?.status===`complete`?_t.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(_t.length===1?`{count} active run`:`{count} active runs`,{count:_t.length})}):!re&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(G.workspace||s)&&(0,h.jsx)($s,{path:J,onClick:()=>c?c(J):te(``)}),G.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),A!==null&&G.workspace&&(0,h.jsx)(Ws,{onOpen:t,projects:i??(q.value?.kind===`projects`?q.value.entries:[]),client:_.client,current:J??G.workspace.rootLabel,initial:A||void 0,home:r,epoch:G.workspace.epoch,onClose:()=>te(null)}),He&&dt&&(0,h.jsx)(Pa,{client:_.client,seed:dt,onClose:()=>Ue(!1),onHit:e=>{qe(e),Ye(e.cursor),S&&history.replaceState(null,``,ec(S,e.cursor,V?{scope:V,snapshotSeq:ke}:void 0))}}),We&&dt&&(0,h.jsx)(ja,{request:{storeId:dt.storeId,scope:dt.scope,snapshotSeq:dt.snapshotSeq,format:`ndjson`},onClose:()=>Ge(!1)})]})}function kc({client:e,seed:t}){let n=Xi(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ca,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Za,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Ac=`cadence-last-project`;function jc(){try{let e=localStorage.getItem(Ac);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Mc(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Ac,e)}catch{}}function Nc(e){let t=jc();return t?e.projects.find(e=>e.id===t):void 0}async function Pc(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=mn(await Pi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Fc(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Pi(t);if(!t.ok)throw Error(Fi(n));return yn(n)}async function Ic(e,t,n,r){if(!Oi)throw Error(`unsupported-context`);let i=await fetch(e,{method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Oi})},body:JSON.stringify({...t,epoch:n.epoch})}),a=await Pi(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(Fi(a));let o=pn(a.project);return{project:o,entry:{...n,projects:[...n.projects.filter(e=>e.id!==o.id),o]}}}async function Lc(e){let t=await Fc();return Ic(`/workbench/v1/select`,{path:e},t)}async function Rc(e,t,n){let r=await Fc(t),i=r.projects.find(t=>t.id===e.id);if(!i||i.path!==e.path||i.cwd!==e.cwd)throw Error(`stale`);let a=await Ic(`/workbench/v1/prepare-send`,{projectId:e.id,commandId:crypto.randomUUID(),...n?{location:n}:{}},r,t);if(!a.project.epoch||a.project.id!==e.id||a.project.path!==e.path||a.project.cwd!==e.cwd)throw Error(`stale`);return a}var zc=`cadence-recovery-dismissed`,Bc={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},Vc={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function Hc(){try{let e=JSON.parse(localStorage.getItem(zc)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Uc(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Wc({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Hc),[a,o]=(0,f.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(zc,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:Uc(e.path)}):e.scope===`workbench`?n(`Workbench`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Bc[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,h.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:u(e)}),` `,(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Vc[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Gc={restart:18e4,upgrade:12e5},Kc=1e3,qc={"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":`npm 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.`},Jc=e=>e instanceof Error?e.message:`unavailable`;function Yc(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(qc[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 Xc(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Zc({epoch:e,csrf:t,onClose:n}){let{t:r}=T(),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(null),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(),[E,D]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return Li(e.signal).then(a,t=>{e.signal.aborted||s(Jc(t))}),()=>e.abort()},[E]),(0,f.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Gc[e.action])return w(`timeout`);try{let t=await Li(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof A||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,Kc)};return r=setTimeout(i,Kc),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Ri().then(l,()=>l(`failed`))},k=n=>{i&&(_(!0),s(``),zi({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(Jc(e)),m(!1),D(e=>e+1)}).finally(()=>_(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&Xc(C),o=i?.unit;return(0,h.jsxs)(Aa,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,h.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(x?`Cadence is starting again…`:`Stopping Cadence…`):r(x?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,h.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Gc[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Yc(r,C)]}),(0,h.jsx)(`p`,{children:r(C===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,h.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,h.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,h.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,h.jsx)(`footer`,{children:a?(0,h.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,h.jsxs)(Aa,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let ee=i&&c&&typeof c==`object`?kn(c.version,i.version)>0:!1;return(0,h.jsxs)(Aa,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Yc(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`npm could not be reached.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking npm for the latest version…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):i.upgrade===`npm`?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.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 copy was not installed with npm install -g; upgrade it the way you installed it.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(zr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Qc({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s}){let{t:c,locale:l,setLocale:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!0),y=(0,f.useRef)(null),b=(0,f.useCallback)(()=>p(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>g(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),_c({enabled:m,open:d,onOpenChange:p,container:y}),ic(y,d,m,b);let x=e=>{b(),i(e)},S=e=>{b(),a?a(e):i(e)},C=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${_?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":c(`Tasks`),onClick:()=>p(e=>e===`left`?null:`left`),children:(0,h.jsx)(Ur,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":c(`Cadence service`),"data-tip":c(`Cadence service`),onClick:o,children:(0,h.jsx)(Lr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,onClick:()=>u(l===`zh`?`en`:`zh`),"aria-label":l===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":c(`Files`),"aria-expanded":m?d===`right`:_,onClick:()=>m?p(e=>e===`right`?null:`right`):v(e=>!e),children:[(0,h.jsx)(Ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:y,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":c(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${d?` on`:``}`,onClick:b}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${d===`left`?` open`:``}`,"aria-label":c(`Task navigation drawer`),tabIndex:-1,inert:m&&d!==`left`,children:(0,h.jsx)(`aside`,{className:`panel panel-left lp-panel`,children:(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:c(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?c(`Returning to your last project {name}…`,{name:C(n.path)}):n?.status===`unavailable`?c(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:C(n.path)}):t.length?c(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):c(`Choose a working folder to see its conversation history.`)}),t.map(t=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item project-item`,title:t,disabled:!e||!!r,"aria-busy":r===t,onClick:()=>S(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:C(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?c(`Selecting folder…`):t})]})]},t))]})]})})}),(0,h.jsx)(`main`,{className:`main`,inert:m&&d!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":c(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(ms,{hint:c(`Choose a working folder. Execution is prepared only when you send.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>x(),children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),c(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":c(`Message`),rows:3,placeholder:c(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:c(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),c(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${d===`right`?` open`:``}`,"aria-label":c(`Files`),tabIndex:-1,inert:m&&d!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),c(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:c(`Files appear here after you open a working folder.`)})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:(0,h.jsx)(`span`,{className:`status-item faint`,children:c(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)($s,{disabled:!e,onClick:()=>x()})})]})]})}function $c(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Da),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(``),[m,g]=(0,f.useState)(0),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(null),x=(0,f.useRef)(new Map),S=(0,f.useRef)(!r),C=(0,f.useRef)(null),w=(0,f.useCallback)(()=>{C.current&&(C.current.abort(),C.current=null,b(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await Pi(t);t.status===400&&Fi(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(Fi(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{w(),b(null),i(Da())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[w]),(0,f.useEffect)(()=>{if(!t||!S.current)return;S.current=!1;let e=Nc(t);if(!e)return;let n=new AbortController;C.current=n,b({status:`checking`,path:e.cwd}),Pc(e.id,n.signal).then(t=>{n.signal.aborted||(C.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let E=(0,f.useCallback)(e=>{w(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&x.current.set(r,window.location.hash),history.pushState({cadenceCwd:e?.cwd},``,e?`/app?project=${e.id}${x.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,w,t]),D=(0,f.useCallback)(async e=>{let t=await Lc(e);n(t.entry),E(t.project)},[E]),O=async(e,i)=>{let a=t?.projects.find(e=>e.id===r);if(!a)throw Error(`unavailable`);let o=await Rc(a,e,i);if(e.aborted)throw Error(`stale`);return n(o.entry),o.project.epoch},k=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new A(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Pi(n);if(!n.ok){let e=Fi(r);return{kind:`error`,error:te(ee.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:yr(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),j=(0,f.useMemo)(()=>r?ki(r):void 0,[r]),M=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{M&&Mc(M.id)},[M]),t===null)return(0,h.jsx)(Oc,{});let N=t&&_&&(0,h.jsx)(Zc,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),P=()=>v(!0),F=t&&a!==null&&(0,h.jsx)(Ws,{selectOnly:!0,client:k,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:D});return t&&M&&j?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Oc,{api:j,project:M,directoryNamespaces:t?.projects.filter(e=>e.path===M.path).map(e=>e.id).sort(),onPrepareSend:O,onChooseFolder:e=>o(e??M.cwd),onOpenProject:D,onWorkbenchHome:()=>E(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(Wc,{notices:t.recoveries,project:M.path}),onOpenService:P},M.id),N,F]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Qc,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?P:void 0,onOpenFolder:e=>{w(),u(``),o(e??t?.home??``)},onOpenProject:t=>{s||(w(),u(``),c(t),D(t).catch(n=>u(e(`{path} could not be opened ({code}).`,{path:t,code:n instanceof Error?n.message:`unavailable`}))).finally(()=>c(null)))},children:[l&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:l}),t&&(0,h.jsx)(Wc,{notices:t.recoveries}),d&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[d,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>g(e=>e+1),children:e(`Reload observation`)})]}),r&&!M&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),F,N]})}function el(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var tl=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(el,{}):this.props.children}},nl=document.getElementById(`root`);if(!nl)throw Error(`Application root unavailable`);(0,p.createRoot)(nl).render((0,h.jsx)(E,{children:(0,h.jsx)(tl,{children:(0,h.jsx)($c,{})})}));export{Sc as t};