@abelxiaoxing/cadence 2.0.50 → 2.1.0
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 -2
- package/docs/conversation-mode.md +26 -6
- package/docs/history.md +15 -2
- package/package.json +4 -1
- package/src/cadence-instructions.ts +5 -5
- package/src/cadence-mode.ts +49 -7
- package/src/coordinator-tools.mjs +39 -5
- package/src/model-preview.mjs +4 -1
- package/src/native-build.ts +1 -1
- package/src/sdk-worker.mjs +80 -59
- package/src/service/contracts/models.ts +6 -0
- package/src/service/contracts/workbench.ts +218 -17
- package/src/service/contracts/workflow.ts +309 -30
- package/src/service-host.mjs +4588 -2279
- package/src/session-entries.mjs +3 -1
- package/src/session-file.mjs +26 -0
- package/src/session-rename.mjs +94 -0
- package/src/session-sharing.ts +3 -1
- package/src/worker-inputs.mjs +144 -0
- package/src/worker-toolkit.mjs +26 -1
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +31 -22
- package/web/dist/manifest.json +7 -7
|
@@ -1,25 +1,34 @@
|
|
|
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={"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"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":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files 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,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,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),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`],ce=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],le=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function K(e){let t=R(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:F(t.api,ce),thinking:F(t.thinking,le)}}function ue(e){let{sourceSelectionId:t,...n}=R(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:B(t),...K(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 pe(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 me(e){let t=R(e,[`start`,`end`]),n=N(t.start);return{start:n,end:N(t.end,n+1,O.detailBytes)}}function he(e){let t=R(e,[`source`,`range`,`requireCompleteObservation`]),n=ge(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=pe(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,me);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:P(t.requireCompleteObservation)}}function ge(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function _e(e){W(e,O.graphBytes);let t=R(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(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,he)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new A(`forbidden`);c(e)}return i}function ve(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 ye(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,ve)}}function be(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,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function xe(e){switch(W(e),ge(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=_e(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:ge(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:be(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 Se(e){W(e);let t=R(e,[`expected`,`action`]);return{expected:ye(t.expected),action:xe(t.action)}}function Ce(e){W(e);let t=R(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:B(t.commandId),grant:B(t.grant),expected:ye(t.expected),action:xe(t.action)}}function we(e){if(W(e),ge(e)===`action`){let t=R(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ye(t.expected),action:xe(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 Te(e){let t=R(e,[`commandId`,`epoch`,`runId`]);return{commandId:B(t.commandId),epoch:B(t.epoch),runId:B(t.runId)}}function Ee(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,be);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:ye(n.version),action:xe(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:L(n.graph,_e),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 De(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:Ee(t.preview)}}function q(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 Oe(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=pe(t.result);I(i.field,`final-text`);let a=L(t.range,me);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:q(t.coverage)}})}}function ke(e){let t=R(e,[`source`,`reason`,`target`]);return{source:F(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:M(t.reason,128,!0),target:M(t.target,128,!0)}}function Ae(e){let t=R(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:ke(t.stop)},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:q(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 je(e){let t=R(e,[`kind`,`id`]);return{kind:F(t.kind,[`task`,`run`,`child`]),id:B(t.id)}}function J(e){let t=M(e,O.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function Me(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:je(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:J(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Ne(e){let t=R(e,[`disposition`,`value`]),n=F(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Le(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function Pe(e){let t=R(e,[`messageId`,`blockId`]);return{messageId:B(t.messageId),blockId:B(t.blockId)}}function Y(e){let t=ge(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=pe(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 Fe(e){let t=R(e,[`owner`,`field`,`encoding`]),n=Y(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 Ie(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:Y(t.owner),sourceType:n,mimeType:i,reason:r}}function Le(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Re(e){let t=R(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`]),n=N(t.maxAttempts,1),r={phase:F(t.phase,[`waiting`,`requesting`]),attempt:N(t.attempt,1,n),maxAttempts:n,delayMs:N(t.delayMs,0,2147483647)};if(r.phase===`requesting`&&r.delayMs!==0)throw new A(`invalid`);return r}function ze(e){let t=ge(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:Ne(n.source),resultCallId:i}}case`message-text`:{let n=R(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...Pe({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:Pe(n.declaration),index:N(n.index,0,O.dataFrames),source:Ne(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,Pe),source:Ne(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,Pe),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:Ne(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:Ie(R(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=R(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:B(n.detailId),descriptor:Fe(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:q(n.coverage)}}case`model-retry`:return{kind:t,progress:L(R(e,[`kind`,`progress`]).progress,Re)};case`capture-status`:return{kind:t,coverage:q(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 Be(e){let t=R(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:ke(t.stop)},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 Ve(e){let t=R(e,[`messageId`,`detailId`]);return{messageId:B(t.messageId),detailId:B(t.detailId)}}function He(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:pe(t.content),committedSeq:n}}function Ue(e){let t=ge(e,`status`);if(t===`committed`){let n=R(e,[`status`,`selected`,`detail`]),r=Ve(n.selected),i=He(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,Ve),error:ie(n.error)}}let n=R(e,[`status`,`selected`]);return{status:F(t,[`pending`,`uncertain`]),selected:L(n.selected,Ve)}}function X(e,t){let n=L(e,H);return(n===`0`||n!==null&&t.status===`committed`&&U(n,t.detail.committedSeq)<0)&&j(),n}function We(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ge(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?We(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function Ke(e){let t=ge(e);if(t===`sdk`){let n=R(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ue(n.recording),i=X(n.settlementSeq,r);return{kind:t,native:Ae(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:Be(n.native),capture:q(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=Ue(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:re(t.assignmentId),childRunId:n,native:L(t.native,Ae),recording:r,settlementSeq:X(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(We))&&j(),{kind:`parent`,outcome:i,required:r}}function qe(e){let t=R(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=N(t.first,1,2**53-1),r=N(t.last,n,2**53-1),i=N(t.firstObservedMs),a=N(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Je(e){let t=R(e,[`source`,`event`]),n=qe(t.source),r=ge(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:q(e.coverage)}}}let i=ze(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ye(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 Xe(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:Ze(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 Ze(e){let t=ie(e);return I(t.effect,`none`),t}function Qe(e){let t=R(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:V(t.sourceHash),contractHash:V(t.contractHash),buildId:V(t.buildId)}}function $e(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,...Qe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function et(e){let t=R(e,[`contractHash`,`assets`]);return{contractHash:V(t.contractHash),assets:Qe(t.assets)}}function tt(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 nt(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,Ke),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&&Ge(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function rt(e){W(e);let t=R(e,[`identity`,`receipt`]),n=we(t.identity),r=nt(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(ge(e)===`ok`)return{kind:`ok`,value:t(R(e,[`kind`,`value`]).value)};let n=R(e,[`kind`,`error`]);return I(n.kind,`error`),{kind:`error`,error:ie(n.error)}}function it(e){switch(W(e),ge(e,`status`)){case`found`:return{status:`found`,receipt:nt(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 at(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:ht(t.admission),lifecycle:F(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:L(t.outcome,e=>F(e,oe)),settlement:L(t.settlement,Ke),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:q(t.coverage),result:L(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&&Ge(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ge(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function ot(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function st(e,t,n){return ot(e,t)&&e.taskId===vt(n)&&e.admission.context.workspaceId===_t(n)}function ct(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:je(t.scope),committedSeq:H(t.committedSeq),context:gt(t.context),runs:z(t.runs,O.maxPageEntries,at),horizon:At(t.horizon)};return(!yt(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=>!st(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function lt(e){W(e,O.pageBytes);let t=ge(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:je(n.scope),committedSeq:H(n.committedSeq)};if(t===`update`){let e=H(n.previousSeq);U(r.committedSeq,e)<=0&&j();let i=gt(n.context);yt(i,r.epoch,r.scope)||j();let a=z(n.runs,O.maxPageEntries,at),o=z(n.removed,O.maxPageEntries,B),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!st(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 ut(e){let{navigation:t,...n}=e;return n}function dt(e,t){(!t.navigation||t.navigation===e.navigation||W(ut(e))!==W(ut(t)))&&j()}function ft(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return pt(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`cursor`,`next`,`coverage`]),n=Me(t.cursor),r=Me(t.next);return dt(n,r),{kind:`progress`,cursor:n,next:r,coverage:q(t.coverage)}}function pt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Me(t.cursor),content:pe(t.content),range:L(t.range,me),text:M(t.text,O.detailPageBytes),next:L(t.next,Me),coverage:q(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(ut({...n.next,offset:n.cursor.offset}))!==W(ut(n.cursor)))&&j(),n}function mt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`cursor`,`hits`,`next`,`coverage`]),n=Me(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=pe(t.content),a=St(t.owner);Ct(a,n.scope)||j();let o=me(t.range),s=Me(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,Me);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:q(t.coverage)}}function ht(e){let t=R(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ye(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 gt(e){if(ge(e,`status`)===`available`)return{status:`available`,version:ye(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 _t(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function vt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function yt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||vt(e)===n.id)}function bt(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:et(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 xt(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:Xe(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:gt(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(),(_t(n.context)!==n.workspaceId||vt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function St(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 Ct(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function wt(e){let t=R(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:V(t.identity),complete:P(t.complete),checkoutGeneration:N(t.checkoutGeneration)}}function Tt(e){W(e,O.controlBytes);let t=ge(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:ht(n.identity)}}case`parent-settled`:{let n=R(e,[`kind`,`runId`,`settlement`]),r=Ke(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:Oe(n.handoff),observation:wt(n.observation)}}case`changes`:{let n=R(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=pe(n.content);return I(r.field,`changes`),{kind:t,observationId:B(n.observationId),stage:F(n.stage,[`before`,`after`,`review`]),observation:wt(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:be(n.selection),cwdId:B(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:N(n.checkEnvGeneration,1),before:wt(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=Be(r.native),o=F(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=wt(r.before),c=wt(r.after),l=L(r.output,pe),u=q(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=pe(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 Et(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 Dt(e){W(e,O.ownerQueueBytes);let t=R(e,[`observedMs`,`link`,`events`]),n=Et(t.link),r=z(t.events,O.ownerQueueFrames,e=>{let t=ge(e);if(t===`fact`){let r=Tt(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=St(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:q(r.coverage)}});return{observedMs:N(t.observedMs),link:n,events:r}}var Ot=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function kt(e){let t=R(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=F(t.reader,Ot),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:J(t.navigation)}:{},storeId:B(t.storeId),scope:i,snapshotSeq:a,after:o,limit:N(t.limit,1,O.maxPageEntries)}}function At(e){let t=R(e,[`policy`,`historicalRuns`]),n=kt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:I(t.policy,`active-and-recent`),historicalRuns:n}}function jt(e){let t=ge(e);if(t===`run`)return{kind:t,projection:at(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:Ye(n.link),capture:Je(n.capture)}}if(t===`owner-fact`){let n=R(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Dt({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=St(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,pe);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=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,pe),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:Ne(i.source)}}if(t===`tool`){let e=L(i.declaration,Pe),n=L(i.declarationStage,e=>F(e,[`partial`,`final`])),r=P(i.startObserved),s=L(i.result,e=>{let t=ze(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:Ne(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Fe(i.descriptor),n=pe(i.content);return(e.field!==n.field||!Mt(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:B(i.detailId),descriptor:e,content:n,coverage:q(i.coverage)}}I(t,`omitted`);let s=Ie(i.block);return Mt(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function Mt(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 Nt(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 Pt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`request`,`records`,`next`,`coverage`]),n=kt(t.request);n.snapshotSeq===null&&j();let r=z(t.records,n.limit,jt),i=L(t.next,kt);return(r.some(e=>!Nt(e,n))||i&&(i.after===null||W(ut({...i,after:n.after}))!==W(ut(n))||W(i.after)===W(n.after)))&&j(),{request:n,records:r,next:i,coverage:q(t.coverage)}}function Ft(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=kt(t.request),r=kt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(ut({...r,snapshotSeq:null}))!==W(ut(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:q(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Pt(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=kt(t.request),r=kt(t.next);return dt(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}function It(e,t){return W({...t.request,snapshotSeq:e.snapshotSeq})===W(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Lt(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:J(t.navigation)}:{},storeId:B(t.storeId),scope:je(t.scope),snapshotSeq:H(t.snapshotSeq),graph:{recordId:B(n.recordId),revision:N(n.revision,1),sha256:V(n.sha256)}}}function Rt(e){W({kind:`ok`,value:e});let t=R(e,[`request`,`graph`]),n=Lt(t.request),r=_e(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function zt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Rt(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return dt(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}function Bt(e){let t=R(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:B(t.storeId),scope:je(t.scope),snapshotSeq:H(t.snapshotSeq),format:F(t.format,[`ndjson`,`markdown`])}}function Vt(e){W(e,O.controlBytes);let t=R(e,[`exportId`,`ordinal`,`event`]),n=ge(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:Bt(e.request),coverage:q(e.coverage),serviceProtocol:I(e.serviceProtocol,1),workerProtocol:I(e.workerProtocol,2)};break}case`record`:r={kind:n,record:jt(R(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Rt(R(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=R(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=pe(e.content),a=L(e.range,me),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:St(e.owner),content:i,range:a,text:o,coverage:q(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=q(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 Ht(e,t){let n=Vt(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 Ut=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Bt(e)}receive(e){let t=Vt(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`&&!Ct(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`&&!Wt(n.record,this.request.scope)&&j(),this.bytes+=ne(Ht(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 Wt(e,t){return e.kind===`run`?ot(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:Ct(e.owner,t)}function Gt(e){let t=R(e,[`taskId`,`revision`,`definitions`]),n=z(t.definitions,32,e=>{let t=R(e,[`selection`,`status`,`checkId`]),n=be(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 Kt(e){let t=R(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:J(t.navigation)}:{},storeId:B(t.storeId),scope:je(t.scope),snapshotSeq:H(t.snapshotSeq),kind:F(t.kind,[`task`,`message`,`tool`]),id:B(t.id),version:N(t.version,1)}}function qt(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`request`,`record`]),n=Kt(t.request),r=jt(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||!Ct(r.owner,n.scope))&&j(),{request:n,record:r}}function Jt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return qt(e);W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`kind`,`request`,`next`,`coverage`]),n=Kt(t.request),r=Kt(t.next);return dt(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}var Yt=e=>{let t=ie(e);return I(t.effect,`none`),t};function Xt(e){let t=R(e,[`storeId`,`taskId`]);return{storeId:B(t.storeId),taskId:L(t.taskId,B)}}function Zt(e){let t=Xt(e);return t.taskId===null&&j(),t}function Qt(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 $t(e){let t=z(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function en(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:Lt(n.request),planRevision:N(n.planRevision,1)}}let n=R(e,[`status`,`error`]);return I(n.status,`unavailable`),{status:`unavailable`,error:Yt(n.error)}}function tn(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||_t(e.context)!==e.workspaceId||vt(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 nn(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Xt(t.request),workspaceId:B(t.workspaceId),epoch:B(t.epoch),committedSeq:H(t.committedSeq),context:gt(t.context),task:L(t.task,Qt),roles:$t(t.roles),savedGraph:en(t.savedGraph),readablePlan:L(t.readablePlan,e=>{let t=R(e,[`source`,`text`,`editable`,`coverage`]),n=q(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}})};tn(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 rn(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:Zt(t.request),workspaceId:B(t.workspaceId),epoch:B(t.epoch),committedSeq:H(t.committedSeq),context:gt(t.context),task:Qt(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:q(t.coverage)};if(tn(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 an(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 on(e){let t=R(e,[`id`,`cwd`]);return{id:an(t.id),cwd:M(t.cwd,4096,!0)}}function sn(e){let t=R(e,[`id`,`cwd`,`revision`,`model`]);return{id:an(t.id),cwd:M(t.cwd,4096,!0),revision:N(t.revision,0,2**53-1-1),model:L(t.model,K)}}function cn(e){let t=R(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:M(t.cwd,4096,!0),checkoutRoot:M(t.checkoutRoot,4096,!0),version:ln(t.version),model:L(t.model,ue)}}function ln(e){let t=R(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:on(t.conversation)},epoch:B(t.epoch),accessGeneration:N(t.accessGeneration,1),configRev:N(t.configRev,1),catalogId:B(t.catalogId)}}function un(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`version`,`selected`]);return{version:ln(t.version),selected:L(t.selected,ue)}}function dn(e){W(e);let t=R(e,[`expected`,`choice`]);return{expected:ln(t.expected),choice:K(t.choice)}}function fn(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,ce)),thinking:z(t.thinking,7,e=>{let t=R(e,[`level`,`selectable`]);return{level:F(t.level,le),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 pn(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 mn(e){W({kind:`ok`,value:e},O.pageBytes);let t=R(e,[`status`,`entries`,`withheld`,`remembered`]),n=z(t.entries,O.maxPageEntries,fn),r=L(t.remembered,K),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&&!pn(n,r))&&j(),{status:i,entries:n,withheld:a,remembered:r}}function hn(e){let{version:t,selected:n,...r}=R(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return W({kind:`ok`,value:e},O.pageBytes),{...mn(r),version:ln(t),selected:L(n,ue)}}function gn(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 _n(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 vn=[`registry`,`workbench`,`project`],yn=[`reboot`,`crash`,`restart`,`storage`],bn=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function xn(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,vn),path:t.path===null?null:M(t.path,4096,!0),cause:F(t.cause,yn),actions:z(t.actions,bn.length,e=>F(e,bn)),workers:N(t.workers,0,1e6),archived:P(t.archived)}}function Sn(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,gn),recoveries:z(t.recoveries,20,xn),build:et(t.build)}}var Cn=[`restart`,`upgrade`],wn=[`running`,`ready`,`failed`,`rolled-back`],Tn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],En=/^(?: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 Dn(e){let t=M(e,96,!0);if(!En.test(t))throw new A(`invalid`);return t}function On(e){let t=R(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:B(t.id),action:F(t.action,Cn),from:Dn(t.from),to:t.to===null?null:Dn(t.to),state:F(t.state,wn),reason:t.reason===null?null:F(t.reason,Tn),version:t.version===null?null:Dn(t.version),at:N(t.at,0),endedAt:t.endedAt===null?null:N(t.endedAt,0)}}var kn=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function An(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function jn(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:Dn(t.version),unit:n,upgrade:F(t.upgrade,kn),work:N(t.work,0,1e6),job:t.job===null?null:On(t.job)}}function Mn(e){let t=R(e,[`kind`,`version`,`deprecated`]);return{kind:I(t.kind,`release`),version:Dn(t.version),deprecated:P(t.deprecated)}}function Nn(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 Pn=Object.freeze({chunkChars:262144,idleMs:6e5}),Fn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function In(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 Ln(e,t){if(!Fn.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={"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"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":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,"Context {used} / {window} · {percent}%":`上下文 {used} / {window} · {percent}%`,"Context {used} tokens":`上下文 {used} tokens`,"Context unknown after compaction":`压缩后上下文大小未知`,"Context window in use":`上下文窗口占用`,"Context size as of the last completed model response ({model}). Messages after that response are not counted.":`上下文大小以最近一次完成的模型回复({model})为准,不包含那次回复之后的消息。`,"A compaction followed that response, so the size is unknown until the next one.":`那次回复之后做过压缩,下一次模型回复完成前无法得知大小。`,"The model list states no context window for this model, so no percentage is shown.":`模型列表没有给出这个模型的上下文窗口,因此不显示占比。`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files appear once this folder has been observed.":`读取到该目录的状态后即可浏览文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"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 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution 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":`等待批准计划`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.":`批准覆盖本目标及其决定、验收标准和假设。之后由服务自行完成:它可以在仓库内调整路线和写入范围;对验收的任何偏离都会记录下来,交给自动审查确认,并在最终报告中置顶。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Waiting messages":`等待中的消息`,"Steering: read at the model's next step":`插队:模型下一步就会读到`,"Queued: sent when this reply ends":`排队:这条回复结束后发送`,Withdraw:`撤回`,"Withdraw and put back in the message box":`撤回并放回输入框`,"Not delivered.":`未送达。`,"Not delivered: the reply ended before this message reached the model. Nothing was replayed; send it again.":`未送达:回复在这条消息到达模型之前就结束了。没有任何内容被重放;需要的话请重新发送。`,"Not observed: the session could not be read when the reply ended, so whether this message was delivered was not recorded. Nothing was replayed.":`未观察到:回复结束时会话无法读取,因此没有记录这条消息是否送达。没有任何内容被重放。`,"Put back in the message box":`放回输入框`,"Queue behind this reply":`排在这条回复之后`,"Queue: sent when this reply ends (Alt+Enter)":`排队:这条回复结束后发送(Alt+Enter)`,"Steer this reply":`插队到这条回复`,"Steer: read at the model's next step (Enter)":`插队:模型下一步就会读到(Enter)`,"Enter steers this reply · Alt+Enter queues behind it":`Enter 插队 · Alt+Enter 排队`,"The running reply did not take the message ({reason}). Your text stays here.":`进行中的回复没有接收这条消息({reason})。你的文字仍在输入框里。`,"That message has already been handed to the model and can no longer be withdrawn.":`这条消息已经交给模型,无法再撤回。`,"The message was not withdrawn ({reason}).":`消息没有撤回({reason})。`,"A message into a running reply carries no images. Remove them, or send after the reply ends.":`发给进行中回复的消息不能带图片。请移除图片,或等回复结束后再发送。`,"Cadence mode is not changed by a message into a running reply. Send this after the reply ends.":`发给进行中回复的消息不会切换 Cadence 模式。请等回复结束后再发送。`,"Eight messages already wait for this reply. Withdraw one, or wait.":`已有 8 条消息在等这条回复。请撤回一条,或稍等。`,"A message into a running reply continues that reply, not another entry.":`发给进行中回复的消息只能接在这条回复上,不能接到别的位置。`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"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 that could not be read is not shown.":`无法读取的思考内容不显示。`,"Show thinking":`展开思考内容`,"Thinking still being recorded":`思考内容仍在记录中`,"No thinking text is recorded for this block.":`这段思考没有记录文本。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Link copied.":`链接已复制。`,"Dismiss notification":`关闭通知`,"Theme: {current}. Switch to {next}.":`主题:{current}。点击切换为{next}。`,System:`跟随系统`,Light:`浅色`,Dark:`深色`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"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":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,superseded:`已被取代`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then 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})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},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-theme`,O=[`system`,`light`,`dark`],k=e=>e===`light`||e===`dark`;function A(){try{let e=localStorage.getItem(D);if(k(e))return e}catch{}return`system`}function ee(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function te(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return k(e)?e:`system`}function j(e){try{e===`system`?localStorage.removeItem(D):localStorage.setItem(D,e)}catch{}ee(e)}var ne=e=>O[(O.indexOf(e)+1)%O.length],re=`cadence-graph/2`,ie=`cadence-public-export/2`,M=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,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,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),ae=[`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`],N=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function oe(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 P(){throw new N}function F(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&P(),se(e)>t)throw new N(`oversize`);return e}function se(e){return new TextEncoder().encode(e).length}function I(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&P(),e}function L(e){return typeof e!=`boolean`&&P(),e}function R(e,t){return(typeof e!=`string`||!t.includes(e))&&P(),e}function z(e,t){return e!==t&&P(),t}function B(e,t){return e===null?null:t(e)}function V(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&P();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&P();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&P(),r[n]=t.value}return r}function H(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&P();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&P(),r.push(n(i.value))}return r}function U(e){let t=F(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)||P(),t}function W(e){let t=F(e,64);return/^[0-9a-f]{64}$/.test(t)||P(),t}function G(e){let t=F(e,M.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||P(),t}function K(e,t){return G(e),G(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ce(e){let t=F(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||P(),t}function q(e,t=M.controlBytes){let n=t,r=e=>{if(n-=se(e),n<0)throw new N(`oversize`);return e};function i(e,n){if(n>64&&P(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return F(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||P(),r(JSON.stringify(e));if(Array.isArray(e)){let a=H(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`)&&P();let a=t.sort(),o=V(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 P()}return i(e,0)}function le(e,t=M.controlBytes){F(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 F(JSON.parse(e.slice(r,n)),t)}catch{return P()}i=!i&&a===`\\`}return P()}function a(t){if(t>64&&P(),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]!==`"`&&P(),d=i(),u.has(d)&&P(),u.add(d),r(),e[n++]!==`:`&&P());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&P()}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||P(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&P(),s}let o=a(0);return r(),n!==e.length&&P(),o}function J(e){let t=V(e,[`code`,`effect`,`recovery`]);return{code:R(t.code,ae),effect:R(t.effect,[`none`,`accepted`,`uncertain`]),recovery:R(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ue=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],Y=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],de=[`not-launched`,`direct-child-closed`,`unconfirmed`],fe=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],pe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function me(e){let t=V(e,[`provider`,`model`,`api`,`thinking`]);return{provider:F(t.provider,128,!0),model:F(t.model,256,!0),api:R(t.api,fe),thinking:R(t.thinking,pe)}}function he(e){let{sourceSelectionId:t,...n}=V(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:U(t),...me(n)}}function ge(e){let t=V(e,[`role`,`sha256`]);return{role:R(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:W(t.sha256)}}function _e(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function ve(e){let t=V(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:U(t.recordId),version:I(t.version,1),field:R(t.field,ue),bytes:I(t.bytes,0,M.detailBytes),sha256:W(t.sha256)}}function ye(e){let t=V(e,[`start`,`end`]),n=I(t.start);return{start:n,end:I(t.end,n+1,M.detailBytes)}}function be(e){let t=V(e,[`source`,`range`,`requireCompleteObservation`]),n=xe(t.source),r;if(n===`current`)r={kind:n,assignmentId:ce(V(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=V(t.source,[`kind`,`runId`,`childRunId`,`result`]);z(n,`historical`);let i=ve(e.result);z(i.field,`final-text`),r={kind:`historical`,runId:U(e.runId),childRunId:U(e.childRunId),result:i}}let i=B(t.range,ye);return r.kind===`historical`&&i&&i.end>r.result.bytes&&P(),{source:r,range:i,requireCompleteObservation:L(t.requireCompleteObservation)}}function xe(e,t=`kind`){(typeof e!=`object`||!e)&&P();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&P(),F(n.value,64,!0)}function Se(e){q(e,M.graphBytes);let t=V(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=ve(t.plan);z(n.field,`plan`);let r=I(t.planRevision,1);n.version!==r&&P();let i={schema:z(t.schema,re),taskId:U(t.taskId),taskKind:R(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:I(t.taskRevision,1),revision:I(t.revision,1),planRevision:r,plan:n,assignments:H(t.assignments,M.assignments,e=>{let t=V(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ce(t.id),purpose:R(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:F(t.instructions,M.instructionsBytes,!0),expectedOutput:F(t.expectedOutput,M.expectedOutputBytes,!0),role:ge(t.role),model:he(t.model),dependencies:H(t.dependencies,M.assignments,be)}})};i.assignments.length||P();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&P();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&P(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=q(n.source);if(t.has(e)&&P(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||P(),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!==_e(e.purpose))throw new N(`forbidden`);c(e)}return i}function Ce(e){let t=V(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=B(t.graphRevision,e=>I(e,1)),r=B(t.graphIdentity,W);return n===null!=(r===null)&&P(),{id:U(t.id),kind:R(t.kind,[`code`,`research`,`diagnosis`]),revision:I(t.revision,1),identity:W(t.identity),graphRevision:n,graphIdentity:r}}function we(e){let t=V(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=V(t.observation,[`identity`,`complete`]);return{epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),configRev:I(t.configRev,1),controlRev:I(t.controlRev,1),workspaceId:U(t.workspaceId),cwdId:U(t.cwdId),model:he(t.model),checkEnvGeneration:I(t.checkEnvGeneration,1),checkoutGeneration:I(t.checkoutGeneration),observation:{identity:W(n.identity),complete:L(n.complete)},task:B(t.task,Ce)}}function Te(e){let t=V(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:R(t.kind,[`configured`,`manual`]),name:F(t.name,128,!0),command:F(t.command,4096,!0),timeoutMs:I(t.timeoutMs,100,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&P(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&P(),n}function Ee(e){switch(q(e),xe(e)){case`create`:{let t=V(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:R(t.taskKind,[`code`,`research`,`diagnosis`]),goal:F(t.goal,8192,!0)}}case`save-plan`:{let t=V(e,[`kind`,`taskId`,`plan`,`graph`]),n=Se(t.graph),r=U(t.taskId);return n.taskId!==r&&P(),{kind:`save-plan`,taskId:r,plan:F(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:xe(e),taskId:U(V(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=V(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:U(t.taskId),check:Te(t.check)}}case`review`:{let t=V(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:U(t.taskId),runId:U(t.runId),changesIdentity:W(t.changesIdentity),checksRevision:I(t.checksRevision),acceptIssues:L(t.acceptIssues)}}default:return P()}}function De(e){q(e);let t=V(e,[`expected`,`action`]);return{expected:we(t.expected),action:Ee(t.action)}}function Oe(e){q(e);let t=V(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:U(t.commandId),grant:U(t.grant),expected:we(t.expected),action:Ee(t.action)}}function ke(e){if(q(e),xe(e)===`action`){let t=V(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:we(t.expected),action:Ee(t.action)}}let t=V(e,[`kind`,`epoch`,`runId`]);return z(t.kind,`cancel`),{kind:`cancel`,epoch:U(t.epoch),runId:U(t.runId)}}function Ae(e){let t=V(e,[`commandId`,`epoch`,`runId`]);return{commandId:U(t.commandId),epoch:U(t.epoch),runId:U(t.runId)}}function je(e){q(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=V(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=H(n.configuredChecks,32,Te);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&P(),{...t?{checkEnvironmentPolicy:z(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:I(n.checksRevision),reviewRunId:B(n.reviewRunId,U),version:we(n.version),action:Ee(n.action),rootLabel:F(n.rootLabel,4096,!0),cwdLabel:F(n.cwdLabel,4096,!0),readablePlan:F(n.readablePlan,32768),graph:B(n.graph,Se),activeRunId:B(n.activeRunId,U),issues:H(n.issues,7,e=>R(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Me(e){q(e);let t=V(e,[`grant`,`expiresAt`,`preview`]),n=F(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)&&P(),{grant:U(t.grant),expiresAt:n,preview:je(t.preview)}}function Ne(e){let t=V(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:R(t.observed,[`complete`,`incomplete`]),source:R(t.source,[`complete`,`limited`,`unavailable`]),redacted:L(t.redacted),omissions:H(t.omissions,6,e=>R(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`))&&P(),n}function Pe(e){let t=V(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:I(t.graphRevision,1),inputs:H(t.inputs,M.assignments,e=>{let t=V(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=ve(t.result);z(i.field,`final-text`);let a=B(t.range,ye);a&&a.end>i.bytes&&P();let o=F(t.text,M.predecessorBytes);if(n+=se(o),n>M.handoffBytes)throw new N(`oversize`);let s=I(t.dependencyIndex,0,M.assignments-1);return r.has(s)&&P(),r.add(s),se(o)!==(a?a.end-a.start:i.bytes)&&P(),{assignmentId:ce(t.assignmentId),dependencyIndex:s,runId:U(t.runId),childRunId:U(t.childRunId),result:i,range:a,text:o,coverage:Ne(t.coverage)}})}}function Fe(e){let t=V(e,[`source`,`reason`,`target`]);return{source:R(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:F(t.reason,128,!0),target:F(t.target,128,!0)}}function Ie(e){let t=V(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Fe(t.stop)},outcome:R(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:R(t.closure,de),exitCode:B(t.exitCode,e=>I(e,-2147483648,4294967295)),signal:B(t.signal,e=>F(e,32,!0)),durationMs:I(t.durationMs),stdin:R(t.stdin,[`delivered`,`failed`,`not-required`]),final:R(t.final,[`valid`,`missing`,`invalid`]),cleanup:R(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Ne(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&P(),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`)&&P(),n}function Le(e){let t=V(e,[`kind`,`id`]);return{kind:R(t.kind,[`task`,`run`,`child`]),id:U(t.id)}}function Re(e){let t=F(e,M.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||P(),t}function ze(e){q(e);let t=V(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:U(t.storeId),scope:Le(t.scope),query:B(t.query,e=>{let t=F(e,M.queryBytes);return t.length||P(),t}),snapshotSeq:G(t.snapshotSeq),recordId:B(t.recordId,U),recordVersion:B(t.recordVersion,e=>I(e,1)),field:B(t.field,e=>R(e,ue)),offset:I(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&P(),n}function Be(e){let t=V(e,[`disposition`,`value`]),n=R(t.disposition,[`observed`,`unavailable`,`redacted`]),r=We(t.value);return n===`observed`!=(r!==null)&&P(),{disposition:n,value:r}}function Ve(e){let t=V(e,[`messageId`,`blockId`]);return{messageId:U(t.messageId),blockId:U(t.blockId)}}function X(e){let t=xe(e);if(t===`message-final`)return{kind:t,messageId:U(V(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:R(V(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=V(e,[`kind`,`dependencyIndex`,`source`]),r=ve(n.source);return z(r.field,`final-text`),{kind:t,dependencyIndex:I(n.dependencyIndex,0,M.assignments-1),source:r}}if(t===`message`){let n=V(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:U(n.messageId),blockId:U(n.blockId),index:I(n.index,0,M.dataFrames),stage:R(n.stage,[`stream`,`final`])}}let n=V(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return z(t,`tool`),{kind:`tool`,callId:U(n.callId),blockId:U(n.blockId),index:I(n.index,0,M.dataFrames),stage:R(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function He(e){let t=V(e,[`owner`,`field`,`encoding`]),n=X(t.owner),r=R(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=R(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`))&&P(),{owner:n,field:r,encoding:i}}function Ue(e){let t=V(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=R(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=R(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=B(t.mimeType,e=>F(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)))&&P(),{owner:X(t.owner),sourceType:n,mimeType:i,reason:r}}function We(e){if(e===null)return null;let t=F(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||P(),t}function Ge(e){let t=V(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`]),n=I(t.maxAttempts,1),r={phase:R(t.phase,[`waiting`,`requesting`]),attempt:I(t.attempt,1,n),maxAttempts:n,delayMs:I(t.delayMs,0,2147483647)};if(r.phase===`requesting`&&r.delayMs!==0)throw new N(`invalid`);return r}function Ke(e){let t=xe(e);switch(t){case`ready`:{let n=V(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:z(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=V(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:F(e.sdkVersion,128,!0),workerHash:W(e.workerHash)}})()}}}case`message-start`:{let n=V(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=R(n.role,[`user`,`assistant`,`tool-result`]),i=B(n.resultCallId,U);return r!==`tool-result`&&i!==null&&P(),{kind:t,messageId:U(n.messageId),role:r,source:Be(n.source),resultCallId:i}}case`message-text`:{let n=V(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...Ve({messageId:n.messageId,blockId:n.blockId}),detailId:U(n.detailId)}}case`message-end`:{let n=V(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:U(n.messageId),finalDetailId:B(n.finalDetailId,U),finalBlockCount:I(n.finalBlockCount,0,M.dataFrames),stopReason:R(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=V(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:U(n.callId),declaration:Ve(n.declaration),index:I(n.index,0,M.dataFrames),source:Be(n.source),name:F(n.name,128,!0),argsDetailId:B(n.argsDetailId,U),stage:R(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=V(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:U(n.callId),declaration:B(n.declaration,Ve),source:Be(n.source),name:F(n.name,128,!0),argsDetailId:B(n.argsDetailId,U)}}case`tool-update`:{let n=V(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:U(n.callId),detailId:U(n.detailId),semantics:z(n.semantics,`snapshot`)}}case`tool-end`:{let n=V(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=R(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=B(n.declaration,Ve),a=L(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&P(),{kind:t,callId:U(n.callId),declaration:i,source:Be(n.source),name:F(n.name,128,!0),resultDetailId:U(n.resultDetailId),isError:L(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Ue(V(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=V(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:U(n.detailId),descriptor:He(n.descriptor)}}case`detail-chunk`:{let n=V(e,[`kind`,`detailId`,`offset`,`text`]),r=F(n.text,M.chunkBytes),i=I(n.offset,0,M.detailBytes);return i+se(r)>M.detailBytes&&P(),{kind:t,detailId:U(n.detailId),offset:i,text:r}}case`detail-end`:{let n=V(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:U(n.detailId),bytes:I(n.bytes,0,M.detailBytes),sha256:W(n.sha256),coverage:Ne(n.coverage)}}case`model-retry`:return{kind:t,progress:B(V(e,[`kind`,`progress`]).progress,Ge)};case`capture-status`:return{kind:t,coverage:Ne(V(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:R(V(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=V(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:U(n.messageId),detailId:U(n.detailId),stopReason:z(n.stopReason,`stop`)}}default:return P()}}function qe(e){let t=V(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Fe(t.stop)},outcome:R(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:R(t.closure,de),exitCode:B(t.exitCode,e=>I(e,-2147483648,4294967295)),signal:B(t.signal,e=>F(e,32,!0)),durationMs:I(t.durationMs),stdin:z(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))&&P(),n}function Je(e){let t=V(e,[`messageId`,`detailId`]);return{messageId:U(t.messageId),detailId:U(t.detailId)}}function Ye(e){let t=V(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=G(t.committedSeq);return n===`0`&&P(),{childRunId:U(t.childRunId),detailId:U(t.detailId),content:ve(t.content),committedSeq:n}}function Xe(e){let t=xe(e,`status`);if(t===`committed`){let n=V(e,[`status`,`selected`,`detail`]),r=Je(n.selected),i=Ye(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&P(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=V(e,[`status`,`selected`,`error`]);return{status:t,selected:B(n.selected,Je),error:J(n.error)}}let n=V(e,[`status`,`selected`]);return{status:R(t,[`pending`,`uncertain`]),selected:B(n.selected,Je)}}function Ze(e,t){let n=B(e,G);return(n===`0`||n!==null&&t.status===`committed`&&K(n,t.detail.committedSeq)<0)&&P(),n}function Qe(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function $e(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Qe(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function et(e){let t=xe(e);if(t===`sdk`){let n=V(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Xe(n.recording),i=Ze(n.settlementSeq,r);return{kind:t,native:Ie(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=V(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=B(n.settlementSeq,G);return r===`0`&&P(),{kind:t,native:qe(n.native),capture:Ne(n.capture),settlementSeq:r}}let n=V(e,[`kind`,`outcome`,`required`]);z(t,`parent`);let r=H(n.required,M.assignments,e=>{let t=V(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=U(t.childRunId),r=Xe(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&P(),{assignmentId:ce(t.assignmentId),childRunId:n,native:B(t.native,Ie),recording:r,settlementSeq:Ze(t.settlementSeq,r)}}),i=R(n.outcome,Y);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(Qe))&&P(),{kind:`parent`,outcome:i,required:r}}function tt(e){let t=V(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=I(t.first,1,2**53-1),r=I(t.last,n,2**53-1),i=I(t.firstObservedMs),a=I(t.lastObservedMs,i);return n===r&&i!==a&&P(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function nt(e){let t=V(e,[`source`,`event`]),n=tt(t.source),r=xe(t.event);if(r===`stored-chunk`){let e=V(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:U(e.detailId),text:F(e.text,M.chunkBytes)}}}if(r===`stored-end`){let e=V(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:U(e.detailId),coverage:Ne(e.coverage)}}}let i=Ke(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&P(),{source:n,event:i}}function rt(e){let t=V(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:U(t.epoch),taskId:U(t.taskId),runId:U(t.runId),childRunId:U(t.childRunId)}}function it(e){q({kind:`ok`,value:e},M.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=V(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:U(n.storeId),workspaceId:U(n.workspaceId),epoch:U(n.epoch)};if(!t)return z(n.status,`unavailable`),{...r,status:`unavailable`,error:at(n.error)};let i=H(n.runs,M.episodes,e=>{let t=V(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:U(t.taskId),runId:U(t.runId),operationId:U(t.operationId),epoch:U(t.epoch),kind:R(t.kind,[`start`,`generate-plan`,`check`]),stage:R(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)&&P(),{...r,status:`complete`,runs:i}}function at(e){let t=J(e);return z(t.effect,`none`),t}function ot(e){let t=V(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:W(t.sourceHash),contractHash:W(t.contractHash),buildId:W(t.buildId)}}function st(e){let t=R(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=V(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:W(n.contractHash)}:{kind:t,...ot({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function ct(e){let t=V(e,[`contractHash`,`assets`]);return{contractHash:W(t.contractHash),assets:ot(t.assets)}}function lt(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 ut(e){q(e);let t=V(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:U(t.commandId),operationId:U(t.operationId),runId:B(t.runId,U),admission:R(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:G(t.committedSeq),execution:B(t.execution,e=>R(e,Y)),settlement:B(t.settlement,et),created:B(t.created,e=>{let t=V(e,[`kind`,`taskId`,`state`]);return{kind:z(t.kind,`task`),taskId:U(t.taskId),state:R(t.state,[`reserved`,`published`])}}),publication:R(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&&$e(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&P(),n}function dt(e){q(e);let t=V(e,[`identity`,`receipt`]),n=ke(t.identity),r=ut(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&P();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&P(),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`))&&P()}return{identity:n,receipt:r}}function Z(e,t){if(xe(e)===`ok`)return{kind:`ok`,value:t(V(e,[`kind`,`value`]).value)};let n=V(e,[`kind`,`error`]);return z(n.kind,`error`),{kind:`error`,error:J(n.error)}}function ft(e){switch(q(e),xe(e,`status`)){case`found`:return{status:`found`,receipt:ut(V(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:G(V(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:J(V(e,[`status`,`error`]).error)};default:return P()}}function pt(e){let t=V(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:U(t.runId),taskId:U(t.taskId),childRunId:B(t.childRunId,U),assignmentId:B(t.assignmentId,ce),admission:Ct(t.admission),lifecycle:R(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:B(t.outcome,e=>R(e,Y)),settlement:B(t.settlement,et),reason:B(t.reason,e=>R(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:R(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Ne(t.coverage),result:B(t.result,ve)};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`&&q(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==q(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&q(n.result)!==q(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&&$e(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||$e(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&P(),n}function mt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function ht(e,t,n){return mt(e,t)&&e.taskId===Et(n)&&e.admission.context.workspaceId===Tt(n)}function gt(e){q(e,M.pageBytes);let t=V(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:z(t.protocol,1),storeId:U(t.storeId),epoch:U(t.epoch),scope:Le(t.scope),committedSeq:G(t.committedSeq),context:wt(t.context),runs:H(t.runs,M.maxPageEntries,pt),horizon:Rt(t.horizon)};return(!Dt(n.context,n.epoch,n.scope)||q(n.horizon.historicalRuns.scope)!==q(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!ht(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&P(),n}function _t(e){q(e,M.pageBytes);let t=xe(e),n=V(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:U(n.storeId),epoch:U(n.epoch),scope:Le(n.scope),committedSeq:G(n.committedSeq)};if(t===`update`){let e=G(n.previousSeq);K(r.committedSeq,e)<=0&&P();let i=wt(n.context);Dt(i,r.epoch,r.scope)||P();let a=H(n.runs,M.maxPageEntries,pt),o=H(n.removed,M.maxPageEntries,U),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!ht(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&P(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return z(t,`heartbeat`),{kind:`heartbeat`,...r}}function vt(e){let{navigation:t,...n}=e;return n}function yt(e,t){(!t.navigation||t.navigation===e.navigation||q(vt(e))!==q(vt(t)))&&P()}function bt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return xt(e);q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`kind`,`cursor`,`next`,`coverage`]),n=ze(t.cursor),r=ze(t.next);return yt(n,r),{kind:`progress`,cursor:n,next:r,coverage:Ne(t.coverage)}}function xt(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ze(t.cursor),content:ve(t.content),range:B(t.range,ye),text:F(t.text,M.detailPageBytes),next:B(t.next,ze),coverage:Ne(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!==se(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&P(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&P(),n.next&&(n.next.offset!==n.range?.end||q(vt({...n.next,offset:n.cursor.offset}))!==q(vt(n.cursor)))&&P(),n}function St(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`cursor`,`hits`,`next`,`coverage`]),n=ze(t.cursor);n.query||P();let r=se(n.query),i=H(t.hits,M.maxPageEntries,e=>{let t=V(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=ve(t.content),a=At(t.owner);jt(a,n.scope)||P();let o=ye(t.range),s=ze(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||q(s.scope)!==q(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&P(),{content:i,owner:a,range:o,preview:F(t.preview,M.previewBytes),cursor:s}}),a=B(t.next,ze);return a&&(a.storeId!==n.storeId||q(a.scope)!==q(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)))&&P(),{cursor:n,hits:i,next:a,coverage:Ne(t.coverage)}}function Ct(e){let t=V(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=we(t.context),r=B(t.graph,e=>{let t=V(e,[`recordId`,`revision`,`sha256`]);return{recordId:U(t.recordId),revision:I(t.revision,1),sha256:W(t.sha256)}}),i=R(t.kind,[`start`,`generate-plan`,`check`]),a=H(t.assignments,M.assignments,e=>{let t=V(e,[`assignmentId`,`childRunId`]);return{assignmentId:ce(t.assignmentId),childRunId:U(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)&&P(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&P(),{operationId:U(t.operationId),commandId:U(t.commandId),kind:i,context:n,assignments:a,graph:r}}function wt(e){if(xe(e,`status`)===`available`)return{status:`available`,version:we(V(e,[`status`,`version`]).version)};let t=V(e,[`status`,`workspaceId`,`taskId`,`error`]);z(t.status,`unavailable`);let n=J(t.error);return z(n.effect,`none`),{status:`unavailable`,workspaceId:U(t.workspaceId),taskId:B(t.taskId,U),error:n}}function Tt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Et(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Dt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Et(e)===n.id)}function Ot(e){let t=V(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=V(t.capabilities,[`actions`,`manualChecks`,`history`]),r=R(t.authority,[`browser`,`local`]),i=B(t.csrf,U),a={actions:L(n.actions),manualChecks:L(n.manualChecks),history:L(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&P(),{...t.build===void 0?{}:{build:ct(t.build)},protocol:z(t.protocol,1),storeId:U(t.storeId),epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function kt(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:it(t.activeRuns)},workspaceId:U(t.workspaceId),storeId:U(t.storeId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),rootLabel:F(t.rootLabel,4096,!0),context:wt(t.context),models:H(t.models,M.maxPageEntries,he)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&P(),(Tt(n.context)!==n.workspaceId||Et(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&P(),n}function At(e){let t=V(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=V(t.entity,[`kind`,`id`,`version`]),r={taskId:U(t.taskId),runId:B(t.runId,U),childRunId:B(t.childRunId,U),entity:{kind:R(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:U(n.id),version:I(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)&&P(),r}function jt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Mt(e){let t=V(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:W(t.identity),complete:L(t.complete),checkoutGeneration:I(t.checkoutGeneration)}}function Nt(e){q(e,M.controlBytes);let t=xe(e);switch(t){case`assignment-state`:{let n=V(e,[`kind`,`childRunId`,`state`,`reason`]),r=R(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=B(n.reason,e=>R(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&P(),(r===`ready`||r===`preparing`)&&i!==null&&P(),{kind:t,childRunId:U(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:R(V(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=V(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:U(n.runId),identity:Ct(n.identity)}}case`parent-settled`:{let n=V(e,[`kind`,`runId`,`settlement`]),r=et(n.settlement);return r.kind!==`parent`&&P(),{kind:t,runId:U(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=V(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:U(r.reservationId)}:{},lane:R(r.lane,[`reader`,`writer`,`check`]),state:R(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:I(r.checkoutGeneration)}}case`handoff`:{let n=V(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:U(n.childRunId),handoff:Pe(n.handoff),observation:Mt(n.observation)}}case`changes`:{let n=V(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=ve(n.content);return z(r.field,`changes`),{kind:t,observationId:U(n.observationId),stage:R(n.stage,[`before`,`after`,`review`]),observation:Mt(n.observation),content:r}}case`check-start`:{let n=V(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:U(n.checkId),selection:Te(n.selection),cwdId:U(n.cwdId),cwdLabel:F(n.cwdLabel,4096,!0),checkEnvGeneration:I(n.checkEnvGeneration,1),before:Mt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=V(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=V(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:U(e.operationId),reservationId:U(e.reservationId),from:I(e.from),to:I(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&P()}let a=qe(r.native),o=R(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=Mt(r.before),c=Mt(r.after),l=B(r.output,ve),u=Ne(r.coverage);return l&&l.field!==`check`&&P(),o===`passed`&&(a.outcome!==`completed`||q({...s,checkoutGeneration:c.checkoutGeneration})!==q(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&P(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&P(),{kind:t,...i?{ownAdvance:i}:{},checkId:U(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=V(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=L(n.acceptIssues),i=R(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=ve(n.content);return z(a.field,`review`),i===`reviewed-with-issues`&&!r&&P(),{kind:t,reviewId:U(n.reviewId),runId:U(n.runId),checksRevision:I(n.checksRevision),changesIdentity:W(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=V(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=I(n.expectedRevision),i=B(n.expectedIdentity,W),a=I(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&P(),{kind:t,publicationId:U(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:W(n.nextIdentity)}}case`publication-settled`:{let n=V(e,[`kind`,`publicationId`,`status`,`observed`]),r=R(n.status,[`published`,`conflict`,`uncertain`]),i=B(n.observed,e=>{let t=V(e,[`revision`,`identity`]);return{revision:I(t.revision,1),identity:W(t.identity)}});return r===`published`&&i===null&&P(),{kind:t,publicationId:U(n.publicationId),status:r,observed:i}}default:return P()}}function Pt(e){let t=V(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:U(t.epoch),operationId:U(t.operationId),taskId:U(t.taskId),runId:B(t.runId,U)}}function Ft(e){q(e,M.ownerQueueBytes);let t=V(e,[`observedMs`,`link`,`events`]),n=Pt(t.link),r=H(t.events,M.ownerQueueFrames,e=>{let t=xe(e);if(t===`fact`){let r=Nt(V(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)&&P(),{kind:t,fact:r}}if(t===`content-begin`){let r=V(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=At(r.owner),a=R(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))&&P(),{kind:t,detailId:U(r.detailId),owner:i,field:a,encoding:z(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=V(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:U(n.detailId),text:F(n.text,M.chunkBytes)}}let r=V(e,[`kind`,`detailId`,`coverage`]);return z(t,`content-end`),{kind:`content-end`,detailId:U(r.detailId),coverage:Ne(r.coverage)}});return{observedMs:I(t.observedMs),link:n,events:r}}var It=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Lt(e){let t=V(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=R(t.reader,It),r=V(t.scope,[`kind`,`id`]),i={kind:R(r.kind,[`workspace`,`task`,`run`,`child`]),id:U(r.id)},a=B(t.snapshotSeq,G),o=B(t.after,e=>{let t=V(e,[`recordId`,`version`,`offset`]);return{recordId:U(t.recordId),version:I(t.version,1),offset:I(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&P(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:U(t.storeId),scope:i,snapshotSeq:a,after:o,limit:I(t.limit,1,M.maxPageEntries)}}function Rt(e){let t=V(e,[`policy`,`historicalRuns`]),n=Lt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&P(),{policy:z(t.policy,`active-and-recent`),historicalRuns:n}}function zt(e){let t=xe(e);if(t===`run`)return{kind:t,projection:pt(V(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=V(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=G(n.committedSeq);return r===`0`&&P(),{kind:t,recordId:U(n.recordId),committedSeq:r,link:rt(n.link),capture:nt(n.capture)}}if(t===`owner-fact`){let n=V(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Ft({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&P();let a=G(n.committedSeq);return a===`0`&&P(),{kind:t,recordId:U(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=V(e,[...n,...r]),a=At(i.owner),o=I(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&P(),t===`task`){let e=B(i.plan,ve);return e&&e.field!==`plan`&&P(),{kind:t,owner:a,version:o,goal:F(i.goal,8192,!0),plan:e}}if(t===`message`){let e=R(i.role,[`user`,`assistant`,`tool-result`]),n=R(i.state,[`partial`,`final`]),r=B(i.finalBlockCount,e=>I(e,0,M.dataFrames)),s=B(i.finalText,ve),c=B(i.resultCallId,U);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&P(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Be(i.source)}}if(t===`tool`){let e=B(i.declaration,Ve),n=B(i.declarationStage,e=>R(e,[`partial`,`final`])),r=L(i.startObserved),s=B(i.result,e=>{let t=Ke(e);return t.kind!==`tool-end`&&P(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||q(s.declaration)!==q(e)))&&P(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Be(i.source),name:F(i.name,128,!0)}}if(t===`content`){let e=He(i.descriptor),n=ve(i.content);return(e.field!==n.field||!Bt(e.owner,a))&&P(),{kind:t,owner:a,version:o,detailId:U(i.detailId),descriptor:e,content:n,coverage:Ne(i.coverage)}}z(t,`omitted`);let s=Ue(i.block);return Bt(s.owner,a)||P(),{kind:`omitted`,owner:a,version:o,block:s}}function Bt(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 Vt(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 Ht(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`request`,`records`,`next`,`coverage`]),n=Lt(t.request);n.snapshotSeq===null&&P();let r=H(t.records,n.limit,zt),i=B(t.next,Lt);return(r.some(e=>!Vt(e,n))||i&&(i.after===null||q(vt({...i,after:n.after}))!==q(vt(n))||q(i.after)===q(n.after)))&&P(),{request:n,records:r,next:i,coverage:Ne(t.coverage)}}function Ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||q(vt({...r,snapshotSeq:null}))!==q(vt(n)))&&P(),{kind:`snapshot`,request:n,next:r,coverage:Ne(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ht(e);q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}function Wt(e,t){return q({...t.request,snapshotSeq:e.snapshotSeq})===q(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Gt(e){let t=V(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=V(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:U(t.storeId),scope:Le(t.scope),snapshotSeq:G(t.snapshotSeq),graph:{recordId:U(n.recordId),revision:I(n.revision,1),sha256:W(n.sha256)}}}function Kt(e){q({kind:`ok`,value:e});let t=V(e,[`request`,`graph`]),n=Gt(t.request),r=Se(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&P(),{request:n,graph:r}}function qt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Kt(e);q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`kind`,`request`,`next`,`coverage`]),n=Gt(t.request),r=Gt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}function Jt(e){let t=V(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:U(t.storeId),scope:Le(t.scope),snapshotSeq:G(t.snapshotSeq),format:R(t.format,[`ndjson`,`markdown`])}}function Yt(e){q(e,M.controlBytes);let t=V(e,[`exportId`,`ordinal`,`event`]),n=xe(t.event),r;switch(n){case`manifest`:{let e=V(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=V(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:W(i.exporterBuildSha256),capturePolicy:z(i.capturePolicy,`public-text-tools/2`)},schema:z(e.schema,ie),request:Jt(e.request),coverage:Ne(e.coverage),serviceProtocol:z(e.serviceProtocol,1),workerProtocol:z(e.workerProtocol,2)};break}case`record`:r={kind:n,record:zt(V(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Kt(V(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=V(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=ve(e.content),a=B(e.range,ye),o=F(e.text,M.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==se(o):i.bytes!==0||o!==``)&&P(),r={kind:n,owner:At(e.owner),content:i,range:a,text:o,coverage:Ne(e.coverage)};break}case`markdown`:r={kind:n,text:F(V(t.event,[`kind`,`text`]).text,M.detailPageBytes)};break;case`trailer`:{let e=V(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Ne(e.coverage),a=L(e.complete);a&&i.observed!==`complete`&&P(),r={kind:n,complete:a,frames:I(e.frames,1),encodedBytes:I(e.encodedBytes),sha256:W(e.sha256),committedSeq:G(e.committedSeq),coverage:i};break}default:return P()}return{exportId:U(t.exportId),ordinal:I(t.ordinal,1),event:r}}function Xt(e,t){let n=Yt(e);return t===`ndjson`?`${q(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&P(),`\n\n\`\`\`json\n${q(n)}\n\`\`\`\n`)}var Zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Jt(e)}receive(e){let t=Yt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&P(),this.ordinal===0?(n.kind!==`manifest`||q(n.request)!==q(this.request))&&P():n.kind===`manifest`&&P(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&P(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&P(),this.request.format===`ndjson`&&n.kind===`markdown`&&P(),n.kind===`detail`&&!jt(n.owner,this.request.scope)&&P(),n.kind===`graph`&&(q(n.graph.request.scope)!==q(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&P(),n.kind===`record`&&!Qt(n.record,this.request.scope)&&P(),this.bytes+=se(Xt(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 Qt(e,t){return e.kind===`run`?mt(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:jt(e.owner,t)}function $t(e){let t=V(e,[`taskId`,`revision`,`definitions`]),n=H(t.definitions,32,e=>{let t=V(e,[`selection`,`status`,`checkId`]),n=Te(t.selection),r=R(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=B(t.checkId,U);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&P(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&P(),{taskId:U(t.taskId),revision:I(t.revision),definitions:n}}function en(e){let t=V(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:U(t.storeId),scope:Le(t.scope),snapshotSeq:G(t.snapshotSeq),kind:R(t.kind,[`task`,`message`,`tool`]),id:U(t.id),version:I(t.version,1)}}function tn(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`request`,`record`]),n=en(t.request),r=zt(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||!jt(r.owner,n.scope))&&P(),{request:n,record:r}}function nn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return tn(e);q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`kind`,`request`,`next`,`coverage`]),n=en(t.request),r=en(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}var rn=e=>{let t=J(e);return z(t.effect,`none`),t};function an(e){let t=V(e,[`storeId`,`taskId`]);return{storeId:U(t.storeId),taskId:B(t.taskId,U)}}function on(e){let t=an(e);return t.taskId===null&&P(),t}function sn(e){let t=V(e,[`id`,`kind`,`revision`,`identity`]);return{id:U(t.id),kind:R(t.kind,[`code`,`research`,`diagnosis`]),revision:I(t.revision,1),identity:W(t.identity)}}function cn(e){let t=H(e,3,ge);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&P(),t}function ln(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return V(e,[`status`]),{status:t};if(t===`saved`){let n=V(e,[`status`,`request`,`planRevision`]);return{status:t,request:Gt(n.request),planRevision:I(n.planRevision,1)}}let n=V(e,[`status`,`error`]);return z(n.status,`unavailable`),{status:`unavailable`,error:rn(n.error)}}function un(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Tt(e.context)!==e.workspaceId||Et(e.context)!==e.request.taskId)&&P(),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))&&P()}}function dn(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:an(t.request),workspaceId:U(t.workspaceId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),context:wt(t.context),task:B(t.task,sn),roles:cn(t.roles),savedGraph:ln(t.savedGraph),readablePlan:B(t.readablePlan,e=>{let t=V(e,[`source`,`text`,`editable`,`coverage`]),n=Ne(t.coverage),r=L(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&P(),{source:z(t.source,`current-v1`),text:F(t.text,32768),editable:r,coverage:n}})};un(n),!!n.task!=!!n.readablePlan&&P();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))&&P(),r.status===`unavailable`&&n.context.status===`available`&&P(),n}function fn(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=V(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:on(t.request),workspaceId:U(t.workspaceId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),context:wt(t.context),task:sn(t.task),observation:{identity:W(n.identity),complete:L(n.complete),checkoutGeneration:I(n.checkoutGeneration,0)},text:F(t.text,131072),git:L(t.git),coverage:Ne(t.coverage)};if(un(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)&&P()}return r}function pn(e){let t=F(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||P(),t}function mn(e){let t=V(e,[`id`,`cwd`]);return{id:pn(t.id),cwd:F(t.cwd,4096,!0)}}function hn(e){let t=V(e,[`id`,`cwd`,`revision`,`model`]);return{id:pn(t.id),cwd:F(t.cwd,4096,!0),revision:I(t.revision,0,2**53-1-1),model:B(t.model,me)}}function gn(e){let t=V(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:F(t.cwd,4096,!0),checkoutRoot:F(t.checkoutRoot,4096,!0),version:_n(t.version),model:B(t.model,he)}}function _n(e){let t=V(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:mn(t.conversation)},epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),configRev:I(t.configRev,1),catalogId:U(t.catalogId)}}function vn(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`version`,`selected`]);return{version:_n(t.version),selected:B(t.selected,he)}}function yn(e){q(e);let t=V(e,[`expected`,`choice`]);return{expected:_n(t.expected),choice:me(t.choice)}}function bn(e){let t=V(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:L(t.images)},...t.contextWindow===void 0?{}:{contextWindow:I(t.contextWindow,1)},provider:F(t.provider,128,!0),model:F(t.model,256,!0),api:B(t.api,e=>R(e,fe)),thinking:H(t.thinking,7,e=>{let t=V(e,[`level`,`selectable`]);return{level:R(t.level,pe),selectable:L(t.selectable)}}),eligibility:R(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))&&P(),n}function xn(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 Sn(e){q({kind:`ok`,value:e},M.pageBytes);let t=V(e,[`status`,`entries`,`withheld`,`remembered`]),n=H(t.entries,M.maxPageEntries,bn),r=B(t.remembered,me),i=R(t.status,[`complete`,`capacity`]),a=I(t.withheld,0,M.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>M.maxPageEntries||new Set(n.map(e=>q([e.provider,e.model]))).size!==n.length||r&&!xn(n,r))&&P(),{status:i,entries:n,withheld:a,remembered:r}}function Cn(e){let{version:t,selected:n,...r}=V(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return q({kind:`ok`,value:e},M.pageBytes),{...Sn(r),version:_n(t),selected:B(n,he)}}function wn(e){let t=V(e,[`id`,`path`,`cwd`,`epoch`]);return{id:W(t.id),path:F(t.path,4096,!0),cwd:F(t.cwd,4096,!0),epoch:t.epoch===null?null:U(t.epoch)}}function Tn(e){let t=V(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:z(t.kind,`project-observation`),status:R(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:U(t.epoch),workspaceId:t.workspaceId===null?null:U(t.workspaceId)}}var En=[`registry`,`workbench`,`project`],Dn=[`reboot`,`crash`,`restart`,`storage`],On=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function kn(e){let t=V(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:U(t.id),at:I(t.at,0),scope:R(t.scope,En),path:t.path===null?null:F(t.path,4096,!0),cause:R(t.cause,Dn),actions:H(t.actions,On.length,e=>R(e,On)),workers:I(t.workers,0,1e6),archived:L(t.archived)}}function An(e){let t=V(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:z(t.kind,`workbench`),epoch:U(t.epoch),csrf:U(t.csrf),home:F(t.home,4096,!0),projects:H(t.projects,128,wn),recoveries:H(t.recoveries,20,kn),build:ct(t.build)}}var jn=[`restart`,`upgrade`],Mn=[`running`,`ready`,`failed`,`rolled-back`],Nn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Pn=/^(?: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 Fn(e){let t=F(e,96,!0);if(!Pn.test(t))throw new N(`invalid`);return t}function In(e){let t=V(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:U(t.id),action:R(t.action,jn),from:Fn(t.from),to:t.to===null?null:Fn(t.to),state:R(t.state,Mn),reason:t.reason===null?null:R(t.reason,Nn),version:t.version===null?null:Fn(t.version),at:I(t.at,0),endedAt:t.endedAt===null?null:I(t.endedAt,0)}}var Ln=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Rn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function zn(e){let t=V(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=V(t.unit,[`name`,`scope`]);n={name:F(e.name,96,!0),scope:R(e.scope,[`user`,`system`])}}return{kind:z(t.kind,`service`),version:Fn(t.version),unit:n,upgrade:R(t.upgrade,Ln),work:I(t.work,0,1e6),job:t.job===null?null:In(t.job)}}function Bn(e){let t=V(e,[`kind`,`version`,`deprecated`]);return{kind:z(t.kind,`release`),version:Fn(t.version),deprecated:L(t.deprecated)}}function Vn(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 Hn=Object.freeze({chunkChars:262144,idleMs:6e5}),Un=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Wn(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 Gn(e,t){if(!Un.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
|
|
4
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return s}function Kn(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function qn(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 Jn(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 Yn(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 Xn(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 Zn(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:Xn(n.checkoutRoot),repository:Xn(n.repository),repositoryIdentity:V(n.repositoryIdentity),branch:Yn(n.branch),head:Jn(n.head)}}}function Qn(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,Rn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Jn(t.candidate),tree:Jn(t.tree),planDigest:V(t.planDigest),contextDigest:V(t.contextDigest),checks:n,review:i(t.review)}}),o=L(t.candidate,Jn);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=L(t.workspace,e=>{let t=R(e,[`head`,`state`]);return{head:Jn(t.head),state:F(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=Zn(t.binding),l=Yn(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:Xn(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:Jn(n.before),after:L(n.after,Jn),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 $n(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 er(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:Zn(n.delivery)},id:B(n.id),epoch:B(n.epoch),digest:V(n.digest),observation:V(n.observation),model:ln(n.model),plan:Gn(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`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:M(e.runtime,4096,!0)},model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function tr(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,Rn.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:ln(n.model)}}if(t===`propose`){let n=R(e,[`action`,`plan`,`model`]);return{action:t,plan:Gn(n.plan),model:ln(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 nr(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:Qn(t.delivery)},...t.execution===void 0?{}:{execution:cn(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:sr(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:or(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 rr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:nr(R(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:er(R(e,[`type`,`proposal`]).proposal)};let n=R(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:F(n.type,[`grant`]),proposal:er(n.proposal),grant:B(n.grant),expiresAt:N(n.expiresAt,0)}}function ir(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${Un(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
|
|
3
|
+
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Kn={tasks:16,route:48,questions:8,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4},qn=[`queued`,`running`,`completed`,`failed`,`superseded`];function Jn(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Yn(e,t=!1){let n=F(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 Xn=(e,t=!1)=>{let n=F(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function Zn(e){let t=V(e,[`name`,`command`,...Object.hasOwn(e??{},`timeoutMs`)?[`timeoutMs`]:[]]);return{name:F(t.name,128,!0),command:F(t.command,4096,!0),...t.timeoutMs===void 0?{}:{timeoutMs:I(t.timeoutMs,100,2147483647)}}}function Qn(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 $n(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 Qn(e),r(t),Qn(e).filter(e=>n.has(e.id))}function er(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`);q(e,Kn.bytes);let i=r?e.version:void 0;if(r&&i!==2&&i!==3)throw Error(`Unsupported delivery agreement version`);let a=i===3;if(n&&!a)throw Error(`Publish a new delivery agreement; earlier agreements are readonly`);let o=V(e,[`goal`,`design`,`decisions`,`acceptance`,...a?[`version`,`assumptions`,`documents`,`reviewReads`,`policy`]:r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),s=e=>H(e,16,e=>{let t=Yn(e,n);if(!t.endsWith(`.md`))throw Error(`Documentation targets must be Markdown files`);return t}),c=H(o.tasks,Kn.tasks,e=>{let t=V(e,[`id`,`title`,`instructions`,`writes`,`after`,...a?[`reads`]:[]]);return{id:Xn(t.id,n),title:F(t.title,256,!0),instructions:F(t.instructions,8192,!0),writes:H(t.writes,128,e=>Yn(e,n)),after:H(t.after,Kn.tasks,e=>Xn(e,n)),...a?{reads:rr(t.reads,n)}:{}}});if(!c.length||c.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`);Qn(c);for(let e of r?[]:c)for(let t of c)if(!(e.id>=t.id||$n(c,e.id).some(e=>e.id===t.id)||$n(c,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>Jn(t.writes,e))||t.writes.some(t=>Jn(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let l=H(o.checks,Kn.checks,Zn);if(!l.length)throw Error(`At least one real verification command is required`);let u={goal:F(o.goal,8192,!0),design:F(o.design,32768,!0),decisions:F(o.decisions,16384),acceptance:F(o.acceptance,16384,!0),...a?{version:3,assumptions:F(o.assumptions,16384),documents:s(o.documents),reviewReads:rr(o.reviewReads,n),policy:{installs:L(V(o.policy,[`installs`]).installs)}}:r?{version:2,knowledge:s(o.knowledge)}:{projectContext:F(o.projectContext,16384),repairAttempts:I(o.repairAttempts,0,2)},tasks:c,checks:l,setup:H(o.setup,4,Zn),baselineChecks:H(o.baselineChecks,Kn.checks,Zn),delivery:R(o.delivery,[`local-merge`,`working-copy`])};ir(u),F(nr(u).join(`, `),16384);for(let e of[u.goal,u.design,u.decisions,u.acceptance,u.assumptions??``,u.projectContext??``,...[...u.reviewReads??[],...u.tasks.flatMap(e=>e.reads??[])].flatMap(e=>[e.reason,`section`in e?e.section??``:``]),...u.tasks.flatMap(e=>[e.title,e.instructions]),...[...u.checks,...u.setup,...u.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 u}function tr(e){return e.documents??e.knowledge??[]}function nr(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...tr(e)])]}function rr(e,t){return H(e,16,e=>{if(Object.hasOwn(e??{},`research`)){let t=V(e,[`research`,`reason`]);return{research:U(t.research),reason:F(t.reason,512,!0)}}let n=V(e,[`path`,...Object.hasOwn(e??{},`section`)?[`section`]:[],`reason`]);return{path:Yn(n.path,t),...n.section===void 0?{}:{section:F(n.section,256,!0)},reason:F(n.reason,512,!0)}})}function ir(e){return F(`# ${e.goal}\n\nInitial route (${e.version===3?`the owner may revise it`:`adapt within the approved boundary`}): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}${e.assumptions?`\n\nAssumptions confirmed with the agreement: ${e.assumptions}`:``}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function ar(e){let t=F(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function or(e){let t=F(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 sr(e){let t=F(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function cr(e){let t=V(e,[`policy`,`target`]),n=V(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:R(t.policy,[`task-branch-v1`]),target:{checkoutRoot:sr(n.checkoutRoot),repository:sr(n.repository),repositoryIdentity:W(n.repositoryIdentity),branch:or(n.branch),head:ar(n.head)}}}function lr(e){let t=V(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=V(t.integration,[`status`,`before`,`after`,`reason`]),r=V(t.cleanup,[`status`,`reason`]),i=e=>F(e,160,!0),a=B(t.acceptance,e=>{let t=V(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=H(t.checks,Kn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:ar(t.candidate),tree:ar(t.tree),planDigest:W(t.planDigest),contextDigest:W(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:H(t.waived,Kn.checks,i).filter(e=>n.includes(e))}}}),o=B(t.candidate,ar);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=B(t.workspace,e=>{let t=V(e,[`head`,`state`]);return{head:ar(t.head),state:R(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=cr(t.binding),l=or(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:sr(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:H(t.artifacts,256,e=>{let t=V(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:Xn(t.id),path:sr(t.path),base:ar(t.base),head:ar(t.head),applied:B(t.applied,ar),state:R(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:R(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:R(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:ar(n.before),after:B(n.after,ar),reason:F(n.reason,2048)},postChecks:R(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:R(r.status,[`pending`,`removed`,`retained`]),reason:F(r.reason,2048)}}}function ur(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate.\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 dr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=V(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:cr(n.delivery)},id:U(n.id),epoch:U(n.epoch),digest:W(n.digest),observation:W(n.observation),model:_n(n.model),plan:er(n.plan),cwd:F(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:F(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=V(n.display,[`model`,`branch`,`baseCommit`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:F(e.runtime,4096,!0)},model:F(e.model,1024,!0),branch:F(e.branch,1024),baseCommit:F(e.baseCommit,64)}})()}:{}}}function fr(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=V(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=H(n.questions,Kn.questions,e=>F(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:H(n.roots,8,e=>F(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:F(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:_n(n.model)}}if(t===`propose`){let n=V(e,[`action`,`plan`,`model`]);return{action:t,plan:er(n.plan),model:_n(n.model)}}if(t===`prepare`||t===`execute`){let n=V(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:U(n.proposalId),digest:W(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:U(n.grant)}}let n=V(e,[`action`,`runId`]);return{action:R(n.action,[`cancel`]),runId:U(n.runId)}}function pr(e){let t=V(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`scope`)?[`scope`]:[],...Object.hasOwn(e??{},`deviations`)?[`deviations`]:[],...Object.hasOwn(e??{},`tasks`)?[`tasks`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>R(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=V(t.verification,[`id`,`source`,`steps`]);return{id:U(e.id),source:W(e.source),steps:H(e.steps,32,e=>F(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:I(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:I(t.revision,0)},...t.scope===void 0?{}:{scope:H(t.scope,1024,e=>Yn(e))},...t.deviations===void 0?{}:{deviations:H(t.deviations,16,e=>{let t=V(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:I(t.revision,0),item:F(t.item,2048,!0),reason:F(t.reason,4096,!0),delivered:F(t.delivered,4096,!0),waives:H(t.waives,16,e=>F(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:H(t.tasks,Kn.route,e=>{let t=V(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:Xn(t.id),title:F(t.title,256,!0),after:H(t.after,Kn.tasks,e=>Xn(e)),state:R(t.state,qn),...t.revision===void 0?{}:{revision:I(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:lr(t.delivery)},...t.execution===void 0?{}:{execution:gn(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:xr(t.diagnostics)},id:U(t.id),epoch:U(t.epoch),goal:F(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:R(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:F(t.notice,2048),mergedCommit:B(t.mergedCommit,e=>F(e,64,!0)),humanReviewed:!1,steps:H(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=V(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:br(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=V(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:F(e.sdkVersion,128,!0),workerHash:W(e.workerHash)}})()},id:F(r.id,160,!0),...t?{childRunId:U(r.childRunId)}:{},kind:R(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:n(r.status),text:F(r.text,65536),exitCode:B(r.exitCode,e=>I(e,-2147483648,2147483647)),truncated:L(r.truncated)}})}}function mr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:pr(V(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:dr(V(e,[`type`,`proposal`]).proposal)};let n=V(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:R(n.type,[`grant`]),proposal:dr(n.proposal),grant:U(n.grant),expiresAt:I(n.expiresAt,0)}}var hr=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,gr=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function _r(e){return e.version===3?`After approval the service works to completion without further confirmation. It may on its own: retry and repair a failed assignment; revise the route, the assignments and their order; and bring further repository files into the write scope (never credentials, keys, .env, .git or files outside the repository). When an acceptance item or decision proves impossible it delivers the closest achievable result as a recorded deviation, which names the item, the evidence and what was delivered instead, must be confirmed necessary and minimal by the independent Agent review, and leads the final report. Declared checks always run; a check is set aside only through such a deviation, never silently. At the end it maintains the project's knowledge store under .cadence/ within its fixed budget, adding what this delivery taught and removing what went stale, when a fast-forward can carry it. It stops only for a condition outside the repository: an unavailable model, failed authentication, storage or permission limits, a target branch changed from outside, or a required installation this agreement does not allow. ${e.policy?.installs?`Revisions may add dependency-installation commands with the project's own package manager.`:`No dependency installation beyond the setup commands listed here.`}`:e.version===2?`Retained agreement (readonly): diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`}function vr(e){let t=tr(e);return`# ${e.goal}\n\n## Initial route (the service may revise it)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}${e.version===3?`\n\n## Assumptions (confirmed by approval)\n${e.assumptions||`None beyond the decisions above.`}`:``}\n\n## Tasks\n${Qn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}${e.reads?.length?`\nReads first: ${e.reads.map(gr).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
5
5
|
|
|
6
|
-
`)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(
|
|
7
|
-
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(
|
|
8
|
-
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(
|
|
9
|
-
`)}
|
|
10
|
-
`)
|
|
11
|
-
`)}function
|
|
12
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function _r(e,t,n=!1){let r=e.role===`tool`,i=r?``:hr(e.text,pr);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?hr(gr(e.args),mr):``,error:e.error,parts:t}}function vr(e){let t=R(e,[`id`,`updatedAt`]);return{id:an(t.id),updatedAt:N(t.updatedAt,0)}}var yr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function br(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:on(R(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=R(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:an(n.id),leaf:L(n.leaf,ur),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%Pn.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:an(n.id),leaf:L(n.leaf,ur),...n.live===void 0?{}:{live:!0},entry:ur(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:an(n.id),leaf:L(n.leaf,ur),turnId:ur(n.turnId),step:N(n.step,0),part:N(n.part,0)}}case`cadence-conversation`:return{kind:t,id:an(R(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=R(e,[`kind`,`id`,`leaf`]);return{kind:t,id:an(n.id),leaf:L(n.leaf,ur)}}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,vr)}:{}}}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:an(n.id),leaf:L(n.leaf,ur),known:L(n.known,ur)}}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:on(r.location)}:{}}}}}function xr(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:on(n.location),expected:ln(n.expected),choice:K(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:on(n.location)},...r?{expected:ln(n.expected),choice:K(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:on(n.location)},commandId:B(n.commandId),conversationId:an(n.conversationId),head:L(n.head,ur),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=xr(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,Fn),size:N(n.size,1),offset:N(n.offset,0),data:M(n.data,Pn.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:an(n.conversationId),head:L(n.head,ur),text:M(n.text,dr),...n.images===void 0?{}:{images:z(n.images,2**53-1,B)},model:ln(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:an(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:tr(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:an(n.conversationId),head:L(n.head,ur),text:M(n.text,dr),...n.images===void 0?{}:{images:z(n.images,2**53-1,B)},model:ln(n.model)}}if(t===`interrupt`){let n=R(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:B(n.commandId),conversationId:an(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 Sr(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=R(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?R(i.transcript,[`pages`]):null,o=n?R(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:cn(i.execution)},...i.retry===void 0?{}:{retry:Re(i.retry)},id:B(i.id),epoch:B(i.epoch),status:F(i.status,yr),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,wr)}}function Cr(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:ur(t.entry),index:N(t.index,0),mimeType:F(t.mimeType,Fn)}})}function wr(e){let t=R(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:Cr(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 Tr(e){let t=R(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:Cr(t.images)},id:M(t.id,160,!0),role:F(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,pr),clipped:P(t.clipped),name:M(t.name,128),target:M(t.target,mr),error:P(t.error),parts:N(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function Er(e){let t=R(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,`at`]),n=R(t.omitted,[`thinking`,`media`,`other`]),r=N(t.steps,0);return{...t.execution===void 0?{}:{execution:cn(t.execution)},...t.retry===void 0?{}:{retry:Re(t.retry)},id:ur(t.id),entry:L(t.entry,ur),at:N(t.at,0),status:F(t.status,yr),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 Dr(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:an(n.id),title:M(n.title,512,!0),leaf:L(n.leaf,ur),status:F(n.status,yr),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 Or(e){let t=R(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:B(t.commandId),text:M(t.text,16384),status:F(t.status,yr),notice:M(t.notice,1024)}}function kr(e){let t=R(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:ur(t.id),parent:L(t.parent,ur),text:M(t.text,1024),at:N(t.at,0),leaf:ur(t.leaf),current:P(t.current)}}function Ar(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,Fn),data:M(n.data,Pn.chunkChars,!0),next:L(n.next,e=>N(e,0))}}if(t===`conversation-context`)return{kind:t,context:sn(R(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:hn(R(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=R(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:B(n.commandId),choice:un(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,Sr)}}if(t===`cadence-conversation`)return{kind:t,state:lr(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,Rn.historyPage,e=>{let t=R(e,[`id`,`run`]),n=B(t.id),r=L(t.run,nr);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,nr),a=n?z(r.links,4,e=>{let t=R(e,[`runId`,`conversationId`]);return{runId:B(t.runId),conversationId:an(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:er(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:rr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:z(R(e,[`kind`,`entries`]).entries,8,Dr)};if(n===`conversations`){let t=R(e,[`kind`,`entries`,`next`]);return{kind:n,entries:z(t.entries,200,Dr),next:L(t.next,vr)}}if(n===`conversation`){let t=R(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=L(t.summary,Dr),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,ur),continues:P(t.continues),turns:i,branches:N(t.branches,0),runs:z(t.runs,200,B),attempt:L(t.attempt,Or)}}if(n===`conversation-tree`){let t=R(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:an(t.conversationId),nodes:z(t.nodes,fr,kr),truncated:P(t.truncated)}}if(n===`conversation-turn`){let t=R(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Er(t.turn),i=N(t.start,0),a=z(t.steps,24,Tr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:an(t.conversationId),leaf:L(t.leaf,ur),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:an(t.conversationId),leaf:L(t.leaf,ur),turnId:ur(t.turnId),step:N(t.step,0),part:N(t.part,0),item:wr(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 jr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Mr=f.createContext&&f.createContext(jr),Nr=[`attr`,`size`,`title`];function Pr(e,t){if(e==null)return{};var n,r,i=Fr(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 Fr(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 Ir(){return Ir=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},Ir.apply(null,arguments)}function Lr(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 Rr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Lr(Object(n),!0).forEach(function(t){zr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function zr(e,t,n){return(t=Br(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Br(e){var t=Vr(e,`string`);return typeof t==`symbol`?t:t+``}function Vr(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 Hr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Rr({key:t},e.attr),Hr(e.child)))}function Q(e){return t=>f.createElement(Ur,Ir({attr:Rr({},e.attr)},t),Hr(e.child))}function Ur(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Pr(e,Nr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Ir({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Rr(Rr({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 Mr===void 0?t(jr):f.createElement(Mr.Consumer,null,e=>t(e))}function Wr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 Kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function qr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Jr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Yr(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 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:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function Zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function 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:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function $r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function ti(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},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:`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 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:`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 ii(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 ai(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 oi(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 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:`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 ci(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function li(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`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 ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 di(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 fi(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 pi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function mi(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 hi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function gi(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 _i(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 vi(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 yi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},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:`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 xi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function Si(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 Ci(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function wi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function Ti(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function Ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function Di(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},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:`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 ki(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`)}),Ai=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=br(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Ar);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=xr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Ar);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Xt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),nn);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Zt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),rn);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),Xe):$(!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),hn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=dn(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),un)}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),Gt);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=Kt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Jt);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),bt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),xt)}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=kt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Ft);return t.kind===`ok`&&!It(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Lt(e);try{let e=Z(await this.transport.graph(n,t),zt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Bt(e),r=new Ut(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=Se({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),De);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=Ce(t);if(n.action.kind!==e)return{kind:`error`,error:te(`invalid`)};try{let e=Z(await this.transport.command(n),nt);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);rt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Te(e);try{let e=Z(await this.transport.cancel(t),nt);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);rt({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=it(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=je(e);try{let e=Z(await this.transport.snapshot(n,t),ct);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=Me(e);try{let e=Z(await this.transport.detail(n,t),ft);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=Me(e);try{let e=Z(await this.transport.search(n,t),mt);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},ji=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ct(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=lt(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||_t(i.context)!==_t(a.context)||vt(i.context)!==vt(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{ct(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 Mi(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 Ni={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`},Pi=`/api/v1/events`,Fi=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Ii(e,t){if(Fi.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 Li(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Ri(e,t){switch(e){case`workbenchRead`:return br(t);case`workbenchCommand`:return xr(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=kt(t);if(n.reader!==e)throw new A(`invalid`);return n}case`current`:return Xt(t);case`currentChanges`:return Zt(t);case`checkObligations`:case`receipt`:return B(t);case`entity`:return Kt(t);case`graph`:return Lt(t);case`snapshot`:return je(t);case`detail`:case`search`:return Me(t);case`export`:case`download`:return Bt(t);case`chooseModel`:return dn(t);case`preflight`:return Se(t);case`command`:return Ce(t);case`cancel`:return Te(t)}}function zi(e,t){if(Fi.includes(e))return Z(t,Ft);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Ar);case`current`:return Z(t,nn);case`currentChanges`:return Z(t,rn);case`activeRuns`:return Z(t,Xe);case`models`:return Z(t,hn);case`chooseModel`:return Z(t,un);case`session`:return Z(t,bt);case`workspace`:return Z(t,xt);case`checkObligations`:return Z(t,Gt);case`entity`:return Z(t,Jt);case`graph`:return Z(t,zt);case`snapshot`:return Z(t,ct);case`detail`:return Z(t,ft);case`search`:return Z(t,mt);case`preflight`:return Z(t,De);case`command`:case`cancel`:return Z(t,nt);case`receipt`:return it(t);case`detach`:return Z(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function Bi(e){return[...Fi,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Vi(e,t){let n=Ni[e];return t===null||Li(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Hi(e,t){let n=Ri(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ni[e]:Vi(e,n);return Li(e)||Bi(e)&&(r||ne(i)>O.headerBytes/4)?{path:Ni[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Ui(e){W(e,O.viewerBytes);let t=F(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ct(R(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:lt(R(e,[`kind`,`event`]).event)}:(R(e,[`kind`]),{kind:t})}var Wi=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&&=$e(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=Hi(e,Ri(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Mi([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 Gi(t,Ii(e)),s=G(a);if(ne(a)>Ii(e,s))throw new A(`oversize`);let c=zi(e,s);if(e===`session`){let e=Z(c,bt);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`,dn(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`,Kt(e),t)}tasks(e,t){return this.request(`tasks`,kt(e),t)}runs(e,t){return this.request(`runs`,kt(e),t)}messages(e,t){return this.request(`messages`,kt(e),t)}tools(e,t){return this.request(`tools`,kt(e),t)}contents(e,t){return this.request(`contents`,kt(e),t)}events(e,t){return this.request(`events`,kt(e),t)}checks(e,t){return this.request(`checks`,kt(e),t)}changes(e,t){return this.request(`changes`,kt(e),t)}reviews(e,t){return this.request(`reviews`,kt(e),t)}graph(e,t){return this.request(`graph`,Lt(e),t)}preflight(e){return this.request(`preflight`,Se(e))}command(e){return this.request(`command`,Ce(e))}cancel(e){return this.request(`cancel`,Te(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=Hi(`export`,Bt(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 Vt(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=je(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}`:``}${Pi}?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=Ui(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 Gi(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 Ki={sourceHash:`6a3ae3e3fae91f635f34f16332eb39bfcb3bdf6a71f81fa5b3abef2bbc63c1cc`,contractHash:`069d95cf6e4efcd6d8975b2ee3f707c51d11038477a01f76398a610712f1c9d7`,buildId:`ecbaced5ae867bbc1dab01deb5ba2d05b44f6f879359823823bd434dcc7b1c82`};function qi(e){let t=new Wi({origin:window.location.origin,...e?{project:e}:{},...Ki?{build:{kind:`browser`,...Ki}}:{},socket:e=>new WebSocket(e)});return{client:new Ai(t),transport:t}}function Ji(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?an(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Yi(e=typeof window>`u`?``:window.location.search){return Ji(e,``).project}function Xi(e=typeof window>`u`?``:window.location.hash){return Ji(``,e).chat}function Zi(){let e=Yi();return e?`/projects/${e}`:``}function Qi(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&Ji(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?ur(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function $i(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 ea(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(br(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 ta(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 na(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=ea(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 ra(e){return G(await Gi(e,1048576),1048576)}function ia(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 aa(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await ra(r);if(!r.ok)throw Error(ia(i));return t(i)}function oa(e){return aa(`/workbench/v1/service`,jn,e)}function sa(e){return aa(`/workbench/v1/service/release`,Mn,e)}async function ca(e,t){if(!Ki)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`,...Ki})},body:JSON.stringify(e)}),r=await ra(n);if(!n.ok)throw Error(ia(r));let i=R(r,[`kind`,`job`]);return I(i.kind,`service-job`),On(i.job)}function la(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function ua(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function da(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 ra(r);if(!r.ok)throw Error(ia(a));let c=_n(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...ua(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...ua(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:la(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var fa=e=>e===`unauthenticated`||e===`forbidden`,pa=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 ji,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 ji,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,fa(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(fa(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,fa(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,fa(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 ji,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Ki?{kind:`browser`,...Ki}:null;_.compatible=tt(e.build,t),_.cancelCompatible=tt(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 ji,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new ji,_={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 ma(e,t,n,r){let i=(0,f.useMemo)(()=>new pa(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 ha=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 ga({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 _a(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 va(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 ya(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 ba(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=_a(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 xa(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),va(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 Sa({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)(Sa,{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 Ca(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 wa(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Ca(e)}return Ca(e)}function Ta(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 wa(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 Ea(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 Da=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Oa(!0)},text:{92:Oa(!1)}});let t={enter:{backslashMathInline:ka,backslashMathDisplay:ka,backslashMathBlock:ka},exit:{backslashMathInline:Aa,backslashMathDisplay:Aa,backslashMathBlock:Aa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Oa(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 ka=function(e){let t=e.type===`backslashMathBlock`,n=e.type!==`backslashMathInline`,r=this.sliceSerialize(e).slice(2,-2).trim(),i={type:`element`,tagName:`code`,properties:{className:[`language-math`,n?`math-display`:`math-inline`]},children:[{type:`text`,value:r}]},a=t?{type:`math`,meta:null,value:r,data:{hName:`pre`,hChildren:[i]}}:{type:`inlineMath`,value:r,data:{hName:`code`,hProperties:i.properties,hChildren:i.children}};this.enter(a,e)},Aa=function(e){this.exit(e)},ja=(0,f.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=T(),[r,i]=(0,f.useState)(!1),{copied:a,copy:o}=Ta();return(0,h.jsxs)(`button`,{type:`button`,className:a?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(!1),o(e).then(e=>i(!e))},children:[a?(0,h.jsx)(Ei,{}):(0,h.jsx)(bi,{}),r&&n(`Copy unavailable`)]})}),Ma=[s,d,Da],Na=[s,l,d,Da],Pa=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Fa(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 Ia({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Na:Ma,rehypePlugins:t?[i,o,...Pa]:Pa,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:za,a:Ra,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var La=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Ia,{...e})})});function Ra({href:e,children:t}){let n=e&&Fa(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 za({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Ea(r).map(e=>{let t=`code-offset:${i}`;return i+=Ba(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)(ja,{text:Ba(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 Ba(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ba).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ba(t?.children)}return``}function Va(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 Ha=new Map;function Ua(e,t){t.length?Ha.set(e,t):Ha.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Ha].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 Wa(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 Ga(e,t){let n=t.startContainer.parentElement;for(let r of Wa(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 Ka({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?Va(n,r):[];return l.current=i,c(i.length),o(0),Ua(u,i),()=>Ua(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Ga(e.current,l.current[n]),Ua(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Ua(`${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 qa({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>Me(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 ba(e,t,n.signal);if(n.signal.aborted)return;let i=await wa(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)(Sa,{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)(Ka,{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)(La,{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 Ja({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)(Sa,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,h.jsx)(Zr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function Ya({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=xa(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)(Ja,{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)(Sa,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ya(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)(qa,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Xa({client:e,seed:t}){return(0,h.jsx)(Za,{client:e,seed:t},W(t))}function Za({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(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)(Sa,{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 Qa(e){let t=Hi(`download`,Bt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Zi()+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 $a({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)(Wr,{"aria-hidden":`true`})})]}),t]})}function eo({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)($a,{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{Qa({...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 to(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 Me({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function no(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 ro({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=to(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)($a,{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)(Xr,{}),(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)(Sa,{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(no(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 io({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)(Sa,{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 ao({client:e,seed:t}){return(0,h.jsx)(oo,{client:e,seed:t},W(t))}function oo({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)(Sa,{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)(qa,{client:e,cursor:ya(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)(La,{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 so({client:e,seed:t,onScope:n}){let{t:r}=T(),i=xa(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ja,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(io,{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)(ao,{client:e,seed:o},o.graph.recordId)]})}function co({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)(Xr,{"aria-hidden":`true`})})}function lo(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 uo(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 fo(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)??po(n.role,n.customType)}return r}function po(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 mo(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function ho(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=fo(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=lo(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=>uo(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)=>mo(e,t,s.current,n),[])}}var go=(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`})}),_o=(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)(Ci,{"aria-hidden":`true`}):(0,h.jsx)(mi,{"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)(qa,{compact:!0,client:t,cursor:ya(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)(Ya,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function vo({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=ho(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)(go,{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)(_o,{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)(ki,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function yo({client:e,seed:t}){let{t:n}=T(),r=xa(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ja,{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)(vo,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function bo({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)(Ti,{}):(0,h.jsx)(wi,{})}):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 xo=(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)(bo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Gr,{}),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)(Ya,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),So=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function Co({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(So(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 wo=[`queued`,`running`];function To(e){return e.replace(/(?:-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})+$/i,``)}var Eo=4,Do=1e4;function Oo(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?wo.includes(t.status):i-(u.get(e)??0)>=Do}).reverse();for(let n=0;n<a.length;n+=Eo){let r=await Promise.all(a.slice(n,n+Eo).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+Eo<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>wo.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),Do))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function ko({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=Oo(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(!wo.includes(e.step.status))-Number(!wo.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>wo.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)(Ti,{}),(0,h.jsx)(vi,{}),(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=To(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 Ao=2e4;async function jo(e,t,n,r){let i=Mi([t],Ao);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Mo(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 No(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 Po(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Fo(e){let t={commandId:crypto.randomUUID(),conversationId:an(e.id),head:e.head===null?null:ur(e.head)},n=e.location?on(e.location):void 0;if(n&&n.id!==t.conversationId)throw new A(`stale`);let r=M(e.text,dr,!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(Io(e.model))}:{}})}function Io(e){return K({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Lo(e,t){return Object.freeze({...e,model:Object.freeze(Io(t))})}function Ro(e,t){if(e.model&&W(e.model)!==W(Io(t)))throw new A(`stale`)}function zo(e,t){return Object.freeze({...e,preparedEpoch:B(t)})}function Bo(e,t,n){return Object.freeze({...Lo(e,t),installModel:!n})}function Vo(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 Ho(e,t){return!!e&&e===t}async function Uo(e,t,n,r){if(!r())throw new A(`stale`);if(!t.installModel||!t.model)return n;if(!pn(n.entries,t.model))throw new A(`unsupported-context`);if(n.selected&&W(Io(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 Ro(t,a.value.selected),a.value}function Wo(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=xr(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 Go(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 Ko(e){for(let t of e){if(!Fn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function qo(e){Ko([e]);let t=new Uint8Array(await e.arrayBuffer());return Ln(t,e.type),t}var Jo=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 Yo(e,t,n,r){Ko(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await qo(a);if(!r())throw Error(`stale`);let o=Jo(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Pn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Pn.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 Xo(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>Pn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Pn.chunkChars)throw Error(`invalid`)}let i=In(n.join(``));return Ln(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Zo=1e3,Qo=1e4,$o=4,es=e=>e===`queued`||e===`running`,ts=class extends Error{},ns=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 ts?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=es(this.summary?.status)||[...this.turns.values()].some(e=>es(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Zo:Qo)}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 ts(`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||es(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 ts(`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 ts(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Mi([t,r]);try{return await Xo(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=Mi([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 ts(`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>=$o&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new ts(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new ts(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function rs(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 ns(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??is,loadEarlier:i?.loadEarlier??is,choose:i?.choose??is}}function is(){}function as(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 os(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 ss(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function cs(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var ls={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},us={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.`},ds=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,fs=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function ps(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 ms(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(ls[t.thinking])}`,[e])}function hs({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=ms(),_=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=>fs(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=K({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&&ds(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)(vi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:ae}),(0,h.jsx)(Ti,{"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)(Xr,{"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=fs(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,ps(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)(Ei,{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(ls[e.level])}),"aria-pressed":R?.thinking===e.level,disabled:!V||!e.selectable||k||o,onClick:()=>void H(B,e.level),children:m(ls[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:us[ee]?m(us[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 gs(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 _s({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=ea(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>gs(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)(Wr,{"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 vs({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 ys(){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])];Ko(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 bs({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),qo(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 xs({image:e,read:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(!1),{entry:s,index:c,mimeType:l,live:u}=e;return(0,f.useEffect)(()=>{let e=new AbortController,n=``;if(i(``),o(!1),!t)o(!0);else return t({entry:s,index:c,mimeType:l,...u?{live:u}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i(n))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,s,c,l,u]),a?(0,h.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,h.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,"aria-label":n(`Open image`),children:(0,h.jsx)(`img`,{src:r,alt:n(`Attached image`),loading:`lazy`,onError:()=>o(!0)})}):(0,h.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)})}function Ss({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(xs,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var Cs=/^\s{0,3}(`{3,}|~{3,})/,ws=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Ts(e){return e.trim()===``}function Es(e){let t=Cs.exec(e);return t?t[1]:null}function Ds(e){let t=e.split(`
|
|
16
|
-
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Es(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Es(a);if(o&&!Ts(a))i=o,r.push(a);else if(Ts(a)){let i=e;for(;i<t.length&&Ts(t[i]);)i++;if(!(i<t.length&&ws.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
6
|
+
`)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(hr).join(`
|
|
7
|
+
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(hr).join(`
|
|
8
|
+
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(hr).join(`
|
|
9
|
+
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(gr).join(`
|
|
10
|
+
`)}`:``}\n\n## Automation boundary\n${_r(e)} Only actual verification and independent Agent review permit delivery. ${e.delivery===`local-merge`?`Authorize one new named task branch and stable isolated worktree after approval, temporary worktrees beside it for assignments that run side by side, local commits and 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 or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project documents\n${e.version===void 0?e.projectContext:t.join(`
|
|
11
|
+
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var yr=e=>I(e,0,864e13);function br(e){let t=V(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,...Object.hasOwn(e??{},`timeoutMs`)?[`timeoutMs`]:[],`stopReason`]);return{createdAt:yr(t.createdAt),preparedAt:B(t.preparedAt,yr),startedAt:B(t.startedAt,yr),stopRequestedAt:B(t.stopRequestedAt,yr),closedAt:B(t.closedAt,yr),settledAt:B(t.settledAt,yr),...t.timeoutMs===void 0?{}:{timeoutMs:I(t.timeoutMs,100,2147483647)},stopReason:B(t.stopReason,e=>F(e,320,!0))}}function xr(e){let t=V(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=V(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:yr(t.acceptedAt),acquiredAt:B(t.acquiredAt,yr),settledAt:B(t.settledAt,yr),owner:{version:F(n.version,128,!0),build:F(n.build,64,!0),entry:F(n.entry,4096,!0),pid:I(n.pid,1),node:F(n.node,128,!0),platform:F(n.platform,32,!0),startedAt:yr(n.startedAt)}}}function Sr(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)} · ${e.timing.timeoutMs===void 0?`no total runtime deadline`:`historical process budget ${e.timing.timeoutMs}ms`}${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
|
|
12
|
+
`)}function Cr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=V(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:pn(n.id),revision:I(n.revision,0),enabled:L(n.enabled),head:B(n.head,U),proposal:B(n.proposal,dr),runs:H(n.runs,200,U),...t?{notice:F(n.notice,1024,!0)}:{}}}function wr(e){let t=F(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new N(`invalid`);return t}var Tr=16384,Er=1e3,Dr=16384,Or=1024;function kr(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function Ar(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
|
|
13
|
+
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function jr(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:kr(e.text,Dr);return{id:e.id,role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?kr(Ar(e.args),Or):``,error:e.error,parts:t}}function Mr(e){let t=V(e,[`id`,`updatedAt`]);return{id:pn(t.id),updatedAt:I(t.updatedAt,0)}}var Nr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Pr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:mn(V(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=V(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:pn(n.id),leaf:B(n.leaf,wr),ordinal:I(n.ordinal,0),before:B(n.before,e=>I(e,0))}}case`conversation-image`:{let n=V(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=I(n.offset,0);if(r%Hn.chunkChars||n.live!==void 0&&n.live!==!0)throw new N(`invalid`);return{kind:t,id:pn(n.id),leaf:B(n.leaf,wr),...n.live===void 0?{}:{live:!0},entry:wr(n.entry),index:I(n.index,0),offset:r}}case`conversation-step`:{let n=V(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:pn(n.id),leaf:B(n.leaf,wr),turnId:wr(n.turnId),step:I(n.step,0),part:I(n.part,0)}}case`cadence-conversation`:return{kind:t,id:pn(V(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=V(e,[`kind`,`id`,`leaf`]);return{kind:t,id:pn(n.id),leaf:B(n.leaf,wr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=V(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:B(r.after,U),...n?{scan:U(r.scan)}:{}}}case`workflow-active`:return V(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=V(e,[`kind`,`id`,`stepId`]);return{kind:t,id:U(n.id),stepId:F(n.stepId,160,!0)}}case`workflow`:{let n=V(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:U(n.id),...n.before===void 0?{}:{before:I(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=V(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new N(`invalid`);return{kind:t,...n?{after:B(i.after,Mr)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return V(e,[`kind`]),{kind:t};case`conversation`:{let n=V(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:pn(n.id),leaf:B(n.leaf,wr),known:B(n.known,wr)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=V(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:R(r.kind,[`files`,`file`,`directories`]),path:F(r.path,4096),...n?{location:mn(r.location)}:{}}}}}function Fr(e){let t=F(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new N(`invalid`);if([...t].length>100)throw new N(`oversize`);return t}function Ir(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=V(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:U(n.commandId),location:mn(n.location),expected:_n(n.expected),choice:me(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=V(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 N(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:U(n.commandId),epoch:U(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:mn(n.location)},...r?{expected:_n(n.expected),choice:me(n.choice)}:{}}:{kind:t,...i,runId:U(n.runId)}}if(t===`cadence-exit`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:mn(n.location)},commandId:U(n.commandId),conversationId:pn(n.conversationId),head:B(n.head,wr),revision:I(n.revision,0)}}if(t===`image-upload`){let n=V(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new N(`invalid`);let r=Ir(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new N(`invalid`);return{kind:t,commandId:U(n.commandId),imageId:U(n.imageId),send:r,mimeType:R(n.mimeType,Un),size:I(n.size,1),offset:I(n.offset,0),data:F(n.data,Hn.chunkChars,!0)}}if(t===`cadence-send`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:U(n.commandId),conversationId:pn(n.conversationId),head:B(n.head,wr),text:F(n.text,Tr),...n.images===void 0?{}:{images:H(n.images,2**53-1,U)},model:_n(n.model),revision:I(n.revision,0),intent:R(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=V(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:U(r.commandId),conversationId:pn(r.conversationId),revision:I(r.revision,0),proposalId:U(r.proposalId),digest:W(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:U(r.grant)}}if(t===`workflow`){let n=V(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:U(n.commandId),epoch:U(n.epoch),request:fr(n.request)}}if(t===`send`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:U(n.commandId),conversationId:pn(n.conversationId),head:B(n.head,wr),text:F(n.text,Tr),...n.images===void 0?{}:{images:H(n.images,2**53-1,U)},model:_n(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=V(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:U(n.commandId),conversationId:pn(n.conversationId),turnId:U(n.turnId),epoch:U(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:R(n.mode,[`steer`,`queue`]),text:F(n.text,Tr,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:U(n.inputId)}}if(t===`conversation-rename`){let n=V(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:U(n.commandId),conversationId:pn(n.conversationId),name:Fr(n.name)}}if(t===`conversation-archive`){let n=V(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:U(n.commandId),conversationId:pn(n.conversationId),archived:L(n.archived)}}let n=V(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:R(n.kind,[`open-project`]),commandId:U(n.commandId),path:F(n.path,4096,!0),epoch:U(n.epoch)}}function Lr(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=V(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?V(i.transcript,[`pages`]):null,o=n?V(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:gn(i.execution)},...i.retry===void 0?{}:{retry:Ge(i.retry)},id:U(i.id),epoch:U(i.epoch),status:R(i.status,Nr),notice:F(i.notice,1024),...a?{transcript:{pages:I(a.pages,0)}}:{},omitted:{thinking:o?L(o.thinking):!1,media:o?L(o.media):!1,other:o?L(o.other):!1},items:H(i.items,256,Br)}}var Rr=[`user`,`assistant`,`tool`,`thinking`];function zr(e){return H(e,2**53-1,e=>{let t=V(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new N(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:wr(t.entry),index:I(t.index,0),mimeType:R(t.mimeType,Un)}})}function Br(e){let t=V(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:zr(t.images)},id:F(t.id,160,!0),role:R(t.role,Rr),text:F(t.text,262144),name:F(t.name,128),args:F(t.args,65536),error:L(t.error)}}function Vr(e){let t=V(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:zr(t.images)},id:F(t.id,160,!0),role:R(t.role,Rr),text:F(t.text,Dr),clipped:L(t.clipped),name:F(t.name,128),target:F(t.target,Or),error:L(t.error),parts:I(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&!n.parts)throw new N(`invalid`);return n}function Hr(e){let t=V(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=V(t.omitted,[`thinking`,`media`,`other`]),r=I(t.steps,0);return{...t.execution===void 0?{}:{execution:gn(t.execution)},...t.retry===void 0?{}:{retry:Ge(t.retry)},id:wr(t.id),entry:B(t.entry,wr),...t.parent===void 0?{}:{parent:B(t.parent,wr)},at:I(t.at,0),status:R(t.status,Nr),notice:F(t.notice,1024),omitted:{thinking:L(n.thinking),media:L(n.media),other:L(n.other)},steps:r,stable:I(t.stable,0,r)}}function Ur(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=V(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?V(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new N(`invalid`);return{id:pn(n.id),title:F(n.title,512,!0),leaf:B(n.leaf,wr),status:R(n.status,Nr),updatedAt:I(n.updatedAt,0),origin:R(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:L(n.cadence)}:{},...r?{live:{commandId:U(r.commandId),epoch:U(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function Wr(e){let t=V(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:U(t.commandId),text:F(t.text,16384),status:R(t.status,Nr),notice:F(t.notice,1024)}}function Gr(e){let t=V(e,[`commandId`,`mode`,`text`]);return{commandId:U(t.commandId),mode:R(t.mode,[`steer`,`queue`]),text:F(t.text,256)}}function Kr(e){let t=V(e,[`tokens`,`provider`,`model`]);return{tokens:B(t.tokens,e=>I(e,1)),provider:F(t.provider,128),model:F(t.model,256)}}function qr(e){let t=V(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:wr(t.id),parent:B(t.parent,wr),text:F(t.text,1024),at:I(t.at,0),leaf:wr(t.leaf),current:L(t.current)}}function Jr(e){q(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=V(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:U(n.commandId),imageId:U(n.imageId),offset:I(n.offset,0)}}if(t===`conversation-image`){let n=V(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:R(n.mimeType,Un),data:F(n.data,Hn.chunkChars,!0),next:B(n.next,e=>I(e,0))}}if(t===`conversation-context`)return{kind:t,context:hn(V(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:Cn(V(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=V(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:U(n.commandId),choice:vn(n.choice)}}if(t===`workflow-transcript`){let n=V(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:U(n.runId),stepId:F(n.stepId,160,!0),turn:B(n.turn,Lr)}}if(t===`cadence-conversation`)return{kind:t,state:Cr(V(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=V(e,[`kind`,`after`,`scan`]);return{kind:t,after:B(n.after,U),scan:U(n.scan)}}if(t===`workflow-history`){let n=V(e,[`kind`,`entries`,`next`]),r=H(n.entries,Kn.historyPage,e=>{let t=V(e,[`id`,`run`]),n=U(t.id),r=B(t.run,pr);if(r&&r.id!==n)throw new N(`invalid`);return{id:n,run:r}}),i=B(n.next,U);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new N(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=V(e,[`kind`,`runs`,...n?[`links`]:[]]),i=H(r.runs,4,pr),a=n?H(r.links,4,e=>{let t=V(e,[`runId`,`conversationId`]);return{runId:U(t.runId),conversationId:pn(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 N(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=V(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:U(n.commandId),grant:U(n.grant),expiresAt:I(n.expiresAt,0),revision:I(n.revision,0),proposal:dr(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=V(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:B(t.commandId,U),response:mr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:H(V(e,[`kind`,`entries`]).entries,8,Ur)};if(n===`conversations`){let t=V(e,[`kind`,`entries`,`next`]);return{kind:n,entries:H(t.entries,200,Ur),next:B(t.next,Mr)}}if(n===`conversation`){let t=V(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=B(t.summary,Ur),i=I(t.turns,0);if(!r&&i)throw new N(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:H(t.commands,64,U)},...t.context===void 0?{}:{context:Kr(t.context)},...t.pending===void 0?{}:{pending:H(t.pending,8,Gr)},...t.undelivered===void 0?{}:{undelivered:H(t.undelivered,8,Wr)},summary:r,leaf:B(t.leaf,wr),continues:L(t.continues),turns:i,branches:I(t.branches,0),runs:H(t.runs,200,U),attempt:B(t.attempt,Wr)}}if(n===`conversation-tree`){let t=V(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:pn(t.conversationId),nodes:H(t.nodes,Er,qr),truncated:L(t.truncated)}}if(n===`conversation-turn`){let t=V(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Hr(t.turn),i=I(t.start,0),a=H(t.steps,24,Vr);if(i+a.length>r.steps)throw new N(`invalid`);return{kind:n,conversationId:pn(t.conversationId),leaf:B(t.leaf,wr),ordinal:I(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=V(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:pn(t.conversationId),leaf:B(t.leaf,wr),turnId:wr(t.turnId),step:I(t.step,0),part:I(t.part,0),item:Br(t.item)}}if(n===`files`||n===`directories`){let t=V(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:F(t.path,4096),parent:B(t.parent,e=>F(e,4096)),limited:L(t.limited),entries:H(t.entries,200,e=>{let t=V(e,[`name`,`path`,`directory`]);return{name:F(t.name,1024,!0),path:F(t.path,4096,!0),directory:L(t.directory)}})}}if(n===`file`){let t=V(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:F(t.path,4096),text:F(t.text,262144),limited:L(t.limited)}}if(n===`projects`)return{kind:n,entries:H(V(e,[`kind`,`entries`]).entries,128,e=>{let t=V(e,[`path`,`current`]);return{path:F(t.path,4096,!0),current:L(t.current)}})};if(n===`accepted`)return{kind:n,commandId:U(V(e,[`kind`,`commandId`]).commandId)};let r=V(e,[`kind`,`commandId`,`path`,`link`]);return{kind:R(r.kind,[`project`]),commandId:U(r.commandId),path:F(r.path,4096,!0),link:F(r.link,8192,!0)}}var Yr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xr=f.createContext&&f.createContext(Yr),Zr=[`attr`,`size`,`title`];function Qr(e,t){if(e==null)return{};var n,r,i=$r(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 $r(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 ei(){return ei=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},ei.apply(null,arguments)}function ti(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 ni(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ti(Object(n),!0).forEach(function(t){ri(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ti(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ri(e,t,n){return(t=ii(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ii(e){var t=ai(e,`string`);return typeof t==`symbol`?t:t+``}function ai(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 oi(e){return e&&e.map((e,t)=>f.createElement(e.tag,ni({key:t},e.attr),oi(e.child)))}function Q(e){return t=>f.createElement(si,ei({attr:ni({},e.attr)},t),oi(e.child))}function si(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Qr(e,Zr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,ei({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ni(ni({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return Xr===void 0?t(Yr):f.createElement(Xr.Consumer,null,e=>t(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:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function li(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function di(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function fi(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 pi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function 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:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function hi(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 gi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function _i(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 vi(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 yi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},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:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function xi(e){return 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 Si(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 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:`M21.21 15.89A10 10 0 1 1 8 2.83`},child:[]},{tag:`path`,attr:{d:`M22 12A10 10 0 0 0 12 2v10z`},child:[]}]})(e)}function wi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Ti(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},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:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function Di(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function 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:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function ki(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 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:`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 ji(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function Mi(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 Ni(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Pi(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 Fi(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 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:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},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:`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 zi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function 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:`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 Vi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 Hi(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 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:`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 Wi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function Gi(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 Ki(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function qi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function Ji(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 Yi(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 Xi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function Zi(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 Qi(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 $i(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function ea(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 ta(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function na(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function ra(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function ia(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function aa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function oa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function sa(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 ca(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 la(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function ua(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function da(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function fa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function pa(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var $=e=>({kind:`error`,error:oe(`unavailable`,e?`uncertain`:`none`)}),ma=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Pr(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Jr);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=Ir(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Jr);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=an(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),dn);return e.kind===`ok`&&q(e.value.request)!==q(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=on(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),fn);return e.kind===`ok`&&q(e.value.request)!==q(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),it):$(!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),Cn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=yn(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),vn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(q(i)!==q(n.choice)||q(e.value.version.conversation??null)!==q(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){U(e);try{let n=Z(await this.transport.checkObligations(e,t),$t);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=en({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),nn);return e.kind===`ok`&&q(e.value.request)!==q(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),Ot)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),kt)}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=Lt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Ut);return t.kind===`ok`&&!Wt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Gt(e);try{let e=Z(await this.transport.graph(n,t),qt);return e.kind===`ok`&&q(e.value.request)!==q(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Jt(e),r=new Zt(n),i;try{if(t.aborted)throw new N(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new N(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new N(`unavailable`);yield i}catch{throw new N(`unavailable`)}}async preflight(e,t){let n=De({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Me);return e.kind===`ok`&&(q(e.value.preview.version)!==q(n.expected)||q(e.value.preview.action)!==q(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=Oe(t);if(n.action.kind!==e)return{kind:`error`,error:oe(`invalid`)};try{let e=Z(await this.transport.command(n),ut);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);dt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Ae(e);try{let e=Z(await this.transport.cancel(t),ut);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);dt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){U(e);try{let n=ft(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:oe(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=Le(e);try{let e=Z(await this.transport.snapshot(n,t),gt);return e.kind===`ok`&&q(e.value.scope)!==q(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ze(e);try{let e=Z(await this.transport.detail(n,t),bt);return e.kind===`ok`&&q(e.value.cursor)!==q(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ze(e);try{let e=Z(await this.transport.search(n,t),St);return e.kind===`ok`&&q(e.value.cursor)!==q(n)?$(!1):e}catch{return $(!1)}}},ha=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=gt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&q(i.scope)===q(r.scope)&&K(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>=M.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=M.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=_t(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||q(i.scope)!==q(a.scope))return this.resync();let o=K(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||Tt(i.context)!==Tt(a.context)||Et(i.context)!==Et(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||q(t.admission)!==q(e.admission))return this.resync();s[n]=e}}if(s.length>M.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{gt(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 ga(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 _a={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`},va=`/api/v1/events`,ya=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function ba(e,t){if(ya.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return M.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 M.pageBytes}return M.controlBytes}function xa(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Sa(e,t){switch(e){case`workbenchRead`:return Pr(t);case`workbenchCommand`:return Ir(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new N(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Lt(t);if(n.reader!==e)throw new N(`invalid`);return n}case`current`:return an(t);case`currentChanges`:return on(t);case`checkObligations`:case`receipt`:return U(t);case`entity`:return en(t);case`graph`:return Gt(t);case`snapshot`:return Le(t);case`detail`:case`search`:return ze(t);case`export`:case`download`:return Jt(t);case`chooseModel`:return yn(t);case`preflight`:return De(t);case`command`:return Oe(t);case`cancel`:return Ae(t)}}function Ca(e,t){if(ya.includes(e))return Z(t,Ut);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Jr);case`current`:return Z(t,dn);case`currentChanges`:return Z(t,fn);case`activeRuns`:return Z(t,it);case`models`:return Z(t,Cn);case`chooseModel`:return Z(t,vn);case`session`:return Z(t,Ot);case`workspace`:return Z(t,kt);case`checkObligations`:return Z(t,$t);case`entity`:return Z(t,nn);case`graph`:return Z(t,qt);case`snapshot`:return Z(t,gt);case`detail`:return Z(t,bt);case`search`:return Z(t,St);case`preflight`:return Z(t,Me);case`command`:case`cancel`:return Z(t,ut);case`receipt`:return ft(t);case`detach`:return Z(t,e=>{if(e!==null)throw new N(`invalid`);return null});default:throw new N(`invalid`)}}function wa(e){return[...ya,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ta(e,t){let n=_a[e];return t===null||xa(e)?n:`${n}?request=${encodeURIComponent(q(t))}`}function Ea(e,t){let n=Sa(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?_a[e]:Ta(e,n);return xa(e)||wa(e)&&(r||se(i)>M.headerBytes/4)?{path:_a[e],method:`POST`,body:q(n)}:{path:i,method:`GET`}}function Da(e){q(e,M.viewerBytes);let t=R(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:gt(V(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:_t(V(e,[`kind`,`event`]).event)}:(V(e,[`kind`]),{kind:t})}var Oa=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 N(`invalid`);this.origin=e.origin,e.build&&=st(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`]=q(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 N(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Ea(e,Sa(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:ga([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=U(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await ka(t,ba(e)),s=le(a);if(se(a)>ba(e,s))throw new N(`oversize`);let c=Ca(e,s);if(e===`session`){let e=Z(c,Ot);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new N(`forbidden`);this.attachment=n??U(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`,yn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,U(e),t)}entity(e,t){return this.request(`entity`,en(e),t)}tasks(e,t){return this.request(`tasks`,Lt(e),t)}runs(e,t){return this.request(`runs`,Lt(e),t)}messages(e,t){return this.request(`messages`,Lt(e),t)}tools(e,t){return this.request(`tools`,Lt(e),t)}contents(e,t){return this.request(`contents`,Lt(e),t)}events(e,t){return this.request(`events`,Lt(e),t)}checks(e,t){return this.request(`checks`,Lt(e),t)}changes(e,t){return this.request(`changes`,Lt(e),t)}reviews(e,t){return this.request(`reviews`,Lt(e),t)}graph(e,t){return this.request(`graph`,Gt(e),t)}preflight(e){return this.request(`preflight`,De(e))}command(e){return this.request(`command`,Oe(e))}cancel(e){return this.request(`cancel`,Ae(e))}receipt(e,t){return this.request(`receipt`,U(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 N(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new N(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Ea(`export`,Jt(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 N(`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 N(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=M.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+M.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
14
|
+
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield Yt(le(e,M.controlBytes)),r=o.indexOf(`
|
|
15
|
+
`)}if(new TextEncoder().encode(o).length>M.controlBytes)throw new N(`oversize`)}if(n){if(o)throw new N(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=Le(e);if(!this.attachment||!this.options.socket)throw new N(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${va}?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>=M.staleMs&&u(`stale`);try{Date.now()-c>=M.reconcileMs?(i.send(q({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},M.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(q({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new N(`invalid`);let n=Da(le(e.data,M.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function ka(e,t){if(!e.body)throw new N(`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 N(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Aa={sourceHash:`7b7e03938efd5a44f2f80ec394b667c01952f3897e3f02a61cb7193d368d8dae`,contractHash:`0b8623caaab7eb70f0bc49eeeb7b688a2aeafc2eef6aaaab4e961bb2a1e069e0`,buildId:`07e8da93e70966a4e42ffb090fbe53e2402d3dd9f8518ec8ed56220893868422`};function ja(e){let t=new Oa({origin:window.location.origin,...e?{project:e}:{},...Aa?{build:{kind:`browser`,...Aa}}:{},socket:e=>new WebSocket(e)});return{client:new ma(t),transport:t}}function Ma(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?pn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Na(e=typeof window>`u`?``:window.location.search){return Ma(e,``).project}function Pa(e=typeof window>`u`?``:window.location.hash){return Ma(``,e).chat}function Fa(){let e=Na();return e?`/projects/${e}`:``}function Ia(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&Ma(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?wr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function La(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,wr(t)),`#${n}`}function Ra(e,t){if(typeof window>`u`||Pa()!==e)return;let n=La(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function za(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&&K(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&&q(t.settlement)!==q(r.settlement))?i=!0:(!r||K(t.committedSeq,r.committedSeq)>0||q(r)===q(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 Ba(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(Pr(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 Va(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 Ha(e,t,n=!1){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)([]),s=Ba(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}async function Ua(e){return le(await ka(e,1048576),1048576)}function Wa(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 Ga(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await Ua(r);if(!r.ok)throw Error(Wa(i));return t(i)}function Ka(e){return Ga(`/workbench/v1/service`,zn,e)}function qa(e){return Ga(`/workbench/v1/service/release`,Bn,e)}async function Ja(e,t){if(!Aa)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`,...Aa})},body:JSON.stringify(e)}),r=await Ua(n);if(!n.ok)throw Error(Wa(r));let i=V(r,[`kind`,`job`]);return z(i.kind,`service-job`),In(i.job)}function Ya(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function Xa(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function Za(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 Ua(r);if(!r.ok)throw Error(Wa(a));let c=Tn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...Xa(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...Xa(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:Ya(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var Qa=e=>e===`unauthenticated`||e===`forbidden`,$a=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 ha,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 ha,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,Qa(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(Qa(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,Qa(o.error.code)&&w();return}if(!t&&q(_.workspace?.models??[])!==q(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,Qa(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 ha,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Aa?{kind:`browser`,...Aa}:null;_.compatible=lt(e.build,t),_.cancelCompatible=lt(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 ha,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new ha,_={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 eo(e,t,n,r){let i=(0,f.useMemo)(()=>new $a(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 to=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 no({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 ro(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 io(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 ao(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 oo(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=ro(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 so(e,t){let n=t?q({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),io(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 co({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)(co,{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 lo(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 uo(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return lo(e)}return lo(e)}function fo(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 uo(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 po(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
16
|
+
`).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 mo=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ho(!0)},text:{92:ho(!1)}});let t={enter:{backslashMathInline:go,backslashMathDisplay:go,backslashMathBlock:go},exit:{backslashMathInline:_o,backslashMathDisplay:_o,backslashMathBlock:_o}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ho(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 go=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)},_o=function(e){this.exit(e)};function vo(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var yo=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function bo(e,t,n=3){let r=[...e.filter(e=>!yo(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var xo=[],So=1,Co=new Set;function wo(e){if(!(e.length===xo.length&&e.every((e,t)=>e===xo[t]))){xo=e;for(let e of Co)e()}}function To(e,t,n){let r=So++;return wo(bo(xo,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function Eo(e){wo(xo.filter(t=>t.id!==e))}function Do(e){wo(xo.filter(t=>t.key!==e))}function Oo(e){return Co.add(e),()=>{Co.delete(e)}}var ko=()=>xo,Ao=(0,f.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=T(),{copied:r,copy:i}=fo();return(0,h.jsx)(`button`,{type:`button`,className:r?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(e).then(e=>{e||To(`error`,n(`Copy unavailable`))})},children:r?(0,h.jsx)(aa,{}):(0,h.jsx)(Qi,{})})}),jo=[s,d,mo],Mo=[s,l,d,mo],No=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Po(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 Fo({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Mo:jo,rehypePlugins:t?[i,o,...No]:No,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Ro,a:Lo,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var Io=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Fo,{...e})})});function Lo({href:e,children:t}){let n=e&&Po(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 Ro({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=po(r).map(e=>{let t=`code-offset:${i}`;return i+=zo(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)(Ao,{text:zo(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 zo(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(zo).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return zo(t?.children)}return``}function Bo(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 Vo=new Map;function Ho(e,t){t.length?Vo.set(e,t):Vo.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Vo].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 Uo(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 Wo(e,t){let n=t.startContainer.parentElement;for(let r of Uo(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 Go({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?Bo(n,r):[];return l.current=i,c(i.length),o(0),Ho(u,i),()=>Ho(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Wo(e.current,l.current[n]),Ho(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Ho(`${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 Ko({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=q(t),c=(0,f.useMemo)(()=>ze(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 oo(e,t,n.signal);if(n.signal.aborted)return;let i=await uo(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)(co,{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)(Go,{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)(Io,{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 qo({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)(co,{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)(xi,{"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 Jo({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=so(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)(qo,{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)(co,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ao(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)(Ko,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Yo({client:e,seed:t}){return(0,h.jsx)(Xo,{client:e,seed:t},q(t))}function Xo({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)(co,{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 Zo(e){let t=Ea(`download`,Jt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Fa()+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 Qo({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)(ui,{"aria-hidden":`true`})})]}),t]})}function $o({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)(Qo,{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{Zo({...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 es(e,t){if(!t||se(t)>M.queryBytes)throw Error(`Query must be 1–${M.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ze({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ts(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 ns({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=es(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)(Qo,{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)(yi,{}),(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)(co,{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(ts(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 rs({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)(co,{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 is({client:e,seed:t}){return(0,h.jsx)(as,{client:e,seed:t},q(t))}function as({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)(co,{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)(Ko,{client:e,cursor:ao(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)(Io,{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 os({client:e,seed:t,onScope:n}){let{t:r}=T(),i=so(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(qo,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(rs,{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)(is,{client:e,seed:o},o.graph.recordId)]})}function ss({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)(yi,{"aria-hidden":`true`})})}function cs(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 ls(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 us(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)??ds(n.role,n.customType)}return r}function ds(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 fs(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function ps(e,t,n=null,r=1800){let[i,a]=(0,f.useState)(()=>new Set),o=(0,f.useRef)(i);o.current=i;let s=(0,f.useRef)(new Map),c=(0,f.useRef)(new Map),l=(0,f.useRef)(new Map),u=(0,f.useRef)(0),d=(0,f.useRef)(new Map);d.current=new Map(t.map(e=>[e.id,e.version]));let p=(0,f.useRef)(new Set);p.current=us(t,s.current,r),n!==null&&p.current.add(n);let m=(0,f.useCallback)((e,t)=>{let n=d.current.get(e);n!==void 0&&(c.current.set(e,{h:t,len:n}),s.current.set(e,t))},[]),h=(0,f.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of l.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),o.current.has(e)||m(e,n.height)}let i=cs(r,{top:n.top-1200,bottom:n.bottom+1200},p.current,o.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=l.current.get(e);t&&m(e,t.offsetHeight)}a(e=>ls(e,i))},[m,e]),g=(0,f.useCallback)(()=>{u.current||=requestAnimationFrame(()=>{u.current=0,h()})},[h]);return(0,f.useLayoutEffect)(()=>{t.length?h():a(new Set)},[h,t,n]),(0,f.useEffect)(()=>{let t=new ResizeObserver(g);return e.current&&t.observe(e.current),()=>{t.disconnect(),cancelAnimationFrame(u.current)}},[g,e]),{hidden:i,scheduleSweep:g,recordMeasured:m,register:(0,f.useCallback)(e=>t=>{t?l.current.set(e,t):l.current.delete(e)},[]),placeholder:(0,f.useCallback)((e,t,n)=>fs(e,t,c.current,n),[])}}var ms=(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`})}),hs=(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)(ta,{"aria-hidden":`true`}):(0,h.jsx)(Gi,{"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)(Ko,{compact:!0,client:t,cursor:ao(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)(Jo,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function gs({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=ps(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)(ms,{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)(hs,{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)(ua,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function _s({client:e,seed:t}){let{t:n}=T(),r=so(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(qo,{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)(gs,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function vs({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)(ia,{}):(0,h.jsx)(na,{})}):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 ys=(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)(vs,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(fi,{}),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)(Jo,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),bs=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function xs({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(bs(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))]})]})}function Ss(e){return e.replace(/(?:-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})+$/i,``)}function Cs(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var ws=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function Ts(e,t){return ws.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function Es(e){let t=Cs(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function Ds(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>Ss(e.id)===n.id),...r?{artifact:r}:{}}})}var Os=[`queued`,`running`];function ks(e,t){let n=e=>Number(!Os.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function As(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(Ss(t.id))):!1}var js=[`queued`,`running`],Ms=4,Ns=1e4;function Ps(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?js.includes(t.status):i-(u.get(e)??0)>=Ns}).reverse();for(let n=0;n<a.length;n+=Ms){let r=await Promise.all(a.slice(n,n+Ms).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+Ms<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>js.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),Ns))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function Fs({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=T(),o=Cs(e),s=n?.runId===e.id?n.stepId:void 0;return(0,h.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${s===null?` active`:``}`,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,h.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,h.jsx)(`span`,{className:`agent-dock-run-state`,children:Ts(o,i)})]}),t.map(t=>{let n=Ss(t.id),o=e.tasks?.find(e=>e.id===n);return(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row${s===t.id?` active`:``}`,title:o?`${o.title} · ${e.goal}`:e.goal,onClick:()=>r?.({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.jsx)(`strong`,{children:`${a(t.kind)} · ${n}`}),o&&(0,h.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(o.state)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function Is({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=Ps(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=ks(a,y.runs),w=C.flatMap(e=>e.steps),E=S.length+w.length,D=w.filter(e=>js.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,O=d??(E>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${O?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":O,onClick:()=>p(!O),children:[(0,h.jsx)(ia,{}),(0,h.jsx)(Yi,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${D?` live`:``}`,children:D?l(`{active} active · {total} total`,{active:D,total:E}):E})]}),O&&(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`)}),E===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,steps:t})=>(0,h.jsx)(Fs,{run:e,steps:t,selected:o,onOpen:c},e.id)),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))]})]})}function Ls(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function Rs(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var zs=e=>e.filter(e=>e.current);function Bs(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function Vs(e,t,n,r,i){let[a,o]=(0,f.useState)();(0,f.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=Ba(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,f.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,p]=(0,f.useState)();return(0,f.useEffect)(()=>{u&&p(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function Hs({view:e,onChosen:t}){let{t:n,locale:r}=T(),[i,a]=(0,f.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,f.useMemo)(()=>Ls(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,h.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,h.jsx)(xi,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,h.jsxs)(`p`,{className:`branches-pinned`,children:[(0,h.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(n,e.error)}),s?.truncated&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,h.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,h.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,h.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,h.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,h.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,h.jsx)(qi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,h.jsx)(Zi,{"aria-hidden":`true`})})]},t.id))})]})}function Us(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function Ws(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function Gs(e,t){return Math.round(e/t*100)}var Ks=e=>e.trim().split(`
|
|
17
|
+
`,1)[0].slice(0,200);function qs(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var Js=(e,t)=>e?e.entry:t,Ys=(e,t)=>e!==null&&t>=e.from;function Xs(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:wr(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function Zs(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function Qs(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function $s(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function ec(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function tc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var nc=2e4;async function rc(e,t,n,r){let i=ga([t],nc);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function ic(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 ac(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 oc(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function sc(e){let t={commandId:crypto.randomUUID(),conversationId:pn(e.id),head:e.head===null?null:wr(e.head)},n=e.location?mn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new N(`stale`);let r=F(e.text,Tr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:I(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:I(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(cc(e.model))}:{}})}function cc(e){return me({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function lc(e,t){return Object.freeze({...e,model:Object.freeze(cc(t))})}function uc(e,t){if(e.model&&q(e.model)!==q(cc(t)))throw new N(`stale`)}function dc(e,t){return Object.freeze({...e,preparedEpoch:U(t)})}function fc(e,t,n){return Object.freeze({...lc(e,t),installModel:!n})}function pc(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 mc(e,t){return!!e&&e===t}async function hc(e,t,n,r){if(!r())throw new N(`stale`);if(!t.installModel||!t.model)return n;if(!xn(n.entries,t.model))throw new N(`unsupported-context`);if(n.selected&&q(cc(n.selected))===q(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new N(`stale`);if(i.kind===`error`)throw new N(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new N(`stale`);if(a.kind===`error`)throw new N(a.error.code);if(!a.value.selected||q(a.value.version)!==q(i.value.version)||q(a.value.selected)!==q(i.value.selected))throw new N(`stale`);return uc(t,a.value.selected),a.value}function gc(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&q(e.location)!==q(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new N(`stale`);let n=Ir(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 N(`invalid`);return n}function _c(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 vc(e){for(let t of e){if(!Un.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function yc(e){vc([e]);let t=new Uint8Array(await e.arrayBuffer());return Gn(t,e.type),t}var bc=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 xc(e,t,n,r){vc(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await yc(a);if(!r())throw Error(`stale`);let o=bc(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Hn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Hn.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 Sc(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>Hn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Hn.chunkChars)throw Error(`invalid`)}let i=Wn(n.join(``));return Gn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Cc=1e3,wc=1e4,Tc=4,Ec=e=>e===`queued`||e===`running`,Dc=class extends Error{},Oc=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;count=0;first=null;opening=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,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.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())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},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 Dc?e.message:`unavailable`)}finally{this.running=!1}if(e&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=Ec(this.summary?.status)||[...this.turns.values()].some(e=>Ec(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Cc:wc)}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 Dc(`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.pending=n.pending??[],this.undelivered=n.undelivered??[],this.commands=n.commands??[],this.context=n.context,this.summary=n.summary,this.count=n.turns;let i=Math.max(0,n.turns-2);this.first=Math.min(this.first??this.opening??i,i),this.opening=null,this.publish();let a=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||Ec(t.header.status))&&a.push(e)}await Promise.all(a.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 Dc(`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 Dc(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=ga([t,r]);try{return await Sc(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=ga([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 Dc(`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>=Tc&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Dc(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Dc(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function kc(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 Oc(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,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:i?.refresh??Ac,loadEarlier:i?.loadEarlier??Ac,showFrom:i?.showFrom??Ac,choose:i?.choose??Ac}}function Ac(){}function jc(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 Mc(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||q(r.value.proposal)!==q(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 Nc(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Pc(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Fc=e=>`cadence:prompt-history:${e}`;function Ic(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function Lc(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function Rc(e){try{let t=sessionStorage.getItem(Fc(e));return t?Ic(JSON.parse(t)):[]}catch{return[]}}function zc(e,t){let n=t;for(;n;)try{sessionStorage.setItem(Fc(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function Bc(e,t){let n=Rc(e),r=Lc(n,t);r!==n&&zc(e,r)}var Vc={index:-1,draft:``};function Hc(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:Vc,text:t.draft}}function Uc(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Wc(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!Uc(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function Gc(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var Kc=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function qc(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function Jc(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function Yc(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Xc=``;function Zc(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function Qc(e,t){return{first:!e.slice(0,t).includes(`
|
|
18
|
+
`),last:!e.slice(t).includes(`
|
|
19
|
+
`)}}var $c=null;function el(){if($c?.isConnected)return $c;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),$c=e,e}function tl(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function nl(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Xc,e.appendChild(n),n.offsetTop}function rl(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=Qc(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=el();if(tl(e,i)<=0)return r;let a=nl(i,t.slice(0,n)),o=nl(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Zc(a,o,Yc(e))}var il={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},al={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.`},ol=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,sl=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function cl(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>pe.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function ll(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(il[t.thinking])}`,[e])}function ul({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=ll(),_=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,ee]=(0,f.useState)(!1),[te,j]=(0,f.useState)(``),ne=(0,f.useRef)(null),re=(0,f.useRef)(null),ie=(0,f.useRef)(null),M=(0,f.useRef)(null),ae=(0,f.useRef)(c);ae.current=c,(0,f.useEffect)(()=>{k(``)},[e,b,x]);let N=(0,f.useCallback)((e=!0,t)=>{t?ae.current(!1,t):ae.current(!1),j(``),k(``),e&&re.current?.focus({preventScroll:!0})},[]);(0,f.useEffect)(()=>{if(!s)return;y&&ie.current?.focus({preventScroll:!0});let e=e=>{ne.current?.contains(e.target)||N(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,N,y]);let oe=E?.selected??null,P=i??oe??(v?r:null)??D?.remembered??null,F=(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]),se=D?.entries.find(e=>sl(e,P)),I=(_||!!v)&&!!D&&!C&&!S&&n.isCurrent(),L=async(t,r)=>{if(!I||!n.isCurrent()||!D||!t.api||A||o)return;let i=me({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),N(!0,`chosen`);else if(E&&e){if(oe&&ol(oe,i))N(!0,`chosen`),u?.(i);else{ee(!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(),N(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(k(`uncertain`),w())}finally{ee(!1)}}}},R=()=>[...M.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],z=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=R(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?ie.current?.focus():t[Math.min(n,t.length-1)]?.focus()},B=t.status===`stopped`||t.status===`not-started`,V=D?null:r,H=n.preview||n.loading&&a||S&&a?m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):B?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`),U=P?g(P):B&&V?m(`Last used: {model}`,{model:g(V)}):H;return(0,h.jsxs)(`div`,{className:`model-picker`,ref:ne,children:[(0,h.jsxs)(`button`,{ref:re,type:`button`,className:`model-trigger${P&&!oe||V?` remembered`:``}${D&&!P?` empty`:``}`,"aria-label":m(`Model: {model}`,{model:U}),"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.`):V?m(`Last used model; availability is checked when you send.`):P&&!oe?m(`Last used model; it is used again when you send.`):P?`${P.provider}/${P.model} · ${P.api}`:H,onClick:()=>{s?N():(k(``),c(!0))},children:[(0,h.jsx)(Yi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:U}),(0,h.jsx)(ia,{"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(),N())},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.`)}),V&&(0,h.jsxs)(`p`,{className:`model-popover-lead`,children:[m(`Last used: {model}`,{model:g(V)}),(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)(yi,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:ie,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(),R()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),R()[0]?.click())}})]}),y&&(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":m(`Models`),ref:M,onKeyDown:z,children:[C&&(0,h.jsx)(`p`,{className:`model-empty`,role:`status`,children:m(`Reading models…`)}),F.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=sl(e,P);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!I||!t||A||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void L(e,cl(e,P?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?m(`Credentials unavailable`):m(`Not supported`)}),n&&(!oe||!!i)&&(0,h.jsx)(`span`,{className:`model-option-note`,children:m(`Used when you send`)}),n&&(0,h.jsx)(aa,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),D?.status===`complete`&&F.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&&se&&se.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:m(`Thinking`)}),se.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":m(`Thinking level: {level}`,{level:m(il[e.level])}),"aria-pressed":P?.thinking===e.level,disabled:!I||!e.selectable||A||o,onClick:()=>void L(se,e.level),children:m(il[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:al[O]?m(al[O]):m(`The model was not changed ({code}).`,{code:O})}),I&&(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 dl({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]})}var fl=.1,pl=(e,t)=>Math.max(fl,Math.min(4,e*t));function ml({blob:e,label:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(null),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)({width:0,height:0}),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(null);(0,f.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let g=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;m(n=>pl(n??t,e))},_=(e,t,n,r=!1)=>(0,h.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,h.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,h.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,h.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,h.jsx)(`span`,{className:`img-lightbox-name`,children:t}),_(r(`Close`),(0,h.jsx)(ui,{"aria-hidden":`true`}),n)]}),(0,h.jsxs)(`div`,{className:`img-lightbox-image${p===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,h.jsx)(`img`,{ref:a,src:o,alt:t,style:p===null||!c.width?void 0:{width:c.width*p,height:c.height*p},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,h.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,h.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,h.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),_(r(`Zoom out`),(0,h.jsx)(ci,{"aria-hidden":`true`}),()=>g(1/1.25),!c.width||p!==null&&p<=.1),_(r(`Actual size`),(0,h.jsx)(ji,{"aria-hidden":`true`}),()=>m(1),!c.width||p===1),p!==null&&(0,h.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(p*100),`%`]}),_(r(`Zoom in`),(0,h.jsx)(li,{"aria-hidden":`true`}),()=>g(1.25),!c.width||p!==null&&p>=4),_(r(`Fit to window`),(0,h.jsx)(Oi,{"aria-hidden":`true`}),()=>m(null),p===null)]})]})})}function hl(){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])];vc(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)},[]),replace:(0,f.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function gl(e){let[t,n]=(0,f.useState)(null);return{open:n,lightbox:t&&(0,h.jsx)(ml,{blob:t,label:e,onClose:()=>n(null)})}}function _l({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,h.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function vl({file:e,disabled:t,remove:n}){let{t:r}=T(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(!1),{open:c,lightbox:l}=gl(e.name);return(0,f.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),yc(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)(_l,{url:i,alt:e.name,onOpen:()=>c(e)}),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`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function yl({image:e,read:t}){let{t:n}=T(),[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(!1),{open:s,lightbox:c}=gl(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:p}=e;return(0,f.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...p?{live:p}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,p]),(0,h.jsxs)(h.Fragment,{children:[a?(0,h.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,h.jsx)(_l,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,h.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function bl({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(yl,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var xl=`cadence:composer-height`,Sl=16;function Cl(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var wl=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,Tl=()=>wl(typeof window>`u`?0:window.innerHeight);function El({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:p,hint:m,running:g,canStop:_,onStop:v,canSend:y,onSend:x,input:S,historyScope:C,files:w,onResized:E}){let{t:D}=T(),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useId)(),[ee,te]=(0,f.useState)(()=>{try{return Cl(localStorage.getItem(xl))}catch{return null}}),[j,ne]=(0,f.useState)(64),[re,ie]=(0,f.useState)(``);(0,f.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Tl();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(ee===null?Math.max(r,64):ee,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,ne(i)},[t,ee,re,e]);let M=(0,f.useRef)(E);M.current=E,(0,f.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.offsetHeight,n=()=>{ie(`${e.clientWidth}:${window.innerHeight}`),e.offsetHeight!==t&&(t=e.offsetHeight,M.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let ae=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(te(n),t)try{n===null?localStorage.removeItem(xl):localStorage.setItem(xl,String(n))}catch{}},N=(0,f.useRef)(void 0);(0,f.useEffect)(()=>()=>N.current?.(),[]);let oe=(0,f.useRef)(Vc),P=(0,f.useRef)(null);(0,f.useEffect)(()=>{t!==P.current&&(oe.current=Vc)},[t]);let F=(0,f.useRef)(null),[se,I]=(0,f.useState)(-1);(0,f.useLayoutEffect)(()=>{let t=e.current;t&&F.current!==null&&(t.setSelectionRange(F.current,F.current),I(F.current),F.current=null)},[t,e]);let L=e=>{P.current=e,F.current=e.length,n(e)},[R,z]=(0,f.useState)(!1),[B,V]=(0,f.useState)(-1),[H,U]=(0,f.useState)(null),{location:W}=w,G=W&&R&&!r&&H===t?Wc(t,se):null,K=Gc(G?.query??``),ce=G!==null&&G.start!==B&&Kc(K.folder),q=Ba(w.client,ce&&W?{kind:`files`,path:K.folder,location:W}:null),le=q.value?.kind===`files`?q.value:void 0,J=le?qc(le.entries,K.name):[],[ue,Y]=(0,f.useState)(0),de=G?`${G.start}:${G.query}`:``;(0,f.useEffect)(()=>{Y(0),de||V(-1)},[de]);let fe=Math.min(ue,J.length-1),pe=J[fe],me=pe?`${A}-${fe}`:void 0;(0,f.useEffect)(()=>{me&&document.getElementById(me)?.scrollIntoView({block:`nearest`})},[me]);let he=e=>{if(!G)return;let r=Jc(t,G,se,e);F.current=r.cursor,U(r.text),n(r.text)},ge=e=>{if(!e.nativeEvent.isComposing){if(ce){if(e.key===`Escape`){e.preventDefault(),V(G.start);return}if(pe){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;Y((fe+t+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),he(pe);return}}}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){let n=e.key===`ArrowUp`;if(!n&&oe.current.index===-1)return;let r=rl(e.currentTarget);if(n?!r.first:!r.last)return;let i=Hc(Rc(C),oe.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),oe.current=i.cursor,L(i.text)}else if(e.key===`Escape`&&oe.current.index!==-1){e.preventDefault();let t=oe.current.draft;oe.current=Vc,L(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),g&&S?S.enabled&&S.onInput(e.altKey?`queue`:`steer`):x())}},_e=D(ee===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,h.jsxs)(`form`,{ref:O,className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),g||x()},children:[(0,h.jsx)(`input`,{type:`range`,className:`composer-resize${ee===null?``:` is-manual`}`,min:64,max:320,step:Sl,value:Math.round(j),"aria-label":_e,title:_e,"aria-orientation":`vertical`,"aria-valuetext":ee===null?D(`Automatic`):D(`{pixels} pixels`,{pixels:Math.round(j)}),onChange:e=>ae(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),ae(null,!0))},onDoubleClick:()=>ae(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),N.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??j,i=null,a=e=>{i=Math.min(Tl(),Math.max(64,r+(n-e.clientY))),ae(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),N.current=void 0,i!==null&&ae(i,!0)};N.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,h.jsx)(`input`,{ref:k,type:`file`,accept:Un.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":D(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,h.jsx)(vl,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),ce&&(0,h.jsxs)(`div`,{className:`mention-menu`,id:A,role:`listbox`,"aria-label":D(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:[(0,h.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,h.jsx)(`span`,{className:`mention-menu-folder`,children:K.folder?`@${K.folder}`:D(`Files in the conversation folder`)}),(0,h.jsx)(`span`,{children:D(`Enter inserts the path · Esc closes`)})]}),q.error?(0,h.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:b(D,q.error)}):le?J.length===0?(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`No matching files`)}):null:(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`Reading files…`)}),J.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,role:`option`,id:`${A}-${t}`,className:`mention-item${e===pe?` active`:``}`,"aria-selected":e===pe,tabIndex:-1,title:e.path,onMouseEnter:()=>Y(t),onClick:()=>he(e),children:[e.directory?(0,h.jsx)(Hi,{"aria-hidden":`true`}):(0,h.jsx)(Ui,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,h.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),le?.limited&&(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`Bounded listing; narrow the directory to see more.`)})]}),(0,h.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":D(`Message`),"aria-autocomplete":W?`list`:void 0,"aria-controls":ce?A:void 0,"aria-activedescendant":ce?me:void 0,value:t,placeholder:D(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{I(e.target.selectionStart),U(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;I(t===n?t:-1)},onFocus:()=>z(!0),onBlur:()=>z(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:ge}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":D(`Add images`),title:D(`Add images`),onClick:()=>k.current?.click(),children:(0,h.jsx)(Li,{"aria-hidden":`true`})}),(0,h.jsx)(dl,{...d}),(0,h.jsx)(ul,{...p}),(0,h.jsx)(`span`,{className:`composer-hint`,children:m}),g&&S?.enabled&&(0,h.jsxs)(`span`,{className:`composer-split`,children:[(0,h.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":D(`Queue behind this reply`),title:D(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>S.onInput(`queue`),children:(0,h.jsx)(Ni,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":D(`Steer this reply`),title:D(`Steer: read at the model's next step (Enter)`),onClick:()=>S.onInput(`steer`),children:(0,h.jsx)(sa,{"aria-hidden":`true`})})]}),g?(0,h.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":D(`Stop response`),title:D(`Stop response`),disabled:!_,onClick:v,children:(0,h.jsx)(hi,{"aria-hidden":`true`})}):(0,h.jsx)(`button`,{"aria-label":D(`Send`),title:D(`Send`),type:`submit`,className:`primary`,disabled:!y,children:(0,h.jsx)(sa,{"aria-hidden":`true`})})]})]})}function Dl(e){let t=e.items.map(e=>({...jr(e,1),text:e.role===`tool`||e.role===`thinking`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,...e.retry?{retry:e.retry}:{},omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function Ol(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:{}}var kl={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,py:`python`,rs:`rust`,go:`go`,java:`java`,kt:`kotlin`,swift:`swift`,rb:`ruby`,php:`php`,lua:`lua`,pl:`perl`,r:`r`,cs:`csharp`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,md:`markdown`,sql:`sql`,diff:`diff`,patch:`diff`,graphql:`graphql`,mk:`makefile`};function Al(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(kl,n)&&kl[n]||`plaintext`}var jl=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function Ml(e,t){let n={oldTokens:[{type:`del`,text:e}],newTokens:[{type:`add`,text:t}]};if(!e||!t||e.length>800||t.length>800)return n;let r=e.match(jl)||[e],i=t.match(jl)||[t],a=r.length,o=i.length;if(a*o>4e3)return n;let s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=r[e-1]===i[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);if(s[a][o]/Math.max(a,o)<.25)return n;let c=[],l=[],u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(c.push({type:`same`,text:r[u-1]}),l.push({type:`same`,text:i[d-1]}),u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l.push({type:`add`,text:i[d-1]}),d--):(c.push({type:`del`,text:r[u-1]}),u--);let f=e=>{let t=[];for(let n of e.reverse()){let e=t.at(-1);e?.type===n.type?e.text+=n.text:t.push({...n})}return t};return{oldTokens:f(c),newTokens:f(l)}}function Nl(e){if(!e)return[];let t=e.split(`
|
|
20
|
+
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function Pl(e){let t=0,n=0;return{hunks:e.map(e=>{let r=typeof e.oldText==`string`?e.oldText:``,i=typeof e.newText==`string`?e.newText:``,a=Nl(r),o=Nl(i);n+=a.length,t+=o.length;let s=[];if(a.length===1&&o.length===1){let{oldTokens:e,newTokens:t}=Ml(a[0],o[0]);s.push({type:`del`,content:a[0],tokens:e}),s.push({type:`add`,content:o[0],tokens:t})}else{for(let e of a)s.push({type:`del`,content:e});for(let e of o)s.push({type:`add`,content:e})}return{removed:a.length,added:o.length,lines:s}}),additions:t,deletions:n}}var Fl=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function Il(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!Fl(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:Al(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=Nl(n.content);return{...i,isWrite:!0,additions:e.length,deletions:0,hunks:[{removed:0,added:e.length,lines:e.map(e=>({type:`add`,content:e}))}]}}let a=[...Array.isArray(n.edits)?n.edits.filter(Fl):[],...typeof n.oldText==`string`||typeof n.newText==`string`?[{oldText:n.oldText,newText:n.newText}]:[]];return a.length===0?null:{...i,isWrite:!1,...Pl(a)}}function Ll({line:e}){return(0,h.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,h.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,h.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,h.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function Rl({data:e,failed:t=!1}){let{t:n}=T(),[r,i]=(0,f.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,h.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,h.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,h.jsxs)(`div`,{className:`file-diff-info`,children:[(0,h.jsx)(Wi,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,h.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,h.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,h.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,h.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,h.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,h.jsx)(pa,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]})]}),(0,h.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,h.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,h.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,h.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,h.jsx)(`div`,{className:`diff-hunk-header`,children:(0,h.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,h.jsx)(Ll,{line:e},t))]},r))})}),!r&&a>400&&(0,h.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function zl(e){let t=e.map((e,t)=>({step:e,index:t}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var Bl={bash:[pi,`exec`],powershell:[pi,`exec`],read:[Wi,`read`],ls:[Hi,`read`],write:[Ki,`edit`],edit:[qi,`edit`],grep:[yi,`search`],find:[$i,`search`]},Vl=[fi,`default`],Hl=e=>Object.hasOwn(Bl,e)?Bl[e]:Vl;function Ul(e,t){let{header:n,steps:r}=e;if(r[t]?.error)return`err`;let i=n.status===`queued`||n.status===`running`;return i&&t>=n.stable?`run`:n.status===`completed`||i||r.slice(t+1).some(e=>e.role===`assistant`)?`ok`:`idle`}var Wl={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function Gl(){return(0,h.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,h.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function Kl({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,h.jsx)(Io,{text:e})}){let{t:a}=T(),o=t<e.header.stable,s=Ol(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(bl,{images:n.images,turn:e}):null,c.trim()!==``&&(0,h.jsxs)(`div`,{className:`msg-text single`,children:[(0,h.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,h.jsx)(Ao,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,h.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?b(a,s.error):a(`Reading the rest of this message…`)})]})}function ql(e){try{let t=JSON.parse(e),n=t&&typeof t==`object`&&Object.hasOwn(t,`command`)?t.command:void 0;return typeof n==`string`&&n?n:void 0}catch{return}}function Jl(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Yl({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=Ol(e,t,n,i),[s,c]=Hl(n.name),l=Ul(e,t),u=r(Wl[l]),d=o.value?.args,p=d?ql(d):void 0,m=(0,f.useMemo)(()=>d?Il(n.name,d):null,[n.name,d]);return(0,h.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,h.jsx)(vs,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,h.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,h.jsx)(ui,{"aria-hidden":`true`}):l===`ok`?(0,h.jsx)(aa,{"aria-hidden":`true`}):l===`run`?(0,h.jsx)(Gl,{}):(0,h.jsx)(Di,{"aria-hidden":`true`})}),n.target&&(0,h.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,h.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,h.jsx)(Ao,{text:n.target,className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,h.jsx)(`div`,{className:`toolcall-body`,children:n.parts===0?(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`div`,{className:`toolcall-args`,children:m?(0,h.jsx)(Rl,{data:m,failed:l===`err`}):p?(0,h.jsxs)(`div`,{className:`termline`,children:[(0,h.jsx)(pi,{className:`termline-icon`,"aria-hidden":`true`}),(0,h.jsx)(`code`,{children:p})]}):(0,h.jsx)(`pre`,{children:Jl(o.value.args)})}),o.value.text&&(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(n.error?`Error output`:`Output`)}),(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 Xl=/^\s{0,3}(`{3,}|~{3,})/,Zl=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Ql(e){return e.trim()===``}function $l(e){let t=Xl.exec(e);return t?t[1]:null}function eu(e){let t=e.split(`
|
|
21
|
+
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=$l(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=$l(a);if(o&&!Ql(a))i=o,r.push(a);else if(Ql(a)){let i=e;for(;i<t.length&&Ql(t[i]);)i++;if(!(i<t.length&&Zl.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
17
22
|
`)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
|
|
18
|
-
`),inFence:i!==null}}function
|
|
19
|
-
|
|
20
|
-
`)})
|
|
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(``),lc(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(qr,{"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 cc({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?.runtime&&(0,h.jsx)(`p`,{children:e.display.runtime}),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)(La,{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)(La,{text:ir(e.plan)})]}),e.delivery&&(0,h.jsx)(La,{text:$n(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 lc(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 uc(e){return(0,h.jsx)(dc,{...e},e.id)}function dc({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=ea(e,{kind:`workflow`,id:t},o),d=ea(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=ea(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)(fc,{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:cr(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),` · `,To(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(La,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:To(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),lc(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 fc({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 pc=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function mc(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function hc({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,prepareForSend:u,legacyWorkspaceId:d,directoryNamespaces:p=[],available:m=c,canInterrupt:g=c,modelAvailability:_,previewModels:v,initialDraft:y,onDraftApplied:x,onModelChanged:S,onChanged:C,reference:w,onReferenceUsed:E,hidden:D=!1,onOpenAgent:ee,onWorkflowRuns:O}){let{t:k,tx:A}=T(),[j]=(0,f.useState)(()=>Go(n,t,d,...p)),[M,ne]=(0,f.useState)(()=>mc(j,y?.text));(0,f.useEffect)(()=>{y&&x?.()},[y,x]);let N=ys(),P=N.remove,F=(0,f.useRef)([]),I=(0,f.useRef)(null),[L,R]=(0,f.useState)(()=>mc(`${j}:mode`)===`cadence`?`cadence`:`chat`),[z,B]=(0,f.useState)(!1),[V,H]=(0,f.useState)(``),[U,re]=(0,f.useState)(()=>mc(`${j}:pending`)),[G,ie]=(0,f.useState)(()=>mc(`${j}:model-command`)),[ae,oe]=(0,f.useState)(!1),[se,ce]=(0,f.useState)(!1),[le,ue]=(0,f.useState)(!1),[de,fe]=(0,f.useState)(0),pe=(0,f.useRef)(null),me=(0,f.useRef)(!1),he=(0,f.useRef)(0),ge=(0,f.useRef)(new AbortController),[_e,ve]=(0,f.useState)(!1),[ye,be]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(`${j}:model`);if(e)return K(JSON.parse(e))}catch{}return y?.model??null});(0,f.useEffect)(()=>{try{ye?sessionStorage.setItem(`${j}:model`,JSON.stringify(ye)):sessionStorage.removeItem(`${j}:model`)}catch{}},[j,ye]);let xe=ea(e,m&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),Se=xe.value?.kind===`conversation-context`?xe.value.context:void 0,Ce=!!Se&&!xe.error,we=Se?.cwd??r,Te=(0,f.useMemo)(()=>({models:n=>we?e.models(n,{id:t,cwd:we}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>we?e.chooseModel(n,{id:t,cwd:we}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,we]),Ee=_e?{status:`preparing`}:_.status===`ready`&&(!m||!Ce)?{status:xe.error?`unavailable`:`connecting`}:_,De=(0,f.useRef)(Ee);De.current=Ee;let q=as(Te,Ee,`${de}:${Se?.revision??`unobserved`}`,v),Oe=()=>{pe.current=null,ce(!1),ue(!1)},ke=(e,t)=>{e&&!q.preview&&!q.loading?q.reread():!e&&t!==`chosen`&&Oe(),oe(e)},Ae=(e,t)=>{be(t?null:e);let n=pe.current;se&&n&&(Vo(n,De.current)===`cancel`?(Oe(),H(k(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(pe.current=Bo(n,e,t),ce(!1),H(``),ue(!0)))},je=(0,f.useRef)(o);je.current=o,(0,f.useEffect)(()=>{Ce&&we&&je.current?.({id:t,cwd:we})},[Ce,t,we]);let J=rs(e,t,m,i),{turns:Me}=J,Ne=J.summary!==void 0,Pe=ea(e,m?{kind:`cadence-conversation`,id:t}:null,1e3),Y=Pe.value?.kind===`cadence-conversation`?Pe.value.state:void 0,Fe=Y?.enabled===!0,Ie=!!Y||!!Pe.error,Le=!!Y&&!Pe.error&&!Y.notice,Re=(0,f.useRef)(Y);Re.current=Y;let[ze,Be]=(0,f.useState)(``),Ve=(0,f.useRef)(``),He=ta(M,Fe?`cadence`:L),Ue=c&&!(a&&!J.summary)&&Ce&&Ne&&!J.error&&Ie&&!(Fe&&(Pe.error||Y?.notice))&&!z&&!se&&!U,X=J.summary??void 0,We=X&&(X.status===`queued`||X.status===`running`),Ge=!!X&&X.status!==`completed`&&!We,Ke=Me.at(-1)?.header,qe=We?Ke&&[`queued`,`running`].includes(Ke.status)?Ke.at:0:null,Je=(0,f.useRef)(s);Je.current=s,(0,f.useEffect)(()=>{Je.current?.({id:t,turns:J.count,runningSince:qe})},[t,J.count,qe]);let[Ye,Xe]=(0,f.useState)(!1),Ze=!!u&&c&&(!!J.error||!!xe.error)&&J.error!==`retired-conversation`&&xe.error!==`retired-conversation`&&!Y?.notice&&!We&&!z&&!U&&!se,Qe=(g||!!u)&&Ce&&Ne&&Le&&!J.error&&!z&&!U&&!We,$e=!!ye&&W(ye)!==W(Se?.model??null),et=!!Y?.proposal&&!!X&&!We&&X.status!==`unknown`,tt=$e?k(`Send with this model before approving a plan.`):X?.status===`unknown`?k(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?Le?We?k(`Wait for the current reply before approving this plan.`):ze?k(`Observing plan approval…`):Ue?void 0:k(`Read the current conversation context before approving this plan.`):k(`Cadence state unavailable`):k(`Read the current execution state before approving this plan.`),nt=(0,f.useRef)(null),rt=(0,f.useRef)(null),Z=(0,f.useRef)(0),it=(0,f.useRef)(!0),[at,ot]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!D&&rt.current&&!it.current&&(rt.current.scrollTop=Z.current)},[D]);let st=(0,f.useRef)(!0),ct=(0,f.useRef)(``),lt=(0,f.useRef)(M);(0,f.useEffect)(()=>(st.current=!0,ge.current.signal.aborted&&(ge.current=new AbortController),()=>{st.current=!1,ge.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${j}:mode`,L)}catch{}},[j,L]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(j,M)}catch{}},[M,j]),(0,f.useEffect)(()=>{try{U?sessionStorage.setItem(`${j}:pending`,U):sessionStorage.removeItem(`${j}:pending`)}catch{}},[j,U]),(0,f.useEffect)(()=>{try{U&&G===U?sessionStorage.setItem(`${j}:model-command`,G):sessionStorage.removeItem(`${j}:model-command`)}catch{}},[j,U,G]),(0,f.useEffect)(()=>{w&&(ne(e=>`${e}${e?`
|
|
22
|
-
`:``}@${w}`),E(),nt.current?.focus())},[w,E]),(0,f.useEffect)(()=>{let e=X?`${X.leaf}:${X.status}`:``;e&&ct.current!==e&&(ct.current=e,C()),Ve.current&&Y?.runs.includes(Ve.current)&&(Ve.current=``,Be(``),H(``)),U&&(X?.live?.commandId===U||J.attempt?.commandId===U||Me.some(e=>e.header.id===U)||J.commands.includes(U))&&(re(``),Ho(U,G)&&be(null),ie(``),P(F.current),ne(e=>e===lt.current?``:e),C()),it.current&&rt.current&&(rt.current.scrollTop=rt.current.scrollHeight)},[X,Me,U,G,C,Y,J,P]);let ut=(0,f.useMemo)(()=>Me.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})),[Me]),dt=ho(rt,ut),{earlier:ft,loadEarlier:pt}=J,mt=()=>{let e=rt.current;e&&!D&&ft&&e.scrollTop<1200&&pt()};(0,f.useEffect)(mt);let ht=Me[0]?.ordinal,gt=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=rt.current;if(!e)return;let t=gt.current;!pc&&!it.current&&t.ordinal!==void 0&&ht!==void 0&&ht<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),gt.current={ordinal:ht,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${j}:approval`)}catch{}},[j]);let _t=(0,f.useMemo)(()=>[...new Set([...J.runs,...Y?.runs??[]])],[J.runs,Y?.runs]),vt=JSON.stringify(_t.slice(-4));(0,f.useEffect)(()=>{O?.(JSON.parse(vt))},[vt,O]);let[yt,bt]=(0,f.useState)({terminal:8,browser:8}),xt=(0,f.useMemo)(()=>[...new Set([...J.runs.slice(-yt.terminal),...(Y?.runs??[]).slice(-yt.browser)])],[J.runs,Y?.runs,yt]),St=Oo(e,m?xt:[],1e3),Ct=Me.find(e=>e.header.at>0)?.header.at,wt=!ft&&Me.length>0;(0,f.useEffect)(()=>{if(!m)return;let e=(e,t)=>ac(e,t,St.runs,St.unreadable,Ct,wt),t=e(J.runs,yt.terminal),n=e(Y?.runs??[],yt.browser);(t!==yt.terminal||n!==yt.browser)&&bt({terminal:t,browser:n})},[m,J.runs,Y?.runs,yt,St,Ct,wt]);let Tt=(0,f.useMemo)(()=>ic(Me,St.runs.values(),ft),[Me,St.runs,ft]),Et=[...St.runs.values()].filter(tc).at(-1),Dt=[...St.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{Dt&&it.current&&rt.current&&(rt.current.scrollTop=rt.current.scrollHeight)},[Dt]);let Ot=t=>(0,h.jsx)(sc,{client:e,run:t,onOpen:()=>ee?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{Pe.refresh(),C()}},t.id),kt=async()=>{if(!Y?.proposal){H(k(`No plan is awaiting approval.`));return}if($e||!l||!Le||!Ue||We||ze||!et)return;let t=Y,n=he.current;B(!0),H(``);try{let r=await os({client:e,state:t,current:()=>st.current&&he.current===n&&Re.current?.revision===t.revision&&Re.current?.enabled===!0,submitting:e=>{Ve.current=e,Be(e)}});if(!st.current||he.current!==n)return;r.kind===`error`?(H(r.error.code),Be(``)):ne(e=>cs(e)?``:e)}catch(e){st.current&&he.current===n&&H(e instanceof Error?e.message:`unavailable`)}finally{st.current&&he.current===n&&(B(!1),Pe.refresh(),J.refresh(),C())}},At=async(n,r)=>{let i=r?.text??n??M,a=r?.images??(n?[]:N.files),o=r?r.command.kind===`cadence-exit`:Fe&&ss(i);if(!(o?Qe:Ue)&&!Ze||We||!i.trim()&&!a.length||r&&(!Ue||Vo(r,De.current)!==`ready`))return;if(o&&a.length){H(k(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Fe&&cs(i)){l?await kt():H(k(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let s=ta(i,L).mode===`cadence`;if(!Ze&&(Fe||s)&&!Le){H(k(`Cadence state unavailable. Observe the conversation before sending.`));return}if(me.current)return;me.current=!0,B(!0),H(``);let c=he.current,d=()=>st.current&&he.current===c,f=!1,p=`not-dispatched`,m=e=>{d()&&(re(e),ie(e&&!o?e:``))},h=async e=>{u&&(ve(!0),await jo(u,ge.current.signal,e,e=>{p=e}),d()&&(ve(!1),fe(e=>e+1)))};try{if(Ze){if(await h(Se?{id:t,cwd:Se.cwd}:void 0),!d())return;J.refresh(),xe.refresh(),Pe.refresh(),C(),H(k(`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??Fo({id:t,head:J.leaf,text:i,images:a,revision:Y?.revision??0,location:Se?{id:t,cwd:Se.cwd}:void 0,installModel:!!ye,model:ye??(q.catalog?.selected?Io(q.catalog.selected):q.catalog?.remembered??Se?.model??q.preview?.remembered??void 0),intent:o?`exit`:Fe?`message`:s?`enter`:`ordinary`});if(r){if(Vo(r,De.current)!==`ready`)throw Error(`stale`)}else await h(n.location);if(!d())return;if(n.command.kind===`cadence-exit`){let t=Wo(n);lt.current=i,f=!0;let r=await Po(e,t,m);if(!d())return;r.kind===`error`?H(k(No(r.error.effect),{code:r.error.code})):(re(``),R(`chat`),ne(e=>e===i?``:e)),Pe.refresh(),J.refresh(),C();return}let c=e=>{let t=De.current,r=e??(t.status===`ready`?t.epoch:void 0);r&&Vo(zo(n,r),t)!==`cancel`?(pe.current=zo(n,r),ce(!0)):(Oe(),H(k(`The connection changed. Your model choice and draft are kept; send again when ready.`))),ke(!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=Lo(n,u)),n.installModel&&l.kind===`ok`){if(l={kind:`ok`,value:await Uo(e,n,l.value,d)},!d())return;fe(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`){H(t.error.code),c(l.value.version.epoch);return}if(l=await e.models(void 0,n.location),!d())return;fe(e=>e+1)}if(l.kind!==`ok`||!l.value.selected){c(l.kind===`ok`?l.value.version.epoch:void 0);return}Ro(n,l.value.selected);let g=Wo(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)){H(k(`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 Yo(e,g,n.images,d),!d())return}F.current=n.images,lt.current=i,f=!0;let _=await Po(e,g,m);if(!d())return;_.kind===`error`?H(k(No(_.error.effect),{code:_.error.code})):(P(F.current),be(null),ne(e=>e===lt.current?``:e),re(``),g.kind===`cadence-send`&&R(`chat`),Nt(null)),Pe.refresh(),J.refresh(),C()}catch(e){d()&&H(k(f?No():Mo(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{he.current===c&&(me.current=!1),d()&&(B(!1),ve(!1))}},jt=(0,f.useRef)(At);jt.current=At,(0,f.useEffect)(()=>{let e=pe.current;if(!e||!le&&!se)return;let t=Vo(e,Ee);t===`cancel`?(pe.current=null,ce(!1),ue(!1),H(k(`The connection changed. Your model choice and draft are kept; send again when ready.`))):le&&t===`ready`&&Ue&&!We&&(ue(!1),pe.current=null,jt.current(void 0,e))},[le,se,Ue,We,Ee,k]),(0,f.useEffect)(()=>{if(!le)return;let e=setTimeout(()=>{ue(!1),pe.current=null},1e4);return()=>clearTimeout(e)},[le]);let Mt=async()=>{let n=X?.live;if(!n||z)return;B(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});st.current&&(r.kind===`error`&&H(r.error.code),B(!1),J.refresh())},Nt=e=>{++he.current,ge.current.abort(),ge.current=new AbortController,pe.current=null,me.current=!1,ce(!1),ue(!1),oe(!1),B(!1),ve(!1),J.choose(e),Xe(!1)},Pt=z||se||!!U||!!We,Ft=e=>{if(!Pt)try{N.add(e),H(``)}catch(e){H(A(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:D,"aria-label":k(Le?Fe?`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)(ti,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:X?.title??(a?k(`Discovered session`):J.summary===null?k(`New conversation`):k(`Conversation`))}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:k(Le?Fe?`Cadence on`:`Ordinary`:`Cadence state unavailable`)}),X&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:X.origin===`terminal`?k(`Started in the terminal`):k(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(J.branches>1||J.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":Ye,onClick:()=>Xe(e=>!e),children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),k(`Branches ({count})`,{count:J.branches})]}),J.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Nt(null),children:k(`Show the latest`)}),Et&&(0,h.jsx)(`span`,{className:`ep-state running`,children:A(rc(Et))}),X&&(!Et||Ge||Fe&&!We&&!!Y?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${X.status}`,children:Fe?We?k(`Discussing`):Ge?A(X.status):Y?.proposal?k(`Awaiting plan approval`):k(`Ready for conversation`):A(X.status)})]})]}),xe.error&&!Ze&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(k,xe.error)}),Ze&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:k(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),_e&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:k(`Preparing execution for this Send…`)}),Ye&&(0,h.jsx)(_s,{client:e,id:t,leaf:J.leaf,onChoose:Nt,onClose:()=>Xe(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,h.jsxs)(`div`,{className:`chat-messages`,ref:rt,onScroll:()=>{let e=rt.current;e&&!D&&(Z.current=e.scrollTop,it.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,ot(!it.current),mt())},children:[a&&!J.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:k(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!m&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:k(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),J.summary===null&&!J.error&&!a&&(0,h.jsx)($s,{hint:k(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),m&&!J.error&&(!Ne||Me.length===0&&J.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:k(`Reading this conversation…`)}),Me.length>0&&ft&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:J.loadingEarlier&&k(`Reading earlier messages…`)}),Tt.start.map(Ot),ut.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(go,{id:e,show:!dt.hidden.has(e),height:dt.placeholder(e,t,320),containerRef:rt,onMeasured:dt.recordMeasured,lazyRef:dt.register(e),children:(0,h.jsx)(Qs,{turn:n})}),Tt.after.get(e)?.map(Ot),n.header.entry&&n.ordinal<J.count-1&&!We&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:k(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>Nt(n.header.entry),children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),k(`Continue from here`)]})]},e)),Tt.end.map(Ot),J.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":k(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:J.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${J.attempt.status}`,children:A(J.attempt.status)}),` `,J.attempt.notice?A(J.attempt.notice):``]})]}),Y?.enabled&&Y.proposal&&(0,h.jsx)(cc,{proposal:Y.proposal,canApprove:!$e&&l&&Ue&&Le&&et&&!We&&!ze,approvalHint:tt,onApprove:()=>void kt()}),Y?.enabled&&!Y.proposal&&_t.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:k(`Cadence stays on for this conversation until you explicitly exit.`)}),St.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:k(`Workflow activity unavailable; retained work may still be running.`)}),Y?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:A(Y.notice)}),[...new Set([V,J.error,Pe.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(k,e??``)},e)),J.error&&J.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:k(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),U&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[k(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:U}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:J.refresh,children:k(`Observe current state`)})]}),J.pinned&&!We&&(0,h.jsx)(`p`,{className:`inspector-note`,children:k(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),at&&(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{rt.current&&(rt.current.scrollTop=rt.current.scrollHeight),it.current=!0},children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),k(`Latest messages`)]})]}),(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(),Ft(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),At()},children:[(0,h.jsx)(`input`,{ref:I,type:`file`,accept:Fn.join(`,`),multiple:!0,hidden:!0,disabled:Pt,"aria-label":k(`Add images`),onChange:e=>{Ft(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)(bs,{file:e,disabled:Pt,remove:()=>P([e])},N.key(e)))}),!We&&!Ze&&!Ue&&!_e&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:k(U?`The last Send is not yet confirmed. No message is resent.`:se?`Choose a model; your message is sent right after.`:z?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`)}),(0,h.jsx)(`textarea`,{ref:nt,disabled:z||!!U||se,"aria-label":k(`Message`),value:M,placeholder:k(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>ne(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),Ft(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),At())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:Pt,"aria-label":k(`Add images`),title:k(`Add images`),onClick:()=>I.current?.click(),children:(0,h.jsx)(oi,{"aria-hidden":`true`})}),(0,h.jsx)(vs,{active:Fe,armed:He.mode===`cadence`,known:Le,disabled:Fe?!Qe:!!We||z||!!U||se,onClick:()=>{Fe?At(`exit cadence`):He.mode===`cadence`?(R(`chat`),ta(M,`chat`).mode===`cadence`&&ne(He.text)):R(`cadence`)}}),(0,h.jsx)(hs,{client:Te,availability:Ee,read:q,lastModel:Se?.model,draftModel:ye,onPreviewChoice:v?e=>Ae(e,!1):void 0,locked:!!We||z||!!U,open:ae,onOpenChange:ke,onChanged:()=>{xe.refresh(),S()},onChosen:e=>Ae(e,!0),awaitingSend:se}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Fe?k(`Cadence stays on. Confirm one plan before implementation.`):He.mode===`cadence`?k(`Your next message turns on Cadence mode.`):``}),We?(0,h.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":k(`Stop response`),title:k(`Stop response`),disabled:z||!g,onClick:()=>void Mt(),children:(0,h.jsx)(qr,{"aria-hidden":`true`})}):(0,h.jsx)(`button`,{"aria-label":k(`Send`),title:k(`Send`),type:`submit`,className:`primary`,disabled:!(Fe&&ss(M)?Qe:Ue)&&!Ze||!M.trim()&&!N.files.length,children:(0,h.jsx)(Di,{"aria-hidden":`true`})})]})]})]})}var gc=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function _c(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}function vc({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,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(!1),{copied:y,copy:x}=Ta(),S=ea(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),C=ea(e,t&&s?{kind:`file`,path:s,...n?{location:n}:{}}:null),w=S.value?.kind===`files`?S.value:void 0,E=C.value?.kind===`file`?C.value:void 0,D=e=>{o(e),p(null)},ee=d?.trim().toLowerCase()??``,O=w?.entries.filter(e=>!ee||e.name.toLowerCase().includes(ee));return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsx)(`button`,{type:`button`,className:`crumb${a?``:` active`}`,title:n?`${i(`Conversation folder:`)} ${n.cwd}`:void 0,disabled:!n,onClick:()=>D(``),children:n?gc(n.cwd):i(`Not observed`)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:i(`Refresh files`),"aria-label":i(`Refresh files`),disabled:!t,onClick:()=>{S.refresh(),C.refresh()},children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${d===null?``:` active`}`,"aria-label":i(`Filter this folder…`),title:i(`Filter this folder…`),"aria-pressed":d!==null,disabled:!w,onClick:()=>p(d===null?``:null),children:(0,h.jsx)(Xr,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${_?` active`:``}`,"aria-label":i(`About this panel`),title:i(`About this panel`),"aria-expanded":_,onClick:()=>v(e=>!e),children:(0,h.jsx)(ci,{"aria-hidden":`true`})}),_c(a).map(e=>(0,h.jsxs)(`span`,{className:`crumb-seg`,children:[(0,h.jsx)(wi,{"aria-hidden":`true`}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${e.path===a?` active`:``}`,title:e.path,onClick:()=>D(e.path),children:e.label})]},e.path))]}),_&&(0,h.jsx)(`p`,{className:`files-policy`,children:i(`Readonly preview · references send paths, not file contents`)}),d!==null&&(0,h.jsxs)(`label`,{className:`file-filter`,children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{autoFocus:!0,value:d,"aria-label":i(`Filter this folder…`),placeholder:i(`Filter this folder…`),onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Escape`&&p(null)}}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":i(`Close`),onClick:()=>p(null),children:(0,h.jsx)(Wr,{"aria-hidden":`true`})})]}),S.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(i,S.error)}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[t?!w&&!S.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.`)}),w&&w.parent!=null&&!ee&&(0,h.jsxs)(`button`,{type:`button`,className:`file-item dir`,"aria-label":i(`Parent folder`),title:i(`Parent folder`),onClick:()=>D(w.parent??``),children:[(0,h.jsx)(di,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:`..`})]}),O?.map(e=>(0,h.jsxs)(`div`,{className:`file-item ${e.directory?`dir`:`file`}${s===e.path?` selected`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-main`,title:e.path,onClick:()=>e.directory?D(e.path):c(e.path),children:[e.directory?(0,h.jsx)(di,{className:`file-icon`,"aria-hidden":`true`}):(0,h.jsx)(fi,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach`,"aria-label":i(`Reference {path}`,{path:e.name}),title:i(`Reference {path}`,{path:e.name}),disabled:!t||!!S.error,onClick:()=>r(e.path),children:(0,h.jsx)(ii,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach${y&&m===e.path?` copied`:``}`,"aria-label":i(`Copy path {path}`,{path:e.name}),title:i(`Copy path {path}`,{path:e.name}),onClick:()=>{g(e.path),x(e.path).then(e=>u(e?``:i(`Link copy unavailable.`)))},children:y&&m===e.path?(0,h.jsx)(Ei,{"aria-hidden":`true`}):(0,h.jsx)(bi,{"aria-hidden":`true`})})]},e.path)),t&&!S.error&&O?.length===0&&(ee?(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No matching files`)}):(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No visible files`)})),w?.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)(fi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{title:s,children:gc(s)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":i(`Close preview`),title:i(`Close preview`),onClick:()=>c(null),children:(0,h.jsx)(Wr,{"aria-hidden":`true`})})]}),C.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(i,C.error)}),E&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:E.text}),E.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})]})}var yc=`未命名章节`;function bc(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 xc(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=bc(r||yc),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||yc}})}function Sc(e){return e.length>=2}function Cc(e){let t=0,n=0;return e.split(`
|
|
23
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function wc({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:Cc(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 Tc({text:e}){let{t}=T(),[n,r]=(0,f.useState)(`raw`),[i,a]=(0,f.useState)(!0),[o,s]=(0,f.useState)(1),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(null),p=(0,f.useRef)(1),m=(0,f.useRef)(null),g=e.split(`
|
|
24
|
-
`);return(0,f.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(m.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=xc(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)(ja,{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:[Sc(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)(La,{text:e})})]}):n===`diff`?(0,h.jsx)(wc,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Cc(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 Ec({client:e,seed:t}){let{t:n,tx:r}=T(),i=xa(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ja,{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(ya(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)(qa,{client:e,cursor:a,render:e=>(0,h.jsx)(Tc,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Dc=[`contents`,`checks`,`changes`,`reviews`];function Oc({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:Dc.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)(Ya,{client:e,seed:t}):(0,h.jsx)(Ec,{client:e,seed:{...t,reader:i}},i)})]})}var kc={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.`},Ac=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function jc(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 Mc({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||(Ac(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&&!Ac(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?jc(d.path,r):void 0,B=y.trim().toLowerCase(),V=d?.entries.filter(e=>e.name.toLowerCase().includes(B))??[],H=ee&&(ee.step===`read`&&kc[ee.code]?l(kc[ee.code]):u(ee.code));return(0,h.jsxs)($a,{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)(di,{"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)(si,{"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)(wi,{"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)(gi,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Xr,{"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)(Di,{}),l(`Parent folder`)]}),V.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(e.path),children:[(0,h.jsx)(di,{}),(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 Nc(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 Pc({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)(Qr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function Fc({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)(Ti,{"aria-hidden":`true`}):(0,h.jsx)(wi,{"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 Ic({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=Nc(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)(wi,{"aria-hidden":`true`}):(0,h.jsx)(Ti,{"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)(vi,{"aria-hidden":`true`}):(0,h.jsx)(ti,{"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 Lc({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)(Ic,{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)(Ja,{pager:e,compact:!0})]})}function Rc({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=xa(e,te),M=xa(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)(Lc,{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)(qr,{"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)(ti,{})}),(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(rc(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)(Co,{...E,represented:!n&&E.project?[...(S??[]).map(e=>So(E.project,`workflow`,e.id,e.epoch)),...z.flatMap(e=>e.live?[So(E.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(Pc,{onConversation:x}),!n&&(0,h.jsxs)(Fc,{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)(qr,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Ic,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(Fc,{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)(ti,{"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)(Ja,{pager:j,compact:!0})]}),!P.some(e=>e.owner.taskId===r)&&F]})]})}var zc=[`queued`,`running`];function Bc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=ea(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?zc.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!zc.includes(u.status)&&c(0)},[u]);let m=ea(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?Rs(g):null,[g]),[v,y]=(0,f.useState)(!1),b=ea(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)(vi,{"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)(uc,{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)(Qs,{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)(La,{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 Vc({path:e,disabled:t=!1,onClick:n}){let{t:r}=T(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;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)(di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Hc({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 Uc(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Yi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:B(e)});if(n&&(a.set(`scope`,JSON.stringify(je(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 Wc(){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?je(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=Me(G(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Gc=`cadence-panel-layout-v1`,Kc={left:260,right:360,navigation:!0,inspector:!1};function qc(e,t=600){return Math.max(220,Math.min(t,e))}function Jc(e){let t={...Kc};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]=qc(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Yc(e,t){let n=e<=900,r=qc(t.left,e-560),i=qc(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:qc(e-560-s),rightMaximum:qc(e-560-a)}}function Xc({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(qc(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(qc(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(qc(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 Zc(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 Qc=.4,$c=1.05;function el(e){return Math.min(300,e*.86)}function tl(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function nl(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function rl(e,t){return e===`left`?t:-t}function il(e,t){return Math.max(-e,Math.min(0,-e+t))}function al(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function ol(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:al(r*$c,n,t)>=Qc}var sl=new Set([`auto`,`scroll`,`overlay`]);function cl(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&sl.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function ll(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function ul(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=tl(r.clientX,window.innerWidth,n);i&&!cl(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=nl(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=el(window.innerWidth),h=m*$c;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=rl(r,d);let b=il(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(al(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?ol({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(ll(),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 dl({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,compatible:u,onRefresh:d,onDisconnect:p,onOpenService:m,content:g}){let{t:_,locale:v,setLocale:y}=T(),{mobile:b,overlay:S,closeDrawer:C}=e,w=(0,f.useRef)(null),E=(0,f.useRef)(null),D=()=>{E.current&&(E.current.open=!1)};return ul({enabled:b,open:S,onOpenChange:e.setDrawer,container:w}),Zc(w,S,!!S,C),(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":_(`Toggle conversation navigation`),"aria-expanded":b?S===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(ni,{"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`}),a,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o,(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)(li,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:v===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:E,onKeyDown:e=>{e.key===`Escape`&&E.current&&(E.current.open=!1,E.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":_(`More`),title:_(`More`),children:(0,h.jsx)($r,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Observe current state`),onClick:()=>{D(),d()},children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),_(`Refresh status`)]}),m&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Cadence service`),onClick:()=>{D(),m()},children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[_(`Cadence service`),(0,h.jsx)(`small`,{children:_(`Version, restart and upgrade.`)})]})]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Disconnect this page`),title:_(`Return — accepted work continues`),onClick:()=>{D(),C(),p()},children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[_(`Disconnect this page`),(0,h.jsx)(`small`,{children:_(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${u===!1?` warn`:``}`,title:Ki?.buildId??_(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:_(`Shared compatibility: {state}.`,{state:_(u===void 0?`Execution compatibility not observed`:u?`compatible`:`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:_(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ki?.buildId??_(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":_(`Toggle workspace panels`),"aria-expanded":b?S===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??_(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{ref:w,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":_(`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":_(`Conversation navigation`),tabIndex:-1,inert:b?S!==`left`:!e.navigation||S===`right`,children:t}),(0,h.jsx)(Xc,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:S!==null,children:g}),(0,h.jsx)(Xc,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${S===`right`?` open`:``}`,"aria-label":_(`Files and history drawer`),tabIndex:-1,inert:b?S!==`right`:!e.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":_(`Workspace panels`),children:[i??(0,h.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,h.jsx)(di,{"aria-hidden":`true`}),_(`Files`)]}),(0,h.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":_(`Collapse panel`),title:_(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,h.jsx)(wi,{"aria-hidden":`true`})})]}),n]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:l})]})]})}function fl({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,h.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,h.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function pl(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function ml({since:e,label:t}){let[n,r]=(0,f.useState)(Date.now);(0,f.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?pl(n-e):``;return(0,h.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,h.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function hl(){let[e,t]=(0,f.useState)(()=>{try{return Jc(localStorage.getItem(Gc))}catch{return Jc(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=Yc(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Gc,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 gl(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 _l=`modulepreload`,vl=function(e){return`/`+e},yl={},bl=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=vl(t,n),t=s(t),t in yl)return;yl[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`:_l,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 xl({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=xa(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)(Ja,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Sl,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Sl({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 bl(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,gl(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)(Ya,{client:e,seed:t})]})}var Cl=[[`tools`,Gr],[`context`,ai],[`timeline`,Si],[`runs`,ui]];function wl({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??qi()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(Wc),[w,E]=(0,f.useState)(C?.taskId??null),[D,ee]=(0,f.useState)(()=>C?null:Xi()??crypto.randomUUID()),O=Qi(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)(),[V,H]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Xi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[U]=(0,f.useState)(()=>crypto.randomUUID()),re=(0,f.useCallback)(()=>I(void 0),[]),[G,ie]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),ae=da(s?.id,s?.epoch),oe=!s||ae.readiness===`running`,se=!!s&&(ae.readiness===`stopped`||ae.readiness===`not-started`),ce=(0,f.useRef)(null);oe&&ae.value?.epoch&&(ce.current=ae.value.epoch);let le=!s||!se&&(oe||ce.current!==null),K=ma(v,w?{kind:`task`,id:w}:null,!x&&le,ce.current),ue=(0,f.useRef)(!0);(K.workspace||K.observation||K.error||K.transportStatus===`stale`||K.compatible===!1)&&(ue.current=!1);let de=!!(s&&(ae.value||ae.error)),fe=!x&&!!(K.workspace||de),pe=(0,f.useRef)(null);(K.workspace||ae.value?.workspaceId)&&(pe.current=K.workspace?.workspaceId??ae.value?.workspaceId??null);let me=l?async(e,t,n)=>{let r=await l(e,t,n);if(e.aborted)throw Error(`stale`);ae.prepared(r);let i=K.reconnect();await K.whenReady(r,e,i)}:void 0,he=na(v.client,fe),ge=ea(v.client,K.workspace&&!x?{kind:`conversation-active`}:null,1e3),_e=ge.value?.kind===`conversation-active`?ge.value.entries:[],ve=[..._e,...(he.value?.entries??[]).filter(e=>!_e.some(t=>t.id===e.id))],ye=ea(v.client,K.workspace&&!x?{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=ea(v.client,!s&&K.workspace&&!x?{kind:`projects`}:null),Ce=V??s?.cwd??(Se.value?.kind===`projects`?Se.value.entries.find(e=>e.current)?.path:void 0),we=L?.id===D?L:void 0,Te=z?.id===D?z:void 0;(0,f.useEffect)(()=>{we&&Xi()===we.id&&history.replaceState({...history.state,cadenceCwd:we.cwd,cadenceConversationId:we.id},``,location.href)},[we]);let Ee=D?we:Ce?{id:U,cwd:Ce}:void 0,De=we?.cwd??Ce??(Se.value?.kind===`projects`?Se.value.entries.find(e=>e.current)?.path:void 0)??K.workspace?.rootLabel,q={state:K.observation,transportStatus:K.transportStatus,error:K.error,refresh:K.refresh},Oe=q.state?.snapshot.scope.kind===`task`&&q.state.snapshot.scope.id===w?q.state.snapshot.context:void 0,ke=hl(),{closeDrawer:Ae}=ke,[je,J]=(0,f.useState)(C?.snapshotSeq),[Me,Ne]=(0,f.useState)(``),[Pe,Y]=(0,f.useState)(``),Fe=(0,f.useRef)(null),[Ie,Le]=(0,f.useState)(`messages`),[Re,ze]=(0,f.useState)(!1),[Be,Ve]=(0,f.useState)(!1),[He,Ue]=(0,f.useState)(),[X,We]=(0,f.useState)(C?.cursor),[Ge,Ke]=(0,f.useState)(``),[qe,Je]=(0,f.useState)([]),[Ye,Xe]=(0,f.useState)(new Set),Ze=(0,f.useRef)(!0),Qe=e=>{Ze.current&&Je(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?$i(t,e):t)})},$e=(0,f.useRef)(new ha),et=W({taskId:w,scope:G,selectedSnapshot:je??null,detached:x,attachment:K.attachmentVersion,workspaceContext:K.workspace?.context??null,observationError:K.error??null});$e.current.select(et),(0,f.useEffect)(()=>(Ze.current=!0,()=>{Ze.current=!1,$e.current.depart()}),[]);let tt=e=>{b(``);let t=e??crypto.randomUUID();e||H(De??Ce),A(null),t!==D&&(j([]),I(void 0)),$e.current.depart(),ee(t),E(null),ie(null),Ne(``),Y(``),Ue(void 0),We(void 0),J(void 0),Le(`messages`),P(`files`),Ae(),history.replaceState({cadenceCwd:De??Ce,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 nt=(e,t)=>{A(null),j([]),ee(null),P(`task`),Ne(t??``),Y(``),J(void 0),$e.current.depart(),E(e),ie({kind:`task`,id:e}),Ue(void 0),We(void 0),Le(`messages`),Ae(),history.replaceState(null,``,Uc(e))};(0,f.useEffect)(()=>{let e=()=>{let e=Wc();if(e)A(null),j([]),ee(null),P(`task`),$e.current.depart(),J(e.snapshotSeq),Ne(``),Y(``),E(e.taskId),ie(e.scope??{kind:`task`,id:e.taskId}),Ue(void 0),We(e.cursor),Le(`messages`),Ae();else{let e=Xi();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&H(t),I(void 0),A(null),j([]),ee(e),E(null),ie(null),P(`files`),$e.current.depart(),Ae()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Ae]);let rt=(e,t,n)=>{A(null),J(t),Y(n??``),$e.current.depart(),ie(e),Ue(void 0),We(void 0),Le(`messages`),Ae(),w&&history.replaceState(null,``,Uc(w,void 0,{scope:e,snapshotSeq:t}))},Z=je??q.state?.snapshot.committedSeq??K.workspace?.committedSeq,it=K.workspace?.storeId,at=G&&it&&Z?{storeId:it,scope:G,snapshotSeq:Z,reader:`messages`,after:null,limit:50}:null,ot=G&&it&&Z?{storeId:it,scope:G,snapshotSeq:Z,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,st=Oe?q.state?.snapshot.runs??[]:[],ct=$e.current.ticket(),lt=e=>{Qe(e),e.receipt&&$e.current.current(ct)&&K.refresh()},ut=e=>{if(Ye.has(e)||!K.cancelCompatible||!K.activeRuns)return;let t=crypto.randomUUID(),n=K.activeRuns.epoch;Xe(t=>new Set(t).add(e)),Qe({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{lt(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(()=>Qe({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Ze.current&&Xe(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.`)}),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:()=>S(!1),children:g(`Reconnect as a viewer`)})]});let dt=K.activeRuns,ft=dt?.status===`complete`?dt.runs:[],pt=!x&&!K.error&&K.transportStatus===`current`&&(!q.state||q.state.connection===`current`),mt=oe&&pt,ht=ue.current&&!q.state&&!q.error&&!ae.error&&(!s||!ae.value&&ae.readiness===`unknown`||ae.readiness===`running`),gt=se?{status:ae.readiness===`not-started`?`not-started`:`stopped`}:K.compatible===!1?{status:`incompatible`}:oe&&pt&&K.compatible&&K.epoch&&(!s||ae.value?.epoch===K.epoch)?{status:`ready`,epoch:K.epoch,attachmentVersion:K.attachmentVersion}:{status:ht?`connecting`:`unavailable`},_t=x?`Viewer disconnected`:ht?`Connecting…`:s&&ae.readiness===`unknown`?`Project readiness unknown`:s&&ae.readiness===`stale`?`Project observation stale`:se?`Ready to prepare on Send`:pt?K.workspace?q.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)(dl,{panels:ke,compatible:K.compatible,onOpenService:o,onRefresh:()=>{K.refresh(),ae.refresh()},onDisconnect:()=>{ze(!1),Ve(!1),$e.current.depart(),S(!0)},inspectorLabel:g(G&&N===`task`?`History details`:`Files`),toolbar: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":Ie===`messages`&&!X,onClick:()=>{We(void 0),Ue(void 0),Le(`messages`)},children:[(0,h.jsx)(ti,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Fe,onKeyDown:e=>{e.key===`Escape`&&Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Ie===`messages`?g(`Details`):_(Ie),(0,h.jsx)(Ti,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Cl.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Ie===e,onClick:()=>{We(void 0),Ue(void 0),Le(e),Fe.current&&(Fe.current.open=!1,Fe.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:!at,onClick:()=>{Fe.current&&(Fe.current.open=!1,Fe.current.querySelector(`summary`)?.focus()),Ve(!0)},children:[(0,h.jsx)(_i,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&wa(Uc(w,X,G?{scope:G,snapshotSeq:je}:void 0)).then(e=>Ke(e?``:g(`Link copy unavailable.`)))},children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:G&&(0,h.jsx)(co,{disabled:!ot,onOpen:()=>ze(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!K.workspace&&ft.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:ft.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:()=>nt(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!K.cancelCompatible||Ye.has(e.runId),onClick:()=>ut(e.runId),children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(Hc,{error:Ge,projectObservationError:ae.error,observationError:K.error,unavailable:!ht&&!se&&!mt,onRefresh:()=>{K.refresh(),ae.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!fe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(Co,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(ht?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),fe&&(0,h.jsx)(Rc,{discovery:a,client:v.client,workspace:K.workspace,executionStopped:se,taskId:w,scope:G,runs:st,snapshot:q.state?.snapshot.committedSeq,activeRuns:K.activeRuns,cancelCompatible:!!K.cancelCompatible,canceling:Ye,onCancel:ut,chats:ve,chatActivityKnown:ge.value?.kind===`conversation-active`&&!ge.error,chatHistoryPartial:he.loading||he.canPrevious||!!he.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[he.error&&(0,h.jsx)(`p`,{role:`alert`,children:he.error}),he.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:g(`Reading conversation history…`)}),he.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:he.loading,onClick:he.previous,children:g(`Newer conversations`)}),he.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:he.loading,onClick:he.next,children:g(`Older conversations`)}),he.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:he.first,children:g(`Latest conversations`)}),he.error&&(0,h.jsx)(`button`,{type:`button`,onClick:he.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:tt,onNewConversation:()=>tt(),workflows:be?.runs,workflowLinks:be?.links,workflowError:!!ye.error,selectedWorkflow:k?.runId,onWorkflow:(e,t)=>{t?tt(t):(A({runId:e.id,stepId:null,label:e.goal}),Ae())},onCancelWorkflow:async e=>{let t=await lc(v.client,e);t&&Ke(t),ye.refresh()},onTask:nt,onScope:rt}),K.workspace&&(0,h.jsx)(ko,{client:v.client,active:K.activeRuns,taskId:w,runs:st,snapshot:Z,workflowRuns:xe,selected:k,onOpenWorkflow:e=>{A(e),Ae()},onOpen:(e,t,n,r)=>{nt(e),ie({kind:`child`,id:t}),Y(r),J(n),history.replaceState(null,``,Uc(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!de&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),k&&(0,h.jsx)(Bc,{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||de)&&(0,h.jsx)(hc,{client:v.client,id:D,activitySelected:O.selected,initialLeaf:O.leaf,initialCwd:Ce,onLocation:R,onActivity:B,hidden:!!k,onOpenAgent:A,onWorkflowRuns:j,workspaceId:s?`checkout:${s.path}`:pe.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?ae.value?.workspaceId??void 0:void 0,prepareForSend:me,actionsReady:oe&&!!K.workspace&&!!K.compatible&&!K.error&&pt,available:fe,canInterrupt:!!K.cancelCompatible,enabled:me?fe:!!K.workspace&&!!K.compatible&&!K.error,modelAvailability:gt,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{$e.current.depart(),K.refresh(!0),ae.refresh()},onChanged:()=>{he.refresh(),K.refresh()},reference:F,onReferenceUsed:re},`${s?.id??pe.current??`connecting`}:${D}:${O.leaf??``}`),G&&!k&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[G.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>nt(w,Me),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Me||G.id,children:G.kind===`task`?Me||g(`Task {id}`,{id:G.id.slice(0,8)}):Pe||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:Z??``})]}),(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:!!D||!!k,children:[!at&&(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.`)})]}),at&&X?(0,h.jsxs)(`div`,{className:`tab-body`,children:[He&&(He.owner.entity.kind===`task`||He.owner.entity.kind===`message`||He.owner.entity.kind===`tool`)&&(0,h.jsx)(Xa,{client:v.client,seed:{storeId:X.storeId,scope:X.scope,snapshotSeq:X.snapshotSeq,kind:He.owner.entity.kind,id:He.owner.entity.id,version:He.owner.entity.version}},`${He.owner.entity.id}:${He.owner.entity.version}`),(0,h.jsx)(qa,{client:v.client,cursor:X,highlight:He?.range},`${X.recordId}:${X.recordVersion}`)]}):at&&(0,h.jsxs)(`div`,{className:Ie===`messages`||Ie===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ie===`messages`&&(0,h.jsx)(yo,{client:v.client,seed:at}),Ie===`tools`&&(0,h.jsx)(Tl,{client:v.client,seed:at}),Ie===`context`&&(0,h.jsx)(Ya,{client:v.client,seed:at}),Ie===`timeline`&&(0,h.jsx)(xl,{client:v.client,seed:at,onSearch:()=>ze(!0)}),Ie===`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`)}),st.length>0?st.map(e=>(0,h.jsx)(io,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Oe&&q.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)(so,{client:v.client,seed:{...at,scope:{kind:`task`,id:w??at.scope.id}},onScope:rt},w)]})]},`${G?.kind}:${G?.id}:${je??`current`}`)]}),K.workspace&&qe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:qe.map(e=>(0,h.jsx)(ga,{client:v.client,value:e,onChange:Qe},e.commandId))})]}),inspectorTabs:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`files`||!G,onClick:()=>P(`files`),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),g(`Files`)]}),G&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!at,onClick:()=>P(`task`),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),g(`History details`)]})]}),inspector:N===`files`||!G?(0,h.jsx)(vc,{location:Ee,client:v.client,enabled:!!K.workspace&&!!Ee,onReference:e=>{D||tt(U);let t=!D&&Ee?`${Ee.cwd.replace(/[\\/]+$/,``)}${Ee.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;I(t),Ae()}},Ee?.cwd??`owner`):at?(0,h.jsx)(Oc,{client:v.client,seed:{...at,scope:{kind:`task`,id:w??at.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.jsx)(fl,{role:`status`,tip:g(`Connection freshness is not execution outcome.`),dot:ht?`busy`:se?``:!mt||!K.workspace?`error`:q.transportStatus===`current`&&(!q.state||q.state.connection===`current`)?`ok`:`busy`,children:_(_t)}),s&&(0,h.jsx)(fl,{tone:`faint`,icon:(0,h.jsx)(Yr,{}),children:g(`Execution service: {status}`,{status:_(ae.readiness)})}),Te&&Te.turns>0&&(0,h.jsx)(fl,{icon:(0,h.jsx)(ti,{}),tip:g(`Turns in this conversation: {count}`,{count:Te.turns}),children:Te.turns}),Te&&Te.runningSince!==null&&(0,h.jsx)(ml,{since:Te.runningSince,label:g(`Working`)}),dt?.status===`complete`?ft.length>0&&(0,h.jsx)(fl,{tone:`warn`,children:g(mt?ft.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:ft.length})}):!ht&&!se&&(0,h.jsx)(fl,{tone:`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)(Vc,{path:De,onClick:()=>c?c(De):ne(``)}),K.compatible===!1&&(0,h.jsx)(fl,{tone:`warn`,children:g(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})}),M!==null&&K.workspace&&(0,h.jsx)(Mc,{onOpen:t,projects:r??(Se.value?.kind===`projects`?Se.value.entries:[]),client:v.client,current:De??K.workspace.rootLabel,initial:M||void 0,home:n,epoch:K.workspace.epoch,onClose:()=>ne(null)}),Re&&ot&&(0,h.jsx)(ro,{client:v.client,seed:ot,onClose:()=>ze(!1),onHit:e=>{Ue(e),We(e.cursor),w&&history.replaceState(null,``,Uc(w,e.cursor,G?{scope:G,snapshotSeq:je}:void 0))}}),Be&&ot&&(0,h.jsx)(eo,{request:{storeId:ot.storeId,scope:ot.scope,snapshotSeq:ot.snapshotSeq,format:`ndjson`},onClose:()=>Ve(!1)})]})}function Tl({client:e,seed:t}){let n=xa(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ja,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(xo,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var El=`cadence:folder-draft`,Dl=()=>({text:``,model:null});function Ol(){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=K(e.model))}catch{}return{text:e.text,model:t}}catch{return Dl()}}function kl(e){try{e.text||e.model?sessionStorage.setItem(El,JSON.stringify(e)):sessionStorage.removeItem(El)}catch{}}function Al(e,t,n){let r=Go(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(El)}catch{}return{...n,conversationId:t}}var jl=`cadence-last-project`;function Ml(){try{let e=localStorage.getItem(jl);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Nl(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(jl,e)}catch{}}function Pl(e){let t=Ml();return t?e.projects.find(e=>e.id===t):void 0}async function Fl(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=_n(await ra(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Il(e,t){if(!Ki)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`,...Ki})}}),r=await ra(n);if(!n.ok)throw Error(ia(r));return mn(r)}async function Ll(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await ra(t);if(!t.ok)throw Error(ia(n));return Sn(n)}async function Rl(e,t,n,r,i){if(!Ki)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`,...Ki})},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 ra(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(ia(c));let l=gn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function zl(e,t){let n=await Ll(t);return Rl(`/workbench/v1/select`,{path:e},n,t)}async function Bl(e,t,n,r){let i=await Ll(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 Rl(`/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 Vl(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await zl(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Hl=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Ul(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:an(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,Hl),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 Wl(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,Ul)}})}}async function Gl(e){if(!Ki)throw Error(`unsupported-context`);let t=Mi([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`,...Ki})}}),n=await ra(e);if(!e.ok)throw Error(ia(n));return Wl(n)}finally{t.dispose()}}function Kl(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 ql(e,t,n,r=Gl){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?Kl(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 Jl(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return ql(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function Yl({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=hl(),[p,m]=(0,f.useState)(!1),g=as(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(dl,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(Pc,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(Co,{...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)($s,{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)(di,{"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)(hs,{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.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,h.jsx)(Di,{"aria-hidden":`true`})})]})]})]}),inspector:(0,h.jsx)(`aside`,{className:`panel files-panel`,children:(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,h.jsx)(fl,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(Vc,{disabled:!e,onClick:_})})}var Xl=`cadence-recovery-dismissed`,Zl={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.`},Ql={"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 $l(){try{let e=JSON.parse(localStorage.getItem(Xl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function eu(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function tu({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)($l),[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(Xl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:eu(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(Zl[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(Ql[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var nu={restart:18e4,upgrade:12e5},ru=1e3,iu={"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.`},au=e=>e instanceof Error?e.message:`unavailable`;function ou(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(iu[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 su(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function cu(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 lu({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 oa(e.signal).then(a,t=>{e.signal.aborted||s(au(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>nu[e.action])return w(`timeout`);try{let t=await oa(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,ru)};return r=setTimeout(i,ru),()=>{n.abort(),clearTimeout(r)}},[v]);let ee=()=>{l(`checking`),sa().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},O=n=>{i&&(_(!0),s(``),ca({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(au(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`&&su(C),o=i?.unit;return(0,h.jsxs)($a,{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:nu[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):ou(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)($a,{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`?Nn(c.version,i.version)>0:!1;return(0,h.jsxs)($a,{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:cu(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:ou(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})}):An(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(Oi,{"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)(Zr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function uu(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Ol),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(Yi),u=(0,f.useCallback)(e=>Il(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=Jl(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 ra(t);t.status===400&&ia(r)===`invalid`?n(null):t.ok?(n(Sn(r)),b(``)):b(ia(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,f.useEffect)(()=>{let e=()=>{j.current?.abort(),P(),D(null),l(Yi())};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=Pl(t);if(!e)return;let n=new AbortController;N.current=n,D({status:`checking`,path:e.cwd}),Fl(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(Al(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 zl(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(``),Vl(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 Bl(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 ra(n);if(!n.ok){let e=ia(r);return{kind:`error`,error:te(k.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Ar(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),B=(0,f.useMemo)(()=>c?qi(c):void 0,[c]),V=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{V&&Nl(V.id)},[V]),t===null)return(0,h.jsx)(wl,{});let H=t&&C&&(0,h.jsx)(lu,{epoch:t.epoch,csrf:t.csrf,onClose:()=>w(!1)}),U=()=>w(!0),re=t&&d!==null&&(0,h.jsx)(Mc,{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)(wl,{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)(tu,{notices:t.recoveries,project:V.path}),` `]}),onOpenService:U},V.id),H,re]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Yl,{discovery:L,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{P(),i(e),kl(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)(tu,{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 du(){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 fu=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(du,{}):this.props.children}},pu=document.getElementById(`root`);if(!pu)throw Error(`Application root unavailable`);(0,p.createRoot)(pu).render((0,h.jsx)(E,{children:(0,h.jsx)(fu,{children:(0,h.jsx)(uu,{})})}));export{bl as t};
|
|
23
|
+
`),inFence:i!==null}}function tu(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 nu=(0,f.memo)(function({text:e}){return(0,h.jsx)(Fo,{text:e})}),ru=22,iu=14,au=()=>typeof document<`u`&&document.hidden;function ou(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||au()||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(au()){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?iu:ru;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=tu(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 su=600,cu=32;function lu({text:e,inFence:t}){let n=!t&&e.length>=su,[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>=cu)r();else return o.current=setTimeout(r,cu-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)(Fo,{text:n?r:e})}var uu=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=ou(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>eu(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)(nu,{text:e},t)),a.length>0&&(0,h.jsx)(lu,{text:a,inFence:o},i.length)]})});function du(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
24
|
+
|
|
25
|
+
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function fu({label:e,children:t}){return(0,h.jsx)(`div`,{className:`msg-actions`,role:`group`,"aria-label":e,children:t})}function pu({icon:e,label:t,title:n=t,showLabel:r=!1,done:i=!1,onClick:a}){return(0,h.jsxs)(`button`,{type:`button`,className:`msg-action${r?` labelled`:``}${i?` done`:``}`,title:n,"aria-label":t,onClick:a,children:[e,r&&(0,h.jsx)(`span`,{className:`msg-action-label`,children:t})]})}function mu({turn:e,parts:t}){let{t:n}=T(),{copied:r,copy:i}=fo();return(0,h.jsx)(pu,{icon:r?(0,h.jsx)(aa,{"aria-hidden":`true`}):(0,h.jsx)(Qi,{"aria-hidden":`true`}),label:n(`Copy message`),done:r,onClick:()=>{let r=()=>To(`error`,n(`Copy unavailable`)),a=e=>i(e).then(e=>{e||r()}),o=du(e,t,new AbortController().signal);typeof o==`string`?a(o):o.then(a,r)}})}function hu({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=Ol(e,t,n,i),{header:s}=e,c=(s.status===`queued`||s.status===`running`)&&t>=s.stable,l=o.value?.text.trim()??``,u=r(`Thinking still being recorded`);return(0,h.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,h.jsx)(vs,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,h.jsx)(Yi,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,h.jsxs)(h.Fragment,{children:[c&&(0,h.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:(0,h.jsx)(Gl,{})}),(0,h.jsx)(`span`,{className:`toolcall-spacer`}),l&&(0,h.jsx)(Ao,{text:l,className:`chead-copy`})]}),children:r(`Thinking`)}),i&&(0,h.jsx)(`div`,{className:`thinking-body`,children:l||(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):n.parts===0||o.value?r(`No thinking text is recorded for this block.`):r(`Reading…`)})})]})}var gu=(e,t)=>new Date(e).toLocaleTimeString(t===`zh`?`zh-CN`:`en-GB`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),_u=(0,f.memo)(function({turn:e,onContinue:t,onEdit:n,version:r=0,versions:i=0,onVersion:a,off:o=!1}){let{t:s,tx:c,locale:l}=T(),{header:u}=e,{user:d,replies:p}=zl(e.steps),m=p.filter(({step:e})=>e.role===`assistant`&&!e.error),g=u.status===`queued`||u.status===`running`,_=t&&u.entry&&(0,h.jsx)(pu,{icon:(0,h.jsx)(Zi,{"aria-hidden":`true`}),label:s(`Continue from here`),title:s(`Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.`),showLabel:!0,onClick:()=>t(u.id)}),v=n&&!g&&(0,h.jsx)(pu,{icon:(0,h.jsx)(qi,{"aria-hidden":`true`}),label:s(`Edit and resend`),title:s(`Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.`),onClick:()=>n(u.id)}),[y,b]=(0,f.useState)(!1),{thinking:x,media:S,other:C}=u.omitted,w=[x&&s(`Thinking that could not be read is not shown.`),S&&s(`Media is not retained.`),C&&s(`Other content is not retained.`)].filter(e=>e!==!1),E=u.notice.split(`
|
|
26
|
+
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:D}=u,O=g&&p.at(-1)?.step.role===`assistant`,k=g&&!O&&!p.some(({index:e})=>e>=u.stable),A=u.at>0&&(0,h.jsx)(`time`,{className:`msg-time`,dateTime:new Date(u.at).toISOString(),children:gu(u.at,l)}),ee=p.length>0||g||w.length>0;return(0,h.jsxs)(`section`,{className:o?`chat-turn off-branch`:`chat-turn`,"aria-label":s(o?`Conversation turn, not in the new message's context`:`Conversation turn`),children:[d.map(({step:t,index:n},o)=>{let c=t.text.trim()!==``,l=o===0&&v,f=!ee&&o===d.length-1&&_;return(0,h.jsxs)(`article`,{className:`msg msg-user`,children:[(0,h.jsxs)(`div`,{className:`msg-meta`,children:[(0,h.jsx)(`span`,{className:`msg-role`,children:s(`You`)}),A,o===0&&i>1&&(0,h.jsxs)(`span`,{className:`msg-versions`,role:`group`,"aria-label":s(`Version {index} of {count}`,{index:r,count:i}),children:[(0,h.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Previous version`),title:s(`Previous version`),disabled:!a||r<=1,onClick:()=>a?.(u.id,-1),children:(0,h.jsx)(ra,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`msg-version-count`,"aria-hidden":`true`,children:[r,`/`,i]}),(0,h.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Next version`),title:s(`Next version`),disabled:!a||r>=i,onClick:()=>a?.(u.id,1),children:(0,h.jsx)(na,{"aria-hidden":`true`})})]})]}),(0,h.jsx)(`div`,{className:`msg-body`,children:(0,h.jsx)(Kl,{turn:e,index:n,step:t,copy:!1})}),(c||l||f)&&(0,h.jsxs)(fu,{label:s(`Message actions`),children:[l,c&&(0,h.jsx)(mu,{turn:e,parts:[{step:t,index:n}]}),f]})]},n)}),ee&&(0,h.jsxs)(`article`,{className:`msg msg-assistant`,children:[(0,h.jsxs)(`div`,{className:`msg-meta`,children:[(0,h.jsx)(`span`,{className:`msg-role`,children:`Cadence`}),D&&(0,h.jsx)(`button`,{type:`button`,className:`msg-model`,"aria-expanded":y,title:s(`Context fixed at admission:`),onClick:()=>b(e=>!e),children:D.model?`${D.model.provider}/${D.model.model}`:s(`No model`)}),d.length===0&&A]}),D&&y&&(0,h.jsxs)(`p`,{className:`msg-context`,children:[s(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:D.cwd}),` · `,D.model?`${D.model.provider}/${D.model.model} · ${D.model.thinking}`:s(`No model`)]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[p.map(({step:t,index:n},r)=>t.role===`tool`?(0,h.jsx)(Yl,{turn:e,index:n,step:t},n):t.role===`thinking`?(0,h.jsx)(hu,{turn:e,index:n,step:t},n):(0,h.jsxs)(`div`,{className:`msg-part`,children:[t.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:s(`Incomplete model response`)}),(0,h.jsx)(Kl,{turn:e,index:n,step:t,render:O&&r===p.length-1?e=>(0,h.jsx)(uu,{text:e}):void 0})]},n)),k&&(0,h.jsxs)(`p`,{className:`msg-working`,role:`status`,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),u.status===`queued`?c(`queued`):s(`Working…`)]}),w.map(e=>(0,h.jsx)(`p`,{className:`msg-omitted`,children:e},e))]}),!g&&(m.length>0||_)&&(0,h.jsxs)(fu,{label:s(`Message actions`),children:[m.length>0&&(0,h.jsx)(mu,{turn:e,parts:m}),_]})]}),u.status===`running`&&u.retry&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-retry`,role:`status`,children:u.retry.phase===`waiting`?s(`Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts,seconds:Math.ceil(u.retry.delayMs/1e3)}):s(`Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts})}),E.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:E.map(e=>c(e)).join(`
|
|
27
|
+
`)}),![`completed`,`running`,`queued`].includes(u.status)&&(0,h.jsx)(`p`,{className:`ep-state ${u.status}`,children:c(u.status)})]})});function vu({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]})}function yu(e,t,n){let r=Math.max(0,t),i=Math.floor((r+4)/7),a=Math.min(e,i),o=Array.from({length:a},(t,r)=>{let i=Math.floor(r*e/a),o=Math.floor((r+1)*e/a)-1;return n>=i&&n<=o?n:r===a-1?o:i}),s=a>1?Math.min(27,(r-a*3)/(a-1)):0;return{indices:o,gap:s,many:e>a||a>1&&s<20}}function bu({questions:e,active:t,reading:n,onJump:r}){let{t:i}=T(),a=(0,f.useRef)(null),[o,s]=(0,f.useState)(0);(0,f.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>s(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let{indices:c,gap:l,many:u}=(0,f.useMemo)(()=>yu(e.length,o,t),[e.length,o,t]),d=c.includes(t)?t:c.at(-1),p=e=>{let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t&&e.key!==`Home`&&e.key!==`End`)return;let n=[...e.currentTarget.querySelectorAll(u?`.qn-list-item`:`.qn-bar`)];if(!n.length)return;e.preventDefault();let r=document.activeElement,i=u?Number(r?.dataset.question??0):n.indexOf(r);n[e.key===`Home`?0:e.key===`End`?n.length-1:Math.min(n.length-1,Math.max(0,i+t))]?.focus()},m=()=>a.current?.querySelector(`.qn-list-item.active`)?.scrollIntoView({block:`nearest`}),g=(e,t)=>{e.detail>0&&e.currentTarget.blur(),r(t)},_=t=>`${t+1}. ${e[t].text}`;return(0,h.jsxs)(`nav`,{className:`qn-rail${u?` many`:``}`,ref:a,"aria-label":i(`Questions in this conversation`),style:{"--rail-gap":`${l}px`},onKeyDown:p,onMouseEnter:m,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||m()},children:[c.map(r=>{let i=e[r];return(0,h.jsx)(`button`,{type:`button`,className:`qn-bar${r===t?` active`:``}`,"aria-label":_(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===i.id||void 0,"data-question":r,tabIndex:r===d?0:-1,onClick:e=>g(e,i.id),children:(0,h.jsx)(`span`,{className:`qn-bar-text`,children:_(r)})},i.id)}),u&&(0,h.jsx)(`div`,{className:`qn-list`,children:e.map((e,r)=>(0,h.jsxs)(`button`,{type:`button`,className:`qn-list-item${r===t?` active`:``}`,"aria-label":_(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===e.id||void 0,"data-question":r,tabIndex:-1,onClick:t=>g(t,e.id),children:[(0,h.jsx)(`span`,{className:`qn-list-idx`,children:r+1}),(0,h.jsx)(`span`,{className:`qn-list-text`,children:e.text||`…`})]},e.id))})]})}var xu={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`},Su=(e,t,n)=>new File([e],`image-${n+1}.${xu[t.mimeType]??`img`}`,{type:t.mimeType});function Cu({draftKey:e,draft:t,setDraft:n,images:r,alive:i,onUnread:a}){let[o,s]=(0,f.useState)(()=>{try{return Xs(sessionStorage.getItem(`${e}:anchor`))}catch{return null}}),c=(0,f.useRef)(o);c.current=o,(0,f.useEffect)(()=>{try{o?sessionStorage.setItem(`${e}:anchor`,JSON.stringify(o)):sessionStorage.removeItem(`${e}:anchor`)}catch{}},[e,o]);let l=(0,f.useRef)([]),u=(0,f.useRef)(null),[d,p]=(0,f.useState)(!1),m=()=>{u.current?.abort(),u.current=null,p(!1)},h=()=>{m();let e=c.current;e&&(c.current=null,s(null),n(e.stash),r.replace(l.current),l.current=[])},g=(e,n,i)=>{m();let a=c.current;a||(l.current=r.files);let o=zl(e.steps).user[0],u={kind:n,entry:i,turnId:e.header.id,from:n===`edit`?e.ordinal:e.ordinal+1,label:Ks(o?.step.text??``),media:n===`edit`&&e.header.omitted.media,stash:a?a.stash:t};return c.current=u,s(u),r.replace([]),o};return{anchor:o,current:()=>c.current,attaching:d,release:h,continueAfter:e=>e.header.entry?(g(e,`continue`,e.header.entry),n(``),!0):!1,edit:(e,t)=>{let o=qs(e,t);if(o===void 0)return!1;let s=g(e,`edit`,o);if(n(s?.step.text??``),!s)return!0;let c=s.step.text,l=s.step.images??[],d=new AbortController,f=du(e,[s],d.signal);if(typeof f==`string`&&!l.length)return!0;u.current=d,p(!0);let{image:m}=e;return Promise.allSettled([f,...l.map((e,t)=>m?m(e,d.signal).then(n=>Su(n,e,t)):Promise.reject(Error(`unavailable`)))]).then(([e,...t])=>{if(d.signal.aborted||!i.current)return;u.current=null,p(!1),e.status===`fulfilled`&&n(t=>t===c?e.value:t);let o=t.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);try{o.length&&r.add(o)}catch{o.length=0}(e.status===`rejected`||o.length<l.length)&&a()}),!0}}}function wu({pending:e,undelivered:t,canWithdraw:n,recallable:r,onWithdraw:i,onRestore:a}){let{t:o,tx:s}=T();return!e.length&&!t.length?null:(0,h.jsxs)(`section`,{className:`chat-waiting-list`,"aria-label":o(`Waiting messages`),children:[e.map(e=>(0,h.jsxs)(`article`,{className:`chat-waiting ${e.mode}`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{className:`chat-waiting-tag ${e.mode}`,children:e.mode===`steer`?o(`Steering: read at the model's next step`):o(`Queued: sent when this reply ends`)}),(0,h.jsxs)(`span`,{className:`chat-waiting-actions`,children:[r(e)&&(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw and put back in the message box`),"aria-label":o(`Withdraw and put back in the message box`),onClick:()=>i(e,!0),children:(0,h.jsx)(Xi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw`),"aria-label":o(`Withdraw`),onClick:()=>i(e,!1),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]})]}),(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:e.text})]},e.commandId)),t.map(e=>(0,h.jsxs)(`article`,{className:`chat-attempt chat-undelivered`,children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:e.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${e.status}`,children:s(e.status)}),` `,e.notice?s(e.notice):o(`Not delivered.`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(e.text),children:[(0,h.jsx)(Xi,{"aria-hidden":`true`}),o(`Put back in the message box`)]})]},e.commandId))]})}var Tu=[`queued`,`running`],Eu=e=>Tu.includes(e.status);function Du(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function Ou(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function ku(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=>Du(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=Du(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 Au(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?Du(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 ju(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 Mu({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=Eu(t),m=p?Es(t):null,g=t.status===`completed`?t.deviations?.length??0:0,_=g?g===1?i(`delivered with 1 deviation`):i(`delivered with {count} deviations`,{count:g}):``,v=e=>e.filter(Boolean).join(` · `),y=v(p?[a(Ou(t)),m?Ts(m,i):t.steps.filter(e=>e.status===`running`).map(e=>Ss(e.id)).join(`, `)]:[a(t.status)]),x=p?``:v([t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,ju(t,i)]),S=p||t.status===`completed`?``:t.notice.split(`
|
|
28
|
+
`).find(e=>e.trim())??``,C=v([y,_,x]);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:C,children:_?(0,h.jsxs)(h.Fragment,{children:[`${y} · `,(0,h.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,h.jsx)(fa,{"aria-hidden":`true`}),_]}),x&&` · ${x}`]}):C})]}),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(``),Pu(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(hi,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):S&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:S,children:a(S)})]})}function Nu({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?.runtime&&(0,h.jsx)(`p`,{children:e.display.runtime}),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, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.`)}),(0,h.jsx)(Io,{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)(Io,{text:vr(e.plan)})]}),e.delivery&&(0,h.jsx)(Io,{text:ur(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 Pu(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 Fu(e){return(0,h.jsx)(Iu,{...e},e.id)}function Iu({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=Ba(e,{kind:`workflow`,id:t},o),d=Ba(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=Ba(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&&(0,h.jsx)(Ru,{run:m}),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&&g&&(0,h.jsx)(Vu,{run:m,steps:g.steps,partial:(g.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:Ss(e.id)}))}),m&&((m.revision??0)>0||!!m.scope?.length)&&(0,h.jsxs)(`section`,{className:`workflow-route`,"aria-label":i(`Route revisions`),children:[(m.revision??0)>0&&(0,h.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,m.revision]}),!!m.scope?.length&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:i(`Paths added to the write scope after approval:`)}),(0,h.jsx)(`ul`,{className:`workflow-scope`,children:m.scope.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(`code`,{children:e})},e))})]})]}),m?.delivery&&(0,h.jsx)(Hu,{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:Sr(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&&((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.jsx)(`summary`,{children:(0,h.jsx)(Lu,{run:m??g,step:e})}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(Io,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:Ss(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),Pu(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 Lu({run:e,step:t}){let{t:n,tx:r}=T();return(0,h.jsxs)(h.Fragment,{children:[`${r(t.kind)} · ${Ss(t.id)} · ${r(t.status)}`,As(e,t)&&(0,h.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function Ru({run:e}){let{t}=T(),n=e.deviations??[];return n.length?(0,h.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,h.jsxs)(`h3`,{children:[(0,h.jsx)(fa,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,h.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,h.jsx)(`ol`,{children:n.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:t(`Could not be met`)}),(0,h.jsx)(`dd`,{children:e.item}),(0,h.jsx)(`dt`,{children:t(`Why`)}),(0,h.jsx)(`dd`,{children:e.reason}),(0,h.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,h.jsx)(`dd`,{children:e.delivered}),(0,h.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,h.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,h.jsx)(`code`,{children:e},e)):t(`None`)}),(0,h.jsx)(`dt`,{children:t(`Recorded at`)}),(0,h.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function zu({state:e}){return e===`running`?(0,h.jsx)(Gl,{}):e===`completed`?(0,h.jsx)(oa,{"aria-hidden":`true`}):e===`failed`?(0,h.jsx)(di,{"aria-hidden":`true`}):e===`superseded`?(0,h.jsx)(gi,{"aria-hidden":`true`}):(0,h.jsx)(ea,{"aria-hidden":`true`})}function Bu(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function Vu({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=T(),o=Cs(e);return o?(0,h.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,h.jsxs)(`h3`,{children:[i(`Assignments`),(0,h.jsx)(`span`,{className:`workflow-board-counts`,children:Ts(o,i)})]}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,h.jsx)(`ul`,{children:Ds(e,t).map(({task:e,steps:t,artifact:n})=>(0,h.jsxs)(`li`,{className:`workflow-task`,children:[(0,h.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,h.jsx)(zu,{state:e.state}),a(e.state)]}),(0,h.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,h.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,h.jsx)(`span`,{children:e.title}),(0,h.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,h.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,h.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,h.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,h.jsx)(`span`,{className:`workflow-task-worktree`,children:Bu(n,i)})]}),n?.state===`retained`&&(0,h.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,h.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,h.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,h.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function Hu({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?`${e.acceptance.waived?.length?t(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,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 Uu=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Wu(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Gu({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,prepareForSend:u,legacyWorkspaceId:d,directoryNamespaces:p=[],available:m=c,canInterrupt:g=c,modelAvailability:_,previewModels:v,initialDraft:y,onDraftApplied:x,onModelChanged:S,onChanged:C,reference:w,onReferenceUsed:E,hidden:D=!1,observe:O=0,onOpenAgent:k,onWorkflowRuns:A,onBranches:ee,onOpenBranches:te}){let{t:j,tx:ne}=T(),[re]=(0,f.useState)(()=>_c(n,t,d,...p)),[ie,M]=(0,f.useState)(()=>Wu(re,y?.text));(0,f.useEffect)(()=>{y&&x?.()},[y,x]);let ae=hl(),N=ae.remove,P=(0,f.useRef)([]),F=(0,f.useRef)(!0),se=Cu({draftKey:re,draft:ie,setDraft:M,images:ae,alive:F,onUnread:()=>le(j(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:I,attaching:L}=se,R=se.release,z=(0,f.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[B,V]=(0,f.useState)(()=>Wu(`${re}:mode`)===`cadence`?`cadence`:`chat`),[H,U]=(0,f.useState)(!1),[W,G]=(0,f.useState)(``),K=`conversation:${t}`,ce=()=>{G(``),Do(K)},le=e=>To(`error`,e,K);(0,f.useEffect)(()=>()=>Do(K),[K]);let[J,ue]=(0,f.useState)(()=>Wu(`${re}:pending`)),[Y,de]=(0,f.useState)(()=>Wu(`${re}:model-command`)),[fe,pe]=(0,f.useState)(!1),[he,ge]=(0,f.useState)(!1),[_e,ve]=(0,f.useState)(!1),[ye,be]=(0,f.useState)(0),xe=(0,f.useRef)(null),Se=(0,f.useRef)(!1),Ce=(0,f.useRef)(0),we=(0,f.useRef)(new AbortController),[Te,Ee]=(0,f.useState)(!1),[De,Oe]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(`${re}:model`);if(e)return me(JSON.parse(e))}catch{}return y?.model??null});(0,f.useEffect)(()=>{try{De?sessionStorage.setItem(`${re}:model`,JSON.stringify(De)):sessionStorage.removeItem(`${re}:model`)}catch{}},[re,De]);let ke=Ba(e,m&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),Ae=ke.value?.kind===`conversation-context`?ke.value.context:void 0,je=!!Ae&&!ke.error,Me=Ae?.cwd??r,Ne=(0,f.useMemo)(()=>({models:n=>Me?e.models(n,{id:t,cwd:Me}):Promise.resolve({kind:`error`,error:oe(`unavailable`)}),chooseModel:n=>Me?e.chooseModel(n,{id:t,cwd:Me}):Promise.resolve({kind:`error`,error:oe(`unavailable`)})}),[e,t,Me]),Pe=Te?{status:`preparing`}:_.status===`ready`&&(!m||!je)?{status:ke.error?`unavailable`:`connecting`}:_,Fe=(0,f.useRef)(Pe);Fe.current=Pe;let Ie=jc(Ne,Pe,`${ye}:${Ae?.revision??`unobserved`}`,v),Le=()=>{xe.current=null,ge(!1),ve(!1)},Re=(e,t)=>{e&&!Ie.preview&&!Ie.loading?Ie.reread():!e&&t!==`chosen`&&Le(),pe(e)},ze=(e,t)=>{Oe(t?null:e);let n=xe.current;he&&n&&(pc(n,Fe.current)===`cancel`?(Le(),le(j(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(xe.current=fc(n,e,t),ge(!1),ce(),ve(!0)))},Be=(0,f.useRef)(o);Be.current=o,(0,f.useEffect)(()=>{je&&Me&&Be.current?.({id:t,cwd:Me})},[je,t,Me]);let[Ve]=(0,f.useState)(()=>typeof window<`u`&&Pa()===t?Ia(window.location.hash,t).leaf:i),X=kc(e,t,m,Ve),{turns:He}=X,Ue=X.summary!==void 0,We=Ba(e,m?{kind:`cadence-conversation`,id:t}:null,1e3),Ge=We.value?.kind===`cadence-conversation`?We.value.state:void 0,Ke=Ge?.enabled===!0,qe=!!Ge||!!We.error,Je=!!Ge&&!We.error&&!Ge.notice,Ye=(0,f.useRef)(Ge);Ye.current=Ge;let[Xe,Ze]=(0,f.useState)(``),Qe=(0,f.useRef)(``),$e=Va(ie,Ke?`cadence`:B),et=c&&!(a&&!X.summary)&&je&&Ue&&!X.error&&qe&&!(Ke&&(We.error||Ge?.notice))&&!H&&!he&&!J,tt=X.summary??void 0,nt=tt&&(tt.status===`queued`||tt.status===`running`),rt=!!tt&&tt.status!==`completed`&&!nt,it=He.at(-1)?.header,at=nt?it&&[`queued`,`running`].includes(it.status)?it.at:0:null,{tokens:ot,provider:st,model:ct}=X.context??{},lt=Ie.catalog?.entries??Ie.preview?.entries,ut=(0,f.useMemo)(()=>ot===void 0||st===void 0||ct===void 0?void 0:Us({tokens:ot,provider:st,model:ct},lt),[ot,st,ct,lt]),dt=X.refresh;(0,f.useEffect)(()=>{O&&dt()},[O,dt]);let Z=(0,f.useRef)(s);Z.current=s,(0,f.useEffect)(()=>{Z.current?.({id:t,turns:X.count,runningSince:at,...ut?{context:ut}:{}})},[t,X.count,at,ut]);let ft=He.at(-1),pt=!!ft&&[`queued`,`running`].includes(ft.header.status),mt=Vs(e,t,X.leaf,[ft?.header.id??``,X.count,X.branches,pt].join(),m&&!!tt),{tree:ht}=mt,gt=(0,f.useMemo)(()=>Rs(ht??{nodes:[],truncated:!1}),[ht]),_t=(0,f.useMemo)(()=>{let e=zs(ht?.nodes??[]).map(e=>({id:e.id,text:e.text}));if(!ft||!pt||e.some(e=>e.id===ft.header.id))return e;let t=zl(ft.steps).user[0]?.step.text??``;return[...e,{id:ft.header.id,text:Ks(t)}]},[ht,ft,pt]),[vt,yt]=(0,f.useState)(null),[bt,xt]=(0,f.useState)(null),[St,Ct]=(0,f.useState)(null),wt=!!u&&c&&(!!X.error||!!ke.error)&&X.error!==`retired-conversation`&&ke.error!==`retired-conversation`&&!Ge?.notice&&!nt&&!H&&!J&&!he,Tt=(g||!!u)&&je&&Ue&&Je&&!X.error&&!H&&!J&&!nt,Et=!!De&&q(De)!==q(Ae?.model??null),Dt=!!Ge?.proposal&&!!tt&&!nt&&tt.status!==`unknown`,Ot=Et?j(`Send with this model before approving a plan.`):tt?.status===`unknown`?j(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?Je?nt?j(`Wait for the current reply before approving this plan.`):Xe?j(`Observing plan approval…`):et?void 0:j(`Read the current conversation context before approving this plan.`):j(`Cadence state unavailable`):j(`Read the current execution state before approving this plan.`),kt=(0,f.useRef)(null),At=(0,f.useRef)(null),jt=(0,f.useRef)(0),Mt=(0,f.useRef)(!0),[Nt,Pt]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!D&&At.current&&!Mt.current&&(At.current.scrollTop=jt.current)},[D]);let Ft=(0,f.useRef)(``),It=(0,f.useRef)(ie);(0,f.useEffect)(()=>(F.current=!0,we.current.signal.aborted&&(we.current=new AbortController),()=>{F.current=!1,we.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${re}:mode`,B)}catch{}},[re,B]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(re,ie)}catch{}},[ie,re]),(0,f.useEffect)(()=>{try{J?sessionStorage.setItem(`${re}:pending`,J):sessionStorage.removeItem(`${re}:pending`)}catch{}},[re,J]),(0,f.useEffect)(()=>{try{J&&Y===J?sessionStorage.setItem(`${re}:model-command`,Y):sessionStorage.removeItem(`${re}:model-command`)}catch{}},[re,J,Y]),(0,f.useEffect)(()=>{w&&(M(e=>`${e}${e?`
|
|
29
|
+
`:``}@${w}`),E(),kt.current?.focus())},[w,E]),(0,f.useEffect)(()=>{let e=tt?`${tt.leaf}:${tt.status}`:``;e&&Ft.current!==e&&(Ft.current=e,C()),Qe.current&&Ge?.runs.includes(Qe.current)&&(Qe.current=``,Ze(``),G(``)),J&&(tt?.live?.commandId===J||X.attempt?.commandId===J||He.some(e=>e.header.id===J)||X.commands.includes(J))&&(ue(``),mc(J,Y)&&Oe(null),de(``),N(P.current),M(e=>e===It.current?``:e),mc(J,Y)&&Bc(n,It.current),z.current.followAnchor(),C()),Mt.current&&At.current&&(At.current.scrollTop=At.current.scrollHeight)},[tt,He,J,Y,C,Ge,X,N,n]);let Lt=(0,f.useMemo)(()=>He.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})),[He]),Rt=ps(At,Lt,bt?.id??null),{earlier:zt,loadEarlier:Bt}=X,Vt=()=>{let e=At.current;e&&!D&&zt&&e.scrollTop<1200&&Bt()};(0,f.useEffect)(Vt);let Ht=(0,f.useRef)(0),Ut=()=>{Ht.current||=requestAnimationFrame(()=>{Ht.current=0;let e=At.current;if(!e)return;let t=null;if(!Mt.current){let n=e.getBoundingClientRect().top+140;for(let r of e.querySelectorAll(`[data-lazy-id]`)){if(t!==null&&r.getBoundingClientRect().top>n)break;t=r.dataset.lazyId??null}}Ct(t)})};(0,f.useEffect)(()=>()=>{Ht.current&&cancelAnimationFrame(Ht.current)},[]),(0,f.useEffect)(()=>{if(!bt)return;let e=requestAnimationFrame(()=>{let e=[...At.current?.querySelectorAll(`[data-lazy-id]`)??[]].find(e=>e.dataset.lazyId===bt.id);e&&(Mt.current=!1,e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),Ct(bt.id))});return()=>cancelAnimationFrame(e)},[bt]);let Wt=He[0]?.ordinal,Gt=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=At.current;if(!e)return;let t=Gt.current;!Uu&&!Mt.current&&t.ordinal!==void 0&&Wt!==void 0&&Wt<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Gt.current={ordinal:Wt,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${re}:approval`)}catch{}},[re]);let Kt=(0,f.useMemo)(()=>[...new Set([...X.runs,...Ge?.runs??[]])],[X.runs,Ge?.runs]),qt=JSON.stringify(Kt.slice(-4));(0,f.useEffect)(()=>{A?.(JSON.parse(qt))},[qt,A]);let[Jt,Yt]=(0,f.useState)({terminal:8,browser:8}),Xt=(0,f.useMemo)(()=>[...new Set([...X.runs.slice(-Jt.terminal),...(Ge?.runs??[]).slice(-Jt.browser)])],[X.runs,Ge?.runs,Jt]),Zt=Ps(e,m?Xt:[],1e3),Qt=He.find(e=>e.header.at>0)?.header.at,$t=!zt&&He.length>0;(0,f.useEffect)(()=>{if(!m)return;let e=(e,t)=>Au(e,t,Zt.runs,Zt.unreadable,Qt,$t),t=e(X.runs,Jt.terminal),n=e(Ge?.runs??[],Jt.browser);(t!==Jt.terminal||n!==Jt.browser)&&Yt({terminal:t,browser:n})},[m,X.runs,Ge?.runs,Jt,Zt,Qt,$t]);let en=(0,f.useMemo)(()=>ku(He,Zt.runs.values(),zt),[He,Zt.runs,zt]),tn=[...Zt.runs.values()].filter(Eu).at(-1),nn=[...Zt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{nn&&Mt.current&&At.current&&(At.current.scrollTop=At.current.scrollHeight)},[nn]);let rn=t=>(0,h.jsx)(Mu,{client:e,run:t,onOpen:()=>k?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{We.refresh(),C()}},t.id),an=async()=>{if(!Ge?.proposal){le(j(`No plan is awaiting approval.`));return}if(Et||!l||!Je||!et||nt||Xe||!Dt)return;let t=Ge,n=Ce.current;U(!0),ce();try{let r=await Mc({client:e,state:t,current:()=>F.current&&Ce.current===n&&Ye.current?.revision===t.revision&&Ye.current?.enabled===!0,submitting:e=>{Qe.current=e,Ze(e)}});if(!F.current||Ce.current!==n)return;r.kind===`error`?(G(r.error.code),Ze(``)):M(e=>Pc(e)?``:e)}catch(e){F.current&&Ce.current===n&&G(e instanceof Error?e.message:`unavailable`)}finally{F.current&&Ce.current===n&&(U(!1),We.refresh(),X.refresh(),C())}},on=async(r,i)=>{let a=i?.text??r??ie,o=i?.images??(r?[]:ae.files),s=i?i.command.kind===`cadence-exit`:Ke&&Nc(a);if(!(s?Tt:et)&&!wt||nt||L&&!i||!a.trim()&&!o.length||i&&(!et||pc(i,Fe.current)!==`ready`))return;if(s&&o.length){le(j(`Remove images before exiting Cadence.`));return}if(!o.length&&!i&&!r&&Ke&&Pc(a)){l?await an():le(j(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let c=Va(a,B).mode===`cadence`;if(!wt&&(Ke||c)&&!Je){le(j(`Cadence state unavailable. Observe the conversation before sending.`));return}if(Se.current)return;Se.current=!0,U(!0),ce();let d=Ce.current,f=()=>F.current&&Ce.current===d,p=!1,m=`not-dispatched`,h=(e,t)=>{let n=j(ac(t),{code:e});t===`none`?le(n):G(n)},g=e=>{f()&&(ue(e),de(e&&!s?e:``))},_=async e=>{u&&(Ee(!0),await rc(u,we.current.signal,e,e=>{m=e}),f()&&(Ee(!1),be(e=>e+1)))};try{if(wt){if(await _(Ae?{id:t,cwd:Ae.cwd}:void 0),!f())return;X.refresh(),ke.refresh(),We.refresh(),C(),G(j(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let l=i??sc({id:t,head:s?X.leaf:Js(I,X.leaf),text:a,images:o,revision:Ge?.revision??0,location:Ae?{id:t,cwd:Ae.cwd}:void 0,installModel:!!De,model:De??(Ie.catalog?.selected?cc(Ie.catalog.selected):Ie.catalog?.remembered??Ae?.model??Ie.preview?.remembered??void 0),intent:s?`exit`:Ke?`message`:c?`enter`:`ordinary`});if(i){if(pc(i,Fe.current)!==`ready`)throw Error(`stale`)}else await _(l.location);if(!f())return;if(l.command.kind===`cadence-exit`){let t=gc(l);It.current=a,p=!0;let n=await oc(e,t,g);if(!f())return;n.kind===`error`?h(n.error.code,n.error.effect):(ue(``),V(`chat`),M(e=>e===a?``:e)),We.refresh(),X.refresh(),C();return}let u=e=>{let t=Fe.current,n=e??(t.status===`ready`?t.epoch:void 0);n&&pc(dc(l,n),t)!==`cancel`?(xe.current=dc(l,n),ge(!0)):(Le(),le(j(`The connection changed. Your model choice and draft are kept; send again when ready.`))),Re(!0)},d=await e.models(void 0,l.location);if(!f())return;if(l.preparedEpoch&&d.kind===`ok`&&d.value.version.epoch!==l.preparedEpoch)throw Error(`stale`);let m=d.kind===`ok`?d.value.selected??d.value.remembered:null;if(!l.model&&m&&(l=lc(l,m)),l.installModel&&d.kind===`ok`){if(d={kind:`ok`,value:await hc(e,l,d.value,f)},!f())return;be(e=>e+1)}let v=l.model??(d.kind===`ok`?d.value.remembered:null);if(d.kind===`ok`&&!d.value.selected&&v){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:d.value.version.epoch,...l.location?{location:l.location,expected:d.value.version,choice:v}:{}});if(!f())return;if(t.kind===`error`){G(t.error.code),u(d.value.version.epoch);return}if(d=await e.models(void 0,l.location),!f())return;be(e=>e+1)}if(d.kind!==`ok`||!d.value.selected){u(d.kind===`ok`?d.value.version.epoch:void 0);return}uc(l,d.value.selected);let y=gc(l,d.value.version);if(l.images.length){let t=d.value.selected;if(!d.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){le(j(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(y.kind===`cadence-exit`)throw Error(`invalid`);if(y=await xc(e,y,l.images,f),!f())return}P.current=l.images,It.current=a,p=!0;let b=await oc(e,y,g);if(!f())return;b.kind===`error`?h(b.error.code,b.error.effect):(N(P.current),Oe(null),M(e=>e===It.current?``:e),ue(``),y.kind===`cadence-send`&&V(`chat`),r||Bc(n,a),gn(null)),We.refresh(),X.refresh(),C()}catch(e){if(f()){let t=j(p?ac():ic(m),{code:e instanceof Error?e.message:`unavailable`});!p&&m===`not-dispatched`?le(t):G(t)}}finally{Ce.current===d&&(Se.current=!1),f()&&(U(!1),Ee(!1))}},sn=(0,f.useRef)(on);sn.current=on,(0,f.useEffect)(()=>{let e=xe.current;if(!e||!_e&&!he)return;let t=pc(e,Pe);t===`cancel`?(xe.current=null,ge(!1),ve(!1),To(`error`,j(`The connection changed. Your model choice and draft are kept; send again when ready.`),K)):_e&&t===`ready`&&et&&!nt&&(ve(!1),xe.current=null,sn.current(void 0,e))},[_e,he,et,nt,Pe,j,K]),(0,f.useEffect)(()=>{if(!_e)return;let e=setTimeout(()=>{ve(!1),xe.current=null},1e4);return()=>clearTimeout(e)},[_e]);let cn=nt?tt?.live:void 0,ln=(0,f.useRef)(new Map),un=Zs({images:ae.files.length,modeChange:Ke?Nc(ie):$e.mode===`cadence`,anchored:!!I,waiting:X.pending.length}),dn=!!cn&&g&&!H&&!L,fn=async r=>{if(!cn||!dn||un||!ie.trim())return;ce(),U(!0);let i=ie,a=Qs(t,cn,r,i),o=tc(await e.workbenchCommand(a));F.current&&(U(!1),o.kind===`accepted`?(ln.current.set(a.commandId,i),Bc(n,i),M(``)):o.kind===`refused`?le(j(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:b(j,o.code)})):G(o.code),X.refresh())},pn=async(n,r)=>{if(!cn||H)return;U(!0);let i=tc(await e.workbenchCommand($s(t,cn,n.commandId)));if(F.current){if(U(!1),i.kind===`accepted`){let e=ln.current.get(n.commandId)??n.text;ln.current.delete(n.commandId),r&&M(t=>t.trim()?t:e)}else i.kind===`refused`?le(i.code===`conflict`?j(`That message has already been handed to the model and can no longer be withdrawn.`):j(`The message was not withdrawn ({reason}).`,{reason:b(j,i.code)})):G(i.code);X.refresh()}},mn=e=>{M(t=>t.trim()?`${t}\n${e}`:e),kt.current?.focus()},hn=async()=>{let n=tt?.live;if(!n||H)return;U(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});F.current&&(r.kind===`error`&&G(r.error.code),U(!1),X.refresh())},gn=(e,n)=>{++Ce.current,we.current.abort(),we.current=new AbortController,xe.current=null,Se.current=!1,ge(!1),ve(!1),pe(!1),U(!1),Ee(!1),R(),X.choose(e,n),Ra(t,e)},_n=!nt&&!H&&!J&&!he,vn=()=>{ce(),kt.current?.focus()},yn=e=>{_n&&e.header.entry&&(e.ordinal>=X.count-1?R():se.continueAfter(e),vn())},bn=e=>{if(!_n)return;let t=He.find(t=>t.ordinal===e.ordinal-1);se.edit(e,t)?vn():le(j(`This message cannot be rewritten from here: the entry it continued is not known.`))},xn=(e,t)=>yt({id:e,then:t});z.current={chooseBranch:gn,followAnchor(){se.current()&&gn(null)},show:xn,stepVersion:(e,t)=>{let n=gt.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(gn(r.leaf===tt?.leaf?null:r.leaf,He.find(t=>t.header.id===e)?.ordinal),xn(r.id,`show`))}};let Sn=(0,f.useCallback)(e=>z.current.show(e,`continue`),[]),Cn=(0,f.useCallback)(e=>z.current.show(e,`edit`),[]),wn=(0,f.useCallback)((e,t)=>z.current.stepVersion(e,t),[]),Tn=(0,f.useCallback)(e=>z.current.show(e,`show`),[]);(0,f.useEffect)(()=>{if(!vt)return;let e=He.find(e=>e.header.id===vt.id);if(e){yt(null),vt.then===`edit`?bn(e):vt.then===`continue`&&yn(e),xt({id:e.header.id});return}let t=e=>{yt(null),le(e)};if(X.error)return yt(null);if(!Ue||!He.length&&X.count>0)return;if(!mt.current){mt.error&&!mt.loading&&t(b(j,mt.error));return}let n=ht?.nodes.find(e=>e.id===vt.id);if(n&&!n.current&&!vt.switched)return gn(n.leaf===tt?.leaf?null:n.leaf),yt({...vt,switched:!0});let r=Bs(_t,vt.id,He,X.count,pt);if(r===void 0||He.some(e=>e.ordinal===r))return t(j(`That message could not be found in this conversation.`));X.showFrom(r)});let En=tt?Ke?nt?j(`Discussing`):rt?ne(tt.status):Ge?.proposal?j(`Awaiting plan approval`):``:tt.status===`completed`?``:ne(tt.status):``,Dn=H||he||!!J||!!nt||L,On=e=>{if(!Dn)try{ae.add(e),ce()}catch(e){le(ne(e instanceof Error?e.message:`unavailable`))}},kn=(0,f.useRef)(ee);kn.current=ee;let An=(0,f.useMemo)(()=>({onShow:e=>z.current.show(e.id,`show`),onEdit:e=>z.current.show(e.id,`edit`),onContinue:e=>z.current.show(e.id,`continue`),onLatest:()=>z.current.chooseBranch(null)}),[]),{error:jn,loading:Mn,refresh:Nn}=mt,{pinned:Pn}=X;(0,f.useEffect)(()=>{kn.current?.({id:t,tree:ht,error:jn,loading:Mn,pinned:Pn,canAct:_n,onRefresh:Nn,...An})},[t,ht,jn,Mn,Pn,_n,Nn,An]);let Fn=I!==null&&(He.some(e=>e.header.id===I.turnId)||_t.some(e=>e.id===I.turnId))?I:null,In=Fn?Lt.find(({turn:e})=>Ys(Fn,e.ordinal))?.id:void 0,Ln=St===null?_t.length-1:_t.findIndex(e=>e.id===St),Rn=(0,f.useCallback)(()=>{Mt.current&&At.current&&(At.current.scrollTop=At.current.scrollHeight)},[]),zn=I?(0,h.jsxs)(`div`,{className:`composer-anchor`,children:[I.kind===`edit`?(0,h.jsx)(qi,{"aria-hidden":`true`}):(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,h.jsx)(`strong`,{children:I.kind===`edit`?j(`Rewriting a message`):j(`Continuing after an earlier turn`)}),I.label&&(0,h.jsx)(`span`,{className:`composer-anchor-quote`,children:I.label}),(0,h.jsxs)(`span`,{children:[I.kind===`edit`?j(`Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.`):j(`Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.`),` `,j(`Only the conversation is rewound: files on disk stay as they are.`)]}),L&&(0,h.jsx)(`span`,{children:j(`Reading the message's images…`)}),I.media&&(0,h.jsx)(`span`,{children:j(`Attachments that were not retained are not attached again.`)})]}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,title:j(`Cancel and restore the draft that was here`),disabled:H||!!J,onClick:()=>{R(),kt.current?.focus()},children:j(`Cancel`)})]}):Pn&&!nt?(0,h.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),(0,h.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,h.jsx)(`span`,{children:j(`A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.`)})})]}):void 0;return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:D,"aria-label":j(Je?Ke?`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)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:tt?.title??(a?j(`Discovered session`):X.summary===null?j(`New conversation`):j(`Conversation`))})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(0,h.jsxs)(`span`,{className:`conversation-meta`,children:[j(Je?Ke?`Cadence on`:`Ordinary`:`Cadence state unavailable`),tt&&` · ${tt.origin===`terminal`?j(`Started in the terminal`):j(`Started in the WebUI`)}`]}),tt?.archived&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:j(`Archived`)}),te&&(X.branches>1||Pn)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-label":j(`Branches ({count})`,{count:X.branches}),title:j(`Branches ({count})`,{count:X.branches}),onClick:te,children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),X.branches]}),Pn&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>gn(null),children:j(`Show the latest`)}),tn&&(0,h.jsx)(`span`,{className:`ep-state running`,role:`status`,children:ne(Ou(tn))}),tt&&En&&(!tn||rt||Ke&&!nt&&!!Ge?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${tt.status}`,children:En})]})]}),ke.error&&!wt&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(j,ke.error)}),wt&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),Te&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`Preparing execution for this Send…`)}),(0,h.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,h.jsxs)(`div`,{className:`chat-messages`,ref:At,onScroll:()=>{let e=At.current;e&&!D&&(jt.current=e.scrollTop,Mt.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Pt(!Mt.current),Vt(),Ut())},children:[a&&!X.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:j(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!m&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:j(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),X.summary===null&&!X.error&&!a&&(0,h.jsx)(vu,{hint:j(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),m&&!X.error&&(!Ue||He.length===0&&X.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:j(`Reading this conversation…`)}),He.length>0&&zt&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:X.loadingEarlier&&j(`Reading earlier messages…`)}),en.start.map(rn),Lt.map(({id:e,version:t,turn:n},r)=>{let i=gt.get(e);return(0,h.jsxs)(f.Fragment,{children:[e===In&&(0,h.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),j(`From here on, the turns stay on their branch: the message being written will not have them in its context.`)]}),(0,h.jsx)(ms,{id:e,show:!Rt.hidden.has(e)||e===bt?.id,height:Rt.placeholder(e,t,320),containerRef:At,onMeasured:Rt.recordMeasured,lazyRef:Rt.register(e),children:(0,h.jsx)(_u,{turn:n,onContinue:_n&&n.header.entry&&n.ordinal<X.count-1?Sn:void 0,onEdit:_n&&qs(n,Lt[r-1]?.turn)!==void 0?Cn:void 0,version:i?i.findIndex(t=>t.id===e)+1:0,versions:i?.length??0,onVersion:wn,off:Ys(Fn,n.ordinal)})}),en.after.get(e)?.map(rn)]},e)}),en.end.map(rn),X.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":j(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:X.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${X.attempt.status}`,children:ne(X.attempt.status)}),` `,X.attempt.notice?ne(X.attempt.notice):``]})]}),(0,h.jsx)(wu,{pending:X.pending,undelivered:X.undelivered,canWithdraw:!!cn&&g&&!H,recallable:e=>ln.current.has(e.commandId)||ec(e.text),onWithdraw:(e,t)=>void pn(e,t),onRestore:mn}),Ge?.enabled&&Ge.proposal&&(0,h.jsx)(Nu,{proposal:Ge.proposal,canApprove:!Et&&l&&et&&Je&&Dt&&!nt&&!Xe,approvalHint:Ot,onApprove:()=>void an()}),Ge?.enabled&&!Ge.proposal&&Kt.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:j(`Cadence stays on for this conversation until you explicitly exit.`)}),Zt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),Ge?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:ne(Ge.notice)}),[...new Set([W,X.error,We.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(j,e??``)},e)),X.error&&X.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:j(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),J&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[j(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:J}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:X.refresh,children:j(`Observe current state`)})]})]}),Nt&&(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{At.current&&(At.current.scrollTop=At.current.scrollHeight),Mt.current=!0},children:[(0,h.jsx)(ua,{"aria-hidden":`true`}),j(`Latest messages`)]}),vt&&(0,h.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:j(`Reading earlier messages…`)}),_t.length>1&&(0,h.jsx)(bu,{questions:_t,active:Ln,reading:vt?.id??null,onJump:Tn})]}),(0,h.jsx)(El,{inputRef:kt,draft:ie,onDraft:M,locked:H||!!J||he,images:ae.files,imageKey:ae.key,imagesLocked:Dn,onAddImages:On,onRemoveImage:e=>N([e]),anchor:zn,status:cn&&ie.trim()&&un?j(un===`images`?`A message into a running reply carries no images. Remove them, or send after the reply ends.`:un===`mode`?`Cadence mode is not changed by a message into a running reply. Send this after the reply ends.`:un===`full`?`Eight messages already wait for this reply. Withdraw one, or wait.`:`A message into a running reply continues that reply, not another entry.`):nt||wt||et||Te?void 0:j(J?`The last Send is not yet confirmed. No message is resent.`:he?`Choose a model; your message is sent right after.`:H?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`),cadence:{active:Ke,armed:$e.mode===`cadence`,known:Je,disabled:Ke?!Tt:!!nt||H||!!J||he,onClick:()=>{Ke?on(`exit cadence`):$e.mode===`cadence`?(V(`chat`),Va(ie,`chat`).mode===`cadence`&&M($e.text)):V(`cadence`)}},model:{client:Ne,availability:Pe,read:Ie,lastModel:Ae?.model,draftModel:De,onPreviewChoice:v?e=>ze(e,!1):void 0,locked:!!nt||H||!!J,open:fe,onOpenChange:Re,onChanged:()=>{ke.refresh(),S()},onChosen:e=>ze(e,!0),awaitingSend:he},hint:cn&&dn&&!un&&ie.trim()?j(`Enter steers this reply · Alt+Enter queues behind it`):Ke?j(`Cadence stays on. Confirm one plan before implementation.`):$e.mode===`cadence`?j(`Your next message turns on Cadence mode.`):``,running:!!nt,canStop:!H&&g,onStop:()=>void hn(),canSend:((Ke&&Nc(ie)?Tt:et)||wt)&&!L&&(!!ie.trim()||ae.files.length>0),onSend:()=>void on(),input:cn?{enabled:dn&&!un&&!!ie.trim(),onInput:e=>void fn(e)}:void 0,historyScope:n,files:{client:e,location:m&&je&&Ae?{id:t,cwd:Ae.cwd}:void 0},onResized:Rn})]})}function Ku(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
30
|
+
`)?``:`
|
|
31
|
+
`}${r}`}var qu=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function Ju(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}var Yu=(0,f.memo)(function({path:e,text:t}){return(0,h.jsx)(Io,{text:Ku(t,Al(e))})});function Xu({client:e,enabled:t,location:n,observed:r=``,onReference:i}){let{t:a}=T(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1),{copied:v,copy:y}=fo(),x=Ba(e,t?{kind:`files`,path:o,...n?{location:n}:{}}:null),S=Ba(e,t&&c?{kind:`file`,path:c,...n?{location:n}:{}}:null),{refresh:C}=x,{refresh:w}=S,E=(0,f.useRef)(r);(0,f.useEffect)(()=>{E.current!==r&&(E.current=r,C(),w())},[r,C,w]);let D=x.value?.kind===`files`?x.value:void 0,O=S.value?.kind===`file`?S.value:void 0,k=e=>{s(e),d(null)},A=u?.trim().toLowerCase()??``,ee=D?.entries.filter(e=>!A||e.name.toLowerCase().includes(A));return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsx)(`button`,{type:`button`,className:`crumb${o?``:` active`}`,title:n?`${a(`Conversation folder:`)} ${n.cwd}`:void 0,disabled:!n,onClick:()=>k(``),children:n?qu(n.cwd):a(`Not observed`)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:a(`Refresh files`),"aria-label":a(`Refresh files`),disabled:!t,onClick:()=>{x.refresh(),S.refresh()},children:(0,h.jsx)(xi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${u===null?``:` active`}`,"aria-label":a(`Filter this folder…`),title:a(`Filter this folder…`),"aria-pressed":u!==null,disabled:!D,onClick:()=>d(u===null?``:null),children:(0,h.jsx)(yi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${g?` active`:``}`,"aria-label":a(`About this panel`),title:a(`About this panel`),"aria-expanded":g,onClick:()=>_(e=>!e),children:(0,h.jsx)(zi,{"aria-hidden":`true`})}),Ju(o).map(e=>(0,h.jsxs)(`span`,{className:`crumb-seg`,children:[(0,h.jsx)(na,{"aria-hidden":`true`}),(0,h.jsx)(`button`,{type:`button`,className:`crumb${e.path===o?` active`:``}`,title:e.path,onClick:()=>k(e.path),children:e.label})]},e.path))]}),g&&(0,h.jsx)(`p`,{className:`files-policy`,children:a(`Readonly preview · references send paths, not file contents`)}),u!==null&&(0,h.jsxs)(`label`,{className:`file-filter`,children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{autoFocus:!0,value:u,"aria-label":a(`Filter this folder…`),placeholder:a(`Filter this folder…`),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&d(null)}}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close`),onClick:()=>d(null),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]}),x.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(a,x.error)}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":a(`File list`),children:[t?!D&&!x.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(`Reading files…`)}):null:(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(n?`Files appear once this folder has been observed.`:`The conversation folder has not been observed.`)}),D&&D.parent!=null&&!A&&(0,h.jsxs)(`button`,{type:`button`,className:`file-item dir`,"aria-label":a(`Parent folder`),title:a(`Parent folder`),onClick:()=>k(D.parent??``),children:[(0,h.jsx)(Hi,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:`..`})]}),ee?.map(e=>(0,h.jsxs)(`div`,{className:`file-item ${e.directory?`dir`:`file`}${c===e.path?` selected`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-main`,title:e.path,onClick:()=>e.directory?k(e.path):l(e.path),children:[e.directory?(0,h.jsx)(Hi,{className:`file-icon`,"aria-hidden":`true`}):(0,h.jsx)(Ui,{className:`file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-name`,children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach`,"aria-label":a(`Reference {path}`,{path:e.name}),title:a(`Reference {path}`,{path:e.name}),disabled:!t||!!x.error,onClick:()=>i(e.path),children:(0,h.jsx)(Pi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`file-attach${v&&p===e.path?` copied`:``}`,"aria-label":a(`Copy path {path}`,{path:e.name}),title:a(`Copy path {path}`,{path:e.name}),onClick:()=>{m(e.path),y(e.path).then(e=>{e||To(`error`,a(`Copy unavailable`))})},children:v&&p===e.path?(0,h.jsx)(aa,{"aria-hidden":`true`}):(0,h.jsx)(Qi,{"aria-hidden":`true`})})]},e.path)),t&&!x.error&&ee?.length===0&&(A?(0,h.jsx)(`p`,{className:`panel-empty`,children:a(`No matching files`)}):(0,h.jsx)(`p`,{className:`panel-empty`,children:a(`No visible files`)})),D?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`Bounded listing; narrow the directory to see more.`)})]}),c&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(Ui,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{title:c,children:qu(c)}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close preview`),title:a(`Close preview`),onClick:()=>l(null),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]}),S.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,S.error)}),O&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Yu,{path:O.path,text:O.text}),O.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`File preview is limited; this is not the complete file.`)})]})]})]})}var Zu=`未命名章节`;function Qu(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 $u(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Qu(r||Zu),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Zu}})}function ed(e){return e.length>=2}function td(e){let t=0,n=0;return e.split(`
|
|
32
|
+
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function nd({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:td(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 rd({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(`
|
|
33
|
+
`);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=$u(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)(Ao,{text:u?g.slice(u.start-1,u.end).join(`
|
|
34
|
+
`):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:[ed(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)(Io,{text:e})})]}):n===`diff`?(0,h.jsx)(nd,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:td(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 id({client:e,seed:t}){let{t:n,tx:r}=T(),i=so(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(qo,{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(ao(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)(Ko,{client:e,cursor:a,render:e=>(0,h.jsx)(rd,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var ad=[`contents`,`checks`,`changes`,`reviews`];function od({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:ad.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)(Jo,{client:e,seed:t}):(0,h.jsx)(id,{client:e,seed:{...t,reader:i}},i)})]})}var sd={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.`},cd=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function ld(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 ud({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),ee=(0,f.useRef)(void 0),te=(0,f.useRef)(n??t),j=(0,f.useRef)(null),ne=(0,f.useRef)(null),re=async t=>{ee.current?.abort();let n=new AbortController;ee.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(ee.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`})}},ie=(0,f.useRef)(re);(0,f.useEffect)(()=>(A.current=!0,ie.current(te.current).then(()=>{A.current&&w(!1)}),()=>{A.current=!1,ee.current?.abort()}),[]),(0,f.useEffect)(()=>{_&&j.current?.select()},[_]),(0,f.useEffect)(()=>{ne.current&&(ne.current.scrollLeft=ne.current.scrollWidth)});let M=e=>{E||re(e)},ae=()=>{let e=m.trim();E||(cd(e)?re(e):k({step:`read`,code:`relative`}))},N=(_||!d)&&m.trim()||d?.path||``,oe=!E&&!x&&!!N,P=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!cd(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await re(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)}},F=d?ld(d.path,r):void 0,se=y.trim().toLowerCase(),I=d?.entries.filter(e=>e.name.toLowerCase().includes(se))??[],L=O&&(O.step===`read`&&sd[O.code]?l(sd[O.code]):u(O.code));return(0,h.jsxs)(Qo,{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 P(e.path),children:[(0,h.jsx)(Hi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[F&&!_?(0,h.jsxs)(`nav`,{ref:ne,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:()=>M(`~`),children:[(0,h.jsx)(Ri,{"aria-hidden":`true`}),F.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),F.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||F.inside)&&(0,h.jsx)(na,{"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:()=>M(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(),ae()},children:(0,h.jsx)(`input`,{ref:j,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:m,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{g(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),k(null))}})}),d&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":_,disabled:E,onClick:()=>{g(d.path),v(!_),k(null)},children:(0,h.jsx)(qi,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(yi,{"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:()=>M(d.parent),children:[(0,h.jsx)(sa,{}),l(`Parent folder`)]}),I.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>M(e.path),children:[(0,h.jsx)(Hi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&I.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(se?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),L&&(0,h.jsxs)(`p`,{role:`alert`,children:[L,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:[N&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:N})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!oe,onClick:()=>void P(N),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function dd(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var fd=[`today`,`yesterday`,`earlier`];function pd(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function md(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=pd(t(i),n);r.set(e,[...r.get(e)??[],i])}return fd.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function hd(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function gd(e,t,n=Date.now()){let r=new Date(e);return pd(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function _d({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)(Si,{"aria-hidden":`true`}),n(`New conversation`)]})})}function vd(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var yd=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),bd=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function xd(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var Sd={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},Cd={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},wd={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},Td=e=>`conversation-row:${e}`;function Ed(e,t){return t.kind===`refused`?{refusal:{text:Cd[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function Dd(e,t){let{t:n}=T(),[r,i]=(0,f.useState)(()=>new Map),a=(0,f.useRef)(!0);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Do(Td(c)),l({pending:o}),xd(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=Ed(o,e);l(r),i&&To(`error`,n(i.text,{code:i.code}),Td(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,yd(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,bd(e,t))}}function Od({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=T(),d=u===`zh`?`zh-CN`:`en-GB`,[p,m]=(0,f.useState)(null),g=p!==null,_=(0,f.useRef)(null),v=(0,f.useRef)(null),y=(0,f.useRef)(!1);(0,f.useEffect)(()=>{let e=_.current;if(!g||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,m(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,h.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,h.jsx)(pi,{"aria-hidden":`true`}):(0,h.jsx)(ki,{"aria-hidden":`true`})}),S=()=>{if(p===null)return;let t=vd(p);t===null?To(`error`,l(`A name can have at most {count} characters.`,{count:100}),Td(e.id)):(y.current=!0,m(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(Sd[a.pending]):a?.unknown?l(wd[a.unknown.action],{code:a.unknown.code}):``;return g?(0,h.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||m(null)},children:[(0,h.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,h.jsx)(`input`,{ref:_,className:`session-rename-input`,value:p,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>m(e.target.value)})]}),(0,h.jsxs)(`span`,{className:`session-actions`,children:[(0,h.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,h.jsx)(aa,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,m(null)},children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]})]}):(0,h.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,h.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,h.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:gd(e.updatedAt,d)})]}),c&&(0,h.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,h.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>m(e.title),children:(0,h.jsx)(qi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,h.jsx)(bi,{"aria-hidden":`true`}):(0,h.jsx)(da,{"aria-hidden":`true`})})]}),w&&(0,h.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function kd({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=T(),a=e.value?.entries??[];return(0,h.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,h.jsx)(la,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,b(i,e.error)]}),e.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,h.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,h.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var Ad={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function jd({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,h.jsxs)(`header`,{className:`lp-section-header`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(ia,{"aria-hidden":`true`}):(0,h.jsx)(na,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,h.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function Md({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=dd(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)(na,{"aria-hidden":`true`}):(0,h.jsx)(ia,{"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)(Yi,{"aria-hidden":`true`}):(0,h.jsx)(ki,{"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 Nd({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)(Md,{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)(qo,{pager:e,compact:!0})]})}function Pd({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,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:A,onCancelWorkflow:ee}){let{t:te,tx:j}=T(),[ne,re]=(0,f.useState)(``),[ie,M]=(0,f.useState)(!1),ae=Ha(e,ie,!0),N=ae.refresh,oe=Dd(e,e=>{N(),C?.(e)}),P=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,F=so(e,P),se=so(e,r&&P&&t?{...P,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),I=F.page&&!(`kind`in F.page)?F.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],L=s?.status===`complete`?s.runs:[],R=I.filter(e=>!L.some(t=>t.taskId===e.owner.taskId)),z=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":te(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:te(`Task conversations`)}),(0,h.jsx)(Nd,{pager:se,scope:i,onScope:p,exclude:L.map(e=>e.runId)},r)]}),[B,V]=(0,f.useState)(()=>new Set),H=e=>{let t=E.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${k===e.id||t&&t===y?` active`:``}`,onClick:()=>A?.(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:[te(`Cadence workflow`),` · `,j(e.phase),` · `,j(e.status)]})]})]}),ee&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:B.has(e.id),onClick:()=>{V(t=>new Set(t).add(e.id)),ee(e).finally(()=>V(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(hi,{"aria-hidden":`true`}),te(`Cancel workflow — request stop`)]})]},e.id)},U=m.filter(e=>e.status===`running`||e.status===`queued`),W=m.filter(e=>!U.includes(e)),G=e=>w?.findLast(t=>E.some(n=>n.runId===t.id&&n.conversationId===e.id)),K=e=>{let t=e.status===`running`||e.status===`queued`,n=t||e.status===`completed`?G(e):void 0,r=n?j(Ou(n)):e.cadence&&t?te(`Discussing`):e.status===`completed`?``:j(e.status);return(0,h.jsx)(Od,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:oe.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>oe.archive(e.id,t),onRename:t||e.archived?void 0:t=>oe.rename(e.id,t)},e.id)},ce=W.filter(e=>hd(e.title,ne)),q=R.filter(e=>hd(e.goal,ne));return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,h.jsx)(xs,{...O,represented:!n&&O.project?[...(w??[]).map(e=>bs(O.project,`workflow`,e.id,e.epoch)),...U.flatMap(e=>e.live?[bs(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(_d,{onConversation:x}),!n&&(0,h.jsxs)(jd,{title:te(`Running work`),count:s?.status===`complete`&&w&&!D&&g?String(L.length+U.length+w.length):te(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:te(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,h.jsx)(`p`,{className:`panel-hint`,children:te(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:te(`Conversation activity unavailable.`)}),U.map(K),w?.map(H),s?.status===`complete`&&L.length===0&&U.length===0&&w?.length===0&&!D&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:te(`No active runs`)}),L.map(e=>{let t=I.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??te(`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)(hi,{"aria-hidden":`true`}),te(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(Md,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(jd,{title:te(ie?`Archived conversations`:`Conversation history`),count:ie?ae.value?`${ae.value.entries.length}${ae.value.next||ae.canPrevious?`+`:``}`:te(`Not observed`):t?F.page&&!(`kind`in F.page)?`${W.length+R.length}${F.page.next||F.canPrevious||_?`+`:``}`:te(`Not observed`):`${W.length}${_?`+`:``}`,className:`grow`,actions:(0,h.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":ie,title:te(ie?`Back to history`:`Show archived`),"aria-label":te(ie?`Back to history`:`Show archived`),onClick:()=>M(e=>!e),children:(0,h.jsx)(da,{"aria-hidden":`true`})}),children:[ie&&(0,h.jsx)(kd,{list:ae,unavailable:S,onBack:()=>M(!1),row:K}),(0,h.jsxs)(`nav`,{"aria-label":te(`Tasks`),className:`task-list`,hidden:ie,children:[(W.length>0||R.length>0)&&(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:ne,placeholder:te(`Filter conversations…`),"aria-label":te(`Filter conversations…`),onChange:e=>re(e.target.value)}),ne&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:te(`Clear filter`),"aria-label":te(`Clear filter`),onClick:()=>re(``),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]}),S&&W.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),md(ce,e=>e.updatedAt).map(e=>(0,h.jsxs)(`div`,{className:`lp-time-group`,children:[(0,h.jsx)(`h3`,{className:`lp-time-label`,children:te(Ad[e.key])}),e.items.map(K)]},e.key)),q.length>0&&(0,h.jsx)(`h3`,{className:`lp-time-label`,children:te(`Tasks`)}),q.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)(ki,{"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:te(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&z]},e.owner.taskId)),ce.length===0&&q.length===0&&(W.length>0||R.length>0)&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:te(`No listed conversation matches. Pages not loaded are not searched.`)}),F.page&&!(`kind`in F.page)&&R.length===0&&W.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:te(`No conversations yet.`)}),v,t&&(0,h.jsx)(qo,{pager:F,compact:!0})]}),!ie&&!q.some(e=>e.owner.taskId===r)&&z]})]})}var Fd=[`queued`,`running`];function Id({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Ba(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?Fd.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Fd.includes(u.status)&&c(0)},[u]);let m=Ba(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?Dl(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Ba(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)(Yi,{"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)(Fu,{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)(_u,{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)(Io,{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 Ld({path:e,disabled:t=!1,onClick:n}){let{t:r}=T(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;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)(Hi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Rd({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 zd(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Na();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:U(e)});if(n&&(a.set(`scope`,JSON.stringify(Le(n.scope))),n.snapshotSeq&&a.set(`snapshot`,G(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Bd(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=U(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?Le(le(r)):void 0,o=i?G(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=ze(le(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Vd=`cadence-panel-layout-v1`,Hd={left:260,right:360,navigation:!0,inspector:!1};function Ud(e,t=600){return Math.max(220,Math.min(t,e))}function Wd(e){let t={...Hd};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]=Ud(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Gd(e,t){let n=e<=900,r=Ud(t.left,e-560),i=Ud(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:Ud(e-560-s),rightMaximum:Ud(e-560-a)}}function Kd({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(Ud(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(Ud(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Ud(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var qd=[],Jd={error:pa,warning:fa,info:Ii};function Yd({toast:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=n||i,s=vo(e.level);(0,f.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Eo(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Jd[e.level];return(0,h.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,h.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,h.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Eo(e.id),children:(0,h.jsx)(ui,{"aria-hidden":`true`})})]})}function Xd(){let e=(0,f.useSyncExternalStore)(Oo,ko,()=>qd);return(0,h.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,h.jsx)(Yd,{toast:e},e.id))})}function Zd(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 Qd=.4,$d=1.05;function ef(e){return Math.min(300,e*.86)}function tf(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function nf(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function rf(e,t){return e===`left`?t:-t}function af(e,t){return Math.max(-e,Math.min(0,-e+t))}function of(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function sf(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:of(r*$d,n,t)>=Qd}var cf=new Set([`auto`,`scroll`,`overlay`]);function lf(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&cf.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function uf(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function df(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=tf(r.clientX,window.innerWidth,n);i&&!lf(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=nf(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=ef(window.innerWidth),h=m*$d;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=rf(r,d);let b=af(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(of(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?sf({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(uf(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var ff={system:[Ei,`System`],light:[mi,`Light`],dark:[Ti,`Dark`]};function pf({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,compatible:u,onRefresh:d,onDisconnect:p,onOpenService:m,content:g}){let{t:_,locale:v,setLocale:y}=T(),[b,S]=(0,f.useState)(te),[C,w]=ff[b],E=_(`Theme: {current}. Switch to {next}.`,{current:_(w),next:_(ff[ne(b)][1])}),{mobile:D,overlay:O,closeDrawer:k}=e,A=(0,f.useRef)(null),ee=(0,f.useRef)(null),re=()=>{ee.current&&(ee.current.open=!1)};return df({enabled:D,open:O,onOpenChange:e.setDrawer,container:A}),Zd(A,O,!!O,k),(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":_(`Toggle conversation navigation`),"aria-expanded":D?O===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(Ai,{"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`}),a,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o,(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)(Bi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:v===`zh`?`EN`:`中文`})]}),(0,h.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":E,"data-tip":E,onClick:()=>{let e=ne(b);j(e),S(e)},children:(0,h.jsx)(C,{"aria-hidden":`true`})}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:ee,onKeyDown:e=>{e.key===`Escape`&&ee.current&&(ee.current.open=!1,ee.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":_(`More`),title:_(`More`),children:(0,h.jsx)(wi,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Observe current state`),onClick:()=>{re(),d()},children:[(0,h.jsx)(xi,{"aria-hidden":`true`}),_(`Refresh status`)]}),m&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Cadence service`),onClick:()=>{re(),m()},children:[(0,h.jsx)(vi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[_(`Cadence service`),(0,h.jsx)(`small`,{children:_(`Version, restart and upgrade.`)})]})]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":_(`Disconnect this page`),title:_(`Return — accepted work continues`),onClick:()=>{re(),k(),p()},children:[(0,h.jsx)(Mi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[_(`Disconnect this page`),(0,h.jsx)(`small`,{children:_(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${u===!1?` warn`:``}`,title:Aa?.buildId??_(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:_(`Shared compatibility: {state}.`,{state:_(u===void 0?`Execution compatibility not observed`:u?`compatible`:`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:_(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Aa?.buildId??_(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":_(`Toggle workspace panels`),"aria-expanded":D?O===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(_i,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??_(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{ref:A,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":_(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${O?` on`:``}`,onClick:k}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${O===`left`?` open`:``}`,"aria-label":_(`Conversation navigation`),tabIndex:-1,inert:D?O!==`left`:!e.navigation||O===`right`,children:t}),(0,h.jsx)(Kd,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:O!==null,children:g}),(0,h.jsx)(Kd,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${O===`right`?` open`:``}`,"aria-label":_(`Files and history drawer`),tabIndex:-1,inert:D?O!==`right`:!e.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":_(`Workspace panels`),children:[i??(0,h.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,h.jsx)(Hi,{"aria-hidden":`true`}),_(`Files`)]}),(0,h.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":_(`Collapse panel`),title:_(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,h.jsx)(na,{"aria-hidden":`true`})})]}),n]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,h.jsx)(Xd,{})]})}function mf({usage:e}){let{t}=T(),{tokens:n,window:r}=e,i=n!==null&&r?Gs(n,r):null,a=n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:Ws(n),window:Ws(r),percent:i}):t(`Context {used} tokens`,{used:Ws(n)}),o=[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `);return(0,h.jsxs)(`span`,{className:`status-item status-ctx${i!==null&&i>=90?` warn`:``}`,title:o,children:[(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,h.jsx)(Ci,{})}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a}),n!==null&&r&&(0,h.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:(0,h.jsx)(`span`,{style:{width:`${Math.min(100,i??0)}%`}})})]})}function hf({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,h.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,h.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function gf(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function _f({since:e,label:t}){let[n,r]=(0,f.useState)(Date.now);(0,f.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?gf(n-e):``;return(0,h.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,h.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function vf(){let[e,t]=(0,f.useState)(()=>{try{return Wd(localStorage.getItem(Vd))}catch{return Wd(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=Gd(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Vd,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 yf(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 bf=`modulepreload`,xf=function(e){return`/`+e},Sf={},Cf=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=xf(t,n),t=s(t),t in Sf)return;Sf[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`:bf,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 wf({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=so(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)(qo,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Tf,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Tf({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 Cf(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,yf(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)(Jo,{client:e,seed:t})]})}var Ef=[[`tools`,fi],[`context`,Fi],[`timeline`,ea],[`runs`,Vi]];function Df({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??ja()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(Bd),[w,E]=(0,f.useState)(C?.taskId??null),[D,O]=(0,f.useState)(()=>C?null:Pa()??crypto.randomUUID()),k=Ia(y,D??``),[A,ee]=(0,f.useState)(null),[te,j]=(0,f.useState)([]),[ne,re]=(0,f.useState)(null),[ie,M]=(0,f.useState)(C?`task`:`files`),[ae,N]=(0,f.useState)(),[oe,P]=(0,f.useState)(),[F,se]=(0,f.useState)(),[I,L]=(0,f.useState)(),[R,z]=(0,f.useState)(0),[B,V]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Pa();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[H]=(0,f.useState)(()=>crypto.randomUUID()),U=(0,f.useCallback)(()=>P(void 0),[]),[W,G]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),K=Za(s?.id,s?.epoch),ce=!s||K.readiness===`running`,le=!!s&&(K.readiness===`stopped`||K.readiness===`not-started`),J=(0,f.useRef)(null);ce&&K.value?.epoch&&(J.current=K.value.epoch);let ue=!s||!le&&(ce||J.current!==null),Y=eo(v,w?{kind:`task`,id:w}:null,!x&&ue,J.current),de=(0,f.useRef)(!0);(Y.workspace||Y.observation||Y.error||Y.transportStatus===`stale`||Y.compatible===!1)&&(de.current=!1);let fe=!!(s&&(K.value||K.error)),pe=!x&&!!(Y.workspace||fe),me=(0,f.useRef)(null);(Y.workspace||K.value?.workspaceId)&&(me.current=Y.workspace?.workspaceId??K.value?.workspaceId??null);let he=l?async(e,t,n)=>{let r=await l(e,t,n);if(e.aborted)throw Error(`stale`);K.prepared(r);let i=Y.reconnect();await Y.whenReady(r,e,i)}:void 0,ge=Ha(v.client,pe),_e=Ba(v.client,Y.workspace&&!x?{kind:`conversation-active`}:null,1e3),ve=_e.value?.kind===`conversation-active`?_e.value.entries:[],ye=[...ve,...(ge.value?.entries??[]).filter(e=>!ve.some(t=>t.id===e.id))],be=Ba(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),xe=be.value?.kind===`workflow-active`?be.value:void 0,Se=(0,f.useMemo)(()=>[...new Set([...xe?.runs.map(e=>e.id)??[],...te])],[xe,te]),Ce=Ba(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),we=B??s?.cwd??(Ce.value?.kind===`projects`?Ce.value.entries.find(e=>e.current)?.path:void 0),Te=F?.id===D?F:void 0,Ee=I?.id===D?I:void 0;(0,f.useEffect)(()=>{Te&&Pa()===Te.id&&history.replaceState({...history.state,cadenceCwd:Te.cwd,cadenceConversationId:Te.id},``,location.href)},[Te]);let De=D?Te:we?{id:H,cwd:we}:void 0,Oe=Te?.cwd??we??(Ce.value?.kind===`projects`?Ce.value.entries.find(e=>e.current)?.path:void 0)??Y.workspace?.rootLabel,ke={state:Y.observation,transportStatus:Y.transportStatus,error:Y.error,refresh:Y.refresh},Ae=ke.state?.snapshot.scope.kind===`task`&&ke.state.snapshot.scope.id===w?ke.state.snapshot.context:void 0,je=vf(),{closeDrawer:Me}=je,Ne=ie===`branches`&&!!D,Pe=!Ne&&(ie!==`task`||!W),Fe=()=>{M(`branches`),je.mobile?je.setDrawer(`right`):je.inspector||je.toggle(`right`)},[Ie,Le]=(0,f.useState)(C?.snapshotSeq),[Re,ze]=(0,f.useState)(``),[Be,Ve]=(0,f.useState)(``),X=(0,f.useRef)(null),[He,Ue]=(0,f.useState)(`messages`),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(!1),[Je,Ye]=(0,f.useState)(),[Xe,Ze]=(0,f.useState)(C?.cursor),[Qe,$e]=(0,f.useState)(``),[et,tt]=(0,f.useState)([]),[nt,rt]=(0,f.useState)(new Set),it=(0,f.useRef)(!0),at=e=>{it.current&&tt(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?za(t,e):t)})},ot=(0,f.useRef)(new to),st=q({taskId:w,scope:W,selectedSnapshot:Ie??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ot.current.select(st),(0,f.useEffect)(()=>(it.current=!0,()=>{it.current=!1,ot.current.depart()}),[]);let ct=e=>{b(``);let t=e??crypto.randomUUID();e||V(Oe??we),ee(null),t!==D&&(j([]),P(void 0)),ot.current.depart(),O(t),E(null),G(null),ze(``),Ve(``),Ye(void 0),Ze(void 0),Le(void 0),Ue(`messages`),M(e=>e===`task`?`files`:e),Me();let n=t===D?Ia(location.hash,t).leaf:null;history.replaceState({cadenceCwd:Oe??we,cadenceConversationId:t},``,`${location.pathname}${location.search}${La(`#chat=${t}`,n)}`)};(0,f.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let lt=(e,t)=>{ee(null),j([]),O(null),M(`task`),ze(t??``),Ve(``),Le(void 0),ot.current.depart(),E(e),G({kind:`task`,id:e}),Ye(void 0),Ze(void 0),Ue(`messages`),Me(),history.replaceState(null,``,zd(e))};(0,f.useEffect)(()=>{let e=()=>{let e=Bd();if(e)ee(null),j([]),O(null),M(`task`),ot.current.depart(),Le(e.snapshotSeq),ze(``),Ve(``),E(e.taskId),G(e.scope??{kind:`task`,id:e.taskId}),Ye(void 0),Ze(e.cursor),Ue(`messages`),Me();else{let e=Pa();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&V(t),P(void 0),ee(null),j([]),O(e),E(null),G(null),M(e=>e===`task`?`files`:e),ot.current.depart(),Me()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Me]);let ut=(e,t,n)=>{ee(null),Le(t),Ve(n??``),ot.current.depart(),G(e),Ye(void 0),Ze(void 0),Ue(`messages`),Me(),w&&history.replaceState(null,``,zd(w,void 0,{scope:e,snapshotSeq:t}))},dt=Ie??ke.state?.snapshot.committedSeq??Y.workspace?.committedSeq,Z=Y.workspace?.storeId,ft=W&&Z&&dt?{storeId:Z,scope:W,snapshotSeq:dt,reader:`messages`,after:null,limit:50}:null,pt=W&&Z&&dt?{storeId:Z,scope:W,snapshotSeq:dt,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,mt=Ae?ke.state?.snapshot.runs??[]:[],ht=ot.current.ticket(),gt=e=>{at(e),e.receipt&&ot.current.current(ht)&&Y.refresh()},_t=e=>{if(nt.has(e)||!Y.cancelCompatible||!Y.activeRuns)return;let t=crypto.randomUUID(),n=Y.activeRuns.epoch;rt(t=>new Set(t).add(e)),at({commandId:t,error:g(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{gt(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(()=>at({commandId:t,error:g(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{it.current&&rt(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.`)}),et.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 vt=Y.activeRuns,yt=vt?.status===`complete`?vt.runs:[],bt=!x&&!Y.error&&Y.transportStatus===`current`&&(!ke.state||ke.state.connection===`current`),xt=ce&&bt,St=ce&&!!Y.workspace&&!!Y.compatible&&!Y.error&&bt,Ct=de.current&&!ke.state&&!ke.error&&!K.error&&(!s||!K.value&&K.readiness===`unknown`||K.readiness===`running`),wt=le?{status:K.readiness===`not-started`?`not-started`:`stopped`}:Y.compatible===!1?{status:`incompatible`}:ce&&bt&&Y.compatible&&Y.epoch&&(!s||K.value?.epoch===Y.epoch)?{status:`ready`,epoch:Y.epoch,attachmentVersion:Y.attachmentVersion}:{status:Ct?`connecting`:`unavailable`},Tt=x?`Viewer disconnected`:Ct?`Connecting…`:s&&K.readiness===`unknown`?`Project readiness unknown`:s&&K.readiness===`stale`?`Project observation stale`:le?`Ready to prepare on Send`:bt?Y.workspace?ke.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)(pf,{panels:je,compatible:Y.compatible,onOpenService:o,onRefresh:()=>{Y.refresh(),K.refresh()},onDisconnect:()=>{Ge(!1),qe(!1),ot.current.depart(),S(!0)},inspectorLabel:g(W&&ie===`task`?`History details`:Ne?`Branches`:`Files`),toolbar:W&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":He===`messages`&&!Xe,onClick:()=>{Ze(void 0),Ye(void 0),Ue(`messages`)},children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:X,onKeyDown:e=>{e.key===`Escape`&&X.current&&(X.current.open=!1,X.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[He===`messages`?g(`Details`):_(He),(0,h.jsx)(ia,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Ef.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":He===e,onClick:()=>{Ze(void 0),Ye(void 0),Ue(e),X.current&&(X.current.open=!1,X.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:!ft,onClick:()=>{X.current&&(X.current.open=!1,X.current.querySelector(`summary`)?.focus()),qe(!0)},children:[(0,h.jsx)(Ji,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&uo(zd(w,Xe,W?{scope:W,snapshotSeq:Ie}:void 0)).then(e=>e?To(`info`,g(`Link copied.`)):To(`error`,g(`Link copy unavailable.`)))},children:[(0,h.jsx)(Pi,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:W&&(0,h.jsx)(ss,{disabled:!pt,onOpen:()=>Ge(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!Y.workspace&&yt.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:yt.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:()=>lt(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.cancelCompatible||nt.has(e.runId),onClick:()=>_t(e.runId),children:[(0,h.jsx)(hi,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(Rd,{error:Qe,projectObservationError:K.error,observationError:Y.error,unavailable:!Ct&&!le&&!xt,onRefresh:()=>{Y.refresh(),K.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!pe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(xs,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(Ct?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,h.jsx)(Pd,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:le,taskId:w,scope:W,runs:mt,snapshot:ke.state?.snapshot.committedSeq,activeRuns:Y.activeRuns,cancelCompatible:!!Y.cancelCompatible,canceling:nt,onCancel:_t,chats:ye,chatActivityKnown:_e.value?.kind===`conversation-active`&&!_e.error,chatHistoryPartial:ge.loading||ge.canPrevious||!!ge.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[ge.error&&(0,h.jsx)(`p`,{role:`alert`,children:ge.error}),ge.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:g(`Reading conversation history…`)}),ge.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:ge.loading,onClick:ge.previous,children:g(`Newer conversations`)}),ge.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:ge.loading,onClick:ge.next,children:g(`Older conversations`)}),ge.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:ge.first,children:g(`Latest conversations`)}),ge.error&&(0,h.jsx)(`button`,{type:`button`,onClick:ge.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:ct,onNewConversation:()=>ct(),actionsUnavailable:St?``:g(le?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{ge.refresh(),e===D&&z(e=>e+1)},workflows:xe?.runs,workflowLinks:xe?.links,workflowError:!!be.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?ct(t):(ee({runId:e.id,stepId:null,label:e.goal}),Me())},onCancelWorkflow:async e=>{$e(await Pu(v.client,e)),be.refresh()},onTask:lt,onScope:ut}),Y.workspace&&(0,h.jsx)(Is,{client:v.client,active:Y.activeRuns,taskId:w,runs:mt,snapshot:dt,workflowRuns:Se,selected:A,onOpenWorkflow:e=>{ee(e),Me()},onOpen:(e,t,n,r)=>{lt(e),G({kind:`child`,id:t}),Ve(r),Le(n),history.replaceState(null,``,zd(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!fe&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),A&&(0,h.jsx)(Id,{client:v.client,agent:A,backLabel:g(D?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>ee(null),onOpenAgent:ee},`${A.runId}:${A.stepId??``}`),D&&(!s||fe)&&(0,h.jsx)(Gu,{client:v.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:we,onLocation:se,onActivity:L,hidden:!!A,onOpenAgent:ee,onWorkflowRuns:j,onBranches:N,onOpenBranches:Fe,workspaceId:s?`checkout:${s.path}`:me.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?K.value?.workspaceId??void 0:void 0,prepareForSend:he,actionsReady:St,observe:R,available:pe,canInterrupt:!!Y.cancelCompatible,enabled:he?pe:!!Y.workspace&&!!Y.compatible&&!Y.error,modelAvailability:wt,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{ot.current.depart(),Y.refresh(!0),K.refresh()},onChanged:()=>{ge.refresh(),Y.refresh()},reference:oe,onReferenceUsed:U},`${s?.id??me.current??`connecting`}:${D}:${k.leaf??``}`),W&&!A&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[W.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>lt(w,Re),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Re||W.id,children:W.kind===`task`?Re||g(`Task {id}`,{id:W.id.slice(0,8)}):Be||g(`{kind} {id}`,{kind:_(W.kind),id:W.id.slice(0,8)})}),W.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:dt??``})]}),(0,h.jsx)(`code`,{children:W.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||!!A,children:[!ft&&(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:Y.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.`)})]}),ft&&Xe?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Je&&(Je.owner.entity.kind===`task`||Je.owner.entity.kind===`message`||Je.owner.entity.kind===`tool`)&&(0,h.jsx)(Yo,{client:v.client,seed:{storeId:Xe.storeId,scope:Xe.scope,snapshotSeq:Xe.snapshotSeq,kind:Je.owner.entity.kind,id:Je.owner.entity.id,version:Je.owner.entity.version}},`${Je.owner.entity.id}:${Je.owner.entity.version}`),(0,h.jsx)(Ko,{client:v.client,cursor:Xe,highlight:Je?.range},`${Xe.recordId}:${Xe.recordVersion}`)]}):ft&&(0,h.jsxs)(`div`,{className:He===`messages`||He===`tools`?`tab-body transcript-body`:`tab-body`,children:[He===`messages`&&(0,h.jsx)(_s,{client:v.client,seed:ft}),He===`tools`&&(0,h.jsx)(Of,{client:v.client,seed:ft}),He===`context`&&(0,h.jsx)(Jo,{client:v.client,seed:ft}),He===`timeline`&&(0,h.jsx)(wf,{client:v.client,seed:ft,onSearch:()=>Ge(!0)}),He===`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`)}),mt.length>0?mt.map(e=>(0,h.jsx)(rs,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Ae&&ke.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)(os,{client:v.client,seed:{...ft,scope:{kind:`task`,id:w??ft.scope.id}},onScope:ut},w)]})]},`${W?.kind}:${W?.id}:${Ie??`current`}`)]}),Y.workspace&&et.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:et.map(e=>(0,h.jsx)(no,{client:v.client,value:e,onChange:at},e.commandId))})]}),inspectorTabs:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Pe,onClick:()=>M(`files`),children:[(0,h.jsx)(Hi,{"aria-hidden":`true`}),g(`Files`)]}),D&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ne,onClick:()=>M(`branches`),children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),g(`Branches`)]}),W&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":ie===`task`,disabled:!ft,onClick:()=>M(`task`),children:[(0,h.jsx)(Fi,{"aria-hidden":`true`}),g(`History details`)]})]}),inspector:Ne?(0,h.jsx)(Hs,{view:ae?.id===D?ae:void 0,onChosen:Me}):Pe?(0,h.jsx)(Xu,{location:De,client:v.client,enabled:pe&&!!De,observed:`${K.readiness}:${K.value?.epoch??``}`,onReference:e=>{D||ct(H);let t=!D&&De?`${De.cwd.replace(/[\\/]+$/,``)}${De.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;P(t),Me()}},De?.cwd??`owner`):ft?(0,h.jsx)(od,{client:v.client,seed:{...ft,scope:{kind:`task`,id:w??ft.scope.id}}},w):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),status:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hf,{role:`status`,tip:g(`Connection freshness is not execution outcome.`),dot:Ct?`busy`:le?``:!xt||!Y.workspace?`error`:ke.transportStatus===`current`&&(!ke.state||ke.state.connection===`current`)?`ok`:`busy`,children:_(Tt)}),s&&(0,h.jsx)(hf,{tone:`faint`,icon:(0,h.jsx)(vi,{}),children:g(`Execution service: {status}`,{status:_(K.readiness)})}),Ee&&Ee.turns>0&&(0,h.jsx)(hf,{icon:(0,h.jsx)(ki,{}),tip:g(`Turns in this conversation: {count}`,{count:Ee.turns}),children:Ee.turns}),Ee?.context&&(0,h.jsx)(mf,{usage:Ee.context}),Ee&&Ee.runningSince!==null&&(0,h.jsx)(_f,{since:Ee.runningSince,label:g(`Working`)}),vt?.status===`complete`?yt.length>0&&(0,h.jsx)(hf,{tone:`warn`,children:g(xt?yt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:yt.length})}):!Ct&&!le&&(0,h.jsx)(hf,{tone:`faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(0,h.jsxs)(h.Fragment,{children:[(Y.workspace||s)&&(0,h.jsx)(Ld,{path:Oe,onClick:()=>c?c(Oe):re(``)}),Y.compatible===!1&&(0,h.jsx)(hf,{tone:`warn`,children:g(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})}),ne!==null&&Y.workspace&&(0,h.jsx)(ud,{onOpen:t,projects:r??(Ce.value?.kind===`projects`?Ce.value.entries:[]),client:v.client,current:Oe??Y.workspace.rootLabel,initial:ne||void 0,home:n,epoch:Y.workspace.epoch,onClose:()=>re(null)}),We&&pt&&(0,h.jsx)(ns,{client:v.client,seed:pt,onClose:()=>Ge(!1),onHit:e=>{Ye(e),Ze(e.cursor),w&&history.replaceState(null,``,zd(w,e.cursor,W?{scope:W,snapshotSeq:Ie}:void 0))}}),Ke&&pt&&(0,h.jsx)($o,{request:{storeId:pt.storeId,scope:pt.scope,snapshotSeq:pt.snapshotSeq,format:`ndjson`},onClose:()=>qe(!1)})]})}function Of({client:e,seed:t}){let n=so(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(qo,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(ys,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var kf=`cadence:folder-draft`,Af=()=>({text:``,model:null});function jf(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Af();let t=null;try{e.model!=null&&(t=me(e.model))}catch{}return{text:e.text,model:t}}catch{return Af()}}function Mf(e){try{e.text||e.model?sessionStorage.setItem(kf,JSON.stringify(e)):sessionStorage.removeItem(kf)}catch{}}function Nf(e,t,n){let r=_c(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(kf)}catch{}return{...n,conversationId:t}}var Pf=`cadence-last-project`;function Ff(){try{let e=localStorage.getItem(Pf);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function If(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Pf,e)}catch{}}function Lf(e){let t=Ff();return t?e.projects.find(e=>e.id===t):void 0}async function Rf(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=Tn(await Ua(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function zf(e,t){if(!Aa)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`,...Aa})}}),r=await Ua(n);if(!n.ok)throw Error(Wa(r));return Sn(r)}async function Bf(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await Ua(t);if(!t.ok)throw Error(Wa(n));return An(n)}async function Vf(e,t,n,r,i){if(!Aa)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`,...Aa})},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 Ua(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Wa(c));let l=wn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Hf(e,t){let n=await Bf(t);return Vf(`/workbench/v1/select`,{path:e},n,t)}async function Uf(e,t,n,r){let i=await Bf(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 Vf(`/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 Wf(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Hf(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Gf=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Kf(e){let t=V(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:U(t.id),source:R(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:pn(t.sessionId),cwd:F(t.cwd,4096,!0),leaf:t.leaf===null?null:F(t.leaf,128,!0),history:R(t.history,[`shared`,`unavailable`]),phase:R(t.phase,Gf),freshness:R(t.freshness,[`current`,`stale`,`unknown`]),observedAt:I(t.observedAt,0),epoch:t.epoch===null?null:U(t.epoch),instance:t.instance===null?null:U(t.instance),executionCwd:t.executionCwd===null?null:F(t.executionCwd,4096,!0)}}function qf(e){let t=V(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:z(t.kind,`activity-discovery`),epoch:U(t.epoch),observedAt:I(t.observedAt,0),completeness:R(t.completeness,[`complete`,`partial`]),unavailable:I(t.unavailable,0,1e4),projects:H(t.projects,128,e=>{let t=V(e,[`path`,`activities`]);return{path:F(t.path,4096,!0),activities:H(t.activities,256,Kf)}})}}async function Jf(e){if(!Aa)throw Error(`unsupported-context`);let t=ga([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`,...Aa})}}),n=await Ua(e);if(!e.ok)throw Error(Wa(n));return qf(n)}finally{t.dispose()}}function Yf(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 Xf(e,t,n,r=Jf){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?Yf(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 Zf(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return Xf(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function Qf({ready:e,previewModels:t,draft:n=Af(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=T(),d=vf(),[p,m]=(0,f.useState)(!1),g=jc(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(pf,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(_d,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(xs,{...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)(vu,{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)(Hi,{"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)(ul,{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.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,h.jsx)(sa,{"aria-hidden":`true`})})]})]})]}),inspector:(0,h.jsx)(`aside`,{className:`panel files-panel`,children:(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,h.jsx)(hf,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(Ld,{disabled:!e,onClick:_})})}var $f=`cadence-recovery-dismissed`,ep={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.`},tp={"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 np(){try{let e=JSON.parse(localStorage.getItem($f)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function rp(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function ip({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(np),[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($f,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:rp(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(ep[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(tp[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var ap={restart:18e4,upgrade:12e5},op=1e3,sp={"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.`},cp=e=>e instanceof Error?e.message:`unavailable`;function lp(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(sp[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 up(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function dp(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 fp({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 Ka(e.signal).then(a,t=>{e.signal.aborted||s(cp(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>ap[e.action])return w(`timeout`);try{let t=await Ka(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 N||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,op)};return r=setTimeout(i,op),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),qa().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),Ja({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(cp(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`&&up(C),o=i?.unit;return(0,h.jsxs)(Qo,{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:ap[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):lp(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)(Qo,{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`?Vn(c.version,i.version)>0:!1;return(0,h.jsxs)(Qo,{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:dp(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:lp(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})}):Rn(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(ca,{"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)(xi,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function pp(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(jf),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(Na),u=(0,f.useCallback)(e=>zf(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),O=(0,f.useCallback)(()=>S(e=>e+1),[]),k=Zf(t?.epoch,O),A=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>A.current?.abort(),[]);let ee=(0,f.useRef)(new Map),te=(0,f.useRef)(!c),j=(0,f.useRef)(null),ne=(0,f.useCallback)(()=>{j.current&&(j.current.abort(),j.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 Ua(t);t.status===400&&Wa(r)===`invalid`?n(null):t.ok?(n(An(r)),b(``)):b(Wa(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,f.useEffect)(()=>{let e=()=>{A.current?.abort(),ne(),D(null),l(Na())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,f.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=Lf(t);if(!e)return;let n=new AbortController;j.current=n,D({status:`checking`,path:e.cwd}),Rf(e.id,n.signal).then(t=>{n.signal.aborted||(j.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),D(null),l(e.id)):D({status:`unavailable`,path:e.cwd}))})},[t,r]);let re=(0,f.useCallback)((e,n)=>{ne(),D(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&ee.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(Nf(e.path,a,r)),i(Af())):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}`:ee.current.get(e.id)??`#chat=${a}`}`),l(e.id),p(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),ie=(0,f.useCallback)(async e=>{A.current?.abort();let t=new AbortController;A.current=t;let r=await Hf(e,t.signal);t.signal.aborted||(n(r.entry),re(r.project))},[re]),M=t?{value:k.value,error:k.error,opening:!!m,project:t.projects.find(e=>e.id===c)?.path,onOpen:(e,t)=>{A.current?.abort(),ne();let r=new AbortController;A.current=r,g(t.cwd),v(``),Wf(e,t,r.signal).then(e=>{r.signal.aborted||(n(e.entry),re(e.project,t))}).catch(e=>{r.signal.aborted||v(e instanceof Error?e.message:`unavailable`)}).finally(()=>{A.current===r&&g(null)})}}:void 0,P=async(e,r,i)=>{let a=t?.projects.find(e=>e.id===c);if(!a)throw Error(`unavailable`);let o=await Uf(a,e,r,i);if(e.aborted)throw Error(`stale`);return n(o.entry),o.project.epoch},F=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new N(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Ua(n);if(!n.ok){let e=Wa(r);return{kind:`error`,error:oe(ae.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Jr(r)}}catch{return{kind:`error`,error:oe(`unavailable`)}}}}),[]),se=(0,f.useMemo)(()=>c?ja(c):void 0,[c]),I=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{I&&If(I.id)},[I]),t===null)return(0,h.jsx)(Df,{});let L=t&&C&&(0,h.jsx)(fp,{epoch:t.epoch,csrf:t.csrf,onClose:()=>w(!1)}),R=()=>w(!0),z=t&&d!==null&&(0,h.jsx)(ud,{selectOnly:!0,client:F,current:I?.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:ie});return t&&I&&se?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Df,{api:se,project:I,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===I.path).map(e=>e.id).sort(),discovery:M,onPrepareSend:P,onChooseFolder:e=>{A.current?.abort(),p(e??I.cwd)},onOpenProject:ie,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)(ip,{notices:t.recoveries,project:I.path}),` `]}),onOpenService:R},I.id),L,z]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Qf,{discovery:M,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),Mf(e)},restore:E,onRefresh:()=>S(e=>e+1),onOpenService:t?R:void 0,onChooseFolder:()=>{ne(),v(``),A.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)(ip,{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&&!I&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),z,L]})}function mp(){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 hp=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(mp,{}):this.props.children}};ee(A());var gp=document.getElementById(`root`);if(!gp)throw Error(`Application root unavailable`);(0,p.createRoot)(gp).render((0,h.jsx)(E,{children:(0,h.jsx)(hp,{children:(0,h.jsx)(pp,{})})}));export{Cf as t};
|