@abelxiaoxing/cadence 2.0.36 → 2.0.38

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.
Files changed (55) hide show
  1. package/README.de.md +4 -4
  2. package/README.es.md +4 -4
  3. package/README.fr.md +4 -4
  4. package/README.ja.md +4 -4
  5. package/README.ko.md +4 -4
  6. package/README.md +11 -9
  7. package/README.pt-BR.md +4 -4
  8. package/README.ru.md +4 -4
  9. package/README.zh-CN.md +12 -10
  10. package/THIRD_PARTY_NOTICES.md +9 -1
  11. package/agents/design-explorer.md +4 -2
  12. package/agents/diagnosis-worker.md +5 -2
  13. package/agents/implementation-worker.md +19 -12
  14. package/docs/conversation-mode.md +46 -18
  15. package/docs/reuse-and-distribution.md +1 -1
  16. package/docs/service-management.md +35 -9
  17. package/package.json +16 -8
  18. package/src/agent-browser/labeled-rule.ts +74 -0
  19. package/src/agent-browser/session-navigator.ts +214 -0
  20. package/src/agent-browser/source.ts +174 -0
  21. package/src/agent-browser/transcript-content.ts +442 -0
  22. package/src/agent-browser/transcript-pane.ts +324 -0
  23. package/src/agent-panel-cadence.ts +147 -628
  24. package/src/agent-panel-model.ts +34 -267
  25. package/src/agent-panel.ts +139 -437
  26. package/src/cadence-instructions.ts +8 -7
  27. package/src/cadence-mode.ts +30 -9
  28. package/src/change-tools.mjs +268 -0
  29. package/src/coordinator-tools.mjs +44 -16
  30. package/src/git-environment.d.mts +2 -0
  31. package/src/git-environment.mjs +24 -0
  32. package/src/image-content.mjs +7 -28
  33. package/src/index.ts +1 -1
  34. package/src/native-build.ts +1 -1
  35. package/src/native-workflow-history.ts +20 -3
  36. package/src/operator-cli.mjs +18 -11
  37. package/src/research-scan.mjs +393 -0
  38. package/src/research-tools.mjs +406 -342
  39. package/src/sdk-worker.mjs +42 -55
  40. package/src/service/contracts/core.ts +0 -1
  41. package/src/service/contracts/workbench.ts +21 -19
  42. package/src/service/contracts/workflow.ts +283 -16
  43. package/src/service/coordination.ts +7 -0
  44. package/src/service-cli.mjs +652 -149
  45. package/src/service-host.mjs +2745 -1137
  46. package/src/worker-capture.mjs +24 -1
  47. package/src/worker-public.mjs +19 -2
  48. package/src/worker-redaction.mjs +11 -0
  49. package/src/worker-toolkit.mjs +157 -0
  50. package/src/worker-workspace.d.mts +13 -0
  51. package/src/worker-workspace.mjs +48 -0
  52. package/src/workspace.ts +4 -24
  53. package/web/dist/assets/cadence.css +1 -1
  54. package/web/dist/assets/cadence.js +18 -17
  55. package/web/dist/manifest.json +7 -7
