@abelxiaoxing/cadence 2.0.43 → 2.0.44

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,25 +1,25 @@
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={"Recorded history could not be read.":`暂时无法读取历史证据。`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Files are unavailable until the execution state is ready.":`执行状态就绪后才能读取文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Owner work already listed below is not duplicated here.":`下方已经列出的 owner 工作不在此重复显示。`,"Active Pi work":`Pi 活动工作`,"{projects} projects · {sessions} sessions":`{projects} 个项目 · {sessions} 个会话`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Discovering active work…":`正在发现活动工作…`,"No active work observed. Idle terminals and owners are not listed.":`未观察到活动工作。空闲终端和 owner 不列入此处。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution 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.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Connecting…":`正在连接…`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution 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":`历史详情`,"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 this goal and boundary: adaptive implementation, checks, recovery, project knowledge 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.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,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:":`尚未观察到此次发送的结果:`,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.":`当前服务连接一个项目,打开项目不会启动执行。`,"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}。`,"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:`失败`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"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…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"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}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"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.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager 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.":`包管理器会在 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.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,"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:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function 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 ee=`cadence-graph/2`,D=`cadence-public-export/2`,O=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}),k=[`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 ne(e){let t=M(e,O.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function re(e,t){return ne(e),ne(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function U(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=O.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=O.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,k),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var oe=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],se=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],ce=[`not-launched`,`direct-child-closed`,`unconfirmed`],le=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],G=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ue(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,le),thinking:I(t.thinking,G)}}function de(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...ue(n)}}function fe(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function pe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function me(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,oe),bytes:P(t.bytes,0,O.detailBytes),sha256:H(t.sha256)}}function K(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,O.detailBytes)}}function he(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=ge(t.source),r;if(n===`current`)r={kind:n,assignmentId:U(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=me(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,K);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function ge(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 _e(e){W(e,O.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=me(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,ee),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,O.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:U(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,O.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,O.expectedOutputBytes,!0),role:fe(t.role),model:de(t.model),dependencies:B(t.dependencies,O.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!==pe(e.purpose))throw new A(`forbidden`);c(e)}return i}function q(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:de(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,q)}}function ye(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,O.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 be(e){switch(W(e),ge(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=_e(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:ge(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:ye(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 J(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:ve(t.expected),action:be(t.action)}}function xe(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:be(t.action)}}function Se(e){if(W(e),ge(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:be(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 Ce(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function we(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,ye);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:be(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,_e),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 Te(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:we(t.preview)}}function Y(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 Ee(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,O.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=me(t.result);L(i.field,`final-text`);let a=R(t.range,K);a&&a.end>i.bytes&&j();let o=M(t.text,O.predecessorBytes);if(n+=N(o),n>O.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,O.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:U(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:Y(t.coverage)}})}}function De(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,ce),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:Y(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 Oe(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function ke(e){let t=M(e,O.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function X(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:Oe(t.scope),query:R(t.query,e=>{let t=M(e,O.queryBytes);return t.length||j(),t}),snapshotSeq:ne(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,oe)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:ke(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=ge(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=me(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,O.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,O.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,O.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=ge(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,O.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,O.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,O.chunkBytes),i=P(n.offset,0,O.detailBytes);return i+N(r)>O.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,O.detailBytes),sha256:H(n.sha256),coverage:Y(n.coverage)}}case`capture-status`:return{kind:t,coverage:Y(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,ce),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=ne(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:me(t.content),committedSeq:n}}function Be(e){let t=ge(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,ne);return(n===`0`||n!==null&&t.status===`committed`&&re(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=ge(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:De(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,ne);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:Y(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,O.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:U(t.assignmentId),childRunId:n,native:R(t.native,De),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,se);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,O.dataFrames+O.controlFrames),r=P(t.last,n,O.dataFrames+O.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=ge(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,O.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:Y(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},O.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,O.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:ne(t.committedSeq),execution:R(t.execution,e=>I(e,se)),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=Se(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(ge(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),ge(e,`status`)){case`found`:return{status:`found`,receipt:et(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:ne(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,U),admission:pt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,se)),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:Y(t.coverage),result:R(t.result,me)};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,O.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:Oe(t.scope),committedSeq:ne(t.committedSeq),context:mt(t.context),runs:B(t.runs,O.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,O.pageBytes);let t=ge(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:Oe(n.scope),committedSeq:ne(n.committedSeq)};if(t===`update`){let e=ne(n.previousSeq);re(r.committedSeq,e)<=0&&j();let i=mt(n.context);_t(i,r.epoch,r.scope)||j();let a=B(n.runs,O.maxPageEntries,rt),o=B(n.removed,O.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},O.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=X(t.cursor),r=X(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:Y(t.coverage)}}function dt(e){W({kind:`ok`,value:e},O.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:X(t.cursor),content:me(t.content),range:R(t.range,K),text:M(t.text,O.detailPageBytes),next:R(t.next,X),coverage:Y(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},O.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=X(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,O.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=me(t.content),a=bt(t.owner);xt(a,n.scope)||j();let o=K(t.range),s=X(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,O.previewBytes),cursor:s}}),a=R(t.next,X);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:Y(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,O.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:U(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(ge(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},O.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:ne(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:mt(t.context),models:B(t.models,O.maxPageEntries,de)};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,O.controlBytes);let t=ge(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:Ee(n.handoff),observation:St(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=me(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:ye(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,me),u=Y(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=me(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,O.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=B(t.events,O.ownerQueueFrames,e=>{let t=ge(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,O.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:Y(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,ne),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:ke(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,O.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=ge(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=ne(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=ne(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,me);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,O.dataFrames)),s=R(i.finalText,me),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=me(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:Y(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},O.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:Y(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},O.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:Y(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},O.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:Y(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:ke(t.navigation)}:{},storeId:V(t.storeId),scope:Oe(t.scope),snapshotSeq:ne(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=_e(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},O.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:Y(t.coverage)}}function Rt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:Oe(t.scope),snapshotSeq:ne(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,O.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=ge(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,D),request:Rt(e.request),coverage:Y(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=me(e.content),a=R(e.range,K),o=M(e.text,O.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:Y(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,O.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Y(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:ne(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=ye(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:ke(t.navigation)}:{},storeId:V(t.storeId),scope:Oe(t.scope),snapshotSeq:ne(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},O.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},O.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:Y(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,fe);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},O.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:ne(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=Y(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},O.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:ne(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:Y(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,ue)}}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,de)}}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},O.pageBytes);let t=z(e,[`version`,`selected`]);return{version:sn(t.version),selected:R(t.selected,de)}}function ln(e){W(e);let t=z(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:ue(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,le)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,G),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},O.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=B(t.entries,O.maxPageEntries,un),r=R(t.remembered,ue),i=I(t.status,[`complete`,`capacity`]),a=P(t.withheld,0,O.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>O.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,de),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`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Dn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function On(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 kn(e){let t=z(e,[`kind`,`version`,`deprecated`]);return{kind:L(t.kind,`release`),version:wn(t.version),deprecated:F(t.deprecated)}}function An(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 jn=Object.freeze({chunkChars:262144,idleMs:6e5}),Mn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Nn(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Pn(e,t){if(!Mn.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
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={"Models load when you send":`发送时加载模型`,"Preparing execution…":`正在准备执行环境…`,"Model selection needs a compatible connection":`连接兼容后才能选择模型`,"Checking execution state…":`正在确认执行状态…`,"Execution state unavailable":`执行状态暂时无法确认`,"Model list unavailable":`模型目录读取失败`,"Last used: {model}":`上次使用:{model}`,"Last used model; availability is checked when you send.":`上次使用的模型,发送时会验证其可用性。`,"Execution is not running. Send prepares it and loads models; opening this panel does not start anything.":`项目执行服务尚未启动。发送消息时会准备执行环境并加载模型;打开此面板不会启动服务。`,"Execution is being prepared for your Send. Models will load when it is ready.":`正在为本次发送准备执行环境,就绪后会加载模型。`,"Reload the page to observe a compatible execution connection before choosing a model.":`请重新加载页面,确认执行连接兼容后再选择模型。`,"The model list changed. Read the current list before choosing again.":`模型列表已变化,请读取当前列表后再选择。`,"The choice was not confirmed. Read the current model before choosing again.":`模型选择结果尚未确认,请读取当前模型后再决定是否重新选择。`,"Recorded history could not be read.":`暂时无法读取历史证据。`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Files are unavailable until the execution state is ready.":`执行状态就绪后才能读取文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Owner work already listed below is not duplicated here.":`下方已经列出的 owner 工作不在此重复显示。`,"Active Pi work":`Pi 活动工作`,"{projects} projects · {sessions} sessions":`{projects} 个项目 · {sessions} 个会话`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Discovering active work…":`正在发现活动工作…`,"No active work observed. Idle terminals and owners are not listed.":`未观察到活动工作。空闲终端和 owner 不列入此处。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution 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.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Connecting…":`正在连接…`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution 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":`历史详情`,"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 this goal and boundary: adaptive implementation, checks, recovery, project knowledge 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.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,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:":`尚未观察到此次发送的结果:`,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.":`当前服务连接一个项目,打开项目不会启动执行。`,"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}。`,"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:`失败`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then 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…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"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}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"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.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager 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.":`包管理器会在 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.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,"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:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function 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 te(e){let t=N(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||M(),t}function ne(e,t){return te(e),te(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function W(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 ae=[`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`],K=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function le(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,ce),thinking:L(t.thinking,K)}}function ue(e){let{sourceSelectionId:t,...n}=B(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:H(t),...le(n)}}function de(e){let t=B(e,[`role`,`sha256`]);return{role:L(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:U(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function pe(e){let t=B(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:H(t.recordId),version:F(t.version,1),field:L(t.field,ae),bytes:F(t.bytes,0,k.detailBytes),sha256:U(t.sha256)}}function q(e){let t=B(e,[`start`,`end`]),n=F(t.start);return{start:n,end:F(t.end,n+1,k.detailBytes)}}function me(e){let t=B(e,[`source`,`range`,`requireCompleteObservation`]),n=he(t.source),r;if(n===`current`)r={kind:n,assignmentId:W(B(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=B(t.source,[`kind`,`runId`,`childRunId`,`result`]);R(n,`historical`);let i=pe(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,q);return r.kind===`historical`&&i&&i.end>r.result.bytes&&M(),{source:r,range:i,requireCompleteObservation:I(t.requireCompleteObservation)}}function he(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 ge(e){G(e,k.graphBytes);let t=B(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(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:W(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:de(t.role),model:ue(t.model),dependencies:V(t.dependencies,k.assignments,me)}})};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!==fe(e.purpose))throw new j(`forbidden`);c(e)}return i}function _e(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 ve(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:ue(t.model),checkEnvGeneration:F(t.checkEnvGeneration,1),checkoutGeneration:F(t.checkoutGeneration),observation:{identity:U(n.identity),complete:I(n.complete)},task:z(t.task,_e)}}function J(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 ye(e){switch(G(e),he(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=ge(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:he(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:J(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 be(e){G(e);let t=B(e,[`expected`,`action`]);return{expected:ve(t.expected),action:ye(t.action)}}function xe(e){G(e);let t=B(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:H(t.commandId),grant:H(t.grant),expected:ve(t.expected),action:ye(t.action)}}function Y(e){if(G(e),he(e)===`action`){let t=B(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:ye(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 Se(e){let t=B(e,[`commandId`,`epoch`,`runId`]);return{commandId:H(t.commandId),epoch:H(t.epoch),runId:H(t.runId)}}function Ce(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,J);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:ve(n.version),action:ye(n.action),rootLabel:N(n.rootLabel,4096,!0),cwdLabel:N(n.cwdLabel,4096,!0),readablePlan:N(n.readablePlan,32768),graph:z(n.graph,ge),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 we(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:Ce(t.preview)}}function X(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=pe(t.result);R(i.field,`final-text`);let a=z(t.range,q);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:W(t.assignmentId),dependencyIndex:s,runId:H(t.runId),childRunId:H(t.childRunId),result:i,range:a,text:o,coverage:X(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,se),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:X(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:te(t.snapshotSeq),recordId:z(t.recordId,H),recordVersion:z(t.recordVersion,e=>F(e,1)),field:z(t.field,e=>L(e,ae)),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=he(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=pe(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=he(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:X(n.coverage)}}case`capture-status`:return{kind:t,coverage:X(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,se),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=te(t.committedSeq);return n===`0`&&M(),{childRunId:H(t.childRunId),detailId:H(t.detailId),content:pe(t.content),committedSeq:n}}function Be(e){let t=he(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,te);return(n===`0`||n!==null&&t.status===`committed`&&ne(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=he(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,te);return r===`0`&&M(),{kind:t,native:Le(n.native),capture:X(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:W(t.assignmentId),childRunId:n,native:z(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=L(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))&&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=he(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:X(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:te(t.committedSeq),execution:z(t.execution,e=>L(e,oe)),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=Y(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(he(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),he(e,`status`)){case`found`:return{status:`found`,receipt:et(B(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:te(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,W),admission:pt(t.admission),lifecycle:L(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:z(t.outcome,e=>L(e,oe)),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:X(t.coverage),result:z(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`&&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:te(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=he(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:te(n.committedSeq)};if(t===`update`){let e=te(n.previousSeq);ne(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:X(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:pe(t.content),range:z(t.range,q),text:N(t.text,k.detailPageBytes),next:z(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!==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=pe(t.content),a=bt(t.owner);xt(a,n.scope)||M();let o=q(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:X(t.coverage)}}function pt(e){let t=B(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(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:W(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(he(e,`status`)===`available`)return{status:`available`,version:ve(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:te(t.committedSeq),rootLabel:N(t.rootLabel,4096,!0),context:mt(t.context),models:V(t.models,k.maxPageEntries,ue)};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=he(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=pe(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:J(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,pe),u=X(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=pe(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=he(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:X(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,te),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=he(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=te(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=te(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,pe);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,pe),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=pe(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:X(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:X(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:X(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:X(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:te(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=ge(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:X(t.coverage)}}function Rt(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:te(t.snapshotSeq),format:L(t.format,[`ndjson`,`markdown`])}}function zt(e){G(e,k.controlBytes);let t=B(e,[`exportId`,`ordinal`,`event`]),n=he(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:X(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=pe(e.content),a=z(e.range,q),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:X(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=X(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:te(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=J(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:te(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:X(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,de);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:te(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=X(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:te(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: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)&&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,le)}}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,ue)}}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,ue)}}function ln(e){G(e);let t=B(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:le(t.choice)}}function un(e){let t=B(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]),n={...t.images===void 0?{}:{images:I(t.images)},provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:z(t.api,e=>L(e,ce)),thinking:V(t.thinking,7,e=>{let t=B(e,[`level`,`selectable`]);return{level:L(t.level,K),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,le),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,ue),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`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Dn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function On(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 kn(e){let t=B(e,[`kind`,`version`,`deprecated`]);return{kind:R(t.kind,`release`),version:wn(t.version),deprecated:I(t.deprecated)}}function An(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 jn=Object.freeze({chunkChars:262144,idleMs:6e5}),Mn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Nn(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Pn(e,t){if(!Mn.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
2
2
  
3
- `)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Fn={tasks:16,parallel:2,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4};function In(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Ln(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 Rn=(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 zn(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 Bn(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 Vn(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 Bn(e),r(t),Bn(e).filter(e=>n.has(e.id))}function Hn(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);if(W(e,Fn.bytes),r&&e.version!==2)throw Error(`Unsupported delivery agreement version`);let i=z(e,[`goal`,`design`,`decisions`,`acceptance`,...r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),a=B(i.tasks,Fn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Rn(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>Ln(e,n)),after:B(t.after,Fn.tasks,e=>Rn(e,n))}});if(!a.length||a.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`);Bn(a);for(let e of r?[]:a)for(let t of a)if(!(e.id>=t.id||Vn(a,e.id).some(e=>e.id===t.id)||Vn(a,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>In(t.writes,e))||t.writes.some(t=>In(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let o=B(i.checks,Fn.checks,zn);if(!o.length)throw Error(`At least one real verification command is required`);let s={goal:M(i.goal,8192,!0),design:M(i.design,32768,!0),decisions:M(i.decisions,16384),acceptance:M(i.acceptance,16384,!0),...r?{version:2,knowledge:B(i.knowledge,16,e=>{let t=Ln(e,n);if(!t.endsWith(`.md`))throw Error(`Knowledge targets must be Markdown files`);return t})}:{projectContext:M(i.projectContext,16384),repairAttempts:P(i.repairAttempts,0,2)},tasks:a,checks:o,setup:B(i.setup,4,zn),baselineChecks:B(i.baselineChecks,Fn.checks,zn),delivery:I(i.delivery,[`local-merge`,`working-copy`])};Wn(s),M(Un(s).join(`, `),16384);for(let e of[s.goal,s.design,s.decisions,s.acceptance,s.projectContext??``,...s.tasks.flatMap(e=>[e.title,e.instructions]),...[...s.checks,...s.setup,...s.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 s}function Un(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function Wn(e){return M(`# ${e.goal}\n\nInitial route (adapt within the approved boundary): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}\n\nImmutable acceptance: ${e.acceptance}`,32768,!0)}function Gn(e){let t=M(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Kn(e){let t=M(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function qn(e){let t=M(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function Jn(e){let t=z(e,[`policy`,`target`]),n=z(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:I(t.policy,[`task-branch-v1`]),target:{checkoutRoot:qn(n.checkoutRoot),repository:qn(n.repository),repositoryIdentity:H(n.repositoryIdentity),branch:Kn(n.branch),head:Gn(n.head)}}}function Yn(e){let t=z(e,[`binding`,`taskBranch`,`worktreeRoot`,`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=z(t.integration,[`status`,`before`,`after`,`reason`]),r=z(t.cleanup,[`status`,`reason`]),i=e=>M(e,160,!0),a=R(t.acceptance,e=>{let t=z(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`]),n=B(t.checks,Fn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Gn(t.candidate),tree:Gn(t.tree),planDigest:H(t.planDigest),contextDigest:H(t.contextDigest),checks:n,review:i(t.review)}}),o=R(t.candidate,Gn);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=R(t.workspace,e=>{let t=z(e,[`head`,`state`]);return{head:Gn(t.head),state:I(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=Jn(t.binding),l=Kn(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:qn(t.worktreeRoot),preparation:I(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:I(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Gn(n.before),after:R(n.after,Gn),reason:M(n.reason,2048)},postChecks:I(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:I(r.status,[`pending`,`removed`,`retained`]),reason:M(r.reason,2048)}}}function Xn(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval.\nAcceptance: checks and automatic Agent review of the exact candidate.\nDelivery: fast-forward only into the bound target, unchanged since approval or this run's last confirmed merge. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function Zn(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`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...t?[`display`]:[]]);return{...n.delivery===void 0?{}:{delivery:Jn(n.delivery)},id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:sn(n.model),plan:Hn(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 Qn(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,Fn.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:Hn(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 $n(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>I(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=z(t.verification,[`id`,`source`,`steps`]);return{id:V(e.id),source:H(e.source),steps:B(e.steps,32,e=>M(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:P(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:P(t.revision,0)},...t.delivery===void 0?{}:{delivery:Yn(t.delivery)},...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:ir(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`,`recovering`,`learning`,`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:rr(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`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function er(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:$n(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Zn(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:Zn(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function tr(e){return`# ${e.goal}\n\n## Initial route (automatically adjustable)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${Bn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
3
+ `)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Fn={tasks:16,parallel:2,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4};function In(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Ln(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 Rn=(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 zn(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 Bn(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 Vn(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 Bn(e),r(t),Bn(e).filter(e=>n.has(e.id))}function Hn(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);if(G(e,Fn.bytes),r&&e.version!==2)throw Error(`Unsupported delivery agreement version`);let i=B(e,[`goal`,`design`,`decisions`,`acceptance`,...r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),a=V(i.tasks,Fn.tasks,e=>{let t=B(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Rn(t.id,n),title:N(t.title,256,!0),instructions:N(t.instructions,8192,!0),writes:V(t.writes,128,e=>Ln(e,n)),after:V(t.after,Fn.tasks,e=>Rn(e,n))}});if(!a.length||a.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`);Bn(a);for(let e of r?[]:a)for(let t of a)if(!(e.id>=t.id||Vn(a,e.id).some(e=>e.id===t.id)||Vn(a,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>In(t.writes,e))||t.writes.some(t=>In(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let o=V(i.checks,Fn.checks,zn);if(!o.length)throw Error(`At least one real verification command is required`);let s={goal:N(i.goal,8192,!0),design:N(i.design,32768,!0),decisions:N(i.decisions,16384),acceptance:N(i.acceptance,16384,!0),...r?{version:2,knowledge:V(i.knowledge,16,e=>{let t=Ln(e,n);if(!t.endsWith(`.md`))throw Error(`Knowledge targets must be Markdown files`);return t})}:{projectContext:N(i.projectContext,16384),repairAttempts:F(i.repairAttempts,0,2)},tasks:a,checks:o,setup:V(i.setup,4,zn),baselineChecks:V(i.baselineChecks,Fn.checks,zn),delivery:L(i.delivery,[`local-merge`,`working-copy`])};Wn(s),N(Un(s).join(`, `),16384);for(let e of[s.goal,s.design,s.decisions,s.acceptance,s.projectContext??``,...s.tasks.flatMap(e=>[e.title,e.instructions]),...[...s.checks,...s.setup,...s.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 s}function Un(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function Wn(e){return N(`# ${e.goal}\n\nInitial route (adapt within the approved boundary): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}\n\nImmutable acceptance: ${e.acceptance}`,32768,!0)}function Gn(e){let t=N(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Kn(e){let t=N(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function qn(e){let t=N(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function Jn(e){let t=B(e,[`policy`,`target`]),n=B(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:L(t.policy,[`task-branch-v1`]),target:{checkoutRoot:qn(n.checkoutRoot),repository:qn(n.repository),repositoryIdentity:U(n.repositoryIdentity),branch:Kn(n.branch),head:Gn(n.head)}}}function Yn(e){let t=B(e,[`binding`,`taskBranch`,`worktreeRoot`,`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=B(t.integration,[`status`,`before`,`after`,`reason`]),r=B(t.cleanup,[`status`,`reason`]),i=e=>N(e,160,!0),a=z(t.acceptance,e=>{let t=B(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`]),n=V(t.checks,Fn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Gn(t.candidate),tree:Gn(t.tree),planDigest:U(t.planDigest),contextDigest:U(t.contextDigest),checks:n,review:i(t.review)}}),o=z(t.candidate,Gn);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=z(t.workspace,e=>{let t=B(e,[`head`,`state`]);return{head:Gn(t.head),state:L(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=Jn(t.binding),l=Kn(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:qn(t.worktreeRoot),preparation:L(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:L(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Gn(n.before),after:z(n.after,Gn),reason:N(n.reason,2048)},postChecks:L(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:L(r.status,[`pending`,`removed`,`retained`]),reason:N(r.reason,2048)}}}function Xn(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval.\nAcceptance: checks and automatic Agent review of the exact candidate.\nDelivery: fast-forward only into the bound target, unchanged since approval or this run's last confirmed merge. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}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`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...t?[`display`]:[]]);return{...n.delivery===void 0?{}:{delivery:Jn(n.delivery)},id:H(n.id),epoch:H(n.epoch),digest:U(n.digest),observation:U(n.observation),model:sn(n.model),plan:Hn(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 Qn(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,Fn.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:Hn(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 $n(e){let t=B(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>L(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=B(t.verification,[`id`,`source`,`steps`]);return{id:H(e.id),source:U(e.source),steps:V(e.steps,32,e=>N(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:F(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:F(t.revision,0)},...t.delivery===void 0?{}:{delivery:Yn(t.delivery)},...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:ir(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`,`recovering`,`learning`,`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:rr(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`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:n(r.status),text:N(r.text,65536),exitCode:z(r.exitCode,e=>F(e,-2147483648,2147483647)),truncated:I(r.truncated)}})}}function er(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:$n(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 tr(e){return`# ${e.goal}\n\n## Initial route (automatically adjustable)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${Bn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
5
5
 
6
6
  `)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
7
7
  `)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
8
8
  `)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
9
9
  `)}\n\n## Automation boundary\n${e.version===2?`Authorize diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands. No fixed repair-round or delivery-duration quota. Only actual verification and independent Agent review permit delivery.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`} ${e.delivery===`local-merge`?`Authorize one new named task branch and stable isolated worktree after approval, local commits and fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project knowledge\n${e.version===2?e.knowledge?.join(`
10
- `)||`No documentation edits authorized; existing knowledge is still read.`:e.projectContext}\n`}var nr=e=>P(e,0,864e13);function rr(e){let t=z(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:nr(t.createdAt),preparedAt:R(t.preparedAt,nr),startedAt:R(t.startedAt,nr),stopRequestedAt:R(t.stopRequestedAt,nr),closedAt:R(t.closedAt,nr),settledAt:R(t.settledAt,nr),timeoutMs:P(t.timeoutMs,100,12e5),stopReason:R(t.stopReason,e=>M(e,32,!0))}}function ir(e){let t=z(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=z(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:nr(t.acceptedAt),acquiredAt:R(t.acquiredAt,nr),settledAt:R(t.settledAt,nr),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:nr(n.startedAt)}}}function ar(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(`
11
- `)}function or(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,Zn),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}function sr(e){let t=M(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new A(`invalid`);return t}var cr=16384,lr=1e3,ur=16384,dr=1024;function fr(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 pr(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(`
12
- `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function mr(e,t,n=!1){let r=e.role===`tool`,i=r?``:fr(e.text,ur);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?fr(pr(e.args),dr):``,error:e.error,parts:t}}function hr(e){let t=z(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:P(t.updatedAt,0)}}var gr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function _r(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,sr),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);if(r%jn.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr),...n.live===void 0?{}:{live:!0},entry:sr(n.entry),index:P(n.index,0),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,sr),turnId:sr(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,sr)}}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`:{let n=z(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:V(n.id),...n.before===void 0?{}:{before:P(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=z(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:R(r.after,hr)}:{}}}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,sr),known:R(n.known,sr)}}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 vr(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:ue(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:ue(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,sr),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=vr(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,Mn),size:P(n.size,1),offset:P(n.offset,0),data:M(n.data,jn.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,sr),text:M(n.text,cr),...n.images===void 0?{}:{images:B(n.images,2**53-1,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:Qn(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,sr),text:M(n.text,cr),...n.images===void 0?{}:{images:B(n.images,2**53-1,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 yr(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,gr),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,xr)}}function br(e){return B(e,2**53-1,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:sr(t.entry),index:P(t.index,0),mimeType:I(t.mimeType,Mn)}})}function xr(e){let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:br(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 Sr(e){let t=z(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:br(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,ur),clipped:F(t.clipped),name:M(t.name,128),target:M(t.target,dr),error:F(t.error),parts:P(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function Cr(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:sr(t.id),entry:R(t.entry,sr),at:P(t.at,0),status:I(t.status,gr),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 wr(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,sr),status:I(n.status,gr),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 Tr(e){let t=z(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:V(t.commandId),text:M(t.text,16384),status:I(t.status,gr),notice:M(t.notice,1024)}}function Er(e){let t=z(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:sr(t.id),parent:R(t.parent,sr),text:M(t.text,1024),at:P(t.at,0),leaf:sr(t.leaf),current:F(t.current)}}function Dr(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)}}if(t===`conversation-image`){let n=z(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:I(n.mimeType,Mn),data:M(n.data,jn.chunkChars,!0),next:R(n.next,e=>P(e,0))}}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,yr)}}if(t===`cadence-conversation`)return{kind:t,state:or(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,Fn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,$n);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,$n),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:Zn(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:er(t.response)}}if(n===`conversation-active`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,8,wr)};if(n===`conversations`){let t=z(e,[`kind`,`entries`,`next`]);return{kind:n,entries:B(t.entries,200,wr),next:R(t.next,hr)}}if(n===`conversation`){let t=z(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=R(t.summary,wr),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,sr),continues:F(t.continues),turns:i,branches:P(t.branches,0),runs:B(t.runs,200,V),attempt:R(t.attempt,Tr)}}if(n===`conversation-tree`){let t=z(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:B(t.nodes,lr,Er),truncated:F(t.truncated)}}if(n===`conversation-turn`){let t=z(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Cr(t.turn),i=P(t.start,0),a=B(t.steps,24,Sr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,sr),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,sr),turnId:sr(t.turnId),step:P(t.step,0),part:P(t.part,0),item:xr(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 Or={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},kr=f.createContext&&f.createContext(Or),Ar=[`attr`,`size`,`title`];function jr(e,t){if(e==null)return{};var n,r,i=Mr(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 Mr(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 Nr(){return Nr=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},Nr.apply(null,arguments)}function Pr(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 Fr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pr(Object(n),!0).forEach(function(t){Ir(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ir(e,t,n){return(t=Lr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lr(e){var t=Rr(e,`string`);return typeof t==`symbol`?t:t+``}function Rr(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 zr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Fr({key:t},e.attr),zr(e.child)))}function Q(e){return t=>f.createElement(Br,Nr({attr:Fr({},e.attr)},t),zr(e.child))}function Br(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=jr(e,Ar),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Nr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Fr(Fr({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 kr===void 0?t(Or):f.createElement(kr.Consumer,null,e=>t(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:`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 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:`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 Ur(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 Wr(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 Gr(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 Kr(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 qr(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 Jr(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 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:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},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:`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 Zr(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 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:`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 $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:`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 ei(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 ti(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 ni(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 ri(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 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:`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 ai(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 oi(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 si(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 ci(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 li(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 ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 di(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 fi(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 pi(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 mi(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 hi(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 gi(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 _i(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 vi(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 yi(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 bi(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`)}),xi=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=_r(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Dr);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=vr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Dr);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=J({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Te);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=xe(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=Ce(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=Oe(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=X(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=X(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)}}},Si=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)&&re(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>=O.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=O.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=re(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>O.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`}};function Ci(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var wi={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`},Ti=`/api/v1/events`,Ei=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Di(e,t){if(Ei.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 O.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 O.pageBytes}return O.controlBytes}function Oi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function ki(e,t){switch(e){case`workbenchRead`:return _r(t);case`workbenchCommand`:return vr(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 Oe(t);case`detail`:case`search`:return X(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return J(t);case`command`:return xe(t);case`cancel`:return Ce(t)}}function Ai(e,t){if(Ei.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Dr);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,Te);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 ji(e){return[...Ei,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Mi(e,t){let n=wi[e];return t===null||Oi(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Ni(e,t){let n=ki(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?wi[e]:Mi(e,n);return Oi(e)||ji(e)&&(r||N(i)>O.headerBytes/4)?{path:wi[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Pi(e){W(e,O.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 Fi=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=Ni(e,ki(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Ci([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;let t=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:o,...i?{body:r.body}:{}}),n;try{e===`session`&&t.ok&&(n=V(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Ii(t,Di(e)),s=ie(a);if(N(a)>Di(e,s))throw new A(`oversize`);let c=Ai(e,s);if(e===`session`){let e=Z(c,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`forbidden`);this.attachment=n??V(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,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`,J(e))}command(e){return this.request(`command`,xe(e))}cancel(e){return this.request(`cancel`,Ce(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=Ni(`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+=O.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+O.chunkBytes),{stream:!0});let r=o.indexOf(`
13
- `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(ie(e,O.controlBytes)),r=o.indexOf(`
14
- `)}if(new TextEncoder().encode(o).length>O.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=Oe(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}`:``}${Ti}?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>=O.staleMs&&u(`stale`);try{Date.now()-c>=O.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},O.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=Pi(ie(e.data,O.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Ii(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 Li={sourceHash:`c6f8f1a6009db41d0981c2cdec5cd450ace3ea29bb153bdd3c7b542c5d6701f5`,contractHash:`002b8e5b103844b2237ba13aa27a72344e5bd61b94f96bb41181f53b9dd5a225`,buildId:`47a800af27a5559a12ebe4f41cf5a17fd678b226404dc89fd1477ad58865a115`};function Ri(e){let t=new Fi({origin:window.location.origin,...e?{project:e}:{},...Li?{build:{kind:`browser`,...Li}}:{},socket:e=>new WebSocket(e)});return{client:new xi(t),transport:t}}function zi(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?nn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Bi(e=typeof window>`u`?``:window.location.search){return zi(e,``).project}function Vi(e=typeof window>`u`?``:window.location.hash){return zi(``,e).chat}function Hi(){let e=Bi();return e?`/projects/${e}`:``}function Ui(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&zi(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?sr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}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&&re(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||re(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 Gi(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(_r(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 Ki(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 qi(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Gi(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 Ji(e){return ie(await Ii(e,1048576),1048576)}function Yi(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 Xi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Ji(r);if(!r.ok)throw Error(Yi(i));return t(i)}function Zi(e){return Xi(`/workbench/v1/service`,On,e)}function Qi(e){return Xi(`/workbench/v1/service/release`,kn,e)}async function $i(e,t){if(!Li)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`,...Li})},body:JSON.stringify(e)}),r=await Ji(n);if(!n.ok)throw Error(Yi(r));let i=z(r,[`kind`,`job`]);return L(i.kind,`service-job`),Tn(i.job)}function ea(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function ta(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function na(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),a=(0,f.useRef)(0),[o,s]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await Ji(r);if(!r.ok)throw Error(Yi(a));let c=mn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...ta(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...ta(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,f.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:ea(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var ra=e=>e===`unauthenticated`||e===`forbidden`,ia=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 Si,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 Si,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,ra(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(ra(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,ra(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,ra(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 Si,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Li?{kind:`browser`,...Li}: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 Si,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Si,_={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 aa(e,t,n,r){let i=(0,f.useMemo)(()=>new ia(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 oa=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 sa({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 ca(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 la(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 ua(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 da(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=ca(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 fa(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),la(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 pa({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)(pa,{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 ma(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 ha(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ma(e)}return ma(e)}function ga(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 ha(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 _a(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
15
- `).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 va=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ya(!0)},text:{92:ya(!1)}});let t={enter:{backslashMathInline:ba,backslashMathDisplay:ba,backslashMathBlock:ba},exit:{backslashMathInline:xa,backslashMathDisplay:xa,backslashMathBlock:xa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ya(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 ba=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)},xa=function(e){this.exit(e)},Sa=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ga();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)(_i,{}):(0,h.jsx)(fi,{}),n&&t(`Copy unavailable`)]})}),Ca=[s,d,va],wa=[s,l,d,va],Ta=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Ea(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?wa:Ca,rehypePlugins:t?[i,o,...Ta]:Ta,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Aa,a:ka,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)(Da,{...e})})});function ka({href:e,children:t}){let n=e&&Ea(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 Aa({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=_a(r).map(e=>{let t=`code-offset:${i}`;return i+=ja(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)(Sa,{text:ja(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 ja(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(ja).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return ja(t?.children)}return``}function Ma(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 Na=new Map;function Pa(e,t){t.length?Na.set(e,t):Na.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Na].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 Fa(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 Ia(e,t){let n=t.startContainer.parentElement;for(let r of Fa(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 La({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?Ma(n,r):[];return l.current=i,c(i.length),o(0),Pa(u,i),()=>Pa(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Ia(e.current,l.current[n]),Pa(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Pa(`${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 Ra({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>X(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),ee=(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 D=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await da(e,t,n.signal);if(n.signal.aborted)return;let i=await ha(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)}},O=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 D(),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)(pa,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,h.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),O&&(0,h.jsxs)(h.Fragment,{children:[(!i||O.next)&&(0,h.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:O.range?.start??0,end:O.range?.end??0,total:O.content.bytes}),` `,O.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,h.jsx)(La,{container:ee,version:`${O.content.recordId}:${O.content.version}:${O.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:ee,"data-retained-field":!0,children:r?r(O.text):x===`markdown`?(0,h.jsx)(Oa,{text:O.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!O||!n||!O.range)return O?.text;let e=Math.max(n.start,O.range.start)-O.range.start,t=Math.min(n.end,O.range.end)-O.range.start;if(t<=e)return O.text;let r=new TextEncoder().encode(O.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 za({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)(pa,{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)(qr,{"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 Ba({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=fa(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)(za,{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)(pa,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ua(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)(Ra,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Va({client:e,seed:t}){return(0,h.jsx)(Ha,{client:e,seed:t},W(t))}function Ha({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)(pa,{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 Ua(e){let t=Ni(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Hi()+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)(Vr,{"aria-hidden":`true`})})]}),t]})}function Ga({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{Ua({...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 Ka(e,t){if(!t||N(t)>O.queryBytes)throw Error(`Query must be 1–${O.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return X({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function qa(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 Ja({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=Ka(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)(Kr,{}),(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)(pa,{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(qa(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 Ya({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)(pa,{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 Xa({client:e,seed:t}){return(0,h.jsx)(Za,{client:e,seed:t},W(t))}function Za({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)(pa,{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)(Ra,{client:e,cursor:ua(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 Qa({client:e,seed:t,onScope:n}){let{t:r}=T(),i=fa(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(za,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ya,{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)(Xa,{client:e,seed:o},o.graph.recordId)]})}function $a({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)(Kr,{"aria-hidden":`true`})})}function eo(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 to(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 no(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)??ro(n.role,n.customType)}return r}function ro(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 io(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function ao(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=no(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=eo(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=>to(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)=>io(e,t,s.current,n),[])}}var oo=(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`})}),so=(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)(mi,{"aria-hidden":`true`}):(0,h.jsx)(si,{"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)(Ra,{compact:!0,client:t,cursor:ua(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)(Ba,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function co({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=ao(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)(oo,{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)(so,{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)(bi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function lo({client:e,seed:t}){let{t:n}=T(),r=fa(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(za,{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)(co,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function uo({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)(gi,{}):(0,h.jsx)(hi,{})}):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 fo=(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)(uo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Hr,{}),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)(Ba,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),po=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function mo({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=T(),s=new Set(e?.projects.flatMap(e=>e.activities.filter(e=>e.sessionId).map(t=>`${e.path}\0${t.sessionId}`))),c=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(po(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length);return(0,h.jsxs)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:a(`Active Pi work`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[e&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`{projects} projects · {sessions} sessions`,{projects:e.projects.length,sessions:s.size})}),(t||e?.completeness===`partial`)&&(0,h.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),i.length>0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Owner work already listed below is not duplicated here.`)}),!e&&!t&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Discovering active work…`)}),e?.completeness===`complete`&&!t&&!e.projects.length&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`No active work observed. Idle terminals and owners are not listed.`)}),c?.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,h.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})]})}var ho=[`queued`,`running`];function go(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 _o=4,vo=1e4;function yo(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?ho.includes(t.status):i-(u.get(e)??0)>=vo}).reverse();for(let n=0;n<a.length;n+=_o){let r=await Promise.all(a.slice(n,n+_o).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+_o<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>ho.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),vo))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function bo({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=yo(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(!ho.includes(e.step.status))-Number(!ho.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>ho.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,ee=d??(w>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${ee?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":ee,onClick:()=>p(!ee),children:[(0,h.jsx)(gi,{}),(0,h.jsx)(ui,{}),(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})]}),ee&&(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=go(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 xo=2e4;async function So(e,t,n,r){let i=Ci([t],xo);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Co(e){switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function wo(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function To(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Eo(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:sr(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,cr,!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(Do(e.model))}:{}})}function Do(e){return ue({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Oo(e,t){return Object.freeze({...e,model:Object.freeze(Do(t))})}function ko(e,t){if(e.model&&W(e.model)!==W(Do(t)))throw new A(`stale`)}function Ao(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null))throw new A(`stale`);let n=vr(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 jo(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 Mo(e){for(let t of e){if(!Mn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function No(e){Mo([e]);let t=new Uint8Array(await e.arrayBuffer());return Pn(t,e.type),t}var Po=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 Fo(e,t,n,r){Mo(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await No(a);if(!r())throw Error(`stale`);let o=Po(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=jn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+jn.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 Io(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>jn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==jn.chunkChars)throw Error(`invalid`)}let i=Nn(n.join(``));return Pn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Lo=1e3,Ro=1e4,zo=4,Bo=e=>e===`queued`||e===`running`,Vo=class extends Error{},Ho=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 Vo?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?Lo:Ro)}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 Vo(`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 Vo(`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 Vo(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Ci([t,r]);try{return await Io(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n){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=Ci([n,a]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},s.signal);if(n.kind!==`conversation-step`||n.part!==o)throw new Vo(`invalid`);return n.item}finally{s.dispose()}}));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>=zo&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Vo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Vo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Uo(e,t,n,r=null){let[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new Ho(e,t,()=>s(n.view()));return n.choose(r),a(n),s(n.view()),()=>n.close()},[e,t,r]),(0,f.useEffect)(()=>{i?.setActive(n)},[i,n]),{...o??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:i?.refresh??Wo,loadEarlier:i?.loadEarlier??Wo,choose:i?.choose??Wo}}function Wo(){}async function Go(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 Ko(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function qo(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Jo={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Yo={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.`},Xo=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Zo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Qo(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>G.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function $o(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Jo[t.thinking])}`,[e])}function es({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=$o(),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,ee]=(0,f.useState)(0),D=(0,f.useRef)(null),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(null),te=(0,f.useCallback)(()=>ee(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&&O.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;b(``),k.current?.focus({preventScroll:!0});let e=e=>{D.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=>Zo(e,N)),I=t&&!_,L=async(t,r)=>{if(!I||!m||!t.api||x||n)return;let i=ue({provider:t.provider,model:t.model,api:t.api,thinking:r});if(M&&Xo(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)}}},R=()=>[...A.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?k.current?.focus():t[Math.min(n,t.length-1)]?.focus()},B=!t||!m&&!!_,V=m?N?d(N):u(`Choose a model`):u(_?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:D,children:[(0,h.jsxs)(`button`,{ref:O,type:`button`,className:`model-trigger${N&&!M?` remembered`:``}${m&&!N?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:V}),"aria-haspopup":`dialog`,"aria-expanded":i,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)(ui,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:V}),(0,h.jsx)(gi,{"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)(Kr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:k,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:A,onKeyDown:z,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=Zo(e,N);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!I||!t||x||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void L(e,Qo(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)(_i,{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(Jo[e.level])}),"aria-pressed":N?.thinking===e.level,disabled:!I||!e.selectable||x||n,onClick:()=>void L(F,e.level),children:u(Jo[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[!t&&(0,h.jsx)(`p`,{role:`status`,children:u(`Model selection is unavailable until the current conversation and execution state are observed.`)}),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:Yo[y]?u(Yo[y]):u(`The model was not changed ({code}).`,{code:y})}),!B&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(x?`Switching model…`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function ts(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 ns({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Gi(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>ts(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)(Vr,{"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 rs({active:e,armed:t,known:n,disabled:r,onClick:i}){let{t:a}=T(),o=n?e?`on`:t?`armed`:`off`:`unknown`,s=a(n?e?`Cadence on`:t?`Cadence on next Send`:`Cadence off`:`Cadence state unavailable`);return(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle ${o}`,"aria-label":s,disabled:r||!n,title:a(e?`Cadence mode is on. Click to exit it.`:t?`Your next message turns on Cadence mode. Click to cancel.`:`Turn on Cadence mode: agree on a plan before implementation.`),onClick:i,children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),s]})}function is(){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])];Mo(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 as({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),No(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 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 os({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 ss({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(os,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var cs=/^\s{0,3}(`{3,}|~{3,})/,ls=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function us(e){return e.trim()===``}function ds(e){let t=cs.exec(e);return t?t[1]:null}function fs(e){let t=e.split(`
16
- `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=ds(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=ds(a);if(o&&!us(a))i=o,r.push(a);else if(us(a)){let i=e;for(;i<t.length&&us(t[i]);)i++;if(!(i<t.length&&ls.test(t[i]))&&r.length>0){n.push(r.join(`
10
+ `)||`No documentation edits authorized; existing knowledge is still read.`:e.projectContext}\n`}var nr=e=>F(e,0,864e13);function rr(e){let t=B(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:nr(t.createdAt),preparedAt:z(t.preparedAt,nr),startedAt:z(t.startedAt,nr),stopRequestedAt:z(t.stopRequestedAt,nr),closedAt:z(t.closedAt,nr),settledAt:z(t.settledAt,nr),timeoutMs:F(t.timeoutMs,100,12e5),stopReason:z(t.stopReason,e=>N(e,32,!0))}}function ir(e){let t=B(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=B(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:nr(t.acceptedAt),acquiredAt:z(t.acquiredAt,nr),settledAt:z(t.settledAt,nr),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:nr(n.startedAt)}}}function ar(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(`
11
+ `)}function or(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 sr(e){let t=N(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new j(`invalid`);return t}var cr=16384,lr=1e3,ur=16384,dr=1024;function fr(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 pr(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(`
12
+ `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function mr(e,t,n=!1){let r=e.role===`tool`,i=r?``:fr(e.text,ur);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?fr(pr(e.args),dr):``,error:e.error,parts:t}}function hr(e){let t=B(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:F(t.updatedAt,0)}}var gr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function _r(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,sr),ordinal:F(n.ordinal,0),before:z(n.before,e=>F(e,0))}}case`conversation-image`:{let n=B(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=F(n.offset,0);if(r%jn.chunkChars||n.live!==void 0&&n.live!==!0)throw new j(`invalid`);return{kind:t,id:nn(n.id),leaf:z(n.leaf,sr),...n.live===void 0?{}:{live:!0},entry:sr(n.entry),index:F(n.index,0),offset:r}}case`conversation-step`:{let n=B(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:z(n.leaf,sr),turnId:sr(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,sr)}}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`:{let n=B(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:H(n.id),...n.before===void 0?{}:{before:F(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=B(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:z(r.after,hr)}:{}}}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,sr),known:z(n.known,sr)}}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 vr(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:le(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:le(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,sr),revision:F(n.revision,0)}}if(t===`image-upload`){let n=B(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new j(`invalid`);let r=vr(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new j(`invalid`);return{kind:t,commandId:H(n.commandId),imageId:H(n.imageId),send:r,mimeType:L(n.mimeType,Mn),size:F(n.size,1),offset:F(n.offset,0),data:N(n.data,jn.chunkChars,!0)}}if(t===`cadence-send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:H(n.commandId),conversationId:nn(n.conversationId),head:z(n.head,sr),text:N(n.text,cr),...n.images===void 0?{}:{images:V(n.images,2**53-1,H)},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:Qn(n.request)}}if(t===`send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:H(n.commandId),conversationId:nn(n.conversationId),head:z(n.head,sr),text:N(n.text,cr),...n.images===void 0?{}:{images:V(n.images,2**53-1,H)},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 yr(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,gr),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,xr)}}function br(e){return V(e,2**53-1,e=>{let t=B(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new j(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:sr(t.entry),index:F(t.index,0),mimeType:L(t.mimeType,Mn)}})}function xr(e){let t=B(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:br(t.images)},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 Sr(e){let t=B(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:br(t.images)},id:N(t.id,160,!0),role:L(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,ur),clipped:I(t.clipped),name:N(t.name,128),target:N(t.target,dr),error:I(t.error),parts:F(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new j(`invalid`);return n}function Cr(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:sr(t.id),entry:z(t.entry,sr),at:F(t.at,0),status:L(t.status,gr),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 wr(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,sr),status:L(n.status,gr),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 Tr(e){let t=B(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:H(t.commandId),text:N(t.text,16384),status:L(t.status,gr),notice:N(t.notice,1024)}}function Er(e){let t=B(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:sr(t.id),parent:z(t.parent,sr),text:N(t.text,1024),at:F(t.at,0),leaf:sr(t.leaf),current:I(t.current)}}function Dr(e){G(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=B(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:H(n.commandId),imageId:H(n.imageId),offset:F(n.offset,0)}}if(t===`conversation-image`){let n=B(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:L(n.mimeType,Mn),data:N(n.data,jn.chunkChars,!0),next:z(n.next,e=>F(e,0))}}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,yr)}}if(t===`cadence-conversation`)return{kind:t,state:or(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,Fn.historyPage,e=>{let t=B(e,[`id`,`run`]),n=H(t.id),r=z(t.run,$n);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,$n),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:er(t.response)}}if(n===`conversation-active`)return{kind:n,entries:V(B(e,[`kind`,`entries`]).entries,8,wr)};if(n===`conversations`){let t=B(e,[`kind`,`entries`,`next`]);return{kind:n,entries:V(t.entries,200,wr),next:z(t.next,hr)}}if(n===`conversation`){let t=B(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=z(t.summary,wr),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,sr),continues:I(t.continues),turns:i,branches:F(t.branches,0),runs:V(t.runs,200,H),attempt:z(t.attempt,Tr)}}if(n===`conversation-tree`){let t=B(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:V(t.nodes,lr,Er),truncated:I(t.truncated)}}if(n===`conversation-turn`){let t=B(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Cr(t.turn),i=F(t.start,0),a=V(t.steps,24,Sr);if(i+a.length>r.steps)throw new j(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:z(t.leaf,sr),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,sr),turnId:sr(t.turnId),step:F(t.step,0),part:F(t.part,0),item:xr(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 Or={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},kr=f.createContext&&f.createContext(Or),Ar=[`attr`,`size`,`title`];function jr(e,t){if(e==null)return{};var n,r,i=Mr(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 Mr(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 Nr(){return Nr=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},Nr.apply(null,arguments)}function Pr(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 Fr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pr(Object(n),!0).forEach(function(t){Ir(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ir(e,t,n){return(t=Lr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lr(e){var t=Rr(e,`string`);return typeof t==`symbol`?t:t+``}function Rr(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 zr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Fr({key:t},e.attr),zr(e.child)))}function Q(e){return t=>f.createElement(Br,Nr({attr:Fr({},e.attr)},t),zr(e.child))}function Br(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=jr(e,Ar),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Nr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Fr(Fr({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 kr===void 0?t(Or):f.createElement(kr.Consumer,null,e=>t(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:`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 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:`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 Ur(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 Wr(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 Gr(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 Kr(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 qr(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 Jr(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 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:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},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:`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 Zr(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 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:`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 $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:`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 ei(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 ti(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 ni(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 ri(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 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:`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 ai(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 oi(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 si(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 ci(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 li(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 ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 di(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 fi(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 pi(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 mi(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 hi(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 gi(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 _i(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 vi(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 yi(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 bi(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`)}),xi=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=_r(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Dr);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=vr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Dr);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=be({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),we);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=xe(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=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){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)}}},Si=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)&&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||G(i.scope)!==G(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||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`}};function Ci(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var wi={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`},Ti=`/api/v1/events`,Ei=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Di(e,t){if(Ei.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 Oi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function ki(e,t){switch(e){case`workbenchRead`:return _r(t);case`workbenchCommand`:return vr(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 be(t);case`command`:return xe(t);case`cancel`:return Se(t)}}function Ai(e,t){if(Ei.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Dr);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 j(`invalid`);return null});default:throw new j(`invalid`)}}function ji(e){return[...Ei,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Mi(e,t){let n=wi[e];return t===null||Oi(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function Ni(e,t){let n=ki(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?wi[e]:Mi(e,n);return Oi(e)||ji(e)&&(r||P(i)>k.headerBytes/4)?{path:wi[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function Pi(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 Fi=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=Ni(e,ki(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Ci([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;let t=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:o,...i?{body:r.body}:{}}),n;try{e===`session`&&t.ok&&(n=H(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Ii(t,Di(e)),s=re(a);if(P(a)>Di(e,s))throw new j(`oversize`);let c=Ai(e,s);if(e===`session`){let e=Z(c,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new j(`forbidden`);this.attachment=n??H(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,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`,be(e))}command(e){return this.request(`command`,xe(e))}cancel(e){return this.request(`cancel`,Se(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=Ni(`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(`
13
+ `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(re(e,k.controlBytes)),r=o.indexOf(`
14
+ `)}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}`:``}${Ti}?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=Pi(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 Ii(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 Li={sourceHash:`8151acf692a562ac1149d08da013f94387fa587da13384a05f3063a66b2039a3`,contractHash:`002b8e5b103844b2237ba13aa27a72344e5bd61b94f96bb41181f53b9dd5a225`,buildId:`111d93d622e3a8cc5218cdcc1e271b4f53770e7b37b291a64fd23cf6407785f6`};function Ri(e){let t=new Fi({origin:window.location.origin,...e?{project:e}:{},...Li?{build:{kind:`browser`,...Li}}:{},socket:e=>new WebSocket(e)});return{client:new xi(t),transport:t}}function zi(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?nn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Bi(e=typeof window>`u`?``:window.location.search){return zi(e,``).project}function Vi(e=typeof window>`u`?``:window.location.hash){return zi(``,e).chat}function Hi(){let e=Bi();return e?`/projects/${e}`:``}function Ui(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&zi(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?sr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}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&&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&&G(t.settlement)!==G(r.settlement))?i=!0:(!r||ne(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 Gi(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(_r(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 Ki(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 qi(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Gi(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 Ji(e){return re(await Ii(e,1048576),1048576)}function Yi(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 Xi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Ji(r);if(!r.ok)throw Error(Yi(i));return t(i)}function Zi(e){return Xi(`/workbench/v1/service`,On,e)}function Qi(e){return Xi(`/workbench/v1/service/release`,kn,e)}async function $i(e,t){if(!Li)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`,...Li})},body:JSON.stringify(e)}),r=await Ji(n);if(!n.ok)throw Error(Yi(r));let i=B(r,[`kind`,`job`]);return R(i.kind,`service-job`),Tn(i.job)}function ea(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function ta(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function na(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),a=(0,f.useRef)(0),[o,s]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await Ji(r);if(!r.ok)throw Error(Yi(a));let c=mn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...ta(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...ta(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,f.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:ea(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var ra=e=>e===`unauthenticated`||e===`forbidden`,ia=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 Si,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 Si,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,ra(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(ra(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,ra(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,ra(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 Si,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Li?{kind:`browser`,...Li}: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 Si,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Si,_={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 aa(e,t,n,r){let i=(0,f.useMemo)(()=>new ia(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 oa=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 sa({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 ca(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 la(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 ua(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 da(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=ca(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 fa(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),la(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 pa({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)(pa,{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 ma(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 ha(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ma(e)}return ma(e)}function ga(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 ha(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 _a(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
15
+ `).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 va=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ya(!0)},text:{92:ya(!1)}});let t={enter:{backslashMathInline:ba,backslashMathDisplay:ba,backslashMathBlock:ba},exit:{backslashMathInline:xa,backslashMathDisplay:xa,backslashMathBlock:xa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ya(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 ba=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)},xa=function(e){this.exit(e)},Sa=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ga();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)(_i,{}):(0,h.jsx)(fi,{}),n&&t(`Copy unavailable`)]})}),Ca=[s,d,va],wa=[s,l,d,va],Ta=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Ea(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?wa:Ca,rehypePlugins:t?[i,o,...Ta]:Ta,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Aa,a:ka,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)(Da,{...e})})});function ka({href:e,children:t}){let n=e&&Ea(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 Aa({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=_a(r).map(e=>{let t=`code-offset:${i}`;return i+=ja(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)(Sa,{text:ja(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 ja(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(ja).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return ja(t?.children)}return``}function Ma(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 Na=new Map;function Pa(e,t){t.length?Na.set(e,t):Na.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Na].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 Fa(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 Ia(e,t){let n=t.startContainer.parentElement;for(let r of Fa(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 La({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?Ma(n,r):[];return l.current=i,c(i.length),o(0),Pa(u,i),()=>Pa(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Ia(e.current,l.current[n]),Pa(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Pa(`${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 Ra({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 da(e,t,n.signal);if(n.signal.aborted)return;let i=await ha(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)(pa,{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)(La,{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 za({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)(pa,{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)(qr,{"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 Ba({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=fa(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)(za,{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)(pa,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ua(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)(Ra,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Va({client:e,seed:t}){return(0,h.jsx)(Ha,{client:e,seed:t},G(t))}function Ha({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)(pa,{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 Ua(e){let t=Ni(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Hi()+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)(Vr,{"aria-hidden":`true`})})]}),t]})}function Ga({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{Ua({...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 Ka(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 qa(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 Ja({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=Ka(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)(Kr,{}),(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)(pa,{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(qa(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 Ya({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)(pa,{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 Xa({client:e,seed:t}){return(0,h.jsx)(Za,{client:e,seed:t},G(t))}function Za({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)(pa,{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)(Ra,{client:e,cursor:ua(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 Qa({client:e,seed:t,onScope:n}){let{t:r}=T(),i=fa(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(za,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ya,{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)(Xa,{client:e,seed:o},o.graph.recordId)]})}function $a({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)(Kr,{"aria-hidden":`true`})})}function eo(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 to(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 no(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)??ro(n.role,n.customType)}return r}function ro(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 io(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function ao(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=no(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=eo(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=>to(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)=>io(e,t,s.current,n),[])}}var oo=(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`})}),so=(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)(mi,{"aria-hidden":`true`}):(0,h.jsx)(si,{"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)(Ra,{compact:!0,client:t,cursor:ua(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)(Ba,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function co({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=ao(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)(oo,{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)(so,{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)(bi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function lo({client:e,seed:t}){let{t:n}=T(),r=fa(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(za,{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)(co,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function uo({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)(gi,{}):(0,h.jsx)(hi,{})}):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 fo=(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)(uo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Hr,{}),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)(Ba,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),po=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function mo({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=T(),s=new Set(e?.projects.flatMap(e=>e.activities.filter(e=>e.sessionId).map(t=>`${e.path}\0${t.sessionId}`))),c=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(po(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length);return(0,h.jsxs)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:a(`Active Pi work`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[e&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`{projects} projects · {sessions} sessions`,{projects:e.projects.length,sessions:s.size})}),(t||e?.completeness===`partial`)&&(0,h.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),i.length>0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Owner work already listed below is not duplicated here.`)}),!e&&!t&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Discovering active work…`)}),e?.completeness===`complete`&&!t&&!e.projects.length&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`No active work observed. Idle terminals and owners are not listed.`)}),c?.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,h.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})]})}var ho=[`queued`,`running`];function go(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 _o=4,vo=1e4;function yo(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?ho.includes(t.status):i-(u.get(e)??0)>=vo}).reverse();for(let n=0;n<a.length;n+=_o){let r=await Promise.all(a.slice(n,n+_o).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+_o<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>ho.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),vo))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function bo({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=yo(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(!ho.includes(e.step.status))-Number(!ho.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>ho.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)(gi,{}),(0,h.jsx)(ui,{}),(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=go(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 xo=2e4;async function So(e,t,n,r){let i=Ci([t],xo);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Co(e){switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function wo(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function To(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Eo(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:sr(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,cr,!e.images?.length),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,images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Do(e.model))}:{}})}function Do(e){return le({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Oo(e,t){return Object.freeze({...e,model:Object.freeze(Do(t))})}function ko(e,t){if(e.model&&G(e.model)!==G(Do(t)))throw new j(`stale`)}function Ao(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&G(e.location)!==G(t?.conversation??null))throw new j(`stale`);let n=vr(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 j(`invalid`);return n}function jo(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 Mo(e){for(let t of e){if(!Mn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function No(e){Mo([e]);let t=new Uint8Array(await e.arrayBuffer());return Pn(t,e.type),t}var Po=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 Fo(e,t,n,r){Mo(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await No(a);if(!r())throw Error(`stale`);let o=Po(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=jn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+jn.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 Io(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>jn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==jn.chunkChars)throw Error(`invalid`)}let i=Nn(n.join(``));return Pn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Lo=1e3,Ro=1e4,zo=4,Bo=e=>e===`queued`||e===`running`,Vo=class extends Error{},Ho=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 Vo?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?Lo:Ro)}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 Vo(`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 Vo(`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 Vo(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Ci([t,r]);try{return await Io(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n){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=Ci([n,a]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},s.signal);if(n.kind!==`conversation-step`||n.part!==o)throw new Vo(`invalid`);return n.item}finally{s.dispose()}}));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>=zo&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Vo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Vo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Uo(e,t,n,r=null){let[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new Ho(e,t,()=>s(n.view()));return n.choose(r),a(n),s(n.view()),()=>n.close()},[e,t,r]),(0,f.useEffect)(()=>{i?.setActive(n)},[i,n]),{...o??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:i?.refresh??Wo,loadEarlier:i?.loadEarlier??Wo,choose:i?.choose??Wo}}function Wo(){}function Go(e,t,n){let r=t.status===`ready`?t.epoch:null,i=t.status===`ready`?t.attachmentVersion:null,[a,o]=(0,f.useState)(0),s=(0,f.useRef)(0),c=(0,f.useMemo)(()=>({client:e,epoch:r,attachment:i,refresh:n,revision:a}),[e,r,i,n,a]),l=(0,f.useRef)(c);l.current=c;let u=(0,f.useRef)(!0);(0,f.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let d=(0,f.useCallback)(()=>u.current&&c.epoch!==null&&l.current===c&&s.current===c.revision,[c]),[p,m]=(0,f.useState)();(0,f.useEffect)(()=>{if(c.epoch===null)return;let t=new AbortController,n=()=>!t.signal.aborted&&d();return e.models(t.signal).then(e=>{n()&&(e.kind===`error`?m({scope:c,error:e.error.code}):e.value.version.epoch===c.epoch?m({scope:c,catalog:e.value}):m({scope:c,error:`stale`}))}).catch(()=>{n()&&m({scope:c,error:`unavailable`})}),()=>t.abort()},[e,c,d]);let h=p?.scope===c&&d()?p:void 0;return{catalog:h?.catalog,error:h?.error,loading:r!==null&&!h,isCurrent:d,reread(){d()&&o(++s.current)},accept(e){return!d()||e.version.epoch!==c.epoch?!1:(m({scope:c,catalog:e}),!0)}}}async function Ko(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 qo(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Jo(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Yo={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Xo={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed. Read the current list before choosing again.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. Read the current model before choosing again.`},Zo=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Qo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function $o(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>K.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function es(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Yo[t.thinking])}`,[e])}function ts({client:e,availability:t,read:n,lastModel:r,locked:i,open:a,onOpenChange:o,onChanged:s,onChosen:c,awaitingSend:l=!1}){let{t:u}=T(),d=es(),p=t.status===`ready`,m=p?t.epoch:null,g=p?t.attachmentVersion:null,{error:_,loading:v,reread:y}=n,b=p?n.catalog:void 0,[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(!1),[E,D]=(0,f.useState)(``),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useRef)(null),j=(0,f.useRef)(null),ee=(0,f.useRef)(o);ee.current=o,(0,f.useEffect)(()=>{S(``)},[e,m,g]);let M=(0,f.useCallback)((e=!0)=>{ee.current(!1),D(``),S(``),e&&k.current?.focus({preventScroll:!0})},[]);(0,f.useEffect)(()=>{if(!a)return;p&&A.current?.focus({preventScroll:!0});let e=e=>{O.current?.contains(e.target)||M(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[a,M,p]);let N=b?.selected??null,P=N??b?.remembered??null,F=(0,f.useMemo)(()=>{let e=E.trim().toLowerCase(),t=new Map;for(let n of b?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[b,E]),I=b?.entries.find(e=>Qo(e,P)),L=p&&!!b&&!v&&!_&&n.isCurrent(),R=async(t,r)=>{if(!L||!n.isCurrent()||!b||!t.api||C||i)return;let a=le({provider:t.provider,model:t.model,api:t.api,thinking:r});if(N&&Zo(N,a))M(),c?.(a);else{w(!0),S(``);try{let t=await e.chooseModel({expected:b.version,choice:a});if(!n.isCurrent())return;if(t.kind===`error`){S(t.error.code),y();return}let r={...b,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;s(),M(),c?.(a)}catch{n.isCurrent()&&(S(`uncertain`),y())}finally{w(!1)}}},z=()=>[...j.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],B=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=z(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?A.current?.focus():t[Math.min(n,t.length-1)]?.focus()},V=t.status===`stopped`||t.status===`not-started`,H=b?null:r,U=V?u(`Models load when you send`):t.status===`preparing`?u(`Preparing execution…`):t.status===`incompatible`?u(`Model selection needs a compatible connection`):t.status===`connecting`?u(`Checking execution state…`):t.status===`unavailable`?u(`Execution state unavailable`):u(v?`Reading models…`:_?`Model list unavailable`:`Choose a model`),te=P?d(P):V&&H?u(`Last used: {model}`,{model:d(H)}):U;return(0,h.jsxs)(`div`,{className:`model-picker`,ref:O,children:[(0,h.jsxs)(`button`,{ref:k,type:`button`,className:`model-trigger${P&&!N||H?` remembered`:``}${b&&!P?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:te}),"aria-haspopup":`dialog`,"aria-expanded":a,title:i?u(`Switch models after the current reply finishes.`):H?u(`Last used model; availability is checked when you send.`):P&&!N?u(`Last used model; it is used again when you send.`):P?`${P.provider}/${P.model} · ${P.api}`:U,onClick:()=>{a?M():(S(``),o(!0))},children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:te}),(0,h.jsx)(gi,{"aria-hidden":`true`})]}),a&&(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.`)}),!p&&(0,h.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:V?u(`Execution is not running. Send prepares it and loads models; opening this panel does not start anything.`):t.status===`preparing`?u(`Execution is being prepared for your Send. Models will load when it is ready.`):t.status===`incompatible`?u(`Reload the page to observe a compatible execution connection before choosing a model.`):u(`Model selection is unavailable until the current conversation and execution state are observed.`)}),H&&(0,h.jsxs)(`p`,{className:`model-popover-lead`,children:[u(`Last used: {model}`,{model:d(H)}),(0,h.jsx)(`br`,{}),u(`Last used model; availability is checked when you send.`)]}),p&&(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(Kr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:A,type:`search`,"aria-label":u(`Search models`),placeholder:u(`Search models…`),value:E,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),z()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),z()[0]?.click())}})]}),p&&(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":u(`Models`),ref:j,onKeyDown:B,children:[v&&(0,h.jsx)(`p`,{className:`model-empty`,role:`status`,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`,n=Qo(e,P);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!L||!t||C||i,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void R(e,$o(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`)}),n&&!N&&(0,h.jsx)(`span`,{className:`model-option-note`,children:u(`Used when you send`)}),n&&(0,h.jsx)(_i,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),b?.status===`complete`&&F.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:E.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.`)})]}),p&&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(Yo[e.level])}),"aria-pressed":P?.thinking===e.level,disabled:!L||!e.selectable||C||i,onClick:()=>void R(I,e.level),children:u(Yo[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[i&&(0,h.jsx)(`p`,{children:u(`Switch models after the current reply finishes.`)}),b?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:u(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!b?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:u(b.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:b.withheld})}),p&&_&&(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:y,children:u(`Read again`)})]}),x&&(0,h.jsx)(`p`,{role:`alert`,children:Xo[x]?u(Xo[x]):u(`The model was not changed ({code}).`,{code:x})}),L&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(C?`Switching model…`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function ns(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 rs({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Gi(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>ns(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)(Vr,{"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 is({active:e,armed:t,known:n,disabled:r,onClick:i}){let{t:a}=T(),o=n?e?`on`:t?`armed`:`off`:`unknown`,s=a(n?e?`Cadence on`:t?`Cadence on next Send`:`Cadence off`:`Cadence state unavailable`);return(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle ${o}`,"aria-label":s,disabled:r||!n,title:a(e?`Cadence mode is on. Click to exit it.`:t?`Your next message turns on Cadence mode. Click to cancel.`:`Turn on Cadence mode: agree on a plan before implementation.`),onClick:i,children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),s]})}function as(){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])];Mo(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 os({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),No(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 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 ss({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 cs({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(ss,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var ls=/^\s{0,3}(`{3,}|~{3,})/,us=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function ds(e){return e.trim()===``}function fs(e){let t=ls.exec(e);return t?t[1]:null}function ps(e){let t=e.split(`
16
+ `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=fs(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=fs(a);if(o&&!ds(a))i=o,r.push(a);else if(ds(a)){let i=e;for(;i<t.length&&ds(t[i]);)i++;if(!(i<t.length&&us.test(t[i]))&&r.length>0){n.push(r.join(`
17
17
  `)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
18
- `),inFence:i!==null}}function ps(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 ms=(0,f.memo)(function({text:e}){return(0,h.jsx)(Da,{text:e})}),hs=22,gs=14,_s=()=>typeof document<`u`&&document.hidden;function vs(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||_s()||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(_s()){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?gs:hs;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=ps(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 ys=600,bs=32;function xs({text:e,inFence:t}){let n=!t&&e.length>=ys,[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>=bs)r();else return o.current=setTimeout(r,bs-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 Ss=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=vs(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>fs(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)(ms,{text:e},t)),a.length>0&&(0,h.jsx)(xs,{text:a,inFence:o},i.length)]})});function Cs(e){let t=e.items.map(e=>({...mr(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 ws(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 Ts(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 Es={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Ds=e=>Object.hasOwn(Es,e)?Es[e]:`other`,Os={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`]},ks=new Set([`read`,`list`,`edit`]);function As(e,t){return ks.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function js({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=Ds(t.name);e.set(n,(e.get(n)??new Set).add(As(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(Os[e][0]):o(Os[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)(hi,{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)(Ns,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(Ms,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function Ms({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=ws(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(ss,{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 Ns({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=ws(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}=Ts(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
19
- `).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)(Ms,{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)(js,{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)(Ms,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(Ss,{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(`
20
- `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function Fs({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 Is=[`queued`,`running`],Ls=e=>Is.includes(e.status);function Rs(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function zs(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function Bs(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=>Rs(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=Rs(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 Vs(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?Rs(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 Hs(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 Us({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=Ls(t),m=p?[a(zs(t)),t.steps.filter(e=>e.status===`running`).map(e=>go(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,Hs(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
21
- `).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(``),Gs(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Ur,{"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 Ws({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan`,"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 this goal and boundary: adaptive implementation, checks, recovery, project knowledge and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(Oa,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:i(`Complete delivery agreement`)}),(0,h.jsx)(Oa,{text:tr(e.plan)})]}),e.delivery&&(0,h.jsx)(Oa,{text:Xn(e.delivery)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),!t&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??i(`Plan approval is currently unavailable.`)}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function Gs(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 Ks(e){return(0,h.jsx)(qs,{...e},e.id)}function qs({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),[c,l]=(0,f.useState)(),u=Gi(e,{kind:`workflow`,id:t},o),d=Gi(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),p=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,m=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,g=c===void 0?m:p,[_,v]=(0,f.useState)(null),y=Gi(e,_?{kind:`workflow-detail`,id:t,stepId:_}:null),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(``),w=m&&[`queued`,`running`].includes(m.status),E=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,f.useEffect)(()=>{m&&![`queued`,`running`].includes(m.status)&&s(0)},[m]),(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:m?.goal??i(`Observing workflow`)}),m&&(0,h.jsxs)(`span`,{className:`ep-state ${m.status}`,children:[a(m.phase),` · `,a(m.status)]})]}),(u.error||d.error||S)&&(0,h.jsxs)(`p`,{role:`alert`,children:[S||u.error||d.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),m?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:m.execution.cwd}),` ·`,` `,m.execution.model?`${m.execution.model.provider}/${m.execution.model.model} · ${m.execution.model.thinking}`:i(`No model`)]}),m?.notice&&(0,h.jsx)(`p`,{children:m.notice}),m?.delivery&&(0,h.jsx)(Js,{delivery:m.delivery}),m&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:ar(m)})]}),m?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:m.mergedCommit})]}),m&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),m&&(m.revision??0)>0&&(0,h.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,m.revision]}),m&&((g?.stepsBefore??0)>0||c!==void 0)&&(0,h.jsxs)(`nav`,{className:`workflow-actions`,children:[(g?.stepsBefore??0)>0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(g?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),g?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,go(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:go(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:()=>v(e.id),children:i(`Read retained step result`)}),_===e.id&&y.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),_===e.id&&y.error&&(0,h.jsx)(`p`,{role:`alert`,children:y.error})]},e.id)),w&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:b,onClick:()=>{m&&(x(!0),Gs(e,m).then(e=>{E.current&&(C(e),u.refresh(),n?.())}).finally(()=>{E.current&&x(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:i(`Observe current state`)})]})}function Js({delivery:e}){let{t,tx:n}=T(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,h.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,h.jsx)(`dl`,{children:r.map(([e,t])=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(`dt`,{children:e}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,h.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,h.jsx)(`p`,{children:e.cleanup.reason}),(0,h.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var Ys=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Xs(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function Zs({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,enabled:s,actionsReady:c=s,prepareForSend:l,legacyWorkspaceId:u,directoryNamespaces:d=[],available:p=s,canInterrupt:m=s,modelEnabled:g=s,onModelChanged:_,onChanged:v,reference:y,onReferenceUsed:x,hidden:S=!1,onOpenAgent:C,onWorkflowRuns:w}){let{t:E,tx:ee}=T(),[D]=(0,f.useState)(()=>jo(n,t,u,...d)),[O,k]=(0,f.useState)(()=>Xs(D)),A=is(),j=A.remove,M=(0,f.useRef)([]),N=(0,f.useRef)(null),[P,F]=(0,f.useState)(()=>Xs(`${D}:mode`)===`cadence`?`cadence`:`chat`),[I,L]=(0,f.useState)(!1),[R,z]=(0,f.useState)(``),[B,V]=(0,f.useState)(()=>Xs(`${D}:pending`)),[H,ne]=(0,f.useState)(!1),[re,U]=(0,f.useState)(!1),[W,ie]=(0,f.useState)(!1),[ae,oe]=(0,f.useState)(0),se=(0,f.useRef)(null),ce=(0,f.useRef)(!1),le=(0,f.useRef)(0),G=(0,f.useRef)(new AbortController),[ue,de]=(0,f.useState)(!1),fe=Gi(e,p&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),pe=fe.value?.kind===`conversation-context`?fe.value.context:void 0,me=!!pe&&!fe.error,K=pe?.cwd??r,he=(0,f.useRef)(null),ge=(0,f.useMemo)(()=>({models:n=>K?e.models(n,{id:t,cwd:K}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>K?e.chooseModel(n,{id:t,cwd:K}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,K]),_e=(0,f.useRef)(o);_e.current=o,(0,f.useEffect)(()=>{me&&K&&_e.current?.({id:t,cwd:K})},[me,t,K]);let q=Uo(e,t,p,i),{turns:ve}=q,ye=q.summary!==void 0,be=Gi(e,p?{kind:`cadence-conversation`,id:t}:null,1e3),J=be.value?.kind===`cadence-conversation`?be.value.state:void 0,xe=J?.enabled===!0,Se=!!J||!!be.error,Ce=!!J&&!be.error&&!J.notice,we=(0,f.useRef)(J);we.current=J;let[Te,Y]=(0,f.useState)(``),Ee=(0,f.useRef)(``),De=Ki(O,xe?`cadence`:P),Oe=s&&!(a&&!q.summary)&&me&&ye&&!q.error&&Se&&!(xe&&(be.error||J?.notice))&&!I&&!re&&!B,ke=q.summary??void 0,X=ke&&(ke.status===`queued`||ke.status===`running`),Ae=!!ke&&ke.status!==`completed`&&!X,[je,Me]=(0,f.useState)(!1),Ne=!!l&&s&&(!!q.error||!!fe.error)&&q.error!==`retired-conversation`&&fe.error!==`retired-conversation`&&!J?.notice&&!X&&!I&&!B&&!re,Pe=(m||!!l)&&me&&ye&&Ce&&!q.error&&!I&&!B&&!X,Fe=!!J?.proposal&&!!ke&&!X&&ke.status!==`unknown`,Ie=ke?.status===`unknown`?E(`The latest turn's outcome is unknown. Approval waits until it is observed.`):c?Ce?X?E(`Wait for the current reply before approving this plan.`):Te?E(`Observing plan approval…`):Oe?void 0:E(`Read the current conversation context before approving this plan.`):E(`Cadence state unavailable`):E(`Read the current execution state before approving this plan.`),Le=(0,f.useRef)(null),Re=(0,f.useRef)(null),ze=(0,f.useRef)(0),Be=(0,f.useRef)(!0),[Ve,He]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!S&&Re.current&&!Be.current&&(Re.current.scrollTop=ze.current)},[S]);let Ue=(0,f.useRef)(!0),We=(0,f.useRef)(``),Ge=(0,f.useRef)(O);(0,f.useEffect)(()=>(Ue.current=!0,G.current.signal.aborted&&(G.current=new AbortController),()=>{Ue.current=!1,G.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${D}:mode`,P)}catch{}},[D,P]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(D,O)}catch{}},[O,D]),(0,f.useEffect)(()=>{try{B?sessionStorage.setItem(`${D}:pending`,B):sessionStorage.removeItem(`${D}:pending`)}catch{}},[D,B]),(0,f.useEffect)(()=>{y&&(k(e=>`${e}${e?`
22
- `:``}@${y}`),x(),Le.current?.focus())},[y,x]),(0,f.useEffect)(()=>{let e=ke?`${ke.leaf}:${ke.status}`:``;e&&We.current!==e&&(We.current=e,v()),Ee.current&&J?.runs.includes(Ee.current)&&(Ee.current=``,Y(``),z(``)),B&&(ke?.live?.commandId===B||q.attempt?.commandId===B||ve.some(e=>e.header.id===B)||q.commands.includes(B))&&(V(``),j(M.current),k(e=>e===Ge.current?``:e),v()),Be.current&&Re.current&&(Re.current.scrollTop=Re.current.scrollHeight)},[ke,ve,B,v,J,q,j]);let Ke=(0,f.useMemo)(()=>ve.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})),[ve]),qe=ao(Re,Ke),Je=(0,f.useRef)(new Map),Ye=(0,f.useCallback)((e,t)=>{Je.current.set(e,t)},[]),{earlier:Xe,loadEarlier:Ze}=q,Qe=()=>{let e=Re.current;e&&!S&&Xe&&e.scrollTop<1200&&Ze()};(0,f.useEffect)(Qe);let $e=ve[0]?.ordinal,et=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Re.current;if(!e)return;let t=et.current;!Ys&&!Be.current&&t.ordinal!==void 0&&$e!==void 0&&$e<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),et.current={ordinal:$e,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${D}:approval`)}catch{}},[D]);let tt=(0,f.useMemo)(()=>[...new Set([...q.runs,...J?.runs??[]])],[q.runs,J?.runs]),Z=JSON.stringify(tt.slice(-4));(0,f.useEffect)(()=>{w?.(JSON.parse(Z))},[Z,w]);let[nt,rt]=(0,f.useState)({terminal:8,browser:8}),it=(0,f.useMemo)(()=>[...new Set([...q.runs.slice(-nt.terminal),...(J?.runs??[]).slice(-nt.browser)])],[q.runs,J?.runs,nt]),at=yo(e,p?it:[],1e3),ot=ve.find(e=>e.header.at>0)?.header.at,st=!Xe&&ve.length>0;(0,f.useEffect)(()=>{if(!p)return;let e=(e,t)=>Vs(e,t,at.runs,at.unreadable,ot,st),t=e(q.runs,nt.terminal),n=e(J?.runs??[],nt.browser);(t!==nt.terminal||n!==nt.browser)&&rt({terminal:t,browser:n})},[p,q.runs,J?.runs,nt,at,ot,st]);let ct=(0,f.useMemo)(()=>Bs(ve,at.runs.values(),Xe),[ve,at.runs,Xe]),lt=[...at.runs.values()].filter(Ls).at(-1),ut=[...at.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{ut&&Be.current&&Re.current&&(Re.current.scrollTop=Re.current.scrollHeight)},[ut]);let dt=t=>(0,h.jsx)(Us,{client:e,run:t,onOpen:()=>C?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{be.refresh(),v()}},t.id),ft=async()=>{if(!J?.proposal){z(E(`No plan is awaiting approval.`));return}if(!c||!Ce||!Oe||X||Te||!Fe)return;let t=J,n=le.current;L(!0),z(``);try{let r=await Go({client:e,state:t,current:()=>Ue.current&&le.current===n&&we.current?.revision===t.revision&&we.current?.enabled===!0,submitting:e=>{Ee.current=e,Y(e)}});if(!Ue.current||le.current!==n)return;r.kind===`error`?(z(r.error.code),Y(``)):k(e=>qo(e)?``:e)}catch(e){Ue.current&&le.current===n&&z(e instanceof Error?e.message:`unavailable`)}finally{Ue.current&&le.current===n&&(L(!1),be.refresh(),q.refresh(),v())}},pt=async(n,r)=>{let i=r?.text??n??O,a=r?.images??(n?[]:A.files),o=r?r.command.kind===`cadence-exit`:xe&&Ko(i);if(!(o?Pe:Oe)&&!Ne||X||!i.trim()&&!a.length)return;if(o&&a.length){z(E(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&xe&&qo(i)){c?await ft():z(E(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let s=Ki(i,P).mode===`cadence`;if(!Ne&&(xe||s)&&!Ce){z(E(`Cadence state unavailable. Observe the conversation before sending.`));return}if(ce.current)return;ce.current=!0,L(!0),z(``);let u=le.current,d=()=>Ue.current&&le.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&V(e)},h=async e=>{l&&(de(!0),await So(l,G.current.signal,e,e=>{p=e}),d()&&(de(!1),oe(e=>e+1)))};try{if(Ne){if(await h(pe?{id:t,cwd:pe.cwd}:void 0),!d())return;q.refresh(),fe.refresh(),be.refresh(),v(),z(E(`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??Eo({id:t,head:q.leaf,text:i,images:a,revision:J?.revision??0,location:pe?{id:t,cwd:pe.cwd}:void 0,model:he.current??pe?.model??void 0,intent:o?`exit`:xe?`message`:s?`enter`:`ordinary`});if(await h(n.location),!d())return;if(n.command.kind===`cadence-exit`){let t=Ao(n);Ge.current=i,f=!0;let r=await To(e,t,m);if(!d())return;r.kind===`error`?z(E(wo(r.error.effect),{code:r.error.code})):(V(``),F(`chat`),k(e=>e===i?``:e)),be.refresh(),q.refresh(),v();return}let c=()=>{se.current=n,U(!0),ne(!0)},l=await e.models(void 0,n.location);if(!d())return;let u=l.kind===`ok`?l.value.selected??l.value.remembered:null;!n.model&&u&&(n=Oo(n,u));let p=n.model??(l.kind===`ok`?l.value.remembered:null);if(l.kind===`ok`&&!l.value.selected&&p){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:l.value.version.epoch,...n.location?{location:n.location,expected:l.value.version,choice:p}:{}});if(!d())return;if(t.kind===`error`){z(t.error.code),c();return}if(l=await e.models(void 0,n.location),!d())return;oe(e=>e+1)}if(l.kind!==`ok`||!l.value.selected){c();return}ko(n,l.value.selected);let g=Ao(n,l.value.version);if(n.images.length){let t=l.value.selected;if(!l.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){z(E(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(g.kind===`cadence-exit`)throw Error(`invalid`);if(g=await Fo(e,g,n.images,d),!d())return}M.current=n.images,Ge.current=i,f=!0;let _=await To(e,g,m);if(!d())return;_.kind===`error`?z(E(wo(_.error.effect),{code:_.error.code})):(j(M.current),k(e=>e===Ge.current?``:e),V(``),g.kind===`cadence-send`&&F(`chat`),gt(null)),be.refresh(),q.refresh(),v()}catch(e){d()&&z(E(f?wo():Co(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{le.current===u&&(ce.current=!1),d()&&(L(!1),de(!1))}},mt=(0,f.useRef)(pt);mt.current=pt,(0,f.useEffect)(()=>{if(W&&Oe&&!X){ie(!1);let e=se.current;se.current=null,e&&mt.current(void 0,e)}},[W,Oe,X]),(0,f.useEffect)(()=>{if(!W)return;let e=setTimeout(()=>{ie(!1),se.current=null},1e4);return()=>clearTimeout(e)},[W]);let ht=async()=>{let n=ke?.live;if(!n||I)return;L(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Ue.current&&(r.kind===`error`&&z(r.error.code),L(!1),q.refresh())},gt=e=>{++le.current,G.current.abort(),G.current=new AbortController,se.current=null,ce.current=!1,U(!1),ie(!1),ne(!1),L(!1),de(!1),q.choose(e),Me(!1)},_t=I||re||!!B||!!X,vt=e=>{if(!_t)try{A.add(e),z(``)}catch(e){z(ee(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:S,"aria-label":E(Ce?xe?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:ke?.title??(a?E(`Discovered session`):q.summary===null?E(`New conversation`):E(`Conversation`))}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:E(Ce?xe?`Cadence on`:`Ordinary`:`Cadence state unavailable`)}),ke&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:ke.origin===`terminal`?E(`Started in the terminal`):E(`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":je,onClick:()=>Me(e=>!e),children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),E(`Branches ({count})`,{count:q.branches})]}),q.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>gt(null),children:E(`Show the latest`)}),lt&&(0,h.jsx)(`span`,{className:`ep-state running`,children:ee(zs(lt))}),ke&&(!lt||Ae||xe&&!X&&!!J?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${ke.status}`,children:xe?X?E(`Discussing`):Ae?ee(ke.status):J?.proposal?E(`Awaiting plan approval`):E(`Ready for conversation`):ee(ke.status)})]})]}),K&&(0,h.jsxs)(`p`,{className:`conversation-cwd`,title:K,children:[E(`Conversation folder:`),` `,(0,h.jsx)(`code`,{children:K})]}),fe.error&&!Ne&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(E,fe.error)}),Ne&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:E(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),ue&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:E(`Preparing execution for this Send…`)}),je&&(0,h.jsx)(ns,{client:e,id:t,leaf:q.leaf,onChoose:gt,onClose:()=>Me(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Re,onScroll:()=>{let e=Re.current;e&&!S&&(ze.current=e.scrollTop,Be.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,He(!Be.current),Qe())},children:[a&&!q.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:E(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!p&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:E(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),q.summary===null&&!q.error&&!a&&(0,h.jsx)(Fs,{hint:E(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),p&&!q.error&&(!ye||ve.length===0&&q.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:E(`Reading this conversation…`)}),ve.length>0&&Xe&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:q.loadingEarlier&&E(`Reading earlier messages…`)}),ct.start.map(dt),Ke.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(oo,{id:e,show:!qe.hidden.has(e),height:qe.placeholder(e,t,320),containerRef:Re,onMeasured:qe.recordMeasured,lazyRef:qe.register(e),children:(0,h.jsx)(Ps,{turn:n,toggled:Je.current.get(e)??null,onToggle:Ye})}),ct.after.get(e)?.map(dt),n.header.entry&&n.ordinal<q.count-1&&!X&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:E(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>gt(n.header.entry),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),E(`Continue from here`)]})]},e)),ct.end.map(dt),q.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":E(`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:ee(q.attempt.status)}),` `,q.attempt.notice?ee(q.attempt.notice):``]})]}),J?.enabled&&J.proposal&&(0,h.jsx)(Ws,{proposal:J.proposal,canApprove:c&&Oe&&Ce&&Fe&&!X&&!Te,approvalHint:Ie,onApprove:()=>void ft()}),J?.enabled&&!J.proposal&&tt.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:E(`Cadence stays on for this conversation until you explicitly exit.`)}),at.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:E(`Workflow activity unavailable; retained work may still be running.`)}),J?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:ee(J.notice)}),[...new Set([R,q.error,be.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(E,e??``)},e)),q.error&&q.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:E(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),B&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[E(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:B}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:E(`Observe current state`)})]}),q.pinned&&!X&&(0,h.jsx)(`p`,{className:`inspector-note`,children:E(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),Ve&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":E(`Latest messages`),onClick:()=>{Re.current&&(Re.current.scrollTop=Re.current.scrollHeight),Be.current=!0},children:(0,h.jsx)(bi,{})}),(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(),vt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),pt()},children:[(0,h.jsx)(`input`,{ref:N,type:`file`,accept:Mn.join(`,`),multiple:!0,hidden:!0,disabled:_t,"aria-label":E(`Add images`),onChange:e=>{vt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),A.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:A.files.map(e=>(0,h.jsx)(as,{file:e,disabled:_t,remove:()=>j([e])},A.key(e)))}),!X&&!Ne&&!Oe&&!ue&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:E(B?`The last Send is not yet confirmed. No message is resent.`:re?`Choose a model; your message is sent right after.`:I?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`)}),(0,h.jsx)(`textarea`,{ref:Le,disabled:I||!!B||re,"aria-label":E(`Message`),value:O,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>k(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),vt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),pt())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:_t,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>N.current?.click(),children:(0,h.jsx)(ti,{"aria-hidden":`true`})}),(0,h.jsx)(rs,{active:xe,armed:De.mode===`cadence`,known:Ce,disabled:xe?!Pe:!!X||I||!!B||re,onClick:()=>{xe?pt(`exit cadence`):De.mode===`cadence`?(F(`chat`),Ki(O,`chat`).mode===`cadence`&&k(De.text)):F(`cadence`)}}),(0,h.jsx)(es,{client:ge,onObserved:e=>{he.current=e.selected?Do(e.selected):e.remembered},enabled:g&&p&&me,locked:!!X,refresh:String(ae),open:H,onOpenChange:e=>{ne(e),e||U(!1)},onChanged:()=>{fe.refresh(),_()},onChosen:e=>{re&&se.current&&(se.current=Oo(se.current,e),U(!1),z(``),ie(!0))},awaitingSend:re}),(0,h.jsx)(`span`,{className:`composer-hint`,children:xe?E(`Cadence stays on. Confirm one plan before implementation.`):De.mode===`cadence`?E(`Your next message turns on Cadence mode.`):``}),X?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:I||!m,onClick:()=>void ht(),children:[(0,h.jsx)(Ur,{}),E(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(xe&&Ko(O)?Pe:Oe)&&!Ne||!O.trim()&&!A.files.length,children:[(0,h.jsx)(vi,{}),E(`Send`)]})]})]})]})}function Qs({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=Gi(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Gi(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)(vi,{})}),(0,h.jsxs)(`span`,{className:`files-path`,title:n?`${n.cwd}${a?` / ${a}`:``}`:void 0,children:[i(`Conversation folder:`),` `,a||n?.cwd||i(`Not observed`)]}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),disabled:!t,onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(qr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(i,d.error)}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[t?!m&&!d.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:i(`Reading files…`)}):null:(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:i(n?`Files are unavailable until the execution state is ready.`:`The conversation folder has not been observed.`)}),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)(ai,{}):(0,h.jsx)(oi,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),disabled:!t||!!d.error,onClick:()=>r(e.path),children:(0,h.jsx)(Jr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void ha(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(fi,{})})]},e.path)),t&&!d.error&&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)(Vr,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(i,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 $s=`未命名章节`;function ec(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 tc(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=ec(r||$s),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||$s}})}function nc(e){return e.length>=2}function rc(e){let t=0,n=0;return e.split(`
23
- `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function ic({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:rc(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 ac({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(`
24
- `);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=tc(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)(Sa,{text:u?g.slice(u.start-1,u.end).join(`
25
- `):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:[nc(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)(ic,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:rc(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 oc({client:e,seed:t}){let{t:n,tx:r}=T(),i=fa(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(za,{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(ua(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)(Ra,{client:e,cursor:a,render:e=>(0,h.jsx)(ac,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var sc=[`contents`,`checks`,`changes`,`reviews`];function cc({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:sc.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)(Ba,{client:e,seed:t}):(0,h.jsx)(oc,{client:e,seed:{...t,reader:i}},i)})]})}var lc={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.`},uc=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function dc(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 fc({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,ee]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(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),O(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&k.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;O({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},P=(0,f.useRef)(N);(0,f.useEffect)(()=>(k.current=!0,P.current(te.current).then(()=>{k.current&&w(!1)}),()=>{k.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||(uc(e)?N(e):O({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&&!uc(n)){O({step:`read`,code:`relative`});return}ee(!0),O(null);let r=n===d?.path?d.path:(await N(n))?.path;if(!k.current)return;if(!r){ee(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),k.current&&a()}catch(e){k.current&&(O({step:`open`,code:e instanceof Error?e.message:`unavailable`}),ee(!1))}return}if(!e.workbenchCommand){O({step:`open`,code:`unavailable`}),ee(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(k.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):(O({step:`open`,code:`unsupported-context`}),ee(!1))}else O({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),ee(!1)}},B=d?dc(d.path,r):void 0,V=y.trim().toLowerCase(),H=d?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],ne=D&&(D.step===`read`&&lc[D.code]?l(lc[D.code]):u(D.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 z(e.path),children:[(0,h.jsx)(ai,{"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)(ni,{"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)(hi,{"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),D?.step===`read`&&O(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),O(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(!_),O(null)},children:(0,h.jsx)(ci,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Kr,{"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)(vi,{}),l(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(e.path),children:[(0,h.jsx)(ai,{}),(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.`)}),ne&&(0,h.jsxs)(`p`,{role:`alert`,children:[ne,D?.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 pc(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 mc({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)(Jr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function hc({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)(gi,{"aria-hidden":`true`}):(0,h.jsx)(hi,{"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 gc({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=pc(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)(hi,{"aria-hidden":`true`}):(0,h.jsx)(gi,{"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)(ui,{"aria-hidden":`true`}):(0,h.jsx)(Xr,{"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 _c({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)(gc,{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)(za,{pager:e,compact:!0})]})}function vc({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,discovery:E,selectedWorkflow:ee,onWorkflow:D,onCancelWorkflow:O}){let{t:k,tx:A}=T(),te=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,j=fa(e,te),M=fa(e,r&&te&&t?{...te,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),N=j.page&&!(`kind`in j.page)?j.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)(_c,{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${ee===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)(Ur,{"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)),ne=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)(Xr,{})}),(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(zs(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:[E&&(0,h.jsx)(mo,{...E,represented:!n&&E.project?[...(S??[]).map(e=>po(E.project,`workflow`,e.id,e.epoch)),...B.flatMap(e=>e.live?[po(E.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(mc,{onConversation:x}),!n&&(0,h.jsxs)(hc,{title:k(`Running work`),count:s?.status===`complete`&&S&&!w&&g?String(P.length+B.length+S.length):k(`Not observed`),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(ne),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)(Ur,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(gc,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(hc,{title:k(`Conversation history`),count:t?j.page&&!(`kind`in j.page)?`${V.length+F.length}${j.page.next||j.canPrevious||_?`+`:``}`:k(`Not observed`):`${V.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[V.map(ne),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)(Xr,{"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)),j.page&&!(`kind`in j.page)&&F.length===0&&V.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(za,{pager:j,compact:!0})]}),!F.some(e=>e.owner.taskId===r)&&I]})]})}var yc=[`queued`,`running`];function bc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Gi(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?yc.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!yc.includes(u.status)&&c(0)},[u]);let m=Gi(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?Cs(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Gi(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)(ui,{"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)(Ks,{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)(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 xc({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)(ai,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(gi,{"aria-hidden":`true`})]})}function Sc({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=T(),o=r||t||n;return!e&&!o?null:(0,h.jsxs)(h.Fragment,{children:[e&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,h.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,h.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,h.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,h.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,h.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function Cc(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Bi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(Oe(n.scope))),n.snapshotSeq&&a.set(`snapshot`,ne(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function wc(){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?Oe(ie(r)):void 0,o=i?ne(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=X(ie(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Tc=`cadence-panel-layout-v1`,Ec={left:260,right:360,navigation:!0,inspector:!1};function Dc(e,t=600){return Math.max(220,Math.min(t,e))}function Oc(e){let t={...Ec};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Dc(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function kc(e,t){let n=e<=900,r=Dc(t.left,e-560),i=Dc(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Dc(e-560-s),rightMaximum:Dc(e-560-a)}}function Ac({side:e,width:t,onResize:n,maximum:r}){let{t:i}=T(),a=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>a.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Dc(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Dc(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Dc(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function jc(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])}function Mc(){let[e,t]=(0,f.useState)(()=>{try{return Oc(localStorage.getItem(Tc))}catch{return Oc(null)}}),[n,r]=(0,f.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=kc(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Tc,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,f.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}var Nc=.4,Pc=1.05;function Fc(e){return Math.min(300,e*.86)}function Ic(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 Rc(e,t){return e===`left`?t:-t}function zc(e,t){return Math.max(-e,Math.min(0,-e+t))}function Bc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Vc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Bc(r*Pc,n,t)>=Nc}var Hc=new Set([`auto`,`scroll`,`overlay`]);function Uc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Hc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Wc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Gc(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=Ic(r.clientX,window.innerWidth,n);i&&!Uc(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=Fc(window.innerWidth),h=m*Pc;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=Rc(r,d);let b=zc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Bc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Vc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Wc(),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 Kc(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 qc=`modulepreload`,Jc=function(e){return`/`+e},Yc={},Xc=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=Jc(t,n),t=s(t),t in Yc)return;Yc[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`:qc,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 Zc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=fa(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)(za,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Qc,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Qc({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 Xc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Kc(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)(Ba,{client:e,seed:t})]})}var $c=[[`tools`,Hr],[`context`,ei],[`timeline`,pi],[`runs`,ii]];function el({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,discovery:o,onOpenService:s,project:c,onChooseFolder:l,onPrepareSend:u,directoryNamespaces:d}){let{t:p,tx:m,locale:g,setLocale:_}=T(),[v]=(0,f.useState)(()=>e??Ri()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[S,C]=(0,f.useState)(!1),[w]=(0,f.useState)(wc),[E,ee]=(0,f.useState)(w?.taskId??null),[D,O]=(0,f.useState)(()=>w?null:Vi()??crypto.randomUUID()),k=Ui(y,D??``),[A,te]=(0,f.useState)(null),[j,M]=(0,f.useState)([]),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(w?`task`:`files`),[L,R]=(0,f.useState)(),[z,B]=(0,f.useState)(),[V,H]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Vi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[ne]=(0,f.useState)(()=>crypto.randomUUID()),re=(0,f.useCallback)(()=>R(void 0),[]),[U,ie]=(0,f.useState)(w?w.scope??{kind:`task`,id:w.taskId}:null),ae=na(c?.id,c?.epoch),oe=!c||ae.readiness===`running`,se=!!c&&(ae.readiness===`stopped`||ae.readiness===`not-started`),ce=(0,f.useRef)(null);oe&&ae.value?.epoch&&(ce.current=ae.value.epoch);let le=!c||!se&&(oe||ce.current!==null),G=aa(v,E?{kind:`task`,id:E}:null,!S&&le,ce.current),ue=(0,f.useRef)(!0);(G.workspace||G.observation||G.error||G.transportStatus===`stale`||G.compatible===!1)&&(ue.current=!1);let de=!!(c&&(ae.value||ae.error)),fe=!S&&!!(G.workspace||de),pe=(0,f.useRef)(null);(G.workspace||ae.value?.workspaceId)&&(pe.current=G.workspace?.workspaceId??ae.value?.workspaceId??null);let me=u?async(e,t,n)=>{let r=await u(e,t,n);if(e.aborted)throw Error(`stale`);ae.prepared(r);let i=G.reconnect();await G.whenReady(r,e,i)}:void 0,K=qi(v.client,fe),he=Gi(v.client,G.workspace&&!S?{kind:`conversation-active`}:null,1e3),ge=he.value?.kind===`conversation-active`?he.value.entries:[],_e=[...ge,...(K.value?.entries??[]).filter(e=>!ge.some(t=>t.id===e.id))],q=Gi(v.client,G.workspace&&!S?{kind:`workflow-active`}:null,2e3),ve=q.value?.kind===`workflow-active`?q.value:void 0,ye=(0,f.useMemo)(()=>[...new Set([...ve?.runs.map(e=>e.id)??[],...j])],[ve,j]),be=Gi(v.client,!c&&G.workspace&&!S?{kind:`projects`}:null),J=V??c?.cwd??(be.value?.kind===`projects`?be.value.entries.find(e=>e.current)?.path:void 0),xe=z?.id===D?z:void 0;(0,f.useEffect)(()=>{xe&&Vi()===xe.id&&history.replaceState({...history.state,cadenceCwd:xe.cwd,cadenceConversationId:xe.id},``,location.href)},[xe]);let Se=D?xe:J?{id:ne,cwd:J}:void 0,Ce=xe?.cwd??J??(be.value?.kind===`projects`?be.value.entries.find(e=>e.current)?.path:void 0)??G.workspace?.rootLabel,we={state:G.observation,transportStatus:G.transportStatus,error:G.error,refresh:G.refresh},Te=we.state?.snapshot.scope.kind===`task`&&we.state.snapshot.scope.id===E?we.state.snapshot.context:void 0,Y=Mc(),{mobile:Ee,overlay:De,closeDrawer:Oe}=Y,ke=(0,f.useRef)(null);Gc({enabled:Ee&&!S,open:De,onOpenChange:Y.setDrawer,container:ke}),jc(ke,De,!S&&!!De,Oe);let[X,Ae]=(0,f.useState)(w?.snapshotSeq),[je,Me]=(0,f.useState)(``),[Ne,Pe]=(0,f.useState)(``),Fe=(0,f.useRef)(null),Ie=(0,f.useRef)(null),Le=()=>{Ie.current&&(Ie.current.open=!1)},[Re,ze]=(0,f.useState)(`messages`),[Be,Ve]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(),[Ke,qe]=(0,f.useState)(w?.cursor),[Je,Ye]=(0,f.useState)(``),[Xe,Ze]=(0,f.useState)([]),[Qe,$e]=(0,f.useState)(new Set),et=(0,f.useRef)(!0),tt=e=>{et.current&&Ze(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)})},Z=(0,f.useRef)(new oa),nt=W({taskId:E,scope:U,selectedSnapshot:X??null,detached:S,attachment:G.attachmentVersion,workspaceContext:G.workspace?.context??null,observationError:G.error??null});Z.current.select(nt),(0,f.useEffect)(()=>(et.current=!0,()=>{et.current=!1,Z.current.depart()}),[]);let rt=e=>{b(``);let t=e??crypto.randomUUID();e||H(Ce??J),te(null),t!==D&&(M([]),R(void 0)),Z.current.depart(),O(t),ee(null),ie(null),Me(``),Pe(``),Ge(void 0),qe(void 0),Ae(void 0),ze(`messages`),I(`files`),Oe(),history.replaceState({cadenceCwd:Ce??J,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let it=(e,t)=>{te(null),M([]),O(null),I(`task`),Me(t??``),Pe(``),Ae(void 0),Z.current.depart(),ee(e),ie({kind:`task`,id:e}),Ge(void 0),qe(void 0),ze(`messages`),Oe(),history.replaceState(null,``,Cc(e))};(0,f.useEffect)(()=>{let e=()=>{let e=wc();if(e)te(null),M([]),O(null),I(`task`),Z.current.depart(),Ae(e.snapshotSeq),Me(``),Pe(``),ee(e.taskId),ie(e.scope??{kind:`task`,id:e.taskId}),Ge(void 0),qe(e.cursor),ze(`messages`),Oe();else{let e=Vi();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&H(t),R(void 0),te(null),M([]),O(e),ee(null),ie(null),I(`files`),Z.current.depart(),Oe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Oe]);let at=(e,t,n)=>{te(null),Ae(t),Pe(n??``),Z.current.depart(),ie(e),Ge(void 0),qe(void 0),ze(`messages`),Oe(),E&&history.replaceState(null,``,Cc(E,void 0,{scope:e,snapshotSeq:t}))},ot=X??we.state?.snapshot.committedSeq??G.workspace?.committedSeq,st=G.workspace?.storeId,ct=U&&st&&ot?{storeId:st,scope:U,snapshotSeq:ot,reader:`messages`,after:null,limit:50}:null,lt=U&&st&&ot?{storeId:st,scope:U,snapshotSeq:ot,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ut=Te?we.state?.snapshot.runs??[]:[],dt=Z.current.ticket(),ft=e=>{tt(e),e.receipt&&Z.current.current(dt)&&G.refresh()},pt=e=>{if(Qe.has(e)||!G.cancelCompatible||!G.activeRuns)return;let t=crypto.randomUUID(),n=G.activeRuns.epoch;$e(t=>new Set(t).add(e)),tt({commandId:t,error:p(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{ft(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:p(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>tt({commandId:t,error:p(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{et.current&&$e(t=>{let n=new Set(t);return n.delete(e),n})})};if(S)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:p(`Detached`)}),(0,h.jsx)(`p`,{children:p(`Accepted service work continues. No Cancel was requested.`)}),Xe.map(e=>(0,h.jsxs)(`p`,{children:[p(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>C(!1),children:p(`Reconnect as a viewer`)})]});let mt=G.activeRuns,ht=mt?.status===`complete`?mt.runs:[],gt=!S&&!G.error&&G.transportStatus===`current`&&(!we.state||we.state.connection===`current`),_t=oe&&gt,vt=ue.current&&!we.state&&!we.error&&!ae.error&&(!c||!ae.value&&ae.readiness===`unknown`||ae.readiness===`running`),yt=S?`Viewer disconnected`:vt?`Connecting…`:c&&ae.readiness===`unknown`?`Project readiness unknown`:c&&ae.readiness===`stale`?`Project observation stale`:se?`Ready to prepare on Send`:gt?G.workspace?we.state?.connection??(E?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(`div`,{className:`app${Y.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":p(`Toggle conversation navigation`),"aria-expanded":Ee?De===`left`:Y.navigation,onClick:()=>Y.toggle(`left`),children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":p(`Workbench projects`),title:p(`Workbench projects`),onClick:n,children:(0,h.jsx)(ai,{})}),(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`}),U&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":p(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Re===`messages`&&!Ke,onClick:()=>{qe(void 0),Ge(void 0),ze(`messages`)},children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),p(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Fe,onKeyDown:e=>{e.key===`Escape`&&Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Re===`messages`?p(`Details`):m(Re),(0,h.jsx)(gi,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[$c.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Re===e,onClick:()=>{qe(void 0),Ge(void 0),ze(e),Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),m(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Export selected scope`),disabled:!ct,onClick:()=>{Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus()),Ue(!0)},children:[(0,h.jsx)(li,{"aria-hidden":`true`}),p(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Copy token-free link`),disabled:!E,onClick:()=>{E&&ha(Cc(E,Ke,U?{scope:U,snapshotSeq:X}:void 0)).then(e=>Ye(e?``:p(`Link copy unavailable.`)))},children:[(0,h.jsx)($r,{"aria-hidden":`true`}),p(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[U&&(0,h.jsx)($a,{disabled:!lt,onOpen:()=>Ve(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>_(g===`zh`?`en`:`zh`),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Ie,onKeyDown:e=>{e.key===`Escape`&&Ie.current&&(Ie.current.open=!1,Ie.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":p(`More`),title:p(`More`),children:(0,h.jsx)(Yr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Observe current state`),onClick:()=>{Le(),G.refresh(),ae.refresh()},children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),p(`Refresh status`)]}),s&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{Le(),s()},children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[p(`Cadence service`),(0,h.jsx)(`small`,{children:p(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Disconnect this page`),title:p(`Return — accepted work continues`),onClick:()=>{Le(),Oe(),Ve(!1),Ue(!1),Z.current.depart(),C(!0)},children:[(0,h.jsx)(Qr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[p(`Disconnect this page`),(0,h.jsx)(`small`,{children:p(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${G.compatible===!1?` warn`:``}`,title:Li?.buildId??p(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:p(`Shared compatibility: {state}.`,{state:G.compatible===void 0?p(`Execution compatibility not observed`):G.compatible?p(`compatible`):p(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:p(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Li?.buildId??p(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":p(`Toggle workspace panels`),"aria-expanded":Ee?De===`right`:Y.inspector,onClick:()=>Y.toggle(`right`),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:p(U&&F===`task`?`History details`:`Files`)})]})]}),!G.workspace&&ht.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":p(`Execution and cancellation`),children:ht.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:[m(e.kind),` `,e.runId,` · `,m(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>it(e.taskId),children:p(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!G.cancelCompatible||Qe.has(e.runId),onClick:()=>pt(e.runId),children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),p(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(Sc,{error:Je,projectObservationError:ae.error,observationError:G.error,unavailable:!vt&&!se&&!_t,onRefresh:()=>{G.refresh(),ae.refresh()}}),(0,h.jsxs)(`div`,{ref:ke,className:`layout`,style:{"--left-w":`${Y.left}px`,"--right-w":`${Y.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":p(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${De?` on`:``}`,onClick:Oe}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${De===`left`?` open`:``}`,"aria-label":p(`Conversation navigation`),tabIndex:-1,inert:Ee?De!==`left`:!Y.navigation||De===`right`,children:[!fe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[o&&(0,h.jsx)(mo,{...o}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:p(vt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),fe&&(0,h.jsx)(vc,{discovery:o,client:v.client,workspace:G.workspace,executionStopped:se,taskId:E,scope:U,runs:ut,snapshot:we.state?.snapshot.committedSeq,activeRuns:G.activeRuns,cancelCompatible:!!G.cancelCompatible,canceling:Qe,onCancel:pt,chats:_e,chatActivityKnown:he.value?.kind===`conversation-active`&&!he.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:p(`Reading conversation history…`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.previous,children:p(`Newer conversations`)}),K.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.next,children:p(`Older conversations`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:K.first,children:p(`Latest conversations`)}),K.error&&(0,h.jsx)(`button`,{type:`button`,onClick:K.refresh,children:p(`Observe current state`)})]}),conversationId:D,onConversation:rt,onNewConversation:()=>rt(),workflows:ve?.runs,workflowLinks:ve?.links,workflowError:!!q.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?rt(t):(te({runId:e.id,stepId:null,label:e.goal}),Oe())},onCancelWorkflow:async e=>{let t=await Gs(v.client,e);t&&Ye(t),q.refresh()},onTask:it,onScope:at}),G.workspace&&(0,h.jsx)(bo,{client:v.client,active:G.activeRuns,taskId:E,runs:ut,snapshot:ot,workflowRuns:ye,selected:A,onOpenWorkflow:e=>{te(e),Oe()},onOpen:(e,t,n,r)=>{it(e),ie({kind:`child`,id:t}),Pe(r),Ae(n),history.replaceState(null,``,Cc(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Ac,{side:`left`,width:Y.left,maximum:Y.leftMaximum,onResize:e=>Y.resize(`left`,e)}),(0,h.jsxs)(`main`,{className:`main`,inert:De!==null,children:[D&&c&&!de&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:p(`Reading this conversation…`)}),A&&(0,h.jsx)(bc,{client:v.client,agent:A,backLabel:p(D?`Back to conversation`:E?`Back to task`:`Back`),onBack:()=>te(null),onOpenAgent:te},`${A.runId}:${A.stepId??``}`),D&&(!c||de)&&(0,h.jsx)(Zs,{client:v.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:J,onLocation:B,hidden:!!A,onOpenAgent:te,onWorkflowRuns:M,workspaceId:c?`checkout:${c.path}`:pe.current??`connecting`,directoryNamespaces:d,legacyWorkspaceId:c?ae.value?.workspaceId??void 0:void 0,prepareForSend:me,actionsReady:oe&&!!G.workspace&&!!G.compatible&&!G.error&&gt,available:fe,canInterrupt:!!G.cancelCompatible,enabled:me?fe:!!G.workspace&&!!G.compatible&&!G.error,modelEnabled:oe&&!!G.compatible&&G.transportStatus===`current`&&!G.error,onModelChanged:()=>{Z.current.depart(),G.refresh(!0),ae.refresh()},onChanged:()=>{K.refresh(),G.refresh()},reference:L,onReferenceUsed:re},`${c?.id??pe.current??`connecting`}:${D}:${k.leaf??``}`),U&&!A&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[U.kind!==`task`&&E&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>it(E,je),children:p(`Back to task`)}),(0,h.jsx)(`h2`,{title:je||U.id,children:U.kind===`task`?je||p(`Task {id}`,{id:U.id.slice(0,8)}):Ne||p(`{kind} {id}`,{kind:m(U.kind),id:U.id.slice(0,8)})}),U.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:p(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[p(`Recorded conversation`),` ·`,` `,p(`snapshot {seq}`,{seq:ot??``})]}),(0,h.jsx)(`code`,{children:U.id}),(0,h.jsx)(`p`,{children:p(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!A,children:[!ct&&(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:G.error?p(`Recorded history could not be read.`):p(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:p(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ct&&Ke?(0,h.jsxs)(`div`,{className:`tab-body`,children:[We&&(We.owner.entity.kind===`task`||We.owner.entity.kind===`message`||We.owner.entity.kind===`tool`)&&(0,h.jsx)(Va,{client:v.client,seed:{storeId:Ke.storeId,scope:Ke.scope,snapshotSeq:Ke.snapshotSeq,kind:We.owner.entity.kind,id:We.owner.entity.id,version:We.owner.entity.version}},`${We.owner.entity.id}:${We.owner.entity.version}`),(0,h.jsx)(Ra,{client:v.client,cursor:Ke,highlight:We?.range},`${Ke.recordId}:${Ke.recordVersion}`)]}):ct&&(0,h.jsxs)(`div`,{className:Re===`messages`||Re===`tools`?`tab-body transcript-body`:`tab-body`,children:[Re===`messages`&&(0,h.jsx)(lo,{client:v.client,seed:ct}),Re===`tools`&&(0,h.jsx)(tl,{client:v.client,seed:ct}),Re===`context`&&(0,h.jsx)(Ba,{client:v.client,seed:ct}),Re===`timeline`&&(0,h.jsx)(Zc,{client:v.client,seed:ct,onSearch:()=>Ve(!0)}),Re===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:p(`Runs in the current snapshot`)}),ut.length>0?ut.map(e=>(0,h.jsx)(Ya,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Te&&we.state?p(`No owner run projection in this snapshot.`):p(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:p(`Retained runs`)}),(0,h.jsx)(Qa,{client:v.client,seed:{...ct,scope:{kind:`task`,id:E??ct.scope.id}},onScope:at},E)]})]},`${U?.kind}:${U?.id}:${X??`current`}`)]}),G.workspace&&Xe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Xe.map(e=>(0,h.jsx)(sa,{client:v.client,value:e,onChange:tt},e.commandId))})]}),(0,h.jsx)(Ac,{side:`right`,width:Y.right,maximum:Y.rightMaximum,onResize:e=>Y.resize(`right`,e)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${De===`right`?` open`:``}`,"aria-label":p(`Files and history drawer`),tabIndex:-1,inert:Ee?De!==`right`:!Y.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":p(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":F===`files`||!U,onClick:()=>I(`files`),children:[(0,h.jsx)(ai,{}),p(`Files`)]}),U&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":F===`task`,disabled:!ct,onClick:()=>I(`task`),children:[(0,h.jsx)(ei,{}),p(`History details`)]})]}),F===`files`||!U?(0,h.jsx)(Qs,{location:Se,client:v.client,enabled:!!G.workspace&&!!Se,onReference:e=>{D||rt(ne);let t=!D&&Se?`${Se.cwd.replace(/[\\/]+$/,``)}${Se.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;R(t),Oe()}},Se?.cwd??`owner`):ct?(0,h.jsx)(cc,{client:v.client,seed:{...ct,scope:{kind:`task`,id:E??ct.scope.id}}},E):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:G.error?p(`Recorded history could not be read.`):p(`Reading recorded history…`)})]})})]}),(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:p(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${vt?`busy`:se?``:!_t||!G.workspace?`error`:we.transportStatus===`current`?we.state?we.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),m(yt)]}),c&&(0,h.jsx)(`span`,{className:`status-item faint`,children:p(`Execution service: {status}`,{status:m(ae.readiness)})}),mt?.status===`complete`?ht.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:p(_t?ht.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:ht.length})}):!vt&&!se&&(0,h.jsx)(`span`,{className:`status-item faint`,children:p(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(G.workspace||c)&&(0,h.jsx)(xc,{path:Ce,onClick:()=>l?l(Ce):P(``)}),G.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:p(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),N!==null&&G.workspace&&(0,h.jsx)(fc,{onOpen:t,projects:i??(be.value?.kind===`projects`?be.value.entries:[]),client:v.client,current:Ce??G.workspace.rootLabel,initial:N||void 0,home:r,epoch:G.workspace.epoch,onClose:()=>P(null)}),Be&&lt&&(0,h.jsx)(Ja,{client:v.client,seed:lt,onClose:()=>Ve(!1),onHit:e=>{Ge(e),qe(e.cursor),E&&history.replaceState(null,``,Cc(E,e.cursor,U?{scope:U,snapshotSeq:X}:void 0))}}),He&&lt&&(0,h.jsx)(Ga,{request:{storeId:lt.storeId,scope:lt.scope,snapshotSeq:lt.snapshotSeq,format:`ndjson`},onClose:()=>Ue(!1)})]})}function tl({client:e,seed:t}){let n=fa(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(za,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(fo,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var nl=`cadence-last-project`;function rl(){try{let e=localStorage.getItem(nl);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function il(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(nl,e)}catch{}}function al(e){let t=rl();return t?e.projects.find(e=>e.id===t):void 0}async function ol(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 Ji(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function sl(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Ji(t);if(!t.ok)throw Error(Yi(n));return yn(n)}async function cl(e,t,n,r,i){if(!Li)throw Error(`unsupported-context`);let a={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`,...Li})},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await Ji(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Yi(c));let l=pn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function ll(e,t){let n=await sl(t);return cl(`/workbench/v1/select`,{path:e},n,t)}async function ul(e,t,n,r){let i=await sl(t),a=i.projects.find(t=>t.id===e.id);if(!a||a.path!==e.path||a.cwd!==e.cwd)throw Error(`stale`);let o=await cl(`/workbench/v1/prepare-send`,{projectId:e.id,commandId:crypto.randomUUID(),...n?{location:n}:{}},i,t,()=>r?.(`dispatched`));if(!o.project.epoch||o.project.id!==e.id||o.project.path!==e.path||o.project.cwd!==e.cwd)throw Error(`stale`);return r?.(`confirmed`),o}async function dl(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await ll(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var fl=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function pl(e){let t=z(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:V(t.id),source:I(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:nn(t.sessionId),cwd:M(t.cwd,4096,!0),leaf:t.leaf===null?null:M(t.leaf,128,!0),history:I(t.history,[`shared`,`unavailable`]),phase:I(t.phase,fl),freshness:I(t.freshness,[`current`,`stale`,`unknown`]),observedAt:P(t.observedAt,0),epoch:t.epoch===null?null:V(t.epoch),instance:t.instance===null?null:V(t.instance),executionCwd:t.executionCwd===null?null:M(t.executionCwd,4096,!0)}}function ml(e){let t=z(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:L(t.kind,`activity-discovery`),epoch:V(t.epoch),observedAt:P(t.observedAt,0),completeness:I(t.completeness,[`complete`,`partial`]),unavailable:P(t.unavailable,0,1e4),projects:B(t.projects,128,e=>{let t=z(e,[`path`,`activities`]);return{path:M(t.path,4096,!0),activities:B(t.activities,256,pl)}})}}async function hl(e){if(!Li)throw Error(`unsupported-context`);let t=Ci([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal,headers:{"X-Cadence-Build":JSON.stringify({kind:`browser`,...Li})}}),n=await Ji(e);if(!e.ok)throw Error(Yi(n));return ml(n)}finally{t.dispose()}}function gl(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function _l(e,t,n,r=hl){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?gl(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function vl(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return _l(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}var yl=`cadence-recovery-dismissed`,bl={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.`},xl={"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 Sl(){try{let e=JSON.parse(localStorage.getItem(yl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Cl(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function wl({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Sl),[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(yl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:Cl(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(bl[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(xl[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Tl={restart:18e4,upgrade:12e5},El=1e3,Dl={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},Ol=e=>e instanceof Error?e.message:`unavailable`;function kl(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(Dl[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 Al(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function jl(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function Ml({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,ee]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return Zi(e.signal).then(a,t=>{e.signal.aborted||s(Ol(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>Tl[e.action])return w(`timeout`);try{let t=await Zi(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,El)};return r=setTimeout(i,El),()=>{n.abort(),clearTimeout(r)}},[v]);let D=()=>{l(`checking`),Qi().then(l,()=>l(`failed`)).finally(()=>ee(e=>e+1))},O=n=>{i&&(_(!0),s(``),$i({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(Ol(e)),m(!1),ee(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`&&Al(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:Tl[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):kl(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(`The package manager 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:()=>O(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let k=i&&c&&typeof c==`object`?An(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:jl(r,i.upgrade)}),(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:kl(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(`Update information is unavailable for this installation.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:D,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):k?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Dn(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(yi,{"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 installation requires a manual update using its original installation method.`,{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)(qr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Nl({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s,discovery:c}){let{t:l,locale:u,setLocale:d}=T(),p=Mc(),{mobile:m,overlay:g,closeDrawer:_}=p,v=(0,f.useRef)(null);Gc({enabled:m,open:g,onOpenChange:p.setDrawer,container:v}),jc(v,g,!!g,_);let y=e=>{_(),i(e)},b=e=>{_(),a?a(e):i(e)},x=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${p.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":l(`Toggle conversation navigation`),"aria-expanded":m?g===`left`:p.navigation,onClick:()=>p.toggle(`left`),children:(0,h.jsx)(Zr,{"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":l(`Cadence service`),"data-tip":l(`Cadence service`),onClick:o,children:(0,h.jsx)(Gr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:u===`zh`?`en`:`zh-CN`,onClick:()=>d(u===`zh`?`en`:`zh`),"aria-label":u===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:u===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":l(`Toggle workspace panels`),"aria-expanded":m?g===`right`:p.inspector,onClick:()=>p.toggle(`right`),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:v,style:{"--left-w":`${p.left}px`,"--right-w":`${p.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":l(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${g?` on`:``}`,onClick:_}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${g===`left`?` open`:``}`,"aria-label":l(`Conversation navigation`),tabIndex:-1,inert:m?g!==`left`:!p.navigation||g===`right`,children:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[c&&(0,h.jsx)(mo,{...c}),(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:l(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?l(`Returning to your last project {name}…`,{name:x(n.path)}):n?.status===`unavailable`?l(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:x(n.path)}):t.length?l(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):l(`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:()=>b(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(ai,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:x(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?l(`Selecting folder…`):t})]})]},t))]})]})]})}),(0,h.jsx)(`main`,{className:`main`,inert:g!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":l(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Fs,{hint:l(`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:()=>y(),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),l(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":l(`Message`),rows:3,placeholder:l(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:l(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(vi,{"aria-hidden":`true`}),l(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${g===`right`?` open`:``}`,"aria-label":l(`Files`),tabIndex:-1,inert:m?g!==`right`:!p.inspector,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),l(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`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:l(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(xc,{disabled:!e,onClick:()=>y()})})]})]})}function Pl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Bi),[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.useCallback)(()=>g(e=>e+1),[]),S=vl(t?.epoch,x),C=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>C.current?.abort(),[]);let w=(0,f.useRef)(new Map),E=(0,f.useRef)(!r),ee=(0,f.useRef)(null),D=(0,f.useCallback)(()=>{ee.current&&(ee.current.abort(),ee.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 Ji(t);t.status===400&&Yi(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(Yi(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{C.current?.abort(),D(),b(null),i(Bi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[D]),(0,f.useEffect)(()=>{if(!t||!E.current)return;E.current=!1;let e=al(t);if(!e)return;let n=new AbortController;ee.current=n,b({status:`checking`,path:e.cwd}),ol(e.id,n.signal).then(t=>{n.signal.aborted||(ee.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let O=(0,f.useCallback)((e,n)=>{D(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&w.current.set(r,window.location.hash),history.pushState({cadenceCwd:n?.cwd??e?.cwd,cadenceConversationId:n?.sessionId},``,e?`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:w.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,D,t]),j=(0,f.useCallback)(async e=>{C.current?.abort();let t=new AbortController;C.current=t;let r=await ll(e,t.signal);t.signal.aborted||(n(r.entry),O(r.project))},[O]),M=t?{value:S.value,error:S.error,opening:!!s,project:t.projects.find(e=>e.id===r)?.path,onOpen:(e,t)=>{C.current?.abort(),D();let r=new AbortController;C.current=r,c(t.cwd),u(``),dl(e,t,r.signal).then(e=>{r.signal.aborted||(n(e.entry),O(e.project,t))}).catch(e=>{r.signal.aborted||u(e instanceof Error?e.message:`unavailable`)}).finally(()=>{C.current===r&&c(null)})}}:void 0,N=async(e,i,a)=>{let o=t?.projects.find(e=>e.id===r);if(!o)throw Error(`unavailable`);let s=await ul(o,e,i,a);if(e.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},P=(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 Ji(n);if(!n.ok){let e=Yi(r);return{kind:`error`,error:te(k.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Dr(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),F=(0,f.useMemo)(()=>r?Ri(r):void 0,[r]),I=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{I&&il(I.id)},[I]),t===null)return(0,h.jsx)(el,{});let L=t&&_&&(0,h.jsx)(Ml,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),R=()=>v(!0),z=t&&a!==null&&(0,h.jsx)(fc,{selectOnly:!0,client:P,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:j});return t&&I&&F?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(el,{api:F,project:I,directoryNamespaces:t?.projects.filter(e=>e.path===I.path).map(e=>e.id).sort(),discovery:M,onPrepareSend:N,onChooseFolder:e=>{C.current?.abort(),o(e??I.cwd)},onOpenProject:j,onWorkbenchHome:()=>O(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsxs)(h.Fragment,{children:[` `,l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(wl,{notices:t.recoveries,project:I.path}),` `]}),onOpenService:R},I.id),L,z]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Nl,{discovery:M,ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?R:void 0,onOpenFolder:e=>{D(),u(``),C.current?.abort(),o(e??t?.home??``)},onOpenProject:t=>{s||(D(),u(``),c(t),j(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)(wl,{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&&!I&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),z,L]})}function Fl(){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 Il=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Fl,{}):this.props.children}},Ll=document.getElementById(`root`);if(!Ll)throw Error(`Application root unavailable`);(0,p.createRoot)(Ll).render((0,h.jsx)(E,{children:(0,h.jsx)(Il,{children:(0,h.jsx)(Pl,{})})}));export{Xc as t};
18
+ `),inFence:i!==null}}function ms(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 hs=(0,f.memo)(function({text:e}){return(0,h.jsx)(Da,{text:e})}),gs=22,_s=14,vs=()=>typeof document<`u`&&document.hidden;function ys(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||vs()||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(vs()){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?_s:gs;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=ms(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 bs=600,xs=32;function Ss({text:e,inFence:t}){let n=!t&&e.length>=bs,[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>=xs)r();else return o.current=setTimeout(r,xs-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 Cs=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=ys(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>ps(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)(hs,{text:e},t)),a.length>0&&(0,h.jsx)(Ss,{text:a,inFence:o},i.length)]})});function ws(e){let t=e.items.map(e=>({...mr(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 Ts(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 Es(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 Ds={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Os=e=>Object.hasOwn(Ds,e)?Ds[e]:`other`,ks={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`]},As=new Set([`read`,`list`,`edit`]);function js(e,t){return As.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function Ms({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(js(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(ks[e][0]):o(ks[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)(hi,{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)(Ps,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(Ns,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function Ns({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=Ts(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(cs,{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 Ps({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=Ts(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 Fs=(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}=Es(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
19
+ `).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)(Ns,{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)(Ms,{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)(Ns,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(Cs,{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(`
20
+ `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function Is({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 Ls=[`queued`,`running`],Rs=e=>Ls.includes(e.status);function zs(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function Bs(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function Vs(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=>zs(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=zs(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 Hs(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?zs(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 Us(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 Ws({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=Rs(t),m=p?[a(Bs(t)),t.steps.filter(e=>e.status===`running`).map(e=>go(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,Us(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
21
+ `).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(``),Ks(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Ur,{"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 Gs({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan`,"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 this goal and boundary: adaptive implementation, checks, recovery, project knowledge and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(Oa,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:i(`Complete delivery agreement`)}),(0,h.jsx)(Oa,{text:tr(e.plan)})]}),e.delivery&&(0,h.jsx)(Oa,{text:Xn(e.delivery)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),!t&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??i(`Plan approval is currently unavailable.`)}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function Ks(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 qs(e){return(0,h.jsx)(Js,{...e},e.id)}function Js({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),[c,l]=(0,f.useState)(),u=Gi(e,{kind:`workflow`,id:t},o),d=Gi(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),p=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,m=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,g=c===void 0?m:p,[_,v]=(0,f.useState)(null),y=Gi(e,_?{kind:`workflow-detail`,id:t,stepId:_}:null),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(``),w=m&&[`queued`,`running`].includes(m.status),E=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,f.useEffect)(()=>{m&&![`queued`,`running`].includes(m.status)&&s(0)},[m]),(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:m?.goal??i(`Observing workflow`)}),m&&(0,h.jsxs)(`span`,{className:`ep-state ${m.status}`,children:[a(m.phase),` · `,a(m.status)]})]}),(u.error||d.error||S)&&(0,h.jsxs)(`p`,{role:`alert`,children:[S||u.error||d.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),m?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:m.execution.cwd}),` ·`,` `,m.execution.model?`${m.execution.model.provider}/${m.execution.model.model} · ${m.execution.model.thinking}`:i(`No model`)]}),m?.notice&&(0,h.jsx)(`p`,{children:m.notice}),m?.delivery&&(0,h.jsx)(Ys,{delivery:m.delivery}),m&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:ar(m)})]}),m?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:m.mergedCommit})]}),m&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),m&&(m.revision??0)>0&&(0,h.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,m.revision]}),m&&((g?.stepsBefore??0)>0||c!==void 0)&&(0,h.jsxs)(`nav`,{className:`workflow-actions`,children:[(g?.stepsBefore??0)>0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(g?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),g?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,go(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:go(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:()=>v(e.id),children:i(`Read retained step result`)}),_===e.id&&y.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),_===e.id&&y.error&&(0,h.jsx)(`p`,{role:`alert`,children:y.error})]},e.id)),w&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:b,onClick:()=>{m&&(x(!0),Ks(e,m).then(e=>{E.current&&(C(e),u.refresh(),n?.())}).finally(()=>{E.current&&x(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:i(`Observe current state`)})]})}function Ys({delivery:e}){let{t,tx:n}=T(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,h.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,h.jsx)(`dl`,{children:r.map(([e,t])=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(`dt`,{children:e}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,h.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,h.jsx)(`p`,{children:e.cleanup.reason}),(0,h.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var Xs=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Zs(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function Qs({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,enabled:s,actionsReady:c=s,prepareForSend:l,legacyWorkspaceId:u,directoryNamespaces:d=[],available:p=s,canInterrupt:m=s,modelAvailability:g,onModelChanged:_,onChanged:v,reference:y,onReferenceUsed:x,hidden:S=!1,onOpenAgent:C,onWorkflowRuns:w}){let{t:E,tx:D}=T(),[O]=(0,f.useState)(()=>jo(n,t,u,...d)),[k,A]=(0,f.useState)(()=>Zs(O)),j=as(),M=j.remove,N=(0,f.useRef)([]),P=(0,f.useRef)(null),[F,I]=(0,f.useState)(()=>Zs(`${O}:mode`)===`cadence`?`cadence`:`chat`),[L,R]=(0,f.useState)(!1),[z,B]=(0,f.useState)(``),[V,H]=(0,f.useState)(()=>Zs(`${O}:pending`)),[U,te]=(0,f.useState)(!1),[ne,W]=(0,f.useState)(!1),[G,re]=(0,f.useState)(!1),[ie,ae]=(0,f.useState)(0),oe=(0,f.useRef)(null),se=(0,f.useRef)(!1),ce=(0,f.useRef)(0),K=(0,f.useRef)(new AbortController),[le,ue]=(0,f.useState)(!1),de=Gi(e,p&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),fe=de.value?.kind===`conversation-context`?de.value.context:void 0,pe=!!fe&&!de.error,q=fe?.cwd??r,me=(0,f.useMemo)(()=>({models:n=>q?e.models(n,{id:t,cwd:q}):Promise.resolve({kind:`error`,error:ee(`unavailable`)}),chooseModel:n=>q?e.chooseModel(n,{id:t,cwd:q}):Promise.resolve({kind:`error`,error:ee(`unavailable`)})}),[e,t,q]),he=le?{status:`preparing`}:g.status===`ready`&&(!p||!pe)?{status:de.error?`unavailable`:`connecting`}:g,ge=Go(me,he,`${ie}:${fe?.revision??`unobserved`}`),_e=e=>{e?ge.reread():W(!1),te(e)},ve=(0,f.useRef)(o);ve.current=o,(0,f.useEffect)(()=>{pe&&q&&ve.current?.({id:t,cwd:q})},[pe,t,q]);let J=Uo(e,t,p,i),{turns:ye}=J,be=J.summary!==void 0,xe=Gi(e,p?{kind:`cadence-conversation`,id:t}:null,1e3),Y=xe.value?.kind===`cadence-conversation`?xe.value.state:void 0,Se=Y?.enabled===!0,Ce=!!Y||!!xe.error,we=!!Y&&!xe.error&&!Y.notice,X=(0,f.useRef)(Y);X.current=Y;let[Te,Ee]=(0,f.useState)(``),De=(0,f.useRef)(``),Oe=Ki(k,Se?`cadence`:F),ke=s&&!(a&&!J.summary)&&pe&&be&&!J.error&&Ce&&!(Se&&(xe.error||Y?.notice))&&!L&&!ne&&!V,Ae=J.summary??void 0,je=Ae&&(Ae.status===`queued`||Ae.status===`running`),Me=!!Ae&&Ae.status!==`completed`&&!je,[Ne,Pe]=(0,f.useState)(!1),Fe=!!l&&s&&(!!J.error||!!de.error)&&J.error!==`retired-conversation`&&de.error!==`retired-conversation`&&!Y?.notice&&!je&&!L&&!V&&!ne,Ie=(m||!!l)&&pe&&be&&we&&!J.error&&!L&&!V&&!je,Le=!!Y?.proposal&&!!Ae&&!je&&Ae.status!==`unknown`,Re=Ae?.status===`unknown`?E(`The latest turn's outcome is unknown. Approval waits until it is observed.`):c?we?je?E(`Wait for the current reply before approving this plan.`):Te?E(`Observing plan approval…`):ke?void 0:E(`Read the current conversation context before approving this plan.`):E(`Cadence state unavailable`):E(`Read the current execution state before approving this plan.`),ze=(0,f.useRef)(null),Be=(0,f.useRef)(null),Ve=(0,f.useRef)(0),He=(0,f.useRef)(!0),[Ue,We]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!S&&Be.current&&!He.current&&(Be.current.scrollTop=Ve.current)},[S]);let Ge=(0,f.useRef)(!0),Ke=(0,f.useRef)(``),qe=(0,f.useRef)(k);(0,f.useEffect)(()=>(Ge.current=!0,K.current.signal.aborted&&(K.current=new AbortController),()=>{Ge.current=!1,K.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${O}:mode`,F)}catch{}},[O,F]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(O,k)}catch{}},[k,O]),(0,f.useEffect)(()=>{try{V?sessionStorage.setItem(`${O}:pending`,V):sessionStorage.removeItem(`${O}:pending`)}catch{}},[O,V]),(0,f.useEffect)(()=>{y&&(A(e=>`${e}${e?`
22
+ `:``}@${y}`),x(),ze.current?.focus())},[y,x]),(0,f.useEffect)(()=>{let e=Ae?`${Ae.leaf}:${Ae.status}`:``;e&&Ke.current!==e&&(Ke.current=e,v()),De.current&&Y?.runs.includes(De.current)&&(De.current=``,Ee(``),B(``)),V&&(Ae?.live?.commandId===V||J.attempt?.commandId===V||ye.some(e=>e.header.id===V)||J.commands.includes(V))&&(H(``),M(N.current),A(e=>e===qe.current?``:e),v()),He.current&&Be.current&&(Be.current.scrollTop=Be.current.scrollHeight)},[Ae,ye,V,v,Y,J,M]);let Je=(0,f.useMemo)(()=>ye.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})),[ye]),Ye=ao(Be,Je),Xe=(0,f.useRef)(new Map),Ze=(0,f.useCallback)((e,t)=>{Xe.current.set(e,t)},[]),{earlier:Qe,loadEarlier:$e}=J,et=()=>{let e=Be.current;e&&!S&&Qe&&e.scrollTop<1200&&$e()};(0,f.useEffect)(et);let tt=ye[0]?.ordinal,Z=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Be.current;if(!e)return;let t=Z.current;!Xs&&!He.current&&t.ordinal!==void 0&&tt!==void 0&&tt<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Z.current={ordinal:tt,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${O}:approval`)}catch{}},[O]);let nt=(0,f.useMemo)(()=>[...new Set([...J.runs,...Y?.runs??[]])],[J.runs,Y?.runs]),rt=JSON.stringify(nt.slice(-4));(0,f.useEffect)(()=>{w?.(JSON.parse(rt))},[rt,w]);let[it,at]=(0,f.useState)({terminal:8,browser:8}),ot=(0,f.useMemo)(()=>[...new Set([...J.runs.slice(-it.terminal),...(Y?.runs??[]).slice(-it.browser)])],[J.runs,Y?.runs,it]),st=yo(e,p?ot:[],1e3),ct=ye.find(e=>e.header.at>0)?.header.at,lt=!Qe&&ye.length>0;(0,f.useEffect)(()=>{if(!p)return;let e=(e,t)=>Hs(e,t,st.runs,st.unreadable,ct,lt),t=e(J.runs,it.terminal),n=e(Y?.runs??[],it.browser);(t!==it.terminal||n!==it.browser)&&at({terminal:t,browser:n})},[p,J.runs,Y?.runs,it,st,ct,lt]);let ut=(0,f.useMemo)(()=>Vs(ye,st.runs.values(),Qe),[ye,st.runs,Qe]),dt=[...st.runs.values()].filter(Rs).at(-1),ft=[...st.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{ft&&He.current&&Be.current&&(Be.current.scrollTop=Be.current.scrollHeight)},[ft]);let pt=t=>(0,h.jsx)(Ws,{client:e,run:t,onOpen:()=>C?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{xe.refresh(),v()}},t.id),mt=async()=>{if(!Y?.proposal){B(E(`No plan is awaiting approval.`));return}if(!c||!we||!ke||je||Te||!Le)return;let t=Y,n=ce.current;R(!0),B(``);try{let r=await Ko({client:e,state:t,current:()=>Ge.current&&ce.current===n&&X.current?.revision===t.revision&&X.current?.enabled===!0,submitting:e=>{De.current=e,Ee(e)}});if(!Ge.current||ce.current!==n)return;r.kind===`error`?(B(r.error.code),Ee(``)):A(e=>Jo(e)?``:e)}catch(e){Ge.current&&ce.current===n&&B(e instanceof Error?e.message:`unavailable`)}finally{Ge.current&&ce.current===n&&(R(!1),xe.refresh(),J.refresh(),v())}},ht=async(n,r)=>{let i=r?.text??n??k,a=r?.images??(n?[]:j.files),o=r?r.command.kind===`cadence-exit`:Se&&qo(i);if(!(o?Ie:ke)&&!Fe||je||!i.trim()&&!a.length)return;if(o&&a.length){B(E(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Se&&Jo(i)){c?await mt():B(E(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let s=Ki(i,F).mode===`cadence`;if(!Fe&&(Se||s)&&!we){B(E(`Cadence state unavailable. Observe the conversation before sending.`));return}if(se.current)return;se.current=!0,R(!0),B(``);let u=ce.current,d=()=>Ge.current&&ce.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&H(e)},h=async e=>{l&&(ue(!0),await So(l,K.current.signal,e,e=>{p=e}),d()&&(ue(!1),ae(e=>e+1)))};try{if(Fe){if(await h(fe?{id:t,cwd:fe.cwd}:void 0),!d())return;J.refresh(),de.refresh(),xe.refresh(),v(),B(E(`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??Eo({id:t,head:J.leaf,text:i,images:a,revision:Y?.revision??0,location:fe?{id:t,cwd:fe.cwd}:void 0,model:ge.catalog?.selected?Do(ge.catalog.selected):ge.catalog?.remembered??fe?.model??void 0,intent:o?`exit`:Se?`message`:s?`enter`:`ordinary`});if(await h(n.location),!d())return;if(n.command.kind===`cadence-exit`){let t=Ao(n);qe.current=i,f=!0;let r=await To(e,t,m);if(!d())return;r.kind===`error`?B(E(wo(r.error.effect),{code:r.error.code})):(H(``),I(`chat`),A(e=>e===i?``:e)),xe.refresh(),J.refresh(),v();return}let c=()=>{oe.current=n,W(!0),_e(!0)},l=await e.models(void 0,n.location);if(!d())return;let u=l.kind===`ok`?l.value.selected??l.value.remembered:null;!n.model&&u&&(n=Oo(n,u));let p=n.model??(l.kind===`ok`?l.value.remembered:null);if(l.kind===`ok`&&!l.value.selected&&p){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:l.value.version.epoch,...n.location?{location:n.location,expected:l.value.version,choice:p}:{}});if(!d())return;if(t.kind===`error`){B(t.error.code),c();return}if(l=await e.models(void 0,n.location),!d())return;ae(e=>e+1)}if(l.kind!==`ok`||!l.value.selected){c();return}ko(n,l.value.selected);let g=Ao(n,l.value.version);if(n.images.length){let t=l.value.selected;if(!l.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){B(E(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(g.kind===`cadence-exit`)throw Error(`invalid`);if(g=await Fo(e,g,n.images,d),!d())return}N.current=n.images,qe.current=i,f=!0;let _=await To(e,g,m);if(!d())return;_.kind===`error`?B(E(wo(_.error.effect),{code:_.error.code})):(M(N.current),A(e=>e===qe.current?``:e),H(``),g.kind===`cadence-send`&&I(`chat`),vt(null)),xe.refresh(),J.refresh(),v()}catch(e){d()&&B(E(f?wo():Co(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{ce.current===u&&(se.current=!1),d()&&(R(!1),ue(!1))}},gt=(0,f.useRef)(ht);gt.current=ht,(0,f.useEffect)(()=>{if(G&&ke&&!je){re(!1);let e=oe.current;oe.current=null,e&&gt.current(void 0,e)}},[G,ke,je]),(0,f.useEffect)(()=>{if(!G)return;let e=setTimeout(()=>{re(!1),oe.current=null},1e4);return()=>clearTimeout(e)},[G]);let _t=async()=>{let n=Ae?.live;if(!n||L)return;R(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Ge.current&&(r.kind===`error`&&B(r.error.code),R(!1),J.refresh())},vt=e=>{++ce.current,K.current.abort(),K.current=new AbortController,oe.current=null,se.current=!1,W(!1),re(!1),te(!1),R(!1),ue(!1),J.choose(e),Pe(!1)},yt=L||ne||!!V||!!je,bt=e=>{if(!yt)try{j.add(e),B(``)}catch(e){B(D(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:S,"aria-label":E(we?Se?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:Ae?.title??(a?E(`Discovered session`):J.summary===null?E(`New conversation`):E(`Conversation`))}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:E(we?Se?`Cadence on`:`Ordinary`:`Cadence state unavailable`)}),Ae&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:Ae.origin===`terminal`?E(`Started in the terminal`):E(`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":Ne,onClick:()=>Pe(e=>!e),children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),E(`Branches ({count})`,{count:J.branches})]}),J.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>vt(null),children:E(`Show the latest`)}),dt&&(0,h.jsx)(`span`,{className:`ep-state running`,children:D(Bs(dt))}),Ae&&(!dt||Me||Se&&!je&&!!Y?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${Ae.status}`,children:Se?je?E(`Discussing`):Me?D(Ae.status):Y?.proposal?E(`Awaiting plan approval`):E(`Ready for conversation`):D(Ae.status)})]})]}),q&&(0,h.jsxs)(`p`,{className:`conversation-cwd`,title:q,children:[E(`Conversation folder:`),` `,(0,h.jsx)(`code`,{children:q})]}),de.error&&!Fe&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(E,de.error)}),Fe&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:E(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),le&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:E(`Preparing execution for this Send…`)}),Ne&&(0,h.jsx)(rs,{client:e,id:t,leaf:J.leaf,onChoose:vt,onClose:()=>Pe(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Be,onScroll:()=>{let e=Be.current;e&&!S&&(Ve.current=e.scrollTop,He.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,We(!He.current),et())},children:[a&&!J.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:E(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!p&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:E(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),J.summary===null&&!J.error&&!a&&(0,h.jsx)(Is,{hint:E(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),p&&!J.error&&(!be||ye.length===0&&J.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:E(`Reading this conversation…`)}),ye.length>0&&Qe&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:J.loadingEarlier&&E(`Reading earlier messages…`)}),ut.start.map(pt),Je.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(oo,{id:e,show:!Ye.hidden.has(e),height:Ye.placeholder(e,t,320),containerRef:Be,onMeasured:Ye.recordMeasured,lazyRef:Ye.register(e),children:(0,h.jsx)(Fs,{turn:n,toggled:Xe.current.get(e)??null,onToggle:Ze})}),ut.after.get(e)?.map(pt),n.header.entry&&n.ordinal<J.count-1&&!je&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:E(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>vt(n.header.entry),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),E(`Continue from here`)]})]},e)),ut.end.map(pt),J.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":E(`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:D(J.attempt.status)}),` `,J.attempt.notice?D(J.attempt.notice):``]})]}),Y?.enabled&&Y.proposal&&(0,h.jsx)(Gs,{proposal:Y.proposal,canApprove:c&&ke&&we&&Le&&!je&&!Te,approvalHint:Re,onApprove:()=>void mt()}),Y?.enabled&&!Y.proposal&&nt.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:E(`Cadence stays on for this conversation until you explicitly exit.`)}),st.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:E(`Workflow activity unavailable; retained work may still be running.`)}),Y?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:D(Y.notice)}),[...new Set([z,J.error,xe.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(E,e??``)},e)),J.error&&J.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:E(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),V&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[E(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:V}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:J.refresh,children:E(`Observe current state`)})]}),J.pinned&&!je&&(0,h.jsx)(`p`,{className:`inspector-note`,children:E(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),Ue&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":E(`Latest messages`),onClick:()=>{Be.current&&(Be.current.scrollTop=Be.current.scrollHeight),He.current=!0},children:(0,h.jsx)(bi,{})}),(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(),bt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),ht()},children:[(0,h.jsx)(`input`,{ref:P,type:`file`,accept:Mn.join(`,`),multiple:!0,hidden:!0,disabled:yt,"aria-label":E(`Add images`),onChange:e=>{bt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),j.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:j.files.map(e=>(0,h.jsx)(os,{file:e,disabled:yt,remove:()=>M([e])},j.key(e)))}),!je&&!Fe&&!ke&&!le&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:E(V?`The last Send is not yet confirmed. No message is resent.`:ne?`Choose a model; your message is sent right after.`:L?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`)}),(0,h.jsx)(`textarea`,{ref:ze,disabled:L||!!V||ne,"aria-label":E(`Message`),value:k,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>A(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),bt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),ht())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:yt,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>P.current?.click(),children:(0,h.jsx)(ti,{"aria-hidden":`true`})}),(0,h.jsx)(is,{active:Se,armed:Oe.mode===`cadence`,known:we,disabled:Se?!Ie:!!je||L||!!V||ne,onClick:()=>{Se?ht(`exit cadence`):Oe.mode===`cadence`?(I(`chat`),Ki(k,`chat`).mode===`cadence`&&A(Oe.text)):I(`cadence`)}}),(0,h.jsx)(ts,{client:me,availability:he,read:ge,lastModel:fe?.model,locked:!!je,open:U,onOpenChange:_e,onChanged:()=>{de.refresh(),_()},onChosen:e=>{ne&&oe.current&&(oe.current=Oo(oe.current,e),W(!1),B(``),re(!0))},awaitingSend:ne}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Se?E(`Cadence stays on. Confirm one plan before implementation.`):Oe.mode===`cadence`?E(`Your next message turns on Cadence mode.`):``}),je?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:L||!m,onClick:()=>void _t(),children:[(0,h.jsx)(Ur,{}),E(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(Se&&qo(k)?Ie:ke)&&!Fe||!k.trim()&&!j.files.length,children:[(0,h.jsx)(vi,{}),E(`Send`)]})]})]})]})}function $s({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=Gi(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Gi(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)(vi,{})}),(0,h.jsxs)(`span`,{className:`files-path`,title:n?`${n.cwd}${a?` / ${a}`:``}`:void 0,children:[i(`Conversation folder:`),` `,a||n?.cwd||i(`Not observed`)]}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),disabled:!t,onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(qr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(i,d.error)}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[t?!m&&!d.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:i(`Reading files…`)}):null:(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:i(n?`Files are unavailable until the execution state is ready.`:`The conversation folder has not been observed.`)}),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)(ai,{}):(0,h.jsx)(oi,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),disabled:!t||!!d.error,onClick:()=>r(e.path),children:(0,h.jsx)(Jr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void ha(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(fi,{})})]},e.path)),t&&!d.error&&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)(Vr,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(i,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 ec=`未命名章节`;function tc(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 nc(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=tc(r||ec),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||ec}})}function rc(e){return e.length>=2}function ic(e){let t=0,n=0;return e.split(`
23
+ `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function ac({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:ic(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 oc({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(`
24
+ `);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=nc(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)(Sa,{text:u?g.slice(u.start-1,u.end).join(`
25
+ `):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:[rc(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)(ac,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:ic(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 sc({client:e,seed:t}){let{t:n,tx:r}=T(),i=fa(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(za,{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(ua(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)(Ra,{client:e,cursor:a,render:e=>(0,h.jsx)(oc,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var cc=[`contents`,`checks`,`changes`,`reviews`];function lc({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:cc.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)(Ba,{client:e,seed:t}):(0,h.jsx)(sc,{client:e,seed:{...t,reader:i}},i)})]})}var uc={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.`},dc=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function fc(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 pc({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||(dc(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&&!dc(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?fc(d.path,r):void 0,H=y.trim().toLowerCase(),U=d?.entries.filter(e=>e.name.toLowerCase().includes(H))??[],te=O&&(O.step===`read`&&uc[O.code]?l(uc[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)(ai,{"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)(ni,{"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)(hi,{"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)(ci,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Kr,{"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)(vi,{}),l(`Parent folder`)]}),U.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>I(e.path),children:[(0,h.jsx)(ai,{}),(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.`)}),te&&(0,h.jsxs)(`p`,{role:`alert`,children:[te,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 mc(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 hc({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)(Jr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function gc({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)(gi,{"aria-hidden":`true`}):(0,h.jsx)(hi,{"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 _c({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=mc(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)(hi,{"aria-hidden":`true`}):(0,h.jsx)(gi,{"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)(ui,{"aria-hidden":`true`}):(0,h.jsx)(Xr,{"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 vc({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)(_c,{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)(za,{pager:e,compact:!0})]})}function yc({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,discovery:E,selectedWorkflow:D,onWorkflow:O,onCancelWorkflow:k}){let{t:A,tx:j}=T(),ee=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,M=fa(e,ee),N=fa(e,r&&ee&&t?{...ee,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),P=M.page&&!(`kind`in M.page)?M.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],F=s?.status===`complete`?s.runs:[],I=P.filter(e=>!F.some(t=>t.taskId===e.owner.taskId)),L=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":A(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:A(`Task conversations`)}),(0,h.jsx)(vc,{pager:N,scope:i,onScope:p,exclude:F.map(e=>e.runId)},r)]}),[R,z]=(0,f.useState)(()=>new Set),B=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${D===e.id||t&&t===y?` active`:``}`,onClick:()=>O?.(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:[A(`Cadence workflow`),` · `,j(e.phase),` · `,j(e.status)]})]})]}),k&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:R.has(e.id),onClick:()=>{z(t=>new Set(t).add(e.id)),k(e).finally(()=>z(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),A(`Cancel workflow — request stop`)]})]},e.id)},V=m.filter(e=>e.status===`running`||e.status===`queued`),H=m.filter(e=>!V.includes(e)),U=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),te=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?U(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)(Xr,{})}),(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`?A(`Terminal`):`WebUI`,` ·`,` `,e.cadence?A(`Cadence on`):A(`Ordinary`),` ·`,` `,t?j(Bs(t)):e.cadence&&[`running`,`queued`].includes(e.status)?A(`Discussing`):e.cadence&&e.status===`completed`?A(`Ready for conversation`):j(e.status)]})]})]},e.id)};return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[E&&(0,h.jsx)(mo,{...E,represented:!n&&E.project?[...(S??[]).map(e=>po(E.project,`workflow`,e.id,e.epoch)),...V.flatMap(e=>e.live?[po(E.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(hc,{onConversation:x}),!n&&(0,h.jsxs)(gc,{title:A(`Running work`),count:s?.status===`complete`&&S&&!w&&g?String(F.length+V.length+S.length):A(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`Active roster unavailable; absence is not proof of settlement.`)}),w&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`Conversation activity unavailable.`)}),V.map(te),S?.map(B),s?.status===`complete`&&F.length===0&&V.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`No active runs`)}),F.map(e=>{let t=P.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??A(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[j(e.kind),` · `,j(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)(Ur,{"aria-hidden":`true`}),A(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(_c,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(gc,{title:A(`Conversation history`),count:t?M.page&&!(`kind`in M.page)?`${H.length+I.length}${M.page.next||M.canPrevious||_?`+`:``}`:A(`Not observed`):`${H.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":A(`Tasks`),className:`task-list`,children:[H.map(te),I.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)(Xr,{"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:A(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&L]},e.owner.taskId)),M.page&&!(`kind`in M.page)&&I.length===0&&H.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`No conversations yet.`)}),v,t&&(0,h.jsx)(za,{pager:M,compact:!0})]}),!I.some(e=>e.owner.taskId===r)&&L]})]})}var bc=[`queued`,`running`];function xc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Gi(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?bc.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!bc.includes(u.status)&&c(0)},[u]);let m=Gi(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?ws(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Gi(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)(ui,{"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)(qs,{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)(Fs,{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 Sc({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)(ai,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(gi,{"aria-hidden":`true`})]})}function Cc({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=T(),o=r||t||n;return!e&&!o?null:(0,h.jsxs)(h.Fragment,{children:[e&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,h.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,h.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,h.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,h.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,h.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function wc(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Bi();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`,te(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=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?te(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}}var Ec=`cadence-panel-layout-v1`,Dc={left:260,right:360,navigation:!0,inspector:!1};function Oc(e,t=600){return Math.max(220,Math.min(t,e))}function kc(e){let t={...Dc};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Oc(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Ac(e,t){let n=e<=900,r=Oc(t.left,e-560),i=Oc(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Oc(e-560-s),rightMaximum:Oc(e-560-a)}}function jc({side:e,width:t,onResize:n,maximum:r}){let{t:i}=T(),a=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>a.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Oc(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Oc(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Oc(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function Mc(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])}function Nc(){let[e,t]=(0,f.useState)(()=>{try{return kc(localStorage.getItem(Ec))}catch{return kc(null)}}),[n,r]=(0,f.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=Ac(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Ec,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,f.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}var Pc=.4,Fc=1.05;function Ic(e){return Math.min(300,e*.86)}function Lc(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Rc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function zc(e,t){return e===`left`?t:-t}function Bc(e,t){return Math.max(-e,Math.min(0,-e+t))}function Vc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Hc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Vc(r*Fc,n,t)>=Pc}var Uc=new Set([`auto`,`scroll`,`overlay`]);function Wc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Uc.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 Kc(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=Lc(r.clientX,window.innerWidth,n);i&&!Wc(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=Rc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Ic(window.innerWidth),h=m*Fc;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=zc(r,d);let b=Bc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Vc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Hc({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 qc(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 Jc=`modulepreload`,Yc=function(e){return`/`+e},Xc={},Zc=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=Yc(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`:Jc,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 Qc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=fa(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)(za,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)($c,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function $c({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 Zc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,qc(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)(Ba,{client:e,seed:t})]})}var el=[[`tools`,Hr],[`context`,ei],[`timeline`,pi],[`runs`,ii]];function tl({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,discovery:o,onOpenService:s,project:c,onChooseFolder:l,onPrepareSend:u,directoryNamespaces:d}){let{t:p,tx:m,locale:g,setLocale:_}=T(),[v]=(0,f.useState)(()=>e??Ri()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[S,C]=(0,f.useState)(!1),[w]=(0,f.useState)(Tc),[E,D]=(0,f.useState)(w?.taskId??null),[O,k]=(0,f.useState)(()=>w?null:Vi()??crypto.randomUUID()),A=Ui(y,O??``),[j,ee]=(0,f.useState)(null),[M,N]=(0,f.useState)([]),[P,F]=(0,f.useState)(null),[I,L]=(0,f.useState)(w?`task`:`files`),[R,z]=(0,f.useState)(),[B,V]=(0,f.useState)(),[H,U]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Vi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[te]=(0,f.useState)(()=>crypto.randomUUID()),ne=(0,f.useCallback)(()=>z(void 0),[]),[W,re]=(0,f.useState)(w?w.scope??{kind:`task`,id:w.taskId}:null),ie=na(c?.id,c?.epoch),ae=!c||ie.readiness===`running`,oe=!!c&&(ie.readiness===`stopped`||ie.readiness===`not-started`),se=(0,f.useRef)(null);ae&&ie.value?.epoch&&(se.current=ie.value.epoch);let ce=!c||!oe&&(ae||se.current!==null),K=aa(v,E?{kind:`task`,id:E}:null,!S&&ce,se.current),le=(0,f.useRef)(!0);(K.workspace||K.observation||K.error||K.transportStatus===`stale`||K.compatible===!1)&&(le.current=!1);let ue=!!(c&&(ie.value||ie.error)),de=!S&&!!(K.workspace||ue),fe=(0,f.useRef)(null);(K.workspace||ie.value?.workspaceId)&&(fe.current=K.workspace?.workspaceId??ie.value?.workspaceId??null);let pe=u?async(e,t,n)=>{let r=await u(e,t,n);if(e.aborted)throw Error(`stale`);ie.prepared(r);let i=K.reconnect();await K.whenReady(r,e,i)}:void 0,q=qi(v.client,de),me=Gi(v.client,K.workspace&&!S?{kind:`conversation-active`}:null,1e3),he=me.value?.kind===`conversation-active`?me.value.entries:[],ge=[...he,...(q.value?.entries??[]).filter(e=>!he.some(t=>t.id===e.id))],_e=Gi(v.client,K.workspace&&!S?{kind:`workflow-active`}:null,2e3),ve=_e.value?.kind===`workflow-active`?_e.value:void 0,J=(0,f.useMemo)(()=>[...new Set([...ve?.runs.map(e=>e.id)??[],...M])],[ve,M]),ye=Gi(v.client,!c&&K.workspace&&!S?{kind:`projects`}:null),be=H??c?.cwd??(ye.value?.kind===`projects`?ye.value.entries.find(e=>e.current)?.path:void 0),xe=B?.id===O?B:void 0;(0,f.useEffect)(()=>{xe&&Vi()===xe.id&&history.replaceState({...history.state,cadenceCwd:xe.cwd,cadenceConversationId:xe.id},``,location.href)},[xe]);let Y=O?xe:be?{id:te,cwd:be}:void 0,Se=xe?.cwd??be??(ye.value?.kind===`projects`?ye.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,Ce={state:K.observation,transportStatus:K.transportStatus,error:K.error,refresh:K.refresh},we=Ce.state?.snapshot.scope.kind===`task`&&Ce.state.snapshot.scope.id===E?Ce.state.snapshot.context:void 0,X=Nc(),{mobile:Te,overlay:Ee,closeDrawer:De}=X,Oe=(0,f.useRef)(null);Kc({enabled:Te&&!S,open:Ee,onOpenChange:X.setDrawer,container:Oe}),Mc(Oe,Ee,!S&&!!Ee,De);let[ke,Ae]=(0,f.useState)(w?.snapshotSeq),[je,Me]=(0,f.useState)(``),[Ne,Pe]=(0,f.useState)(``),Fe=(0,f.useRef)(null),Ie=(0,f.useRef)(null),Le=()=>{Ie.current&&(Ie.current.open=!1)},[Re,ze]=(0,f.useState)(`messages`),[Be,Ve]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(),[Ke,qe]=(0,f.useState)(w?.cursor),[Je,Ye]=(0,f.useState)(``),[Xe,Ze]=(0,f.useState)([]),[Qe,$e]=(0,f.useState)(new Set),et=(0,f.useRef)(!0),tt=e=>{et.current&&Ze(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)})},Z=(0,f.useRef)(new oa),nt=G({taskId:E,scope:W,selectedSnapshot:ke??null,detached:S,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});Z.current.select(nt),(0,f.useEffect)(()=>(et.current=!0,()=>{et.current=!1,Z.current.depart()}),[]);let rt=e=>{b(``);let t=e??crypto.randomUUID();e||U(Se??be),ee(null),t!==O&&(N([]),z(void 0)),Z.current.depart(),k(t),D(null),re(null),Me(``),Pe(``),Ge(void 0),qe(void 0),Ae(void 0),ze(`messages`),L(`files`),De(),history.replaceState({cadenceCwd:Se??be,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{O&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${O}`)},[O]);let it=(e,t)=>{ee(null),N([]),k(null),L(`task`),Me(t??``),Pe(``),Ae(void 0),Z.current.depart(),D(e),re({kind:`task`,id:e}),Ge(void 0),qe(void 0),ze(`messages`),De(),history.replaceState(null,``,wc(e))};(0,f.useEffect)(()=>{let e=()=>{let e=Tc();if(e)ee(null),N([]),k(null),L(`task`),Z.current.depart(),Ae(e.snapshotSeq),Me(``),Pe(``),D(e.taskId),re(e.scope??{kind:`task`,id:e.taskId}),Ge(void 0),qe(e.cursor),ze(`messages`),De();else{let e=Vi();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&U(t),z(void 0),ee(null),N([]),k(e),D(null),re(null),L(`files`),Z.current.depart(),De()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[De]);let at=(e,t,n)=>{ee(null),Ae(t),Pe(n??``),Z.current.depart(),re(e),Ge(void 0),qe(void 0),ze(`messages`),De(),E&&history.replaceState(null,``,wc(E,void 0,{scope:e,snapshotSeq:t}))},ot=ke??Ce.state?.snapshot.committedSeq??K.workspace?.committedSeq,st=K.workspace?.storeId,ct=W&&st&&ot?{storeId:st,scope:W,snapshotSeq:ot,reader:`messages`,after:null,limit:50}:null,lt=W&&st&&ot?{storeId:st,scope:W,snapshotSeq:ot,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ut=we?Ce.state?.snapshot.runs??[]:[],dt=Z.current.ticket(),ft=e=>{tt(e),e.receipt&&Z.current.current(dt)&&K.refresh()},pt=e=>{if(Qe.has(e)||!K.cancelCompatible||!K.activeRuns)return;let t=crypto.randomUUID(),n=K.activeRuns.epoch;$e(t=>new Set(t).add(e)),tt({commandId:t,error:p(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{ft(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:p(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>tt({commandId:t,error:p(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{et.current&&$e(t=>{let n=new Set(t);return n.delete(e),n})})};if(S)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:p(`Detached`)}),(0,h.jsx)(`p`,{children:p(`Accepted service work continues. No Cancel was requested.`)}),Xe.map(e=>(0,h.jsxs)(`p`,{children:[p(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>C(!1),children:p(`Reconnect as a viewer`)})]});let mt=K.activeRuns,ht=mt?.status===`complete`?mt.runs:[],gt=!S&&!K.error&&K.transportStatus===`current`&&(!Ce.state||Ce.state.connection===`current`),_t=ae&&gt,vt=le.current&&!Ce.state&&!Ce.error&&!ie.error&&(!c||!ie.value&&ie.readiness===`unknown`||ie.readiness===`running`),yt=oe?{status:ie.readiness===`not-started`?`not-started`:`stopped`}:K.compatible===!1?{status:`incompatible`}:ae&&gt&&K.compatible&&K.epoch&&(!c||ie.value?.epoch===K.epoch)?{status:`ready`,epoch:K.epoch,attachmentVersion:K.attachmentVersion}:{status:vt?`connecting`:`unavailable`},bt=S?`Viewer disconnected`:vt?`Connecting…`:c&&ie.readiness===`unknown`?`Project readiness unknown`:c&&ie.readiness===`stale`?`Project observation stale`:oe?`Ready to prepare on Send`:gt?K.workspace?Ce.state?.connection??(E?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(`div`,{className:`app${X.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":p(`Toggle conversation navigation`),"aria-expanded":Te?Ee===`left`:X.navigation,onClick:()=>X.toggle(`left`),children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":p(`Workbench projects`),title:p(`Workbench projects`),onClick:n,children:(0,h.jsx)(ai,{})}),(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`}),W&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":p(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Re===`messages`&&!Ke,onClick:()=>{qe(void 0),Ge(void 0),ze(`messages`)},children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),p(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Fe,onKeyDown:e=>{e.key===`Escape`&&Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Re===`messages`?p(`Details`):m(Re),(0,h.jsx)(gi,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[el.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Re===e,onClick:()=>{qe(void 0),Ge(void 0),ze(e),Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),m(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Export selected scope`),disabled:!ct,onClick:()=>{Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus()),Ue(!0)},children:[(0,h.jsx)(li,{"aria-hidden":`true`}),p(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Copy token-free link`),disabled:!E,onClick:()=>{E&&ha(wc(E,Ke,W?{scope:W,snapshotSeq:ke}:void 0)).then(e=>Ye(e?``:p(`Link copy unavailable.`)))},children:[(0,h.jsx)($r,{"aria-hidden":`true`}),p(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[W&&(0,h.jsx)($a,{disabled:!lt,onOpen:()=>Ve(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>_(g===`zh`?`en`:`zh`),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Ie,onKeyDown:e=>{e.key===`Escape`&&Ie.current&&(Ie.current.open=!1,Ie.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":p(`More`),title:p(`More`),children:(0,h.jsx)(Yr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Observe current state`),onClick:()=>{Le(),K.refresh(),ie.refresh()},children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),p(`Refresh status`)]}),s&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{Le(),s()},children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[p(`Cadence service`),(0,h.jsx)(`small`,{children:p(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":p(`Disconnect this page`),title:p(`Return — accepted work continues`),onClick:()=>{Le(),De(),Ve(!1),Ue(!1),Z.current.depart(),C(!0)},children:[(0,h.jsx)(Qr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[p(`Disconnect this page`),(0,h.jsx)(`small`,{children:p(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${K.compatible===!1?` warn`:``}`,title:Li?.buildId??p(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:p(`Shared compatibility: {state}.`,{state:K.compatible===void 0?p(`Execution compatibility not observed`):K.compatible?p(`compatible`):p(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:p(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Li?.buildId??p(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":p(`Toggle workspace panels`),"aria-expanded":Te?Ee===`right`:X.inspector,onClick:()=>X.toggle(`right`),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:p(W&&I===`task`?`History details`:`Files`)})]})]}),!K.workspace&&ht.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":p(`Execution and cancellation`),children:ht.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:[m(e.kind),` `,e.runId,` · `,m(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>it(e.taskId),children:p(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!K.cancelCompatible||Qe.has(e.runId),onClick:()=>pt(e.runId),children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),p(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(Cc,{error:Je,projectObservationError:ie.error,observationError:K.error,unavailable:!vt&&!oe&&!_t,onRefresh:()=>{K.refresh(),ie.refresh()}}),(0,h.jsxs)(`div`,{ref:Oe,className:`layout`,style:{"--left-w":`${X.left}px`,"--right-w":`${X.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":p(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${Ee?` on`:``}`,onClick:De}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${Ee===`left`?` open`:``}`,"aria-label":p(`Conversation navigation`),tabIndex:-1,inert:Te?Ee!==`left`:!X.navigation||Ee===`right`,children:[!de&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[o&&(0,h.jsx)(mo,{...o}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:p(vt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),de&&(0,h.jsx)(yc,{discovery:o,client:v.client,workspace:K.workspace,executionStopped:oe,taskId:E,scope:W,runs:ut,snapshot:Ce.state?.snapshot.committedSeq,activeRuns:K.activeRuns,cancelCompatible:!!K.cancelCompatible,canceling:Qe,onCancel:pt,chats:ge,chatActivityKnown:me.value?.kind===`conversation-active`&&!me.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:p(`Reading conversation history…`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.previous,children:p(`Newer conversations`)}),q.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.next,children:p(`Older conversations`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:q.first,children:p(`Latest conversations`)}),q.error&&(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:p(`Observe current state`)})]}),conversationId:O,onConversation:rt,onNewConversation:()=>rt(),workflows:ve?.runs,workflowLinks:ve?.links,workflowError:!!_e.error,selectedWorkflow:j?.runId,onWorkflow:(e,t)=>{t?rt(t):(ee({runId:e.id,stepId:null,label:e.goal}),De())},onCancelWorkflow:async e=>{let t=await Ks(v.client,e);t&&Ye(t),_e.refresh()},onTask:it,onScope:at}),K.workspace&&(0,h.jsx)(bo,{client:v.client,active:K.activeRuns,taskId:E,runs:ut,snapshot:ot,workflowRuns:J,selected:j,onOpenWorkflow:e=>{ee(e),De()},onOpen:(e,t,n,r)=>{it(e),re({kind:`child`,id:t}),Pe(r),Ae(n),history.replaceState(null,``,wc(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(jc,{side:`left`,width:X.left,maximum:X.leftMaximum,onResize:e=>X.resize(`left`,e)}),(0,h.jsxs)(`main`,{className:`main`,inert:Ee!==null,children:[O&&c&&!ue&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:p(`Reading this conversation…`)}),j&&(0,h.jsx)(xc,{client:v.client,agent:j,backLabel:p(O?`Back to conversation`:E?`Back to task`:`Back`),onBack:()=>ee(null),onOpenAgent:ee},`${j.runId}:${j.stepId??``}`),O&&(!c||ue)&&(0,h.jsx)(Qs,{client:v.client,id:O,activitySelected:A.selected,initialLeaf:A.leaf,initialCwd:be,onLocation:V,hidden:!!j,onOpenAgent:ee,onWorkflowRuns:N,workspaceId:c?`checkout:${c.path}`:fe.current??`connecting`,directoryNamespaces:d,legacyWorkspaceId:c?ie.value?.workspaceId??void 0:void 0,prepareForSend:pe,actionsReady:ae&&!!K.workspace&&!!K.compatible&&!K.error&&gt,available:de,canInterrupt:!!K.cancelCompatible,enabled:pe?de:!!K.workspace&&!!K.compatible&&!K.error,modelAvailability:yt,onModelChanged:()=>{Z.current.depart(),K.refresh(!0),ie.refresh()},onChanged:()=>{q.refresh(),K.refresh()},reference:R,onReferenceUsed:ne},`${c?.id??fe.current??`connecting`}:${O}:${A.leaf??``}`),W&&!j&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[W.kind!==`task`&&E&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>it(E,je),children:p(`Back to task`)}),(0,h.jsx)(`h2`,{title:je||W.id,children:W.kind===`task`?je||p(`Task {id}`,{id:W.id.slice(0,8)}):Ne||p(`{kind} {id}`,{kind:m(W.kind),id:W.id.slice(0,8)})}),W.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:p(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[p(`Recorded conversation`),` ·`,` `,p(`snapshot {seq}`,{seq:ot??``})]}),(0,h.jsx)(`code`,{children:W.id}),(0,h.jsx)(`p`,{children:p(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!O||!!j,children:[!ct&&(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:K.error?p(`Recorded history could not be read.`):p(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:p(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ct&&Ke?(0,h.jsxs)(`div`,{className:`tab-body`,children:[We&&(We.owner.entity.kind===`task`||We.owner.entity.kind===`message`||We.owner.entity.kind===`tool`)&&(0,h.jsx)(Va,{client:v.client,seed:{storeId:Ke.storeId,scope:Ke.scope,snapshotSeq:Ke.snapshotSeq,kind:We.owner.entity.kind,id:We.owner.entity.id,version:We.owner.entity.version}},`${We.owner.entity.id}:${We.owner.entity.version}`),(0,h.jsx)(Ra,{client:v.client,cursor:Ke,highlight:We?.range},`${Ke.recordId}:${Ke.recordVersion}`)]}):ct&&(0,h.jsxs)(`div`,{className:Re===`messages`||Re===`tools`?`tab-body transcript-body`:`tab-body`,children:[Re===`messages`&&(0,h.jsx)(lo,{client:v.client,seed:ct}),Re===`tools`&&(0,h.jsx)(nl,{client:v.client,seed:ct}),Re===`context`&&(0,h.jsx)(Ba,{client:v.client,seed:ct}),Re===`timeline`&&(0,h.jsx)(Qc,{client:v.client,seed:ct,onSearch:()=>Ve(!0)}),Re===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:p(`Runs in the current snapshot`)}),ut.length>0?ut.map(e=>(0,h.jsx)(Ya,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:we&&Ce.state?p(`No owner run projection in this snapshot.`):p(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:p(`Retained runs`)}),(0,h.jsx)(Qa,{client:v.client,seed:{...ct,scope:{kind:`task`,id:E??ct.scope.id}},onScope:at},E)]})]},`${W?.kind}:${W?.id}:${ke??`current`}`)]}),K.workspace&&Xe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Xe.map(e=>(0,h.jsx)(sa,{client:v.client,value:e,onChange:tt},e.commandId))})]}),(0,h.jsx)(jc,{side:`right`,width:X.right,maximum:X.rightMaximum,onResize:e=>X.resize(`right`,e)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${Ee===`right`?` open`:``}`,"aria-label":p(`Files and history drawer`),tabIndex:-1,inert:Te?Ee!==`right`:!X.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":p(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":I===`files`||!W,onClick:()=>L(`files`),children:[(0,h.jsx)(ai,{}),p(`Files`)]}),W&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":I===`task`,disabled:!ct,onClick:()=>L(`task`),children:[(0,h.jsx)(ei,{}),p(`History details`)]})]}),I===`files`||!W?(0,h.jsx)($s,{location:Y,client:v.client,enabled:!!K.workspace&&!!Y,onReference:e=>{O||rt(te);let t=!O&&Y?`${Y.cwd.replace(/[\\/]+$/,``)}${Y.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;z(t),De()}},Y?.cwd??`owner`):ct?(0,h.jsx)(lc,{client:v.client,seed:{...ct,scope:{kind:`task`,id:E??ct.scope.id}}},E):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:K.error?p(`Recorded history could not be read.`):p(`Reading recorded history…`)})]})})]}),(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:p(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${vt?`busy`:oe?``:!_t||!K.workspace?`error`:Ce.transportStatus===`current`?Ce.state?Ce.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),m(bt)]}),c&&(0,h.jsx)(`span`,{className:`status-item faint`,children:p(`Execution service: {status}`,{status:m(ie.readiness)})}),mt?.status===`complete`?ht.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:p(_t?ht.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:ht.length})}):!vt&&!oe&&(0,h.jsx)(`span`,{className:`status-item faint`,children:p(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(K.workspace||c)&&(0,h.jsx)(Sc,{path:Se,onClick:()=>l?l(Se):F(``)}),K.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:p(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),P!==null&&K.workspace&&(0,h.jsx)(pc,{onOpen:t,projects:i??(ye.value?.kind===`projects`?ye.value.entries:[]),client:v.client,current:Se??K.workspace.rootLabel,initial:P||void 0,home:r,epoch:K.workspace.epoch,onClose:()=>F(null)}),Be&&lt&&(0,h.jsx)(Ja,{client:v.client,seed:lt,onClose:()=>Ve(!1),onHit:e=>{Ge(e),qe(e.cursor),E&&history.replaceState(null,``,wc(E,e.cursor,W?{scope:W,snapshotSeq:ke}:void 0))}}),He&&lt&&(0,h.jsx)(Ga,{request:{storeId:lt.storeId,scope:lt.scope,snapshotSeq:lt.snapshotSeq,format:`ndjson`},onClose:()=>Ue(!1)})]})}function nl({client:e,seed:t}){let n=fa(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(za,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(fo,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var rl=`cadence-last-project`;function il(){try{let e=localStorage.getItem(rl);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function al(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(rl,e)}catch{}}function ol(e){let t=il();return t?e.projects.find(e=>e.id===t):void 0}async function sl(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 Ji(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function cl(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Ji(t);if(!t.ok)throw Error(Yi(n));return yn(n)}async function ll(e,t,n,r,i){if(!Li)throw Error(`unsupported-context`);let a={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`,...Li})},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await Ji(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Yi(c));let l=pn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function ul(e,t){let n=await cl(t);return ll(`/workbench/v1/select`,{path:e},n,t)}async function dl(e,t,n,r){let i=await cl(t),a=i.projects.find(t=>t.id===e.id);if(!a||a.path!==e.path||a.cwd!==e.cwd)throw Error(`stale`);let o=await ll(`/workbench/v1/prepare-send`,{projectId:e.id,commandId:crypto.randomUUID(),...n?{location:n}:{}},i,t,()=>r?.(`dispatched`));if(!o.project.epoch||o.project.id!==e.id||o.project.path!==e.path||o.project.cwd!==e.cwd)throw Error(`stale`);return r?.(`confirmed`),o}async function fl(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await ul(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var pl=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function ml(e){let t=B(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:H(t.id),source:L(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:nn(t.sessionId),cwd:N(t.cwd,4096,!0),leaf:t.leaf===null?null:N(t.leaf,128,!0),history:L(t.history,[`shared`,`unavailable`]),phase:L(t.phase,pl),freshness:L(t.freshness,[`current`,`stale`,`unknown`]),observedAt:F(t.observedAt,0),epoch:t.epoch===null?null:H(t.epoch),instance:t.instance===null?null:H(t.instance),executionCwd:t.executionCwd===null?null:N(t.executionCwd,4096,!0)}}function hl(e){let t=B(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:R(t.kind,`activity-discovery`),epoch:H(t.epoch),observedAt:F(t.observedAt,0),completeness:L(t.completeness,[`complete`,`partial`]),unavailable:F(t.unavailable,0,1e4),projects:V(t.projects,128,e=>{let t=B(e,[`path`,`activities`]);return{path:N(t.path,4096,!0),activities:V(t.activities,256,ml)}})}}async function gl(e){if(!Li)throw Error(`unsupported-context`);let t=Ci([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal,headers:{"X-Cadence-Build":JSON.stringify({kind:`browser`,...Li})}}),n=await Ji(e);if(!e.ok)throw Error(Yi(n));return hl(n)}finally{t.dispose()}}function _l(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function vl(e,t,n,r=gl){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?_l(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function yl(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return vl(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}var bl=`cadence-recovery-dismissed`,xl={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.`},Sl={"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 Cl(){try{let e=JSON.parse(localStorage.getItem(bl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function wl(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Tl({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Cl),[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(bl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:wl(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(xl[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(Sl[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var El={restart:18e4,upgrade:12e5},Dl=1e3,Ol={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},kl=e=>e instanceof Error?e.message:`unavailable`;function Al(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(Ol[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 jl(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Ml(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function Nl({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 Zi(e.signal).then(a,t=>{e.signal.aborted||s(kl(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>El[e.action])return w(`timeout`);try{let t=await Zi(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,Dl)};return r=setTimeout(i,Dl),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Qi().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),$i({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(kl(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`&&jl(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:El[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Al(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(`The package manager 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`?An(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:Ml(r,i.upgrade)}),(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:Al(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(`Update information is unavailable for this installation.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking the package registry 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})}):Dn(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(yi,{"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 installation requires a manual update using its original installation method.`,{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)(qr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Pl({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s,discovery:c}){let{t:l,locale:u,setLocale:d}=T(),p=Nc(),{mobile:m,overlay:g,closeDrawer:_}=p,v=(0,f.useRef)(null);Kc({enabled:m,open:g,onOpenChange:p.setDrawer,container:v}),Mc(v,g,!!g,_);let y=e=>{_(),i(e)},b=e=>{_(),a?a(e):i(e)},x=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${p.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":l(`Toggle conversation navigation`),"aria-expanded":m?g===`left`:p.navigation,onClick:()=>p.toggle(`left`),children:(0,h.jsx)(Zr,{"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":l(`Cadence service`),"data-tip":l(`Cadence service`),onClick:o,children:(0,h.jsx)(Gr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:u===`zh`?`en`:`zh-CN`,onClick:()=>d(u===`zh`?`en`:`zh`),"aria-label":u===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:u===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":l(`Toggle workspace panels`),"aria-expanded":m?g===`right`:p.inspector,onClick:()=>p.toggle(`right`),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:v,style:{"--left-w":`${p.left}px`,"--right-w":`${p.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":l(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${g?` on`:``}`,onClick:_}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${g===`left`?` open`:``}`,"aria-label":l(`Conversation navigation`),tabIndex:-1,inert:m?g!==`left`:!p.navigation||g===`right`,children:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[c&&(0,h.jsx)(mo,{...c}),(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:l(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?l(`Returning to your last project {name}…`,{name:x(n.path)}):n?.status===`unavailable`?l(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:x(n.path)}):t.length?l(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):l(`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:()=>b(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(ai,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:x(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?l(`Selecting folder…`):t})]})]},t))]})]})]})}),(0,h.jsx)(`main`,{className:`main`,inert:g!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":l(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Is,{hint:l(`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:()=>y(),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),l(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":l(`Message`),rows:3,placeholder:l(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:l(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(vi,{"aria-hidden":`true`}),l(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${g===`right`?` open`:``}`,"aria-label":l(`Files`),tabIndex:-1,inert:m?g!==`right`:!p.inspector,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),l(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`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:l(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(Sc,{disabled:!e,onClick:()=>y()})})]})]})}function Fl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Bi),[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.useCallback)(()=>g(e=>e+1),[]),S=yl(t?.epoch,x),C=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>C.current?.abort(),[]);let w=(0,f.useRef)(new Map),E=(0,f.useRef)(!r),D=(0,f.useRef)(null),O=(0,f.useCallback)(()=>{D.current&&(D.current.abort(),D.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 Ji(t);t.status===400&&Yi(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(Yi(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{C.current?.abort(),O(),b(null),i(Bi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[O]),(0,f.useEffect)(()=>{if(!t||!E.current)return;E.current=!1;let e=ol(t);if(!e)return;let n=new AbortController;D.current=n,b({status:`checking`,path:e.cwd}),sl(e.id,n.signal).then(t=>{n.signal.aborted||(D.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let k=(0,f.useCallback)((e,n)=>{O(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&w.current.set(r,window.location.hash),history.pushState({cadenceCwd:n?.cwd??e?.cwd,cadenceConversationId:n?.sessionId},``,e?`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:w.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,O,t]),M=(0,f.useCallback)(async e=>{C.current?.abort();let t=new AbortController;C.current=t;let r=await ul(e,t.signal);t.signal.aborted||(n(r.entry),k(r.project))},[k]),N=t?{value:S.value,error:S.error,opening:!!s,project:t.projects.find(e=>e.id===r)?.path,onOpen:(e,t)=>{C.current?.abort(),O();let r=new AbortController;C.current=r,c(t.cwd),u(``),fl(e,t,r.signal).then(e=>{r.signal.aborted||(n(e.entry),k(e.project,t))}).catch(e=>{r.signal.aborted||u(e instanceof Error?e.message:`unavailable`)}).finally(()=>{C.current===r&&c(null)})}}:void 0,P=async(e,i,a)=>{let o=t?.projects.find(e=>e.id===r);if(!o)throw Error(`unavailable`);let s=await dl(o,e,i,a);if(e.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},F=(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 Ji(n);if(!n.ok){let e=Yi(r);return{kind:`error`,error:ee(A.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Dr(r)}}catch{return{kind:`error`,error:ee(`unavailable`)}}}}),[]),I=(0,f.useMemo)(()=>r?Ri(r):void 0,[r]),L=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{L&&al(L.id)},[L]),t===null)return(0,h.jsx)(tl,{});let R=t&&_&&(0,h.jsx)(Nl,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),z=()=>v(!0),B=t&&a!==null&&(0,h.jsx)(pc,{selectOnly:!0,client:F,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:M});return t&&L&&I?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(tl,{api:I,project:L,directoryNamespaces:t?.projects.filter(e=>e.path===L.path).map(e=>e.id).sort(),discovery:N,onPrepareSend:P,onChooseFolder:e=>{C.current?.abort(),o(e??L.cwd)},onOpenProject:M,onWorkbenchHome:()=>k(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsxs)(h.Fragment,{children:[` `,l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(Tl,{notices:t.recoveries,project:L.path}),` `]}),onOpenService:z},L.id),R,B]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Pl,{discovery:N,ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?z:void 0,onOpenFolder:e=>{O(),u(``),C.current?.abort(),o(e??t?.home??``)},onOpenProject:t=>{s||(O(),u(``),c(t),M(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)(Tl,{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&&!L&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),B,R]})}function Il(){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 Ll=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Il,{}):this.props.children}},Rl=document.getElementById(`root`);if(!Rl)throw Error(`Application root unavailable`);(0,p.createRoot)(Rl).render((0,h.jsx)(E,{children:(0,h.jsx)(Ll,{children:(0,h.jsx)(Fl,{})})}));export{Zc as t};