@abelxiaoxing/cadence 2.0.46 → 2.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/README.zh-CN.md +5 -3
- package/docs/reuse-and-distribution.md +5 -3
- package/package.json +1 -1
- package/src/service-host.mjs +1 -1
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +12 -12
- package/web/dist/manifest.json +6 -6
|
@@ -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={"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Send with this model before approving a plan.":`请先使用此模型发送消息,再批准计划。`,"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 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(),te(e)>t)throw new j(`oversize`);return e}function te(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)&&M(),e}function F(e){return typeof e!=`boolean`&&M(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&M(),e}function L(e,t){return e!==t&&M(),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)))&&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 B(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 V(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 H(e){let t=N(e,64);return/^[0-9a-f]{64}$/.test(t)||M(),t}function U(e){let t=N(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||M(),t}function ne(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function re(e){let t=N(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||M(),t}function W(e,t=k.controlBytes){let n=t,r=e=>{if(n-=te(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=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`)&&M();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 M()}return i(e,0)}function ie(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 G(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,A),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(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`],le=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ue(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:I(t.api,ce),thinking:I(t.thinking,le)}}function K(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...ue(n)}}function de(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function pe(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ae),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function me(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function he(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:re(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=pe(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,me);return r.kind===`historical`&&i&&i.end>r.result.bytes&&M(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(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){W(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&M();let i={schema:L(t.schema,D),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:re(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:N(t.instructions,k.instructionsBytes,!0),expectedOutput:N(t.expectedOutput,k.expectedOutputBytes,!0),role:de(t.role),model:K(t.model),dependencies:B(t.dependencies,k.assignments,he)}})};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=W(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=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)&&M(),{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:K(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,_e)}}function ye(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:N(t.name,128,!0),command:N(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&M(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&M(),n}function be(e){switch(W(e),q(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:N(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=ge(t.graph),r=V(t.taskId);return n.taskId!==r&&M(),{kind:`save-plan`,taskId:r,plan:N(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:q(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check: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 M()}}function xe(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:ve(t.expected),action:be(t.action)}}function Se(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 Ce(e){if(W(e),q(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 we(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function Te(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)&&M(),{...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:N(n.rootLabel,4096,!0),cwdLabel:N(n.cwdLabel,4096,!0),readablePlan:N(n.readablePlan,32768),graph:R(n.graph,ge),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ee(e){W(e);let t=z(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:V(t.grant),expiresAt:n,preview:Te(t.preview)}}function J(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`))&&M(),n}function De(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=pe(t.result);L(i.field,`final-text`);let a=R(t.range,me);a&&a.end>i.bytes&&M();let o=N(t.text,k.predecessorBytes);if(n+=te(o),n>k.handoffBytes)throw new j(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&M(),r.add(s),te(o)!==(a?a.end-a.start:i.bytes)&&M(),{assignmentId:re(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:J(t.coverage)}})}}function Oe(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>N(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:J(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 Y(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function ke(e){let t=N(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||M(),t}function Ae(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:Y(t.scope),query:R(t.query,e=>{let t=N(e,k.queryBytes);return t.length||M(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,ae)),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))&&M(),n}function je(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&M(),{disposition:n,value:r}}function X(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Me(e){let t=q(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=pe(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&M(),{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=>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=q(e);switch(t){case`ready`:{let n=z(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:L(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=z(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:N(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&&M(),{kind:t,messageId:V(n.messageId),role:r,source:je(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...X({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,k.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:X(n.declaration),index:P(n.index,0,k.dataFrames),source:je(n.source),name:N(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,X),source:je(n.source),name:N(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,X),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&M(),{kind:t,callId:V(n.callId),declaration:i,source:je(n.source),name:N(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=N(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+te(r)>k.detailBytes&&M(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,k.detailBytes),sha256:H(n.sha256),coverage:J(n.coverage)}}case`capture-status`:return{kind:t,coverage:J(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 M()}}function Le(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>N(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))&&M(),n}function Re(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function ze(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&M(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:pe(t.content),committedSeq:n}}function Be(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&M(),{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:G(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Re)}}function Ve(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&ne(n,t.detail.committedSeq)<0)&&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=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Oe(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&M(),{kind:t,native:Le(n.native),capture:J(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&M(),{assignmentId:re(t.assignmentId),childRunId:n,native:R(t.native,Oe),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,oe);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&M(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&M(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=z(e,[`source`,`event`]),n=Ge(t.source),r=q(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:N(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:J(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=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Je(e){W({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=B(n.runs,k.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&M(),{...r,status:`complete`,runs:i}}function Ye(e){let t=G(e);return L(t.effect,`none`),t}function Xe(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ze(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){W(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,oe)),settlement:R(t.settlement,We),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&M(),n}function tt(e){W(e);let t=z(e,[`identity`,`receipt`]),n=Ce(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(q(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:G(n.error)}}function nt(e){switch(W(e),q(e,`status`)){case`found`:return{status:`found`,receipt:et(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:G(z(e,[`status`,`error`]).error)};default:return M()}}function rt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,re),admission:pt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,oe)),settlement:R(t.settlement,We),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:J(t.coverage),result:R(t.result,pe)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&W(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==W(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&W(n.result)!==W(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&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){W(e,k.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:Y(t.scope),committedSeq:U(t.committedSeq),context:mt(t.context),runs:B(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||W(n.horizon.historicalRuns.scope)!==W(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&M(),n}function st(e){W(e,k.pageBytes);let t=q(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:Y(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);ne(r.committedSeq,e)<=0&&M();let i=mt(n.context);_t(i,r.epoch,r.scope)||M();let a=B(n.runs,k.maxPageEntries,rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&M(),{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)))&&M()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=Ae(t.cursor),r=Ae(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:J(t.coverage)}}function dt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Ae(t.cursor),content:pe(t.content),range:R(t.range,me),text:N(t.text,k.detailPageBytes),next:R(t.next,Ae),coverage:J(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!==te(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||W(ct({...n.next,offset:n.cursor.offset}))!==W(ct(n.cursor)))&&M(),n}function ft(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=Ae(t.cursor);n.query||M();let r=te(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=pe(t.content),a=bt(t.owner);xt(a,n.scope)||M();let o=me(t.range),s=Ae(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)&&M(),{content:i,owner:a,range:o,preview:N(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,Ae);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)))&&M(),{cursor:n,hits:i,next:a,coverage:J(t.coverage)}}function pt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:re(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&M(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&M(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(q(e,`status`)===`available`)return{status:`available`,version:ve(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=G(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)&&M(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:N(t.rootLabel,4096,!0),context:mt(t.context),models:B(t.models,k.maxPageEntries,K)};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=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)&&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=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function Ct(e){W(e,k.controlBytes);let t=q(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&M(),(r===`ready`||r===`preparing`)&&i!==null&&M(),{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`&&M(),{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:De(n.handoff),observation:St(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=pe(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:ye(n.selection),cwdId:V(n.cwdId),cwdLabel:N(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)&&M()}let a=Le(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=R(r.output,pe),u=J(r.coverage);return l&&l.field!==`check`&&M(),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`)&&M(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&M(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=pe(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&M(),{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)&&M(),{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&&M(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return M()}}function wt(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Tt(e){W(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=Ct(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&M(),{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))&&M(),{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:N(n.text,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:J(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,Et),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&M(),{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,k.maxPageEntries)}}function Ot(e){let t=z(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&M(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=q(e);if(t===`run`)return{kind:t,projection:rt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&M(),{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`&&M();let a=U(n.committedSeq);return a===`0`&&M(),{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)&&M(),t===`task`){let e=R(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=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,k.dataFrames)),s=R(i.finalText,pe),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&M(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:je(i.source)}}if(t===`tool`){let e=R(i.declaration,X),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`&&M(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||W(s.declaration)!==W(e)))&&M(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:je(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:V(i.detailId),descriptor:e,content:n,coverage:J(i.coverage)}}L(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){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&M();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)))&&M(),{request:n,records:r,next:i,coverage:J(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(ct({...r,snapshotSeq:null}))!==W(ct(n)))&&M(),{kind:`snapshot`,request:n,next:r,coverage:J(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(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:Y(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function It(e){W({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Ft(t.request),r=ge(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&M(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function Rt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:Y(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,O),request:Rt(e.request),coverage:J(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=pe(e.content),a=R(e.range,me),o=N(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==te(o):i.bytes!==0||o!==``)&&M(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:J(e.coverage)};break}case`markdown`:r={kind:n,text:N(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=J(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&M(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return M()}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`&&M(),`\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)&&M(),this.ordinal===0?(n.kind!==`manifest`||W(n.request)!==W(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`&&(W(n.graph.request.scope)!==W(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+=te(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))&&M(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&M(),{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:Y(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Gt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Wt(t.request),r=kt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!xt(r.owner,n.scope))&&M(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}var qt=e=>{let t=G(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&&M(),t}function Xt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Zt(e){let t=B(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&M(),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)&&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){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:R(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=J(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&M(),{source:L(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){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:N(t.text,131072),git:F(t.git),coverage:J(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=z(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:N(t.cwd,4096,!0)}}function an(e){let t=z(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:N(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:N(t.cwd,4096,!0),checkoutRoot:N(t.checkoutRoot,4096,!0),version:sn(t.version),model:R(t.model,K)}}function sn(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function cn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:sn(t.version),selected:R(t.selected,K)}}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:N(t.provider,128,!0),model:N(t.model,256,!0),api:R(t.api,e=>I(e,ce)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,le),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&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){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`status`,`entries`,`withheld`,`remembered`]),n=B(t.entries,k.maxPageEntries,un),r=R(t.remembered,ue),i=I(t.status,[`complete`,`capacity`]),a=P(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>W([e.provider,e.model]))).size!==n.length||r&&!dn(n,r))&&M(),{status:i,entries:n,withheld:a,remembered:r}}function pn(e){let{version:t,selected:n,...r}=z(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return W({kind:`ok`,value:e},k.pageBytes),{...fn(r),version:sn(t),selected:R(n,K)}}function mn(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:N(t.path,4096,!0),cwd:N(t.cwd,4096,!0),epoch:t.epoch===null?null:V(t.epoch)}}function hn(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 gn=[`registry`,`workbench`,`project`],_n=[`reboot`,`crash`,`restart`,`storage`],vn=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function yn(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,gn),path:t.path===null?null:N(t.path,4096,!0),cause:I(t.cause,_n),actions:B(t.actions,vn.length,e=>I(e,vn)),workers:P(t.workers,0,1e6),archived:F(t.archived)}}function bn(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:N(t.home,4096,!0),projects:B(t.projects,128,mn),recoveries:B(t.recoveries,20,yn),build:Qe(t.build)}}var xn=[`restart`,`upgrade`],Sn=[`running`,`ready`,`failed`,`rolled-back`],Cn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],wn=/^(?: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 Tn(e){let t=N(e,96,!0);if(!wn.test(t))throw new j(`invalid`);return t}function En(e){let t=z(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:V(t.id),action:I(t.action,xn),from:Tn(t.from),to:t.to===null?null:Tn(t.to),state:I(t.state,Sn),reason:t.reason===null?null:I(t.reason,Cn),version:t.version===null?null:Tn(t.version),at:P(t.at,0),endedAt:t.endedAt===null?null:P(t.endedAt,0)}}var Dn=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function On(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function kn(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:N(e.name,96,!0),scope:I(e.scope,[`user`,`system`])}}return{kind:L(t.kind,`service`),version:Tn(t.version),unit:n,upgrade:I(t.upgrade,Dn),work:P(t.work,0,1e6),job:t.job===null?null:En(t.job)}}function An(e){let t=z(e,[`kind`,`version`,`deprecated`]);return{kind:L(t.kind,`release`),version:Tn(t.version),deprecated:F(t.deprecated)}}function jn(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 Mn=Object.freeze({chunkChars:262144,idleMs:6e5}),Nn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Pn(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 Fn(e,t){if(!Nn.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={"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Send with this model before approving a plan.":`请先使用此模型发送消息,再批准计划。`,"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 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":`选择工作文件夹`,"Choose a working folder to start. You can write a draft below.":`选择工作文件夹即可开始,也可以先在下方写草稿。`,"Write a message. Choose a folder before sending…":`输入消息,发送前请选择文件夹…`,"Choose a folder before sending.":`发送前请选择文件夹。`,"Returning to your last folder {path}…":`正在返回上次的文件夹 {path}…`,"Could not restore {path}. Choose a folder to continue; nothing was started.":`无法恢复 {path},请选择文件夹以继续;没有启动任何服务。`,"Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.":`选择服务所在主机上的文件夹。会话保留在原文件夹中,运行中的工作不受影响;仅在发送消息时按需启动执行服务。`,"Connecting…":`正在连接…`,"Ready to prepare 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.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"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 folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"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.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"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`,ee=`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(),ne(e)>t)throw new A(`oversize`);return e}function ne(e){return new TextEncoder().encode(e).length}function N(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function P(e){return typeof e!=`boolean`&&j(),e}function F(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function I(e,t){return e!==t&&j(),t}function L(e,t){return e===null?null:t(e)}function R(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 z(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 B(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 V(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function H(e){let t=M(e,O.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function U(e,t){return H(e),H(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function re(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=O.controlBytes){let n=t,r=e=>{if(n-=ne(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=z(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=R(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 G(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 ie(e){let t=R(e,[`code`,`effect`,`recovery`]);return{code:F(t.code,k),effect:F(t.effect,[`none`,`accepted`,`uncertain`]),recovery:F(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`],K=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],ce=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function le(e){let t=R(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:F(t.api,K),thinking:F(t.thinking,ce)}}function ue(e){let{sourceSelectionId:t,...n}=R(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:B(t),...le(n)}}function de(e){let t=R(e,[`role`,`sha256`]);return{role:F(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:V(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function q(e){let t=R(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:B(t.recordId),version:N(t.version,1),field:F(t.field,ae),bytes:N(t.bytes,0,O.detailBytes),sha256:V(t.sha256)}}function pe(e){let t=R(e,[`start`,`end`]),n=N(t.start);return{start:n,end:N(t.end,n+1,O.detailBytes)}}function me(e){let t=R(e,[`source`,`range`,`requireCompleteObservation`]),n=he(t.source),r;if(n===`current`)r={kind:n,assignmentId:re(R(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=R(t.source,[`kind`,`runId`,`childRunId`,`result`]);I(n,`historical`);let i=q(e.result);I(i.field,`final-text`),r={kind:`historical`,runId:B(e.runId),childRunId:B(e.childRunId),result:i}}let i=L(t.range,pe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:P(t.requireCompleteObservation)}}function he(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function ge(e){W(e,O.graphBytes);let t=R(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=q(t.plan);I(n.field,`plan`);let r=N(t.planRevision,1);n.version!==r&&j();let i={schema:I(t.schema,D),taskId:B(t.taskId),taskKind:F(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:N(t.taskRevision,1),revision:N(t.revision,1),planRevision:r,plan:n,assignments:z(t.assignments,O.assignments,e=>{let t=R(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:re(t.id),purpose:F(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,O.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,O.expectedOutputBytes,!0),role:de(t.role),model:ue(t.model),dependencies:z(t.dependencies,O.assignments,me)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new A(`forbidden`);c(e)}return i}function _e(e){let t=R(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=L(t.graphRevision,e=>N(e,1)),r=L(t.graphIdentity,V);return n===null!=(r===null)&&j(),{id:B(t.id),kind:F(t.kind,[`code`,`research`,`diagnosis`]),revision:N(t.revision,1),identity:V(t.identity),graphRevision:n,graphIdentity:r}}function ve(e){let t=R(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=R(t.observation,[`identity`,`complete`]);return{epoch:B(t.epoch),accessGeneration:N(t.accessGeneration,1),configRev:N(t.configRev,1),controlRev:N(t.controlRev,1),workspaceId:B(t.workspaceId),cwdId:B(t.cwdId),model:ue(t.model),checkEnvGeneration:N(t.checkEnvGeneration,1),checkoutGeneration:N(t.checkoutGeneration),observation:{identity:V(n.identity),complete:P(n.complete)},task:L(t.task,_e)}}function ye(e){let t=R(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:F(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:N(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),he(e)){case`create`:{let t=R(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:F(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=R(e,[`kind`,`taskId`,`plan`,`graph`]),n=ge(t.graph),r=B(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:he(e),taskId:B(R(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=R(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:B(t.taskId),check:ye(t.check)}}case`review`:{let t=R(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:B(t.taskId),runId:B(t.runId),changesIdentity:V(t.changesIdentity),checksRevision:N(t.checksRevision),acceptIssues:P(t.acceptIssues)}}default:return j()}}function xe(e){W(e);let t=R(e,[`expected`,`action`]);return{expected:ve(t.expected),action:be(t.action)}}function Se(e){W(e);let t=R(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:B(t.commandId),grant:B(t.grant),expected:ve(t.expected),action:be(t.action)}}function Ce(e){if(W(e),he(e)===`action`){let t=R(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:be(t.action)}}let t=R(e,[`kind`,`epoch`,`runId`]);return I(t.kind,`cancel`),{kind:`cancel`,epoch:B(t.epoch),runId:B(t.runId)}}function we(e){let t=R(e,[`commandId`,`epoch`,`runId`]);return{commandId:B(t.commandId),epoch:B(t.epoch),runId:B(t.runId)}}function Te(e){W(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=R(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=z(n.configuredChecks,32,ye);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:I(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:N(n.checksRevision),reviewRunId:L(n.reviewRunId,B),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:L(n.graph,ge),activeRunId:L(n.activeRunId,B),issues:z(n.issues,7,e=>F(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ee(e){W(e);let t=R(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:B(t.grant),expiresAt:n,preview:Te(t.preview)}}function J(e){let t=R(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:F(t.observed,[`complete`,`incomplete`]),source:F(t.source,[`complete`,`limited`,`unavailable`]),redacted:P(t.redacted),omissions:z(t.omissions,6,e=>F(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 De(e){let t=R(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:N(t.graphRevision,1),inputs:z(t.inputs,O.assignments,e=>{let t=R(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=q(t.result);I(i.field,`final-text`);let a=L(t.range,pe);a&&a.end>i.bytes&&j();let o=M(t.text,O.predecessorBytes);if(n+=ne(o),n>O.handoffBytes)throw new A(`oversize`);let s=N(t.dependencyIndex,0,O.assignments-1);return r.has(s)&&j(),r.add(s),ne(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:re(t.assignmentId),dependencyIndex:s,runId:B(t.runId),childRunId:B(t.childRunId),result:i,range:a,text:o,coverage:J(t.coverage)}})}}function Oe(e){let t=R(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:F(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:F(t.closure,se),exitCode:L(t.exitCode,e=>N(e,-2147483648,4294967295)),signal:L(t.signal,e=>M(e,32,!0)),durationMs:N(t.durationMs),stdin:F(t.stdin,[`delivered`,`failed`,`not-required`]),final:F(t.final,[`valid`,`missing`,`invalid`]),cleanup:F(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:J(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 ke(e){let t=R(e,[`kind`,`id`]);return{kind:F(t.kind,[`task`,`run`,`child`]),id:B(t.id)}}function Y(e){let t=M(e,O.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function Ae(e){W(e);let t=R(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:B(t.storeId),scope:ke(t.scope),query:L(t.query,e=>{let t=M(e,O.queryBytes);return t.length||j(),t}),snapshotSeq:H(t.snapshotSeq),recordId:L(t.recordId,B),recordVersion:L(t.recordVersion,e=>N(e,1)),field:L(t.field,e=>F(e,ae)),offset:N(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Y(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function je(e){let t=R(e,[`disposition`,`value`]),n=F(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function Me(e){let t=R(e,[`messageId`,`blockId`]);return{messageId:B(t.messageId),blockId:B(t.blockId)}}function X(e){let t=he(e);if(t===`message-final`)return{kind:t,messageId:B(R(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:F(R(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=R(e,[`kind`,`dependencyIndex`,`source`]),r=q(n.source);return I(r.field,`final-text`),{kind:t,dependencyIndex:N(n.dependencyIndex,0,O.assignments-1),source:r}}if(t===`message`){let n=R(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:B(n.messageId),blockId:B(n.blockId),index:N(n.index,0,O.dataFrames),stage:F(n.stage,[`stream`,`final`])}}let n=R(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return I(t,`tool`),{kind:`tool`,callId:B(n.callId),blockId:B(n.blockId),index:N(n.index,0,O.dataFrames),stage:F(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=R(e,[`owner`,`field`,`encoding`]),n=X(t.owner),r=F(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=F(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=R(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=F(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=F(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=L(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:X(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=he(e);switch(t){case`ready`:{let n=R(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:I(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=R(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:V(e.workerHash)}})()}}}case`message-start`:{let n=R(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=F(n.role,[`user`,`assistant`,`tool-result`]),i=L(n.resultCallId,B);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:B(n.messageId),role:r,source:je(n.source),resultCallId:i}}case`message-text`:{let n=R(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...Me({messageId:n.messageId,blockId:n.blockId}),detailId:B(n.detailId)}}case`message-end`:{let n=R(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:B(n.messageId),finalDetailId:L(n.finalDetailId,B),finalBlockCount:N(n.finalBlockCount,0,O.dataFrames),stopReason:F(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=R(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:B(n.callId),declaration:Me(n.declaration),index:N(n.index,0,O.dataFrames),source:je(n.source),name:M(n.name,128,!0),argsDetailId:L(n.argsDetailId,B),stage:F(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=R(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:B(n.callId),declaration:L(n.declaration,Me),source:je(n.source),name:M(n.name,128,!0),argsDetailId:L(n.argsDetailId,B)}}case`tool-update`:{let n=R(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:B(n.callId),detailId:B(n.detailId),semantics:I(n.semantics,`snapshot`)}}case`tool-end`:{let n=R(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=F(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=L(n.declaration,Me),a=P(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:B(n.callId),declaration:i,source:je(n.source),name:M(n.name,128,!0),resultDetailId:B(n.resultDetailId),isError:P(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(R(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=R(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:B(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=R(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,O.chunkBytes),i=N(n.offset,0,O.detailBytes);return i+ne(r)>O.detailBytes&&j(),{kind:t,detailId:B(n.detailId),offset:i,text:r}}case`detail-end`:{let n=R(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:B(n.detailId),bytes:N(n.bytes,0,O.detailBytes),sha256:V(n.sha256),coverage:J(n.coverage)}}case`capture-status`:return{kind:t,coverage:J(R(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:F(R(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=R(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:B(n.messageId),detailId:B(n.detailId),stopReason:I(n.stopReason,`stop`)}}default:return j()}}function Le(e){let t=R(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:F(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:F(t.closure,se),exitCode:L(t.exitCode,e=>N(e,-2147483648,4294967295)),signal:L(t.signal,e=>M(e,32,!0)),durationMs:N(t.durationMs),stdin:I(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=R(e,[`messageId`,`detailId`]);return{messageId:B(t.messageId),detailId:B(t.detailId)}}function ze(e){let t=R(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=H(t.committedSeq);return n===`0`&&j(),{childRunId:B(t.childRunId),detailId:B(t.detailId),content:q(t.content),committedSeq:n}}function Be(e){let t=he(e,`status`);if(t===`committed`){let n=R(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=R(e,[`status`,`selected`,`error`]);return{status:t,selected:L(n.selected,Re),error:ie(n.error)}}let n=R(e,[`status`,`selected`]);return{status:F(t,[`pending`,`uncertain`]),selected:L(n.selected,Re)}}function Ve(e,t){let n=L(e,H);return(n===`0`||n!==null&&t.status===`committed`&&U(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=he(e);if(t===`sdk`){let n=R(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Oe(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=R(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=L(n.settlementSeq,H);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:J(n.capture),settlementSeq:r}}let n=R(e,[`kind`,`outcome`,`required`]);I(t,`parent`);let r=z(n.required,O.assignments,e=>{let t=R(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=B(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:re(t.assignmentId),childRunId:n,native:L(t.native,Oe),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=F(n.outcome,oe);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&j(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=R(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=N(t.first,1,O.dataFrames+O.controlFrames),r=N(t.last,n,O.dataFrames+O.controlFrames),i=N(t.firstObservedMs),a=N(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=R(e,[`source`,`event`]),n=Ge(t.source),r=he(t.event);if(r===`stored-chunk`){let e=R(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:B(e.detailId),text:M(e.text,O.chunkBytes)}}}if(r===`stored-end`){let e=R(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:B(e.detailId),coverage:J(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=R(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:B(t.epoch),taskId:B(t.taskId),runId:B(t.runId),childRunId:B(t.childRunId)}}function Je(e){W({kind:`ok`,value:e},O.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=R(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:B(n.storeId),workspaceId:B(n.workspaceId),epoch:B(n.epoch)};if(!t)return I(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=z(n.runs,O.episodes,e=>{let t=R(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:B(t.taskId),runId:B(t.runId),operationId:B(t.operationId),epoch:B(t.epoch),kind:F(t.kind,[`start`,`generate-plan`,`check`]),stage:F(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=ie(e);return I(t.effect,`none`),t}function Xe(e){let t=R(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:V(t.sourceHash),contractHash:V(t.contractHash),buildId:V(t.buildId)}}function Ze(e){let t=F(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=R(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:V(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=R(e,[`contractHash`,`assets`]);return{contractHash:V(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=R(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:B(t.commandId),operationId:B(t.operationId),runId:L(t.runId,B),admission:F(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:H(t.committedSeq),execution:L(t.execution,e=>F(e,oe)),settlement:L(t.settlement,We),created:L(t.created,e=>{let t=R(e,[`kind`,`taskId`,`state`]);return{kind:I(t.kind,`task`),taskId:B(t.taskId),state:F(t.state,[`reserved`,`published`])}}),publication:F(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=R(e,[`identity`,`receipt`]),n=Ce(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(he(e)===`ok`)return{kind:`ok`,value:t(R(e,[`kind`,`value`]).value)};let n=R(e,[`kind`,`error`]);return I(n.kind,`error`),{kind:`error`,error:ie(n.error)}}function nt(e){switch(W(e),he(e,`status`)){case`found`:return{status:`found`,receipt:et(R(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:H(R(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ie(R(e,[`status`,`error`]).error)};default:return j()}}function rt(e){let t=R(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:B(t.runId),taskId:B(t.taskId),childRunId:L(t.childRunId,B),assignmentId:L(t.assignmentId,re),admission:pt(t.admission),lifecycle:F(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:L(t.outcome,e=>F(e,oe)),settlement:L(t.settlement,We),reason:L(t.reason,e=>F(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:F(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:J(t.coverage),result:L(t.result,q)};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=R(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:I(t.protocol,1),storeId:B(t.storeId),epoch:B(t.epoch),scope:ke(t.scope),committedSeq:H(t.committedSeq),context:mt(t.context),runs:z(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=he(e),n=R(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:B(n.storeId),epoch:B(n.epoch),scope:ke(n.scope),committedSeq:H(n.committedSeq)};if(t===`update`){let e=H(n.previousSeq);U(r.committedSeq,e)<=0&&j();let i=mt(n.context);_t(i,r.epoch,r.scope)||j();let a=z(n.runs,O.maxPageEntries,rt),o=z(n.removed,O.maxPageEntries,B),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 I(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=R(e,[`kind`,`cursor`,`next`,`coverage`]),n=Ae(t.cursor),r=Ae(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:J(t.coverage)}}function dt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Ae(t.cursor),content:q(t.content),range:L(t.range,pe),text:M(t.text,O.detailPageBytes),next:L(t.next,Ae),coverage:J(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!==ne(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=R(e,[`cursor`,`hits`,`next`,`coverage`]),n=Ae(t.cursor);n.query||j();let r=ne(n.query),i=z(t.hits,O.maxPageEntries,e=>{let t=R(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=q(t.content),a=bt(t.owner);xt(a,n.scope)||j();let o=pe(t.range),s=Ae(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=L(t.next,Ae);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:J(t.coverage)}}function pt(e){let t=R(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(t.context),r=L(t.graph,e=>{let t=R(e,[`recordId`,`revision`,`sha256`]);return{recordId:B(t.recordId),revision:N(t.revision,1),sha256:V(t.sha256)}}),i=F(t.kind,[`start`,`generate-plan`,`check`]),a=z(t.assignments,O.assignments,e=>{let t=R(e,[`assignmentId`,`childRunId`]);return{assignmentId:re(t.assignmentId),childRunId:B(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:B(t.operationId),commandId:B(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(he(e,`status`)===`available`)return{status:`available`,version:ve(R(e,[`status`,`version`]).version)};let t=R(e,[`status`,`workspaceId`,`taskId`,`error`]);I(t.status,`unavailable`);let n=ie(t.error);return I(n.effect,`none`),{status:`unavailable`,workspaceId:B(t.workspaceId),taskId:L(t.taskId,B),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=R(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=R(t.capabilities,[`actions`,`manualChecks`,`history`]),r=F(t.authority,[`browser`,`local`]),i=L(t.csrf,B),a={actions:P(n.actions),manualChecks:P(n.manualChecks),history:P(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:I(t.protocol,1),storeId:B(t.storeId),epoch:B(t.epoch),accessGeneration:N(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:B(t.workspaceId),storeId:B(t.storeId),epoch:B(t.epoch),committedSeq:H(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:mt(t.context),models:z(t.models,O.maxPageEntries,ue)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function bt(e){let t=R(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=R(t.entity,[`kind`,`id`,`version`]),r={taskId:B(t.taskId),runId:L(t.runId,B),childRunId:L(t.childRunId,B),entity:{kind:F(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:B(n.id),version:N(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=R(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:V(t.identity),complete:P(t.complete),checkoutGeneration:N(t.checkoutGeneration)}}function Ct(e){W(e,O.controlBytes);let t=he(e);switch(t){case`assignment-state`:{let n=R(e,[`kind`,`childRunId`,`state`,`reason`]),r=F(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=L(n.reason,e=>F(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:B(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:F(R(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=R(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:B(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=R(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:B(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=R(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:B(r.reservationId)}:{},lane:F(r.lane,[`reader`,`writer`,`check`]),state:F(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:N(r.checkoutGeneration)}}case`handoff`:{let n=R(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:B(n.childRunId),handoff:De(n.handoff),observation:St(n.observation)}}case`changes`:{let n=R(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=q(n.content);return I(r.field,`changes`),{kind:t,observationId:B(n.observationId),stage:F(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=R(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:B(n.checkId),selection:ye(n.selection),cwdId:B(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:N(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=R(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=R(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:B(e.operationId),reservationId:B(e.reservationId),from:N(e.from),to:N(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Le(r.native),o=F(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=L(r.output,q),u=J(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:B(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=R(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=P(n.acceptIssues),i=F(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=q(n.content);return I(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:B(n.reviewId),runId:B(n.runId),checksRevision:N(n.checksRevision),changesIdentity:V(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=R(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=N(n.expectedRevision),i=L(n.expectedIdentity,V),a=N(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:B(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:V(n.nextIdentity)}}case`publication-settled`:{let n=R(e,[`kind`,`publicationId`,`status`,`observed`]),r=F(n.status,[`published`,`conflict`,`uncertain`]),i=L(n.observed,e=>{let t=R(e,[`revision`,`identity`]);return{revision:N(t.revision,1),identity:V(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:B(n.publicationId),status:r,observed:i}}default:return j()}}function wt(e){let t=R(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:B(t.epoch),operationId:B(t.operationId),taskId:B(t.taskId),runId:L(t.runId,B)}}function Tt(e){W(e,O.ownerQueueBytes);let t=R(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=z(t.events,O.ownerQueueFrames,e=>{let t=he(e);if(t===`fact`){let r=Ct(R(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=R(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=F(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:B(r.detailId),owner:i,field:a,encoding:I(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=R(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:B(n.detailId),text:M(n.text,O.chunkBytes)}}let r=R(e,[`kind`,`detailId`,`coverage`]);return I(t,`content-end`),{kind:`content-end`,detailId:B(r.detailId),coverage:J(r.coverage)}});return{observedMs:N(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=R(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=F(t.reader,Et),r=R(t.scope,[`kind`,`id`]),i={kind:F(r.kind,[`workspace`,`task`,`run`,`child`]),id:B(r.id)},a=L(t.snapshotSeq,H),o=L(t.after,e=>{let t=R(e,[`recordId`,`version`,`offset`]);return{recordId:B(t.recordId),version:N(t.version,1),offset:N(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Y(t.navigation)}:{},storeId:B(t.storeId),scope:i,snapshotSeq:a,after:o,limit:N(t.limit,1,O.maxPageEntries)}}function Ot(e){let t=R(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:I(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=he(e);if(t===`run`)return{kind:t,projection:rt(R(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=R(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=H(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:B(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=R(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=H(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:B(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=R(e,[...n,...r]),a=bt(i.owner),o=N(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=L(i.plan,q);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=F(i.role,[`user`,`assistant`,`tool-result`]),n=F(i.state,[`partial`,`final`]),r=L(i.finalBlockCount,e=>N(e,0,O.dataFrames)),s=L(i.finalText,q),c=L(i.resultCallId,B);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:je(i.source)}}if(t===`tool`){let e=L(i.declaration,Me),n=L(i.declarationStage,e=>F(e,[`partial`,`final`])),r=P(i.startObserved),s=L(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:je(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=q(i.content);return(e.field!==n.field||!At(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:B(i.detailId),descriptor:e,content:n,coverage:J(i.coverage)}}I(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=R(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&j();let r=z(t.records,n.limit,kt),i=L(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:J(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},O.pageBytes);let t=R(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:J(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(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=R(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=R(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Y(t.navigation)}:{},storeId:B(t.storeId),scope:ke(t.scope),snapshotSeq:H(t.snapshotSeq),graph:{recordId:B(n.recordId),revision:N(n.revision,1),sha256:V(n.sha256)}}}function It(e){W({kind:`ok`,value:e});let t=R(e,[`request`,`graph`]),n=Ft(t.request),r=ge(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function Rt(e){let t=R(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:B(t.storeId),scope:ke(t.scope),snapshotSeq:H(t.snapshotSeq),format:F(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,O.controlBytes);let t=R(e,[`exportId`,`ordinal`,`event`]),n=he(t.event),r;switch(n){case`manifest`:{let e=R(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=R(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:V(i.exporterBuildSha256),capturePolicy:I(i.capturePolicy,`public-text-tools/2`)},schema:I(e.schema,ee),request:Rt(e.request),coverage:J(e.coverage),serviceProtocol:I(e.serviceProtocol,1),workerProtocol:I(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(R(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(R(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=R(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=q(e.content),a=L(e.range,pe),o=M(e.text,O.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==ne(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:J(e.coverage)};break}case`markdown`:r={kind:n,text:M(R(t.event,[`kind`,`text`]).text,O.detailPageBytes)};break;case`trailer`:{let e=R(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=J(e.coverage),a=P(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:N(e.frames,1),encodedBytes:N(e.encodedBytes),sha256:V(e.sha256),committedSeq:H(e.committedSeq),coverage:i};break}default:return j()}return{exportId:B(t.exportId),ordinal:N(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+=ne(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=R(e,[`taskId`,`revision`,`definitions`]),n=z(t.definitions,32,e=>{let t=R(e,[`selection`,`status`,`checkId`]),n=ye(t.selection),r=F(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=L(t.checkId,B);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:B(t.taskId),revision:N(t.revision),definitions:n}}function Wt(e){let t=R(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Y(t.navigation)}:{},storeId:B(t.storeId),scope:ke(t.scope),snapshotSeq:H(t.snapshotSeq),kind:F(t.kind,[`task`,`message`,`tool`]),id:B(t.id),version:N(t.version,1)}}function Gt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(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=R(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}var qt=e=>{let t=ie(e);return I(t.effect,`none`),t};function Jt(e){let t=R(e,[`storeId`,`taskId`]);return{storeId:B(t.storeId),taskId:L(t.taskId,B)}}function Yt(e){let t=Jt(e);return t.taskId===null&&j(),t}function Xt(e){let t=R(e,[`id`,`kind`,`revision`,`identity`]);return{id:B(t.id),kind:F(t.kind,[`code`,`research`,`diagnosis`]),revision:N(t.revision,1),identity:V(t.identity)}}function Zt(e){let t=z(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return R(e,[`status`]),{status:t};if(t===`saved`){let n=R(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:N(n.planRevision,1)}}let n=R(e,[`status`,`error`]);return I(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=R(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:B(t.workspaceId),epoch:B(t.epoch),committedSeq:H(t.committedSeq),context:mt(t.context),task:L(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:L(t.readablePlan,e=>{let t=R(e,[`source`,`text`,`editable`,`coverage`]),n=J(t.coverage),r=P(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:I(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=R(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=R(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:B(t.workspaceId),epoch:B(t.epoch),committedSeq:H(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:V(n.identity),complete:P(n.complete),checkoutGeneration:N(n.checkoutGeneration,0)},text:M(t.text,131072),git:P(t.git),coverage:J(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=R(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0)}}function an(e){let t=R(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0),revision:N(t.revision,0,2**53-1-1),model:L(t.model,le)}}function on(e){let t=R(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:M(t.cwd,4096,!0),checkoutRoot:M(t.checkoutRoot,4096,!0),version:sn(t.version),model:L(t.model,ue)}}function sn(e){let t=R(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:B(t.epoch),accessGeneration:N(t.accessGeneration,1),configRev:N(t.configRev,1),catalogId:B(t.catalogId)}}function cn(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`version`,`selected`]);return{version:sn(t.version),selected:L(t.selected,ue)}}function ln(e){W(e);let t=R(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:le(t.choice)}}function un(e){let t=R(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]),n={...t.images===void 0?{}:{images:P(t.images)},provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:L(t.api,e=>F(e,K)),thinking:z(t.thinking,7,e=>{let t=R(e,[`level`,`selectable`]);return{level:F(t.level,ce),selectable:P(t.selectable)}}),eligibility:F(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=R(e,[`status`,`entries`,`withheld`,`remembered`]),n=z(t.entries,O.maxPageEntries,un),r=L(t.remembered,le),i=F(t.status,[`complete`,`capacity`]),a=N(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(),{status:i,entries:n,withheld:a,remembered:r}}function pn(e){let{version:t,selected:n,...r}=R(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return W({kind:`ok`,value:e},O.pageBytes),{...fn(r),version:sn(t),selected:L(n,ue)}}function mn(e){let t=R(e,[`id`,`path`,`cwd`,`epoch`]);return{id:V(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:t.epoch===null?null:B(t.epoch)}}function hn(e){let t=R(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:I(t.kind,`project-observation`),status:F(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:B(t.epoch),workspaceId:t.workspaceId===null?null:B(t.workspaceId)}}var gn=[`registry`,`workbench`,`project`],_n=[`reboot`,`crash`,`restart`,`storage`],vn=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function yn(e){let t=R(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:B(t.id),at:N(t.at,0),scope:F(t.scope,gn),path:t.path===null?null:M(t.path,4096,!0),cause:F(t.cause,_n),actions:z(t.actions,vn.length,e=>F(e,vn)),workers:N(t.workers,0,1e6),archived:P(t.archived)}}function bn(e){let t=R(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:I(t.kind,`workbench`),epoch:B(t.epoch),csrf:B(t.csrf),home:M(t.home,4096,!0),projects:z(t.projects,128,mn),recoveries:z(t.recoveries,20,yn),build:Qe(t.build)}}var xn=[`restart`,`upgrade`],Sn=[`running`,`ready`,`failed`,`rolled-back`],Cn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],wn=/^(?: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 Tn(e){let t=M(e,96,!0);if(!wn.test(t))throw new A(`invalid`);return t}function En(e){let t=R(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:B(t.id),action:F(t.action,xn),from:Tn(t.from),to:t.to===null?null:Tn(t.to),state:F(t.state,Sn),reason:t.reason===null?null:F(t.reason,Cn),version:t.version===null?null:Tn(t.version),at:N(t.at,0),endedAt:t.endedAt===null?null:N(t.endedAt,0)}}var Dn=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function On(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function kn(e){let t=R(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=R(t.unit,[`name`,`scope`]);n={name:M(e.name,96,!0),scope:F(e.scope,[`user`,`system`])}}return{kind:I(t.kind,`service`),version:Tn(t.version),unit:n,upgrade:F(t.upgrade,Dn),work:N(t.work,0,1e6),job:t.job===null?null:En(t.job)}}function An(e){let t=R(e,[`kind`,`version`,`deprecated`]);return{kind:I(t.kind,`release`),version:Tn(t.version),deprecated:P(t.deprecated)}}function jn(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 Mn=Object.freeze({chunkChars:262144,idleMs:6e5}),Nn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Pn(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 Fn(e,t){if(!Nn.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 In={tasks:16,parallel:2,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4};function Ln(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Rn(e,t=!1){let n=
|
|
4
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return s}function Wn(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function Gn(e){return
|
|
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 In={tasks:16,parallel:2,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4};function Ln(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Rn(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 zn=(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 Bn(e){let t=R(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:N(t.timeoutMs,100,12e5)}}function Vn(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 Hn(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 Vn(e),r(t),Vn(e).filter(e=>n.has(e.id))}function Un(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,In.bytes),r&&e.version!==2)throw Error(`Unsupported delivery agreement version`);let i=R(e,[`goal`,`design`,`decisions`,`acceptance`,...r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),a=z(i.tasks,In.tasks,e=>{let t=R(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:zn(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:z(t.writes,128,e=>Rn(e,n)),after:z(t.after,In.tasks,e=>zn(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`);Vn(a);for(let e of r?[]:a)for(let t of a)if(!(e.id>=t.id||Hn(a,e.id).some(e=>e.id===t.id)||Hn(a,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>Ln(t.writes,e))||t.writes.some(t=>Ln(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let o=z(i.checks,In.checks,Bn);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:z(i.knowledge,16,e=>{let t=Rn(e,n);if(!t.endsWith(`.md`))throw Error(`Knowledge targets must be Markdown files`);return t})}:{projectContext:M(i.projectContext,16384),repairAttempts:N(i.repairAttempts,0,2)},tasks:a,checks:o,setup:z(i.setup,4,Bn),baselineChecks:z(i.baselineChecks,In.checks,Bn),delivery:F(i.delivery,[`local-merge`,`working-copy`])};Gn(s),M(Wn(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 Wn(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function Gn(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 Kn(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 qn(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 Jn(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 Yn(e){let t=R(e,[`policy`,`target`]),n=R(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:F(t.policy,[`task-branch-v1`]),target:{checkoutRoot:Jn(n.checkoutRoot),repository:Jn(n.repository),repositoryIdentity:V(n.repositoryIdentity),branch:qn(n.branch),head:Kn(n.head)}}}function Xn(e){let t=R(e,[`binding`,`taskBranch`,`worktreeRoot`,`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=R(t.integration,[`status`,`before`,`after`,`reason`]),r=R(t.cleanup,[`status`,`reason`]),i=e=>M(e,160,!0),a=L(t.acceptance,e=>{let t=R(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`]),n=z(t.checks,In.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Kn(t.candidate),tree:Kn(t.tree),planDigest:V(t.planDigest),contextDigest:V(t.contextDigest),checks:n,review:i(t.review)}}),o=L(t.candidate,Kn);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=L(t.workspace,e=>{let t=R(e,[`head`,`state`]);return{head:Kn(t.head),state:F(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=Yn(t.binding),l=qn(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:Jn(t.worktreeRoot),preparation:F(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:F(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Kn(n.before),after:L(n.after,Kn),reason:M(n.reason,2048)},postChecks:F(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:F(r.status,[`pending`,`removed`,`retained`]),reason:M(r.reason,2048)}}}function Zn(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 Qn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=R(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:Yn(n.delivery)},id:B(n.id),epoch:B(n.epoch),digest:V(n.digest),observation:V(n.observation),model:sn(n.model),plan:Un(n.plan),cwd:M(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:M(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=R(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function $n(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=R(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=z(n.questions,In.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:z(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=R(e,[`action`,`plan`,`model`]);return{action:t,plan:Un(n.plan),model:sn(n.model)}}if(t===`prepare`||t===`execute`){let n=R(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:B(n.proposalId),digest:V(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:B(n.grant)}}let n=R(e,[`action`,`runId`]);return{action:F(n.action,[`cancel`]),runId:B(n.runId)}}function er(e){let t=R(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=>F(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=R(t.verification,[`id`,`source`,`steps`]);return{id:B(e.id),source:V(e.source),steps:z(e.steps,32,e=>M(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:N(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:N(t.revision,0)},...t.delivery===void 0?{}:{delivery:Xn(t.delivery)},...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:ar(t.diagnostics)},id:B(t.id),epoch:B(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:F(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:L(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:z(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=R(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:ir(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=R(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:V(e.workerHash)}})()},id:M(r.id,160,!0),...t?{childRunId:B(r.childRunId)}:{},kind:F(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:L(r.exitCode,e=>N(e,-2147483648,2147483647)),truncated:P(r.truncated)}})}}function tr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:er(R(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Qn(R(e,[`type`,`proposal`]).proposal)};let n=R(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:F(n.type,[`grant`]),proposal:Qn(n.proposal),grant:B(n.grant),expiresAt:N(n.expiresAt,0)}}function nr(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${Vn(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 rr=e=>
|
|
11
|
-
`)}function sr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=
|
|
12
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function hr(e,t,n=!1){let r=e.role===`tool`,i=r?``:pr(e.text,dr);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?pr(mr(e.args),fr):``,error:e.error,parts:t}}function gr(e){let t=z(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:P(t.updatedAt,0)}}var _r=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function vr(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,cr),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%Mn.chunkChars||n.live!==void 0&&n.live!==!0)throw new j(`invalid`);return{kind:t,id:nn(n.id),leaf:R(n.leaf,cr),...n.live===void 0?{}:{live:!0},entry:cr(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,cr),turnId:cr(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,cr)}}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:N(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,gr)}:{}}}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,cr),known:R(n.known,cr)}}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:N(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function yr(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 j(`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,cr),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 j(`invalid`);let r=yr(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:V(n.commandId),imageId:V(n.imageId),send:r,mimeType:I(n.mimeType,Nn),size:P(n.size,1),offset:P(n.offset,0),data:N(n.data,Mn.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,cr),text:N(n.text,lr),...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:$n(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,cr),text:N(n.text,lr),...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:N(n.path,4096,!0),epoch:V(n.epoch)}}function br(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,_r),notice:N(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,Sr)}}function xr(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 j(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:cr(t.entry),index:P(t.index,0),mimeType:I(t.mimeType,Nn)}})}function Sr(e){let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:xr(t.images)},id:N(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,262144),name:N(t.name,128),args:N(t.args,65536),error:F(t.error)}}function Cr(e){let t=z(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:xr(t.images)},id:N(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,dr),clipped:F(t.clipped),name:N(t.name,128),target:N(t.target,fr),error:F(t.error),parts:P(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new j(`invalid`);return n}function wr(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:cr(t.id),entry:R(t.entry,cr),at:P(t.at,0),status:I(t.status,_r),notice:N(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 Tr(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:N(n.title,512,!0),leaf:R(n.leaf,cr),status:I(n.status,_r),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 Er(e){let t=z(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:V(t.commandId),text:N(t.text,16384),status:I(t.status,_r),notice:N(t.notice,1024)}}function Dr(e){let t=z(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:cr(t.id),parent:R(t.parent,cr),text:N(t.text,1024),at:P(t.at,0),leaf:cr(t.leaf),current:F(t.current)}}function Or(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,Nn),data:N(n.data,Mn.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:pn(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:N(n.stepId,160,!0),turn:R(n.turn,br)}}if(t===`cadence-conversation`)return{kind:t,state:sr(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,In.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,er);if(r&&r.id!==n)throw new j(`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 j(`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,er),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 j(`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:Qn(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:tr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,8,Tr)};if(n===`conversations`){let t=z(e,[`kind`,`entries`,`next`]);return{kind:n,entries:B(t.entries,200,Tr),next:R(t.next,gr)}}if(n===`conversation`){let t=z(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=R(t.summary,Tr),i=P(t.turns,0);if(!r&&i)throw new j(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:B(t.commands,64,V)},summary:r,leaf:R(t.leaf,cr),continues:F(t.continues),turns:i,branches:P(t.branches,0),runs:B(t.runs,200,V),attempt:R(t.attempt,Er)}}if(n===`conversation-tree`){let t=z(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:B(t.nodes,ur,Dr),truncated:F(t.truncated)}}if(n===`conversation-turn`){let t=z(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=wr(t.turn),i=P(t.start,0),a=B(t.steps,24,Cr);if(i+a.length>r.steps)throw new j(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,cr),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,cr),turnId:cr(t.turnId),step:P(t.step,0),part:P(t.part,0),item:Sr(t.item)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:N(t.path,4096),parent:R(t.parent,e=>N(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:N(t.name,1024,!0),path:N(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:N(t.path,4096),text:N(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:N(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:N(r.path,4096,!0),link:N(r.link,8192,!0)}}var kr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ar=f.createContext&&f.createContext(kr),jr=[`attr`,`size`,`title`];function Mr(e,t){if(e==null)return{};var n,r,i=Nr(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 Nr(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 Pr(){return Pr=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},Pr.apply(null,arguments)}function Fr(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 Ir(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Fr(Object(n),!0).forEach(function(t){Lr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Lr(e,t,n){return(t=Rr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rr(e){var t=zr(e,`string`);return typeof t==`symbol`?t:t+``}function zr(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 Br(e){return e&&e.map((e,t)=>f.createElement(e.tag,Ir({key:t},e.attr),Br(e.child)))}function Q(e){return t=>f.createElement(Vr,Pr({attr:Ir({},e.attr)},t),Br(e.child))}function Vr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Mr(e,jr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Pr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Ir(Ir({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 Ar===void 0?t(kr):f.createElement(Ar.Consumer,null,e=>t(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:`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 Ur(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 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:[]}]})(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:`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 Kr(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 qr(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 Jr(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 Yr(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 Xr(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 Zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 Qr(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 $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:`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 ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 ti(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 ni(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 ri(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 ii(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`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 ai(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 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:`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 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:`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 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:`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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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:`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 di(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 fi(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 pi(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 mi(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 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:`18 15 12 9 6 15`},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:`9 18 15 12 9 6`},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:`6 9 12 15 18 9`},child:[]}]})(e)}function vi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 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:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},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:`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 xi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var $=e=>({kind:`error`,error:ee(`unavailable`,e?`uncertain`:`none`)}),Si=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=vr(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Or);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=yr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Or);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),pn):$(!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 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=xe({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Ee);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=Se(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=we(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:ee(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=Y(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=Ae(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=Ae(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)}}},Ci=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ne(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ne(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{ot(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function wi(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 Ti={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`},Ei=`/api/v1/events`,Di=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Oi(e,t){if(Di.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return k.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return k.pageBytes}return k.controlBytes}function ki(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Ai(e,t){switch(e){case`workbenchRead`:return vr(t);case`workbenchCommand`:return yr(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 V(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return Y(t);case`detail`:case`search`:return Ae(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return xe(t);case`command`:return Se(t);case`cancel`:return we(t)}}function ji(e,t){if(Di.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Or);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,pn);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,Ee);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 Mi(e){return[...Di,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ni(e,t){let n=Ti[e];return t===null||ki(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Pi(e,t){let n=Ai(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ti[e]:Ni(e,n);return ki(e)||Mi(e)&&(r||te(i)>k.headerBytes/4)?{path:Ti[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Fi(e){W(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Ii=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`]=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 j(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Pi(e,Ai(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:wi([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 Li(t,Oi(e)),s=ie(a);if(te(a)>Oi(e,s))throw new j(`oversize`);let c=ji(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??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`,xe(e))}command(e){return this.request(`command`,Se(e))}cancel(e){return this.request(`cancel`,we(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 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=Pi(`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(
|
|
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=Y(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}`:``}${Ei}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new j(`invalid`);let n=Fi(ie(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Li(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 Ri={sourceHash:`099be83aa462f6a3df11b4b97518effafb28cf24bd70af5ddc2f183183c181b8`,contractHash:`ee8ae17515fd8baf0aba38eb6a78a27e8c574cda265ddc17884c0741a6fb56b1`,buildId:`67e998849b4f7edb269938afeb94202d3f5fcf4c9d45cd117405d2995e35492e`};function zi(e){let t=new Ii({origin:window.location.origin,...e?{project:e}:{},...Ri?{build:{kind:`browser`,...Ri}}:{},socket:e=>new WebSocket(e)});return{client:new Si(t),transport:t}}function Bi(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 Vi(e=typeof window>`u`?``:window.location.search){return Bi(e,``).project}function Hi(e=typeof window>`u`?``:window.location.hash){return Bi(``,e).chat}function Ui(){let e=Vi();return e?`/projects/${e}`:``}function Wi(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&Bi(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?cr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function Gi(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ne(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ne(t.committedSeq,r.committedSeq)>0||W(r)===W(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function Ki(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(vr(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 qi(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 Ji(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Ki(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 Yi(e){return ie(await Li(e,1048576),1048576)}function Xi(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 Zi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Yi(r);if(!r.ok)throw Error(Xi(i));return t(i)}function Qi(e){return Zi(`/workbench/v1/service`,kn,e)}function $i(e){return Zi(`/workbench/v1/service/release`,An,e)}async function ea(e,t){if(!Ri)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`,...Ri})},body:JSON.stringify(e)}),r=await Yi(n);if(!n.ok)throw Error(Xi(r));let i=z(r,[`kind`,`job`]);return L(i.kind,`service-job`),En(i.job)}function ta(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function na(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function ra(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 Yi(r);if(!r.ok)throw Error(Xi(a));let c=hn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...na(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...na(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:ta(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var ia=e=>e===`unauthenticated`||e===`forbidden`,aa=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Ci,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new Ci,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,ia(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(ia(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,ia(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,ia(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Ci,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Ri?{kind:`browser`,...Ri}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new Ci,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Ci,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function oa(e,t,n,r){let i=(0,f.useMemo)(()=>new aa(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 sa=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 ca({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 la(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 ua(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 da(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 fa(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=la(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 pa(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),ua(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 ma({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)(ma,{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 ha(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 ga(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ha(e)}return ha(e)}function _a(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 ga(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 va(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 ya=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ba(!0)},text:{92:ba(!1)}});let t={enter:{backslashMathInline:xa,backslashMathDisplay:xa,backslashMathBlock:xa},exit:{backslashMathInline:Sa,backslashMathDisplay:Sa,backslashMathBlock:Sa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ba(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 xa=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)},Sa=function(e){this.exit(e)},Ca=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=_a();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)(vi,{}):(0,h.jsx)(pi,{}),n&&t(`Copy unavailable`)]})}),wa=[s,d,ya],Ta=[s,l,d,ya],Ea=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Da(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 Oa({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Ta:wa,rehypePlugins:t?[i,o,...Ea]:Ea,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ja,a:Aa,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ka=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Oa,{...e})})});function Aa({href:e,children:t}){let n=e&&Da(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 ja({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=va(r).map(e=>{let t=`code-offset:${i}`;return i+=Ma(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)(Ca,{text:Ma(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 Ma(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ma).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ma(t?.children)}return``}function Na(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 Pa=new Map;function Fa(e,t){t.length?Pa.set(e,t):Pa.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Pa].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 Ia(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 La(e,t){let n=t.startContainer.parentElement;for(let r of Ia(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 Ra({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?Na(n,r):[];return l.current=i,c(i.length),o(0),Fa(u,i),()=>Fa(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(La(e.current,l.current[n]),Fa(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Fa(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function za({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>Ae(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 fa(e,t,n.signal);if(n.signal.aborted)return;let i=await ga(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)(ma,{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)(Ra,{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)(ka,{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 Ba({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)(ma,{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)(Jr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function Va({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=pa(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)(Ba,{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)(ma,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(da(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)(za,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ha({client:e,seed:t}){return(0,h.jsx)(Ua,{client:e,seed:t},W(t))}function Ua({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)(ma,{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 Wa(e){let t=Pi(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Ui()+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 Ga({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)(Hr,{"aria-hidden":`true`})})]}),t]})}function Ka({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)(Ga,{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{Wa({...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 qa(e,t){if(!t||te(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Ae({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Ja(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 Ya({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=qa(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)(Ga,{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)(qr,{}),(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)(ma,{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(Ja(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 Xa({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)(ma,{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 Za({client:e,seed:t}){return(0,h.jsx)(Qa,{client:e,seed:t},W(t))}function Qa({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)(ma,{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)(za,{client:e,cursor:da(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)(ka,{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 $a({client:e,seed:t,onScope:n}){let{t:r}=T(),i=pa(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ba,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Xa,{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)(Za,{client:e,seed:o},o.graph.recordId)]})}function eo({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)(qr,{"aria-hidden":`true`})})}function to(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 no(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 ro(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)??io(n.role,n.customType)}return r}function io(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 ao(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function oo(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=ro(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=to(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=>no(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)=>ao(e,t,s.current,n),[])}}var so=(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`})}),co=(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)(hi,{"aria-hidden":`true`}):(0,h.jsx)(ci,{"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)(za,{compact:!0,client:t,cursor:da(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(Va,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function lo({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=oo(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)(so,{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)(co,{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)(xi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function uo({client:e,seed:t}){let{t:n}=T(),r=pa(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ba,{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)(lo,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function fo({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)(_i,{}):(0,h.jsx)(gi,{})}):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 po=(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)(fo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Ur,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(Va,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),mo=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function ho({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(mo(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 go=[`queued`,`running`];function _o(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 vo=4,yo=1e4;function bo(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?go.includes(t.status):i-(u.get(e)??0)>=yo}).reverse();for(let n=0;n<a.length;n+=vo){let r=await Promise.all(a.slice(n,n+vo).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+vo<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>go.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),yo))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function xo({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=bo(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(!go.includes(e.step.status))-Number(!go.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>go.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)(_i,{}),(0,h.jsx)(di,{}),(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=_o(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 So=2e4;async function Co(e,t,n,r){let i=wi([t],So);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function wo(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 To(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 Eo(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Do(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:cr(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,lr,!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,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Oo(e.model))}:{}})}function Oo(e){return ue({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function ko(e,t){return Object.freeze({...e,model:Object.freeze(Oo(t))})}function Ao(e,t){if(e.model&&W(e.model)!==W(Oo(t)))throw new j(`stale`)}function jo(e,t){return Object.freeze({...e,preparedEpoch:V(t)})}function Mo(e,t,n){return Object.freeze({...ko(e,t),installModel:!n})}function No(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`,`incompatible`].includes(t.status)?`cancel`:`wait`:`cancel`}function Po(e,t){return!!e&&e===t}async function Fo(e,t,n,r){if(!r())throw new j(`stale`);if(!t.installModel||!t.model)return n;if(!dn(n.entries,t.model))throw new j(`unsupported-context`);if(n.selected&&W(Oo(n.selected))===W(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new j(`stale`);if(i.kind===`error`)throw new j(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new j(`stale`);if(a.kind===`error`)throw new j(a.error.code);if(!a.value.selected||W(a.value.version)!==W(i.value.version)||W(a.value.selected)!==W(i.value.selected))throw new j(`stale`);return Ao(t,a.value.selected),a.value}function Io(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new j(`stale`);let n=yr(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 Lo(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 Ro(e){for(let t of e){if(!Nn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function zo(e){Ro([e]);let t=new Uint8Array(await e.arrayBuffer());return Fn(t,e.type),t}var Bo=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 Vo(e,t,n,r){Ro(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await zo(a);if(!r())throw Error(`stale`);let o=Bo(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Mn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Mn.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 Ho(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>Mn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Mn.chunkChars)throw Error(`invalid`)}let i=Pn(n.join(``));return Fn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Uo=1e3,Wo=1e4,Go=4,Ko=e=>e===`queued`||e===`running`,qo=class extends Error{},Jo=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 qo?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=Ko(this.summary?.status)||[...this.turns.values()].some(e=>Ko(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Uo:Wo)}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 qo(`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||Ko(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 qo(`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 qo(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=wi([t,r]);try{return await Ho(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=wi([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 qo(`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>=Go&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new qo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new qo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Yo(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 Jo(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??Xo,loadEarlier:i?.loadEarlier??Xo,choose:i?.choose??Xo}}function Xo(){}function Zo(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`incompatible`&&t.status!==`preparing`?r:void 0,[s,c]=(0,f.useState)(0),l=(0,f.useRef)(0),u=(0,f.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,revision:s,preview:o}),[e,i,a,n,s,o]),d=(0,f.useRef)(u);d.current=u;let p=(0,f.useRef)(!0);(0,f.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let m=(0,f.useCallback)(()=>p.current&&(u.epoch!==null||!!u.preview)&&d.current===u&&l.current===u.revision,[u]),[h,g]=(0,f.useState)();(0,f.useEffect)(()=>{if(u.epoch===null&&!u.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&m();return u.preview?(u.preview(t.signal).then(e=>{n()&&g({scope:u,preview:e})}).catch(e=>{n()&&g({scope:u,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal).then(e=>{n()&&(e.kind===`error`?g({scope:u,error:e.error.code}):e.value.version.epoch===u.epoch?g({scope:u,catalog:e.value}):g({scope:u,error:`stale`}))}).catch(()=>{n()&&g({scope:u,error:`unavailable`})}),()=>t.abort())},[e,u,m]);let _=h?.scope===u&&m()?h:void 0;return{catalog:_?.catalog,preview:_?.preview,error:_?.error,loading:(i!==null||!!o)&&!_,isCurrent:m,reread(){m()&&c(++l.current)},accept(e){return!m()||e.version.epoch!==u.epoch?!1:(g({scope:u,catalog:e}),!0)}}}async function Qo(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 $o(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function es(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var ts={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},ns={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.`},rs=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,is=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function as(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>le.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function os(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(ts[t.thinking])}`,[e])}function ss({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:p=`conversation`}){let{t:m}=T(),g=os(),_=t.status===`ready`,v=n.preview,y=_||!!v||n.loading&&t.status!==`preparing`,b=_?t.epoch:null,x=_?t.attachmentVersion:null,{error:S,loading:C,reread:w}=n,E=_?n.catalog:void 0,D=E??v,[O,k]=(0,f.useState)(``),[A,j]=(0,f.useState)(!1),[ee,M]=(0,f.useState)(``),N=(0,f.useRef)(null),te=(0,f.useRef)(null),P=(0,f.useRef)(null),F=(0,f.useRef)(null),I=(0,f.useRef)(c);I.current=c,(0,f.useEffect)(()=>{k(``)},[e,b,x]);let L=(0,f.useCallback)((e=!0,t)=>{t?I.current(!1,t):I.current(!1),M(``),k(``),e&&te.current?.focus({preventScroll:!0})},[]);(0,f.useEffect)(()=>{if(!s)return;y&&P.current?.focus({preventScroll:!0});let e=e=>{N.current?.contains(e.target)||L(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,L,y]);let R=E?.selected??null,z=i??R??(v?r:null)??D?.remembered??null,B=(0,f.useMemo)(()=>{let e=ee.trim().toLowerCase(),t=new Map;for(let n of D?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[D,ee]),V=D?.entries.find(e=>is(e,z)),H=(_||!!v)&&!!D&&!C&&!S&&n.isCurrent(),U=async(t,r)=>{if(!H||!n.isCurrent()||!D||!t.api||A||o)return;let i=ue({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),L(!0,`chosen`);else if(E&&e){if(R&&rs(R,i))L(!0,`chosen`),u?.(i);else{j(!0),k(``);try{let t=await e.chooseModel({expected:E.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){k(t.error.code),w();return}let r={...E,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),L(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(k(`uncertain`),w())}finally{j(!1)}}}},ne=()=>[...F.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],re=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=ne(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?P.current?.focus():t[Math.min(n,t.length-1)]?.focus()},W=t.status===`stopped`||t.status===`not-started`,ie=D?null:r,G=n.preview||n.loading&&a||S&&a?m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):W?m(`Choose a model`):t.status===`preparing`?m(`Preparing execution…`):t.status===`incompatible`?m(`Model selection needs a compatible connection`):t.status===`connecting`?m(`Checking execution state…`):t.status===`unavailable`?m(`Execution state unavailable`):m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`),ae=z?g(z):W&&ie?m(`Last used: {model}`,{model:g(ie)}):G;return(0,h.jsxs)(`div`,{className:`model-picker`,ref:N,children:[(0,h.jsxs)(`button`,{ref:te,type:`button`,className:`model-trigger${z&&!R||ie?` remembered`:``}${D&&!z?` empty`:``}`,"aria-label":m(`Model: {model}`,{model:ae}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?m(`Switch models after the current reply finishes.`):i?m(`Choose now; the model is verified when you send.`):ie?m(`Last used model; availability is checked when you send.`):z&&!R?m(`Last used model; it is used again when you send.`):z?`${z.provider}/${z.model} · ${z.api}`:G,onClick:()=>{s?L():(k(``),c(!0))},children:[(0,h.jsx)(di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:ae}),(0,h.jsx)(_i,{"aria-hidden":`true`})]}),s&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":m(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),L())},children:[d&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose a model; your message is sent right after.`)}),v&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose now; the model is verified when you send.`)}),!y&&!S&&(0,h.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?m(`Execution is being prepared for your Send. Models will load when it is ready.`):t.status===`incompatible`?m(`Reload the page to observe a compatible execution connection before choosing a model.`):m(`Model selection is unavailable until the current conversation and execution state are observed.`)}),ie&&(0,h.jsxs)(`p`,{className:`model-popover-lead`,children:[m(`Last used: {model}`,{model:g(ie)}),(0,h.jsx)(`br`,{}),m(`Last used model; availability is checked when you send.`)]}),y&&(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:P,type:`search`,"aria-label":m(`Search models`),placeholder:m(`Search models…`),value:ee,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),ne()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),ne()[0]?.click())}})]}),y&&(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":m(`Models`),ref:F,onKeyDown:re,children:[C&&(0,h.jsx)(`p`,{className:`model-empty`,role:`status`,children:m(`Reading models…`)}),B.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=is(e,z);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!H||!t||A||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void U(e,as(e,z?.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`?m(`Credentials unavailable`):m(`Not supported`)}),n&&(!R||!!i)&&(0,h.jsx)(`span`,{className:`model-option-note`,children:m(`Used when you send`)}),n&&(0,h.jsx)(vi,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),D?.status===`complete`&&B.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:ee.trim()?m(`No matching models.`):m(v?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),y&&V&&V.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:m(`Thinking`)}),V.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":m(`Thinking level: {level}`,{level:m(ts[e.level])}),"aria-pressed":z?.thinking===e.level,disabled:!H||!e.selectable||A||o,onClick:()=>void U(V,e.level),children:m(ts[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[v&&!S&&(0,h.jsx)(`button`,{type:`button`,className:`link`,disabled:C||A,onClick:w,children:m(`Refresh models`)}),o&&(0,h.jsx)(`p`,{children:m(`Switch models after the current reply finishes.`)}),D?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:m(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!D?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:m(D.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:D.withheld})}),(_||!!a)&&S&&(0,h.jsxs)(`p`,{role:`alert`,children:[m(`The model list could not be read ({code}).`,{code:S}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:w,children:m(`Read again`)})]}),O&&(0,h.jsx)(`p`,{role:`alert`,children:ns[O]?m(ns[O]):m(`The model was not changed ({code}).`,{code:O})}),H&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:m(A?`Switching model…`:p===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function cs(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 ls({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Ki(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>cs(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)(Hr,{"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 us({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 ds(){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])];Ro(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 fs({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),zo(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 ps({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 ms({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(ps,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var hs=/^\s{0,3}(`{3,}|~{3,})/,gs=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function _s(e){return e.trim()===``}function vs(e){let t=hs.exec(e);return t?t[1]:null}function ys(e){let t=e.split(`
|
|
10
|
+
`)||`No documentation edits authorized; existing knowledge is still read.`:e.projectContext}\n`}var rr=e=>N(e,0,864e13);function ir(e){let t=R(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:rr(t.createdAt),preparedAt:L(t.preparedAt,rr),startedAt:L(t.startedAt,rr),stopRequestedAt:L(t.stopRequestedAt,rr),closedAt:L(t.closedAt,rr),settledAt:L(t.settledAt,rr),timeoutMs:N(t.timeoutMs,100,12e5),stopReason:L(t.stopReason,e=>M(e,32,!0))}}function ar(e){let t=R(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=R(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:rr(t.acceptedAt),acquiredAt:L(t.acquiredAt,rr),settledAt:L(t.settledAt,rr),owner:{version:M(n.version,128,!0),build:M(n.build,64,!0),entry:M(n.entry,4096,!0),pid:N(n.pid,1),node:M(n.node,128,!0),platform:M(n.platform,32,!0),startedAt:rr(n.startedAt)}}}function or(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 sr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=R(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:nn(n.id),revision:N(n.revision,0),enabled:P(n.enabled),head:L(n.head,B),proposal:L(n.proposal,Qn),runs:z(n.runs,200,B),...t?{notice:M(n.notice,1024,!0)}:{}}}function cr(e){let t=M(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new A(`invalid`);return t}var lr=16384,ur=1e3,dr=16384,fr=1024;function pr(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 mr(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 hr(e,t,n=!1){let r=e.role===`tool`,i=r?``:pr(e.text,dr);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?pr(mr(e.args),fr):``,error:e.error,parts:t}}function gr(e){let t=R(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:N(t.updatedAt,0)}}var _r=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function vr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:rn(R(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=R(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:nn(n.id),leaf:L(n.leaf,cr),ordinal:N(n.ordinal,0),before:L(n.before,e=>N(e,0))}}case`conversation-image`:{let n=R(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=N(n.offset,0);if(r%Mn.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:nn(n.id),leaf:L(n.leaf,cr),...n.live===void 0?{}:{live:!0},entry:cr(n.entry),index:N(n.index,0),offset:r}}case`conversation-step`:{let n=R(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:L(n.leaf,cr),turnId:cr(n.turnId),step:N(n.step,0),part:N(n.part,0)}}case`cadence-conversation`:return{kind:t,id:nn(R(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=R(e,[`kind`,`id`,`leaf`]);return{kind:t,id:nn(n.id),leaf:L(n.leaf,cr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=R(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:L(r.after,B),...n?{scan:B(r.scan)}:{}}}case`workflow-active`:return R(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=R(e,[`kind`,`id`,`stepId`]);return{kind:t,id:B(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:{let n=R(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:B(n.id),...n.before===void 0?{}:{before:N(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=R(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:L(r.after,gr)}:{}}}case`conversation-active`:case`projects`:return R(e,[`kind`]),{kind:t};case`conversation`:{let n=R(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:nn(n.id),leaf:L(n.leaf,cr),known:L(n.known,cr)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=R(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:F(r.kind,[`files`,`file`,`directories`]),path:M(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function yr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=R(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:B(n.commandId),location:rn(n.location),expected:sn(n.expected),choice:le(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=R(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:B(n.commandId),epoch:B(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:B(n.runId)}}if(t===`cadence-exit`){let n=R(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:rn(n.location)},commandId:B(n.commandId),conversationId:nn(n.conversationId),head:L(n.head,cr),revision:N(n.revision,0)}}if(t===`image-upload`){let n=R(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=yr(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:B(n.commandId),imageId:B(n.imageId),send:r,mimeType:F(n.mimeType,Nn),size:N(n.size,1),offset:N(n.offset,0),data:M(n.data,Mn.chunkChars,!0)}}if(t===`cadence-send`){let n=R(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:B(n.commandId),conversationId:nn(n.conversationId),head:L(n.head,cr),text:M(n.text,lr),...n.images===void 0?{}:{images:z(n.images,2**53-1,B)},model:sn(n.model),revision:N(n.revision,0),intent:F(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=R(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:B(r.commandId),conversationId:nn(r.conversationId),revision:N(r.revision,0),proposalId:B(r.proposalId),digest:V(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:B(r.grant)}}if(t===`workflow`){let n=R(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:B(n.commandId),epoch:B(n.epoch),request:$n(n.request)}}if(t===`send`){let n=R(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:B(n.commandId),conversationId:nn(n.conversationId),head:L(n.head,cr),text:M(n.text,lr),...n.images===void 0?{}:{images:z(n.images,2**53-1,B)},model:sn(n.model)}}if(t===`interrupt`){let n=R(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:B(n.commandId),conversationId:nn(n.conversationId),turnId:B(n.turnId),epoch:B(n.epoch)}}let n=R(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:F(n.kind,[`open-project`]),commandId:B(n.commandId),path:M(n.path,4096,!0),epoch:B(n.epoch)}}function br(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=R(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),a=r?R(i.transcript,[`pages`]):null,o=n?R(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:on(i.execution)},id:B(i.id),epoch:B(i.epoch),status:F(i.status,_r),notice:M(i.notice,1024),...a?{transcript:{pages:N(a.pages,0)}}:{},omitted:{thinking:o?P(o.thinking):!1,media:o?P(o.media):!1,other:o?P(o.other):!1},items:z(i.items,256,Sr)}}function xr(e){return z(e,2**53-1,e=>{let t=R(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:cr(t.entry),index:N(t.index,0),mimeType:F(t.mimeType,Nn)}})}function Sr(e){let t=R(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:xr(t.images)},id:M(t.id,160,!0),role:F(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:P(t.error)}}function Cr(e){let t=R(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:xr(t.images)},id:M(t.id,160,!0),role:F(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,dr),clipped:P(t.clipped),name:M(t.name,128),target:M(t.target,fr),error:P(t.error),parts:N(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function wr(e){let t=R(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],`entry`,`at`]),n=R(t.omitted,[`thinking`,`media`,`other`]),r=N(t.steps,0);return{...t.execution===void 0?{}:{execution:on(t.execution)},id:cr(t.id),entry:L(t.entry,cr),at:N(t.at,0),status:F(t.status,_r),notice:M(t.notice,1024),omitted:{thinking:P(n.thinking),media:P(n.media),other:P(n.other)},steps:r,stable:N(t.stable,0,r)}}function Tr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=R(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[]]),r=t(`live`)?R(n.live,[`commandId`,`epoch`]):null;return{id:nn(n.id),title:M(n.title,512,!0),leaf:L(n.leaf,cr),status:F(n.status,_r),updatedAt:N(n.updatedAt,0),origin:F(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:P(n.cadence)}:{},...r?{live:{commandId:B(r.commandId),epoch:B(r.epoch)}}:{}}}function Er(e){let t=R(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:B(t.commandId),text:M(t.text,16384),status:F(t.status,_r),notice:M(t.notice,1024)}}function Dr(e){let t=R(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:cr(t.id),parent:L(t.parent,cr),text:M(t.text,1024),at:N(t.at,0),leaf:cr(t.leaf),current:P(t.current)}}function Or(e){W(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=R(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:B(n.commandId),imageId:B(n.imageId),offset:N(n.offset,0)}}if(t===`conversation-image`){let n=R(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:F(n.mimeType,Nn),data:M(n.data,Mn.chunkChars,!0),next:L(n.next,e=>N(e,0))}}if(t===`conversation-context`)return{kind:t,context:an(R(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:pn(R(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=R(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:B(n.commandId),choice:cn(n.choice)}}if(t===`workflow-transcript`){let n=R(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:B(n.runId),stepId:M(n.stepId,160,!0),turn:L(n.turn,br)}}if(t===`cadence-conversation`)return{kind:t,state:sr(R(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=R(e,[`kind`,`after`,`scan`]);return{kind:t,after:L(n.after,B),scan:B(n.scan)}}if(t===`workflow-history`){let n=R(e,[`kind`,`entries`,`next`]),r=z(n.entries,In.historyPage,e=>{let t=R(e,[`id`,`run`]),n=B(t.id),r=L(t.run,er);if(r&&r.id!==n)throw new A(`invalid`);return{id:n,run:r}}),i=L(n.next,B);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=R(e,[`kind`,`runs`,...n?[`links`]:[]]),i=z(r.runs,4,er),a=n?z(r.links,4,e=>{let t=R(e,[`runId`,`conversationId`]);return{runId:B(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=R(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:B(n.commandId),grant:B(n.grant),expiresAt:N(n.expiresAt,0),revision:N(n.revision,0),proposal:Qn(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=R(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:L(t.commandId,B),response:tr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:z(R(e,[`kind`,`entries`]).entries,8,Tr)};if(n===`conversations`){let t=R(e,[`kind`,`entries`,`next`]);return{kind:n,entries:z(t.entries,200,Tr),next:L(t.next,gr)}}if(n===`conversation`){let t=R(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=L(t.summary,Tr),i=N(t.turns,0);if(!r&&i)throw new A(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:z(t.commands,64,B)},summary:r,leaf:L(t.leaf,cr),continues:P(t.continues),turns:i,branches:N(t.branches,0),runs:z(t.runs,200,B),attempt:L(t.attempt,Er)}}if(n===`conversation-tree`){let t=R(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:z(t.nodes,ur,Dr),truncated:P(t.truncated)}}if(n===`conversation-turn`){let t=R(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=wr(t.turn),i=N(t.start,0),a=z(t.steps,24,Cr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:L(t.leaf,cr),ordinal:N(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=R(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:nn(t.conversationId),leaf:L(t.leaf,cr),turnId:cr(t.turnId),step:N(t.step,0),part:N(t.part,0),item:Sr(t.item)}}if(n===`files`||n===`directories`){let t=R(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:L(t.parent,e=>M(e,4096)),limited:P(t.limited),entries:z(t.entries,200,e=>{let t=R(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:P(t.directory)}})}}if(n===`file`){let t=R(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:P(t.limited)}}if(n===`projects`)return{kind:n,entries:z(R(e,[`kind`,`entries`]).entries,128,e=>{let t=R(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:P(t.current)}})};if(n===`accepted`)return{kind:n,commandId:B(R(e,[`kind`,`commandId`]).commandId)};let r=R(e,[`kind`,`commandId`,`path`,`link`]);return{kind:F(r.kind,[`project`]),commandId:B(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var kr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ar=f.createContext&&f.createContext(kr),jr=[`attr`,`size`,`title`];function Mr(e,t){if(e==null)return{};var n,r,i=Nr(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 Nr(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 Pr(){return Pr=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},Pr.apply(null,arguments)}function Fr(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 Ir(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Fr(Object(n),!0).forEach(function(t){Lr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Fr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Lr(e,t,n){return(t=Rr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rr(e){var t=zr(e,`string`);return typeof t==`symbol`?t:t+``}function zr(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 Br(e){return e&&e.map((e,t)=>f.createElement(e.tag,Ir({key:t},e.attr),Br(e.child)))}function Q(e){return t=>f.createElement(Vr,Pr({attr:Ir({},e.attr)},t),Br(e.child))}function Vr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Mr(e,jr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Pr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Ir(Ir({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 Ar===void 0?t(kr):f.createElement(Ar.Consumer,null,e=>t(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:`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 Ur(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 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:[]}]})(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:`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 Kr(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 qr(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 Jr(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 Yr(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 Xr(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 Zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 Qr(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 $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:`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 ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 ti(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 ni(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 ri(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 ii(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`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 ai(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 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:`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 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:`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 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:`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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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:`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 di(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 fi(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 pi(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 mi(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 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:`18 15 12 9 6 15`},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:`9 18 15 12 9 6`},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:`6 9 12 15 18 9`},child:[]}]})(e)}function vi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 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:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},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:`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 xi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var $=e=>({kind:`error`,error:te(`unavailable`,e?`uncertain`:`none`)}),Si=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=vr(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Or);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=yr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Or);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),pn):$(!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){B(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=xe({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Ee);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=Se(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=we(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){B(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=ke(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=Ae(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=Ae(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)}}},Ci=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&U(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=U(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 wi(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 Ti={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`},Ei=`/api/v1/events`,Di=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Oi(e,t){if(Di.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return 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 ki(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Ai(e,t){switch(e){case`workbenchRead`:return vr(t);case`workbenchCommand`:return yr(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 B(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return ke(t);case`detail`:case`search`:return Ae(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return xe(t);case`command`:return Se(t);case`cancel`:return we(t)}}function ji(e,t){if(Di.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Or);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,pn);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,Ee);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 Mi(e){return[...Di,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ni(e,t){let n=Ti[e];return t===null||ki(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Pi(e,t){let n=Ai(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ti[e]:Ni(e,n);return ki(e)||Mi(e)&&(r||ne(i)>O.headerBytes/4)?{path:Ti[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Fi(e){W(e,O.viewerBytes);let t=F(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(R(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(R(e,[`kind`,`event`]).event)}:(R(e,[`kind`]),{kind:t})}var Ii=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=Pi(e,Ai(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:wi([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=B(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Li(t,Oi(e)),s=G(a);if(ne(a)>Oi(e,s))throw new A(`oversize`);let c=ji(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??B(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`,B(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`,xe(e))}command(e){return this.request(`command`,Se(e))}cancel(e){return this.request(`cancel`,we(e))}receipt(e,t){return this.request(`receipt`,B(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=Pi(`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(G(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=ke(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}`:``}${Ei}?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=Fi(G(e.data,O.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Li(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 Ri={sourceHash:`441a06e99ceddeadc51c10b7dd30142691148bc5da77bdec9ee5db24b437948b`,contractHash:`ee8ae17515fd8baf0aba38eb6a78a27e8c574cda265ddc17884c0741a6fb56b1`,buildId:`2c260dfa0e9dcf7a5d5e5bba1b9531b26dabb78d8a5a9c6288a5d81babe624af`};function zi(e){let t=new Ii({origin:window.location.origin,...e?{project:e}:{},...Ri?{build:{kind:`browser`,...Ri}}:{},socket:e=>new WebSocket(e)});return{client:new Si(t),transport:t}}function Bi(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 Vi(e=typeof window>`u`?``:window.location.search){return Bi(e,``).project}function Hi(e=typeof window>`u`?``:window.location.hash){return Bi(``,e).chat}function Ui(){let e=Vi();return e?`/projects/${e}`:``}function Wi(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&Bi(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?cr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function Gi(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&&U(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||U(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 Ki(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(vr(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 qi(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 Ji(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Ki(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 Yi(e){return G(await Li(e,1048576),1048576)}function Xi(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 Zi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Yi(r);if(!r.ok)throw Error(Xi(i));return t(i)}function Qi(e){return Zi(`/workbench/v1/service`,kn,e)}function $i(e){return Zi(`/workbench/v1/service/release`,An,e)}async function ea(e,t){if(!Ri)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`,...Ri})},body:JSON.stringify(e)}),r=await Yi(n);if(!n.ok)throw Error(Xi(r));let i=R(r,[`kind`,`job`]);return I(i.kind,`service-job`),En(i.job)}function ta(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function na(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function ra(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 Yi(r);if(!r.ok)throw Error(Xi(a));let c=hn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...na(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...na(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:ta(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var ia=e=>e===`unauthenticated`||e===`forbidden`,aa=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Ci,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new Ci,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,ia(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(ia(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,ia(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,ia(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Ci,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Ri?{kind:`browser`,...Ri}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new Ci,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Ci,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function oa(e,t,n,r){let i=(0,f.useMemo)(()=>new aa(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 sa=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 ca({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 la(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 ua(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 da(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 fa(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=la(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 pa(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),ua(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 ma({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)(ma,{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 ha(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 ga(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ha(e)}return ha(e)}function _a(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 ga(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 va(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 ya=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ba(!0)},text:{92:ba(!1)}});let t={enter:{backslashMathInline:xa,backslashMathDisplay:xa,backslashMathBlock:xa},exit:{backslashMathInline:Sa,backslashMathDisplay:Sa,backslashMathBlock:Sa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ba(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 xa=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)},Sa=function(e){this.exit(e)},Ca=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=_a();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)(vi,{}):(0,h.jsx)(pi,{}),n&&t(`Copy unavailable`)]})}),wa=[s,d,ya],Ta=[s,l,d,ya],Ea=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Da(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 Oa({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Ta:wa,rehypePlugins:t?[i,o,...Ea]:Ea,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ja,a:Aa,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ka=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Oa,{...e})})});function Aa({href:e,children:t}){let n=e&&Da(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 ja({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=va(r).map(e=>{let t=`code-offset:${i}`;return i+=Ma(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)(Ca,{text:Ma(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 Ma(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ma).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ma(t?.children)}return``}function Na(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 Pa=new Map;function Fa(e,t){t.length?Pa.set(e,t):Pa.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Pa].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 Ia(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 La(e,t){let n=t.startContainer.parentElement;for(let r of Ia(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 Ra({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?Na(n,r):[];return l.current=i,c(i.length),o(0),Fa(u,i),()=>Fa(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(La(e.current,l.current[n]),Fa(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Fa(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function za({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>Ae(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 ee=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await fa(e,t,n.signal);if(n.signal.aborted)return;let i=await ga(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 ee(),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)(ma,{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)(Ra,{container:D,version:`${O.content.recordId}:${O.content.version}:${O.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(O.text):x===`markdown`?(0,h.jsx)(ka,{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 Ba({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)(ma,{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)(Jr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function Va({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=pa(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)(Ba,{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)(ma,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(da(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)(za,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ha({client:e,seed:t}){return(0,h.jsx)(Ua,{client:e,seed:t},W(t))}function Ua({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)(ma,{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 Wa(e){let t=Pi(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Ui()+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 Ga({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)(Hr,{"aria-hidden":`true`})})]}),t]})}function Ka({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)(Ga,{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{Wa({...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 qa(e,t){if(!t||ne(t)>O.queryBytes)throw Error(`Query must be 1–${O.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Ae({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Ja(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 Ya({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=qa(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)(Ga,{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)(qr,{}),(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)(ma,{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(Ja(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 Xa({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)(ma,{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 Za({client:e,seed:t}){return(0,h.jsx)(Qa,{client:e,seed:t},W(t))}function Qa({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)(ma,{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)(za,{client:e,cursor:da(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)(ka,{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 $a({client:e,seed:t,onScope:n}){let{t:r}=T(),i=pa(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ba,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Xa,{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)(Za,{client:e,seed:o},o.graph.recordId)]})}function eo({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)(qr,{"aria-hidden":`true`})})}function to(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 no(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 ro(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)??io(n.role,n.customType)}return r}function io(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 ao(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function oo(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=ro(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=to(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=>no(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)=>ao(e,t,s.current,n),[])}}var so=(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`})}),co=(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)(hi,{"aria-hidden":`true`}):(0,h.jsx)(ci,{"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)(za,{compact:!0,client:t,cursor:da(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(Va,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function lo({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=oo(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)(so,{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)(co,{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)(xi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function uo({client:e,seed:t}){let{t:n}=T(),r=pa(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ba,{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)(lo,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function fo({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)(_i,{}):(0,h.jsx)(gi,{})}):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 po=(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)(fo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Ur,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(Va,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),mo=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function ho({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(mo(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 go=[`queued`,`running`];function _o(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 vo=4,yo=1e4;function bo(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?go.includes(t.status):i-(u.get(e)??0)>=yo}).reverse();for(let n=0;n<a.length;n+=vo){let r=await Promise.all(a.slice(n,n+vo).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+vo<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>go.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),yo))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function xo({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=bo(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(!go.includes(e.step.status))-Number(!go.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>go.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)(_i,{}),(0,h.jsx)(di,{}),(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=_o(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 So=2e4;async function Co(e,t,n,r){let i=wi([t],So);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function wo(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 To(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 Eo(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Do(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:cr(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,lr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:N(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:N(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Oo(e.model))}:{}})}function Oo(e){return le({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function ko(e,t){return Object.freeze({...e,model:Object.freeze(Oo(t))})}function Ao(e,t){if(e.model&&W(e.model)!==W(Oo(t)))throw new A(`stale`)}function jo(e,t){return Object.freeze({...e,preparedEpoch:B(t)})}function Mo(e,t,n){return Object.freeze({...ko(e,t),installModel:!n})}function No(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`,`incompatible`].includes(t.status)?`cancel`:`wait`:`cancel`}function Po(e,t){return!!e&&e===t}async function Fo(e,t,n,r){if(!r())throw new A(`stale`);if(!t.installModel||!t.model)return n;if(!dn(n.entries,t.model))throw new A(`unsupported-context`);if(n.selected&&W(Oo(n.selected))===W(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new A(`stale`);if(i.kind===`error`)throw new A(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new A(`stale`);if(a.kind===`error`)throw new A(a.error.code);if(!a.value.selected||W(a.value.version)!==W(i.value.version)||W(a.value.selected)!==W(i.value.selected))throw new A(`stale`);return Ao(t,a.value.selected),a.value}function Io(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new A(`stale`);let n=yr(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 Lo(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 Ro(e){for(let t of e){if(!Nn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function zo(e){Ro([e]);let t=new Uint8Array(await e.arrayBuffer());return Fn(t,e.type),t}var Bo=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 Vo(e,t,n,r){Ro(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await zo(a);if(!r())throw Error(`stale`);let o=Bo(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Mn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Mn.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 Ho(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>Mn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Mn.chunkChars)throw Error(`invalid`)}let i=Pn(n.join(``));return Fn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Uo=1e3,Wo=1e4,Go=4,Ko=e=>e===`queued`||e===`running`,qo=class extends Error{},Jo=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 qo?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=Ko(this.summary?.status)||[...this.turns.values()].some(e=>Ko(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Uo:Wo)}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 qo(`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||Ko(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 qo(`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 qo(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=wi([t,r]);try{return await Ho(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=wi([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 qo(`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>=Go&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new qo(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new qo(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Yo(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 Jo(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??Xo,loadEarlier:i?.loadEarlier??Xo,choose:i?.choose??Xo}}function Xo(){}function Zo(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`incompatible`&&t.status!==`preparing`?r:void 0,[s,c]=(0,f.useState)(0),l=(0,f.useRef)(0),u=(0,f.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,revision:s,preview:o}),[e,i,a,n,s,o]),d=(0,f.useRef)(u);d.current=u;let p=(0,f.useRef)(!0);(0,f.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let m=(0,f.useCallback)(()=>p.current&&(u.epoch!==null||!!u.preview)&&d.current===u&&l.current===u.revision,[u]),[h,g]=(0,f.useState)();(0,f.useEffect)(()=>{if(u.epoch===null&&!u.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&m();return u.preview?(u.preview(t.signal).then(e=>{n()&&g({scope:u,preview:e})}).catch(e=>{n()&&g({scope:u,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal).then(e=>{n()&&(e.kind===`error`?g({scope:u,error:e.error.code}):e.value.version.epoch===u.epoch?g({scope:u,catalog:e.value}):g({scope:u,error:`stale`}))}).catch(()=>{n()&&g({scope:u,error:`unavailable`})}),()=>t.abort())},[e,u,m]);let _=h?.scope===u&&m()?h:void 0;return{catalog:_?.catalog,preview:_?.preview,error:_?.error,loading:(i!==null||!!o)&&!_,isCurrent:m,reread(){m()&&c(++l.current)},accept(e){return!m()||e.version.epoch!==u.epoch?!1:(g({scope:u,catalog:e}),!0)}}}async function Qo(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 $o(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function es(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var ts={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},ns={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.`},rs=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,is=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function as(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>ce.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function os(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(ts[t.thinking])}`,[e])}function ss({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:p=`conversation`}){let{t:m}=T(),g=os(),_=t.status===`ready`,v=n.preview,y=_||!!v||n.loading&&t.status!==`preparing`,b=_?t.epoch:null,x=_?t.attachmentVersion:null,{error:S,loading:C,reread:w}=n,E=_?n.catalog:void 0,D=E??v,[ee,O]=(0,f.useState)(``),[k,A]=(0,f.useState)(!1),[te,j]=(0,f.useState)(``),M=(0,f.useRef)(null),ne=(0,f.useRef)(null),N=(0,f.useRef)(null),P=(0,f.useRef)(null),F=(0,f.useRef)(c);F.current=c,(0,f.useEffect)(()=>{O(``)},[e,b,x]);let I=(0,f.useCallback)((e=!0,t)=>{t?F.current(!1,t):F.current(!1),j(``),O(``),e&&ne.current?.focus({preventScroll:!0})},[]);(0,f.useEffect)(()=>{if(!s)return;y&&N.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||I(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,I,y]);let L=E?.selected??null,R=i??L??(v?r:null)??D?.remembered??null,z=(0,f.useMemo)(()=>{let e=te.trim().toLowerCase(),t=new Map;for(let n of D?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[D,te]),B=D?.entries.find(e=>is(e,R)),V=(_||!!v)&&!!D&&!C&&!S&&n.isCurrent(),H=async(t,r)=>{if(!V||!n.isCurrent()||!D||!t.api||k||o)return;let i=le({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),I(!0,`chosen`);else if(E&&e){if(L&&rs(L,i))I(!0,`chosen`),u?.(i);else{A(!0),O(``);try{let t=await e.chooseModel({expected:E.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){O(t.error.code),w();return}let r={...E,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),I(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(O(`uncertain`),w())}finally{A(!1)}}}},U=()=>[...P.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],re=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=U(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?N.current?.focus():t[Math.min(n,t.length-1)]?.focus()},W=t.status===`stopped`||t.status===`not-started`,G=D?null:r,ie=n.preview||n.loading&&a||S&&a?m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):W?m(`Choose a model`):t.status===`preparing`?m(`Preparing execution…`):t.status===`incompatible`?m(`Model selection needs a compatible connection`):t.status===`connecting`?m(`Checking execution state…`):t.status===`unavailable`?m(`Execution state unavailable`):m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`),ae=R?g(R):W&&G?m(`Last used: {model}`,{model:g(G)}):ie;return(0,h.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,h.jsxs)(`button`,{ref:ne,type:`button`,className:`model-trigger${R&&!L||G?` remembered`:``}${D&&!R?` empty`:``}`,"aria-label":m(`Model: {model}`,{model:ae}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?m(`Switch models after the current reply finishes.`):i?m(`Choose now; the model is verified when you send.`):G?m(`Last used model; availability is checked when you send.`):R&&!L?m(`Last used model; it is used again when you send.`):R?`${R.provider}/${R.model} · ${R.api}`:ie,onClick:()=>{s?I():(O(``),c(!0))},children:[(0,h.jsx)(di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:ae}),(0,h.jsx)(_i,{"aria-hidden":`true`})]}),s&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":m(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),I())},children:[d&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose a model; your message is sent right after.`)}),v&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose now; the model is verified when you send.`)}),!y&&!S&&(0,h.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?m(`Execution is being prepared for your Send. Models will load when it is ready.`):t.status===`incompatible`?m(`Reload the page to observe a compatible execution connection before choosing a model.`):m(`Model selection is unavailable until the current conversation and execution state are observed.`)}),G&&(0,h.jsxs)(`p`,{className:`model-popover-lead`,children:[m(`Last used: {model}`,{model:g(G)}),(0,h.jsx)(`br`,{}),m(`Last used model; availability is checked when you send.`)]}),y&&(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:N,type:`search`,"aria-label":m(`Search models`),placeholder:m(`Search models…`),value:te,onChange:e=>j(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),U()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),U()[0]?.click())}})]}),y&&(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":m(`Models`),ref:P,onKeyDown:re,children:[C&&(0,h.jsx)(`p`,{className:`model-empty`,role:`status`,children:m(`Reading models…`)}),z.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=is(e,R);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!V||!t||k||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void H(e,as(e,R?.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`?m(`Credentials unavailable`):m(`Not supported`)}),n&&(!L||!!i)&&(0,h.jsx)(`span`,{className:`model-option-note`,children:m(`Used when you send`)}),n&&(0,h.jsx)(vi,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),D?.status===`complete`&&z.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:te.trim()?m(`No matching models.`):m(v?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),y&&B&&B.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:m(`Thinking`)}),B.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":m(`Thinking level: {level}`,{level:m(ts[e.level])}),"aria-pressed":R?.thinking===e.level,disabled:!V||!e.selectable||k||o,onClick:()=>void H(B,e.level),children:m(ts[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[v&&!S&&(0,h.jsx)(`button`,{type:`button`,className:`link`,disabled:C||k,onClick:w,children:m(`Refresh models`)}),o&&(0,h.jsx)(`p`,{children:m(`Switch models after the current reply finishes.`)}),D?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:m(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!D?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:m(D.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:D.withheld})}),(_||!!a)&&S&&(0,h.jsxs)(`p`,{role:`alert`,children:[m(`The model list could not be read ({code}).`,{code:S}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:w,children:m(`Read again`)})]}),ee&&(0,h.jsx)(`p`,{role:`alert`,children:ns[ee]?m(ns[ee]):m(`The model was not changed ({code}).`,{code:ee})}),V&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:m(k?`Switching model…`:p===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function cs(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 ls({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Ki(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>cs(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)(Hr,{"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 us({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 ds(){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])];Ro(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 fs({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),zo(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 ps({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 ms({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(ps,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var hs=/^\s{0,3}(`{3,}|~{3,})/,gs=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function _s(e){return e.trim()===``}function vs(e){let t=hs.exec(e);return t?t[1]:null}function ys(e){let t=e.split(`
|
|
16
16
|
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=vs(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=vs(a);if(o&&!_s(a))i=o,r.push(a);else if(_s(a)){let i=e;for(;i<t.length&&_s(t[i]);)i++;if(!(i<t.length&&gs.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
18
|
`),inFence:i!==null}}function bs(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 xs=(0,f.memo)(function({text:e}){return(0,h.jsx)(Oa,{text:e})}),Ss=22,Cs=14,ws=()=>typeof document<`u`&&document.hidden;function Ts(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||ws()||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(ws()){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?Cs:Ss;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=bs(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 Es=600,Ds=32;function Os({text:e,inFence:t}){let n=!t&&e.length>=Es,[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>=Ds)r();else return o.current=setTimeout(r,Ds-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)(Oa,{text:n?r:e})}var ks=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=Ts(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>ys(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)(xs,{text:e},t)),a.length>0&&(0,h.jsx)(Os,{text:a,inFence:o},i.length)]})});function As(e){let t=e.items.map(e=>({...hr(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 js(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 Ms(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 Ns={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Ps=e=>Object.hasOwn(Ns,e)?Ns[e]:`other`,Fs={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`]},Is=new Set([`read`,`list`,`edit`]);function Ls(e,t){return Is.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function Rs({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=Ps(t.name);e.set(n,(e.get(n)??new Set).add(Ls(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(Fs[e][0]):o(Fs[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)(gi,{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)(Bs,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(zs,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function zs({turn:e,index:t,step:n,render:r=e=>(0,h.jsx)(ka,{text:e})}){let{t:i}=T(),a=t<e.header.stable,o=js(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(ms,{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 Bs({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=js(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 Vs=(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}=Ms(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
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)(zs,{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)(Rs,{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)(zs,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(ks,{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
20
|
`)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function Hs({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 Us=[`queued`,`running`],Ws=e=>Us.includes(e.status);function Gs(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function Ks(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function qs(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=>Gs(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=Gs(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 Js(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?Gs(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 Ys(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 Xs({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=Ws(t),m=p?[a(Ks(t)),t.steps.filter(e=>e.status===`running`).map(e=>_o(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,Ys(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(``),Qs(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Wr,{"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 Zs({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)(ka,{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)(ka,{text:nr(e.plan)})]}),e.delivery&&(0,h.jsx)(ka,{text:Zn(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 Qs(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 $s(e){return(0,h.jsx)(ec,{...e},e.id)}function ec({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=Ki(e,{kind:`workflow`,id:t},o),d=Ki(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=Ki(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)(tc,{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:or(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),` · `,_o(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(ka,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:_o(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),Qs(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 tc({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 nc=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function rc(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function ic({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,previewModels:_,initialModel:v,onModelChanged:y,onChanged:x,reference:S,onReferenceUsed:C,hidden:w=!1,onOpenAgent:E,onWorkflowRuns:D}){let{t:O,tx:k}=T(),[A]=(0,f.useState)(()=>Lo(n,t,u,...d)),[j,M]=(0,f.useState)(()=>rc(A)),N=ds(),te=N.remove,P=(0,f.useRef)([]),F=(0,f.useRef)(null),[I,L]=(0,f.useState)(()=>rc(`${A}:mode`)===`cadence`?`cadence`:`chat`),[R,z]=(0,f.useState)(!1),[B,V]=(0,f.useState)(``),[H,U]=(0,f.useState)(()=>rc(`${A}:pending`)),[ne,re]=(0,f.useState)(()=>rc(`${A}:model-command`)),[ie,G]=(0,f.useState)(!1),[ae,oe]=(0,f.useState)(!1),[se,ce]=(0,f.useState)(!1),[le,K]=(0,f.useState)(0),de=(0,f.useRef)(null),fe=(0,f.useRef)(!1),pe=(0,f.useRef)(0),me=(0,f.useRef)(new AbortController),[he,q]=(0,f.useState)(!1),[ge,_e]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(`${A}:model`);if(e)return ue(JSON.parse(e))}catch{}return v??null});(0,f.useEffect)(()=>{try{ge?sessionStorage.setItem(`${A}:model`,JSON.stringify(ge)):sessionStorage.removeItem(`${A}:model`)}catch{}},[A,ge]);let ve=Ki(e,p&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),ye=ve.value?.kind===`conversation-context`?ve.value.context:void 0,be=!!ye&&!ve.error,xe=ye?.cwd??r,Se=(0,f.useMemo)(()=>({models:n=>xe?e.models(n,{id:t,cwd:xe}):Promise.resolve({kind:`error`,error:ee(`unavailable`)}),chooseModel:n=>xe?e.chooseModel(n,{id:t,cwd:xe}):Promise.resolve({kind:`error`,error:ee(`unavailable`)})}),[e,t,xe]),Ce=he?{status:`preparing`}:g.status===`ready`&&(!p||!be)?{status:ve.error?`unavailable`:`connecting`}:g,we=(0,f.useRef)(Ce);we.current=Ce;let Te=Zo(Se,Ce,`${le}:${ye?.revision??`unobserved`}`,_),Ee=()=>{de.current=null,oe(!1),ce(!1)},J=(e,t)=>{e&&!Te.preview&&!Te.loading?Te.reread():!e&&t!==`chosen`&&Ee(),G(e)},De=(e,t)=>{_e(t?null:e);let n=de.current;ae&&n&&(No(n,we.current)===`cancel`?(Ee(),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(de.current=Mo(n,e,t),oe(!1),V(``),ce(!0)))},Oe=(0,f.useRef)(o);Oe.current=o,(0,f.useEffect)(()=>{be&&xe&&Oe.current?.({id:t,cwd:xe})},[be,t,xe]);let Y=Yo(e,t,p,i),{turns:ke}=Y,Ae=Y.summary!==void 0,je=Ki(e,p?{kind:`cadence-conversation`,id:t}:null,1e3),X=je.value?.kind===`cadence-conversation`?je.value.state:void 0,Me=X?.enabled===!0,Ne=!!X||!!je.error,Pe=!!X&&!je.error&&!X.notice,Fe=(0,f.useRef)(X);Fe.current=X;let[Ie,Le]=(0,f.useState)(``),Re=(0,f.useRef)(``),ze=qi(j,Me?`cadence`:I),Be=s&&!(a&&!Y.summary)&&be&&Ae&&!Y.error&&Ne&&!(Me&&(je.error||X?.notice))&&!R&&!ae&&!H,Ve=Y.summary??void 0,He=Ve&&(Ve.status===`queued`||Ve.status===`running`),Ue=!!Ve&&Ve.status!==`completed`&&!He,[We,Ge]=(0,f.useState)(!1),Ke=!!l&&s&&(!!Y.error||!!ve.error)&&Y.error!==`retired-conversation`&&ve.error!==`retired-conversation`&&!X?.notice&&!He&&!R&&!H&&!ae,qe=(m||!!l)&&be&&Ae&&Pe&&!Y.error&&!R&&!H&&!He,Je=!!ge&&W(ge)!==W(ye?.model??null),Ye=!!X?.proposal&&!!Ve&&!He&&Ve.status!==`unknown`,Xe=Je?O(`Send with this model before approving a plan.`):Ve?.status===`unknown`?O(`The latest turn's outcome is unknown. Approval waits until it is observed.`):c?Pe?He?O(`Wait for the current reply before approving this plan.`):Ie?O(`Observing plan approval…`):Be?void 0:O(`Read the current conversation context before approving this plan.`):O(`Cadence state unavailable`):O(`Read the current execution state before approving this plan.`),Ze=(0,f.useRef)(null),Qe=(0,f.useRef)(null),$e=(0,f.useRef)(0),et=(0,f.useRef)(!0),[tt,Z]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!w&&Qe.current&&!et.current&&(Qe.current.scrollTop=$e.current)},[w]);let nt=(0,f.useRef)(!0),rt=(0,f.useRef)(``),it=(0,f.useRef)(j);(0,f.useEffect)(()=>(nt.current=!0,me.current.signal.aborted&&(me.current=new AbortController),()=>{nt.current=!1,me.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${A}:mode`,I)}catch{}},[A,I]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(A,j)}catch{}},[j,A]),(0,f.useEffect)(()=>{try{H?sessionStorage.setItem(`${A}:pending`,H):sessionStorage.removeItem(`${A}:pending`)}catch{}},[A,H]),(0,f.useEffect)(()=>{try{H&&ne===H?sessionStorage.setItem(`${A}:model-command`,ne):sessionStorage.removeItem(`${A}:model-command`)}catch{}},[A,H,ne]),(0,f.useEffect)(()=>{S&&(M(e=>`${e}${e?`
|
|
22
|
-
`:``}@${S}`),C(),Ze.current?.focus())},[S,C]),(0,f.useEffect)(()=>{let e=Ve?`${Ve.leaf}:${Ve.status}`:``;e&&rt.current!==e&&(rt.current=e,x()),Re.current&&X?.runs.includes(Re.current)&&(Re.current=``,Le(``),V(``)),H&&(Ve?.live?.commandId===H||Y.attempt?.commandId===H||ke.some(e=>e.header.id===H)||Y.commands.includes(H))&&(U(``),Po(H,ne)&&_e(null),re(``),te(P.current),M(e=>e===it.current?``:e),x()),et.current&&Qe.current&&(Qe.current.scrollTop=Qe.current.scrollHeight)},[Ve,ke,H,ne,x,X,Y,te]);let at=(0,f.useMemo)(()=>ke.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})),[ke]),ot=oo(Qe,at),st=(0,f.useRef)(new Map),ct=(0,f.useCallback)((e,t)=>{st.current.set(e,t)},[]),{earlier:lt,loadEarlier:ut}=Y,dt=()=>{let e=Qe.current;e&&!w&<&&e.scrollTop<1200&&ut()};(0,f.useEffect)(dt);let ft=ke[0]?.ordinal,pt=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Qe.current;if(!e)return;let t=pt.current;!nc&&!et.current&&t.ordinal!==void 0&&ft!==void 0&&ft<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),pt.current={ordinal:ft,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${A}:approval`)}catch{}},[A]);let mt=(0,f.useMemo)(()=>[...new Set([...Y.runs,...X?.runs??[]])],[Y.runs,X?.runs]),ht=JSON.stringify(mt.slice(-4));(0,f.useEffect)(()=>{D?.(JSON.parse(ht))},[ht,D]);let[gt,_t]=(0,f.useState)({terminal:8,browser:8}),vt=(0,f.useMemo)(()=>[...new Set([...Y.runs.slice(-gt.terminal),...(X?.runs??[]).slice(-gt.browser)])],[Y.runs,X?.runs,gt]),yt=bo(e,p?vt:[],1e3),bt=ke.find(e=>e.header.at>0)?.header.at,xt=!lt&&ke.length>0;(0,f.useEffect)(()=>{if(!p)return;let e=(e,t)=>Js(e,t,yt.runs,yt.unreadable,bt,xt),t=e(Y.runs,gt.terminal),n=e(X?.runs??[],gt.browser);(t!==gt.terminal||n!==gt.browser)&&_t({terminal:t,browser:n})},[p,Y.runs,X?.runs,gt,yt,bt,xt]);let St=(0,f.useMemo)(()=>qs(ke,yt.runs.values(),lt),[ke,yt.runs,lt]),Ct=[...yt.runs.values()].filter(Ws).at(-1),wt=[...yt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{wt&&et.current&&Qe.current&&(Qe.current.scrollTop=Qe.current.scrollHeight)},[wt]);let Tt=t=>(0,h.jsx)(Xs,{client:e,run:t,onOpen:()=>E?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{je.refresh(),x()}},t.id),Et=async()=>{if(!X?.proposal){V(O(`No plan is awaiting approval.`));return}if(Je||!c||!Pe||!Be||He||Ie||!Ye)return;let t=X,n=pe.current;z(!0),V(``);try{let r=await Qo({client:e,state:t,current:()=>nt.current&&pe.current===n&&Fe.current?.revision===t.revision&&Fe.current?.enabled===!0,submitting:e=>{Re.current=e,Le(e)}});if(!nt.current||pe.current!==n)return;r.kind===`error`?(V(r.error.code),Le(``)):M(e=>es(e)?``:e)}catch(e){nt.current&&pe.current===n&&V(e instanceof Error?e.message:`unavailable`)}finally{nt.current&&pe.current===n&&(z(!1),je.refresh(),Y.refresh(),x())}},Dt=async(n,r)=>{let i=r?.text??n??j,a=r?.images??(n?[]:N.files),o=r?r.command.kind===`cadence-exit`:Me&&$o(i);if(!(o?qe:Be)&&!Ke||He||!i.trim()&&!a.length||r&&(!Be||No(r,we.current)!==`ready`))return;if(o&&a.length){V(O(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Me&&es(i)){c?await Et():V(O(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let s=qi(i,I).mode===`cadence`;if(!Ke&&(Me||s)&&!Pe){V(O(`Cadence state unavailable. Observe the conversation before sending.`));return}if(fe.current)return;fe.current=!0,z(!0),V(``);let u=pe.current,d=()=>nt.current&&pe.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&(U(e),re(e&&!o?e:``))},h=async e=>{l&&(q(!0),await Co(l,me.current.signal,e,e=>{p=e}),d()&&(q(!1),K(e=>e+1)))};try{if(Ke){if(await h(ye?{id:t,cwd:ye.cwd}:void 0),!d())return;Y.refresh(),ve.refresh(),je.refresh(),x(),V(O(`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??Do({id:t,head:Y.leaf,text:i,images:a,revision:X?.revision??0,location:ye?{id:t,cwd:ye.cwd}:void 0,installModel:!!ge,model:ge??(Te.catalog?.selected?Oo(Te.catalog.selected):Te.catalog?.remembered??ye?.model??Te.preview?.remembered??void 0),intent:o?`exit`:Me?`message`:s?`enter`:`ordinary`});if(r){if(No(r,we.current)!==`ready`)throw Error(`stale`)}else await h(n.location);if(!d())return;if(n.command.kind===`cadence-exit`){let t=Io(n);it.current=i,f=!0;let r=await Eo(e,t,m);if(!d())return;r.kind===`error`?V(O(To(r.error.effect),{code:r.error.code})):(U(``),L(`chat`),M(e=>e===i?``:e)),je.refresh(),Y.refresh(),x();return}let c=e=>{let t=we.current,r=e??(t.status===`ready`?t.epoch:void 0);r&&No(jo(n,r),t)!==`cancel`?(de.current=jo(n,r),oe(!0)):(Ee(),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))),J(!0)},l=await e.models(void 0,n.location);if(!d())return;if(n.preparedEpoch&&l.kind===`ok`&&l.value.version.epoch!==n.preparedEpoch)throw Error(`stale`);let u=l.kind===`ok`?l.value.selected??l.value.remembered:null;if(!n.model&&u&&(n=ko(n,u)),n.installModel&&l.kind===`ok`){if(l={kind:`ok`,value:await Fo(e,n,l.value,d)},!d())return;K(e=>e+1)}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`){V(t.error.code),c(l.value.version.epoch);return}if(l=await e.models(void 0,n.location),!d())return;K(e=>e+1)}if(l.kind!==`ok`||!l.value.selected){c(l.kind===`ok`?l.value.version.epoch:void 0);return}Ao(n,l.value.selected);let g=Io(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)){V(O(`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 Vo(e,g,n.images,d),!d())return}P.current=n.images,it.current=i,f=!0;let _=await Eo(e,g,m);if(!d())return;_.kind===`error`?V(O(To(_.error.effect),{code:_.error.code})):(te(P.current),_e(null),M(e=>e===it.current?``:e),U(``),g.kind===`cadence-send`&&L(`chat`),At(null)),je.refresh(),Y.refresh(),x()}catch(e){d()&&V(O(f?To():wo(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{pe.current===u&&(fe.current=!1),d()&&(z(!1),q(!1))}},Ot=(0,f.useRef)(Dt);Ot.current=Dt,(0,f.useEffect)(()=>{let e=de.current;if(!e||!se&&!ae)return;let t=No(e,Ce);t===`cancel`?(de.current=null,oe(!1),ce(!1),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))):se&&t===`ready`&&Be&&!He&&(ce(!1),de.current=null,Ot.current(void 0,e))},[se,ae,Be,He,Ce,O]),(0,f.useEffect)(()=>{if(!se)return;let e=setTimeout(()=>{ce(!1),de.current=null},1e4);return()=>clearTimeout(e)},[se]);let kt=async()=>{let n=Ve?.live;if(!n||R)return;z(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});nt.current&&(r.kind===`error`&&V(r.error.code),z(!1),Y.refresh())},At=e=>{++pe.current,me.current.abort(),me.current=new AbortController,de.current=null,fe.current=!1,oe(!1),ce(!1),G(!1),z(!1),q(!1),Y.choose(e),Ge(!1)},jt=R||ae||!!H||!!He,Mt=e=>{if(!jt)try{N.add(e),V(``)}catch(e){V(k(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:w,"aria-label":O(Pe?Me?`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)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:Ve?.title??(a?O(`Discovered session`):Y.summary===null?O(`New conversation`):O(`Conversation`))}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:O(Pe?Me?`Cadence on`:`Ordinary`:`Cadence state unavailable`)}),Ve&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:Ve.origin===`terminal`?O(`Started in the terminal`):O(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(Y.branches>1||Y.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":We,onClick:()=>Ge(e=>!e),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),O(`Branches ({count})`,{count:Y.branches})]}),Y.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>At(null),children:O(`Show the latest`)}),Ct&&(0,h.jsx)(`span`,{className:`ep-state running`,children:k(Ks(Ct))}),Ve&&(!Ct||Ue||Me&&!He&&!!X?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${Ve.status}`,children:Me?He?O(`Discussing`):Ue?k(Ve.status):X?.proposal?O(`Awaiting plan approval`):O(`Ready for conversation`):k(Ve.status)})]})]}),ve.error&&!Ke&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(O,ve.error)}),Ke&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:O(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),he&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:O(`Preparing execution for this Send…`)}),We&&(0,h.jsx)(ls,{client:e,id:t,leaf:Y.leaf,onChoose:At,onClose:()=>Ge(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Qe,onScroll:()=>{let e=Qe.current;e&&!w&&($e.current=e.scrollTop,et.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Z(!et.current),dt())},children:[a&&!Y.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:O(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!p&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:O(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),Y.summary===null&&!Y.error&&!a&&(0,h.jsx)(Hs,{hint:O(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),p&&!Y.error&&(!Ae||ke.length===0&&Y.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:O(`Reading this conversation…`)}),ke.length>0&<&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:Y.loadingEarlier&&O(`Reading earlier messages…`)}),St.start.map(Tt),at.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(so,{id:e,show:!ot.hidden.has(e),height:ot.placeholder(e,t,320),containerRef:Qe,onMeasured:ot.recordMeasured,lazyRef:ot.register(e),children:(0,h.jsx)(Vs,{turn:n,toggled:st.current.get(e)??null,onToggle:ct})}),St.after.get(e)?.map(Tt),n.header.entry&&n.ordinal<Y.count-1&&!He&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:O(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>At(n.header.entry),children:[(0,h.jsx)(fi,{"aria-hidden":`true`}),O(`Continue from here`)]})]},e)),St.end.map(Tt),Y.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":O(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:Y.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${Y.attempt.status}`,children:k(Y.attempt.status)}),` `,Y.attempt.notice?k(Y.attempt.notice):``]})]}),X?.enabled&&X.proposal&&(0,h.jsx)(Zs,{proposal:X.proposal,canApprove:!Je&&c&&Be&&Pe&&Ye&&!He&&!Ie,approvalHint:Xe,onApprove:()=>void Et()}),X?.enabled&&!X.proposal&&mt.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:O(`Cadence stays on for this conversation until you explicitly exit.`)}),yt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:O(`Workflow activity unavailable; retained work may still be running.`)}),X?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:k(X.notice)}),[...new Set([B,Y.error,je.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(O,e??``)},e)),Y.error&&Y.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:O(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),H&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[O(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:H}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:Y.refresh,children:O(`Observe current state`)})]}),Y.pinned&&!He&&(0,h.jsx)(`p`,{className:`inspector-note`,children:O(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),tt&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":O(`Latest messages`),onClick:()=>{Qe.current&&(Qe.current.scrollTop=Qe.current.scrollHeight),et.current=!0},children:(0,h.jsx)(xi,{})}),(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(),Mt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),Dt()},children:[(0,h.jsx)(`input`,{ref:F,type:`file`,accept:Nn.join(`,`),multiple:!0,hidden:!0,disabled:jt,"aria-label":O(`Add images`),onChange:e=>{Mt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),N.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:N.files.map(e=>(0,h.jsx)(fs,{file:e,disabled:jt,remove:()=>te([e])},N.key(e)))}),!He&&!Ke&&!Be&&!he&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:O(H?`The last Send is not yet confirmed. No message is resent.`:ae?`Choose a model; your message is sent right after.`:R?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`)}),(0,h.jsx)(`textarea`,{ref:Ze,disabled:R||!!H||ae,"aria-label":O(`Message`),value:j,placeholder:O(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>M(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Mt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Dt())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:jt,"aria-label":O(`Add images`),title:O(`Add images`),onClick:()=>F.current?.click(),children:(0,h.jsx)(ni,{"aria-hidden":`true`})}),(0,h.jsx)(us,{active:Me,armed:ze.mode===`cadence`,known:Pe,disabled:Me?!qe:!!He||R||!!H||ae,onClick:()=>{Me?Dt(`exit cadence`):ze.mode===`cadence`?(L(`chat`),qi(j,`chat`).mode===`cadence`&&M(ze.text)):L(`cadence`)}}),(0,h.jsx)(ss,{client:Se,availability:Ce,read:Te,lastModel:ye?.model,draftModel:ge,onPreviewChoice:_?e=>De(e,!1):void 0,locked:!!He||R||!!H,open:ie,onOpenChange:J,onChanged:()=>{ve.refresh(),y()},onChosen:e=>De(e,!0),awaitingSend:ae}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Me?O(`Cadence stays on. Confirm one plan before implementation.`):ze.mode===`cadence`?O(`Your next message turns on Cadence mode.`):``}),He?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:R||!m,onClick:()=>void kt(),children:[(0,h.jsx)(Wr,{}),O(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(Me&&$o(j)?qe:Be)&&!Ke||!j.trim()&&!N.files.length,children:[(0,h.jsx)(yi,{}),O(`Send`)]})]})]})]})}function ac({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=Ki(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Ki(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)(yi,{})}),(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)(Jr,{})})]}),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)(oi,{}):(0,h.jsx)(si,{}),(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)(Yr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void ga(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(pi,{})})]},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)(Hr,{})})]}),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 oc=`未命名章节`;function sc(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 cc(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=sc(r||oc),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||oc}})}function lc(e){return e.length>=2}function uc(e){let t=0,n=0;return e.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(``),Qs(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Wr,{"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 Zs({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)(ka,{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)(ka,{text:nr(e.plan)})]}),e.delivery&&(0,h.jsx)(ka,{text:Zn(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 Qs(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 $s(e){return(0,h.jsx)(ec,{...e},e.id)}function ec({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=Ki(e,{kind:`workflow`,id:t},o),d=Ki(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=Ki(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)(tc,{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:or(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),` · `,_o(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(ka,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:_o(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),Qs(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 tc({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 nc=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function rc(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function ic({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,previewModels:_,initialDraft:v,onDraftApplied:y,onModelChanged:x,onChanged:S,reference:C,onReferenceUsed:w,hidden:E=!1,onOpenAgent:D,onWorkflowRuns:ee}){let{t:O,tx:k}=T(),[A]=(0,f.useState)(()=>Lo(n,t,u,...d)),[j,M]=(0,f.useState)(()=>rc(A,v?.text));(0,f.useEffect)(()=>{v&&y?.()},[v,y]);let ne=ds(),N=ne.remove,P=(0,f.useRef)([]),F=(0,f.useRef)(null),[I,L]=(0,f.useState)(()=>rc(`${A}:mode`)===`cadence`?`cadence`:`chat`),[R,z]=(0,f.useState)(!1),[B,V]=(0,f.useState)(``),[H,U]=(0,f.useState)(()=>rc(`${A}:pending`)),[re,G]=(0,f.useState)(()=>rc(`${A}:model-command`)),[ie,ae]=(0,f.useState)(!1),[oe,se]=(0,f.useState)(!1),[K,ce]=(0,f.useState)(!1),[ue,de]=(0,f.useState)(0),fe=(0,f.useRef)(null),q=(0,f.useRef)(!1),pe=(0,f.useRef)(0),me=(0,f.useRef)(new AbortController),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(`${A}:model`);if(e)return le(JSON.parse(e))}catch{}return v?.model??null});(0,f.useEffect)(()=>{try{_e?sessionStorage.setItem(`${A}:model`,JSON.stringify(_e)):sessionStorage.removeItem(`${A}:model`)}catch{}},[A,_e]);let ye=Ki(e,p&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),be=ye.value?.kind===`conversation-context`?ye.value.context:void 0,xe=!!be&&!ye.error,Se=be?.cwd??r,Ce=(0,f.useMemo)(()=>({models:n=>Se?e.models(n,{id:t,cwd:Se}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>Se?e.chooseModel(n,{id:t,cwd:Se}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,Se]),we=he?{status:`preparing`}:g.status===`ready`&&(!p||!xe)?{status:ye.error?`unavailable`:`connecting`}:g,Te=(0,f.useRef)(we);Te.current=we;let Ee=Zo(Ce,we,`${ue}:${be?.revision??`unobserved`}`,_),J=()=>{fe.current=null,se(!1),ce(!1)},De=(e,t)=>{e&&!Ee.preview&&!Ee.loading?Ee.reread():!e&&t!==`chosen`&&J(),ae(e)},Oe=(e,t)=>{ve(t?null:e);let n=fe.current;oe&&n&&(No(n,Te.current)===`cancel`?(J(),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(fe.current=Mo(n,e,t),se(!1),V(``),ce(!0)))},ke=(0,f.useRef)(o);ke.current=o,(0,f.useEffect)(()=>{xe&&Se&&ke.current?.({id:t,cwd:Se})},[xe,t,Se]);let Y=Yo(e,t,p,i),{turns:Ae}=Y,je=Y.summary!==void 0,Me=Ki(e,p?{kind:`cadence-conversation`,id:t}:null,1e3),X=Me.value?.kind===`cadence-conversation`?Me.value.state:void 0,Ne=X?.enabled===!0,Pe=!!X||!!Me.error,Fe=!!X&&!Me.error&&!X.notice,Ie=(0,f.useRef)(X);Ie.current=X;let[Le,Re]=(0,f.useState)(``),ze=(0,f.useRef)(``),Be=qi(j,Ne?`cadence`:I),Ve=s&&!(a&&!Y.summary)&&xe&&je&&!Y.error&&Pe&&!(Ne&&(Me.error||X?.notice))&&!R&&!oe&&!H,He=Y.summary??void 0,Ue=He&&(He.status===`queued`||He.status===`running`),We=!!He&&He.status!==`completed`&&!Ue,[Ge,Ke]=(0,f.useState)(!1),qe=!!l&&s&&(!!Y.error||!!ye.error)&&Y.error!==`retired-conversation`&&ye.error!==`retired-conversation`&&!X?.notice&&!Ue&&!R&&!H&&!oe,Je=(m||!!l)&&xe&&je&&Fe&&!Y.error&&!R&&!H&&!Ue,Ye=!!_e&&W(_e)!==W(be?.model??null),Xe=!!X?.proposal&&!!He&&!Ue&&He.status!==`unknown`,Ze=Ye?O(`Send with this model before approving a plan.`):He?.status===`unknown`?O(`The latest turn's outcome is unknown. Approval waits until it is observed.`):c?Fe?Ue?O(`Wait for the current reply before approving this plan.`):Le?O(`Observing plan approval…`):Ve?void 0:O(`Read the current conversation context before approving this plan.`):O(`Cadence state unavailable`):O(`Read the current execution state before approving this plan.`),Qe=(0,f.useRef)(null),$e=(0,f.useRef)(null),et=(0,f.useRef)(0),tt=(0,f.useRef)(!0),[Z,nt]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!E&&$e.current&&!tt.current&&($e.current.scrollTop=et.current)},[E]);let rt=(0,f.useRef)(!0),it=(0,f.useRef)(``),at=(0,f.useRef)(j);(0,f.useEffect)(()=>(rt.current=!0,me.current.signal.aborted&&(me.current=new AbortController),()=>{rt.current=!1,me.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${A}:mode`,I)}catch{}},[A,I]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(A,j)}catch{}},[j,A]),(0,f.useEffect)(()=>{try{H?sessionStorage.setItem(`${A}:pending`,H):sessionStorage.removeItem(`${A}:pending`)}catch{}},[A,H]),(0,f.useEffect)(()=>{try{H&&re===H?sessionStorage.setItem(`${A}:model-command`,re):sessionStorage.removeItem(`${A}:model-command`)}catch{}},[A,H,re]),(0,f.useEffect)(()=>{C&&(M(e=>`${e}${e?`
|
|
22
|
+
`:``}@${C}`),w(),Qe.current?.focus())},[C,w]),(0,f.useEffect)(()=>{let e=He?`${He.leaf}:${He.status}`:``;e&&it.current!==e&&(it.current=e,S()),ze.current&&X?.runs.includes(ze.current)&&(ze.current=``,Re(``),V(``)),H&&(He?.live?.commandId===H||Y.attempt?.commandId===H||Ae.some(e=>e.header.id===H)||Y.commands.includes(H))&&(U(``),Po(H,re)&&ve(null),G(``),N(P.current),M(e=>e===at.current?``:e),S()),tt.current&&$e.current&&($e.current.scrollTop=$e.current.scrollHeight)},[He,Ae,H,re,S,X,Y,N]);let ot=(0,f.useMemo)(()=>Ae.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})),[Ae]),st=oo($e,ot),ct=(0,f.useRef)(new Map),lt=(0,f.useCallback)((e,t)=>{ct.current.set(e,t)},[]),{earlier:ut,loadEarlier:dt}=Y,ft=()=>{let e=$e.current;e&&!E&&ut&&e.scrollTop<1200&&dt()};(0,f.useEffect)(ft);let pt=Ae[0]?.ordinal,mt=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=$e.current;if(!e)return;let t=mt.current;!nc&&!tt.current&&t.ordinal!==void 0&&pt!==void 0&&pt<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),mt.current={ordinal:pt,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${A}:approval`)}catch{}},[A]);let ht=(0,f.useMemo)(()=>[...new Set([...Y.runs,...X?.runs??[]])],[Y.runs,X?.runs]),gt=JSON.stringify(ht.slice(-4));(0,f.useEffect)(()=>{ee?.(JSON.parse(gt))},[gt,ee]);let[_t,vt]=(0,f.useState)({terminal:8,browser:8}),yt=(0,f.useMemo)(()=>[...new Set([...Y.runs.slice(-_t.terminal),...(X?.runs??[]).slice(-_t.browser)])],[Y.runs,X?.runs,_t]),bt=bo(e,p?yt:[],1e3),xt=Ae.find(e=>e.header.at>0)?.header.at,St=!ut&&Ae.length>0;(0,f.useEffect)(()=>{if(!p)return;let e=(e,t)=>Js(e,t,bt.runs,bt.unreadable,xt,St),t=e(Y.runs,_t.terminal),n=e(X?.runs??[],_t.browser);(t!==_t.terminal||n!==_t.browser)&&vt({terminal:t,browser:n})},[p,Y.runs,X?.runs,_t,bt,xt,St]);let Ct=(0,f.useMemo)(()=>qs(Ae,bt.runs.values(),ut),[Ae,bt.runs,ut]),wt=[...bt.runs.values()].filter(Ws).at(-1),Tt=[...bt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{Tt&&tt.current&&$e.current&&($e.current.scrollTop=$e.current.scrollHeight)},[Tt]);let Et=t=>(0,h.jsx)(Xs,{client:e,run:t,onOpen:()=>D?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{Me.refresh(),S()}},t.id),Dt=async()=>{if(!X?.proposal){V(O(`No plan is awaiting approval.`));return}if(Ye||!c||!Fe||!Ve||Ue||Le||!Xe)return;let t=X,n=pe.current;z(!0),V(``);try{let r=await Qo({client:e,state:t,current:()=>rt.current&&pe.current===n&&Ie.current?.revision===t.revision&&Ie.current?.enabled===!0,submitting:e=>{ze.current=e,Re(e)}});if(!rt.current||pe.current!==n)return;r.kind===`error`?(V(r.error.code),Re(``)):M(e=>es(e)?``:e)}catch(e){rt.current&&pe.current===n&&V(e instanceof Error?e.message:`unavailable`)}finally{rt.current&&pe.current===n&&(z(!1),Me.refresh(),Y.refresh(),S())}},Ot=async(n,r)=>{let i=r?.text??n??j,a=r?.images??(n?[]:ne.files),o=r?r.command.kind===`cadence-exit`:Ne&&$o(i);if(!(o?Je:Ve)&&!qe||Ue||!i.trim()&&!a.length||r&&(!Ve||No(r,Te.current)!==`ready`))return;if(o&&a.length){V(O(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Ne&&es(i)){c?await Dt():V(O(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let s=qi(i,I).mode===`cadence`;if(!qe&&(Ne||s)&&!Fe){V(O(`Cadence state unavailable. Observe the conversation before sending.`));return}if(q.current)return;q.current=!0,z(!0),V(``);let u=pe.current,d=()=>rt.current&&pe.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&(U(e),G(e&&!o?e:``))},h=async e=>{l&&(ge(!0),await Co(l,me.current.signal,e,e=>{p=e}),d()&&(ge(!1),de(e=>e+1)))};try{if(qe){if(await h(be?{id:t,cwd:be.cwd}:void 0),!d())return;Y.refresh(),ye.refresh(),Me.refresh(),S(),V(O(`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??Do({id:t,head:Y.leaf,text:i,images:a,revision:X?.revision??0,location:be?{id:t,cwd:be.cwd}:void 0,installModel:!!_e,model:_e??(Ee.catalog?.selected?Oo(Ee.catalog.selected):Ee.catalog?.remembered??be?.model??Ee.preview?.remembered??void 0),intent:o?`exit`:Ne?`message`:s?`enter`:`ordinary`});if(r){if(No(r,Te.current)!==`ready`)throw Error(`stale`)}else await h(n.location);if(!d())return;if(n.command.kind===`cadence-exit`){let t=Io(n);at.current=i,f=!0;let r=await Eo(e,t,m);if(!d())return;r.kind===`error`?V(O(To(r.error.effect),{code:r.error.code})):(U(``),L(`chat`),M(e=>e===i?``:e)),Me.refresh(),Y.refresh(),S();return}let c=e=>{let t=Te.current,r=e??(t.status===`ready`?t.epoch:void 0);r&&No(jo(n,r),t)!==`cancel`?(fe.current=jo(n,r),se(!0)):(J(),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))),De(!0)},l=await e.models(void 0,n.location);if(!d())return;if(n.preparedEpoch&&l.kind===`ok`&&l.value.version.epoch!==n.preparedEpoch)throw Error(`stale`);let u=l.kind===`ok`?l.value.selected??l.value.remembered:null;if(!n.model&&u&&(n=ko(n,u)),n.installModel&&l.kind===`ok`){if(l={kind:`ok`,value:await Fo(e,n,l.value,d)},!d())return;de(e=>e+1)}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`){V(t.error.code),c(l.value.version.epoch);return}if(l=await e.models(void 0,n.location),!d())return;de(e=>e+1)}if(l.kind!==`ok`||!l.value.selected){c(l.kind===`ok`?l.value.version.epoch:void 0);return}Ao(n,l.value.selected);let g=Io(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)){V(O(`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 Vo(e,g,n.images,d),!d())return}P.current=n.images,at.current=i,f=!0;let _=await Eo(e,g,m);if(!d())return;_.kind===`error`?V(O(To(_.error.effect),{code:_.error.code})):(N(P.current),ve(null),M(e=>e===at.current?``:e),U(``),g.kind===`cadence-send`&&L(`chat`),jt(null)),Me.refresh(),Y.refresh(),S()}catch(e){d()&&V(O(f?To():wo(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{pe.current===u&&(q.current=!1),d()&&(z(!1),ge(!1))}},kt=(0,f.useRef)(Ot);kt.current=Ot,(0,f.useEffect)(()=>{let e=fe.current;if(!e||!K&&!oe)return;let t=No(e,we);t===`cancel`?(fe.current=null,se(!1),ce(!1),V(O(`The connection changed. Your model choice and draft are kept; send again when ready.`))):K&&t===`ready`&&Ve&&!Ue&&(ce(!1),fe.current=null,kt.current(void 0,e))},[K,oe,Ve,Ue,we,O]),(0,f.useEffect)(()=>{if(!K)return;let e=setTimeout(()=>{ce(!1),fe.current=null},1e4);return()=>clearTimeout(e)},[K]);let At=async()=>{let n=He?.live;if(!n||R)return;z(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});rt.current&&(r.kind===`error`&&V(r.error.code),z(!1),Y.refresh())},jt=e=>{++pe.current,me.current.abort(),me.current=new AbortController,fe.current=null,q.current=!1,se(!1),ce(!1),ae(!1),z(!1),ge(!1),Y.choose(e),Ke(!1)},Mt=R||oe||!!H||!!Ue,Nt=e=>{if(!Mt)try{ne.add(e),V(``)}catch(e){V(k(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:E,"aria-label":O(Fe?Ne?`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)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:He?.title??(a?O(`Discovered session`):Y.summary===null?O(`New conversation`):O(`Conversation`))}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:O(Fe?Ne?`Cadence on`:`Ordinary`:`Cadence state unavailable`)}),He&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:He.origin===`terminal`?O(`Started in the terminal`):O(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(Y.branches>1||Y.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":Ge,onClick:()=>Ke(e=>!e),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),O(`Branches ({count})`,{count:Y.branches})]}),Y.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>jt(null),children:O(`Show the latest`)}),wt&&(0,h.jsx)(`span`,{className:`ep-state running`,children:k(Ks(wt))}),He&&(!wt||We||Ne&&!Ue&&!!X?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${He.status}`,children:Ne?Ue?O(`Discussing`):We?k(He.status):X?.proposal?O(`Awaiting plan approval`):O(`Ready for conversation`):k(He.status)})]})]}),ye.error&&!qe&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(O,ye.error)}),qe&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:O(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),he&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:O(`Preparing execution for this Send…`)}),Ge&&(0,h.jsx)(ls,{client:e,id:t,leaf:Y.leaf,onChoose:jt,onClose:()=>Ke(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:$e,onScroll:()=>{let e=$e.current;e&&!E&&(et.current=e.scrollTop,tt.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,nt(!tt.current),ft())},children:[a&&!Y.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:O(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!p&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:O(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),Y.summary===null&&!Y.error&&!a&&(0,h.jsx)(Hs,{hint:O(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),p&&!Y.error&&(!je||Ae.length===0&&Y.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:O(`Reading this conversation…`)}),Ae.length>0&&ut&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:Y.loadingEarlier&&O(`Reading earlier messages…`)}),Ct.start.map(Et),ot.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(so,{id:e,show:!st.hidden.has(e),height:st.placeholder(e,t,320),containerRef:$e,onMeasured:st.recordMeasured,lazyRef:st.register(e),children:(0,h.jsx)(Vs,{turn:n,toggled:ct.current.get(e)??null,onToggle:lt})}),Ct.after.get(e)?.map(Et),n.header.entry&&n.ordinal<Y.count-1&&!Ue&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:O(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>jt(n.header.entry),children:[(0,h.jsx)(fi,{"aria-hidden":`true`}),O(`Continue from here`)]})]},e)),Ct.end.map(Et),Y.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":O(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:Y.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${Y.attempt.status}`,children:k(Y.attempt.status)}),` `,Y.attempt.notice?k(Y.attempt.notice):``]})]}),X?.enabled&&X.proposal&&(0,h.jsx)(Zs,{proposal:X.proposal,canApprove:!Ye&&c&&Ve&&Fe&&Xe&&!Ue&&!Le,approvalHint:Ze,onApprove:()=>void Dt()}),X?.enabled&&!X.proposal&&ht.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:O(`Cadence stays on for this conversation until you explicitly exit.`)}),bt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:O(`Workflow activity unavailable; retained work may still be running.`)}),X?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:k(X.notice)}),[...new Set([B,Y.error,Me.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(O,e??``)},e)),Y.error&&Y.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:O(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),H&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[O(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:H}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:Y.refresh,children:O(`Observe current state`)})]}),Y.pinned&&!Ue&&(0,h.jsx)(`p`,{className:`inspector-note`,children:O(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),Z&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":O(`Latest messages`),onClick:()=>{$e.current&&($e.current.scrollTop=$e.current.scrollHeight),tt.current=!0},children:(0,h.jsx)(xi,{})}),(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(),Nt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),Ot()},children:[(0,h.jsx)(`input`,{ref:F,type:`file`,accept:Nn.join(`,`),multiple:!0,hidden:!0,disabled:Mt,"aria-label":O(`Add images`),onChange:e=>{Nt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),ne.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:ne.files.map(e=>(0,h.jsx)(fs,{file:e,disabled:Mt,remove:()=>N([e])},ne.key(e)))}),!Ue&&!qe&&!Ve&&!he&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:O(H?`The last Send is not yet confirmed. No message is resent.`:oe?`Choose a model; your message is sent right after.`:R?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`)}),(0,h.jsx)(`textarea`,{ref:Qe,disabled:R||!!H||oe,"aria-label":O(`Message`),value:j,placeholder:O(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>M(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Nt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),Ot())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:Mt,"aria-label":O(`Add images`),title:O(`Add images`),onClick:()=>F.current?.click(),children:(0,h.jsx)(ni,{"aria-hidden":`true`})}),(0,h.jsx)(us,{active:Ne,armed:Be.mode===`cadence`,known:Fe,disabled:Ne?!Je:!!Ue||R||!!H||oe,onClick:()=>{Ne?Ot(`exit cadence`):Be.mode===`cadence`?(L(`chat`),qi(j,`chat`).mode===`cadence`&&M(Be.text)):L(`cadence`)}}),(0,h.jsx)(ss,{client:Ce,availability:we,read:Ee,lastModel:be?.model,draftModel:_e,onPreviewChoice:_?e=>Oe(e,!1):void 0,locked:!!Ue||R||!!H,open:ie,onOpenChange:De,onChanged:()=>{ye.refresh(),x()},onChosen:e=>Oe(e,!0),awaitingSend:oe}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Ne?O(`Cadence stays on. Confirm one plan before implementation.`):Be.mode===`cadence`?O(`Your next message turns on Cadence mode.`):``}),Ue?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:R||!m,onClick:()=>void At(),children:[(0,h.jsx)(Wr,{}),O(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(Ne&&$o(j)?Je:Ve)&&!qe||!j.trim()&&!ne.files.length,children:[(0,h.jsx)(yi,{}),O(`Send`)]})]})]})]})}function ac({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=Ki(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Ki(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)(yi,{})}),(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)(Jr,{})})]}),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)(oi,{}):(0,h.jsx)(si,{}),(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)(Yr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void ga(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(pi,{})})]},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)(Hr,{})})]}),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 oc=`未命名章节`;function sc(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 cc(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=sc(r||oc),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||oc}})}function lc(e){return e.length>=2}function uc(e){let t=0,n=0;return e.split(`
|
|
23
23
|
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function dc({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:uc(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 fc({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
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=cc(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)(Ca,{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:[lc(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)(ka,{text:e})})]}):n===`diff`?(0,h.jsx)(dc,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:uc(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 pc({client:e,seed:t}){let{t:n,tx:r}=T(),i=pa(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ba,{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(da(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)(za,{client:e,cursor:a,render:e=>(0,h.jsx)(fc,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var mc=[`contents`,`checks`,`changes`,`reviews`];function hc({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:mc.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(Va,{client:e,seed:t}):(0,h.jsx)(pc,{client:e,seed:{...t,reader:i}},i)})]})}var gc={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.`},_c=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function vc(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 yc({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),te=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`})}},P=(0,f.useRef)(te);(0,f.useEffect)(()=>(A.current=!0,P.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 F=e=>{E||te(e)},I=()=>{let e=m.trim();E||(_c(e)?te(e):k({step:`read`,code:`relative`}))},L=(_||!d)&&m.trim()||d?.path||``,R=!E&&!x&&!!L,z=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!_c(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await te(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)}},B=d?vc(d.path,r):void 0,V=y.trim().toLowerCase(),H=d?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],U=O&&(O.step===`read`&&gc[O.code]?l(gc[O.code]):u(O.code));return(0,h.jsxs)(Ga,{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)(oi,{"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: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:()=>F(`~`),children:[(0,h.jsx)(ri,{"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)(gi,{"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: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)(li,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(qr,{"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)(yi,{}),l(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(e.path),children:[(0,h.jsx)(oi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&H.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(V?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),U&&(0,h.jsxs)(`p`,{role:`alert`,children:[U,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[L&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:L})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!R,onClick:()=>void z(L),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function bc(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 xc({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)(Yr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function Sc({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)(_i,{"aria-hidden":`true`}):(0,h.jsx)(gi,{"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 Cc({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=bc(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)(gi,{"aria-hidden":`true`}):(0,h.jsx)(_i,{"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)(di,{"aria-hidden":`true`}):(0,h.jsx)(Zr,{"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 wc({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)(Cc,{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)(Ba,{pager:e,compact:!0})]})}function Tc({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=pa(e,ee),N=pa(e,r&&ee&&t?{...ee,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),te=M.page&&!(`kind`in M.page)?M.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],P=s?.status===`complete`?s.runs:[],F=te.filter(e=>!P.some(t=>t.taskId===e.owner.taskId)),I=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)(wc,{pager:N,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${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:L.has(e.id),onClick:()=>{R(t=>new Set(t).add(e.id)),k(e).finally(()=>R(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),A(`Cancel workflow — request stop`)]})]},e.id)},B=m.filter(e=>e.status===`running`||e.status===`queued`),V=m.filter(e=>!B.includes(e)),H=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),U=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?H(e):void 0;return(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===y?` active`:``}`,onClick:()=>b?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{})}),(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(Ks(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)(ho,{...E,represented:!n&&E.project?[...(S??[]).map(e=>mo(E.project,`workflow`,e.id,e.epoch)),...B.flatMap(e=>e.live?[mo(E.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(xc,{onConversation:x}),!n&&(0,h.jsxs)(Sc,{title:A(`Running work`),count:s?.status===`complete`&&S&&!w&&g?String(P.length+B.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.`)}),B.map(U),S?.map(z),s?.status===`complete`&&P.length===0&&B.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`No active runs`)}),P.map(e=>{let t=te.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)(Wr,{"aria-hidden":`true`}),A(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Cc,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(Sc,{title:A(`Conversation history`),count:t?M.page&&!(`kind`in M.page)?`${V.length+F.length}${M.page.next||M.canPrevious||_?`+`:``}`:A(`Not observed`):`${V.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":A(`Tasks`),className:`task-list`,children:[V.map(U),F.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{"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&&I]},e.owner.taskId)),M.page&&!(`kind`in M.page)&&F.length===0&&V.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:A(`No conversations yet.`)}),v,t&&(0,h.jsx)(Ba,{pager:M,compact:!0})]}),!F.some(e=>e.owner.taskId===r)&&I]})]})}var Ec=[`queued`,`running`];function Dc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Ki(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?Ec.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Ec.includes(u.status)&&c(0)},[u]);let m=Ki(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?As(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Ki(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)(di,{"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)($s,{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)(Vs,{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)(ka,{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 Oc({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)(oi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(_i,{"aria-hidden":`true`})]})}function kc({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 Ac(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Vi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(Y(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function jc(){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?Y(ie(r)):void 0,o=i?U(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=Ae(ie(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Mc=`cadence-panel-layout-v1`,Nc={left:260,right:360,navigation:!0,inspector:!1};function Pc(e,t=600){return Math.max(220,Math.min(t,e))}function Fc(e){let t={...Nc};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]=Pc(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Ic(e,t){let n=e<=900,r=Pc(t.left,e-560),i=Pc(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:Pc(e-560-s),rightMaximum:Pc(e-560-a)}}function Lc({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(Pc(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(Pc(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Pc(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 Rc(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 zc(){let[e,t]=(0,f.useState)(()=>{try{return Fc(localStorage.getItem(Mc))}catch{return Fc(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=Ic(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Mc,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 Bc=.4,Vc=1.05;function Hc(e){return Math.min(300,e*.86)}function Uc(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Wc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Gc(e,t){return e===`left`?t:-t}function Kc(e,t){return Math.max(-e,Math.min(0,-e+t))}function qc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Jc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:qc(r*Vc,n,t)>=Bc}var Yc=new Set([`auto`,`scroll`,`overlay`]);function Xc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Yc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Zc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Qc(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=Uc(r.clientX,window.innerWidth,n);i&&!Xc(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=Wc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Hc(window.innerWidth),h=m*Vc;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=Gc(r,d);let b=Kc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(qc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Jc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Zc(),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 $c(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 el=`modulepreload`,tl=function(e){return`/`+e},nl={},rl=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=tl(t,n),t=s(t),t in nl)return;nl[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`:el,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 il({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=pa(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)(Ba,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(al,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function al({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 rl(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,$c(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(Va,{client:e,seed:t})]})}var ol=[[`tools`,Ur],[`context`,ti],[`timeline`,mi],[`runs`,ai]];function sl({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,discovery:o,onOpenService:s,project:c,onChooseFolder:l,onPrepareSend:u,directoryNamespaces:d,previewModels:p,initialModel:m}){let{t:g,tx:_,locale:v,setLocale:y}=T(),[b]=(0,f.useState)(()=>e??zi()),[S,C]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[w,E]=(0,f.useState)(!1),[D]=(0,f.useState)(jc),[O,k]=(0,f.useState)(D?.taskId??null),[A,j]=(0,f.useState)(()=>D?null:Hi()??crypto.randomUUID()),ee=Wi(S,A??``),[M,N]=(0,f.useState)(null),[te,P]=(0,f.useState)([]),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(D?`task`:`files`),[z,B]=(0,f.useState)(),[V,H]=(0,f.useState)(),[U,ne]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Hi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[re]=(0,f.useState)(()=>crypto.randomUUID()),ie=(0,f.useCallback)(()=>B(void 0),[]),[G,ae]=(0,f.useState)(D?D.scope??{kind:`task`,id:D.taskId}:null),oe=ra(c?.id,c?.epoch),se=!c||oe.readiness===`running`,ce=!!c&&(oe.readiness===`stopped`||oe.readiness===`not-started`),le=(0,f.useRef)(null);se&&oe.value?.epoch&&(le.current=oe.value.epoch);let ue=!c||!ce&&(se||le.current!==null),K=oa(b,O?{kind:`task`,id:O}:null,!w&&ue,le.current),de=(0,f.useRef)(!0);(K.workspace||K.observation||K.error||K.transportStatus===`stale`||K.compatible===!1)&&(de.current=!1);let fe=!!(c&&(oe.value||oe.error)),pe=!w&&!!(K.workspace||fe),me=(0,f.useRef)(null);(K.workspace||oe.value?.workspaceId)&&(me.current=K.workspace?.workspaceId??oe.value?.workspaceId??null);let he=u?async(e,t,n)=>{let r=await u(e,t,n);if(e.aborted)throw Error(`stale`);oe.prepared(r);let i=K.reconnect();await K.whenReady(r,e,i)}:void 0,q=Ji(b.client,pe),ge=Ki(b.client,K.workspace&&!w?{kind:`conversation-active`}:null,1e3),_e=ge.value?.kind===`conversation-active`?ge.value.entries:[],ve=[..._e,...(q.value?.entries??[]).filter(e=>!_e.some(t=>t.id===e.id))],ye=Ki(b.client,K.workspace&&!w?{kind:`workflow-active`}:null,2e3),be=ye.value?.kind===`workflow-active`?ye.value:void 0,xe=(0,f.useMemo)(()=>[...new Set([...be?.runs.map(e=>e.id)??[],...te])],[be,te]),Se=Ki(b.client,!c&&K.workspace&&!w?{kind:`projects`}:null),Ce=U??c?.cwd??(Se.value?.kind===`projects`?Se.value.entries.find(e=>e.current)?.path:void 0),we=V?.id===A?V:void 0;(0,f.useEffect)(()=>{we&&Hi()===we.id&&history.replaceState({...history.state,cadenceCwd:we.cwd,cadenceConversationId:we.id},``,location.href)},[we]);let Te=A?we:Ce?{id:re,cwd:Ce}:void 0,Ee=we?.cwd??Ce??(Se.value?.kind===`projects`?Se.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,J={state:K.observation,transportStatus:K.transportStatus,error:K.error,refresh:K.refresh},De=J.state?.snapshot.scope.kind===`task`&&J.state.snapshot.scope.id===O?J.state.snapshot.context:void 0,Oe=zc(),{mobile:Y,overlay:ke,closeDrawer:Ae}=Oe,je=(0,f.useRef)(null);Qc({enabled:Y&&!w,open:ke,onOpenChange:Oe.setDrawer,container:je}),Rc(je,ke,!w&&!!ke,Ae);let[X,Me]=(0,f.useState)(D?.snapshotSeq),[Ne,Pe]=(0,f.useState)(``),[Fe,Ie]=(0,f.useState)(``),Le=(0,f.useRef)(null),Re=(0,f.useRef)(null),ze=()=>{Re.current&&(Re.current.open=!1)},[Be,Ve]=(0,f.useState)(`messages`),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(),[Je,Ye]=(0,f.useState)(D?.cursor),[Xe,Ze]=(0,f.useState)(``),[Qe,$e]=(0,f.useState)([]),[et,tt]=(0,f.useState)(new Set),Z=(0,f.useRef)(!0),nt=e=>{Z.current&&$e(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Gi(t,e):t)})},rt=(0,f.useRef)(new sa),it=W({taskId:O,scope:G,selectedSnapshot:X??null,detached:w,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});rt.current.select(it),(0,f.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1,rt.current.depart()}),[]);let at=e=>{C(``);let t=e??crypto.randomUUID();e||ne(Ee??Ce),N(null),t!==A&&(P([]),B(void 0)),rt.current.depart(),j(t),k(null),ae(null),Pe(``),Ie(``),qe(void 0),Ye(void 0),Me(void 0),Ve(`messages`),R(`files`),Ae(),history.replaceState({cadenceCwd:Ee??Ce,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{A&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${A}`)},[A]);let ot=(e,t)=>{N(null),P([]),j(null),R(`task`),Pe(t??``),Ie(``),Me(void 0),rt.current.depart(),k(e),ae({kind:`task`,id:e}),qe(void 0),Ye(void 0),Ve(`messages`),Ae(),history.replaceState(null,``,Ac(e))};(0,f.useEffect)(()=>{let e=()=>{let e=jc();if(e)N(null),P([]),j(null),R(`task`),rt.current.depart(),Me(e.snapshotSeq),Pe(``),Ie(``),k(e.taskId),ae(e.scope??{kind:`task`,id:e.taskId}),qe(void 0),Ye(e.cursor),Ve(`messages`),Ae();else{let e=Hi();if(e){C(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&ne(t),B(void 0),N(null),P([]),j(e),k(null),ae(null),R(`files`),rt.current.depart(),Ae()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Ae]);let st=(e,t,n)=>{N(null),Me(t),Ie(n??``),rt.current.depart(),ae(e),qe(void 0),Ye(void 0),Ve(`messages`),Ae(),O&&history.replaceState(null,``,Ac(O,void 0,{scope:e,snapshotSeq:t}))},ct=X??J.state?.snapshot.committedSeq??K.workspace?.committedSeq,lt=K.workspace?.storeId,ut=G&<&&ct?{storeId:lt,scope:G,snapshotSeq:ct,reader:`messages`,after:null,limit:50}:null,dt=G&<&&ct?{storeId:lt,scope:G,snapshotSeq:ct,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ft=De?J.state?.snapshot.runs??[]:[],pt=rt.current.ticket(),mt=e=>{nt(e),e.receipt&&rt.current.current(pt)&&K.refresh()},ht=e=>{if(et.has(e)||!K.cancelCompatible||!K.activeRuns)return;let t=crypto.randomUUID(),n=K.activeRuns.epoch;tt(t=>new Set(t).add(e)),nt({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),b.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{mt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:g(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>nt({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Z.current&&tt(t=>{let n=new Set(t);return n.delete(e),n})})};if(w)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:g(`Detached`)}),(0,h.jsx)(`p`,{children:g(`Accepted service work continues. No Cancel was requested.`)}),Qe.map(e=>(0,h.jsxs)(`p`,{children:[g(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>E(!1),children:g(`Reconnect as a viewer`)})]});let gt=K.activeRuns,_t=gt?.status===`complete`?gt.runs:[],vt=!w&&!K.error&&K.transportStatus===`current`&&(!J.state||J.state.connection===`current`),yt=se&&vt,bt=de.current&&!J.state&&!J.error&&!oe.error&&(!c||!oe.value&&oe.readiness===`unknown`||oe.readiness===`running`),xt=ce?{status:oe.readiness===`not-started`?`not-started`:`stopped`}:K.compatible===!1?{status:`incompatible`}:se&&vt&&K.compatible&&K.epoch&&(!c||oe.value?.epoch===K.epoch)?{status:`ready`,epoch:K.epoch,attachmentVersion:K.attachmentVersion}:{status:bt?`connecting`:`unavailable`},St=w?`Viewer disconnected`:bt?`Connecting…`:c&&oe.readiness===`unknown`?`Project readiness unknown`:c&&oe.readiness===`stale`?`Project observation stale`:ce?`Ready to prepare on Send`:vt?K.workspace?J.state?.connection??(O?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(`div`,{className:`app${Oe.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":g(`Toggle conversation navigation`),"aria-expanded":Y?ke===`left`:Oe.navigation,onClick:()=>Oe.toggle(`left`),children:(0,h.jsx)(Qr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":g(`Workbench projects`),title:g(`Workbench projects`),onClick:n,children:(0,h.jsx)(oi,{})}),(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`}),G&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Be===`messages`&&!Je,onClick:()=>{Ye(void 0),qe(void 0),Ve(`messages`)},children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Le,onKeyDown:e=>{e.key===`Escape`&&Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Be===`messages`?g(`Details`):_(Be),(0,h.jsx)(_i,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[ol.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Be===e,onClick:()=>{Ye(void 0),qe(void 0),Ve(e),Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),_(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Export selected scope`),disabled:!ut,onClick:()=>{Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus()),Ge(!0)},children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!O,onClick:()=>{O&&ga(Ac(O,Je,G?{scope:G,snapshotSeq:X}:void 0)).then(e=>Ze(e?``:g(`Link copy unavailable.`)))},children:[(0,h.jsx)(ei,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[G&&(0,h.jsx)(eo,{disabled:!dt,onOpen:()=>Ue(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:v===`zh`?`en`:`zh-CN`,"aria-label":v===`zh`?`Switch to English`:`切换到中文`,"data-tip":v===`zh`?`Switch to English`:`切换到中文`,onClick:()=>y(v===`zh`?`en`:`zh`),children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:v===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Re,onKeyDown:e=>{e.key===`Escape`&&Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":g(`More`),title:g(`More`),children:(0,h.jsx)(Xr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Observe current state`),onClick:()=>{ze(),K.refresh(),oe.refresh()},children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),g(`Refresh status`)]}),s&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{ze(),s()},children:[(0,h.jsx)(Kr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Cadence service`),(0,h.jsx)(`small`,{children:g(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Disconnect this page`),title:g(`Return — accepted work continues`),onClick:()=>{ze(),Ae(),Ue(!1),Ge(!1),rt.current.depart(),E(!0)},children:[(0,h.jsx)($r,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Disconnect this page`),(0,h.jsx)(`small`,{children:g(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${K.compatible===!1?` warn`:``}`,title:Ri?.buildId??g(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:g(`Shared compatibility: {state}.`,{state:K.compatible===void 0?g(`Execution compatibility not observed`):K.compatible?g(`compatible`):g(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:g(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ri?.buildId??g(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":g(`Toggle workspace panels`),"aria-expanded":Y?ke===`right`:Oe.inspector,onClick:()=>Oe.toggle(`right`),children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:g(G&&L===`task`?`History details`:`Files`)})]})]}),!K.workspace&&_t.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:_t.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[_(e.kind),` `,e.runId,` · `,_(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ot(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!K.cancelCompatible||et.has(e.runId),onClick:()=>ht(e.runId),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(kc,{error:Xe,projectObservationError:oe.error,observationError:K.error,unavailable:!bt&&!ce&&!yt,onRefresh:()=>{K.refresh(),oe.refresh()}}),(0,h.jsxs)(`div`,{ref:je,className:`layout`,style:{"--left-w":`${Oe.left}px`,"--right-w":`${Oe.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":g(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${ke?` on`:``}`,onClick:Ae}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${ke===`left`?` open`:``}`,"aria-label":g(`Conversation navigation`),tabIndex:-1,inert:Y?ke!==`left`:!Oe.navigation||ke===`right`,children:[!pe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[o&&(0,h.jsx)(ho,{...o}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(bt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,h.jsx)(Tc,{discovery:o,client:b.client,workspace:K.workspace,executionStopped:ce,taskId:O,scope:G,runs:ft,snapshot:J.state?.snapshot.committedSeq,activeRuns:K.activeRuns,cancelCompatible:!!K.cancelCompatible,canceling:et,onCancel:ht,chats:ve,chatActivityKnown:ge.value?.kind===`conversation-active`&&!ge.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:g(`Reading conversation history…`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.previous,children:g(`Newer conversations`)}),q.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.next,children:g(`Older conversations`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:q.first,children:g(`Latest conversations`)}),q.error&&(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:g(`Observe current state`)})]}),conversationId:A,onConversation:at,onNewConversation:()=>at(),workflows:be?.runs,workflowLinks:be?.links,workflowError:!!ye.error,selectedWorkflow:M?.runId,onWorkflow:(e,t)=>{t?at(t):(N({runId:e.id,stepId:null,label:e.goal}),Ae())},onCancelWorkflow:async e=>{let t=await Qs(b.client,e);t&&Ze(t),ye.refresh()},onTask:ot,onScope:st}),K.workspace&&(0,h.jsx)(xo,{client:b.client,active:K.activeRuns,taskId:O,runs:ft,snapshot:ct,workflowRuns:xe,selected:M,onOpenWorkflow:e=>{N(e),Ae()},onOpen:(e,t,n,r)=>{ot(e),ae({kind:`child`,id:t}),Ie(r),Me(n),history.replaceState(null,``,Ac(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Lc,{side:`left`,width:Oe.left,maximum:Oe.leftMaximum,onResize:e=>Oe.resize(`left`,e)}),(0,h.jsxs)(`main`,{className:`main`,inert:ke!==null,children:[A&&c&&!fe&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),M&&(0,h.jsx)(Dc,{client:b.client,agent:M,backLabel:g(A?`Back to conversation`:O?`Back to task`:`Back`),onBack:()=>N(null),onOpenAgent:N},`${M.runId}:${M.stepId??``}`),A&&(!c||fe)&&(0,h.jsx)(ic,{client:b.client,id:A,activitySelected:ee.selected,initialLeaf:ee.leaf,initialCwd:Ce,onLocation:H,hidden:!!M,onOpenAgent:N,onWorkflowRuns:P,workspaceId:c?`checkout:${c.path}`:me.current??`connecting`,directoryNamespaces:d,legacyWorkspaceId:c?oe.value?.workspaceId??void 0:void 0,prepareForSend:he,actionsReady:se&&!!K.workspace&&!!K.compatible&&!K.error&&vt,available:pe,canInterrupt:!!K.cancelCompatible,enabled:he?pe:!!K.workspace&&!!K.compatible&&!K.error,modelAvailability:xt,previewModels:p,initialModel:m?.conversationId===A?m.model:void 0,onModelChanged:()=>{rt.current.depart(),K.refresh(!0),oe.refresh()},onChanged:()=>{q.refresh(),K.refresh()},reference:z,onReferenceUsed:ie},`${c?.id??me.current??`connecting`}:${A}:${ee.leaf??``}`),G&&!M&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[G.kind!==`task`&&O&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ot(O,Ne),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Ne||G.id,children:G.kind===`task`?Ne||g(`Task {id}`,{id:G.id.slice(0,8)}):Fe||g(`{kind} {id}`,{kind:_(G.kind),id:G.id.slice(0,8)})}),G.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[g(`Recorded conversation`),` ·`,` `,g(`snapshot {seq}`,{seq:ct??``})]}),(0,h.jsx)(`code`,{children:G.id}),(0,h.jsx)(`p`,{children:g(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!A||!!M,children:[!ut&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:K.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:g(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ut&&Je?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Ke&&(Ke.owner.entity.kind===`task`||Ke.owner.entity.kind===`message`||Ke.owner.entity.kind===`tool`)&&(0,h.jsx)(Ha,{client:b.client,seed:{storeId:Je.storeId,scope:Je.scope,snapshotSeq:Je.snapshotSeq,kind:Ke.owner.entity.kind,id:Ke.owner.entity.id,version:Ke.owner.entity.version}},`${Ke.owner.entity.id}:${Ke.owner.entity.version}`),(0,h.jsx)(za,{client:b.client,cursor:Je,highlight:Ke?.range},`${Je.recordId}:${Je.recordVersion}`)]}):ut&&(0,h.jsxs)(`div`,{className:Be===`messages`||Be===`tools`?`tab-body transcript-body`:`tab-body`,children:[Be===`messages`&&(0,h.jsx)(uo,{client:b.client,seed:ut}),Be===`tools`&&(0,h.jsx)(cl,{client:b.client,seed:ut}),Be===`context`&&(0,h.jsx)(Va,{client:b.client,seed:ut}),Be===`timeline`&&(0,h.jsx)(il,{client:b.client,seed:ut,onSearch:()=>Ue(!0)}),Be===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:g(`Runs in the current snapshot`)}),ft.length>0?ft.map(e=>(0,h.jsx)(Xa,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:De&&J.state?g(`No owner run projection in this snapshot.`):g(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:g(`Retained runs`)}),(0,h.jsx)($a,{client:b.client,seed:{...ut,scope:{kind:`task`,id:O??ut.scope.id}},onScope:st},O)]})]},`${G?.kind}:${G?.id}:${X??`current`}`)]}),K.workspace&&Qe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Qe.map(e=>(0,h.jsx)(ca,{client:b.client,value:e,onChange:nt},e.commandId))})]}),(0,h.jsx)(Lc,{side:`right`,width:Oe.right,maximum:Oe.rightMaximum,onResize:e=>Oe.resize(`right`,e)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${ke===`right`?` open`:``}`,"aria-label":g(`Files and history drawer`),tabIndex:-1,inert:Y?ke!==`right`:!Oe.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":g(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":L===`files`||!G,onClick:()=>R(`files`),children:[(0,h.jsx)(oi,{}),g(`Files`)]}),G&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":L===`task`,disabled:!ut,onClick:()=>R(`task`),children:[(0,h.jsx)(ti,{}),g(`History details`)]})]}),L===`files`||!G?(0,h.jsx)(ac,{location:Te,client:b.client,enabled:!!K.workspace&&!!Te,onReference:e=>{A||at(re);let t=!A&&Te?`${Te.cwd.replace(/[\\/]+$/,``)}${Te.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;B(t),Ae()}},Te?.cwd??`owner`):ut?(0,h.jsx)(hc,{client:b.client,seed:{...ut,scope:{kind:`task`,id:O??ut.scope.id}}},O):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:K.error?g(`Recorded history could not be read.`):g(`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:g(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${bt?`busy`:ce?``:!yt||!K.workspace?`error`:J.transportStatus===`current`?J.state?J.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),_(St)]}),c&&(0,h.jsx)(`span`,{className:`status-item faint`,children:g(`Execution service: {status}`,{status:_(oe.readiness)})}),gt?.status===`complete`?_t.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:g(yt?_t.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:_t.length})}):!bt&&!ce&&(0,h.jsx)(`span`,{className:`status-item faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(K.workspace||c)&&(0,h.jsx)(Oc,{path:Ee,onClick:()=>l?l(Ee):I(``)}),K.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:g(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),F!==null&&K.workspace&&(0,h.jsx)(yc,{onOpen:t,projects:i??(Se.value?.kind===`projects`?Se.value.entries:[]),client:b.client,current:Ee??K.workspace.rootLabel,initial:F||void 0,home:r,epoch:K.workspace.epoch,onClose:()=>I(null)}),He&&dt&&(0,h.jsx)(Ya,{client:b.client,seed:dt,onClose:()=>Ue(!1),onHit:e=>{qe(e),Ye(e.cursor),O&&history.replaceState(null,``,Ac(O,e.cursor,G?{scope:G,snapshotSeq:X}:void 0))}}),We&&dt&&(0,h.jsx)(Ka,{request:{storeId:dt.storeId,scope:dt.scope,snapshotSeq:dt.snapshotSeq,format:`ndjson`},onClose:()=>Ge(!1)})]})}function cl({client:e,seed:t}){let n=pa(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ba,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(po,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var ll=`cadence-last-project`;function ul(){try{let e=localStorage.getItem(ll);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function dl(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(ll,e)}catch{}}function fl(e){let t=ul();return t?e.projects.find(e=>e.id===t):void 0}async function pl(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=hn(await Yi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function ml(e,t){if(!Ri)throw Error(`unsupported-context`);let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t,headers:{"X-Cadence-Build":JSON.stringify({kind:`browser`,...Ri})}}),r=await Yi(n);if(!n.ok)throw Error(Xi(r));return fn(r)}async function hl(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Yi(t);if(!t.ok)throw Error(Xi(n));return bn(n)}async function gl(e,t,n,r,i){if(!Ri)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`,...Ri})},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 Yi(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Xi(c));let l=mn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function _l(e,t){let n=await hl(t);return gl(`/workbench/v1/select`,{path:e},n,t)}async function vl(e,t,n,r){let i=await hl(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 gl(`/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 yl(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await _l(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var bl=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function xl(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:N(t.cwd,4096,!0),leaf:t.leaf===null?null:N(t.leaf,128,!0),history:I(t.history,[`shared`,`unavailable`]),phase:I(t.phase,bl),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:N(t.executionCwd,4096,!0)}}function Sl(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:N(t.path,4096,!0),activities:B(t.activities,256,xl)}})}}async function Cl(e){if(!Ri)throw Error(`unsupported-context`);let t=wi([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`,...Ri})}}),n=await Yi(e);if(!e.ok)throw Error(Xi(n));return Sl(n)}finally{t.dispose()}}function wl(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 Tl(e,t,n,r=Cl){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?wl(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 El(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return Tl(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}var Dl=`cadence-recovery-dismissed`,Ol={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.`},kl={"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 Al(){try{let e=JSON.parse(localStorage.getItem(Dl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function jl(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Ml({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Al),[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(Dl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:jl(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(Ol[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(kl[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Nl={restart:18e4,upgrade:12e5},Pl=1e3,Fl={"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.`},Il=e=>e instanceof Error?e.message:`unavailable`;function Ll(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(Fl[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 Rl(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function zl(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 Bl({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 Qi(e.signal).then(a,t=>{e.signal.aborted||s(Il(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>Nl[e.action])return w(`timeout`);try{let t=await Qi(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,Pl)};return r=setTimeout(i,Pl),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),$i().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),ea({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(Il(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`&&Rl(C),o=i?.unit;return(0,h.jsxs)(Ga,{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:Nl[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Ll(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)(Ga,{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`?jn(c.version,i.version)>0:!1;return(0,h.jsxs)(Ga,{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:zl(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:Ll(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})}):On(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(bi,{"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)(Jr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Vl({ready:e,previewModels:t,model:n,onModelChoice:r,projects:i=[],restore:a=null,opening:o=null,onOpenFolder:s,onOpenProject:c,onOpenService:l,children:u,discovery:d}){let{t:p,locale:m,setLocale:g}=T(),[_,v]=(0,f.useState)(!1),y=Zo(null,{status:`not-started`},`home`,t),b=zc(),{mobile:x,overlay:S,closeDrawer:C}=b,w=(0,f.useRef)(null);Qc({enabled:x,open:S,onOpenChange:b.setDrawer,container:w}),Rc(w,S,!!S,C);let E=e=>{C(),s(e)},D=e=>{C(),c?c(e):s(e)},O=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${b.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":x?S===`left`:b.navigation,onClick:()=>b.toggle(`left`),children:(0,h.jsx)(Qr,{"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:[l&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":p(`Cadence service`),"data-tip":p(`Cadence service`),onClick:l,children:(0,h.jsx)(Kr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:m===`zh`?`en`:`zh-CN`,onClick:()=>g(m===`zh`?`en`:`zh`),"aria-label":m===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:m===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":p(`Toggle workspace panels`),"aria-expanded":x?S===`right`:b.inspector,onClick:()=>b.toggle(`right`),children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:p(`Files`)})]})]}),u,(0,h.jsxs)(`div`,{className:`layout`,ref:w,style:{"--left-w":`${b.left}px`,"--right-w":`${b.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":p(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${S?` on`:``}`,onClick:C}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${S===`left`?` open`:``}`,"aria-label":p(`Conversation navigation`),tabIndex:-1,inert:x?S!==`left`:!b.navigation||S===`right`,children:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[d&&(0,h.jsx)(ho,{...d}),(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:p(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:a?.status===`checking`?p(`Returning to your last project {name}…`,{name:O(a.path)}):a?.status===`unavailable`?p(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:O(a.path)}):i.length?p(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):p(`Choose a working folder to see its conversation history.`)}),i.map(t=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item project-item`,title:t,disabled:!e||!!o,"aria-busy":o===t,onClick:()=>D(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(oi,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:O(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:o===t?p(`Selecting folder…`):t})]})]},t))]})]})]})}),(0,h.jsx)(`main`,{className:`main`,inert:S!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":p(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Hs,{hint:p(`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:()=>E(),children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),p(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":p(`Message`),rows:3,placeholder:p(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(ss,{scope:`next-conversation`,availability:{status:`not-started`},read:y,draftModel:n,onPreviewChoice:r,locked:!e,open:_,onOpenChange:e=>{e&&!y.preview&&!y.loading&&y.reread(),v(e)},onChanged:()=>{}}),(0,h.jsx)(`span`,{className:`composer-hint`,children:p(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),p(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${S===`right`?` open`:``}`,"aria-label":p(`Files`),tabIndex:-1,inert:x?S!==`right`:!b.inspector,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),p(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:p(`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:p(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(Oc,{disabled:!e,onClick:()=>E()})})]})]})}function Hl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(),[s,c]=(0,f.useState)(Vi),l=(0,f.useCallback)(e=>ml(s??void 0,e),[s]),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(null),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(0),[S,C]=(0,f.useState)(!1),[w,E]=(0,f.useState)(null),D=(0,f.useCallback)(()=>x(e=>e+1),[]),O=El(t?.epoch,D),k=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>k.current?.abort(),[]);let M=(0,f.useRef)(new Map),N=(0,f.useRef)(!s),te=(0,f.useRef)(null),P=(0,f.useCallback)(()=>{te.current&&(te.current.abort(),te.current=null,E(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 Yi(t);t.status===400&&Xi(r)===`invalid`?n(null):t.ok?(n(bn(r)),y(``)):y(Xi(r))}catch{e.signal.aborted||y(`unavailable`)}})(),()=>e.abort()},[b]),(0,f.useEffect)(()=>{let e=()=>{k.current?.abort(),P(),E(null),c(Vi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[P]),(0,f.useEffect)(()=>{if(!t||!N.current)return;N.current=!1;let e=fl(t);if(!e)return;let n=new AbortController;te.current=n,E({status:`checking`,path:e.cwd}),pl(e.id,n.signal).then(t=>{n.signal.aborted||(te.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),E(null),c(e.id)):E({status:`unavailable`,path:e.cwd}))})},[t]);let F=(0,f.useCallback)((e,n)=>{P(),E(null),s&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===s)?.cwd&&M.current.set(s,window.location.hash);let a=crypto.randomUUID();!s&&e&&!n&&r?(o({conversationId:a,model:r}),i(null)):o(void 0),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)}`:``}`:!s&&r?`#chat=${a}`:M.current.get(e.id)??`#chat=${a}`}`:`/app`),c(e?.id??null),d(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[s,P,t,r]),I=(0,f.useCallback)(async e=>{k.current?.abort();let t=new AbortController;k.current=t;let r=await _l(e,t.signal);t.signal.aborted||(n(r.entry),F(r.project))},[F]),L=t?{value:O.value,error:O.error,opening:!!p,project:t.projects.find(e=>e.id===s)?.path,onOpen:(e,t)=>{k.current?.abort(),P();let r=new AbortController;k.current=r,m(t.cwd),_(``),yl(e,t,r.signal).then(e=>{r.signal.aborted||(n(e.entry),F(e.project,t))}).catch(e=>{r.signal.aborted||_(e instanceof Error?e.message:`unavailable`)}).finally(()=>{k.current===r&&m(null)})}}:void 0,R=async(e,r,i)=>{let a=t?.projects.find(e=>e.id===s);if(!a)throw Error(`unavailable`);let o=await vl(a,e,r,i);if(e.aborted)throw Error(`stale`);return n(o.entry),o.project.epoch},z=(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 Yi(n);if(!n.ok){let e=Xi(r);return{kind:`error`,error:ee(A.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Or(r)}}catch{return{kind:`error`,error:ee(`unavailable`)}}}}),[]),B=(0,f.useMemo)(()=>s?zi(s):void 0,[s]),V=t?.projects.find(e=>e.id===s);if((0,f.useEffect)(()=>{V&&dl(V.id)},[V]),t===null)return(0,h.jsx)(sl,{});let H=t&&S&&(0,h.jsx)(Bl,{epoch:t.epoch,csrf:t.csrf,onClose:()=>C(!1)}),U=()=>C(!0),ne=t&&u!==null&&(0,h.jsx)(yc,{selectOnly:!0,client:z,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:u,home:t.home,epoch:t.epoch,onClose:()=>d(null),onOpen:I});return t&&V&&B?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(sl,{api:B,project:V,previewModels:l,initialModel:a,directoryNamespaces:t?.projects.filter(e=>e.path===V.path).map(e=>e.id).sort(),discovery:L,onPrepareSend:R,onChooseFolder:e=>{k.current?.abort(),d(e??V.cwd)},onOpenProject:I,onWorkbenchHome:()=>F(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===s})),notices:(0,h.jsxs)(h.Fragment,{children:[` `,g&&(0,h.jsx)(`p`,{role:`alert`,children:g}),(0,h.jsx)(Ml,{notices:t.recoveries,project:V.path}),` `]}),onOpenService:U},V.id),H,ne]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Vl,{discovery:L,ready:!!t,previewModels:t?l:void 0,model:r,onModelChoice:e=>{P(),i(e)},projects:t?.projects.map(e=>e.cwd)??[],restore:w,opening:p,onOpenService:t?U:void 0,onOpenFolder:e=>{P(),_(``),k.current?.abort(),d(e??t?.home??``)},onOpenProject:t=>{p||(P(),_(``),m(t),I(t).catch(n=>_(e(`{path} could not be opened ({code}).`,{path:t,code:n instanceof Error?n.message:`unavailable`}))).finally(()=>m(null)))},children:[g&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g}),t&&(0,h.jsx)(Ml,{notices:t.recoveries}),v&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[v,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>x(e=>e+1),children:e(`Reload observation`)})]}),s&&!V&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),ne,H]})}function Ul(){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 Wl=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Ul,{}):this.props.children}},Gl=document.getElementById(`root`);if(!Gl)throw Error(`Application root unavailable`);(0,p.createRoot)(Gl).render((0,h.jsx)(E,{children:(0,h.jsx)(Wl,{children:(0,h.jsx)(Hl,{})})}));export{rl as t};
|
|
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:[lc(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)(ka,{text:e})})]}):n===`diff`?(0,h.jsx)(dc,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:uc(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 pc({client:e,seed:t}){let{t:n,tx:r}=T(),i=pa(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ba,{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(da(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)(za,{client:e,cursor:a,render:e=>(0,h.jsx)(fc,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var mc=[`contents`,`checks`,`changes`,`reviews`];function hc({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:mc.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(Va,{client:e,seed:t}):(0,h.jsx)(pc,{client:e,seed:{...t,reader:i}},i)})]})}var gc={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.`},_c=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function vc(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 yc({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),[ee,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),ne=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`})}},N=(0,f.useRef)(ne);(0,f.useEffect)(()=>(k.current=!0,N.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 P=e=>{E||ne(e)},F=()=>{let e=m.trim();E||(_c(e)?ne(e):O({step:`read`,code:`relative`}))},I=(_||!d)&&m.trim()||d?.path||``,L=!E&&!x&&!!I,R=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!_c(n)){O({step:`read`,code:`relative`});return}D(!0),O(null);let r=n===d?.path?d.path:(await ne(n))?.path;if(!k.current)return;if(!r){D(!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`}),D(!1))}return}if(!e.workbenchCommand){O({step:`open`,code:`unavailable`}),D(!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`}),D(!1))}else O({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},z=d?vc(d.path,r):void 0,B=y.trim().toLowerCase(),V=d?.entries.filter(e=>e.name.toLowerCase().includes(B))??[],H=ee&&(ee.step===`read`&&gc[ee.code]?l(gc[ee.code]):u(ee.code));return(0,h.jsxs)(Ga,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,h.jsx)(`h3`,{children:l(`Recent folders`)}),(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 R(e.path),children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[z&&!_?(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:()=>P(`~`),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),z.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),z.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||z.inside)&&(0,h.jsx)(gi,{"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:()=>P(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(),F()},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),ee?.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)(li,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(qr,{"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:()=>P(d.parent),children:[(0,h.jsx)(yi,{}),l(`Parent folder`)]}),V.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(e.path),children:[(0,h.jsx)(oi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&V.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(B?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),H&&(0,h.jsxs)(`p`,{role:`alert`,children:[H,ee?.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:[I&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:I})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!L,onClick:()=>void R(I),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function bc(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 xc({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)(Yr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function Sc({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)(_i,{"aria-hidden":`true`}):(0,h.jsx)(gi,{"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 Cc({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=bc(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)(gi,{"aria-hidden":`true`}):(0,h.jsx)(_i,{"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)(di,{"aria-hidden":`true`}):(0,h.jsx)(Zr,{"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 wc({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)(Cc,{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)(Ba,{pager:e,compact:!0})]})}function Tc({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:ee,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=pa(e,te),M=pa(e,r&&te&&t?{...te,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),ne=j.page&&!(`kind`in j.page)?j.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],N=s?.status===`complete`?s.runs:[],P=ne.filter(e=>!N.some(t=>t.taskId===e.owner.taskId)),F=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":k(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:k(`Task conversations`)}),(0,h.jsx)(wc,{pager:M,scope:i,onScope:p,exclude:N.map(e=>e.runId)},r)]}),[I,L]=(0,f.useState)(()=>new Set),R=e=>{let t=C.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${D===e.id||t&&t===y?` active`:``}`,onClick:()=>ee?.(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:I.has(e.id),onClick:()=>{L(t=>new Set(t).add(e.id)),O(e).finally(()=>L(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),k(`Cancel workflow — request stop`)]})]},e.id)},z=m.filter(e=>e.status===`running`||e.status===`queued`),B=m.filter(e=>!z.includes(e)),V=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),H=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?V(e):void 0;return(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===y?` active`:``}`,onClick:()=>b?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{})}),(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(Ks(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)(ho,{...E,represented:!n&&E.project?[...(S??[]).map(e=>mo(E.project,`workflow`,e.id,e.epoch)),...z.flatMap(e=>e.live?[mo(E.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(xc,{onConversation:x}),!n&&(0,h.jsxs)(Sc,{title:k(`Running work`),count:s?.status===`complete`&&S&&!w&&g?String(N.length+z.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.`)}),z.map(H),S?.map(R),s?.status===`complete`&&N.length===0&&z.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No active runs`)}),N.map(e=>{let t=ne.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)(Wr,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Cc,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(Sc,{title:k(`Conversation history`),count:t?j.page&&!(`kind`in j.page)?`${B.length+P.length}${j.page.next||j.canPrevious||_?`+`:``}`:k(`Not observed`):`${B.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[B.map(H),P.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:k(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&F]},e.owner.taskId)),j.page&&!(`kind`in j.page)&&P.length===0&&B.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(Ba,{pager:j,compact:!0})]}),!P.some(e=>e.owner.taskId===r)&&F]})]})}var Ec=[`queued`,`running`];function Dc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Ki(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?Ec.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Ec.includes(u.status)&&c(0)},[u]);let m=Ki(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?As(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Ki(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)(di,{"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)($s,{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)(Vs,{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)(ka,{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 Oc({path:e,disabled:t=!1,onClick:n}){let{t:r}=T();return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Choose working folder`)}),(0,h.jsx)(_i,{"aria-hidden":`true`})]})}function kc({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 Ac(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Vi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:B(e)});if(n&&(a.set(`scope`,JSON.stringify(ke(n.scope))),n.snapshotSeq&&a.set(`snapshot`,H(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function jc(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=B(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?ke(G(r)):void 0,o=i?H(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=Ae(G(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Mc=`cadence-panel-layout-v1`,Nc={left:260,right:360,navigation:!0,inspector:!1};function Pc(e,t=600){return Math.max(220,Math.min(t,e))}function Fc(e){let t={...Nc};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]=Pc(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Ic(e,t){let n=e<=900,r=Pc(t.left,e-560),i=Pc(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:Pc(e-560-s),rightMaximum:Pc(e-560-a)}}function Lc({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(Pc(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(Pc(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Pc(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 Rc(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var zc=.4,Bc=1.05;function Vc(e){return Math.min(300,e*.86)}function Hc(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Uc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Wc(e,t){return e===`left`?t:-t}function Gc(e,t){return Math.max(-e,Math.min(0,-e+t))}function Kc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function qc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Kc(r*Bc,n,t)>=zc}var Jc=new Set([`auto`,`scroll`,`overlay`]);function Yc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Jc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Xc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Zc(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=Hc(r.clientX,window.innerWidth,n);i&&!Yc(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=Uc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Vc(window.innerWidth),h=m*Bc;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=Wc(r,d);let b=Gc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Kc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?qc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Xc(),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({panels:e,navigation:t,inspector:n,inspectorLabel:r,toolbar:i,actions:a,notices:o,status:s,folder:c,compatible:l,onRefresh:u,onDisconnect:d,onOpenService:p,content:m}){let{t:g,locale:_,setLocale:v}=T(),{mobile:y,overlay:b,closeDrawer:S}=e,C=(0,f.useRef)(null),w=(0,f.useRef)(null),E=()=>{w.current&&(w.current.open=!1)};return Zc({enabled:y,open:b,onOpenChange:e.setDrawer,container:C}),Rc(C,b,!!b,S),(0,h.jsxs)(`div`,{className:`app${e.className}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":g(`Toggle conversation navigation`),"aria-expanded":y?b===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(Qr,{"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`,"aria-hidden":`true`}),i,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[a,(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:_===`zh`?`en`:`zh-CN`,"aria-label":_===`zh`?`Switch to English`:`切换到中文`,"data-tip":_===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(_===`zh`?`en`:`zh`),children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:_===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:w,onKeyDown:e=>{e.key===`Escape`&&w.current&&(w.current.open=!1,w.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":g(`More`),title:g(`More`),children:(0,h.jsx)(Xr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Observe current state`),onClick:()=>{E(),u()},children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),g(`Refresh status`)]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Cadence service`),onClick:()=>{E(),p()},children:[(0,h.jsx)(Kr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Cadence service`),(0,h.jsx)(`small`,{children:g(`Version, restart and upgrade.`)})]})]}),d&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Disconnect this page`),title:g(`Return — accepted work continues`),onClick:()=>{E(),S(),d()},children:[(0,h.jsx)($r,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Disconnect this page`),(0,h.jsx)(`small`,{children:g(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${l===!1?` warn`:``}`,title:Ri?.buildId??g(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:g(`Shared compatibility: {state}.`,{state:g(l===void 0?`Execution compatibility not observed`:l?`compatible`:`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:g(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ri?.buildId??g(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":g(`Toggle workspace panels`),"aria-expanded":y?b===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??g(`Files`)})]})]}),o,(0,h.jsxs)(`div`,{ref:C,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":g(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${b?` on`:``}`,onClick:S}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${b===`left`?` open`:``}`,"aria-label":g(`Conversation navigation`),tabIndex:-1,inert:y?b!==`left`:!e.navigation||b===`right`,children:t}),(0,h.jsx)(Lc,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:b!==null,children:m}),(0,h.jsx)(Lc,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${b===`right`?` open`:``}`,"aria-label":g(`Files and history drawer`),tabIndex:-1,inert:y?b!==`right`:!e.inspector,children:n})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:s}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:c})]})]})}function $c(){let[e,t]=(0,f.useState)(()=>{try{return Fc(localStorage.getItem(Mc))}catch{return Fc(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=Ic(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Mc,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})}}}function el(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 tl=`modulepreload`,nl=function(e){return`/`+e},rl={},il=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=nl(t,n),t=s(t),t in rl)return;rl[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`:tl,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 al({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=pa(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)(Ba,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(ol,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function ol({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 il(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,el(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(Va,{client:e,seed:t})]})}var sl=[[`tools`,Ur],[`context`,ti],[`timeline`,mi],[`runs`,ai]];function cl({api:e,onOpenProject:t,homeFolder:n,projectEntries:r,notices:i,discovery:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareSend:l,directoryNamespaces:u,previewModels:d,initialDraft:p,onDraftApplied:m}){let{t:g,tx:_}=T(),[v]=(0,f.useState)(()=>e??zi()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(jc),[w,E]=(0,f.useState)(C?.taskId??null),[D,ee]=(0,f.useState)(()=>C?null:Hi()??crypto.randomUUID()),O=Wi(y,D??``),[k,A]=(0,f.useState)(null),[te,j]=(0,f.useState)([]),[M,ne]=(0,f.useState)(null),[N,P]=(0,f.useState)(C?`task`:`files`),[F,I]=(0,f.useState)(),[L,R]=(0,f.useState)(),[z,B]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Hi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[V]=(0,f.useState)(()=>crypto.randomUUID()),H=(0,f.useCallback)(()=>I(void 0),[]),[U,re]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),G=ra(s?.id,s?.epoch),ie=!s||G.readiness===`running`,ae=!!s&&(G.readiness===`stopped`||G.readiness===`not-started`),oe=(0,f.useRef)(null);ie&&G.value?.epoch&&(oe.current=G.value.epoch);let se=!s||!ae&&(ie||oe.current!==null),K=oa(v,w?{kind:`task`,id:w}:null,!x&&se,oe.current),ce=(0,f.useRef)(!0);(K.workspace||K.observation||K.error||K.transportStatus===`stale`||K.compatible===!1)&&(ce.current=!1);let le=!!(s&&(G.value||G.error)),ue=!x&&!!(K.workspace||le),de=(0,f.useRef)(null);(K.workspace||G.value?.workspaceId)&&(de.current=K.workspace?.workspaceId??G.value?.workspaceId??null);let fe=l?async(e,t,n)=>{let r=await l(e,t,n);if(e.aborted)throw Error(`stale`);G.prepared(r);let i=K.reconnect();await K.whenReady(r,e,i)}:void 0,q=Ji(v.client,ue),pe=Ki(v.client,K.workspace&&!x?{kind:`conversation-active`}:null,1e3),me=pe.value?.kind===`conversation-active`?pe.value.entries:[],he=[...me,...(q.value?.entries??[]).filter(e=>!me.some(t=>t.id===e.id))],ge=Ki(v.client,K.workspace&&!x?{kind:`workflow-active`}:null,2e3),_e=ge.value?.kind===`workflow-active`?ge.value:void 0,ve=(0,f.useMemo)(()=>[...new Set([..._e?.runs.map(e=>e.id)??[],...te])],[_e,te]),ye=Ki(v.client,!s&&K.workspace&&!x?{kind:`projects`}:null),be=z??s?.cwd??(ye.value?.kind===`projects`?ye.value.entries.find(e=>e.current)?.path:void 0),xe=L?.id===D?L:void 0;(0,f.useEffect)(()=>{xe&&Hi()===xe.id&&history.replaceState({...history.state,cadenceCwd:xe.cwd,cadenceConversationId:xe.id},``,location.href)},[xe]);let Se=D?xe:be?{id:V,cwd:be}:void 0,Ce=xe?.cwd??be??(ye.value?.kind===`projects`?ye.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,we={state:K.observation,transportStatus:K.transportStatus,error:K.error,refresh:K.refresh},Te=we.state?.snapshot.scope.kind===`task`&&we.state.snapshot.scope.id===w?we.state.snapshot.context:void 0,Ee=$c(),{closeDrawer:J}=Ee,[De,Oe]=(0,f.useState)(C?.snapshotSeq),[ke,Y]=(0,f.useState)(``),[Ae,je]=(0,f.useState)(``),Me=(0,f.useRef)(null),[X,Ne]=(0,f.useState)(`messages`),[Pe,Fe]=(0,f.useState)(!1),[Ie,Le]=(0,f.useState)(!1),[Re,ze]=(0,f.useState)(),[Be,Ve]=(0,f.useState)(C?.cursor),[He,Ue]=(0,f.useState)(``),[We,Ge]=(0,f.useState)([]),[Ke,qe]=(0,f.useState)(new Set),Je=(0,f.useRef)(!0),Ye=e=>{Je.current&&Ge(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Gi(t,e):t)})},Xe=(0,f.useRef)(new sa),Ze=W({taskId:w,scope:U,selectedSnapshot:De??null,detached:x,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});Xe.current.select(Ze),(0,f.useEffect)(()=>(Je.current=!0,()=>{Je.current=!1,Xe.current.depart()}),[]);let Qe=e=>{b(``);let t=e??crypto.randomUUID();e||B(Ce??be),A(null),t!==D&&(j([]),I(void 0)),Xe.current.depart(),ee(t),E(null),re(null),Y(``),je(``),ze(void 0),Ve(void 0),Oe(void 0),Ne(`messages`),P(`files`),J(),history.replaceState({cadenceCwd:Ce??be,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 $e=(e,t)=>{A(null),j([]),ee(null),P(`task`),Y(t??``),je(``),Oe(void 0),Xe.current.depart(),E(e),re({kind:`task`,id:e}),ze(void 0),Ve(void 0),Ne(`messages`),J(),history.replaceState(null,``,Ac(e))};(0,f.useEffect)(()=>{let e=()=>{let e=jc();if(e)A(null),j([]),ee(null),P(`task`),Xe.current.depart(),Oe(e.snapshotSeq),Y(``),je(``),E(e.taskId),re(e.scope??{kind:`task`,id:e.taskId}),ze(void 0),Ve(e.cursor),Ne(`messages`),J();else{let e=Hi();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&B(t),I(void 0),A(null),j([]),ee(e),E(null),re(null),P(`files`),Xe.current.depart(),J()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[J]);let et=(e,t,n)=>{A(null),Oe(t),je(n??``),Xe.current.depart(),re(e),ze(void 0),Ve(void 0),Ne(`messages`),J(),w&&history.replaceState(null,``,Ac(w,void 0,{scope:e,snapshotSeq:t}))},tt=De??we.state?.snapshot.committedSeq??K.workspace?.committedSeq,Z=K.workspace?.storeId,nt=U&&Z&&tt?{storeId:Z,scope:U,snapshotSeq:tt,reader:`messages`,after:null,limit:50}:null,rt=U&&Z&&tt?{storeId:Z,scope:U,snapshotSeq:tt,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,it=Te?we.state?.snapshot.runs??[]:[],at=Xe.current.ticket(),ot=e=>{Ye(e),e.receipt&&Xe.current.current(at)&&K.refresh()},st=e=>{if(Ke.has(e)||!K.cancelCompatible||!K.activeRuns)return;let t=crypto.randomUUID(),n=K.activeRuns.epoch;qe(t=>new Set(t).add(e)),Ye({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{ot(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:g(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>Ye({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Je.current&&qe(t=>{let n=new Set(t);return n.delete(e),n})})};if(x)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:g(`Detached`)}),(0,h.jsx)(`p`,{children:g(`Accepted service work continues. No Cancel was requested.`)}),We.map(e=>(0,h.jsxs)(`p`,{children:[g(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:g(`Reconnect as a viewer`)})]});let ct=K.activeRuns,lt=ct?.status===`complete`?ct.runs:[],ut=!x&&!K.error&&K.transportStatus===`current`&&(!we.state||we.state.connection===`current`),dt=ie&&ut,ft=ce.current&&!we.state&&!we.error&&!G.error&&(!s||!G.value&&G.readiness===`unknown`||G.readiness===`running`),pt=ae?{status:G.readiness===`not-started`?`not-started`:`stopped`}:K.compatible===!1?{status:`incompatible`}:ie&&ut&&K.compatible&&K.epoch&&(!s||G.value?.epoch===K.epoch)?{status:`ready`,epoch:K.epoch,attachmentVersion:K.attachmentVersion}:{status:ft?`connecting`:`unavailable`},mt=x?`Viewer disconnected`:ft?`Connecting…`:s&&G.readiness===`unknown`?`Project readiness unknown`:s&&G.readiness===`stale`?`Project observation stale`:ae?`Ready to prepare on Send`:ut?K.workspace?we.state?.connection??(w?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Qc,{panels:Ee,compatible:K.compatible,onOpenService:o,onRefresh:()=>{K.refresh(),G.refresh()},onDisconnect:()=>{Fe(!1),Le(!1),Xe.current.depart(),S(!0)},inspectorLabel:g(U&&N===`task`?`History details`:`Files`),toolbar:U&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":X===`messages`&&!Be,onClick:()=>{Ve(void 0),ze(void 0),Ne(`messages`)},children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Me,onKeyDown:e=>{e.key===`Escape`&&Me.current&&(Me.current.open=!1,Me.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[X===`messages`?g(`Details`):_(X),(0,h.jsx)(_i,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[sl.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":X===e,onClick:()=>{Ve(void 0),ze(void 0),Ne(e),Me.current&&(Me.current.open=!1,Me.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),_(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Export selected scope`),disabled:!nt,onClick:()=>{Me.current&&(Me.current.open=!1,Me.current.querySelector(`summary`)?.focus()),Le(!0)},children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&ga(Ac(w,Be,U?{scope:U,snapshotSeq:De}:void 0)).then(e=>Ue(e?``:g(`Link copy unavailable.`)))},children:[(0,h.jsx)(ei,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:U&&(0,h.jsx)(eo,{disabled:!rt,onOpen:()=>Fe(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!K.workspace&<.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:lt.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:[_(e.kind),` `,e.runId,` · `,_(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>$e(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!K.cancelCompatible||Ke.has(e.runId),onClick:()=>st(e.runId),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(kc,{error:He,projectObservationError:G.error,observationError:K.error,unavailable:!ft&&!ae&&!dt,onRefresh:()=>{K.refresh(),G.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!ue&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(ho,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(ft?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),ue&&(0,h.jsx)(Tc,{discovery:a,client:v.client,workspace:K.workspace,executionStopped:ae,taskId:w,scope:U,runs:it,snapshot:we.state?.snapshot.committedSeq,activeRuns:K.activeRuns,cancelCompatible:!!K.cancelCompatible,canceling:Ke,onCancel:st,chats:he,chatActivityKnown:pe.value?.kind===`conversation-active`&&!pe.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:g(`Reading conversation history…`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.previous,children:g(`Newer conversations`)}),q.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:q.loading,onClick:q.next,children:g(`Older conversations`)}),q.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:q.first,children:g(`Latest conversations`)}),q.error&&(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:Qe,onNewConversation:()=>Qe(),workflows:_e?.runs,workflowLinks:_e?.links,workflowError:!!ge.error,selectedWorkflow:k?.runId,onWorkflow:(e,t)=>{t?Qe(t):(A({runId:e.id,stepId:null,label:e.goal}),J())},onCancelWorkflow:async e=>{let t=await Qs(v.client,e);t&&Ue(t),ge.refresh()},onTask:$e,onScope:et}),K.workspace&&(0,h.jsx)(xo,{client:v.client,active:K.activeRuns,taskId:w,runs:it,snapshot:tt,workflowRuns:ve,selected:k,onOpenWorkflow:e=>{A(e),J()},onOpen:(e,t,n,r)=>{$e(e),re({kind:`child`,id:t}),je(r),Oe(n),history.replaceState(null,``,Ac(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!le&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),k&&(0,h.jsx)(Dc,{client:v.client,agent:k,backLabel:g(D?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>A(null),onOpenAgent:A},`${k.runId}:${k.stepId??``}`),D&&(!s||le)&&(0,h.jsx)(ic,{client:v.client,id:D,activitySelected:O.selected,initialLeaf:O.leaf,initialCwd:be,onLocation:R,hidden:!!k,onOpenAgent:A,onWorkflowRuns:j,workspaceId:s?`checkout:${s.path}`:de.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?G.value?.workspaceId??void 0:void 0,prepareForSend:fe,actionsReady:ie&&!!K.workspace&&!!K.compatible&&!K.error&&ut,available:ue,canInterrupt:!!K.cancelCompatible,enabled:fe?ue:!!K.workspace&&!!K.compatible&&!K.error,modelAvailability:pt,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{Xe.current.depart(),K.refresh(!0),G.refresh()},onChanged:()=>{q.refresh(),K.refresh()},reference:F,onReferenceUsed:H},`${s?.id??de.current??`connecting`}:${D}:${O.leaf??``}`),U&&!k&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[U.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>$e(w,ke),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:ke||U.id,children:U.kind===`task`?ke||g(`Task {id}`,{id:U.id.slice(0,8)}):Ae||g(`{kind} {id}`,{kind:_(U.kind),id:U.id.slice(0,8)})}),U.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[g(`Recorded conversation`),` ·`,` `,g(`snapshot {seq}`,{seq:tt??``})]}),(0,h.jsx)(`code`,{children:U.id}),(0,h.jsx)(`p`,{children:g(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!k,children:[!nt&&(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?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:g(`History is readonly. Start new work in a conversation with /cadence.`)})]}),nt&&Be?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Re&&(Re.owner.entity.kind===`task`||Re.owner.entity.kind===`message`||Re.owner.entity.kind===`tool`)&&(0,h.jsx)(Ha,{client:v.client,seed:{storeId:Be.storeId,scope:Be.scope,snapshotSeq:Be.snapshotSeq,kind:Re.owner.entity.kind,id:Re.owner.entity.id,version:Re.owner.entity.version}},`${Re.owner.entity.id}:${Re.owner.entity.version}`),(0,h.jsx)(za,{client:v.client,cursor:Be,highlight:Re?.range},`${Be.recordId}:${Be.recordVersion}`)]}):nt&&(0,h.jsxs)(`div`,{className:X===`messages`||X===`tools`?`tab-body transcript-body`:`tab-body`,children:[X===`messages`&&(0,h.jsx)(uo,{client:v.client,seed:nt}),X===`tools`&&(0,h.jsx)(ll,{client:v.client,seed:nt}),X===`context`&&(0,h.jsx)(Va,{client:v.client,seed:nt}),X===`timeline`&&(0,h.jsx)(al,{client:v.client,seed:nt,onSearch:()=>Fe(!0)}),X===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:g(`Runs in the current snapshot`)}),it.length>0?it.map(e=>(0,h.jsx)(Xa,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Te&&we.state?g(`No owner run projection in this snapshot.`):g(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:g(`Retained runs`)}),(0,h.jsx)($a,{client:v.client,seed:{...nt,scope:{kind:`task`,id:w??nt.scope.id}},onScope:et},w)]})]},`${U?.kind}:${U?.id}:${De??`current`}`)]}),K.workspace&&We.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:We.map(e=>(0,h.jsx)(ca,{client:v.client,value:e,onChange:Ye},e.commandId))})]}),inspector:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":g(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`files`||!U,onClick:()=>P(`files`),children:[(0,h.jsx)(oi,{}),g(`Files`)]}),U&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!nt,onClick:()=>P(`task`),children:[(0,h.jsx)(ti,{}),g(`History details`)]})]}),N===`files`||!U?(0,h.jsx)(ac,{location:Se,client:v.client,enabled:!!K.workspace&&!!Se,onReference:e=>{D||Qe(V);let t=!D&&Se?`${Se.cwd.replace(/[\\/]+$/,``)}${Se.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;I(t),J()}},Se?.cwd??`owner`):nt?(0,h.jsx)(hc,{client:v.client,seed:{...nt,scope:{kind:`task`,id:w??nt.scope.id}}},w):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:K.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)})]}),status:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`status-item`,role:`status`,title:g(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${ft?`busy`:ae?``:!dt||!K.workspace?`error`:we.transportStatus===`current`?we.state?we.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),_(mt)]}),s&&(0,h.jsx)(`span`,{className:`status-item faint`,children:g(`Execution service: {status}`,{status:_(G.readiness)})}),ct?.status===`complete`?lt.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:g(dt?lt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:lt.length})}):!ft&&!ae&&(0,h.jsx)(`span`,{className:`status-item faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(0,h.jsxs)(h.Fragment,{children:[(K.workspace||s)&&(0,h.jsx)(Oc,{path:Ce,onClick:()=>c?c(Ce):ne(``)}),K.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:g(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})}),M!==null&&K.workspace&&(0,h.jsx)(yc,{onOpen:t,projects:r??(ye.value?.kind===`projects`?ye.value.entries:[]),client:v.client,current:Ce??K.workspace.rootLabel,initial:M||void 0,home:n,epoch:K.workspace.epoch,onClose:()=>ne(null)}),Pe&&rt&&(0,h.jsx)(Ya,{client:v.client,seed:rt,onClose:()=>Fe(!1),onHit:e=>{ze(e),Ve(e.cursor),w&&history.replaceState(null,``,Ac(w,e.cursor,U?{scope:U,snapshotSeq:De}:void 0))}}),Ie&&rt&&(0,h.jsx)(Ka,{request:{storeId:rt.storeId,scope:rt.scope,snapshotSeq:rt.snapshotSeq,format:`ndjson`},onClose:()=>Le(!1)})]})}function ll({client:e,seed:t}){let n=pa(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ba,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(po,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var ul=`cadence:folder-draft`,dl=()=>({text:``,model:null});function fl(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return dl();let t=null;try{e.model!=null&&(t=le(e.model))}catch{}return{text:e.text,model:t}}catch{return dl()}}function pl(e){try{e.text||e.model?sessionStorage.setItem(ul,JSON.stringify(e)):sessionStorage.removeItem(ul)}catch{}}function ml(e,t,n){let r=Lo(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(ul)}catch{}return{...n,conversationId:t}}var hl=`cadence-last-project`;function gl(){try{let e=localStorage.getItem(hl);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function _l(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(hl,e)}catch{}}function vl(e){let t=gl();return t?e.projects.find(e=>e.id===t):void 0}async function yl(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=hn(await Yi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function bl(e,t){if(!Ri)throw Error(`unsupported-context`);let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t,headers:{"X-Cadence-Build":JSON.stringify({kind:`browser`,...Ri})}}),r=await Yi(n);if(!n.ok)throw Error(Xi(r));return fn(r)}async function xl(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Yi(t);if(!t.ok)throw Error(Xi(n));return bn(n)}async function Sl(e,t,n,r,i){if(!Ri)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`,...Ri})},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 Yi(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Xi(c));let l=mn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Cl(e,t){let n=await xl(t);return Sl(`/workbench/v1/select`,{path:e},n,t)}async function wl(e,t,n,r){let i=await xl(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 Sl(`/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 Tl(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Cl(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var El=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Dl(e){let t=R(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:B(t.id),source:F(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:F(t.history,[`shared`,`unavailable`]),phase:F(t.phase,El),freshness:F(t.freshness,[`current`,`stale`,`unknown`]),observedAt:N(t.observedAt,0),epoch:t.epoch===null?null:B(t.epoch),instance:t.instance===null?null:B(t.instance),executionCwd:t.executionCwd===null?null:M(t.executionCwd,4096,!0)}}function Ol(e){let t=R(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:I(t.kind,`activity-discovery`),epoch:B(t.epoch),observedAt:N(t.observedAt,0),completeness:F(t.completeness,[`complete`,`partial`]),unavailable:N(t.unavailable,0,1e4),projects:z(t.projects,128,e=>{let t=R(e,[`path`,`activities`]);return{path:M(t.path,4096,!0),activities:z(t.activities,256,Dl)}})}}async function kl(e){if(!Ri)throw Error(`unsupported-context`);let t=wi([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`,...Ri})}}),n=await Yi(e);if(!e.ok)throw Error(Xi(n));return Ol(n)}finally{t.dispose()}}function Al(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 jl(e,t,n,r=kl){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?Al(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 Ml(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return jl(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function Nl({ready:e,previewModels:t,draft:n=dl(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=T(),d=$c(),[p,m]=(0,f.useState)(!1),g=Zo(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(Qc,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(xc,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(ho,{...l}),(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:u(`Conversation history`)})}),(0,h.jsx)(`div`,{className:`lp-section-body`,children:(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsxs)(Hs,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:_,children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(ss,{scope:`next-conversation`,availability:{status:`not-started`},read:g,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:p,onOpenChange:e=>{e&&!g.preview&&!g.loading&&g.reread(),m(e)},onChanged:()=>{}}),(0,h.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),u(`Send`)]})]})]})]}),inspector:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(oi,{"aria-hidden":`true`}),u(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})]}),status:(0,h.jsx)(`span`,{className:`status-item faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(Oc,{disabled:!e,onClick:_})})}var Pl=`cadence-recovery-dismissed`,Fl={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.`},Il={"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 Ll(){try{let e=JSON.parse(localStorage.getItem(Pl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Rl(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function zl({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Ll),[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(Pl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:Rl(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Fl[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(Il[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Bl={restart:18e4,upgrade:12e5},Vl=1e3,Hl={"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.`},Ul=e=>e instanceof Error?e.message:`unavailable`;function Wl(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(Hl[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 Gl(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Kl(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 ql({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 Qi(e.signal).then(a,t=>{e.signal.aborted||s(Ul(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>Bl[e.action])return w(`timeout`);try{let t=await Qi(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,Vl)};return r=setTimeout(i,Vl),()=>{n.abort(),clearTimeout(r)}},[v]);let ee=()=>{l(`checking`),$i().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},O=n=>{i&&(_(!0),s(``),ea({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(Ul(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`&&Gl(C),o=i?.unit;return(0,h.jsxs)(Ga,{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:Bl[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Wl(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)(Ga,{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`?jn(c.version,i.version)>0:!1;return(0,h.jsxs)(Ga,{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:Kl(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 Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Wl(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:ee,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})}):On(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(bi,{"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)(Jr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function Jl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(fl),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(Vi),u=(0,f.useCallback)(e=>bl(c??void 0,e),[c]),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(null),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(0),[C,w]=(0,f.useState)(!1),[E,D]=(0,f.useState)(null),ee=(0,f.useCallback)(()=>S(e=>e+1),[]),O=Ml(t?.epoch,ee),j=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>j.current?.abort(),[]);let M=(0,f.useRef)(new Map),ne=(0,f.useRef)(!c),N=(0,f.useRef)(null),P=(0,f.useCallback)(()=>{N.current&&(N.current.abort(),N.current=null,D(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 Yi(t);t.status===400&&Xi(r)===`invalid`?n(null):t.ok?(n(bn(r)),b(``)):b(Xi(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,f.useEffect)(()=>{let e=()=>{j.current?.abort(),P(),D(null),l(Vi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[P]),(0,f.useEffect)(()=>{if(!t||!ne.current||(ne.current=!1,r.text||r.model))return;let e=vl(t);if(!e)return;let n=new AbortController;N.current=n,D({status:`checking`,path:e.cwd}),yl(e.id,n.signal).then(t=>{n.signal.aborted||(N.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),D(null),l(e.id)):D({status:`unavailable`,path:e.cwd}))})},[t,r]);let F=(0,f.useCallback)((e,n)=>{P(),D(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&M.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=!t?.projects.some(e=>e.id===c)&&!n&&!!(r.text||r.model);s?(o(ml(e.path,a,r)),i(dl())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:M.current.get(e.id)??`#chat=${a}`}`),l(e.id),p(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,P,t,r]),I=(0,f.useCallback)(async e=>{j.current?.abort();let t=new AbortController;j.current=t;let r=await Cl(e,t.signal);t.signal.aborted||(n(r.entry),F(r.project))},[F]),L=t?{value:O.value,error:O.error,opening:!!m,project:t.projects.find(e=>e.id===c)?.path,onOpen:(e,t)=>{j.current?.abort(),P();let r=new AbortController;j.current=r,g(t.cwd),v(``),Tl(e,t,r.signal).then(e=>{r.signal.aborted||(n(e.entry),F(e.project,t))}).catch(e=>{r.signal.aborted||v(e instanceof Error?e.message:`unavailable`)}).finally(()=>{j.current===r&&g(null)})}}:void 0,R=async(e,r,i)=>{let a=t?.projects.find(e=>e.id===c);if(!a)throw Error(`unavailable`);let o=await wl(a,e,r,i);if(e.aborted)throw Error(`stale`);return n(o.entry),o.project.epoch},z=(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 Yi(n);if(!n.ok){let e=Xi(r);return{kind:`error`,error:te(k.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Or(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),B=(0,f.useMemo)(()=>c?zi(c):void 0,[c]),V=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{V&&_l(V.id)},[V]),t===null)return(0,h.jsx)(cl,{});let H=t&&C&&(0,h.jsx)(ql,{epoch:t.epoch,csrf:t.csrf,onClose:()=>w(!1)}),U=()=>w(!0),re=t&&d!==null&&(0,h.jsx)(yc,{selectOnly:!0,client:z,current:V?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>p(null),onOpen:I});return t&&V&&B?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(cl,{api:B,project:V,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===V.path).map(e=>e.id).sort(),discovery:L,onPrepareSend:R,onChooseFolder:e=>{j.current?.abort(),p(e??V.cwd)},onOpenProject:I,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,h.jsxs)(h.Fragment,{children:[` `,_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),(0,h.jsx)(zl,{notices:t.recoveries,project:V.path}),` `]}),onOpenService:U},V.id),H,re]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Nl,{discovery:L,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{P(),i(e),pl(e)},restore:E,onRefresh:()=>S(e=>e+1),onOpenService:t?U:void 0,onChooseFolder:()=>{P(),v(``),j.current?.abort(),p(t?.home??``)},notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_}),t&&(0,h.jsx)(zl,{notices:t.recoveries}),y&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e+1),children:e(`Reload observation`)})]}),c&&!V&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),re,H]})}function Yl(){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 Xl=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Yl,{}):this.props.children}},Zl=document.getElementById(`root`);if(!Zl)throw Error(`Application root unavailable`);(0,p.createRoot)(Zl).render((0,h.jsx)(E,{children:(0,h.jsx)(Xl,{children:(0,h.jsx)(Jl,{})})}));export{il as t};
|