@@ -1,24 +1,25 @@
1
- import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./react.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"./markdown.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(n(),1),p=t(),m={"Invalid or oversized image.":`图片格式无效或像素尺寸超出限制。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"PNG, JPEG or WebP · {count} images · {each} MiB each · {total} MiB total. Unsent images stay in this tab.":`PNG、JPEG 或 WebP · 最多 {count} 张 · 单张 {each} MiB · 总计 {total} MiB。未发送图片仅保留在当前页面。`,"Too many images or total image size exceeded.":`图片数量或总大小超出限制。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty or too large.":`图片为空或超过大小限制。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.":`当前执行服务无法接受此计划审批。请先发送消息以刷新会话;未批准任何实施。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder to start chatting.":`选择工作目录后即可开始对话。`,"Choose a working folder. Execution is prepared only when you send.":`选择工作目录;仅在发送消息时准备执行服务。`,"Conversations stay with their folder. Select one to read its history; Send prepares execution.":`会话按目录保留。选择目录即可查看历史;发送时才准备执行服务。`,"Selecting a folder does not start execution. Send prepares it when needed.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Execution will be prepared when you send. Browsing does not start it.":`发送消息时会按需准备执行服务,浏览不会启动服务。`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"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} 个活动运行`,"Observation is not current. Retained history is shown; this does not mean work has stopped.":`观察不是最新状态。仍显示保留的历史;这不表示工作已停止。`,"not-started":`尚未启动`,"Connection unavailable. Existing work may continue; no message is replayed automatically.":`连接当前不可用。已接纳的工作可能仍在运行;不会自动重发任何消息。`,"Execution compatibility not observed":`尚未读取执行服务兼容性`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"Select retained history to inspect":`选择保留的历史记录查看`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Ready for conversation":`可以继续对话`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers only this plan: implementation, checks, bounded repairs and the displayed local delivery. No push, publication or deployment.":`批准仅覆盖本计划中的实施、检查、有限修复和所列的本地交付。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Reference {path}":`引用 {path}`,"Copy path {path}":`复制路径 {path}`,"No visible files":`没有可显示的文件`,"Close preview":`关闭预览`,"Bounded listing; narrow the directory to see more.":`列表已达到显示上限,请进入更具体的目录查看。`,"File preview is limited; this is not the complete file.":`文件预览已截断,并非完整内容。`,"Readonly preview · references send paths, not file contents":`只读预览 · 引用只发送路径,不自动注入文件内容`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking is not retained.":`思考过程不保留。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent projects":`最近项目`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Running conversations":`运行的对话`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Context changed. Observe again and request a fresh confirmation.":`上下文已变化。请重新观察并请求新的确认。`,"Explicit service guidance: {status} / {start}. No service is started by this page.":`显式服务操作:{status} / {start}。本页面不会启动任何服务。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"Shared compatibility: {state}.":`共享兼容性:{state}。`,compatible:`兼容`,"unavailable / mismatch — reload built assets; normal actions disabled":`不可用 / 不匹配——请重新加载构建产物;常规操作已禁用`,"Service unavailable":`服务不可用`,"Task snapshot not observed yet":`尚未观察到任务快照`,"No task selected":`未选择任务`,"Resize left pane":`调整左侧面板宽度`,"Resize right pane":`调整右侧面板宽度`,Detached:`已断开`,"Accepted service work continues. No Cancel was requested.":`已接受的服务工作会继续进行。没有请求取消。`,"Observe command after reconnect:":`重新连接后观察命令:`,"Reconnect as a viewer":`以查看者身份重新连接`,"Current action context unavailable; observe again.":`当前操作上下文不可用;请重新观察。`,"Preflight refused: {code}":`预检被拒绝:{code}`,"Preflight unavailable. No automatic retry.":`预检不可用。不会自动重试。`,"Stop requested; settlement is not yet confirmed.":`已请求停止;尚未确认结束。`,"{code}; cancellation effect {effect}. Observe exact receipt.":`{code};取消效果 {effect}。请观察确切回执。`,"Cancellation effect uncertain. Observe exact receipt.":`取消效果不确定。请观察确切回执。`,"Observation unavailable or detach unconfirmed; explicit re-entry required.":`观察不可用或断开未确认;需要显式重新进入。`,"Observation unavailable.":`观察不可用。`,"Access revoked; explicit token re-entry required.":`访问已被撤销;需要显式重新输入令牌。`,Kind:`类型`,Code:`代码`,"Readonly research":`只读调研`,"Readonly diagnosis":`只读诊断`,Goal:`目标`,"Preview Create (does not Start)":`预览创建(不会启动)`,"Close dialog — no cancellation of accepted work":`关闭对话框——不会取消已接受的工作`,"Close — accepted work is not cancelled":`关闭——不会取消已接受的工作`,Checkout:`工作副本`,Observation:`观察`,Expires:`过期时间`,"Expected: {output}":`预期产出:{output}`,"Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.":`显式的所有者级选择,仅在空闲时可用。它不会解析凭据、探测提供方、保存计划或启动工作。`,"Current: {model}":`当前:{model}`,"No model selected":`未选择模型`,"Exact model / API / thinking":`确切的模型 / API / 思考级别`,"Select explicitly":`请显式选择`,"Catalog capacity exceeded; no partial model list is selectable.":`模型目录超出容量;不能从不完整的列表中选择。`,"{error}. No automatic replacement or retry.":`{error}。不会自动替换或重试。`,"{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"The model list changed and was read again. Choose once more.":`模型列表已变化并已重新读取,请再选一次。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"The choice was not confirmed. The list was read again; check the current model before choosing again.":`未能确认这次选择,列表已重新读取;请先确认当前模型再重新选择。`,"Model unavailable":`模型不可用`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重启服务。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"Every conversation in this project uses this model.":`此项目中的所有对话都使用这个模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"This page was out of date ({code}) and has been read again. Try once more.":`页面状态已过期({code}),已重新读取,请再试一次。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.":`无法读取 {name} 的历史会话。请明确选择目录;没有启动任何服务。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此工作台不是由 Cadence 的 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,Updates:`更新`,"npm could not be reached.":`无法连接 npm。`,"Check for updates":`检查更新`,"Asking npm for the latest version…":`正在向 npm 查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this copy was not installed with npm install -g; upgrade it the way you installed it.":`{version} 可用,但当前副本不是通过 npm install -g 安装的;请按原安装方式升级。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`npm 会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade now":`立即升级`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"npm could not install the release.":`npm 无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,"Show the latest":`查看最新`,"Show the conversation up to here. The next message starts a new branch; nothing is deleted.":`只显示到这里为止的对话。下一条消息会从这里开始一个新分支,不会删除任何内容。`,"Continue from here":`从这里继续`,"You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.":`你正在查看这段对话较早的位置。现在发送的消息会从这里开始一个新分支,其余内容仍保留在会话中。`,Terminal:`终端`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},h=r(),g=`cadence-locale`,_=new Map(Object.entries(m));function v(e,t,n){let r=e===`zh`?_.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var y={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`This page was out of date ({code}) and has been read again. Try once more.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),ee=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],A=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function te(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function j(){throw new A}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new A(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function ne(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function re(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=k.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new A(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&j();let a=t.sort(),o=z(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return j()}return i(e,0)}function ie(e,t=k.controlBytes){M(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function ae(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,ee),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var G=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],oe=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],se=[`not-launched`,`direct-child-closed`,`unconfirmed`],ce=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],le=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function K(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,ce),thinking:I(t.thinking,le)}}function ue(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...K(n)}}function de(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function pe(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,G),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function me(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function he(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:re(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=pe(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,me);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function ge(e){W(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,D),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:re(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,k.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,k.expectedOutputBytes,!0),role:de(t.role),model:ue(t.model),dependencies:B(t.dependencies,k.assignments,he)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new A(`forbidden`);c(e)}return i}function _e(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function ve(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:ue(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,_e)}}function J(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function Y(e){switch(W(e),q(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=ge(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:q(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:J(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function ye(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:ve(t.expected),action:Y(t.action)}}function be(e){W(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:ve(t.expected),action:Y(t.action)}}function xe(e){if(W(e),q(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:Y(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function Se(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function Ce(e){W(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,J);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:ve(n.version),action:Y(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,ge),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function we(e){W(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:Ce(t.preview)}}function X(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&j(),n}function Te(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=pe(t.result);L(i.field,`final-text`);let a=R(t.range,me);a&&a.end>i.bytes&&j();let o=M(t.text,k.predecessorBytes);if(n+=N(o),n>k.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:re(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:X(t.coverage)}})}}function Ee(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:X(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&j(),n}function De(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Oe(e){let t=M(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function ke(e){W(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:De(t.scope),query:R(t.query,e=>{let t=M(e,k.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,G)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Ae(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function je(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Me(e){let t=q(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=pe(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&j(),{owner:n,field:r,encoding:i}}function Pe(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&j(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Ie(e){let t=q(e);switch(t){case`ready`:{let n=z(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:L(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=z(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()}}}case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,k.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:je(n.declaration),index:P(n.index,0,k.dataFrames),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,je),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,je),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Ae(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+N(r)>k.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,k.detailBytes),sha256:H(n.sha256),coverage:X(n.coverage)}}case`capture-status`:return{kind:t,coverage:X(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Le(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&j(),n}function Re(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function ze(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:pe(t.content),committedSeq:n}}function Be(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Re),error:ae(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Re)}}function Ve(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&ne(n,t.detail.committedSeq)<0)&&j(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:X(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:re(t.assignmentId),childRunId:n,native:R(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,oe);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&j(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=z(e,[`source`,`event`]),n=Ge(t.source),r=q(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:X(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function qe(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Je(e){W({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=B(n.runs,k.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&j(),{...r,status:`complete`,runs:i}}function Ye(e){let t=ae(e);return L(t.effect,`none`),t}function Xe(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ze(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){W(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,oe)),settlement:R(t.settlement,We),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function tt(e){W(e);let t=z(e,[`identity`,`receipt`]),n=xe(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(q(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:ae(n.error)}}function nt(e){switch(W(e),q(e,`status`)){case`found`:return{status:`found`,receipt:et(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ae(z(e,[`status`,`error`]).error)};default:return j()}}function rt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,re),admission:pt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,oe)),settlement:R(t.settlement,We),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:X(t.coverage),result:R(t.result,pe)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&W(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==W(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&W(n.result)!==W(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function it(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function at(e,t,n){return it(e,t)&&e.taskId===gt(n)&&e.admission.context.workspaceId===ht(n)}function ot(e){W(e,k.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:De(t.scope),committedSeq:U(t.committedSeq),context:mt(t.context),runs:B(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||W(n.horizon.historicalRuns.scope)!==W(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function st(e){W(e,k.pageBytes);let t=q(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:De(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);ne(r.committedSeq,e)<=0&&j();let i=mt(n.context);_t(i,r.epoch,r.scope)||j();let a=B(n.runs,k.maxPageEntries,rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function ct(e){let{navigation:t,...n}=e;return n}function lt(e,t){(!t.navigation||t.navigation===e.navigation||W(ct(e))!==W(ct(t)))&&j()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:X(t.coverage)}}function dt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:pe(t.content),range:R(t.range,me),text:M(t.text,k.detailPageBytes),next:R(t.next,ke),coverage:X(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||W(ct({...n.next,offset:n.cursor.offset}))!==W(ct(n.cursor)))&&j(),n}function ft(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=pe(t.content),a=bt(t.owner);xt(a,n.scope)||j();let o=me(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||W(s.scope)!==W(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,ke);return a&&(a.storeId!==n.storeId||W(a.scope)!==W(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&j(),{cursor:n,hits:i,next:a,coverage:X(t.coverage)}}function pt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:re(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(q(e,`status`)===`available`)return{status:`available`,version:ve(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=ae(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function ht(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function gt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function _t(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||gt(e)===n.id)}function vt(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:mt(t.context),models:B(t.models,k.maxPageEntries,ue)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function bt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&j(),r}function xt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function St(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function Ct(e){W(e,k.controlBytes);let t=q(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:Te(n.handoff),observation:St(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=pe(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:J(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Le(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=R(r.output,pe),u=X(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||W({...s,checkoutGeneration:c.checkoutGeneration})!==W(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=pe(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function wt(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Tt(e){W(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=Ct(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=I(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:X(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,Et),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=z(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=q(e);if(t===`run`)return{kind:t,projection:rt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Tt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=z(e,[...n,...r]),a=bt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,pe);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,k.dataFrames)),s=R(i.finalText,pe),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=R(i.declaration,je),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||W(s.declaration)!==W(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=pe(i.content);return(e.field!==n.field||!At(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:X(i.coverage)}}L(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function At(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function jt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function Mt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,kt),i=R(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||W(ct({...i,after:n.after}))!==W(ct(n))||W(i.after)===W(n.after)))&&j(),{request:n,records:r,next:i,coverage:X(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(ct({...r,snapshotSeq:null}))!==W(ct(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:X(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Pt(e,t){return W({...t.request,snapshotSeq:e.snapshotSeq})===W(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function It(e){W({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Ft(t.request),r=ge(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Rt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,O),request:Rt(e.request),coverage:X(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=pe(e.content),a=R(e.range,me),o=M(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:X(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=X(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${W(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${W(n)}\n\`\`\`\n`)}var Vt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Rt(e)}receive(e){let t=zt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||W(n.request)!==W(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(W(n.graph.request.scope)!==W(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&j(),this.bytes+=N(Bt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Ht(e,t){return e.kind===`run`?it(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:xt(e.owner,t)}function Ut(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=J(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Wt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:De(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Gt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Wt(t.request),r=kt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!xt(r.owner,n.scope))&&j(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}var qt=e=>{let t=ae(e);return L(t.effect,`none`),t};function Jt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function Yt(e){let t=Jt(e);return t.taskId===null&&j(),t}function Xt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Zt(e){let t=B(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:qt(n.error)}}function $t(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||ht(e.context)!==e.workspaceId||gt(e.context)!==e.request.taskId)&&j(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&j()}}function en(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:R(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=X(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&j();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function tn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:X(t.coverage)};if($t(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&j()}return r}function nn(e){let t=M(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||j(),t}function rn(e){let t=z(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0)}}function an(e){let t=z(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0),revision:P(t.revision,0,2**53-1-1),model:R(t.model,K)}}function on(e){let t=z(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:M(t.cwd,4096,!0),checkoutRoot:M(t.checkoutRoot,4096,!0),version:sn(t.version),model:R(t.model,ue)}}function sn(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function cn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:sn(t.version),selected:R(t.selected,ue)}}function ln(e){W(e);let t=z(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:K(t.choice)}}function un(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]),n={...t.images===void 0?{}:{images:F(t.images)},provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,ce)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,le),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function dn(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function fn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=B(t.entries,k.maxPageEntries,un),r=R(t.remembered,K),i=I(t.status,[`complete`,`capacity`]),a=P(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>W([e.provider,e.model]))).size!==n.length||r&&!dn(n,r))&&j(),{version:sn(t.version),selected:R(t.selected,ue),status:i,entries:n,withheld:a,remembered:r}}function pn(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:t.epoch===null?null:V(t.epoch)}}function mn(e){let t=z(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:L(t.kind,`project-observation`),status:I(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:V(t.epoch),workspaceId:t.workspaceId===null?null:V(t.workspaceId)}}var hn=[`registry`,`workbench`,`project`],gn=[`reboot`,`crash`,`restart`,`storage`],_n=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function vn(e){let t=z(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:V(t.id),at:P(t.at,0),scope:I(t.scope,hn),path:t.path===null?null:M(t.path,4096,!0),cause:I(t.cause,gn),actions:B(t.actions,_n.length,e=>I(e,_n)),workers:P(t.workers,0,1e6),archived:F(t.archived)}}function yn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,pn),recoveries:B(t.recoveries,20,vn),build:Qe(t.build)}}var bn=[`restart`,`upgrade`],xn=[`running`,`ready`,`failed`,`rolled-back`],Sn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Cn=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function wn(e){let t=M(e,96,!0);if(!Cn.test(t))throw new A(`invalid`);return t}function Tn(e){let t=z(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:V(t.id),action:I(t.action,bn),from:wn(t.from),to:t.to===null?null:wn(t.to),state:I(t.state,xn),reason:t.reason===null?null:I(t.reason,Sn),version:t.version===null?null:wn(t.version),at:P(t.at,0),endedAt:t.endedAt===null?null:P(t.endedAt,0)}}var En=[`npm`,`not-npm-global`,`not-writable`];function Dn(e){let t=z(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=z(t.unit,[`name`,`scope`]);n={name:M(e.name,96,!0),scope:I(e.scope,[`user`,`system`])}}return{kind:L(t.kind,`service`),version:wn(t.version),unit:n,upgrade:I(t.upgrade,En),work:P(t.work,0,1e6),job:t.job===null?null:Tn(t.job)}}function On(e){let t=z(e,[`kind`,`version`,`deprecated`]);return{kind:L(t.kind,`release`),version:wn(t.version),deprecated:F(t.deprecated)}}function kn(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}var An=Object.freeze({count:4,bytes:4194304,totalBytes:8388608,chunkChars:262144,stagedBytes:67108864,stagedCount:64,idleMs:6e5,pixels:33554432,dimension:16384,wireBytes:12582912}),jn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Mn(e,t=An.bytes){if(typeof e!=`string`||!e.length||e.length%4||e.length>4*Math.ceil(t/3)||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let n=atob(e);if(n.length>t)throw Error(`Image is too large`);let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}function Nn(e,t){if(!jn.includes(t)||!e.length||e.length>An.bytes)throw Error(`Unsupported image or size`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
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={"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.":`当前执行服务无法接受此计划审批。请先发送消息以刷新会话;未批准任何实施。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder to start chatting.":`选择工作目录后即可开始对话。`,"Choose a working folder. Execution is prepared only when you send.":`选择工作目录;仅在发送消息时准备执行服务。`,"Conversations stay with their folder. Select one to read its history; Send prepares execution.":`会话按目录保留。选择目录即可查看历史;发送时才准备执行服务。`,"Selecting a folder does not start execution. Send prepares it when needed.":`选择目录不会启动执行服务;发送消息时才会按需准备。`,"Connecting…":`正在连接…`,"Ready to prepare on Send":`发送时按需准备`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"Observation is not current. Retained history is shown; this does not mean work has stopped.":`观察不是最新状态。仍显示保留的历史;这不表示工作已停止。`,"not-started":`尚未启动`,"Connection unavailable. Existing work may continue; no message is replayed automatically.":`连接当前不可用。已接纳的工作可能仍在运行;不会自动重发任何消息。`,"Execution compatibility not observed":`尚未读取执行服务兼容性`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"Select retained history to inspect":`选择保留的历史记录查看`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Ready for conversation":`可以继续对话`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal and boundary: adaptive implementation, checks, recovery, project knowledge and the displayed local delivery. No push, publication or deployment.":`批准仅覆盖本计划中的实施、检查、有限修复和所列的本地交付。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Reference {path}":`引用 {path}`,"Copy path {path}":`复制路径 {path}`,"No visible files":`没有可显示的文件`,"Close preview":`关闭预览`,"Bounded listing; narrow the directory to see more.":`列表已达到显示上限,请进入更具体的目录查看。`,"File preview is limited; this is not the complete file.":`文件预览已截断,并非完整内容。`,"Readonly preview · references send paths, not file contents":`只读预览 · 引用只发送路径,不自动注入文件内容`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking is not retained.":`思考过程不保留。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent projects":`最近项目`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Running conversations":`运行的对话`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Context changed. Observe again and request a fresh confirmation.":`上下文已变化。请重新观察并请求新的确认。`,"Explicit service guidance: {status} / {start}. No service is started by this page.":`显式服务操作:{status} / {start}。本页面不会启动任何服务。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"Shared compatibility: {state}.":`共享兼容性:{state}。`,compatible:`兼容`,"unavailable / mismatch — reload built assets; normal actions disabled":`不可用 / 不匹配——请重新加载构建产物;常规操作已禁用`,"Service unavailable":`服务不可用`,"Task snapshot not observed yet":`尚未观察到任务快照`,"No task selected":`未选择任务`,"Resize left pane":`调整左侧面板宽度`,"Resize right pane":`调整右侧面板宽度`,Detached:`已断开`,"Accepted service work continues. No Cancel was requested.":`已接受的服务工作会继续进行。没有请求取消。`,"Observe command after reconnect:":`重新连接后观察命令:`,"Reconnect as a viewer":`以查看者身份重新连接`,"Current action context unavailable; observe again.":`当前操作上下文不可用;请重新观察。`,"Preflight refused: {code}":`预检被拒绝:{code}`,"Preflight unavailable. No automatic retry.":`预检不可用。不会自动重试。`,"Stop requested; settlement is not yet confirmed.":`已请求停止;尚未确认结束。`,"{code}; cancellation effect {effect}. Observe exact receipt.":`{code};取消效果 {effect}。请观察确切回执。`,"Cancellation effect uncertain. Observe exact receipt.":`取消效果不确定。请观察确切回执。`,"Observation unavailable or detach unconfirmed; explicit re-entry required.":`观察不可用或断开未确认;需要显式重新进入。`,"Observation unavailable.":`观察不可用。`,"Access revoked; explicit token re-entry required.":`访问已被撤销;需要显式重新输入令牌。`,Kind:`类型`,Code:`代码`,"Readonly research":`只读调研`,"Readonly diagnosis":`只读诊断`,Goal:`目标`,"Preview Create (does not Start)":`预览创建(不会启动)`,"Close dialog — no cancellation of accepted work":`关闭对话框——不会取消已接受的工作`,"Close — accepted work is not cancelled":`关闭——不会取消已接受的工作`,Checkout:`工作副本`,Observation:`观察`,Expires:`过期时间`,"Expected: {output}":`预期产出:{output}`,"Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.":`显式的所有者级选择,仅在空闲时可用。它不会解析凭据、探测提供方、保存计划或启动工作。`,"Current: {model}":`当前:{model}`,"No model selected":`未选择模型`,"Exact model / API / thinking":`确切的模型 / API / 思考级别`,"Select explicitly":`请显式选择`,"Catalog capacity exceeded; no partial model list is selectable.":`模型目录超出容量;不能从不完整的列表中选择。`,"{error}. No automatic replacement or retry.":`{error}。不会自动替换或重试。`,"{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"The model list changed and was read again. Choose once more.":`模型列表已变化并已重新读取,请再选一次。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"The choice was not confirmed. The list was read again; check the current model before choosing again.":`未能确认这次选择,列表已重新读取;请先确认当前模型再重新选择。`,"Model unavailable":`模型不可用`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重启服务。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"Every conversation in this project uses this model.":`此项目中的所有对话都使用这个模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"This page was out of date ({code}) and has been read again. Try once more.":`页面状态已过期({code}),已重新读取,请再试一次。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.":`无法读取 {name} 的历史会话。请明确选择目录;没有启动任何服务。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此工作台不是由 Cadence 的 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"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:`This page was out of date ({code}) and has been read again. Try once more.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),ee=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],A=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function te(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function j(){throw new A}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new A(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function ne(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function re(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=k.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new A(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&j();let a=t.sort(),o=z(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return j()}return i(e,0)}function ie(e,t=k.controlBytes){M(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function ae(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,ee),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var G=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],oe=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],se=[`not-launched`,`direct-child-closed`,`unconfirmed`],ce=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],le=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ue(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,ce),thinking:I(t.thinking,le)}}function K(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...ue(n)}}function de(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function pe(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,G),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function me(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function he(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:re(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=pe(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,me);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function ge(e){W(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=pe(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,D),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:re(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,k.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,k.expectedOutputBytes,!0),role:de(t.role),model:K(t.model),dependencies:B(t.dependencies,k.assignments,he)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new A(`forbidden`);c(e)}return i}function _e(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function ve(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:K(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,_e)}}function J(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function ye(e){switch(W(e),q(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=ge(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:q(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:J(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function be(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:ve(t.expected),action:ye(t.action)}}function xe(e){W(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:ve(t.expected),action:ye(t.action)}}function Se(e){if(W(e),q(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ve(t.expected),action:ye(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function Ce(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function we(e){W(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,J);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:ve(n.version),action:ye(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,ge),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Te(e){W(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:we(t.preview)}}function Y(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&j(),n}function Ee(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=pe(t.result);L(i.field,`final-text`);let a=R(t.range,me);a&&a.end>i.bytes&&j();let o=M(t.text,k.predecessorBytes);if(n+=N(o),n>k.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:re(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:Y(t.coverage)}})}}function De(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Y(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&j(),n}function X(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Oe(e){let t=M(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function ke(e){W(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:X(t.scope),query:R(t.query,e=>{let t=M(e,k.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,G)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Ae(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function je(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Me(e){let t=q(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=pe(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&j(),{owner:n,field:r,encoding:i}}function Pe(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&j(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Ie(e){let t=q(e);switch(t){case`ready`:{let n=z(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:L(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=z(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()}}}case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,k.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:je(n.declaration),index:P(n.index,0,k.dataFrames),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,je),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,je),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Ae(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+N(r)>k.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,k.detailBytes),sha256:H(n.sha256),coverage:Y(n.coverage)}}case`capture-status`:return{kind:t,coverage:Y(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Le(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,se),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&j(),n}function Re(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function ze(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:pe(t.content),committedSeq:n}}function Be(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Re),error:ae(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Re)}}function Ve(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&ne(n,t.detail.committedSeq)<0)&&j(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:De(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:Y(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:re(t.assignmentId),childRunId:n,native:R(t.native,De),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,oe);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&j(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=z(e,[`source`,`event`]),n=Ge(t.source),r=q(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:Y(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function qe(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Je(e){W({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=B(n.runs,k.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&j(),{...r,status:`complete`,runs:i}}function Ye(e){let t=ae(e);return L(t.effect,`none`),t}function Xe(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ze(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){W(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,oe)),settlement:R(t.settlement,We),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function tt(e){W(e);let t=z(e,[`identity`,`receipt`]),n=Se(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(q(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:ae(n.error)}}function nt(e){switch(W(e),q(e,`status`)){case`found`:return{status:`found`,receipt:et(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:ae(z(e,[`status`,`error`]).error)};default:return j()}}function rt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,re),admission:pt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,oe)),settlement:R(t.settlement,We),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Y(t.coverage),result:R(t.result,pe)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&W(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==W(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&W(n.result)!==W(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function it(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function at(e,t,n){return it(e,t)&&e.taskId===gt(n)&&e.admission.context.workspaceId===ht(n)}function ot(e){W(e,k.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:X(t.scope),committedSeq:U(t.committedSeq),context:mt(t.context),runs:B(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||W(n.horizon.historicalRuns.scope)!==W(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function st(e){W(e,k.pageBytes);let t=q(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:X(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);ne(r.committedSeq,e)<=0&&j();let i=mt(n.context);_t(i,r.epoch,r.scope)||j();let a=B(n.runs,k.maxPageEntries,rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function ct(e){let{navigation:t,...n}=e;return n}function lt(e,t){(!t.navigation||t.navigation===e.navigation||W(ct(e))!==W(ct(t)))&&j()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:Y(t.coverage)}}function dt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:pe(t.content),range:R(t.range,me),text:M(t.text,k.detailPageBytes),next:R(t.next,ke),coverage:Y(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||W(ct({...n.next,offset:n.cursor.offset}))!==W(ct(n.cursor)))&&j(),n}function ft(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=pe(t.content),a=bt(t.owner);xt(a,n.scope)||j();let o=me(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||W(s.scope)!==W(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,ke);return a&&(a.storeId!==n.storeId||W(a.scope)!==W(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&j(),{cursor:n,hits:i,next:a,coverage:Y(t.coverage)}}function pt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ve(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:re(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(q(e,`status`)===`available`)return{status:`available`,version:ve(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=ae(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function ht(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function gt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function _t(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||gt(e)===n.id)}function vt(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:mt(t.context),models:B(t.models,k.maxPageEntries,K)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function bt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&j(),r}function xt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function St(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function Ct(e){W(e,k.controlBytes);let t=q(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:Ee(n.handoff),observation:St(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=pe(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:J(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Le(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=R(r.output,pe),u=Y(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||W({...s,checkoutGeneration:c.checkoutGeneration})!==W(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=pe(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function wt(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Tt(e){W(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=Ct(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=I(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:Y(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,Et),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=z(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=q(e);if(t===`run`)return{kind:t,projection:rt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Tt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=z(e,[...n,...r]),a=bt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,pe);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,k.dataFrames)),s=R(i.finalText,pe),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=R(i.declaration,je),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||W(s.declaration)!==W(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=pe(i.content);return(e.field!==n.field||!At(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:Y(i.coverage)}}L(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function At(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function jt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function Mt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,kt),i=R(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||W(ct({...i,after:n.after}))!==W(ct(n))||W(i.after)===W(n.after)))&&j(),{request:n,records:r,next:i,coverage:Y(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(ct({...r,snapshotSeq:null}))!==W(ct(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:Y(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function Pt(e,t){return W({...t.request,snapshotSeq:e.snapshotSeq})===W(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function It(e){W({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Ft(t.request),r=ge(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function Rt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function zt(e){W(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,O),request:Rt(e.request),coverage:Y(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=pe(e.content),a=R(e.range,me),o=M(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:Y(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Y(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${W(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${W(n)}\n\`\`\`\n`)}var Vt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Rt(e)}receive(e){let t=zt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||W(n.request)!==W(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(W(n.graph.request.scope)!==W(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&j(),this.bytes+=N(Bt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Ht(e,t){return e.kind===`run`?it(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:xt(e.owner,t)}function Ut(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=J(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Wt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Gt(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Wt(t.request),r=kt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!xt(r.owner,n.scope))&&j(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}var qt=e=>{let t=ae(e);return L(t.effect,`none`),t};function Jt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function Yt(e){let t=Jt(e);return t.taskId===null&&j(),t}function Xt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Zt(e){let t=B(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:qt(n.error)}}function $t(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||ht(e.context)!==e.workspaceId||gt(e.context)!==e.request.taskId)&&j(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&j()}}function en(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:R(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=Y(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&j();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function tn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:Y(t.coverage)};if($t(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&j()}return r}function nn(e){let t=M(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||j(),t}function rn(e){let t=z(e,[`id`,`cwd`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0)}}function an(e){let t=z(e,[`id`,`cwd`,`revision`,`model`]);return{id:nn(t.id),cwd:M(t.cwd,4096,!0),revision:P(t.revision,0,2**53-1-1),model:R(t.model,ue)}}function on(e){let t=z(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:M(t.cwd,4096,!0),checkoutRoot:M(t.checkoutRoot,4096,!0),version:sn(t.version),model:R(t.model,K)}}function sn(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:rn(t.conversation)},epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function cn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:sn(t.version),selected:R(t.selected,K)}}function ln(e){W(e);let t=z(e,[`expected`,`choice`]);return{expected:sn(t.expected),choice:ue(t.choice)}}function un(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]),n={...t.images===void 0?{}:{images:F(t.images)},provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,ce)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,le),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function dn(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function fn(e){W({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=B(t.entries,k.maxPageEntries,un),r=R(t.remembered,ue),i=I(t.status,[`complete`,`capacity`]),a=P(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>W([e.provider,e.model]))).size!==n.length||r&&!dn(n,r))&&j(),{version:sn(t.version),selected:R(t.selected,K),status:i,entries:n,withheld:a,remembered:r}}function pn(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:t.epoch===null?null:V(t.epoch)}}function mn(e){let t=z(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:L(t.kind,`project-observation`),status:I(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:V(t.epoch),workspaceId:t.workspaceId===null?null:V(t.workspaceId)}}var hn=[`registry`,`workbench`,`project`],gn=[`reboot`,`crash`,`restart`,`storage`],_n=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function vn(e){let t=z(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:V(t.id),at:P(t.at,0),scope:I(t.scope,hn),path:t.path===null?null:M(t.path,4096,!0),cause:I(t.cause,gn),actions:B(t.actions,_n.length,e=>I(e,_n)),workers:P(t.workers,0,1e6),archived:F(t.archived)}}function yn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,pn),recoveries:B(t.recoveries,20,vn),build:Qe(t.build)}}var bn=[`restart`,`upgrade`],xn=[`running`,`ready`,`failed`,`rolled-back`],Sn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Cn=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function wn(e){let t=M(e,96,!0);if(!Cn.test(t))throw new A(`invalid`);return t}function Tn(e){let t=z(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:V(t.id),action:I(t.action,bn),from:wn(t.from),to:t.to===null?null:wn(t.to),state:I(t.state,xn),reason:t.reason===null?null:I(t.reason,Sn),version:t.version===null?null:wn(t.version),at:P(t.at,0),endedAt:t.endedAt===null?null:P(t.endedAt,0)}}var En=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Dn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function On(e){let t=z(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=z(t.unit,[`name`,`scope`]);n={name:M(e.name,96,!0),scope:I(e.scope,[`user`,`system`])}}return{kind:L(t.kind,`service`),version:wn(t.version),unit:n,upgrade:I(t.upgrade,En),work:P(t.work,0,1e6),job:t.job===null?null:Tn(t.job)}}function kn(e){let t=z(e,[`kind`,`version`,`deprecated`]);return{kind:L(t.kind,`release`),version:wn(t.version),deprecated:F(t.deprecated)}}function An(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}var jn=Object.freeze({chunkChars:262144,idleMs:6e5}),Mn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Nn(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Pn(e,t){if(!Mn.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
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||i>An.dimension||a>An.dimension||i*a>An.pixels)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Pn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function Fn(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function In(e,t=!1){let n=M(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`Invalid workflow file path`);return n}var Ln=(e,t=!1)=>{let n=M(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function Rn(e){let t=z(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,12e5)}}function zn(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate task id`);for(;n.length<e.length;){let r=e.find(e=>!t.has(e.id)&&e.after.every(e=>t.has(e)));if(!r)throw Error(`Missing dependency or cyclic plan`);n.push(r),t.add(r.id)}return n}function Bn(e,t){let n=new Set,r=t=>{for(let i of e.find(e=>e.id===t)?.after??[])n.has(i)||(n.add(i),r(i))};return zn(e),r(t),zn(e).filter(e=>n.has(e.id))}function Vn(e,t={}){let n=t.strict===!0;W(e,Pn.bytes);let r=z(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=B(r.tasks,Pn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Ln(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>In(e,n)),after:B(t.after,Pn.tasks,e=>Ln(e,n))}});if(!i.length||i.some(e=>!e.writes.length||new Set(e.writes).size!==e.writes.length||new Set(e.after).size!==e.after.length))throw Error(`Empty or duplicate task scope`);zn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||Bn(i,e.id).some(e=>e.id===t.id)||Bn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>Fn(t.writes,e))||t.writes.some(t=>Fn(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=B(r.checks,Pn.checks,Rn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:M(r.goal,8192,!0),design:M(r.design,32768,!0),decisions:M(r.decisions,16384),acceptance:M(r.acceptance,16384,!0),projectContext:M(r.projectContext,16384),tasks:i,checks:a,setup:B(r.setup,4,Rn),baselineChecks:B(r.baselineChecks,Pn.checks,Rn),repairAttempts:P(r.repairAttempts,0,Pn.repairs),delivery:I(r.delivery,[`local-merge`,`working-copy`])};Hn(o),M(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
4
- `&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function Hn(e){return M(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function Un(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=z(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...t?[`display`]:[]]);return{id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:sn(n.model),plan:Vn(n.plan),cwd:M(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:M(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=z(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function Wn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=z(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=B(n.questions,Pn.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:B(n.roots,8,e=>M(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:M(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:sn(n.model)}}if(t===`propose`){let n=z(e,[`action`,`plan`,`model`]);return{action:t,plan:Vn(n.plan),model:sn(n.model)}}if(t===`prepare`||t===`execute`){let n=z(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:V(n.proposalId),digest:H(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:V(n.grant)}}let n=z(e,[`action`,`runId`]);return{action:I(n.action,[`cancel`]),runId:V(n.runId)}}function Gn(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),n=e=>I(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Xn(t.diagnostics)},id:V(t.id),epoch:V(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:I(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:R(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:B(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=z(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Yn(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=z(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()},id:M(r.id,160,!0),...t?{childRunId:V(r.childRunId)}:{},kind:I(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function Kn(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Gn(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Un(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:Un(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function qn(e){return`# ${e.goal}\n\n## Design\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${zn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
3
+ `)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Fn={tasks:16,parallel:2,checks:16,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4};function In(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Ln(e,t=!1){let n=M(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`Invalid workflow file path`);return n}var Rn=(e,t=!1)=>{let n=M(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function zn(e){let t=z(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,12e5)}}function Bn(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`Duplicate task id`);for(;n.length<e.length;){let r=e.find(e=>!t.has(e.id)&&e.after.every(e=>t.has(e)));if(!r)throw Error(`Missing dependency or cyclic plan`);n.push(r),t.add(r.id)}return n}function Vn(e,t){let n=new Set,r=t=>{for(let i of e.find(e=>e.id===t)?.after??[])n.has(i)||(n.add(i),r(i))};return Bn(e),r(t),Bn(e).filter(e=>n.has(e.id))}function Hn(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);if(W(e,Fn.bytes),r&&e.version!==2)throw Error(`Unsupported delivery agreement version`);let i=z(e,[`goal`,`design`,`decisions`,`acceptance`,...r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),a=B(i.tasks,Fn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:Rn(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>Ln(e,n)),after:B(t.after,Fn.tasks,e=>Rn(e,n))}});if(!a.length||a.some(e=>!e.writes.length||new Set(e.writes).size!==e.writes.length||new Set(e.after).size!==e.after.length))throw Error(`Empty or duplicate task scope`);Bn(a);for(let e of r?[]:a)for(let t of a)if(!(e.id>=t.id||Vn(a,e.id).some(e=>e.id===t.id)||Vn(a,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>In(t.writes,e))||t.writes.some(t=>In(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let o=B(i.checks,Fn.checks,zn);if(!o.length)throw Error(`At least one real verification command is required`);let s={goal:M(i.goal,8192,!0),design:M(i.design,32768,!0),decisions:M(i.decisions,16384),acceptance:M(i.acceptance,16384,!0),...r?{version:2,knowledge:B(i.knowledge,16,e=>{let t=Ln(e,n);if(!t.endsWith(`.md`))throw Error(`Knowledge targets must be Markdown files`);return t})}:{projectContext:M(i.projectContext,16384),repairAttempts:P(i.repairAttempts,0,2)},tasks:a,checks:o,setup:B(i.setup,4,zn),baselineChecks:B(i.baselineChecks,Fn.checks,zn),delivery:I(i.delivery,[`local-merge`,`working-copy`])};Wn(s),M(Un(s).join(`, `),16384);for(let e of[s.goal,s.design,s.decisions,s.acceptance,s.projectContext??``,...s.tasks.flatMap(e=>[e.title,e.instructions]),...[...s.checks,...s.setup,...s.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
4
+ `&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return s}function Un(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...e.knowledge??[]])]}function Wn(e){return M(`# ${e.goal}\n\nInitial route (adapt within the approved boundary): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}\n\nImmutable acceptance: ${e.acceptance}`,32768,!0)}function Gn(e){let t=M(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Kn(e){let t=M(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function qn(e){let t=M(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function Jn(e){let t=z(e,[`policy`,`target`]),n=z(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:I(t.policy,[`task-branch-v1`]),target:{checkoutRoot:qn(n.checkoutRoot),repository:qn(n.repository),repositoryIdentity:H(n.repositoryIdentity),branch:Kn(n.branch),head:Gn(n.head)}}}function Yn(e){let t=z(e,[`binding`,`taskBranch`,`worktreeRoot`,`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=z(t.integration,[`status`,`before`,`after`,`reason`]),r=z(t.cleanup,[`status`,`reason`]),i=e=>M(e,160,!0),a=R(t.acceptance,e=>{let t=z(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`]),n=B(t.checks,Fn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Gn(t.candidate),tree:Gn(t.tree),planDigest:H(t.planDigest),contextDigest:H(t.contextDigest),checks:n,review:i(t.review)}}),o=R(t.candidate,Gn);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=R(t.workspace,e=>{let t=z(e,[`head`,`state`]);return{head:Gn(t.head),state:I(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=Jn(t.binding),l=Kn(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:qn(t.worktreeRoot),preparation:I(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:I(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Gn(n.before),after:R(n.after,Gn),reason:M(n.reason,2048)},postChecks:I(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:I(r.status,[`pending`,`removed`,`retained`]),reason:M(r.reason,2048)}}}function Xn(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval.\nAcceptance: checks and automatic Agent review of the exact candidate.\nDelivery: fast-forward only into the bound target, unchanged since approval or this run's last confirmed merge. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function Zn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=z(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...t?[`display`]:[]]);return{...n.delivery===void 0?{}:{delivery:Jn(n.delivery)},id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:sn(n.model),plan:Hn(n.plan),cwd:M(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:M(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=z(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function Qn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=z(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=B(n.questions,Fn.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:B(n.roots,8,e=>M(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:M(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:sn(n.model)}}if(t===`propose`){let n=z(e,[`action`,`plan`,`model`]);return{action:t,plan:Hn(n.plan),model:sn(n.model)}}if(t===`prepare`||t===`execute`){let n=z(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:V(n.proposalId),digest:H(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:V(n.grant)}}let n=z(e,[`action`,`runId`]);return{action:I(n.action,[`cancel`]),runId:V(n.runId)}}function $n(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>I(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=z(t.verification,[`id`,`source`,`steps`]);return{id:V(e.id),source:H(e.source),steps:B(e.steps,32,e=>M(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:P(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:P(t.revision,0)},...t.delivery===void 0?{}:{delivery:Yn(t.delivery)},...t.execution===void 0?{}:{execution:on(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:ir(t.diagnostics)},id:V(t.id),epoch:V(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:I(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:R(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:B(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=z(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:rr(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=z(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()},id:M(r.id,160,!0),...t?{childRunId:V(r.childRunId)}:{},kind:I(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function er(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:$n(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Zn(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:Zn(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function tr(e){return`# ${e.goal}\n\n## Initial route (automatically adjustable)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}\n\n## Tasks\n${Bn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
5
5
 
6
6
  `)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
7
7
  `)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
8
8
  `)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
9
- `)}\n\n## Automation boundary\nAt most ${e.repairAttempts} repair rounds. ${e.delivery===`local-merge`?`Authorize isolated task worktrees, local task commits and fast-forward integration into the current branch.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Generated project context and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project context\n${e.projectContext}\n`}var Jn=e=>P(e,0,864e13);function Yn(e){let t=z(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:Jn(t.createdAt),preparedAt:R(t.preparedAt,Jn),startedAt:R(t.startedAt,Jn),stopRequestedAt:R(t.stopRequestedAt,Jn),closedAt:R(t.closedAt,Jn),settledAt:R(t.settledAt,Jn),timeoutMs:P(t.timeoutMs,100,12e5),stopReason:R(t.stopReason,e=>M(e,32,!0))}}function Xn(e){let t=z(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=z(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Jn(t.acceptedAt),acquiredAt:R(t.acquiredAt,Jn),settledAt:R(t.settledAt,Jn),owner:{version:M(n.version,128,!0),build:M(n.build,64,!0),entry:M(n.entry,4096,!0),pid:P(n.pid,1),node:M(n.node,128,!0),platform:M(n.platform,32,!0),startedAt:Jn(n.startedAt)}}}function Zn(e){let t=e.diagnostics;if(!t)return`Owner timing/runtime observations not recorded.`;let n=e=>e===null?`not observed`:new Date(e).toISOString();return[`Owner: Cadence ${t.owner.version} · ${t.owner.platform} · Node ${t.owner.node} · PID ${t.owner.pid} · epoch ${e.epoch}`,`Build: ${t.owner.build} · entry: ${t.owner.entry} · owner started: ${n(t.owner.startedAt)}`,`Accepted: ${n(t.acceptedAt)} · checkout acquired: ${n(t.acquiredAt)} · settled: ${n(t.settledAt)}`,`Checkout wait: ${t.acquiredAt===null?`still waiting or not acquired`:`${Math.max(0,t.acquiredAt-t.acceptedAt)}ms`}. Runs share an exclusive checkout; questions within one research run may overlap.`,...e.steps.flatMap(e=>e.timing?[`${e.id}: preparing ${n(e.timing.createdAt)} · prepared ${n(e.timing.preparedAt)} · spawned ${n(e.timing.startedAt)} · stop ${n(e.timing.stopRequestedAt)} (${e.timing.stopReason??`none`}) · direct child closed ${n(e.timing.closedAt)} · settled ${n(e.timing.settledAt)} · total process budget ${e.timing.timeoutMs}ms${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
10
- `)}function Qn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=z(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:nn(n.id),revision:P(n.revision,0),enabled:F(n.enabled),head:R(n.head,V),proposal:R(n.proposal,Un),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}function $n(e){let t=M(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new A(`invalid`);return t}var er=16384,tr=1e3,nr=16384,rr=1024;function ir(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function ar(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
11
- `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function or(e,t,n=!1){let r=e.role===`tool`,i=r?``:ir(e.text,nr);return{id:e.id,role:e.role,text:i,...e.images?.length?{images:e.images}:{},clipped:!r&&(n||i!==e.text),name:e.name,target:r?ir(ar(e.args),rr):``,error:e.error,parts:t}}function sr(e){let t=z(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:P(t.updatedAt,0)}}var cr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function lr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:rn(z(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=z(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),ordinal:P(n.ordinal,0),before:R(n.before,e=>P(e,0))}}case`conversation-image`:{let n=z(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=P(n.offset,0,4*Math.ceil(An.bytes/3));if(r%An.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),...n.live===void 0?{}:{live:!0},entry:$n(n.entry),index:P(n.index,0,1024),offset:r}}case`conversation-step`:{let n=z(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),turnId:$n(n.turnId),step:P(n.step,0),part:P(n.part,0)}}case`cadence-conversation`:return{kind:t,id:nn(z(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=z(e,[`kind`,`id`,`leaf`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=z(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:R(r.after,V),...n?{scan:V(r.scan)}:{}}}case`workflow-active`:return z(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=z(e,[`kind`,`id`,`stepId`]);return{kind:t,id:V(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`conversations`:{let n=Object.hasOwn(e,`after`),r=z(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:R(r.after,sr)}:{}}}case`conversation-active`:case`projects`:return z(e,[`kind`]),{kind:t};case`conversation`:{let n=z(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,$n),known:R(n.known,$n)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=z(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:I(r.kind,[`files`,`file`,`directories`]),path:M(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function ur(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:V(n.commandId),location:rn(n.location),expected:sn(n.expected),choice:K(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=z(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new A(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:V(n.commandId),epoch:V(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:rn(n.location)},...r?{expected:sn(n.expected),choice:K(n.choice)}:{}}:{kind:t,...i,runId:V(n.runId)}}if(t===`cadence-exit`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:rn(n.location)},commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),revision:P(n.revision,0)}}if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new A(`invalid`);let r=ur(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new A(`invalid`);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),send:r,mimeType:I(n.mimeType,jn),size:P(n.size,1,An.bytes),offset:P(n.offset,0,4*Math.ceil(An.bytes/3)),data:M(n.data,An.chunkChars,!0)}}if(t===`cadence-send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),text:M(n.text,er),...n.images===void 0?{}:{images:B(n.images,An.count,V)},model:sn(n.model),revision:P(n.revision,0),intent:I(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=z(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:V(r.commandId),conversationId:nn(r.conversationId),revision:P(r.revision,0),proposalId:V(r.proposalId),digest:H(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:V(r.grant)}}if(t===`workflow`){let n=z(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),request:Wn(n.request)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,$n),text:M(n.text,er),...n.images===void 0?{}:{images:B(n.images,An.count,V)},model:sn(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function dr(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=z(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),a=r?z(i.transcript,[`pages`]):null,o=n?z(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:on(i.execution)},id:V(i.id),epoch:V(i.epoch),status:I(i.status,cr),notice:M(i.notice,1024),...a?{transcript:{pages:P(a.pages,0)}}:{},omitted:{thinking:o?F(o.thinking):!1,media:o?F(o.media):!1,other:o?F(o.other):!1},items:B(i.items,256,pr)}}function fr(e){return B(e,An.count,e=>{let t=z(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new A(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:$n(t.entry),index:P(t.index,0,1024),mimeType:I(t.mimeType,jn)}})}function pr(e){let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:fr(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}}function mr(e){let t=z(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:fr(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,nr),clipped:F(t.clipped),name:M(t.name,128),target:M(t.target,rr),error:F(t.error),parts:P(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function hr(e){let t=z(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],`entry`,`at`]),n=z(t.omitted,[`thinking`,`media`,`other`]),r=P(t.steps,0);return{...t.execution===void 0?{}:{execution:on(t.execution)},id:$n(t.id),entry:R(t.entry,$n),at:P(t.at,0),status:I(t.status,cr),notice:M(t.notice,1024),omitted:{thinking:F(n.thinking),media:F(n.media),other:F(n.other)},steps:r,stable:P(t.stable,0,r)}}function gr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=z(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[]]),r=t(`live`)?z(n.live,[`commandId`,`epoch`]):null;return{id:nn(n.id),title:M(n.title,512,!0),leaf:R(n.leaf,$n),status:I(n.status,cr),updatedAt:P(n.updatedAt,0),origin:I(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:F(n.cadence)}:{},...r?{live:{commandId:V(r.commandId),epoch:V(r.epoch)}}:{}}}function _r(e){let t=z(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:V(t.commandId),text:M(t.text,16384),status:I(t.status,cr),notice:M(t.notice,1024)}}function vr(e){let t=z(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:$n(t.id),parent:R(t.parent,$n),text:M(t.text,1024),at:P(t.at,0),leaf:$n(t.leaf),current:F(t.current)}}function yr(e){W(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),offset:P(n.offset,0,4*Math.ceil(An.bytes/3))}}if(t===`conversation-image`){let n=z(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:I(n.mimeType,jn),data:M(n.data,An.chunkChars,!0),next:R(n.next,e=>P(e,0,4*Math.ceil(An.bytes/3)))}}if(t===`conversation-context`)return{kind:t,context:an(z(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:fn(z(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:V(n.commandId),choice:cn(n.choice)}}if(t===`workflow-transcript`){let n=z(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:V(n.runId),stepId:M(n.stepId,160,!0),turn:R(n.turn,dr)}}if(t===`cadence-conversation`)return{kind:t,state:Qn(z(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=z(e,[`kind`,`after`,`scan`]);return{kind:t,after:R(n.after,V),scan:V(n.scan)}}if(t===`workflow-history`){let n=z(e,[`kind`,`entries`,`next`]),r=B(n.entries,Pn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,Gn);if(r&&r.id!==n)throw new A(`invalid`);return{id:n,run:r}}),i=R(n.next,V);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new A(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=z(e,[`kind`,`runs`,...n?[`links`]:[]]),i=B(r.runs,4,Gn),a=n?B(r.links,4,e=>{let t=z(e,[`runId`,`conversationId`]);return{runId:V(t.runId),conversationId:nn(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new A(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=z(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:V(n.commandId),grant:V(n.grant),expiresAt:P(n.expiresAt,0),revision:P(n.revision,0),proposal:Un(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=z(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:R(t.commandId,V),response:Kn(t.response)}}if(n===`conversation-active`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,8,gr)};if(n===`conversations`){let t=z(e,[`kind`,`entries`,`next`]);return{kind:n,entries:B(t.entries,200,gr),next:R(t.next,sr)}}if(n===`conversation`){let t=z(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=R(t.summary,gr),i=P(t.turns,0);if(!r&&i)throw new A(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:B(t.commands,64,V)},summary:r,leaf:R(t.leaf,$n),continues:F(t.continues),turns:i,branches:P(t.branches,0),runs:B(t.runs,200,V),attempt:R(t.attempt,_r)}}if(n===`conversation-tree`){let t=z(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:B(t.nodes,tr,vr),truncated:F(t.truncated)}}if(n===`conversation-turn`){let t=z(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=hr(t.turn),i=P(t.start,0),a=B(t.steps,24,mr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,$n),ordinal:P(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=z(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,$n),turnId:$n(t.turnId),step:P(t.step,0),part:P(t.part,0),item:pr(t.item)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:R(t.parent,e=>M(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:F(t.limited)}}if(n===`projects`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(n===`accepted`)return{kind:n,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let r=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(r.kind,[`project`]),commandId:V(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var br={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},xr=f.createContext&&f.createContext(br),Sr=[`attr`,`size`,`title`];function Cr(e,t){if(e==null)return{};var n,r,i=wr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function wr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Tr(){return Tr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Tr.apply(null,arguments)}function Er(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Dr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Er(Object(n),!0).forEach(function(t){Or(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Er(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Or(e,t,n){return(t=kr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kr(e){var t=Ar(e,`string`);return typeof t==`symbol`?t:t+``}function Ar(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function jr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Dr({key:t},e.attr),jr(e.child)))}function Q(e){return t=>f.createElement(Mr,Tr({attr:Dr({},e.attr)},t),jr(e.child))}function Mr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Cr(e,Sr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Tr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Dr(Dr({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return xr===void 0?t(br):f.createElement(xr.Consumer,null,e=>t(e))}function Nr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Pr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Fr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Ir(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Lr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function Rr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Vr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Ur(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Wr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function Gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function Kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function qr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function Jr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function Yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function Xr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function Zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Qr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function $r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function ti(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function ni(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function ri(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function ii(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function ai(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function oi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function si(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function ci(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function li(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function di(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function fi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var $=e=>({kind:`error`,error:te(`unavailable`,e?`uncertain`:`none`)}),pi=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=lr(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),yr);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?$(!1):e}catch{return $(!1)}}async workbenchCommand(e){let t=ur(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),yr);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Jt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),en);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Yt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),tn);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),Je):$(!1)}catch{return $(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:$(!1)}return this.transport.models?Z(await this.transport.models(e),fn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=ln(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:$(!0)}else{if(!this.transport.chooseModel)return $(!1);e=Z(await this.transport.chooseModel(n),cn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(W(i)!==W(n.choice)||W(e.value.version.conversation??null)!==W(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){V(e);try{let n=Z(await this.transport.checkObligations(e,t),Ut);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Wt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Kt);return e.kind===`ok`&&W(e.value.request)!==W(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),vt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),yt)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Dt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Nt);return t.kind===`ok`&&!Pt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Ft(e);try{let e=Z(await this.transport.graph(n,t),Lt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new A(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new A(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new A(`unavailable`);yield i}catch{throw new A(`unavailable`)}}async preflight(e,t){let n=ye({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),we);return e.kind===`ok`&&(W(e.value.preview.version)!==W(n.expected)||W(e.value.preview.action)!==W(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=be(t);if(n.action.kind!==e)return{kind:`error`,error:te(`invalid`)};try{let e=Z(await this.transport.command(n),et);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);tt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Se(e);try{let e=Z(await this.transport.cancel(t),et);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);tt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=nt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:te(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Z(await this.transport.snapshot(n,t),ot);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),ut);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),ft);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},mi=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ne(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ne(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{ot(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function hi(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 gi={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`},_i=`/api/v1/events`,vi=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function yi(e,t){if(vi.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return k.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return k.pageBytes}return k.controlBytes}function bi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function xi(e,t){switch(e){case`workbenchRead`:return lr(t);case`workbenchCommand`:return ur(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new A(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new A(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return ye(t);case`command`:return be(t);case`cancel`:return Se(t)}}function Si(e,t){if(vi.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,yr);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,fn);case`chooseModel`:return Z(t,cn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,we);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function Ci(e){return[...vi,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function wi(e,t){let n=gi[e];return t===null||bi(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Ti(e,t){let n=xi(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?gi[e]:wi(e,n);return bi(e)||Ci(e)&&(r||N(i)>k.headerBytes/4)?{path:gi[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Ei(e){W(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Di=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new A(`invalid`);this.origin=e.origin,e.build&&=Ze(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=W(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new A(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Ti(e,xi(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:hi([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;let t=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),n;try{e===`session`&&t.ok&&(n=V(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Oi(t,yi(e)),s=ie(a);if(N(a)>yi(e,s))throw new A(`oversize`);let c=Si(e,s);if(e===`session`){let e=Z(c,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`forbidden`);this.attachment=n??V(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,ln(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Wt(e),t)}tasks(e,t){return this.request(`tasks`,Dt(e),t)}runs(e,t){return this.request(`runs`,Dt(e),t)}messages(e,t){return this.request(`messages`,Dt(e),t)}tools(e,t){return this.request(`tools`,Dt(e),t)}contents(e,t){return this.request(`contents`,Dt(e),t)}events(e,t){return this.request(`events`,Dt(e),t)}checks(e,t){return this.request(`checks`,Dt(e),t)}changes(e,t){return this.request(`changes`,Dt(e),t)}reviews(e,t){return this.request(`reviews`,Dt(e),t)}graph(e,t){return this.request(`graph`,Ft(e),t)}preflight(e){return this.request(`preflight`,ye(e))}command(e){return this.request(`command`,be(e))}cancel(e){return this.request(`cancel`,Se(e))}receipt(e,t){return this.request(`receipt`,V(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new A(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new A(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Ti(`export`,Rt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new A(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new A(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
9
+ `)}\n\n## Automation boundary\n${e.version===2?`Authorize diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands. No fixed repair-round or delivery-duration quota. Only actual verification and independent Agent review permit delivery.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`} ${e.delivery===`local-merge`?`Authorize one new named task branch and stable isolated worktree after approval, local commits and fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project knowledge\n${e.version===2?e.knowledge?.join(`
10
+ `)||`No documentation edits authorized; existing knowledge is still read.`:e.projectContext}\n`}var nr=e=>P(e,0,864e13);function rr(e){let t=z(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:nr(t.createdAt),preparedAt:R(t.preparedAt,nr),startedAt:R(t.startedAt,nr),stopRequestedAt:R(t.stopRequestedAt,nr),closedAt:R(t.closedAt,nr),settledAt:R(t.settledAt,nr),timeoutMs:P(t.timeoutMs,100,12e5),stopReason:R(t.stopReason,e=>M(e,32,!0))}}function ir(e){let t=z(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=z(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:nr(t.acceptedAt),acquiredAt:R(t.acquiredAt,nr),settledAt:R(t.settledAt,nr),owner:{version:M(n.version,128,!0),build:M(n.build,64,!0),entry:M(n.entry,4096,!0),pid:P(n.pid,1),node:M(n.node,128,!0),platform:M(n.platform,32,!0),startedAt:nr(n.startedAt)}}}function ar(e){let t=e.diagnostics;if(!t)return`Owner timing/runtime observations not recorded.`;let n=e=>e===null?`not observed`:new Date(e).toISOString();return[`Owner: Cadence ${t.owner.version} · ${t.owner.platform} · Node ${t.owner.node} · PID ${t.owner.pid} · epoch ${e.epoch}`,`Build: ${t.owner.build} · entry: ${t.owner.entry} · owner started: ${n(t.owner.startedAt)}`,`Accepted: ${n(t.acceptedAt)} · checkout acquired: ${n(t.acquiredAt)} · settled: ${n(t.settledAt)}`,`Checkout wait: ${t.acquiredAt===null?`still waiting or not acquired`:`${Math.max(0,t.acquiredAt-t.acceptedAt)}ms`}. Runs share an exclusive checkout; questions within one research run may overlap.`,...e.steps.flatMap(e=>e.timing?[`${e.id}: preparing ${n(e.timing.createdAt)} · prepared ${n(e.timing.preparedAt)} · spawned ${n(e.timing.startedAt)} · stop ${n(e.timing.stopRequestedAt)} (${e.timing.stopReason??`none`}) · direct child closed ${n(e.timing.closedAt)} · settled ${n(e.timing.settledAt)} · total process budget ${e.timing.timeoutMs}ms${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
11
+ `)}function or(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=z(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:nn(n.id),revision:P(n.revision,0),enabled:F(n.enabled),head:R(n.head,V),proposal:R(n.proposal,Zn),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}function sr(e){let t=M(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new A(`invalid`);return t}var cr=16384,lr=1e3,ur=16384,dr=1024;function fr(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function pr(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
12
+ `,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function mr(e,t,n=!1){let r=e.role===`tool`,i=r?``:fr(e.text,ur);return{id:e.id,role:e.role,text:i,...e.images?.length?{images:e.images}:{},clipped:!r&&(n||i!==e.text),name:e.name,target:r?fr(pr(e.args),dr):``,error:e.error,parts:t}}function hr(e){let t=z(e,[`id`,`updatedAt`]);return{id:nn(t.id),updatedAt:P(t.updatedAt,0)}}var gr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function _r(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:rn(z(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=z(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr),ordinal:P(n.ordinal,0),before:R(n.before,e=>P(e,0))}}case`conversation-image`:{let n=z(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=P(n.offset,0);if(r%jn.chunkChars||n.live!==void 0&&n.live!==!0)throw new A(`invalid`);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr),...n.live===void 0?{}:{live:!0},entry:sr(n.entry),index:P(n.index,0),offset:r}}case`conversation-step`:{let n=z(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr),turnId:sr(n.turnId),step:P(n.step,0),part:P(n.part,0)}}case`cadence-conversation`:return{kind:t,id:nn(z(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=z(e,[`kind`,`id`,`leaf`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=z(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:R(r.after,V),...n?{scan:V(r.scan)}:{}}}case`workflow-active`:return z(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=z(e,[`kind`,`id`,`stepId`]);return{kind:t,id:V(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:{let n=z(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:V(n.id),...n.before===void 0?{}:{before:P(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=z(e,[`kind`,...n?[`after`]:[]]);return{kind:t,...n?{after:R(r.after,hr)}:{}}}case`conversation-active`:case`projects`:return z(e,[`kind`]),{kind:t};case`conversation`:{let n=z(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:nn(n.id),leaf:R(n.leaf,sr),known:R(n.known,sr)}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=z(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:I(r.kind,[`files`,`file`,`directories`]),path:M(r.path,4096),...n?{location:rn(r.location)}:{}}}}}function vr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:V(n.commandId),location:rn(n.location),expected:sn(n.expected),choice:ue(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=z(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new A(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:V(n.commandId),epoch:V(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:rn(n.location)},...r?{expected:sn(n.expected),choice:ue(n.choice)}:{}}:{kind:t,...i,runId:V(n.runId)}}if(t===`cadence-exit`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:rn(n.location)},commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,sr),revision:P(n.revision,0)}}if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new A(`invalid`);let r=vr(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new A(`invalid`);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),send:r,mimeType:I(n.mimeType,Mn),size:P(n.size,1),offset:P(n.offset,0),data:M(n.data,jn.chunkChars,!0)}}if(t===`cadence-send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,sr),text:M(n.text,cr),...n.images===void 0?{}:{images:B(n.images,2**53-1,V)},model:sn(n.model),revision:P(n.revision,0),intent:I(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=z(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:V(r.commandId),conversationId:nn(r.conversationId),revision:P(r.revision,0),proposalId:V(r.proposalId),digest:H(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:V(r.grant)}}if(t===`workflow`){let n=z(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),request:Qn(n.request)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),head:R(n.head,sr),text:M(n.text,cr),...n.images===void 0?{}:{images:B(n.images,2**53-1,V)},model:sn(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:nn(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function yr(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=z(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[]]),a=r?z(i.transcript,[`pages`]):null,o=n?z(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:on(i.execution)},id:V(i.id),epoch:V(i.epoch),status:I(i.status,gr),notice:M(i.notice,1024),...a?{transcript:{pages:P(a.pages,0)}}:{},omitted:{thinking:o?F(o.thinking):!1,media:o?F(o.media):!1,other:o?F(o.other):!1},items:B(i.items,256,xr)}}function br(e){return B(e,2**53-1,e=>{let t=z(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new A(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:sr(t.entry),index:P(t.index,0),mimeType:I(t.mimeType,Mn)}})}function xr(e){let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:br(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}}function Sr(e){let t=z(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:br(t.images)},id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,ur),clipped:F(t.clipped),name:M(t.name,128),target:M(t.target,dr),error:F(t.error),parts:P(t.parts,0)};if(n.role===`tool`&&(n.text||n.clipped))throw new A(`invalid`);return n}function Cr(e){let t=z(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],`entry`,`at`]),n=z(t.omitted,[`thinking`,`media`,`other`]),r=P(t.steps,0);return{...t.execution===void 0?{}:{execution:on(t.execution)},id:sr(t.id),entry:R(t.entry,sr),at:P(t.at,0),status:I(t.status,gr),notice:M(t.notice,1024),omitted:{thinking:F(n.thinking),media:F(n.media),other:F(n.other)},steps:r,stable:P(t.stable,0,r)}}function wr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=z(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[]]),r=t(`live`)?z(n.live,[`commandId`,`epoch`]):null;return{id:nn(n.id),title:M(n.title,512,!0),leaf:R(n.leaf,sr),status:I(n.status,gr),updatedAt:P(n.updatedAt,0),origin:I(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:F(n.cadence)}:{},...r?{live:{commandId:V(r.commandId),epoch:V(r.epoch)}}:{}}}function Tr(e){let t=z(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:V(t.commandId),text:M(t.text,16384),status:I(t.status,gr),notice:M(t.notice,1024)}}function Er(e){let t=z(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:sr(t.id),parent:R(t.parent,sr),text:M(t.text,1024),at:P(t.at,0),leaf:sr(t.leaf),current:F(t.current)}}function Dr(e){W(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=z(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:V(n.commandId),imageId:V(n.imageId),offset:P(n.offset,0)}}if(t===`conversation-image`){let n=z(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:I(n.mimeType,Mn),data:M(n.data,jn.chunkChars,!0),next:R(n.next,e=>P(e,0))}}if(t===`conversation-context`)return{kind:t,context:an(z(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:fn(z(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=z(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:V(n.commandId),choice:cn(n.choice)}}if(t===`workflow-transcript`){let n=z(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:V(n.runId),stepId:M(n.stepId,160,!0),turn:R(n.turn,yr)}}if(t===`cadence-conversation`)return{kind:t,state:or(z(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=z(e,[`kind`,`after`,`scan`]);return{kind:t,after:R(n.after,V),scan:V(n.scan)}}if(t===`workflow-history`){let n=z(e,[`kind`,`entries`,`next`]),r=B(n.entries,Fn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,$n);if(r&&r.id!==n)throw new A(`invalid`);return{id:n,run:r}}),i=R(n.next,V);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new A(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=z(e,[`kind`,`runs`,...n?[`links`]:[]]),i=B(r.runs,4,$n),a=n?B(r.links,4,e=>{let t=z(e,[`runId`,`conversationId`]);return{runId:V(t.runId),conversationId:nn(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new A(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=z(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:V(n.commandId),grant:V(n.grant),expiresAt:P(n.expiresAt,0),revision:P(n.revision,0),proposal:Zn(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=z(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:R(t.commandId,V),response:er(t.response)}}if(n===`conversation-active`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,8,wr)};if(n===`conversations`){let t=z(e,[`kind`,`entries`,`next`]);return{kind:n,entries:B(t.entries,200,wr),next:R(t.next,hr)}}if(n===`conversation`){let t=z(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[]]),r=R(t.summary,wr),i=P(t.turns,0);if(!r&&i)throw new A(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:B(t.commands,64,V)},summary:r,leaf:R(t.leaf,sr),continues:F(t.continues),turns:i,branches:P(t.branches,0),runs:B(t.runs,200,V),attempt:R(t.attempt,Tr)}}if(n===`conversation-tree`){let t=z(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:nn(t.conversationId),nodes:B(t.nodes,lr,Er),truncated:F(t.truncated)}}if(n===`conversation-turn`){let t=z(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Cr(t.turn),i=P(t.start,0),a=B(t.steps,24,Sr);if(i+a.length>r.steps)throw new A(`invalid`);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,sr),ordinal:P(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=z(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:nn(t.conversationId),leaf:R(t.leaf,sr),turnId:sr(t.turnId),step:P(t.step,0),part:P(t.part,0),item:xr(t.item)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:R(t.parent,e=>M(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:F(t.limited)}}if(n===`projects`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(n===`accepted`)return{kind:n,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let r=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(r.kind,[`project`]),commandId:V(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var Or={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},kr=f.createContext&&f.createContext(Or),Ar=[`attr`,`size`,`title`];function jr(e,t){if(e==null)return{};var n,r,i=Mr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Mr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Nr(){return Nr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Nr.apply(null,arguments)}function Pr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Fr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pr(Object(n),!0).forEach(function(t){Ir(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ir(e,t,n){return(t=Lr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Lr(e){var t=Rr(e,`string`);return typeof t==`symbol`?t:t+``}function Rr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function zr(e){return e&&e.map((e,t)=>f.createElement(e.tag,Fr({key:t},e.attr),zr(e.child)))}function Q(e){return t=>f.createElement(Br,Nr({attr:Fr({},e.attr)},t),zr(e.child))}function Br(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=jr(e,Ar),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Nr({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Fr(Fr({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return kr===void 0?t(Or):f.createElement(kr.Consumer,null,e=>t(e))}function Vr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Ur(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Wr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function Kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function qr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Jr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Xr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Zr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Qr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function $r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function ei(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function ti(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function ni(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function ri(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function ii(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`6`,y1:`3`,x2:`6`,y2:`15`},child:[]},{tag:`circle`,attr:{cx:`18`,cy:`6`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`18`,r:`3`},child:[]},{tag:`path`,attr:{d:`M18 9a9 9 0 0 1-9 9`},child:[]}]})(e)}function ai(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function oi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function si(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function ci(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function li(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`},child:[]},{tag:`polyline`,attr:{points:`7 10 12 15 17 10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`15`,x2:`12`,y2:`3`},child:[]}]})(e)}function ui(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function di(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function fi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function pi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function mi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function hi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function gi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function _i(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function vi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function yi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function bi(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var $=e=>({kind:`error`,error:te(`unavailable`,e?`uncertain`:`none`)}),xi=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=_r(e);try{if(!this.transport.workbenchRead)return $(!1);let e=Z(await this.transport.workbenchRead(n,t),Dr);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?$(!1):e}catch{return $(!1)}}async workbenchCommand(e){let t=vr(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Dr);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Jt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),en);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Yt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),tn);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),Je):$(!1)}catch{return $(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:$(!1)}return this.transport.models?Z(await this.transport.models(e),fn):$(!1)}catch{return $(!1)}}async chooseModel(e,t){let n=ln(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:$(!0)}else{if(!this.transport.chooseModel)return $(!1);e=Z(await this.transport.chooseModel(n),cn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(W(i)!==W(n.choice)||W(e.value.version.conversation??null)!==W(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){V(e);try{let n=Z(await this.transport.checkObligations(e,t),Ut);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Wt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Kt);return e.kind===`ok`&&W(e.value.request)!==W(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),vt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),yt)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Dt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Nt);return t.kind===`ok`&&!Pt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Ft(e);try{let e=Z(await this.transport.graph(n,t),Lt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new A(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new A(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new A(`unavailable`);yield i}catch{throw new A(`unavailable`)}}async preflight(e,t){let n=be({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Te);return e.kind===`ok`&&(W(e.value.preview.version)!==W(n.expected)||W(e.value.preview.action)!==W(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=xe(t);if(n.action.kind!==e)return{kind:`error`,error:te(`invalid`)};try{let e=Z(await this.transport.command(n),et);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);tt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Ce(e);try{let e=Z(await this.transport.cancel(t),et);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);tt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=nt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:te(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=X(e);try{let e=Z(await this.transport.snapshot(n,t),ot);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),ut);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),ft);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},Si=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ne(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ne(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{ot(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function Ci(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var wi={session:`/api/v1/session`,workbenchRead:`/api/v1/workbench/read`,workbenchCommand:`/api/v1/workbench/command`,current:`/api/v1/current`,currentChanges:`/api/v1/current-changes`,activeRuns:`/api/v1/active-runs`,models:`/api/v1/models`,chooseModel:`/api/v1/model-choice`,workspace:`/api/v1/workspace`,tasks:`/api/v1/tasks`,runs:`/api/v1/runs`,messages:`/api/v1/messages`,tools:`/api/v1/tools`,contents:`/api/v1/contents`,events:`/api/v1/history-events`,checks:`/api/v1/checks`,changes:`/api/v1/changes`,reviews:`/api/v1/reviews`,checkObligations:`/api/v1/check-obligations`,entity:`/api/v1/entity`,graph:`/api/v1/graph`,snapshot:`/api/v1/snapshot`,detail:`/api/v1/details`,search:`/api/v1/search`,export:`/api/v1/export`,download:`/api/v1/download`,preflight:`/api/v1/preflight`,command:`/api/v1/commands`,cancel:`/api/v1/cancel`,receipt:`/api/v1/receipt`,detach:`/api/v1/detach`},Ti=`/api/v1/events`,Ei=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Di(e,t){if(Ei.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return k.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return k.pageBytes}return k.controlBytes}function Oi(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function ki(e,t){switch(e){case`workbenchRead`:return _r(t);case`workbenchCommand`:return vr(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new A(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new A(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return X(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return ln(t);case`preflight`:return be(t);case`command`:return xe(t);case`cancel`:return Ce(t)}}function Ai(e,t){if(Ei.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Dr);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,fn);case`chooseModel`:return Z(t,cn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,Te);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function ji(e){return[...Ei,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Mi(e,t){let n=wi[e];return t===null||Oi(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Ni(e,t){let n=ki(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?wi[e]:Mi(e,n);return Oi(e)||ji(e)&&(r||N(i)>k.headerBytes/4)?{path:wi[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function Pi(e){W(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Fi=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new A(`invalid`);this.origin=e.origin,e.build&&=Ze(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=W(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new A(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Ni(e,ki(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Ci([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;let t=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),n;try{e===`session`&&t.ok&&(n=V(t.headers.get(`x-cadence-attachment`)),this.attachment=n)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Ii(t,Di(e)),s=ie(a);if(N(a)>Di(e,s))throw new A(`oversize`);let c=Ai(e,s);if(e===`session`){let e=Z(c,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`forbidden`);this.attachment=n??V(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,ln(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Wt(e),t)}tasks(e,t){return this.request(`tasks`,Dt(e),t)}runs(e,t){return this.request(`runs`,Dt(e),t)}messages(e,t){return this.request(`messages`,Dt(e),t)}tools(e,t){return this.request(`tools`,Dt(e),t)}contents(e,t){return this.request(`contents`,Dt(e),t)}events(e,t){return this.request(`events`,Dt(e),t)}checks(e,t){return this.request(`checks`,Dt(e),t)}changes(e,t){return this.request(`changes`,Dt(e),t)}reviews(e,t){return this.request(`reviews`,Dt(e),t)}graph(e,t){return this.request(`graph`,Ft(e),t)}preflight(e){return this.request(`preflight`,be(e))}command(e){return this.request(`command`,xe(e))}cancel(e){return this.request(`cancel`,Ce(e))}receipt(e,t){return this.request(`receipt`,V(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new A(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new A(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Ni(`export`,Rt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new A(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new A(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
12
13
  `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(ie(e,k.controlBytes)),r=o.indexOf(`
13
- `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new A(`oversize`)}if(n){if(o)throw new A(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=De(e);if(!this.attachment||!this.options.socket)throw new A(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${_i}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new A(`invalid`);let n=Ei(ie(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Oi(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:`b839f8c547259e5d22a3b3296f365c9749de559a527edfa0a4c0159b948debdc`,contractHash:`2d78a97c9d5db70709e390e26fa315b5fdd3539f5a36e040593943f06ee5469a`,buildId:`679db74bbbcdd67056dbaa1748612e4ea6e588cb83ee5474d457053af35bab70`};function Ai(e){let t=new Di({origin:window.location.origin,...e?{project:e}:{},...ki?{build:{kind:`browser`,...ki}}:{},socket:e=>new WebSocket(e)});return{client:new pi(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?nn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Mi(e=typeof window>`u`?``:window.location.search){return ji(e,``).project}function Ni(e=typeof window>`u`?``:window.location.hash){return ji(``,e).chat}function Pi(){let e=Mi();return e?`/projects/${e}`:``}function Fi(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ne(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ne(t.committedSeq,r.committedSeq)>0||W(r)===W(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function Ii(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(lr(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function Li(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 Ri(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Ii(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 zi(e){return ie(await Oi(e,1048576),1048576)}function Bi(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 Vi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await zi(r);if(!r.ok)throw Error(Bi(i));return t(i)}function Hi(e){return Vi(`/workbench/v1/service`,Dn,e)}function Ui(e){return Vi(`/workbench/v1/service/release`,On,e)}async function Wi(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 zi(n);if(!n.ok)throw Error(Bi(r));let i=z(r,[`kind`,`job`]);return L(i.kind,`service-job`),Tn(i.job)}function Gi(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function Ki(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function qi(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 zi(r);if(!r.ok)throw Error(Bi(a));let c=mn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...Ki(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...Ki(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:Gi(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var Ji=e=>e===`unauthenticated`||e===`forbidden`,Yi=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new mi,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new mi,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,Ji(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(Ji(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,Ji(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,Ji(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new mi,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=ki?{kind:`browser`,...ki}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new mi,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new mi,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function Xi(e,t,n,r){let i=(0,f.useMemo)(()=>new Yi(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 Zi=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 Qi({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 $i(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 ea(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 ta(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 na(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=$i(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 ra(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),ea(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 ia({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)(ia,{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 aa(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 oa(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return aa(e)}return aa(e)}function sa(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 oa(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 ca(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
14
- `).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var la=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ua(!0)},text:{92:ua(!1)}});let t={enter:{backslashMathInline:da,backslashMathDisplay:da,backslashMathBlock:da},exit:{backslashMathInline:fa,backslashMathDisplay:fa,backslashMathBlock:fa}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ua(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 da=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)},fa=function(e){this.exit(e)},pa=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=sa();return(0,h.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:t(`Copy displayed text`),"aria-label":t(`Copy displayed text`),onClick:()=>{r(!1),a(e).then(e=>r(!e))},children:[i?(0,h.jsx)(li,{}):(0,h.jsx)(ii,{}),n&&t(`Copy unavailable`)]})}),ma=[s,d,la],ha=[s,l,d,la],ga=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function _a(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 va({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?ha:ma,rehypePlugins:t?[i,o,...ga]:ga,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:xa,a:ba,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ya=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(va,{...e})})});function ba({href:e,children:t}){let n=e&&_a(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 xa({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=ca(r).map(e=>{let t=`code-offset:${i}`;return i+=Sa(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)(pa,{text:Sa(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 Sa(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Sa).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Sa(t?.children)}return``}function Ca(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 wa=new Map;function Ta(e,t){t.length?wa.set(e,t):wa.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...wa].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 Ea(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 Da(e,t){let n=t.startContainer.parentElement;for(let r of Ea(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 Oa({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?Ca(n,r):[];return l.current=i,c(i.length),o(0),Ta(u,i),()=>Ta(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Da(e.current,l.current[n]),Ta(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Ta(`${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 ka({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await na(e,t,n.signal);if(n.signal.aborted)return;let i=await oa(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)(ia,{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)(Oa,{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)(ya,{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 Aa({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)(ia,{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 ja({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=ra(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)(Aa,{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)(ia,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ta(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)(ka,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ma({client:e,seed:t}){return(0,h.jsx)(Na,{client:e,seed:t},W(t))}function Na({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)(ia,{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 Pa(e){let t=Ti(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Pi()+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 Fa({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,h.jsx)(Nr,{"aria-hidden":`true`})})]}),t]})}function Ia({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)(Fa,{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{Pa({...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 La(e,t){if(!t||N(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Ra(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 za({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=La(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)(Fa,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(Rr,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ia,{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(Ra(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 Ba({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)(ia,{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 Va({client:e,seed:t}){return(0,h.jsx)(Ha,{client:e,seed:t},W(t))}function Ha({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),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)(ia,{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)(ka,{client:e,cursor:ta(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)(ya,{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 Ua({client:e,seed:t,onScope:n}){let{t:r}=T(),i=ra(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Aa,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ba,{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)(Va,{client:e,seed:o},o.graph.recordId)]})}function Wa({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,h.jsx)(Rr,{"aria-hidden":`true`})})}function Ga(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 Ka(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 qa(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)??Ja(n.role,n.customType)}return r}function Ja(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 Ya(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Xa(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=qa(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=Ga(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=>Ka(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)=>Ya(e,t,s.current,n),[])}}var Za=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null);return(0,f.useLayoutEffect)(()=>{if(!t)return;let n=s.current;if(!n)return;let r=n.offsetHeight;r>0&&i?.(e,r)},[t,e,i]),t?(0,h.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,h.jsx)(`div`,{ref:s,children:o})}):(0,h.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Qa=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(oi,{"aria-hidden":`true`}):(0,h.jsx)($r,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(ka,{compact:!0,client:t,cursor:ta(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)(ja,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function $a({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=Xa(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)(Za,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,h.jsx)(Qa,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(fi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function eo({client:e,seed:t}){let{t:n}=T(),r=ra(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Aa,{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)($a,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function to({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(ci,{}):(0,h.jsx)(si,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var no=(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)(to,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Pr,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(ja,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),ro=[`queued`,`running`];function io(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 ao=4,oo=1e4;function so(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?ro.includes(t.status):i-(u.get(e)??0)>=oo}).reverse();for(let n=0;n<a.length;n+=ao){let r=await Promise.all(a.slice(n,n+ao).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+ao<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>ro.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),oo))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function co({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=so(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(!ro.includes(e.step.status))-Number(!ro.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>ro.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,D=d??(w>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${D?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":D,onClick:()=>p(!D),children:[(0,h.jsx)(ci,{}),(0,h.jsx)(ni,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:w}):w})]}),D&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),w===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,step:t})=>{let n=io(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 lo=2e4;async function uo(e,t,n,r){let i=hi([t],lo);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function fo(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 po(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 mo(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function ho(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:$n(e.head)},n=e.location?rn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new A(`stale`);let r=M(e.text,er,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:P(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:P(e.revision,0)};return Object.freeze({text:r,images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(go(e.model))}:{}})}function go(e){return K({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function _o(e,t){return Object.freeze({...e,model:Object.freeze(go(t))})}function vo(e,t){if(e.model&&W(e.model)!==W(go(t)))throw new A(`stale`)}function yo(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null))throw new A(`stale`);let n=ur(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new A(`invalid`);return n}function bo(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 xo(e){if(e.length>An.count||e.reduce((e,t)=>e+t.size,0)>An.totalBytes)throw Error(`Too many images or total image size exceeded.`);for(let t of e){if(!jn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size||t.size>An.bytes)throw Error(`Image is empty or too large.`)}}async function So(e){xo([e]);let t=new Uint8Array(await e.arrayBuffer());return Nn(t,e.type),t}var Co=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 wo(e,t,n,r){xo(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await So(a);if(!r())throw Error(`stale`);let o=Co(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=An.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+An.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function To(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>An.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,r>4*Math.ceil(An.bytes/3))throw Error(`capacity`);if(i.next===null)break;if(i.next!==r||i.data.length!==An.chunkChars)throw Error(`invalid`)}let i=Mn(n.join(``));return Nn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Eo=1e3,Do=1e4,Oo=4,ko=e=>e===`queued`||e===`running`,Ao=class extends Error{},jo=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;commands=[];count=0;first=null;turns=new Map;imageReaders=new Map;details=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=e=>{this.closed||this.pinned===e||(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.error=``,this.forget(),this.publish(),this.tick())};forget(){this.turns.clear(),this.details.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,commands:this.commands,count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof Ao?e.message:`unavailable`)}finally{this.running=!1}if(e&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=ko(this.summary?.status)||[...this.turns.values()].some(e=>ko(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Eo:Do)}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 Ao(`invalid`);(!n.continues||n.turns<this.count)&&this.forget();let r=n.leaf===this.leaf?this.count:this.count-1;this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.commands=n.commands??[],this.summary=n.summary,this.count=n.turns,this.first=Math.min(this.first??Math.max(0,n.turns-2),n.turns),this.publish();let i=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||ko(t.header.status))&&i.push(e)}await Promise.all(i.map(t=>this.load(t,n.leaf,e)))}async load(e,t,n){let r=this.turns.get(e),i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{o[i.start+t]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n))))r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)});if(!n.aborted){if(o.some(e=>!e))throw new Ao(`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 Ao(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=hi([t,r]);try{return await To(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=hi([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 Ao(`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>=Oo&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Ao(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Ao(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Mo(e,t,n){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new jo(e,t,()=>o(n.view()));return i(n),o(n.view()),()=>n.close()},[e,t]),(0,f.useEffect)(()=>{r?.setActive(n)},[r,n]),{...a??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:r?.refresh??No,loadEarlier:r?.loadEarlier??No,choose:r?.choose??No}}function No(){}async function Po(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 Fo(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Io(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Lo={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Ro={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed and was read again. Choose once more.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. The list was read again; check the current model before choosing again.`},zo=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Bo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Vo(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 Ho(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Lo[t.thinking])}`,[e])}function Uo({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,onObserved:c,awaitingSend:l=!1}){let{t:u}=T(),d=Ho(),p=(0,f.useRef)(c);p.current=c;let[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(``),[E,D]=(0,f.useState)(0),O=(0,f.useRef)(null),k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=(0,f.useRef)(null),te=(0,f.useCallback)(()=>D(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(g(e.value),p.current?.(e.value),v(``)):v(e.error.code))}).catch(()=>{t.signal.aborted||v(`unavailable`)}),()=>t.abort()},[e,r,E]),(0,f.useEffect)(()=>{i&&te()},[i,te]);let j=(0,f.useCallback)((e=!0)=>{a(!1),w(``),e&&k.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;b(``),ee.current?.focus({preventScroll:!0});let e=e=>{O.current?.contains(e.target)||j(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,j]);let M=m?.selected??null,N=M??m?.remembered??null,P=(0,f.useMemo)(()=>{let e=C.trim().toLowerCase(),t=new Map;for(let n of m?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[m,C]),F=m?.entries.find(e=>Bo(e,N)),I=async(t,r)=>{if(!m||!t.api||x||n)return;let i=K({provider:t.provider,model:t.model,api:t.api,thinking:r});if(M&&zo(M,i))j(),s?.(i);else{S(!0),b(``);try{let t=await e.chooseModel({expected:m.version,choice:i});if(t.kind===`error`){b(t.error.code),te();return}let n={...m,version:t.value.version,selected:t.value.selected};g(n),p.current?.(n),o(),j(),s?.(i)}catch{b(`uncertain`),te()}finally{S(!1)}}},L=()=>[...A.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],R=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=L(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?ee.current?.focus():t[Math.min(n,t.length-1)]?.focus()},z=!t||!m&&!!_,B=m?N?d(N):u(`Choose a model`):u(_?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:O,children:[(0,h.jsxs)(`button`,{ref:k,type:`button`,className:`model-trigger${N&&!M?` remembered`:``}${m&&!N?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:B}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?u(`Switch models after the current reply finishes.`):N&&!M?u(`Last used model; it is used again when you send.`):N?`${N.provider}/${N.model} · ${N.api}`:void 0,onClick:()=>i?j():a(!0),children:[(0,h.jsx)(ni,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:B}),(0,h.jsx)(ci,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":u(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),j())},children:[l&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:u(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(Rr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:ee,type:`search`,"aria-label":u(`Search models`),placeholder:u(`Search models…`),value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),L()[0]?.click())}})]}),(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":u(`Models`),ref:A,onKeyDown:R,children:[!m&&!_&&(0,h.jsx)(`p`,{className:`model-empty`,children:u(`Reading models…`)}),P.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,r=Bo(e,N);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||x||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void I(e,Vo(e,N?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?u(`Credentials unavailable`):u(`Not supported`)}),r&&!M&&(0,h.jsx)(`span`,{className:`model-option-note`,children:u(`Used when you send`)}),r&&(0,h.jsx)(li,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),m?.status===`complete`&&P.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:C.trim()?u(`No matching models.`):u(`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),F&&F.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:u(`Thinking`)}),F.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":u(`Thinking level: {level}`,{level:u(Lo[e.level])}),"aria-pressed":N?.thinking===e.level,disabled:!e.selectable||x||n,onClick:()=>void I(F,e.level),children:u(Lo[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:u(`Switch models after the current reply finishes.`)}),m?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:u(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!m?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:u(m.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:m.withheld})}),_&&(0,h.jsxs)(`p`,{role:`alert`,children:[u(`The model list could not be read ({code}).`,{code:_}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:te,children:u(`Read again`)})]}),y&&(0,h.jsx)(`p`,{role:`alert`,children:Ro[y]?u(Ro[y]):u(`The model was not changed ({code}).`,{code:y})}),!z&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(x?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}function Wo(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function Go({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Ii(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>Wo(s?.nodes??[]),[s]);return(0,h.jsxs)(`section`,{className:`branch-tree`,"aria-label":a(`Conversation branches`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h3`,{children:a(`Conversation branches`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":a(`Close`),onClick:i,children:(0,h.jsx)(Nr,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),o.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,o.error)}),!s&&!o.error&&(0,h.jsx)(`p`,{children:a(`Reading…`)}),s?.truncated&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Only the newest messages are listed.`)}),(0,h.jsx)(`ol`,{className:`branch-rows`,children:c.map(({node:e,depth:t})=>(0,h.jsx)(`li`,{style:{paddingInlineStart:`${t*16}px`},children:(0,h.jsxs)(`button`,{type:`button`,className:`branch-row${e.current?` current`:``}`,"aria-current":e.current?`true`:void 0,title:e.text,onClick:()=>r(e.leaf),children:[(0,h.jsx)(`span`,{className:`branch-text`,children:e.text||`…`}),e.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})},e.id))})]})}function Ko(){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])];xo(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 qo({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),So(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,h.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,h.jsx)(`img`,{src:i,alt:e.name}),o&&(0,h.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid or oversized image.`)}),(0,h.jsx)(`span`,{title:e.name,children:e.name}),(0,h.jsx)(`button`,{type:`button`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`})]})}function Jo({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 Yo({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(Jo,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var Xo=/^\s{0,3}(`{3,}|~{3,})/,Zo=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Qo(e){return e.trim()===``}function $o(e){let t=Xo.exec(e);return t?t[1]:null}function es(e){let t=e.split(`
15
- `),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=$o(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=$o(a);if(o&&!Qo(a))i=o,r.push(a);else if(Qo(a)){let i=e;for(;i<t.length&&Qo(t[i]);)i++;if(!(i<t.length&&Zo.test(t[i]))&&r.length>0){n.push(r.join(`
14
+ `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new A(`oversize`)}if(n){if(o)throw new A(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=X(e);if(!this.attachment||!this.options.socket)throw new A(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Ti}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new A(`invalid`);let n=Pi(ie(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Ii(e,t){if(!e.body)throw new A(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new A(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Li={sourceHash:`7064b712d465c98bf51cc61fe6ec273ad51e169a60b2c7926e3a55a1dc46d205`,contractHash:`0e4bbeb78c11fa9948adefea308d4d00c15af7f4879265fc079aad4b021f2324`,buildId:`06a8c1e51525d871876933a4f5b8590940aa40c32d5c032f75de426b6f215a1a`};function Ri(e){let t=new Fi({origin:window.location.origin,...e?{project:e}:{},...Li?{build:{kind:`browser`,...Li}}:{},socket:e=>new WebSocket(e)});return{client:new xi(t),transport:t}}function zi(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?nn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function Bi(e=typeof window>`u`?``:window.location.search){return zi(e,``).project}function Vi(e=typeof window>`u`?``:window.location.hash){return zi(``,e).chat}function Hi(){let e=Bi();return e?`/projects/${e}`:``}function Ui(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ne(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ne(t.committedSeq,r.committedSeq)>0||W(r)===W(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function Wi(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(_r(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function Gi(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 Ki(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)([]),o=Wi(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 qi(e){return ie(await Ii(e,1048576),1048576)}function Ji(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 Yi(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await qi(r);if(!r.ok)throw Error(Ji(i));return t(i)}function Xi(e){return Yi(`/workbench/v1/service`,On,e)}function Zi(e){return Yi(`/workbench/v1/service/release`,kn,e)}async function Qi(e,t){if(!Li)throw Error(`unavailable`);let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Li})},body:JSON.stringify(e)}),r=await qi(n);if(!n.ok)throw Error(Ji(r));let i=z(r,[`kind`,`job`]);return L(i.kind,`service-job`),Tn(i.job)}function $i(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function ea(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function ta(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 qi(r);if(!r.ok)throw Error(Ji(a));let c=mn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...ea(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...ea(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:$i(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var na=e=>e===`unauthenticated`||e===`forbidden`,ra=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||(t.compatible===!1?a(Error(`unsupported-context`)):t.workspace?.epoch===e&&t.compatible&&!t.error&&t.transportStatus===`current`&&a())},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Si,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new Si,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,na(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(na(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,na(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,na(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Si,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Li?{kind:`browser`,...Li}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new Si,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Si,_={epoch:t.value.epoch,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function ia(e,t,n,r){let i=(0,f.useMemo)(()=>new ra(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 aa=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 oa({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 sa(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 ca(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 la(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 ua(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=sa(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 da(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),ca(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 fa({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)(fa,{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 pa(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 ma(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return pa(e)}return pa(e)}function ha(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 ma(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 ga(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 _a=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:va(!0)},text:{92:va(!1)}});let t={enter:{backslashMathInline:ya,backslashMathDisplay:ya,backslashMathBlock:ya},exit:{backslashMathInline:ba,backslashMathDisplay:ba,backslashMathBlock:ba}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function va(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 ya=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)},ba=function(e){this.exit(e)},xa=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ha();return(0,h.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:t(`Copy displayed text`),"aria-label":t(`Copy displayed text`),onClick:()=>{r(!1),a(e).then(e=>r(!e))},children:[i?(0,h.jsx)(_i,{}):(0,h.jsx)(fi,{}),n&&t(`Copy unavailable`)]})}),Sa=[s,d,_a],Ca=[s,l,d,_a],wa=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Ta(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 Ea({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Ca:Sa,rehypePlugins:t?[i,o,...wa]:wa,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ka,a:Oa,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var Da=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Ea,{...e})})});function Oa({href:e,children:t}){let n=e&&Ta(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 ka({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=ga(r).map(e=>{let t=`code-offset:${i}`;return i+=Aa(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)(xa,{text:Aa(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 Aa(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Aa).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Aa(t?.children)}return``}function ja(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 Ma=new Map;function Na(e,t){t.length?Ma.set(e,t):Ma.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Ma].filter(([e])=>e.endsWith(`-active`)===n).flatMap(([,e])=>e);let r=CSS;if(!r.highlights)return;if(t.length===0){r.highlights.delete(e);return}let i=window.Highlight;i&&r.highlights.set(e,new i(...t))}function Pa(e,t){let n=[],r=e;for(;r&&r!==t;){let e=getComputedStyle(r);/(auto|scroll|hidden)/.test(e.overflowY+e.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function Fa(e,t){let n=t.startContainer.parentElement;for(let r of Pa(n,e)){let e=t.getBoundingClientRect(),n=r.getBoundingClientRect();if(e.height<=0||e.width<=0)return;e.top>=n.top+4&&e.bottom<=n.bottom-4||(r.scrollTop+=e.top-n.top-(r.clientHeight-e.height)/2),e.left>=n.left+4&&e.right<=n.right-4||(r.scrollLeft+=e.left-n.left-(r.clientWidth-e.width)/2)}let r=t.getBoundingClientRect(),i=e.getBoundingClientRect();if(r.height<=0||r.width<=0)return;let a=r.top>=i.top+6&&r.bottom<=i.bottom-6,o=r.left>=i.left+6&&r.right<=i.right-6;a&&o||(a||(e.scrollTop+=r.top-i.top-(i.height-r.height)/2),o||(e.scrollLeft+=r.left-i.left-(i.width-r.width)/2))}function Ia({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?ja(n,r):[];return l.current=i,c(i.length),o(0),Na(u,i),()=>Na(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Fa(e.current,l.current[n]),Na(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Na(`${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 La({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=W(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await ua(e,t,n.signal);if(n.signal.aborted)return;let i=await ma(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)(fa,{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)(Ia,{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)(Da,{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 Ra({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)(fa,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,h.jsx)(qr,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function za({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=da(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)(Ra,{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)(fa,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(la(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)(La,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ba({client:e,seed:t}){return(0,h.jsx)(Va,{client:e,seed:t},W(t))}function Va({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)(fa,{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 Ha(e){let t=Ni(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Hi()+t.path,n.download=`cadence-${e.scope.kind}-${e.scope.id}.${e.format===`markdown`?`md`:`ndjson`}`,n.referrerPolicy=`no-referrer`,document.body.appendChild(n),n.click(),n.remove()}function Ua({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,h.jsx)(Vr,{"aria-hidden":`true`})})]}),t]})}function Wa({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)(Ua,{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{Ha({...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 Ga(e,t){if(!t||N(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Ka(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 qa({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=Ga(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)(Ua,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(Kr,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(fa,{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(Ka(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 Ja({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)(fa,{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 Ya({client:e,seed:t}){return(0,h.jsx)(Xa,{client:e,seed:t},W(t))}function Xa({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)(fa,{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)(La,{client:e,cursor:la(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)(Da,{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 Za({client:e,seed:t,onScope:n}){let{t:r}=T(),i=da(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ra,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ja,{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)(Ya,{client:e,seed:o},o.graph.recordId)]})}function Qa({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,h.jsx)(Kr,{"aria-hidden":`true`})})}function $a(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 eo(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 to(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)??no(n.role,n.customType)}return r}function no(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 ro(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function io(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=to(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=$a(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=>eo(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)=>ro(e,t,s.current,n),[])}}var ao=(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`})}),oo=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(mi,{"aria-hidden":`true`}):(0,h.jsx)(si,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(La,{compact:!0,client:t,cursor:la(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)(za,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function so({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=io(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)(ao,{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)(oo,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(bi,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function co({client:e,seed:t}){let{t:n}=T(),r=da(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ra,{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)(so,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function lo({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(gi,{}):(0,h.jsx)(hi,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var uo=(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)(lo,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Hr,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(za,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),fo=[`queued`,`running`];function po(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 mo=4,ho=1e4;function go(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?fo.includes(t.status):i-(u.get(e)??0)>=ho}).reverse();for(let n=0;n<a.length;n+=mo){let r=await Promise.all(a.slice(n,n+mo).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+mo<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>fo.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),ho))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function _o({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=go(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(!fo.includes(e.step.status))-Number(!fo.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>fo.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,D=d??(w>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${D?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":D,onClick:()=>p(!D),children:[(0,h.jsx)(gi,{}),(0,h.jsx)(ui,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:w}):w})]}),D&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),w===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,step:t})=>{let n=po(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 vo=2e4;async function yo(e,t,n,r){let i=Ci([t],vo);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function bo(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 xo(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 So(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Co(e){let t={commandId:crypto.randomUUID(),conversationId:nn(e.id),head:e.head===null?null:sr(e.head)},n=e.location?rn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new A(`stale`);let r=M(e.text,cr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:P(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:P(e.revision,0)};return Object.freeze({text:r,images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(wo(e.model))}:{}})}function wo(e){return ue({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function To(e,t){return Object.freeze({...e,model:Object.freeze(wo(t))})}function Eo(e,t){if(e.model&&W(e.model)!==W(wo(t)))throw new A(`stale`)}function Do(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&W(e.location)!==W(t?.conversation??null))throw new A(`stale`);let n=vr(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new A(`invalid`);return n}function Oo(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(!Mn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function Ao(e){ko([e]);let t=new Uint8Array(await e.arrayBuffer());return Pn(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 Mo(e,t,n,r){ko(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await Ao(a);if(!r())throw Error(`stale`);let o=jo(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=jn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+jn.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function No(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>jn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==jn.chunkChars)throw Error(`invalid`)}let i=Nn(n.join(``));return Pn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var Po=1e3,Fo=1e4,Io=4,Lo=e=>e===`queued`||e===`running`,Ro=class extends Error{},zo=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 Ro?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=Lo(this.summary?.status)||[...this.turns.values()].some(e=>Lo(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?Po:Fo)}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 Ro(`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||Lo(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 Ro(`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 Ro(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Ci([t,r]);try{return await No(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n){let r=`${e??``}:${t}`,i=this.details.get(r);return i||(i=async(r,i,a)=>{let o=await Promise.all(Array.from({length:i},async(i,o)=>{let s=Ci([n,a]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},s.signal);if(n.kind!==`conversation-step`||n.part!==o)throw new Ro(`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>=Io&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Ro(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Ro(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Bo(e,t,n){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new zo(e,t,()=>o(n.view()));return i(n),o(n.view()),()=>n.close()},[e,t]),(0,f.useEffect)(()=>{r?.setActive(n)},[r,n]),{...a??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:r?.refresh??Vo,loadEarlier:r?.loadEarlier??Vo,choose:r?.choose??Vo}}function Vo(){}async function Ho(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 Uo(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Wo(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Go={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Ko={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed and was read again. Choose once more.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. The list was read again; check the current model before choosing again.`},qo=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Jo=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Yo(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 Xo(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Go[t.thinking])}`,[e])}function Zo({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,onObserved:c,awaitingSend:l=!1}){let{t:u}=T(),d=Xo(),p=(0,f.useRef)(c);p.current=c;let[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(``),[E,D]=(0,f.useState)(0),O=(0,f.useRef)(null),k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=(0,f.useRef)(null),te=(0,f.useCallback)(()=>D(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(g(e.value),p.current?.(e.value),v(``)):v(e.error.code))}).catch(()=>{t.signal.aborted||v(`unavailable`)}),()=>t.abort()},[e,r,E]),(0,f.useEffect)(()=>{i&&te()},[i,te]);let j=(0,f.useCallback)((e=!0)=>{a(!1),w(``),e&&k.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;b(``),ee.current?.focus({preventScroll:!0});let e=e=>{O.current?.contains(e.target)||j(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,j]);let M=m?.selected??null,N=M??m?.remembered??null,P=(0,f.useMemo)(()=>{let e=C.trim().toLowerCase(),t=new Map;for(let n of m?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[m,C]),F=m?.entries.find(e=>Jo(e,N)),I=async(t,r)=>{if(!m||!t.api||x||n)return;let i=ue({provider:t.provider,model:t.model,api:t.api,thinking:r});if(M&&qo(M,i))j(),s?.(i);else{S(!0),b(``);try{let t=await e.chooseModel({expected:m.version,choice:i});if(t.kind===`error`){b(t.error.code),te();return}let n={...m,version:t.value.version,selected:t.value.selected};g(n),p.current?.(n),o(),j(),s?.(i)}catch{b(`uncertain`),te()}finally{S(!1)}}},L=()=>[...A.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],R=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=L(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?ee.current?.focus():t[Math.min(n,t.length-1)]?.focus()},z=!t||!m&&!!_,B=m?N?d(N):u(`Choose a model`):u(_?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:O,children:[(0,h.jsxs)(`button`,{ref:k,type:`button`,className:`model-trigger${N&&!M?` remembered`:``}${m&&!N?` empty`:``}`,"aria-label":u(`Model: {model}`,{model:B}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?u(`Switch models after the current reply finishes.`):N&&!M?u(`Last used model; it is used again when you send.`):N?`${N.provider}/${N.model} · ${N.api}`:void 0,onClick:()=>i?j():a(!0),children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:B}),(0,h.jsx)(gi,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":u(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),j())},children:[l&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:u(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(Kr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:ee,type:`search`,"aria-label":u(`Search models`),placeholder:u(`Search models…`),value:C,onChange:e=>w(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),L()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),L()[0]?.click())}})]}),(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":u(`Models`),ref:A,onKeyDown:R,children:[!m&&!_&&(0,h.jsx)(`p`,{className:`model-empty`,children:u(`Reading models…`)}),P.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,r=Jo(e,N);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||x||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void I(e,Yo(e,N?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?u(`Credentials unavailable`):u(`Not supported`)}),r&&!M&&(0,h.jsx)(`span`,{className:`model-option-note`,children:u(`Used when you send`)}),r&&(0,h.jsx)(_i,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),m?.status===`complete`&&P.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:C.trim()?u(`No matching models.`):u(`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),F&&F.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:u(`Thinking`)}),F.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":u(`Thinking level: {level}`,{level:u(Go[e.level])}),"aria-pressed":N?.thinking===e.level,disabled:!e.selectable||x||n,onClick:()=>void I(F,e.level),children:u(Go[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:u(`Switch models after the current reply finishes.`)}),m?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:u(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!m?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:u(m.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:m.withheld})}),_&&(0,h.jsxs)(`p`,{role:`alert`,children:[u(`The model list could not be read ({code}).`,{code:_}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:te,children:u(`Read again`)})]}),y&&(0,h.jsx)(`p`,{role:`alert`,children:Ko[y]?u(Ko[y]):u(`The model was not changed ({code}).`,{code:y})}),!z&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:u(x?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}function Qo(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 $o({client:e,id:t,leaf:n,onChoose:r,onClose:i}){let{t:a}=T(),o=Wi(e,{kind:`conversation-tree`,id:t,leaf:n}),s=o.value?.kind===`conversation-tree`?o.value:void 0,c=(0,f.useMemo)(()=>Qo(s?.nodes??[]),[s]);return(0,h.jsxs)(`section`,{className:`branch-tree`,"aria-label":a(`Conversation branches`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h3`,{children:a(`Conversation branches`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":a(`Close`),onClick:i,children:(0,h.jsx)(Vr,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),o.error&&(0,h.jsx)(`p`,{role:`alert`,children:b(a,o.error)}),!s&&!o.error&&(0,h.jsx)(`p`,{children:a(`Reading…`)}),s?.truncated&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Only the newest messages are listed.`)}),(0,h.jsx)(`ol`,{className:`branch-rows`,children:c.map(({node:e,depth:t})=>(0,h.jsx)(`li`,{style:{paddingInlineStart:`${t*16}px`},children:(0,h.jsxs)(`button`,{type:`button`,className:`branch-row${e.current?` current`:``}`,"aria-current":e.current?`true`:void 0,title:e.text,onClick:()=>r(e.leaf),children:[(0,h.jsx)(`span`,{className:`branch-text`,children:e.text||`…`}),e.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})},e.id))})]})}function es(){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 ts({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),Ao(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 ns({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 rs({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(ns,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var is=/^\s{0,3}(`{3,}|~{3,})/,as=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function os(e){return e.trim()===``}function ss(e){let t=is.exec(e);return t?t[1]:null}function cs(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=ss(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=ss(a);if(o&&!os(a))i=o,r.push(a);else if(os(a)){let i=e;for(;i<t.length&&os(t[i]);)i++;if(!(i<t.length&&as.test(t[i]))&&r.length>0){n.push(r.join(`
16
17
  `)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
17
- `),inFence:i!==null}}function ts(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 ns=(0,f.memo)(function({text:e}){return(0,h.jsx)(va,{text:e})}),rs=22,is=14,as=()=>typeof document<`u`&&document.hidden;function os(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||as()||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(as()){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?is:rs;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=ts(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 ss=600,cs=32;function ls({text:e,inFence:t}){let n=!t&&e.length>=ss,[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>=cs)r();else return o.current=setTimeout(r,cs-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)(va,{text:n?r:e})}var us=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=os(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>es(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)(ns,{text:e},t)),a.length>0&&(0,h.jsx)(ls,{text:a,inFence:o},i.length)]})});function ds(e){let t=e.items.map(e=>({...or(e,1),text:e.role===`tool`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function fs(e,t,n,r){let i=`${e.header.id}:${t}:${n.id}:${n.parts}`,[a,o]=(0,f.useState)({key:``}),{detail:s}=e,c=n.parts;return(0,f.useEffect)(()=>{if(!r||c===0)return;let e=new AbortController;return s(t,c,e.signal).then(e=>o({key:i,value:e}),t=>{e.signal.aborted||o({key:i,error:t instanceof Error?t.message:`unavailable`})}),()=>e.abort()},[s,t,c,r,i]),a.key===i?a:{}}function ps(e){let t=e.map((e,t)=>({step:e,index:t})),n=t.filter(({step:e})=>e.role!==`user`),r=n.findLastIndex(({step:e})=>e.role===`tool`),i=({step:e})=>e.role===`tool`||e.text.trim()!==``;return{user:t.filter(({step:e})=>e.role===`user`),steps:n.slice(0,r+1).filter(i),answer:n.slice(r+1).filter(i)}}var ms={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},hs=e=>Object.hasOwn(ms,e)?ms[e]:`other`,gs={read:[`Read 1 file`,`Read {n} files`],list:[`Listed 1 directory`,`Listed {n} directories`],search:[`Searched once`,`Searched {n} times`],run:[`Ran 1 command`,`Ran {n} commands`],edit:[`Edited 1 file`,`Edited {n} files`],other:[`Used 1 tool`,`Used {n} tools`]},_s=new Set([`read`,`list`,`edit`]);function vs(e,t){return _s.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function ys({turn:e,steps:t,live:n,answered:r,toggled:i=null,onToggle:a}){let{t:o}=T(),[s,c]=(0,f.useState)(i),l=s??(!n&&!r),u=t.map(({step:e})=>e).filter(e=>e.role===`tool`),d=u.filter(e=>e.error).length,{thinking:p,media:m,other:g}=e.header.omitted,_=[p&&o(`Thinking is not retained.`),m&&o(`Media is not retained.`),g&&o(`Other content is not retained.`)].filter(e=>e!==!1),v;if(n){let e=u.at(-1);v=e?`${o(`Working…`)} ${e.name||o(`Tool`)} ${e.target}`.trim():o(`Working…`)}else{let e=new Map;for(let t of u){let n=hs(t.name);e.set(n,(e.get(n)??new Set).add(vs(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(gs[e][0]):o(gs[e][1],{n:t.size})).join(` · `)||(p?o(`Thought`):m?o(`Media not retained`):g?o(`Content not retained`):``)}let y=(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(`span`,{className:`chat-steps-live`,"aria-hidden":`true`}):(0,h.jsx)(si,{className:`chat-steps-chevron`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chat-steps-title`,children:v}),d>0&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:o(`{n} failed`,{n:d})})]});return t.length===0&&_.length===0?(0,h.jsx)(`div`,{className:`chat-steps`,role:`status`,children:(0,h.jsx)(`div`,{className:`chat-steps-head`,children:y})}):(0,h.jsxs)(`details`,{className:`chat-steps`,"aria-label":o(`Working steps`),open:l,onToggle:e=>{let t=e.currentTarget.open;t!==l&&(c(t),a?.(t))},children:[(0,h.jsx)(`summary`,{className:`chat-steps-head`,children:y}),t.length>0&&(0,h.jsx)(`ol`,{className:`chat-steps-list`,children:t.map(({step:t,index:n})=>(0,h.jsx)(`li`,{children:t.role===`tool`?(0,h.jsx)(xs,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(bs,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function bs({turn:e,index:t,step:n,render:r=e=>(0,h.jsx)(ya,{text:e})}){let{t:i}=T(),a=t<e.header.stable,o=fs(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(Yo,{images:n.images,turn:e}):null,r(o.value?.text??n.text),n.clipped&&a&&!o.value&&(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(i,o.error):i(`Reading the rest of this message…`)})]})}function xs({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=fs(e,t,n,i);return(0,h.jsxs)(`details`,{className:`chat-tool`,open:i,onToggle:e=>a(e.currentTarget.open),children:[(0,h.jsxs)(`summary`,{children:[(0,h.jsx)(`span`,{className:`chat-tool-name`,children:n.name||r(`Tool`)}),n.target&&(0,h.jsx)(`span`,{className:`chat-tool-target`,title:n.target,children:n.target}),n.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:r(`failed`)})]}),i&&n.parts>0&&(o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`pre`,{children:o.value.args}),o.value.text&&(0,h.jsx)(`pre`,{children:o.value.text})]}):(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):r(`Reading…`)}))]})}var Ss=(0,f.memo)(function({turn:e,toggled:t,onToggle:n}){let{t:r,tx:i}=T(),{header:a}=e,{user:o,steps:s,answer:c}=ps(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
18
- `).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":r(`Conversation turn`),children:[o.map(({step:t,index:n})=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:r(`You`)}),(0,h.jsx)(bs,{turn:e,index:n,step:t})]},n)),(u||c.length>0)&&(0,h.jsxs)(`article`,{className:`chat-message assistant`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:`Cadence`}),u&&(0,h.jsx)(ys,{turn:e,steps:s,live:l,answered:c.length>0,toggled:t,onToggle:e=>n?.(a.id,e)}),c.map(({step:t,index:n})=>(0,h.jsx)(bs,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(us,{text:e}):void 0},n))]}),a.execution&&(0,h.jsxs)(`details`,{className:`inspector-note`,children:[(0,h.jsx)(`summary`,{children:r(`Context fixed at admission:`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:a.execution.cwd}),` ·`,` `,a.execution.model?`${a.execution.model.provider}/${a.execution.model.model} · ${a.execution.model.thinking}`:r(`No model`)]})]}),d.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:d.map(e=>i(e)).join(`
19
- `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function Cs({hint:e,children:t}){let{t:n}=T();return(0,h.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e}),t]})}var ws=[`queued`,`running`],Ts=e=>ws.includes(e.status);function Es(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function Ds(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function Os(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=>Es(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=Es(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 ks(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?Es(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 As(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 js({client:e,run:t,onOpen:n,onChanged:r}){let{t:i,tx:a}=T(),o=(0,f.useId)(),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(``),d=(0,f.useRef)(!0);(0,f.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let p=Ts(t),m=p?[a(Ds(t)),t.steps.filter(e=>e.status===`running`).map(e=>io(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,As(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
20
- `).find(e=>e.trim())??``,_=m.filter(Boolean).join(` · `);return(0,h.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,h.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,h.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:_,children:_})]}),p&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),Ns(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):g&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:g,children:a(g)})]})}function Ms({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan banner-notice`,"aria-label":i(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:i(`Current implementation plan`)}),(0,h.jsx)(`p`,{children:i(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,h.jsxs)(`p`,{children:[i(`Declared write paths use the checkout root:`),` `,(0,h.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:e.display.baseCommit})]}),(0,h.jsx)(`p`,{children:i(`Approval covers only this plan: implementation, checks, bounded repairs and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(ya,{text:qn(e.plan)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function Ns(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 Ps({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),c=Ii(e,{kind:`workflow`,id:t},o),l=c.value?.kind===`workflow`&&c.value.response.type===`run`?c.value.response.run:null,[u,d]=(0,f.useState)(null),p=Ii(e,u?{kind:`workflow-detail`,id:t,stepId:u}:null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(``),y=l&&[`queued`,`running`].includes(l.status),b=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(b.current=!0,()=>{b.current=!1}),[]),(0,f.useEffect)(()=>{l&&![`queued`,`running`].includes(l.status)&&s(0)},[l]),(0,h.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`strong`,{children:l?.goal??i(`Observing workflow`)}),l&&(0,h.jsxs)(`span`,{className:`ep-state ${l.status}`,children:[a(l.phase),` · `,a(l.status)]})]}),(c.error||_)&&(0,h.jsxs)(`p`,{role:`alert`,children:[_||c.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),l?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:l.execution.cwd}),` ·`,` `,l.execution.model?`${l.execution.model.provider}/${l.execution.model.model} · ${l.execution.model.thinking}`:i(`No model`)]}),l?.notice&&(0,h.jsx)(`p`,{children:l.notice}),l&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:Zn(l)})]}),l?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:l.mergedCommit})]}),l&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),l?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,io(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(ya,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:io(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,h.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>d(e.id),children:i(`Read retained step result`)}),u===e.id&&p.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:p.value.text}),u===e.id&&p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error})]},e.id)),y&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:m,onClick:()=>{l&&(g(!0),Ns(e,l).then(e=>{b.current&&(v(e),c.refresh(),n?.())}).finally(()=>{b.current&&g(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:c.refresh,children:i(`Observe current state`)})]})}var Fs=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Is(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function Ls({client:e,id:t,workspaceId:n,initialCwd:r,onLocation:i,enabled:a,actionsReady:o=a,prepareForSend:s,legacyWorkspaceId:c,directoryNamespaces:l=[],available:u=a,canInterrupt:d=a,modelEnabled:p=a,onModelChanged:m,onChanged:g,reference:_,onReferenceUsed:v,hidden:y=!1,onOpenAgent:x,onWorkflowRuns:S}){let{t:C,tx:w}=T(),[E]=(0,f.useState)(()=>bo(n,t,c,...l)),[D,O]=(0,f.useState)(()=>Is(E)),k=Ko(),ee=k.remove,A=(0,f.useRef)([]),j=(0,f.useRef)(null),[M,N]=(0,f.useState)(()=>Is(`${E}:mode`)===`cadence`?`cadence`:`chat`),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(``),[R,z]=(0,f.useState)(()=>Is(`${E}:pending`)),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!1),[ne,re]=(0,f.useState)(!1),[W,ie]=(0,f.useState)(0),ae=(0,f.useRef)(null),G=(0,f.useRef)(!1),oe=(0,f.useRef)(0),se=(0,f.useRef)(new AbortController),[ce,le]=(0,f.useState)(!1),K=Ii(e,u&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),ue=K.value?.kind===`conversation-context`?K.value.context:void 0,de=!!ue&&!K.error,fe=ue?.cwd??r,pe=(0,f.useRef)(null),me=(0,f.useMemo)(()=>({models:n=>fe?e.models(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>fe?e.chooseModel(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,fe]),he=(0,f.useRef)(i);he.current=i,(0,f.useEffect)(()=>{de&&fe&&he.current?.({id:t,cwd:fe})},[de,t,fe]);let q=Mo(e,t,u),{turns:ge}=q,_e=q.summary!==void 0,ve=Ii(e,u?{kind:`cadence-conversation`,id:t}:null,1e3),J=ve.value?.kind===`cadence-conversation`?ve.value.state:void 0,Y=J?.enabled===!0,ye=!!J||!!ve.error,be=!!J&&!ve.error&&!J.notice,xe=(0,f.useRef)(J);xe.current=J;let[Se,Ce]=(0,f.useState)(``),we=(0,f.useRef)(``),X=Li(D,Y?`cadence`:M),Te=a&&de&&_e&&!q.error&&ye&&!(Y&&(ve.error||J?.notice))&&!P&&!H&&!R,Ee=q.summary??void 0,De=Ee&&(Ee.status===`queued`||Ee.status===`running`),Oe=!!Ee&&Ee.status!==`completed`&&!De,[ke,Ae]=(0,f.useState)(!1),je=!!s&&a&&(!!q.error||!!K.error)&&q.error!==`retired-conversation`&&K.error!==`retired-conversation`&&!J?.notice&&!De&&!P&&!R&&!H,Me=(d||!!s)&&de&&_e&&be&&!q.error&&!P&&!R&&!De,Ne=!!J?.proposal&&!!Ee&&!De&&Ee.status!==`unknown`,Pe=J?.proposal&&Ee?.status===`unknown`?C(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,Fe=(0,f.useRef)(null),Ie=(0,f.useRef)(null),Le=(0,f.useRef)(0),Re=(0,f.useRef)(!0),[ze,Be]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!y&&Ie.current&&!Re.current&&(Ie.current.scrollTop=Le.current)},[y]);let Ve=(0,f.useRef)(!0),He=(0,f.useRef)(``),Ue=(0,f.useRef)(D);(0,f.useEffect)(()=>(Ve.current=!0,se.current.signal.aborted&&(se.current=new AbortController),()=>{Ve.current=!1,se.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${E}:mode`,M)}catch{}},[E,M]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(E,D)}catch{}},[D,E]),(0,f.useEffect)(()=>{try{R?sessionStorage.setItem(`${E}:pending`,R):sessionStorage.removeItem(`${E}:pending`)}catch{}},[E,R]),(0,f.useEffect)(()=>{_&&(O(e=>`${e}${e?`
21
- `:``}@${_}`),v(),Fe.current?.focus())},[_,v]),(0,f.useEffect)(()=>{let e=Ee?`${Ee.leaf}:${Ee.status}`:``;e&&He.current!==e&&(He.current=e,g()),we.current&&J?.runs.includes(we.current)&&(we.current=``,Ce(``),L(``)),R&&(Ee?.live?.commandId===R||q.attempt?.commandId===R||ge.some(e=>e.header.id===R)||q.commands.includes(R))&&(z(``),ee(A.current),O(e=>e===Ue.current?``:e),g()),Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[Ee,ge,R,g,J,q,ee]);let We=(0,f.useMemo)(()=>ge.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[ge]),Ge=Xa(Ie,We),Ke=(0,f.useRef)(new Map),qe=(0,f.useCallback)((e,t)=>{Ke.current.set(e,t)},[]),{earlier:Je,loadEarlier:Ye}=q,Xe=()=>{let e=Ie.current;e&&!y&&Je&&e.scrollTop<1200&&Ye()};(0,f.useEffect)(Xe);let Ze=ge[0]?.ordinal,Qe=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Ie.current;if(!e)return;let t=Qe.current;!Fs&&!Re.current&&t.ordinal!==void 0&&Ze!==void 0&&Ze<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Qe.current={ordinal:Ze,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${E}:approval`)}catch{}},[E]);let $e=(0,f.useMemo)(()=>[...new Set([...q.runs,...J?.runs??[]])],[q.runs,J?.runs]),et=JSON.stringify($e.slice(-4));(0,f.useEffect)(()=>{S?.(JSON.parse(et))},[et,S]);let[tt,Z]=(0,f.useState)({terminal:8,browser:8}),nt=(0,f.useMemo)(()=>[...new Set([...q.runs.slice(-tt.terminal),...(J?.runs??[]).slice(-tt.browser)])],[q.runs,J?.runs,tt]),rt=so(e,u?nt:[],1e3),it=ge.find(e=>e.header.at>0)?.header.at,at=!Je&&ge.length>0;(0,f.useEffect)(()=>{if(!u)return;let e=(e,t)=>ks(e,t,rt.runs,rt.unreadable,it,at),t=e(q.runs,tt.terminal),n=e(J?.runs??[],tt.browser);(t!==tt.terminal||n!==tt.browser)&&Z({terminal:t,browser:n})},[u,q.runs,J?.runs,tt,rt,it,at]);let ot=(0,f.useMemo)(()=>Os(ge,rt.runs.values(),Je),[ge,rt.runs,Je]),st=[...rt.runs.values()].filter(Ts).at(-1),ct=[...rt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{ct&&Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[ct]);let lt=t=>(0,h.jsx)(js,{client:e,run:t,onOpen:()=>x?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{ve.refresh(),g()}},t.id),ut=async()=>{if(!J?.proposal){L(C(`No plan is awaiting approval.`));return}if(!o||!be||!Te||De||Se||!Ne)return;let t=J,n=oe.current;F(!0),L(``);try{let r=await Po({client:e,state:t,current:()=>Ve.current&&oe.current===n&&xe.current?.revision===t.revision&&xe.current?.enabled===!0,submitting:e=>{we.current=e,Ce(e)}});if(!Ve.current||oe.current!==n)return;r.kind===`error`?(L(r.error.code),Ce(``)):O(e=>Io(e)?``:e)}catch(e){Ve.current&&oe.current===n&&L(e instanceof Error?e.message:`unavailable`)}finally{Ve.current&&oe.current===n&&(F(!1),ve.refresh(),q.refresh(),g())}},dt=async(n,r)=>{let i=r?.text??n??D,a=r?.images??(n?[]:k.files),c=r?r.command.kind===`cadence-exit`:Y&&Fo(i);if(!(c?Me:Te)&&!je||De||!i.trim()&&!a.length)return;if(c&&a.length){L(C(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&Y&&Io(i)){o?await ut():L(C(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let l=Li(i,M).mode===`cadence`;if(!je&&(Y||l)&&!be){L(C(`Cadence state unavailable. Observe the conversation before sending.`));return}if(G.current)return;G.current=!0,F(!0),L(``);let u=oe.current,d=()=>Ve.current&&oe.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&z(e)},h=async e=>{s&&(le(!0),await uo(s,se.current.signal,e,e=>{p=e}),d()&&(le(!1),ie(e=>e+1)))};try{if(je){if(await h(ue?{id:t,cwd:ue.cwd}:void 0),!d())return;q.refresh(),K.refresh(),ve.refresh(),g(),L(C(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let n=r??ho({id:t,head:q.leaf,text:i,images:a,revision:J?.revision??0,location:ue?{id:t,cwd:ue.cwd}:void 0,model:pe.current??ue?.model??void 0,intent:c?`exit`:Y?`message`:l?`enter`:`ordinary`});if(await h(n.location),!d())return;if(n.command.kind===`cadence-exit`){let t=yo(n);Ue.current=i,f=!0;let r=await mo(e,t,m);if(!d())return;r.kind===`error`?L(C(po(r.error.effect),{code:r.error.code})):(z(``),N(`chat`),O(e=>e===i?``:e)),ve.refresh(),q.refresh(),g();return}let o=()=>{ae.current=n,U(!0),V(!0)},s=await e.models(void 0,n.location);if(!d())return;let u=s.kind===`ok`?s.value.selected??s.value.remembered:null;!n.model&&u&&(n=_o(n,u));let p=n.model??(s.kind===`ok`?s.value.remembered:null);if(s.kind===`ok`&&!s.value.selected&&p){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:s.value.version.epoch,...n.location?{location:n.location,expected:s.value.version,choice:p}:{}});if(!d())return;if(t.kind===`error`){L(t.error.code),o();return}if(s=await e.models(void 0,n.location),!d())return;ie(e=>e+1)}if(s.kind!==`ok`||!s.value.selected){o();return}vo(n,s.value.selected);let _=yo(n,s.value.version);if(n.images.length){let t=s.value.selected;if(!s.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){L(C(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(_.kind===`cadence-exit`)throw Error(`invalid`);if(_=await wo(e,_,n.images,d),!d())return}A.current=n.images,Ue.current=i,f=!0;let v=await mo(e,_,m);if(!d())return;v.kind===`error`?L(C(po(v.error.effect),{code:v.error.code})):(ee(A.current),O(e=>e===Ue.current?``:e),z(``),_.kind===`cadence-send`&&N(`chat`),mt(null)),ve.refresh(),q.refresh(),g()}catch(e){d()&&L(C(f?po():fo(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{oe.current===u&&(G.current=!1),d()&&(F(!1),le(!1))}},ft=(0,f.useRef)(dt);ft.current=dt,(0,f.useEffect)(()=>{if(ne&&Te&&!De){re(!1);let e=ae.current;ae.current=null,e&&ft.current(void 0,e)}},[ne,Te,De]),(0,f.useEffect)(()=>{if(!ne)return;let e=setTimeout(()=>{re(!1),ae.current=null},1e4);return()=>clearTimeout(e)},[ne]);let pt=async()=>{let n=Ee?.live;if(!n||P)return;F(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Ve.current&&(r.kind===`error`&&L(r.error.code),F(!1),q.refresh())},mt=e=>{++oe.current,se.current.abort(),se.current=new AbortController,ae.current=null,G.current=!1,U(!1),re(!1),V(!1),F(!1),le(!1),q.choose(e),Ae(!1)},ht=P||H||!!R||!!De,gt=e=>{if(!ht)try{k.add(e),L(``)}catch(e){L(w(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:y,"aria-label":C(Y?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Hr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:Ee?.title??C(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:C(Y?`Cadence on`:`Ordinary`)}),Ee&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:Ee.origin===`terminal`?C(`Started in the terminal`):C(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(q.branches>1||q.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":ke,onClick:()=>Ae(e=>!e),children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),C(`Branches ({count})`,{count:q.branches})]}),q.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>mt(null),children:C(`Show the latest`)}),st&&(0,h.jsx)(`span`,{className:`ep-state running`,children:w(Ds(st))}),Ee&&(!st||Oe||Y&&!De&&!!J?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${Ee.status}`,children:Y?De?C(`Discussing`):Oe?w(Ee.status):J?.proposal?C(`Awaiting plan approval`):C(`Ready for conversation`):w(Ee.status)})]})]}),K.error&&!je&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(C,K.error)}),je&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),ce&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Preparing execution for this Send…`)}),ke&&(0,h.jsx)(Go,{client:e,id:t,leaf:q.leaf,onChoose:mt,onClose:()=>Ae(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Ie,onScroll:()=>{let e=Ie.current;e&&!y&&(Le.current=e.scrollTop,Re.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Be(!Re.current),Xe())},children:[q.summary===null&&(0,h.jsx)(Cs,{hint:C(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),u&&!q.error&&(!_e||ge.length===0&&q.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:C(`Reading this conversation…`)}),ge.length>0&&Je&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:q.loadingEarlier&&C(`Reading earlier messages…`)}),ot.start.map(lt),We.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(Za,{id:e,show:!Ge.hidden.has(e),height:Ge.placeholder(e,t,320),containerRef:Ie,onMeasured:Ge.recordMeasured,lazyRef:Ge.register(e),children:(0,h.jsx)(Ss,{turn:n,toggled:Ke.current.get(e)??null,onToggle:qe})}),ot.after.get(e)?.map(lt),n.header.entry&&n.ordinal<q.count-1&&!De&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:C(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>mt(n.header.entry),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),C(`Continue from here`)]})]},e)),ot.end.map(lt),q.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":C(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:q.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${q.attempt.status}`,children:w(q.attempt.status)}),` `,q.attempt.notice?w(q.attempt.notice):``]})]}),J?.enabled&&J.proposal&&(0,h.jsx)(Ms,{proposal:J.proposal,canApprove:o&&Te&&be&&Ne&&!De&&!Se,approvalHint:Pe,onApprove:()=>void ut()}),J?.enabled&&!J.proposal&&$e.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`Cadence stays on for this conversation until you explicitly exit.`)}),rt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:C(`Workflow activity unavailable; retained work may still be running.`)}),J?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:w(J.notice)}),[...new Set([I,q.error,ve.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(C,e??``)},e)),q.error&&q.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:C(`Observation is not current. Retained history is shown; this does not mean work has stopped.`)}),R&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[C(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:R}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:C(`Observe current state`)})]}),q.pinned&&!De&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),ze&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":C(`Latest messages`),onClick:()=>{Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight),Re.current=!0},children:(0,h.jsx)(fi,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),gt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),dt()},children:[(0,h.jsx)(`input`,{ref:j,type:`file`,accept:jn.join(`,`),multiple:!0,hidden:!0,disabled:ht,"aria-label":C(`Add images`),onChange:e=>{gt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),k.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:k.files.map(e=>(0,h.jsx)(qo,{file:e,disabled:ht,remove:()=>ee([e])},k.key(e)))}),(0,h.jsx)(`textarea`,{ref:Fe,disabled:!a&&!(Y&&d)||!je&&(!_e||!ye||!!q.error)||P||!!R,"aria-label":C(`Message`),value:D,placeholder:C(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>O(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),gt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),dt())}}),(0,h.jsx)(`p`,{className:`composer-image-help`,children:C(`PNG, JPEG or WebP · {count} images · {each} MiB each · {total} MiB total. Unsent images stay in this tab.`,{count:An.count,each:An.bytes/1024/1024,total:An.totalBytes/1024/1024})}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:ht,"aria-label":C(`Add images`),title:C(`Add images`),onClick:()=>j.current?.click(),children:(0,h.jsx)(qr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${Y||X.mode===`cadence`?` on`:``}`,"aria-label":C(`Cadence mode`),"aria-pressed":Y||X.mode===`cadence`,disabled:Y?!Me:De||P,title:Y?C(`Cadence mode is on. Click to exit it.`):X.mode===`cadence`?C(`Your next message turns on Cadence mode. Click to cancel.`):C(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{Y?dt(`exit cadence`):X.mode===`cadence`?(N(`chat`),Li(D,`chat`).mode===`cadence`&&O(X.text)):N(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(Uo,{client:me,onObserved:e=>{pe.current=e.selected?go(e.selected):e.remembered},enabled:p&&u&&de,locked:!!De,refresh:String(W),open:B,onOpenChange:e=>{V(e),e||U(!1)},onChanged:()=>{K.refresh(),m()},onChosen:e=>{H&&ae.current&&(ae.current=_o(ae.current,e),U(!1),L(``),re(!0))},awaitingSend:H}),(0,h.jsx)(`span`,{className:`composer-hint`,children:Y?C(`Cadence stays on. Confirm one plan before implementation.`):X.mode===`cadence`?C(`Your next message turns on Cadence mode.`):``}),De?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:P||!d,onClick:()=>void pt(),children:[(0,h.jsx)(Fr,{}),C(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(Y&&Fo(D)?Me:Te)&&!je||!D.trim()&&!k.files.length,children:[(0,h.jsx)(ui,{}),C(`Send`)]})]})]})]})}function Rs({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=Ii(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Ii(e,t&&s?{kind:`file`,path:s,...n?{location:n}:{}}:null),m=d.value?.kind===`files`?d.value:void 0,g=p.value?.kind===`file`?p.value:void 0;return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Parent folder`),disabled:m?.parent==null,onClick:()=>{m?.parent!=null&&o(m.parent)},children:(0,h.jsx)(ui,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:a,children:a||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(zr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:d.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[m?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${s===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?o(e.path):c(e.path),children:[e.directory?(0,h.jsx)(Zr,{}):(0,h.jsx)(Qr,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),onClick:()=>r(e.path),children:(0,h.jsx)(Br,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void oa(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(ii,{})})]},e.path)),m?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No visible files`)}),m?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Bounded listing; narrow the directory to see more.`)})]}),s&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:s,children:s}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Close preview`),onClick:()=>c(null),children:(0,h.jsx)(Nr,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error}),g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:g.text}),g.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`File preview is limited; this is not the complete file.`)})]})]}),l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(`p`,{className:`files-policy`,children:i(`Readonly preview · references send paths, not file contents`)})]})}var zs=`未命名章节`;function Bs(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 Vs(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Bs(r||zs),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||zs}})}function Hs(e){return e.length>=2}function Us(e){let t=0,n=0;return e.split(`
22
- `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function Ws({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:Us(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 Gs({text:e}){let{t}=T(),[n,r]=(0,f.useState)(`raw`),[i,a]=(0,f.useState)(!0),[o,s]=(0,f.useState)(1),[c,l]=(0,f.useState)([]),[u,d]=(0,f.useState)(null),p=(0,f.useRef)(1),m=(0,f.useRef)(null),g=e.split(`
23
- `);return(0,f.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(m.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=Vs(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)(pa,{text:u?g.slice(u.start-1,u.end).join(`
24
- `):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[Hs(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)(ya,{text:e})})]}):n===`diff`?(0,h.jsx)(Ws,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Us(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 Ks({client:e,seed:t}){let{t:n,tx:r}=T(),i=ra(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Aa,{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(ta(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)(ka,{client:e,cursor:a,render:e=>(0,h.jsx)(Gs,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var qs=[`contents`,`checks`,`changes`,`reviews`];function Js(){let{t:e}=T();return(0,h.jsx)(`aside`,{className:`panel panel-right`,children:(0,h.jsx)(`p`,{className:`panel-empty`,children:e(`Select retained history to inspect`)})})}function Ys({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:qs.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)(ja,{client:e,seed:t}):(0,h.jsx)(Ks,{client:e,seed:{...t,reader:i}},i)})]})}var Xs={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.`},Zs=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Qs(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 $s({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(n??t),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),te=(0,f.useRef)(n??t),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return p(r.value),g(r.value.path),v(!1),b(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},P=(0,f.useRef)(N);(0,f.useEffect)(()=>(ee.current=!0,P.current(te.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{_&&j.current?.select()},[_]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let F=e=>{E||N(e)},I=()=>{let e=m.trim();E||(Zs(e)?N(e):k({step:`read`,code:`relative`}))},L=(_||!d)&&m.trim()||d?.path||``,R=!E&&!x&&!!L,z=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!Zs(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await N(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},B=d?Qs(d.path,r):void 0,V=y.trim().toLowerCase(),H=d?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],U=O&&(O.step===`read`&&Xs[O.code]?l(Xs[O.code]):u(O.code));return(0,h.jsxs)(Fa,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Selecting a folder does not start execution. Send prepares it when needed.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:l(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void z(e.path),children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[B&&!_?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&d?.path===r?`location`:void 0,disabled:E,onClick:()=>F(`~`),children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),B.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),B.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||B.inside)&&(0,h.jsx)(si,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===d?.path?`location`:void 0,disabled:E,onClick:()=>F(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),I()},children:(0,h.jsx)(`input`,{ref:j,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:m,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{g(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),k(null))}})}),d&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":_,disabled:E,onClick:()=>{g(d.path),v(!_),k(null)},children:(0,h.jsx)(ei,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Rr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:y,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>b(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),d?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(d.parent),children:[(0,h.jsx)(ui,{}),l(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(e.path),children:[(0,h.jsx)(Zr,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&H.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(V?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),U&&(0,h.jsxs)(`p`,{role:`alert`,children:[U,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[L&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:L})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!R,onClick:()=>void z(L),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function ec(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 tc({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Br,{"aria-hidden":`true`}),n(`New conversation`)]})})}function nc({title:e,children:t,className:n=``,count:r}){let[i,a]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${i?``:` collapsed`}`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,h.jsx)(ci,{"aria-hidden":`true`}):(0,h.jsx)(si,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]})}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!i,children:t})]})}function rc({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=ec(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,h.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,h.jsx)(si,{"aria-hidden":`true`}):(0,h.jsx)(ci,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(ni,{"aria-hidden":`true`}):(0,h.jsx)(Hr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function ic({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)(rc,{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)(Aa,{pager:e,compact:!0})]})}function ac({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,cancelCompatible:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,workflows:S,workflowLinks:C=[],workflowError:w=!1,selectedWorkflow:E,onWorkflow:D,onCancelWorkflow:O}){let{t:k,tx:ee}=T(),A=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,te=ra(e,A),j=ra(e,r&&A&&t?{...A,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),M=te.page&&!(`kind`in te.page)?te.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],N=s?.status===`complete`?s.runs:[],P=M.filter(e=>!N.some(t=>t.taskId===e.owner.taskId)),F=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":k(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:k(`Task conversations`)}),(0,h.jsx)(ic,{pager:j,scope:i,onScope:p,exclude:N.map(e=>e.runId)},r)]}),[I,L]=(0,f.useState)(()=>new Set),R=e=>{let t=C.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${E===e.id||t&&t===y?` active`:``}`,onClick:()=>D?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[k(`Cadence workflow`),` · `,ee(e.phase),` · `,ee(e.status)]})]})]}),O&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:I.has(e.id),onClick:()=>{L(t=>new Set(t).add(e.id)),O(e).finally(()=>L(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),k(`Cancel workflow — request stop`)]})]},e.id)},z=m.filter(e=>e.status===`running`||e.status===`queued`),B=m.filter(e=>!z.includes(e)),V=e=>S?.findLast(t=>C.some(n=>n.runId===t.id&&n.conversationId===e.id)),H=e=>{let t=[`running`,`queued`,`completed`].includes(e.status)?V(e):void 0;return(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===y?` active`:``}`,onClick:()=>b?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Hr,{})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[e.origin===`terminal`?k(`Terminal`):`WebUI`,` ·`,` `,e.cadence?k(`Cadence on`):k(`Ordinary`),` ·`,` `,t?ee(Ds(t)):e.cadence&&[`running`,`queued`].includes(e.status)?k(`Discussing`):e.cadence&&e.status===`completed`?k(`Ready for conversation`):ee(e.status)]})]})]},e.id)};return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(tc,{onConversation:x}),!n&&(0,h.jsxs)(nc,{title:k(`Running conversations`),count:s?.status===`complete`&&S&&!w&&g?String(N.length+z.length+S.length):`?`,className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Active roster unavailable; absence is not proof of settlement.`)}),w&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Conversation activity unavailable.`)}),z.map(H),S?.map(R),s?.status===`complete`&&N.length===0&&z.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No active runs`)}),N.map(e=>{let t=M.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??k(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[ee(e.kind),` · `,ee(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(rc,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(nc,{title:k(`Conversation history`),count:t?te.page&&!(`kind`in te.page)?`${B.length+P.length}${te.page.next||te.canPrevious||_?`+`:``}`:`?`:`${B.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[B.map(H),P.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Hr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:k(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&F]},e.owner.taskId)),te.page&&!(`kind`in te.page)&&P.length===0&&B.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(Aa,{pager:te,compact:!0})]}),!P.some(e=>e.owner.taskId===r)&&F]})]})}var oc=[`queued`,`running`];function sc({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Ii(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?oc.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!oc.includes(u.status)&&c(0)},[u]);let m=Ii(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?ds(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Ii(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(ni,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(Ps,{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)(Ss,{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)(ya,{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 cc({path:e,disabled:t=!1,onClick:n}){let{t:r}=T();return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Open working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(ci,{"aria-hidden":`true`})]})}function lc(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Mi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function uc(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(ie(r)):void 0,o=i?U(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(ie(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function dc(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function fc({side:e,width:t,onResize:n}){let{t:r}=T(),i=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>i.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":r(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:r=>{r.preventDefault(),i.current?.();let a=r.clientX,o=window.innerWidth,s=r=>{let i=dc({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),i.current=void 0};i.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function pc(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 mc=.4,hc=1.05;function gc(e){return Math.min(300,e*.86)}function _c(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function vc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function yc(e,t){return e===`left`?t:-t}function bc(e,t){return Math.max(-e,Math.min(0,-e+t))}function xc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Sc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:xc(r*hc,n,t)>=mc}var Cc=new Set([`auto`,`scroll`,`overlay`]);function wc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Cc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Tc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Ec(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=_c(r.clientX,window.innerWidth,n);i&&!wc(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=vc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=gc(window.innerWidth),h=m*hc;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=yc(r,d);let b=bc(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(xc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Sc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Tc(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function Dc(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 Oc=`modulepreload`,kc=function(e){return`/`+e},Ac={},jc=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=kc(t,n),t=s(t),t in Ac)return;Ac[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`:Oc,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 Mc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=ra(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)(Aa,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Nc,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Nc({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 jc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Dc(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)(ja,{client:e,seed:t})]})}var Pc=[[`tools`,Pr],[`context`,Kr],[`timeline`,ai],[`runs`,Xr]];function Fc({error:e,observationError:t,projectObservationError:n,onDemand:r=!1}){let{t:i,tx:a}=T();return!e&&!t&&!n?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),n&&(0,h.jsxs)(h.Fragment,{children:[i(`Project observation: {code}.`,{code:a(n)}),` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[i(`{message}.`,{message:a(t)}),` `,t===`stale`?i(`Context changed. Observe again and request a fresh confirmation.`):r?i(`Connection unavailable. Existing work may continue; no message is replayed automatically.`):(0,h.jsx)(x,{text:i(`Explicit service guidance: {status} / {start}. No service is started by this page.`),slots:{status:(0,h.jsx)(`code`,{children:`cadence-service status`}),start:(0,h.jsx)(`code`,{children:`cadence-service start --workspace <path>`})}})]})]})}function Ic({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareSend:l,directoryNamespaces:u}){let{t:d,tx:p,locale:m,setLocale:g}=T(),[_]=(0,f.useState)(()=>e??Ai()),[v,y]=(0,f.useState)(!1),[b]=(0,f.useState)(uc),[S,C]=(0,f.useState)(b?.taskId??null),[w,E]=(0,f.useState)(()=>b?null:Ni()??crypto.randomUUID()),[D,O]=(0,f.useState)(null),[k,ee]=(0,f.useState)([]),[A,te]=(0,f.useState)(null),[j,M]=(0,f.useState)(b?`task`:`files`),[N,P]=(0,f.useState)(),[F,I]=(0,f.useState)(),[L,R]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Ni();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[z]=(0,f.useState)(()=>crypto.randomUUID()),B=(0,f.useCallback)(()=>P(void 0),[]),[V,H]=(0,f.useState)(b?b.scope??{kind:`task`,id:b.taskId}:null),U=qi(s?.id,s?.epoch),ne=!s||U.readiness===`running`,re=!!s&&(U.readiness===`stopped`||U.readiness===`not-started`),ie=(0,f.useRef)(null);ne&&U.value?.epoch&&(ie.current=U.value.epoch);let ae=!s||!re&&(ne||ie.current!==null),G=Xi(_,S?{kind:`task`,id:S}:null,!v&&ae,ie.current),oe=!!(s&&(U.value||U.error)),se=!v&&!!(G.workspace||oe),ce=(0,f.useRef)(null);(G.workspace||U.value?.workspaceId)&&(ce.current=G.workspace?.workspaceId??U.value?.workspaceId??null);let le=l?async(e,t,n)=>{let r=await l(e,t,n);if(e.aborted)throw Error(`stale`);U.prepared(r);let i=G.reconnect();await G.whenReady(r,e,i)}:void 0,K=Ri(_.client,se),ue=Ii(_.client,G.workspace&&!v?{kind:`conversation-active`}:null,1e3),de=ue.value?.kind===`conversation-active`?ue.value.entries:[],fe=[...de,...(K.value?.entries??[]).filter(e=>!de.some(t=>t.id===e.id))],pe=Ii(_.client,G.workspace&&!v?{kind:`workflow-active`}:null,2e3),me=pe.value?.kind===`workflow-active`?pe.value:void 0,he=(0,f.useMemo)(()=>[...new Set([...me?.runs.map(e=>e.id)??[],...k])],[me,k]),q=Ii(_.client,!s&&G.workspace&&!v?{kind:`projects`}:null),ge=L??s?.cwd??(q.value?.kind===`projects`?q.value.entries.find(e=>e.current)?.path:void 0),_e=F?.id===w?F:void 0;(0,f.useEffect)(()=>{_e&&Ni()===_e.id&&history.replaceState({...history.state,cadenceCwd:_e.cwd,cadenceConversationId:_e.id},``,location.href)},[_e]);let ve=w?_e:ge?{id:z,cwd:ge}:void 0,J=_e?.cwd??ge??(q.value?.kind===`projects`?q.value.entries.find(e=>e.current)?.path:void 0)??G.workspace?.rootLabel,Y={state:G.observation,transportStatus:G.transportStatus,error:G.error,refresh:G.refresh},ye=Y.state?.snapshot.scope.kind===`task`&&Y.state.snapshot.scope.id===S?Y.state.snapshot.context:void 0,[be,xe]=(0,f.useState)(null),[Se,Ce]=(0,f.useState)(!1),we=(0,f.useRef)(null),[X,Te]=(0,f.useState)(260),[Ee,De]=(0,f.useState)(360),Oe=(0,f.useCallback)(()=>xe(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>Ce(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Ec({enabled:Se&&!v,open:be,onOpenChange:xe,container:we}),pc(we,be,Se&&!v,Oe);let[ke,Ae]=(0,f.useState)(b?.snapshotSeq),[je,Me]=(0,f.useState)(``),[Ne,Pe]=(0,f.useState)(``),[Fe,Ie]=(0,f.useState)(!0),Le=(0,f.useRef)(null),Re=(0,f.useRef)(null),ze=()=>{Re.current&&(Re.current.open=!1)},[Be,Ve]=(0,f.useState)(`messages`),[He,Ue]=(0,f.useState)(!1),[We,Ge]=(0,f.useState)(!1),[Ke,qe]=(0,f.useState)(),[Je,Ye]=(0,f.useState)(b?.cursor),[Xe,Ze]=(0,f.useState)(``),[Qe,$e]=(0,f.useState)([]),[et,tt]=(0,f.useState)(new Set),Z=(0,f.useRef)(!0),nt=e=>{Z.current&&$e(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Fi(t,e):t)})},rt=(0,f.useRef)(new Zi),it=W({taskId:S,scope:V,selectedSnapshot:ke??null,detached:v,attachment:G.attachmentVersion,workspaceContext:G.workspace?.context??null,observationError:G.error??null});rt.current.select(it),(0,f.useEffect)(()=>(Z.current=!0,()=>{Z.current=!1,rt.current.depart()}),[]);let at=e=>{let t=e??crypto.randomUUID();e||R(J??ge),O(null),t!==w&&(ee([]),P(void 0)),rt.current.depart(),E(t),C(null),H(null),Me(``),Pe(``),qe(void 0),Ye(void 0),Ae(void 0),Ve(`messages`),M(`files`),Oe(),history.replaceState({cadenceCwd:J??ge,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{w&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${w}`)},[w]);let ot=(e,t)=>{O(null),ee([]),E(null),M(`task`),Me(t??``),Pe(``),Ae(void 0),rt.current.depart(),C(e),H({kind:`task`,id:e}),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),history.replaceState(null,``,lc(e))};(0,f.useEffect)(()=>{let e=()=>{let e=uc();if(e)O(null),ee([]),E(null),M(`task`),rt.current.depart(),Ae(e.snapshotSeq),Me(``),Pe(``),C(e.taskId),H(e.scope??{kind:`task`,id:e.taskId}),qe(void 0),Ye(e.cursor),Ve(`messages`),Oe();else{let e=Ni();if(e){let t=history.state?.cadenceCwd;typeof t==`string`&&R(t),P(void 0),O(null),ee([]),E(e),C(null),H(null),M(`files`),rt.current.depart(),Oe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Oe]);let st=(e,t,n)=>{O(null),Ae(t),Pe(n??``),rt.current.depart(),H(e),qe(void 0),Ye(void 0),Ve(`messages`),Oe(),S&&history.replaceState(null,``,lc(S,void 0,{scope:e,snapshotSeq:t}))},ct=ke??Y.state?.snapshot.committedSeq??G.workspace?.committedSeq,lt=G.workspace?.storeId,ut=V&&lt&&ct?{storeId:lt,scope:V,snapshotSeq:ct,reader:`messages`,after:null,limit:50}:null,dt=V&&lt&&ct?{storeId:lt,scope:V,snapshotSeq:ct,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,ft=ye?Y.state?.snapshot.runs??[]:[],pt=rt.current.ticket(),mt=e=>{nt(e),e.receipt&&rt.current.current(pt)&&G.refresh()},ht=e=>{if(et.has(e)||!G.cancelCompatible||!G.activeRuns)return;let t=crypto.randomUUID(),n=G.activeRuns.epoch;tt(t=>new Set(t).add(e)),nt({commandId:t,error:d(`Stop requested; settlement is not yet confirmed.`)}),_.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{mt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:d(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>nt({commandId:t,error:d(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Z.current&&tt(t=>{let n=new Set(t);return n.delete(e),n})})};if(v)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:d(`Detached`)}),(0,h.jsx)(`p`,{children:d(`Accepted service work continues. No Cancel was requested.`)}),Qe.map(e=>(0,h.jsxs)(`p`,{children:[d(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>y(!1),children:d(`Reconnect as a viewer`)})]});let gt=G.activeRuns,_t=gt?.status===`complete`?gt.runs:[],vt=!v&&!G.error&&G.transportStatus===`current`&&(!Y.state||Y.state.connection===`current`),yt=ne&&vt,bt=v?`Viewer disconnected`:s&&U.readiness===`unknown`?`Project readiness unknown`:s&&U.readiness===`stale`?`Project observation stale`:re?`Ready to prepare on Send`:vt?G.workspace?Y.state?.connection??(S?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(`div`,{className:`app${Fe?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":d(`Tasks`),onClick:()=>xe(e=>e===`left`?null:`left`),children:(0,h.jsx)(Ur,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":d(`Workbench projects`),title:d(`Workbench projects`),onClick:n,children:(0,h.jsx)(Zr,{})}),(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),V&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":d(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Be===`messages`&&!Je,onClick:()=>{Ye(void 0),qe(void 0),Ve(`messages`)},children:[(0,h.jsx)(Hr,{"aria-hidden":`true`}),d(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Le,onKeyDown:e=>{e.key===`Escape`&&Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Be===`messages`?d(`Details`):p(Be),(0,h.jsx)(ci,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Pc.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Be===e,onClick:()=>{Ye(void 0),qe(void 0),Ve(e),Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),p(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Export selected scope`),disabled:!ut,onClick:()=>{Le.current&&(Le.current.open=!1,Le.current.querySelector(`summary`)?.focus()),Ge(!0)},children:[(0,h.jsx)(ti,{"aria-hidden":`true`}),d(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Copy token-free link`),disabled:!S,onClick:()=>{S&&oa(lc(S,Je,V?{scope:V,snapshotSeq:ke}:void 0)).then(e=>Ze(e?``:d(`Link copy unavailable.`)))},children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),d(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[(0,h.jsx)(Wa,{disabled:!dt,onOpen:()=>Ue(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:m===`zh`?`en`:`zh-CN`,"aria-label":m===`zh`?`Switch to English`:`切换到中文`,"data-tip":m===`zh`?`Switch to English`:`切换到中文`,onClick:()=>g(m===`zh`?`en`:`zh`),children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:m===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:Re,onKeyDown:e=>{e.key===`Escape`&&Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":d(`More`),title:d(`More`),children:(0,h.jsx)(Vr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Observe current state`),onClick:()=>{ze(),G.refresh(),Y.refresh()},children:[(0,h.jsx)(zr,{"aria-hidden":`true`}),d(`Refresh status`)]}),o&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{ze(),o()},children:[(0,h.jsx)(Lr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Cadence service`),(0,h.jsx)(`small`,{children:d(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Disconnect this page`),title:d(`Return — accepted work continues`),onClick:()=>{ze(),xe(null),Ue(!1),Ge(!1),rt.current.depart(),y(!0)},children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Disconnect this page`),(0,h.jsx)(`small`,{children:d(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${G.compatible===!1?` warn`:``}`,title:ki?.buildId??d(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:d(`Shared compatibility: {state}.`,{state:G.compatible===void 0?d(`Execution compatibility not observed`):G.compatible?d(`compatible`):d(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:d(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:ki?.buildId??d(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":d(`Files / history`),"aria-expanded":Se?be===`right`:Fe,onClick:()=>Se?xe(e=>e===`right`?null:`right`):Ie(e=>!e),children:[(0,h.jsx)(Ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:d(w?`Files`:`History`)})]})]}),!G.workspace&&_t.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":d(`Execution and cancellation`),children:_t.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[p(e.kind),` `,e.runId,` · `,p(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ot(e.taskId),children:d(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!G.cancelCompatible||et.has(e.runId),onClick:()=>ht(e.runId),children:[(0,h.jsx)(Fr,{"aria-hidden":`true`}),d(`Cancel run — request stop`)]})]},e.runId))}),a,re&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`status`,children:d(`Execution will be prepared when you send. Browsing does not start it.`)}),(0,h.jsx)(Fc,{onDemand:!!le,error:Xe,projectObservationError:U.error,observationError:G.error}),!re&&!yt&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`status`,children:d(`Observation is not current. Retained history is shown; this does not mean work has stopped.`)}),(0,h.jsxs)(`div`,{ref:we,className:`layout`,style:{"--left-w":`${X}px`,"--right-w":`${Ee}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":d(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${be?` on`:``}`,onClick:Oe}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${be===`left`?` open`:``}`,"aria-label":d(`Task navigation drawer`),tabIndex:-1,inert:Se&&be!==`left`,children:[se&&(0,h.jsx)(ac,{client:_.client,workspace:G.workspace,executionStopped:re,taskId:S,scope:V,runs:ft,snapshot:Y.state?.snapshot.committedSeq,activeRuns:G.activeRuns,cancelCompatible:!!G.cancelCompatible,canceling:et,onCancel:ht,chats:fe,chatActivityKnown:ue.value?.kind===`conversation-active`&&!ue.error,chatHistoryPartial:K.loading||K.canPrevious||!!K.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[K.error&&(0,h.jsx)(`p`,{role:`alert`,children:K.error}),K.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:d(`Reading conversation history…`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.previous,children:d(`Newer conversations`)}),K.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.next,children:d(`Older conversations`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:K.first,children:d(`Latest conversations`)}),K.error&&(0,h.jsx)(`button`,{type:`button`,onClick:K.refresh,children:d(`Observe current state`)})]}),conversationId:w,onConversation:at,onNewConversation:()=>at(),workflows:me?.runs,workflowLinks:me?.links,workflowError:!!pe.error,selectedWorkflow:D?.runId,onWorkflow:(e,t)=>{t?at(t):(O({runId:e.id,stepId:null,label:e.goal}),Oe())},onCancelWorkflow:async e=>{let t=await Ns(_.client,e);t&&Ze(t),pe.refresh()},onTask:ot,onScope:st}),G.workspace&&(0,h.jsx)(co,{client:_.client,active:G.activeRuns,taskId:S,runs:ft,snapshot:ct,workflowRuns:he,selected:D,onOpenWorkflow:e=>{O(e),Oe()},onOpen:(e,t,n,r)=>{ot(e),H({kind:`child`,id:t}),Pe(r),Ae(n),history.replaceState(null,``,lc(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(fc,{side:`left`,width:X,onResize:Te}),(0,h.jsxs)(`main`,{className:`main`,inert:Se&&be!==null,children:[D&&(0,h.jsx)(sc,{client:_.client,agent:D,backLabel:d(w?`Back to conversation`:S?`Back to task`:`Back`),onBack:()=>O(null),onOpenAgent:O},`${D.runId}:${D.stepId??``}`),w&&(!s||oe)&&(0,h.jsx)(Ls,{client:_.client,id:w,initialCwd:ge,onLocation:I,hidden:!!D,onOpenAgent:O,onWorkflowRuns:ee,workspaceId:s?`checkout:${s.path}`:ce.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?U.value?.workspaceId??void 0:void 0,prepareForSend:le,actionsReady:ne&&!!G.workspace&&!!G.compatible&&!G.error&&vt,available:se,canInterrupt:!!G.cancelCompatible,enabled:le?se:!!G.workspace&&!!G.compatible&&!G.error,modelEnabled:ne&&!!G.compatible&&G.transportStatus===`current`&&!G.error,onModelChanged:()=>{rt.current.depart(),G.refresh(!0),U.refresh()},onChanged:()=>{K.refresh(),G.refresh()},reference:N,onReferenceUsed:B},`${s?.id??ce.current??`connecting`}:${w}`),V&&!D&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[V.kind!==`task`&&S&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ot(S,je),children:d(`Back to task`)}),(0,h.jsx)(`h2`,{title:je||V.id,children:V.kind===`task`?je||d(`Task {id}`,{id:V.id.slice(0,8)}):Ne||d(`{kind} {id}`,{kind:p(V.kind),id:V.id.slice(0,8)})}),V.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:d(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[d(`Recorded conversation`),` ·`,` `,d(`snapshot {seq}`,{seq:ct??``})]}),(0,h.jsx)(`code`,{children:V.id}),(0,h.jsx)(`p`,{children:d(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!w||!!D,children:[!ut&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:d(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:d(`History is readonly. Start new work in a conversation with /cadence.`)})]}),ut&&Je?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Ke&&(Ke.owner.entity.kind===`task`||Ke.owner.entity.kind===`message`||Ke.owner.entity.kind===`tool`)&&(0,h.jsx)(Ma,{client:_.client,seed:{storeId:Je.storeId,scope:Je.scope,snapshotSeq:Je.snapshotSeq,kind:Ke.owner.entity.kind,id:Ke.owner.entity.id,version:Ke.owner.entity.version}},`${Ke.owner.entity.id}:${Ke.owner.entity.version}`),(0,h.jsx)(ka,{client:_.client,cursor:Je,highlight:Ke?.range},`${Je.recordId}:${Je.recordVersion}`)]}):ut&&(0,h.jsxs)(`div`,{className:Be===`messages`||Be===`tools`?`tab-body transcript-body`:`tab-body`,children:[Be===`messages`&&(0,h.jsx)(eo,{client:_.client,seed:ut}),Be===`tools`&&(0,h.jsx)(Lc,{client:_.client,seed:ut}),Be===`context`&&(0,h.jsx)(ja,{client:_.client,seed:ut}),Be===`timeline`&&(0,h.jsx)(Mc,{client:_.client,seed:ut,onSearch:()=>Ue(!0)}),Be===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:d(`Runs in the current snapshot`)}),ft.length>0?ft.map(e=>(0,h.jsx)(Ba,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:ye&&Y.state?d(`No owner run projection in this snapshot.`):d(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:d(`Retained runs`)}),(0,h.jsx)(Ua,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}},onScope:st},S)]})]},`${V?.kind}:${V?.id}:${ke??`current`}`)]}),G.workspace&&Qe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Qe.map(e=>(0,h.jsx)(Qi,{client:_.client,value:e,onChange:nt},e.commandId))})]}),(0,h.jsx)(fc,{side:`right`,width:Ee,onResize:De}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${be===`right`?` open`:``}`,"aria-label":d(`Files and history drawer`),tabIndex:-1,inert:Se&&be!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":d(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`files`,onClick:()=>M(`files`),children:[(0,h.jsx)(Zr,{}),d(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`task`,disabled:!ut,onClick:()=>M(`task`),children:[(0,h.jsx)(Kr,{}),d(`History details`)]})]}),j===`files`?(0,h.jsx)(Rs,{location:ve,client:_.client,enabled:!!G.workspace&&!!ve,onReference:e=>{w||at(z);let t=!w&&ve?`${ve.cwd.replace(/[\\/]+$/,``)}${ve.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;P(t),Oe()}},ve?.cwd??`owner`):ut?(0,h.jsx)(Ys,{client:_.client,seed:{...ut,scope:{kind:`task`,id:S??ut.scope.id}}},S):(0,h.jsx)(Js,{})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsxs)(`div`,{className:`statusbar-left`,children:[(0,h.jsxs)(`span`,{className:`status-item`,role:`status`,title:d(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${re?``:!yt||!G.workspace?`error`:Y.transportStatus===`current`?Y.state?Y.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),p(bt),!re&&Y.transportStatus!==`current`&&d(` · transport {status}`,{status:p(Y.transportStatus)}),Y.error?` · ${p(Y.error)}`:``]}),s&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Execution service: {status}`,{status:p(U.readiness)})}),gt?.status===`complete`?_t.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(yt?_t.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:_t.length})}):!re&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(G.workspace||s)&&(0,h.jsx)(cc,{path:J,onClick:()=>c?c(J):te(``)}),G.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),A!==null&&G.workspace&&(0,h.jsx)($s,{onOpen:t,projects:i??(q.value?.kind===`projects`?q.value.entries:[]),client:_.client,current:J??G.workspace.rootLabel,initial:A||void 0,home:r,epoch:G.workspace.epoch,onClose:()=>te(null)}),He&&dt&&(0,h.jsx)(za,{client:_.client,seed:dt,onClose:()=>Ue(!1),onHit:e=>{qe(e),Ye(e.cursor),S&&history.replaceState(null,``,lc(S,e.cursor,V?{scope:V,snapshotSeq:ke}:void 0))}}),We&&dt&&(0,h.jsx)(Ia,{request:{storeId:dt.storeId,scope:dt.scope,snapshotSeq:dt.snapshotSeq,format:`ndjson`},onClose:()=>Ge(!1)})]})}function Lc({client:e,seed:t}){let n=ra(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Aa,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(no,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Rc=`cadence-last-project`;function zc(){try{let e=localStorage.getItem(Rc);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Bc(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Rc,e)}catch{}}function Vc(e){let t=zc();return t?e.projects.find(e=>e.id===t):void 0}async function Hc(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=mn(await zi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Uc(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await zi(t);if(!t.ok)throw Error(Bi(n));return yn(n)}async function Wc(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 zi(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Bi(c));let l=pn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Gc(e){let t=await Uc();return Wc(`/workbench/v1/select`,{path:e},t)}async function Kc(e,t,n,r){let i=await Uc(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 Wc(`/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}var qc=`cadence-recovery-dismissed`,Jc={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.`},Yc={"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 Xc(){try{let e=JSON.parse(localStorage.getItem(qc)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Zc(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Qc({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Xc),[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(qc,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:Zc(e.path)}):e.scope===`workbench`?n(`Workbench`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Jc[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(Yc[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var $c={restart:18e4,upgrade:12e5},el=1e3,tl={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`npm could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},nl=e=>e instanceof Error?e.message:`unavailable`;function rl(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(tl[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 il(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function al({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 Hi(e.signal).then(a,t=>{e.signal.aborted||s(nl(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>$c[e.action])return w(`timeout`);try{let t=await Hi(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof A||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,el)};return r=setTimeout(i,el),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Ui().then(l,()=>l(`failed`))},k=n=>{i&&(_(!0),s(``),Wi({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(nl(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`&&il(C),o=i?.unit;return(0,h.jsxs)(Fa,{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:$c[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):rl(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)(Fa,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let ee=i&&c&&typeof c==`object`?kn(c.version,i.version)>0:!1;return(0,h.jsxs)(Fa,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:rl(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`npm could not be reached.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking npm for the latest version…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):i.upgrade===`npm`?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this copy was not installed with npm install -g; upgrade it the way you installed it.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(zr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function ol({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s}){let{t:c,locale:l,setLocale:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!0),y=(0,f.useRef)(null),b=(0,f.useCallback)(()=>p(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>g(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Ec({enabled:m,open:d,onOpenChange:p,container:y}),pc(y,d,m,b);let x=e=>{b(),i(e)},S=e=>{b(),a?a(e):i(e)},C=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${_?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":c(`Tasks`),onClick:()=>p(e=>e===`left`?null:`left`),children:(0,h.jsx)(Ur,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":c(`Cadence service`),"data-tip":c(`Cadence service`),onClick:o,children:(0,h.jsx)(Lr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,onClick:()=>u(l===`zh`?`en`:`zh`),"aria-label":l===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(Yr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":c(`Files`),"aria-expanded":m?d===`right`:_,onClick:()=>m?p(e=>e===`right`?null:`right`):v(e=>!e),children:[(0,h.jsx)(Ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:y,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":c(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${d?` on`:``}`,onClick:b}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${d===`left`?` open`:``}`,"aria-label":c(`Task navigation drawer`),tabIndex:-1,inert:m&&d!==`left`,children:(0,h.jsx)(`aside`,{className:`panel panel-left lp-panel`,children:(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:c(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?c(`Returning to your last project {name}…`,{name:C(n.path)}):n?.status===`unavailable`?c(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:C(n.path)}):t.length?c(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):c(`Choose a working folder to see its conversation history.`)}),t.map(t=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item project-item`,title:t,disabled:!e||!!r,"aria-busy":r===t,onClick:()=>S(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:C(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?c(`Selecting folder…`):t})]})]},t))]})]})})}),(0,h.jsx)(`main`,{className:`main`,inert:m&&d!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":c(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Cs,{hint:c(`Choose a working folder. Execution is prepared only when you send.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>x(),children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),c(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":c(`Message`),rows:3,placeholder:c(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:c(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(ui,{"aria-hidden":`true`}),c(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${d===`right`?` open`:``}`,"aria-label":c(`Files`),tabIndex:-1,inert:m&&d!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(Zr,{"aria-hidden":`true`}),c(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:c(`Files appear here after you open a working folder.`)})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:(0,h.jsx)(`span`,{className:`status-item faint`,children:c(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(cc,{disabled:!e,onClick:()=>x()})})]})]})}function sl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Mi),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(``),[m,g]=(0,f.useState)(0),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(null),x=(0,f.useRef)(new Map),S=(0,f.useRef)(!r),C=(0,f.useRef)(null),w=(0,f.useCallback)(()=>{C.current&&(C.current.abort(),C.current=null,b(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await zi(t);t.status===400&&Bi(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(Bi(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{w(),b(null),i(Mi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[w]),(0,f.useEffect)(()=>{if(!t||!S.current)return;S.current=!1;let e=Vc(t);if(!e)return;let n=new AbortController;C.current=n,b({status:`checking`,path:e.cwd}),Hc(e.id,n.signal).then(t=>{n.signal.aborted||(C.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let E=(0,f.useCallback)(e=>{w(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&x.current.set(r,window.location.hash),history.pushState({cadenceCwd:e?.cwd},``,e?`/app?project=${e.id}${x.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,w,t]),D=(0,f.useCallback)(async e=>{let t=await Gc(e);n(t.entry),E(t.project)},[E]),O=async(e,i,a)=>{let o=t?.projects.find(e=>e.id===r);if(!o)throw Error(`unavailable`);let s=await Kc(o,e,i,a);if(e.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},k=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new A(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await zi(n);if(!n.ok){let e=Bi(r);return{kind:`error`,error:te(ee.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:yr(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),j=(0,f.useMemo)(()=>r?Ai(r):void 0,[r]),M=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{M&&Bc(M.id)},[M]),t===null)return(0,h.jsx)(Ic,{});let N=t&&_&&(0,h.jsx)(al,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),P=()=>v(!0),F=t&&a!==null&&(0,h.jsx)($s,{selectOnly:!0,client:k,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:D});return t&&M&&j?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Ic,{api:j,project:M,directoryNamespaces:t?.projects.filter(e=>e.path===M.path).map(e=>e.id).sort(),onPrepareSend:O,onChooseFolder:e=>o(e??M.cwd),onOpenProject:D,onWorkbenchHome:()=>E(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(Qc,{notices:t.recoveries,project:M.path}),onOpenService:P},M.id),N,F]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(ol,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?P:void 0,onOpenFolder:e=>{w(),u(``),o(e??t?.home??``)},onOpenProject:t=>{s||(w(),u(``),c(t),D(t).catch(n=>u(e(`{path} could not be opened ({code}).`,{path:t,code:n instanceof Error?n.message:`unavailable`}))).finally(()=>c(null)))},children:[l&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:l}),t&&(0,h.jsx)(Qc,{notices:t.recoveries}),d&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[d,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>g(e=>e+1),children:e(`Reload observation`)})]}),r&&!M&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),F,N]})}function cl(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var ll=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(cl,{}):this.props.children}},ul=document.getElementById(`root`);if(!ul)throw Error(`Application root unavailable`);(0,p.createRoot)(ul).render((0,h.jsx)(E,{children:(0,h.jsx)(ll,{children:(0,h.jsx)(sl,{})})}));export{jc as t};
18
+ `),inFence:i!==null}}function ls(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 us=(0,f.memo)(function({text:e}){return(0,h.jsx)(Ea,{text:e})}),ds=22,fs=14,ps=()=>typeof document<`u`&&document.hidden;function ms(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||ps()||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(ps()){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?fs:ds;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=ls(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 hs=600,gs=32;function _s({text:e,inFence:t}){let n=!t&&e.length>=hs,[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>=gs)r();else return o.current=setTimeout(r,gs-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)(Ea,{text:n?r:e})}var vs=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=ms(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>cs(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)(us,{text:e},t)),a.length>0&&(0,h.jsx)(_s,{text:a,inFence:o},i.length)]})});function ys(e){let t=e.items.map(e=>({...mr(e,1),text:e.role===`tool`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function bs(e,t,n,r){let i=`${e.header.id}:${t}:${n.id}:${n.parts}`,[a,o]=(0,f.useState)({key:``}),{detail:s}=e,c=n.parts;return(0,f.useEffect)(()=>{if(!r||c===0)return;let e=new AbortController;return s(t,c,e.signal).then(e=>o({key:i,value:e}),t=>{e.signal.aborted||o({key:i,error:t instanceof Error?t.message:`unavailable`})}),()=>e.abort()},[s,t,c,r,i]),a.key===i?a:{}}function xs(e){let t=e.map((e,t)=>({step:e,index:t})),n=t.filter(({step:e})=>e.role!==`user`),r=n.findLastIndex(({step:e})=>e.role===`tool`),i=({step:e})=>e.role===`tool`||e.text.trim()!==``;return{user:t.filter(({step:e})=>e.role===`user`),steps:n.slice(0,r+1).filter(i),answer:n.slice(r+1).filter(i)}}var Ss={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Cs=e=>Object.hasOwn(Ss,e)?Ss[e]:`other`,ws={read:[`Read 1 file`,`Read {n} files`],list:[`Listed 1 directory`,`Listed {n} directories`],search:[`Searched once`,`Searched {n} times`],run:[`Ran 1 command`,`Ran {n} commands`],edit:[`Edited 1 file`,`Edited {n} files`],other:[`Used 1 tool`,`Used {n} tools`]},Ts=new Set([`read`,`list`,`edit`]);function Es(e,t){return Ts.has(t)?e.target?e.target:t===`list`?`.`:e.id:e.id}function Ds({turn:e,steps:t,live:n,answered:r,toggled:i=null,onToggle:a}){let{t:o}=T(),[s,c]=(0,f.useState)(i),l=s??(!n&&!r),u=t.map(({step:e})=>e).filter(e=>e.role===`tool`),d=u.filter(e=>e.error).length,{thinking:p,media:m,other:g}=e.header.omitted,_=[p&&o(`Thinking is not retained.`),m&&o(`Media is not retained.`),g&&o(`Other content is not retained.`)].filter(e=>e!==!1),v;if(n){let e=u.at(-1);v=e?`${o(`Working…`)} ${e.name||o(`Tool`)} ${e.target}`.trim():o(`Working…`)}else{let e=new Map;for(let t of u){let n=Cs(t.name);e.set(n,(e.get(n)??new Set).add(Es(t,n)))}v=[...e].map(([e,t])=>t.size===1?o(ws[e][0]):o(ws[e][1],{n:t.size})).join(` · `)||(p?o(`Thought`):m?o(`Media not retained`):g?o(`Content not retained`):``)}let y=(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(`span`,{className:`chat-steps-live`,"aria-hidden":`true`}):(0,h.jsx)(hi,{className:`chat-steps-chevron`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chat-steps-title`,children:v}),d>0&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:o(`{n} failed`,{n:d})})]});return t.length===0&&_.length===0?(0,h.jsx)(`div`,{className:`chat-steps`,role:`status`,children:(0,h.jsx)(`div`,{className:`chat-steps-head`,children:y})}):(0,h.jsxs)(`details`,{className:`chat-steps`,"aria-label":o(`Working steps`),open:l,onToggle:e=>{let t=e.currentTarget.open;t!==l&&(c(t),a?.(t))},children:[(0,h.jsx)(`summary`,{className:`chat-steps-head`,children:y}),t.length>0&&(0,h.jsx)(`ol`,{className:`chat-steps-list`,children:t.map(({step:t,index:n})=>(0,h.jsx)(`li`,{children:t.role===`tool`?(0,h.jsx)(ks,{turn:e,index:n,step:t}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(Os,{turn:e,index:n,step:t})})},n))}),_.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function Os({turn:e,index:t,step:n,render:r=e=>(0,h.jsx)(Da,{text:e})}){let{t:i}=T(),a=t<e.header.stable,o=bs(e,t,n,n.clipped&&a);return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(rs,{images:n.images,turn:e}):null,r(o.value?.text??n.text),n.clipped&&a&&!o.value&&(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(i,o.error):i(`Reading the rest of this message…`)})]})}function ks({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=bs(e,t,n,i);return(0,h.jsxs)(`details`,{className:`chat-tool`,open:i,onToggle:e=>a(e.currentTarget.open),children:[(0,h.jsxs)(`summary`,{children:[(0,h.jsx)(`span`,{className:`chat-tool-name`,children:n.name||r(`Tool`)}),n.target&&(0,h.jsx)(`span`,{className:`chat-tool-target`,title:n.target,children:n.target}),n.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:r(`failed`)})]}),i&&n.parts>0&&(o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`pre`,{children:o.value.args}),o.value.text&&(0,h.jsx)(`pre`,{children:o.value.text})]}):(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):r(`Reading…`)}))]})}var As=(0,f.memo)(function({turn:e,toggled:t,onToggle:n}){let{t:r,tx:i}=T(),{header:a}=e,{user:o,steps:s,answer:c}=xs(e.steps),l=a.status===`running`&&c.length===0,u=s.length>0||l||Object.values(a.omitted).some(Boolean),d=a.notice.split(`
19
+ `).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":r(`Conversation turn`),children:[o.map(({step:t,index:n})=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:r(`You`)}),(0,h.jsx)(Os,{turn:e,index:n,step:t})]},n)),(u||c.length>0)&&(0,h.jsxs)(`article`,{className:`chat-message assistant`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:`Cadence`}),u&&(0,h.jsx)(Ds,{turn:e,steps:s,live:l,answered:c.length>0,toggled:t,onToggle:e=>n?.(a.id,e)}),c.map(({step:t,index:n})=>(0,h.jsx)(Os,{turn:e,index:n,step:t,render:a.status===`running`?e=>(0,h.jsx)(vs,{text:e}):void 0},n))]}),a.execution&&(0,h.jsxs)(`details`,{className:`inspector-note`,children:[(0,h.jsx)(`summary`,{children:r(`Context fixed at admission:`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:a.execution.cwd}),` ·`,` `,a.execution.model?`${a.execution.model.provider}/${a.execution.model.model} · ${a.execution.model.thinking}`:r(`No model`)]})]}),d.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:d.map(e=>i(e)).join(`
20
+ `)}),![`completed`,`running`,`queued`].includes(a.status)&&(0,h.jsx)(`p`,{className:`ep-state ${a.status}`,children:i(a.status)})]})});function js({hint:e,children:t}){let{t:n}=T();return(0,h.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e}),t]})}var Ms=[`queued`,`running`],Ns=e=>Ms.includes(e.status);function Ps(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function Fs(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function Is(e,t,n){let r=[],i=[],a=new Map;if(!e.length)return{start:r,after:a,end:i};let o=e.filter(e=>e.header.at>0),s=e=>Ps(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=Ps(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 Ls(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?Ps(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 Rs(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 zs({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=Ns(t),m=p?[a(Fs(t)),t.steps.filter(e=>e.status===`running`).map(e=>po(e.id)).join(`, `)]:[a(t.status),t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,Rs(t,i)],g=p||t.status===`completed`?``:t.notice.split(`
21
+ `).find(e=>e.trim())??``,_=m.filter(Boolean).join(` · `);return(0,h.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,h.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,h.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:_,children:_})]}),p&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),Vs(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):g&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:g,children:a(g)})]})}function Bs({proposal:e,canApprove:t,approvalHint:n,onApprove:r}){let{t:i}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan banner-notice`,"aria-label":i(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:i(`Current implementation plan`)}),(0,h.jsx)(`p`,{children:i(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,h.jsxs)(`p`,{children:[i(`Declared write paths use the checkout root:`),` `,(0,h.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:e.display.baseCommit})]}),(0,h.jsx)(`p`,{children:i(`Approval covers this goal and boundary: adaptive implementation, checks, recovery, project knowledge and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(Da,{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)(Da,{text:tr(e.plan)})]}),e.delivery&&(0,h.jsx)(Da,{text:Xn(e.delivery)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!t,onClick:r,children:i(`Implement this plan`)}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n}),(0,h.jsx)(`p`,{children:i(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function Vs(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 Hs(e){return(0,h.jsx)(Us,{...e},e.id)}function Us({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=Wi(e,{kind:`workflow`,id:t},o),d=Wi(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=Wi(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)(Ws,{delivery:m.delivery}),m&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:ar(m)})]}),m?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:m.mergedCommit})]}),m&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),m&&(m.revision??0)>0&&(0,h.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,m.revision]}),m&&((g?.stepsBefore??0)>0||c!==void 0)&&(0,h.jsxs)(`nav`,{className:`workflow-actions`,children:[(g?.stepsBefore??0)>0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(g?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),g?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[a(e.kind),` · `,po(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(Da,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:po(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),Vs(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 Ws({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 Gs=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Ks(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function qs({client:e,id:t,workspaceId:n,initialCwd:r,onLocation:i,enabled:a,actionsReady:o=a,prepareForSend:s,legacyWorkspaceId:c,directoryNamespaces:l=[],available:u=a,canInterrupt:d=a,modelEnabled:p=a,onModelChanged:m,onChanged:g,reference:_,onReferenceUsed:v,hidden:y=!1,onOpenAgent:x,onWorkflowRuns:S}){let{t:C,tx:w}=T(),[E]=(0,f.useState)(()=>Oo(n,t,c,...l)),[D,O]=(0,f.useState)(()=>Ks(E)),k=es(),ee=k.remove,A=(0,f.useRef)([]),j=(0,f.useRef)(null),[M,N]=(0,f.useState)(()=>Ks(`${E}:mode`)===`cadence`?`cadence`:`chat`),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(``),[R,z]=(0,f.useState)(()=>Ks(`${E}:pending`)),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!1),[ne,re]=(0,f.useState)(!1),[W,ie]=(0,f.useState)(0),ae=(0,f.useRef)(null),G=(0,f.useRef)(!1),oe=(0,f.useRef)(0),se=(0,f.useRef)(new AbortController),[ce,le]=(0,f.useState)(!1),ue=Wi(e,u&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),K=ue.value?.kind===`conversation-context`?ue.value.context:void 0,de=!!K&&!ue.error,fe=K?.cwd??r,pe=(0,f.useRef)(null),me=(0,f.useMemo)(()=>({models:n=>fe?e.models(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)}),chooseModel:n=>fe?e.chooseModel(n,{id:t,cwd:fe}):Promise.resolve({kind:`error`,error:te(`unavailable`)})}),[e,t,fe]),he=(0,f.useRef)(i);he.current=i,(0,f.useEffect)(()=>{de&&fe&&he.current?.({id:t,cwd:fe})},[de,t,fe]);let q=Bo(e,t,u),{turns:ge}=q,_e=q.summary!==void 0,ve=Wi(e,u?{kind:`cadence-conversation`,id:t}:null,1e3),J=ve.value?.kind===`cadence-conversation`?ve.value.state:void 0,ye=J?.enabled===!0,be=!!J||!!ve.error,xe=!!J&&!ve.error&&!J.notice,Se=(0,f.useRef)(J);Se.current=J;let[Ce,we]=(0,f.useState)(``),Te=(0,f.useRef)(``),Y=Gi(D,ye?`cadence`:M),Ee=a&&de&&_e&&!q.error&&be&&!(ye&&(ve.error||J?.notice))&&!P&&!H&&!R,De=q.summary??void 0,X=De&&(De.status===`queued`||De.status===`running`),Oe=!!De&&De.status!==`completed`&&!X,[ke,Ae]=(0,f.useState)(!1),je=!!s&&a&&(!!q.error||!!ue.error)&&q.error!==`retired-conversation`&&ue.error!==`retired-conversation`&&!J?.notice&&!X&&!P&&!R&&!H,Me=(d||!!s)&&de&&_e&&xe&&!q.error&&!P&&!R&&!X,Ne=!!J?.proposal&&!!De&&!X&&De.status!==`unknown`,Pe=J?.proposal&&De?.status===`unknown`?C(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,Fe=(0,f.useRef)(null),Ie=(0,f.useRef)(null),Le=(0,f.useRef)(0),Re=(0,f.useRef)(!0),[ze,Be]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!y&&Ie.current&&!Re.current&&(Ie.current.scrollTop=Le.current)},[y]);let Ve=(0,f.useRef)(!0),He=(0,f.useRef)(``),Ue=(0,f.useRef)(D);(0,f.useEffect)(()=>(Ve.current=!0,se.current.signal.aborted&&(se.current=new AbortController),()=>{Ve.current=!1,se.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${E}:mode`,M)}catch{}},[E,M]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(E,D)}catch{}},[D,E]),(0,f.useEffect)(()=>{try{R?sessionStorage.setItem(`${E}:pending`,R):sessionStorage.removeItem(`${E}:pending`)}catch{}},[E,R]),(0,f.useEffect)(()=>{_&&(O(e=>`${e}${e?`
22
+ `:``}@${_}`),v(),Fe.current?.focus())},[_,v]),(0,f.useEffect)(()=>{let e=De?`${De.leaf}:${De.status}`:``;e&&He.current!==e&&(He.current=e,g()),Te.current&&J?.runs.includes(Te.current)&&(Te.current=``,we(``),L(``)),R&&(De?.live?.commandId===R||q.attempt?.commandId===R||ge.some(e=>e.header.id===R)||q.commands.includes(R))&&(z(``),ee(A.current),O(e=>e===Ue.current?``:e),g()),Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[De,ge,R,g,J,q,ee]);let We=(0,f.useMemo)(()=>ge.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[ge]),Ge=io(Ie,We),Ke=(0,f.useRef)(new Map),qe=(0,f.useCallback)((e,t)=>{Ke.current.set(e,t)},[]),{earlier:Je,loadEarlier:Ye}=q,Xe=()=>{let e=Ie.current;e&&!y&&Je&&e.scrollTop<1200&&Ye()};(0,f.useEffect)(Xe);let Ze=ge[0]?.ordinal,Qe=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Ie.current;if(!e)return;let t=Qe.current;!Gs&&!Re.current&&t.ordinal!==void 0&&Ze!==void 0&&Ze<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),Qe.current={ordinal:Ze,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${E}:approval`)}catch{}},[E]);let $e=(0,f.useMemo)(()=>[...new Set([...q.runs,...J?.runs??[]])],[q.runs,J?.runs]),et=JSON.stringify($e.slice(-4));(0,f.useEffect)(()=>{S?.(JSON.parse(et))},[et,S]);let[tt,Z]=(0,f.useState)({terminal:8,browser:8}),nt=(0,f.useMemo)(()=>[...new Set([...q.runs.slice(-tt.terminal),...(J?.runs??[]).slice(-tt.browser)])],[q.runs,J?.runs,tt]),rt=go(e,u?nt:[],1e3),it=ge.find(e=>e.header.at>0)?.header.at,at=!Je&&ge.length>0;(0,f.useEffect)(()=>{if(!u)return;let e=(e,t)=>Ls(e,t,rt.runs,rt.unreadable,it,at),t=e(q.runs,tt.terminal),n=e(J?.runs??[],tt.browser);(t!==tt.terminal||n!==tt.browser)&&Z({terminal:t,browser:n})},[u,q.runs,J?.runs,tt,rt,it,at]);let ot=(0,f.useMemo)(()=>Is(ge,rt.runs.values(),Je),[ge,rt.runs,Je]),st=[...rt.runs.values()].filter(Ns).at(-1),ct=[...rt.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{ct&&Re.current&&Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight)},[ct]);let lt=t=>(0,h.jsx)(zs,{client:e,run:t,onOpen:()=>x?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{ve.refresh(),g()}},t.id),ut=async()=>{if(!J?.proposal){L(C(`No plan is awaiting approval.`));return}if(!o||!xe||!Ee||X||Ce||!Ne)return;let t=J,n=oe.current;F(!0),L(``);try{let r=await Ho({client:e,state:t,current:()=>Ve.current&&oe.current===n&&Se.current?.revision===t.revision&&Se.current?.enabled===!0,submitting:e=>{Te.current=e,we(e)}});if(!Ve.current||oe.current!==n)return;r.kind===`error`?(L(r.error.code),we(``)):O(e=>Wo(e)?``:e)}catch(e){Ve.current&&oe.current===n&&L(e instanceof Error?e.message:`unavailable`)}finally{Ve.current&&oe.current===n&&(F(!1),ve.refresh(),q.refresh(),g())}},dt=async(n,r)=>{let i=r?.text??n??D,a=r?.images??(n?[]:k.files),c=r?r.command.kind===`cadence-exit`:ye&&Uo(i);if(!(c?Me:Ee)&&!je||X||!i.trim()&&!a.length)return;if(c&&a.length){L(C(`Remove images before exiting Cadence.`));return}if(!a.length&&!r&&!n&&ye&&Wo(i)){o?await ut():L(C(`Execution is not ready to approve this plan. Send a message to refresh the conversation first; nothing was approved.`));return}let l=Gi(i,M).mode===`cadence`;if(!je&&(ye||l)&&!xe){L(C(`Cadence state unavailable. Observe the conversation before sending.`));return}if(G.current)return;G.current=!0,F(!0),L(``);let u=oe.current,d=()=>Ve.current&&oe.current===u,f=!1,p=`not-dispatched`,m=e=>{d()&&z(e)},h=async e=>{s&&(le(!0),await yo(s,se.current.signal,e,e=>{p=e}),d()&&(le(!1),ie(e=>e+1)))};try{if(je){if(await h(K?{id:t,cwd:K.cwd}:void 0),!d())return;q.refresh(),ue.refresh(),ve.refresh(),g(),L(C(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let n=r??Co({id:t,head:q.leaf,text:i,images:a,revision:J?.revision??0,location:K?{id:t,cwd:K.cwd}:void 0,model:pe.current??K?.model??void 0,intent:c?`exit`:ye?`message`:l?`enter`:`ordinary`});if(await h(n.location),!d())return;if(n.command.kind===`cadence-exit`){let t=Do(n);Ue.current=i,f=!0;let r=await So(e,t,m);if(!d())return;r.kind===`error`?L(C(xo(r.error.effect),{code:r.error.code})):(z(``),N(`chat`),O(e=>e===i?``:e)),ve.refresh(),q.refresh(),g();return}let o=()=>{ae.current=n,U(!0),V(!0)},s=await e.models(void 0,n.location);if(!d())return;let u=s.kind===`ok`?s.value.selected??s.value.remembered:null;!n.model&&u&&(n=To(n,u));let p=n.model??(s.kind===`ok`?s.value.remembered:null);if(s.kind===`ok`&&!s.value.selected&&p){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:s.value.version.epoch,...n.location?{location:n.location,expected:s.value.version,choice:p}:{}});if(!d())return;if(t.kind===`error`){L(t.error.code),o();return}if(s=await e.models(void 0,n.location),!d())return;ie(e=>e+1)}if(s.kind!==`ok`||!s.value.selected){o();return}Eo(n,s.value.selected);let _=Do(n,s.value.version);if(n.images.length){let t=s.value.selected;if(!s.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){L(C(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(_.kind===`cadence-exit`)throw Error(`invalid`);if(_=await Mo(e,_,n.images,d),!d())return}A.current=n.images,Ue.current=i,f=!0;let v=await So(e,_,m);if(!d())return;v.kind===`error`?L(C(xo(v.error.effect),{code:v.error.code})):(ee(A.current),O(e=>e===Ue.current?``:e),z(``),_.kind===`cadence-send`&&N(`chat`),mt(null)),ve.refresh(),q.refresh(),g()}catch(e){d()&&L(C(f?xo():bo(p),{code:e instanceof Error?e.message:`unavailable`}))}finally{oe.current===u&&(G.current=!1),d()&&(F(!1),le(!1))}},ft=(0,f.useRef)(dt);ft.current=dt,(0,f.useEffect)(()=>{if(ne&&Ee&&!X){re(!1);let e=ae.current;ae.current=null,e&&ft.current(void 0,e)}},[ne,Ee,X]),(0,f.useEffect)(()=>{if(!ne)return;let e=setTimeout(()=>{re(!1),ae.current=null},1e4);return()=>clearTimeout(e)},[ne]);let pt=async()=>{let n=De?.live;if(!n||P)return;F(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});Ve.current&&(r.kind===`error`&&L(r.error.code),F(!1),q.refresh())},mt=e=>{++oe.current,se.current.abort(),se.current=new AbortController,ae.current=null,G.current=!1,U(!1),re(!1),V(!1),F(!1),le(!1),q.choose(e),Ae(!1)},ht=P||H||!!R||!!X,gt=e=>{if(!ht)try{k.add(e),L(``)}catch(e){L(w(e instanceof Error?e.message:`unavailable`))}};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:y,"aria-label":C(ye?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:De?.title??C(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:C(ye?`Cadence on`:`Ordinary`)}),De&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:De.origin===`terminal`?C(`Started in the terminal`):C(`Started in the WebUI`)})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(q.branches>1||q.pinned)&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-expanded":ke,onClick:()=>Ae(e=>!e),children:[(0,h.jsx)(ii,{"aria-hidden":`true`}),C(`Branches ({count})`,{count:q.branches})]}),q.pinned&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>mt(null),children:C(`Show the latest`)}),st&&(0,h.jsx)(`span`,{className:`ep-state running`,children:w(Fs(st))}),De&&(!st||Oe||ye&&!X&&!!J?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${De.status}`,children:ye?X?C(`Discussing`):Oe?w(De.status):J?.proposal?C(`Awaiting plan approval`):C(`Ready for conversation`):w(De.status)})]})]}),ue.error&&!je&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(C,ue.error)}),je&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),ce&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:C(`Preparing execution for this Send…`)}),ke&&(0,h.jsx)($o,{client:e,id:t,leaf:q.leaf,onChoose:mt,onClose:()=>Ae(!1)}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Ie,onScroll:()=>{let e=Ie.current;e&&!y&&(Le.current=e.scrollTop,Re.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Be(!Re.current),Xe())},children:[q.summary===null&&(0,h.jsx)(js,{hint:C(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),u&&!q.error&&(!_e||ge.length===0&&q.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:C(`Reading this conversation…`)}),ge.length>0&&Je&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:q.loadingEarlier&&C(`Reading earlier messages…`)}),ot.start.map(lt),We.map(({id:e,version:t,turn:n})=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(ao,{id:e,show:!Ge.hidden.has(e),height:Ge.placeholder(e,t,320),containerRef:Ie,onMeasured:Ge.recordMeasured,lazyRef:Ge.register(e),children:(0,h.jsx)(As,{turn:n,toggled:Ke.current.get(e)??null,onToggle:qe})}),ot.after.get(e)?.map(lt),n.header.entry&&n.ordinal<q.count-1&&!X&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost turn-branch`,title:C(`Show the conversation up to here. The next message starts a new branch; nothing is deleted.`),onClick:()=>mt(n.header.entry),children:[(0,h.jsx)(di,{"aria-hidden":`true`}),C(`Continue from here`)]})]},e)),ot.end.map(lt),q.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":C(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:q.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${q.attempt.status}`,children:w(q.attempt.status)}),` `,q.attempt.notice?w(q.attempt.notice):``]})]}),J?.enabled&&J.proposal&&(0,h.jsx)(Bs,{proposal:J.proposal,canApprove:o&&Ee&&xe&&Ne&&!X&&!Ce,approvalHint:Pe,onApprove:()=>void ut()}),J?.enabled&&!J.proposal&&$e.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`Cadence stays on for this conversation until you explicitly exit.`)}),rt.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:C(`Workflow activity unavailable; retained work may still be running.`)}),J?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:w(J.notice)}),[...new Set([I,q.error,ve.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(C,e??``)},e)),q.error&&q.summary!==void 0&&(0,h.jsx)(`p`,{role:`status`,className:`inspector-note`,children:C(`Observation is not current. Retained history is shown; this does not mean work has stopped.`)}),R&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[C(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:R}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:q.refresh,children:C(`Observe current state`)})]}),q.pinned&&!X&&(0,h.jsx)(`p`,{className:`inspector-note`,children:C(`You are viewing an earlier point of this conversation. A message sent now starts a new branch here; the rest stays in the session.`)})]}),ze&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":C(`Latest messages`),onClick:()=>{Ie.current&&(Ie.current.scrollTop=Ie.current.scrollHeight),Re.current=!0},children:(0,h.jsx)(bi,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),gt(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),dt()},children:[(0,h.jsx)(`input`,{ref:j,type:`file`,accept:Mn.join(`,`),multiple:!0,hidden:!0,disabled:ht,"aria-label":C(`Add images`),onChange:e=>{gt(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),k.files.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:k.files.map(e=>(0,h.jsx)(ts,{file:e,disabled:ht,remove:()=>ee([e])},k.key(e)))}),(0,h.jsx)(`textarea`,{ref:Fe,disabled:!a&&!(ye&&d)||!je&&(!_e||!be||!!q.error)||P||!!R,"aria-label":C(`Message`),value:D,placeholder:C(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>O(e.target.value),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),gt(t))},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),dt())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:ht,"aria-label":C(`Add images`),title:C(`Add images`),onClick:()=>j.current?.click(),children:(0,h.jsx)(ti,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${ye||Y.mode===`cadence`?` on`:``}`,"aria-label":C(`Cadence mode`),"aria-pressed":ye||Y.mode===`cadence`,disabled:ye?!Me:X||P,title:ye?C(`Cadence mode is on. Click to exit it.`):Y.mode===`cadence`?C(`Your next message turns on Cadence mode. Click to cancel.`):C(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{ye?dt(`exit cadence`):Y.mode===`cadence`?(N(`chat`),Gi(D,`chat`).mode===`cadence`&&O(Y.text)):N(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(Zo,{client:me,onObserved:e=>{pe.current=e.selected?wo(e.selected):e.remembered},enabled:p&&u&&de,locked:!!X,refresh:String(W),open:B,onOpenChange:e=>{V(e),e||U(!1)},onChanged:()=>{ue.refresh(),m()},onChosen:e=>{H&&ae.current&&(ae.current=To(ae.current,e),U(!1),L(``),re(!0))},awaitingSend:H}),(0,h.jsx)(`span`,{className:`composer-hint`,children:ye?C(`Cadence stays on. Confirm one plan before implementation.`):Y.mode===`cadence`?C(`Your next message turns on Cadence mode.`):``}),X?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:P||!d,onClick:()=>void pt(),children:[(0,h.jsx)(Ur,{}),C(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(ye&&Uo(D)?Me:Ee)&&!je||!D.trim()&&!k.files.length,children:[(0,h.jsx)(vi,{}),C(`Send`)]})]})]})]})}function Js({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=Wi(e,t?{kind:`files`,path:a,...n?{location:n}:{}}:null),p=Wi(e,t&&s?{kind:`file`,path:s,...n?{location:n}:{}}:null),m=d.value?.kind===`files`?d.value:void 0,g=p.value?.kind===`file`?p.value:void 0;return(0,h.jsxs)(`div`,{className:`files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Parent folder`),disabled:m?.parent==null,onClick:()=>{m?.parent!=null&&o(m.parent)},children:(0,h.jsx)(vi,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:a,children:a||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Refresh files`),onClick:()=>{d.refresh(),p.refresh()},children:(0,h.jsx)(qr,{})})]}),d.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:d.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":i(`File list`),children:[m?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${s===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?o(e.path):c(e.path),children:[e.directory?(0,h.jsx)(ai,{}):(0,h.jsx)(oi,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Reference {path}`,{path:e.name}),onClick:()=>r(e.path),children:(0,h.jsx)(Jr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":i(`Copy path {path}`,{path:e.name}),onClick:()=>void ma(e.path).then(e=>u(e?``:i(`Link copy unavailable.`))),children:(0,h.jsx)(fi,{})})]},e.path)),m?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:i(`No visible files`)}),m?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Bounded listing; narrow the directory to see more.`)})]}),s&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:s,children:s}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":i(`Close preview`),onClick:()=>c(null),children:(0,h.jsx)(Vr,{})})]}),p.error&&(0,h.jsx)(`p`,{role:`alert`,children:p.error}),g&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:g.text}),g.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`File preview is limited; this is not the complete file.`)})]})]}),l&&(0,h.jsx)(`p`,{role:`alert`,children:l}),(0,h.jsx)(`p`,{className:`files-policy`,children:i(`Readonly preview · references send paths, not file contents`)})]})}var Ys=`未命名章节`;function Xs(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 Zs(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Xs(r||Ys),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Ys}})}function Qs(e){return e.length>=2}function $s(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 ec({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:$s(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=Zs(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)(xa,{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:[Qs(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)(Da,{text:e})})]}):n===`diff`?(0,h.jsx)(ec,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:$s(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 nc({client:e,seed:t}){let{t:n,tx:r}=T(),i=da(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ra,{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(la(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)(La,{client:e,cursor:a,render:e=>(0,h.jsx)(tc,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var rc=[`contents`,`checks`,`changes`,`reviews`];function ic(){let{t:e}=T();return(0,h.jsx)(`aside`,{className:`panel panel-right`,children:(0,h.jsx)(`p`,{className:`panel-empty`,children:e(`Select retained history to inspect`)})})}function ac({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:rc.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)(za,{client:e,seed:t}):(0,h.jsx)(nc,{client:e,seed:{...t,reader:i}},i)})]})}var oc={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.`},sc=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function cc(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 lc({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(n??t),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),te=(0,f.useRef)(n??t),j=(0,f.useRef)(null),M=(0,f.useRef)(null),N=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return p(r.value),g(r.value.path),v(!1),b(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},P=(0,f.useRef)(N);(0,f.useEffect)(()=>(ee.current=!0,P.current(te.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{_&&j.current?.select()},[_]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let F=e=>{E||N(e)},I=()=>{let e=m.trim();E||(sc(e)?N(e):k({step:`read`,code:`relative`}))},L=(_||!d)&&m.trim()||d?.path||``,R=!E&&!x&&!!L,z=async n=>{if(E||!n||x&&n===d?.path)return;if(n!==d?.path&&!sc(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===d?.path?d.path:(await N(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},B=d?cc(d.path,r):void 0,V=y.trim().toLowerCase(),H=d?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],U=O&&(O.step===`read`&&oc[O.code]?l(oc[O.code]):u(O.code));return(0,h.jsxs)(Ua,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Selecting a folder does not start execution. Send prepares it when needed.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:l(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void z(e.path),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[B&&!_?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&d?.path===r?`location`:void 0,disabled:E,onClick:()=>F(`~`),children:[(0,h.jsx)(ni,{"aria-hidden":`true`}),B.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),B.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||B.inside)&&(0,h.jsx)(hi,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===d?.path?`location`:void 0,disabled:E,onClick:()=>F(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),I()},children:(0,h.jsx)(`input`,{ref:j,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:m,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{g(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&d&&(e.preventDefault(),v(!1),g(d.path),k(null))}})}),d&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":_,disabled:E,onClick:()=>{g(d.path),v(!_),k(null)},children:(0,h.jsx)(ci,{"aria-hidden":`true`})})]}),d&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(Kr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:y,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>b(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),d?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(d.parent),children:[(0,h.jsx)(vi,{}),l(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>F(e.path),children:[(0,h.jsx)(ai,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),d&&!x&&H.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(V?`No matching folders.`:`No subfolders.`)})]}),d?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),U&&(0,h.jsxs)(`p`,{role:`alert`,children:[U,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[L&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:L})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!R,onClick:()=>void z(L),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function uc(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 dc({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Jr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function 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)(gi,{"aria-hidden":`true`}):(0,h.jsx)(hi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]})}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!i,children:t})]})}function pc({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=uc(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,h.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,h.jsx)(hi,{"aria-hidden":`true`}):(0,h.jsx)(gi,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(ui,{"aria-hidden":`true`}):(0,h.jsx)(Xr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function mc({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)(pc,{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)(Ra,{pager:e,compact:!0})]})}function hc({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,cancelCompatible:c,canceling:l,onCancel:u,onTask:d,onScope:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,workflows:S,workflowLinks:C=[],workflowError:w=!1,selectedWorkflow:E,onWorkflow:D,onCancelWorkflow:O}){let{t:k,tx:ee}=T(),A=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,te=da(e,A),j=da(e,r&&A&&t?{...A,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),M=te.page&&!(`kind`in te.page)?te.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],N=s?.status===`complete`?s.runs:[],P=M.filter(e=>!N.some(t=>t.taskId===e.owner.taskId)),F=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":k(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:k(`Task conversations`)}),(0,h.jsx)(mc,{pager:j,scope:i,onScope:p,exclude:N.map(e=>e.runId)},r)]}),[I,L]=(0,f.useState)(()=>new Set),R=e=>{let t=C.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${E===e.id||t&&t===y?` active`:``}`,onClick:()=>D?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[k(`Cadence workflow`),` · `,ee(e.phase),` · `,ee(e.status)]})]})]}),O&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:I.has(e.id),onClick:()=>{L(t=>new Set(t).add(e.id)),O(e).finally(()=>L(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ur,{"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)(Xr,{})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[e.origin===`terminal`?k(`Terminal`):`WebUI`,` ·`,` `,e.cadence?k(`Cadence on`):k(`Ordinary`),` ·`,` `,t?ee(Fs(t)):e.cadence&&[`running`,`queued`].includes(e.status)?k(`Discussing`):e.cadence&&e.status===`completed`?k(`Ready for conversation`):ee(e.status)]})]})]},e.id)};return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(dc,{onConversation:x}),!n&&(0,h.jsxs)(fc,{title:k(`Running conversations`),count:s?.status===`complete`&&S&&!w&&g?String(N.length+z.length+S.length):`?`,className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Active roster unavailable; absence is not proof of settlement.`)}),w&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`Conversation activity unavailable.`)}),z.map(H),S?.map(R),s?.status===`complete`&&N.length===0&&z.length===0&&S?.length===0&&!w&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No active runs`)}),N.map(e=>{let t=M.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??k(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[ee(e.kind),` · `,ee(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),k(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(pc,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(fc,{title:k(`Conversation history`),count:t?te.page&&!(`kind`in te.page)?`${B.length+P.length}${te.page.next||te.canPrevious||_?`+`:``}`:`?`:`${B.length}${_?`+`:``}`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":k(`Tasks`),className:`task-list`,children:[B.map(H),P.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Xr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:k(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&F]},e.owner.taskId)),te.page&&!(`kind`in te.page)&&P.length===0&&B.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:k(`No conversations yet.`)}),v,t&&(0,h.jsx)(Ra,{pager:te,compact:!0})]}),!P.some(e=>e.owner.taskId===r)&&F]})]})}var gc=[`queued`,`running`];function _c({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=Wi(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?gc.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!gc.includes(u.status)&&c(0)},[u]);let m=Wi(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?ys(g):null,[g]),[v,y]=(0,f.useState)(!1),b=Wi(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(ui,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(Hs,{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)(As,{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)(Da,{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();return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Open working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(gi,{"aria-hidden":`true`})]})}function yc(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Bi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(X(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function bc(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?X(ie(r)):void 0,o=i?U(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(ie(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function xc(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Sc({side:e,width:t,onResize:n}){let{t:r}=T(),i=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>i.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":r(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:r=>{r.preventDefault(),i.current?.();let a=r.clientX,o=window.innerWidth,s=r=>{let i=xc({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),i.current=void 0};i.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function Cc(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 wc=.4,Tc=1.05;function Ec(e){return Math.min(300,e*.86)}function Dc(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Oc(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function kc(e,t){return e===`left`?t:-t}function Ac(e,t){return Math.max(-e,Math.min(0,-e+t))}function jc(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Mc(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:jc(r*Tc,n,t)>=wc}var Nc=new Set([`auto`,`scroll`,`overlay`]);function Pc(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Nc.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Fc(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Ic(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=Dc(r.clientX,window.innerWidth,n);i&&!Pc(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=Oc(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Ec(window.innerWidth),h=m*Tc;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=kc(r,d);let b=Ac(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(jc(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Mc({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Fc(),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 Lc(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 Rc=`modulepreload`,zc=function(e){return`/`+e},Bc={},Vc=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=zc(t,n),t=s(t),t in Bc)return;Bc[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`:Rc,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 Hc({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=da(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)(Ra,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Uc,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Uc({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 Vc(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Lc(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)(za,{client:e,seed:t})]})}var Wc=[[`tools`,Hr],[`context`,ei],[`timeline`,pi],[`runs`,ii]];function Gc({error:e,observationError:t,projectObservationError:n,onDemand:r=!1}){let{t:i,tx:a}=T();return!e&&!t&&!n?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),n&&(0,h.jsxs)(h.Fragment,{children:[i(`Project observation: {code}.`,{code:a(n)}),` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[i(`{message}.`,{message:a(t)}),` `,t===`stale`?i(`Context changed. Observe again and request a fresh confirmation.`):r?i(`Connection unavailable. Existing work may continue; no message is replayed automatically.`):(0,h.jsx)(x,{text:i(`Explicit service guidance: {status} / {start}. No service is started by this page.`),slots:{status:(0,h.jsx)(`code`,{children:`cadence-service status`}),start:(0,h.jsx)(`code`,{children:`cadence-service start --workspace <path>`})}})]})]})}function Kc({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareSend:l,directoryNamespaces:u}){let{t:d,tx:p,locale:m,setLocale:g}=T(),[_]=(0,f.useState)(()=>e??Ri()),[v,y]=(0,f.useState)(!1),[b]=(0,f.useState)(bc),[S,C]=(0,f.useState)(b?.taskId??null),[w,E]=(0,f.useState)(()=>b?null:Vi()??crypto.randomUUID()),[D,O]=(0,f.useState)(null),[k,ee]=(0,f.useState)([]),[A,te]=(0,f.useState)(null),[j,M]=(0,f.useState)(b?`task`:`files`),[N,P]=(0,f.useState)(),[F,I]=(0,f.useState)(),[L,R]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=Vi();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[z]=(0,f.useState)(()=>crypto.randomUUID()),B=(0,f.useCallback)(()=>P(void 0),[]),[V,H]=(0,f.useState)(b?b.scope??{kind:`task`,id:b.taskId}:null),U=ta(s?.id,s?.epoch),ne=!s||U.readiness===`running`,re=!!s&&(U.readiness===`stopped`||U.readiness===`not-started`),ie=(0,f.useRef)(null);ne&&U.value?.epoch&&(ie.current=U.value.epoch);let ae=!s||!re&&(ne||ie.current!==null),G=ia(_,S?{kind:`task`,id:S}:null,!v&&ae,ie.current),oe=(0,f.useRef)(!0);(G.workspace||G.observation||G.error||G.transportStatus===`stale`||G.compatible===!1)&&(oe.current=!1);let se=!!(s&&(U.value||U.error)),ce=!v&&!!(G.workspace||se),le=(0,f.useRef)(null);(G.workspace||U.value?.workspaceId)&&(le.current=G.workspace?.workspaceId??U.value?.workspaceId??null);let ue=l?async(e,t,n)=>{let r=await l(e,t,n);if(e.aborted)throw Error(`stale`);U.prepared(r);let i=G.reconnect();await G.whenReady(r,e,i)}:void 0,K=Ki(_.client,ce),de=Wi(_.client,G.workspace&&!v?{kind:`conversation-active`}:null,1e3),fe=de.value?.kind===`conversation-active`?de.value.entries:[],pe=[...fe,...(K.value?.entries??[]).filter(e=>!fe.some(t=>t.id===e.id))],me=Wi(_.client,G.workspace&&!v?{kind:`workflow-active`}:null,2e3),he=me.value?.kind===`workflow-active`?me.value:void 0,q=(0,f.useMemo)(()=>[...new Set([...he?.runs.map(e=>e.id)??[],...k])],[he,k]),ge=Wi(_.client,!s&&G.workspace&&!v?{kind:`projects`}:null),_e=L??s?.cwd??(ge.value?.kind===`projects`?ge.value.entries.find(e=>e.current)?.path:void 0),ve=F?.id===w?F:void 0;(0,f.useEffect)(()=>{ve&&Vi()===ve.id&&history.replaceState({...history.state,cadenceCwd:ve.cwd,cadenceConversationId:ve.id},``,location.href)},[ve]);let J=w?ve:_e?{id:z,cwd:_e}:void 0,ye=ve?.cwd??_e??(ge.value?.kind===`projects`?ge.value.entries.find(e=>e.current)?.path:void 0)??G.workspace?.rootLabel,be={state:G.observation,transportStatus:G.transportStatus,error:G.error,refresh:G.refresh},xe=be.state?.snapshot.scope.kind===`task`&&be.state.snapshot.scope.id===S?be.state.snapshot.context:void 0,[Se,Ce]=(0,f.useState)(null),[we,Te]=(0,f.useState)(!1),Y=(0,f.useRef)(null),[Ee,De]=(0,f.useState)(260),[X,Oe]=(0,f.useState)(360),ke=(0,f.useCallback)(()=>Ce(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>Te(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Ic({enabled:we&&!v,open:Se,onOpenChange:Ce,container:Y}),Cc(Y,Se,we&&!v,ke);let[Ae,je]=(0,f.useState)(b?.snapshotSeq),[Me,Ne]=(0,f.useState)(``),[Pe,Fe]=(0,f.useState)(``),[Ie,Le]=(0,f.useState)(!0),Re=(0,f.useRef)(null),ze=(0,f.useRef)(null),Be=()=>{ze.current&&(ze.current.open=!1)},[Ve,He]=(0,f.useState)(`messages`),[Ue,We]=(0,f.useState)(!1),[Ge,Ke]=(0,f.useState)(!1),[qe,Je]=(0,f.useState)(),[Ye,Xe]=(0,f.useState)(b?.cursor),[Ze,Qe]=(0,f.useState)(``),[$e,et]=(0,f.useState)([]),[tt,Z]=(0,f.useState)(new Set),nt=(0,f.useRef)(!0),rt=e=>{nt.current&&et(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Ui(t,e):t)})},it=(0,f.useRef)(new aa),at=W({taskId:S,scope:V,selectedSnapshot:Ae??null,detached:v,attachment:G.attachmentVersion,workspaceContext:G.workspace?.context??null,observationError:G.error??null});it.current.select(at),(0,f.useEffect)(()=>(nt.current=!0,()=>{nt.current=!1,it.current.depart()}),[]);let ot=e=>{let t=e??crypto.randomUUID();e||R(ye??_e),O(null),t!==w&&(ee([]),P(void 0)),it.current.depart(),E(t),C(null),H(null),Ne(``),Fe(``),Je(void 0),Xe(void 0),je(void 0),He(`messages`),M(`files`),ke(),history.replaceState({cadenceCwd:ye??_e,cadenceConversationId:t},``,`${location.pathname}${location.search}#chat=${t}`)};(0,f.useEffect)(()=>{w&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${w}`)},[w]);let st=(e,t)=>{O(null),ee([]),E(null),M(`task`),Ne(t??``),Fe(``),je(void 0),it.current.depart(),C(e),H({kind:`task`,id:e}),Je(void 0),Xe(void 0),He(`messages`),ke(),history.replaceState(null,``,yc(e))};(0,f.useEffect)(()=>{let e=()=>{let e=bc();if(e)O(null),ee([]),E(null),M(`task`),it.current.depart(),je(e.snapshotSeq),Ne(``),Fe(``),C(e.taskId),H(e.scope??{kind:`task`,id:e.taskId}),Je(void 0),Xe(e.cursor),He(`messages`),ke();else{let e=Vi();if(e){let t=history.state?.cadenceCwd;typeof t==`string`&&R(t),P(void 0),O(null),ee([]),E(e),C(null),H(null),M(`files`),it.current.depart(),ke()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[ke]);let ct=(e,t,n)=>{O(null),je(t),Fe(n??``),it.current.depart(),H(e),Je(void 0),Xe(void 0),He(`messages`),ke(),S&&history.replaceState(null,``,yc(S,void 0,{scope:e,snapshotSeq:t}))},lt=Ae??be.state?.snapshot.committedSeq??G.workspace?.committedSeq,ut=G.workspace?.storeId,dt=V&&ut&&lt?{storeId:ut,scope:V,snapshotSeq:lt,reader:`messages`,after:null,limit:50}:null,ft=V&&ut&&lt?{storeId:ut,scope:V,snapshotSeq:lt,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,pt=xe?be.state?.snapshot.runs??[]:[],mt=it.current.ticket(),ht=e=>{rt(e),e.receipt&&it.current.current(mt)&&G.refresh()},gt=e=>{if(tt.has(e)||!G.cancelCompatible||!G.activeRuns)return;let t=crypto.randomUUID(),n=G.activeRuns.epoch;Z(t=>new Set(t).add(e)),rt({commandId:t,error:d(`Stop requested; settlement is not yet confirmed.`)}),_.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{ht(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:d(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>rt({commandId:t,error:d(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{nt.current&&Z(t=>{let n=new Set(t);return n.delete(e),n})})};if(v)return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:d(`Detached`)}),(0,h.jsx)(`p`,{children:d(`Accepted service work continues. No Cancel was requested.`)}),$e.map(e=>(0,h.jsxs)(`p`,{children:[d(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>y(!1),children:d(`Reconnect as a viewer`)})]});let _t=G.activeRuns,vt=_t?.status===`complete`?_t.runs:[],yt=!v&&!G.error&&G.transportStatus===`current`&&(!be.state||be.state.connection===`current`),bt=ne&&yt,xt=oe.current&&!be.state&&!be.error&&!U.error&&(!s||!U.value&&U.readiness===`unknown`||U.readiness===`running`),St=v?`Viewer disconnected`:xt?`Connecting…`:s&&U.readiness===`unknown`?`Project readiness unknown`:s&&U.readiness===`stale`?`Project observation stale`:re?`Ready to prepare on Send`:yt?G.workspace?be.state?.connection??(S?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`;return(0,h.jsxs)(`div`,{className:`app${Ie?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":d(`Tasks`),onClick:()=>Ce(e=>e===`left`?null:`left`),children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":d(`Workbench projects`),title:d(`Workbench projects`),onClick:n,children:(0,h.jsx)(ai,{})}),(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),V&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":d(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ve===`messages`&&!Ye,onClick:()=>{Xe(void 0),Je(void 0),He(`messages`)},children:[(0,h.jsx)(Xr,{"aria-hidden":`true`}),d(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Re,onKeyDown:e=>{e.key===`Escape`&&Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Ve===`messages`?d(`Details`):p(Ve),(0,h.jsx)(gi,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Wc.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Ve===e,onClick:()=>{Xe(void 0),Je(void 0),He(e),Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),p(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Export selected scope`),disabled:!dt,onClick:()=>{Re.current&&(Re.current.open=!1,Re.current.querySelector(`summary`)?.focus()),Ke(!0)},children:[(0,h.jsx)(li,{"aria-hidden":`true`}),d(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Copy token-free link`),disabled:!S,onClick:()=>{S&&ma(yc(S,Ye,V?{scope:V,snapshotSeq:Ae}:void 0)).then(e=>Qe(e?``:d(`Link copy unavailable.`)))},children:[(0,h.jsx)($r,{"aria-hidden":`true`}),d(`Copy token-free link`)]})]})]})]})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[(0,h.jsx)(Qa,{disabled:!ft,onOpen:()=>We(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:m===`zh`?`en`:`zh-CN`,"aria-label":m===`zh`?`Switch to English`:`切换到中文`,"data-tip":m===`zh`?`Switch to English`:`切换到中文`,onClick:()=>g(m===`zh`?`en`:`zh`),children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:m===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:ze,onKeyDown:e=>{e.key===`Escape`&&ze.current&&(ze.current.open=!1,ze.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":d(`More`),title:d(`More`),children:(0,h.jsx)(Yr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Observe current state`),onClick:()=>{Be(),G.refresh(),be.refresh()},children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),d(`Refresh status`)]}),o&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{Be(),o()},children:[(0,h.jsx)(Gr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Cadence service`),(0,h.jsx)(`small`,{children:d(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":d(`Disconnect this page`),title:d(`Return — accepted work continues`),onClick:()=>{Be(),Ce(null),We(!1),Ke(!1),it.current.depart(),y(!0)},children:[(0,h.jsx)(Qr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[d(`Disconnect this page`),(0,h.jsx)(`small`,{children:d(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${G.compatible===!1?` warn`:``}`,title:Li?.buildId??d(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:d(`Shared compatibility: {state}.`,{state:G.compatible===void 0?d(`Execution compatibility not observed`):G.compatible?d(`compatible`):d(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:d(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Li?.buildId??d(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":d(`Files / history`),"aria-expanded":we?Se===`right`:Ie,onClick:()=>we?Ce(e=>e===`right`?null:`right`):Le(e=>!e),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:d(w?`Files`:`History`)})]})]}),!G.workspace&&vt.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":d(`Execution and cancellation`),children:vt.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[p(e.kind),` `,e.runId,` · `,p(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>st(e.taskId),children:d(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!G.cancelCompatible||tt.has(e.runId),onClick:()=>gt(e.runId),children:[(0,h.jsx)(Ur,{"aria-hidden":`true`}),d(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(Gc,{onDemand:!!ue,error:Ze,projectObservationError:U.error,observationError:G.error}),!xt&&!re&&!bt&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`status`,children:d(`Observation is not current. Retained history is shown; this does not mean work has stopped.`)}),(0,h.jsxs)(`div`,{ref:Y,className:`layout`,style:{"--left-w":`${Ee}px`,"--right-w":`${X}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":d(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${Se?` on`:``}`,onClick:ke}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${Se===`left`?` open`:``}`,"aria-label":d(`Task navigation drawer`),tabIndex:-1,inert:we&&Se!==`left`,children:[ce&&(0,h.jsx)(hc,{client:_.client,workspace:G.workspace,executionStopped:re,taskId:S,scope:V,runs:pt,snapshot:be.state?.snapshot.committedSeq,activeRuns:G.activeRuns,cancelCompatible:!!G.cancelCompatible,canceling:tt,onCancel:gt,chats:pe,chatActivityKnown:de.value?.kind===`conversation-active`&&!de.error,chatHistoryPartial:K.loading||K.canPrevious||!!K.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[K.error&&(0,h.jsx)(`p`,{role:`alert`,children:K.error}),K.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:d(`Reading conversation history…`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.previous,children:d(`Newer conversations`)}),K.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:K.loading,onClick:K.next,children:d(`Older conversations`)}),K.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:K.first,children:d(`Latest conversations`)}),K.error&&(0,h.jsx)(`button`,{type:`button`,onClick:K.refresh,children:d(`Observe current state`)})]}),conversationId:w,onConversation:ot,onNewConversation:()=>ot(),workflows:he?.runs,workflowLinks:he?.links,workflowError:!!me.error,selectedWorkflow:D?.runId,onWorkflow:(e,t)=>{t?ot(t):(O({runId:e.id,stepId:null,label:e.goal}),ke())},onCancelWorkflow:async e=>{let t=await Vs(_.client,e);t&&Qe(t),me.refresh()},onTask:st,onScope:ct}),G.workspace&&(0,h.jsx)(_o,{client:_.client,active:G.activeRuns,taskId:S,runs:pt,snapshot:lt,workflowRuns:q,selected:D,onOpenWorkflow:e=>{O(e),ke()},onOpen:(e,t,n,r)=>{st(e),H({kind:`child`,id:t}),Fe(r),je(n),history.replaceState(null,``,yc(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Sc,{side:`left`,width:Ee,onResize:De}),(0,h.jsxs)(`main`,{className:`main`,inert:we&&Se!==null,children:[D&&(0,h.jsx)(_c,{client:_.client,agent:D,backLabel:d(w?`Back to conversation`:S?`Back to task`:`Back`),onBack:()=>O(null),onOpenAgent:O},`${D.runId}:${D.stepId??``}`),w&&(!s||se)&&(0,h.jsx)(qs,{client:_.client,id:w,initialCwd:_e,onLocation:I,hidden:!!D,onOpenAgent:O,onWorkflowRuns:ee,workspaceId:s?`checkout:${s.path}`:le.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?U.value?.workspaceId??void 0:void 0,prepareForSend:ue,actionsReady:ne&&!!G.workspace&&!!G.compatible&&!G.error&&yt,available:ce,canInterrupt:!!G.cancelCompatible,enabled:ue?ce:!!G.workspace&&!!G.compatible&&!G.error,modelEnabled:ne&&!!G.compatible&&G.transportStatus===`current`&&!G.error,onModelChanged:()=>{it.current.depart(),G.refresh(!0),U.refresh()},onChanged:()=>{K.refresh(),G.refresh()},reference:N,onReferenceUsed:B},`${s?.id??le.current??`connecting`}:${w}`),V&&!D&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[V.kind!==`task`&&S&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>st(S,Me),children:d(`Back to task`)}),(0,h.jsx)(`h2`,{title:Me||V.id,children:V.kind===`task`?Me||d(`Task {id}`,{id:V.id.slice(0,8)}):Pe||d(`{kind} {id}`,{kind:p(V.kind),id:V.id.slice(0,8)})}),V.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:d(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[d(`Recorded conversation`),` ·`,` `,d(`snapshot {seq}`,{seq:lt??``})]}),(0,h.jsx)(`code`,{children:V.id}),(0,h.jsx)(`p`,{children:d(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!w||!!D,children:[!dt&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:d(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:d(`History is readonly. Start new work in a conversation with /cadence.`)})]}),dt&&Ye?(0,h.jsxs)(`div`,{className:`tab-body`,children:[qe&&(qe.owner.entity.kind===`task`||qe.owner.entity.kind===`message`||qe.owner.entity.kind===`tool`)&&(0,h.jsx)(Ba,{client:_.client,seed:{storeId:Ye.storeId,scope:Ye.scope,snapshotSeq:Ye.snapshotSeq,kind:qe.owner.entity.kind,id:qe.owner.entity.id,version:qe.owner.entity.version}},`${qe.owner.entity.id}:${qe.owner.entity.version}`),(0,h.jsx)(La,{client:_.client,cursor:Ye,highlight:qe?.range},`${Ye.recordId}:${Ye.recordVersion}`)]}):dt&&(0,h.jsxs)(`div`,{className:Ve===`messages`||Ve===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ve===`messages`&&(0,h.jsx)(co,{client:_.client,seed:dt}),Ve===`tools`&&(0,h.jsx)(qc,{client:_.client,seed:dt}),Ve===`context`&&(0,h.jsx)(za,{client:_.client,seed:dt}),Ve===`timeline`&&(0,h.jsx)(Hc,{client:_.client,seed:dt,onSearch:()=>We(!0)}),Ve===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:d(`Runs in the current snapshot`)}),pt.length>0?pt.map(e=>(0,h.jsx)(Ja,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:xe&&be.state?d(`No owner run projection in this snapshot.`):d(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:d(`Retained runs`)}),(0,h.jsx)(Za,{client:_.client,seed:{...dt,scope:{kind:`task`,id:S??dt.scope.id}},onScope:ct},S)]})]},`${V?.kind}:${V?.id}:${Ae??`current`}`)]}),G.workspace&&$e.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:$e.map(e=>(0,h.jsx)(oa,{client:_.client,value:e,onChange:rt},e.commandId))})]}),(0,h.jsx)(Sc,{side:`right`,width:X,onResize:Oe}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${Se===`right`?` open`:``}`,"aria-label":d(`Files and history drawer`),tabIndex:-1,inert:we&&Se!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":d(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`files`,onClick:()=>M(`files`),children:[(0,h.jsx)(ai,{}),d(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":j===`task`,disabled:!dt,onClick:()=>M(`task`),children:[(0,h.jsx)(ei,{}),d(`History details`)]})]}),j===`files`?(0,h.jsx)(Js,{location:J,client:_.client,enabled:!!G.workspace&&!!J,onReference:e=>{w||ot(z);let t=!w&&J?`${J.cwd.replace(/[\\/]+$/,``)}${J.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;P(t),ke()}},J?.cwd??`owner`):dt?(0,h.jsx)(ac,{client:_.client,seed:{...dt,scope:{kind:`task`,id:S??dt.scope.id}}},S):(0,h.jsx)(ic,{})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsxs)(`div`,{className:`statusbar-left`,children:[(0,h.jsxs)(`span`,{className:`status-item`,role:`status`,title:d(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${xt?`busy`:re?``:!bt||!G.workspace?`error`:be.transportStatus===`current`?be.state?be.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),p(St),!xt&&!re&&be.transportStatus!==`current`&&d(` · transport {status}`,{status:p(be.transportStatus)}),be.error?` · ${p(be.error)}`:``]}),s&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Execution service: {status}`,{status:p(U.readiness)})}),_t?.status===`complete`?vt.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(bt?vt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:vt.length})}):!xt&&!re&&(0,h.jsx)(`span`,{className:`status-item faint`,children:d(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[(G.workspace||s)&&(0,h.jsx)(vc,{path:ye,onClick:()=>c?c(ye):te(``)}),G.compatible===!1&&(0,h.jsx)(`span`,{className:`status-item warn`,children:d(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),A!==null&&G.workspace&&(0,h.jsx)(lc,{onOpen:t,projects:i??(ge.value?.kind===`projects`?ge.value.entries:[]),client:_.client,current:ye??G.workspace.rootLabel,initial:A||void 0,home:r,epoch:G.workspace.epoch,onClose:()=>te(null)}),Ue&&ft&&(0,h.jsx)(qa,{client:_.client,seed:ft,onClose:()=>We(!1),onHit:e=>{Je(e),Xe(e.cursor),S&&history.replaceState(null,``,yc(S,e.cursor,V?{scope:V,snapshotSeq:Ae}:void 0))}}),Ge&&ft&&(0,h.jsx)(Wa,{request:{storeId:ft.storeId,scope:ft.scope,snapshotSeq:ft.snapshotSeq,format:`ndjson`},onClose:()=>Ke(!1)})]})}function qc({client:e,seed:t}){let n=da(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ra,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(uo,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Jc=`cadence-last-project`;function Yc(){try{let e=localStorage.getItem(Jc);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Xc(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Jc,e)}catch{}}function Zc(e){let t=Yc();return t?e.projects.find(e=>e.id===t):void 0}async function Qc(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=mn(await qi(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function $c(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await qi(t);if(!t.ok)throw Error(Ji(n));return yn(n)}async function el(e,t,n,r,i){if(!Li)throw Error(`unsupported-context`);let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Li})},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await qi(s);if(!s.ok||!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Ji(c));let l=pn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function tl(e){let t=await $c();return el(`/workbench/v1/select`,{path:e},t)}async function nl(e,t,n,r){let i=await $c(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 el(`/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}var rl=`cadence-recovery-dismissed`,il={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.`},al={"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 ol(){try{let e=JSON.parse(localStorage.getItem(rl)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function sl(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function cl({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(ol),[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(rl,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:sl(e.path)}):e.scope===`workbench`?n(`Workbench`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(il[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(al[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var ll={restart:18e4,upgrade:12e5},ul=1e3,dl={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},fl=e=>e instanceof Error?e.message:`unavailable`;function pl(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(dl[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function ml(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function hl(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 gl({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 Xi(e.signal).then(a,t=>{e.signal.aborted||s(fl(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>ll[e.action])return w(`timeout`);try{let t=await Xi(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,ul)};return r=setTimeout(i,ul),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Zi().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),Qi({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(fl(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`&&ml(C),o=i?.unit;return(0,h.jsxs)(Ua,{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:ll[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):pl(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)(Ua,{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 ee=i&&c&&typeof c==`object`?An(c.version,i.version)>0:!1;return(0,h.jsxs)(Ua,{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:hl(r,i.upgrade)}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This workbench was not started by Cadence's systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:pl(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…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Dn(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(yi,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(qr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function _l({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,onOpenService:o,children:s}){let{t:c,locale:l,setLocale:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!0),y=(0,f.useRef)(null),b=(0,f.useCallback)(()=>p(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>g(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Ic({enabled:m,open:d,onOpenChange:p,container:y}),Cc(y,d,m,b);let x=e=>{b(),i(e)},S=e=>{b(),a?a(e):i(e)},C=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${_?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":c(`Tasks`),onClick:()=>p(e=>e===`left`?null:`left`),children:(0,h.jsx)(Zr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":c(`Cadence service`),"data-tip":c(`Cadence service`),onClick:o,children:(0,h.jsx)(Gr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,onClick:()=>u(l===`zh`?`en`:`zh`),"aria-label":l===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(ri,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":c(`Files`),"aria-expanded":m?d===`right`:_,onClick:()=>m?p(e=>e===`right`?null:`right`):v(e=>!e),children:[(0,h.jsx)(Wr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{className:`layout`,ref:y,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":c(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${d?` on`:``}`,onClick:b}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${d===`left`?` open`:``}`,"aria-label":c(`Task navigation drawer`),tabIndex:-1,inert:m&&d!==`left`,children:(0,h.jsx)(`aside`,{className:`panel panel-left lp-panel`,children:(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:c(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?c(`Returning to your last project {name}…`,{name:C(n.path)}):n?.status===`unavailable`?c(`The retained conversations for {name} could not be observed. Choose a folder explicitly; nothing was started.`,{name:C(n.path)}):t.length?c(`Conversations stay with their folder. Select one to read its history; Send prepares execution.`):c(`Choose a working folder to see its conversation history.`)}),t.map(t=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item project-item`,title:t,disabled:!e||!!r,"aria-busy":r===t,onClick:()=>S(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(ai,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:C(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?c(`Selecting folder…`):t})]})]},t))]})]})})}),(0,h.jsx)(`main`,{className:`main`,inert:m&&d!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":c(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(js,{hint:c(`Choose a working folder. Execution is prepared only when you send.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>x(),children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),c(`Choose a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":c(`Message`),rows:3,placeholder:c(`Choose a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:c(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(vi,{"aria-hidden":`true`}),c(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${d===`right`?` open`:``}`,"aria-label":c(`Files`),tabIndex:-1,inert:m&&d!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(ai,{"aria-hidden":`true`}),c(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:c(`Files appear here after you open a working folder.`)})]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:(0,h.jsx)(`span`,{className:`status-item faint`,children:c(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(vc,{disabled:!e,onClick:()=>x()})})]})]})}function vl(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Bi),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(null),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(``),[m,g]=(0,f.useState)(0),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(null),x=(0,f.useRef)(new Map),S=(0,f.useRef)(!r),C=(0,f.useRef)(null),w=(0,f.useCallback)(()=>{C.current&&(C.current.abort(),C.current=null,b(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await qi(t);t.status===400&&Ji(r)===`invalid`?n(null):t.ok?(n(yn(r)),p(``)):p(Ji(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{w(),b(null),i(Bi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[w]),(0,f.useEffect)(()=>{if(!t||!S.current)return;S.current=!1;let e=Zc(t);if(!e)return;let n=new AbortController;C.current=n,b({status:`checking`,path:e.cwd}),Qc(e.id,n.signal).then(t=>{n.signal.aborted||(C.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),b(null),i(e.id)):b({status:`unavailable`,path:e.cwd}))})},[t]);let E=(0,f.useCallback)(e=>{w(),b(null),r&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===r)?.cwd&&x.current.set(r,window.location.hash),history.pushState({cadenceCwd:e?.cwd},``,e?`/app?project=${e.id}${x.current.get(e.id)??`#chat=${crypto.randomUUID()}`}`:`/app`),i(e?.id??null),o(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[r,w,t]),D=(0,f.useCallback)(async e=>{let t=await tl(e);n(t.entry),E(t.project)},[E]),O=async(e,i,a)=>{let o=t?.projects.find(e=>e.id===r);if(!o)throw Error(`unavailable`);let s=await nl(o,e,i,a);if(e.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},k=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new A(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await qi(n);if(!n.ok){let e=Ji(r);return{kind:`error`,error:te(ee.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Dr(r)}}catch{return{kind:`error`,error:te(`unavailable`)}}}}),[]),j=(0,f.useMemo)(()=>r?Ri(r):void 0,[r]),M=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{M&&Xc(M.id)},[M]),t===null)return(0,h.jsx)(Kc,{});let N=t&&_&&(0,h.jsx)(gl,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),P=()=>v(!0),F=t&&a!==null&&(0,h.jsx)(lc,{selectOnly:!0,client:k,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:D});return t&&M&&j?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Kc,{api:j,project:M,directoryNamespaces:t?.projects.filter(e=>e.path===M.path).map(e=>e.id).sort(),onPrepareSend:O,onChooseFolder:e=>o(e??M.cwd),onOpenProject:D,onWorkbenchHome:()=>E(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(cl,{notices:t.recoveries,project:M.path}),onOpenService:P},M.id),N,F]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(_l,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:y,opening:s,onOpenService:t?P:void 0,onOpenFolder:e=>{w(),u(``),o(e??t?.home??``)},onOpenProject:t=>{s||(w(),u(``),c(t),D(t).catch(n=>u(e(`{path} could not be opened ({code}).`,{path:t,code:n instanceof Error?n.message:`unavailable`}))).finally(()=>c(null)))},children:[l&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:l}),t&&(0,h.jsx)(cl,{notices:t.recoveries}),d&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[d,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>g(e=>e+1),children:e(`Reload observation`)})]}),r&&!M&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),F,N]})}function yl(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var bl=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(yl,{}):this.props.children}},xl=document.getElementById(`root`);if(!xl)throw Error(`Application root unavailable`);(0,p.createRoot)(xl).render((0,h.jsx)(E,{children:(0,h.jsx)(bl,{children:(0,h.jsx)(vl,{})})}));export{Vc as t};