@abelxiaoxing/cadence 2.0.27 → 2.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.de.md +2 -1
- package/README.es.md +2 -1
- package/README.fr.md +2 -1
- package/README.ja.md +3 -1
- package/README.ko.md +5 -1
- package/README.md +2 -1
- package/README.pt-BR.md +2 -1
- package/README.ru.md +2 -1
- package/README.zh-CN.md +2 -1
- package/docs/service-management.md +23 -1
- package/package.json +1 -1
- package/src/conversation-context.mjs +84 -19
- package/src/native-build.ts +1 -1
- package/src/sdk-worker.mjs +5 -4
- package/src/service/contracts/workbench.ts +89 -6
- package/src/service-cli.mjs +390 -64
- package/src/service-host.mjs +1632 -706
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +16 -16
- package/web/dist/manifest.json +7 -7
|
@@ -1,21 +1,21 @@
|
|
|
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={"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 开始新工作。`,"Scanning retained workflow IDs; no complete page yet.":`正在扫描保留的工作流 ID;尚未形成完整页面。`,"Continue reading history":`继续读取历史`,"Workflow history":`工作流历史`,"ID order; refresh to observe new runs. Unreadable records are not removed.":`按 ID 排序;刷新查看新运行。无法读取的记录不会被删除。`,"No retained workflows on this page.":`此页没有保留的工作流。`,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 状态。请先刷新观察会话再发送。`,"The last turn did not complete. A new message continues from the last complete checkpoint; incomplete work is not replayed.":`上一轮未完成。新消息会从最近一次完整的检查点继续;未完成的工作不会被重放。`,"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 工作流`,"Earlier workflow results":`较早的工作流结果`,"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":`工作流进度`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,"Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.":`暂时无法发送。请检查消息是否超过 16 KiB;如有待确认的命令,请先观察其结果,不要重复发送。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Earlier messages":`较早的消息`,"Latest messages":`最新消息`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,"Observe this send before sending again. No automatic retry.":`请先观察此次发送的结果,不会自动重试。`,"This turn has no complete continuation context. Start a new conversation; retained messages are preserved.":`此轮没有完整的续聊上下文。请新建对话,已记录的消息会保留。`,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.":`还没有对话。`,"Your last project {name} is not running. Click it below to open it again.":`上次的项目 {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})。`},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.`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),A=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],j=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function M(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 N(){throw new j}function P(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&N(),F(e)>t)throw new j(`oversize`);return e}function F(e){return new TextEncoder().encode(e).length}function I(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&N(),e}function L(e){return typeof e!=`boolean`&&N(),e}function R(e,t){return(typeof e!=`string`||!t.includes(e))&&N(),e}function z(e,t){return e!==t&&N(),t}function B(e,t){return e===null?null:t(e)}function V(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&N();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&N();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&N(),r[n]=t.value}return r}function H(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&N();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&N(),r.push(n(i.value))}return r}function U(e){let t=P(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)||N(),t}function W(e){let t=P(e,64);return/^[0-9a-f]{64}$/.test(t)||N(),t}function G(e){let t=P(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||N(),t}function ee(e,t){return G(e),G(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function te(e){let t=P(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||N(),t}function K(e,t=k.controlBytes){let n=t,r=e=>{if(n-=F(e),n<0)throw new j(`oversize`);return e};function i(e,n){if(n>64&&N(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return P(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||N(),r(JSON.stringify(e));if(Array.isArray(e)){let a=H(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&N();let a=t.sort(),o=V(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return N()}return i(e,0)}function ne(e,t=k.controlBytes){P(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 P(JSON.parse(e.slice(r,n)),t)}catch{return N()}i=!i&&a===`\\`}return N()}function a(t){if(t>64&&N(),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]!==`"`&&N(),d=i(),u.has(d)&&N(),u.add(d),r(),e[n++]!==`:`&&N());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&N()}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||N(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&N(),s}let o=a(0);return r(),n!==e.length&&N(),o}function re(e){let t=V(e,[`code`,`effect`,`recovery`]);return{code:R(t.code,A),effect:R(t.effect,[`none`,`accepted`,`uncertain`]),recovery:R(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ie=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],ae=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],oe=[`not-launched`,`direct-child-closed`,`unconfirmed`],q=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],se=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ce(e){let t=V(e,[`provider`,`model`,`api`,`thinking`]);return{provider:P(t.provider,128,!0),model:P(t.model,256,!0),api:R(t.api,q),thinking:R(t.thinking,se)}}function le(e){let{sourceSelectionId:t,...n}=V(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:U(t),...ce(n)}}function ue(e){let t=V(e,[`role`,`sha256`]);return{role:R(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:W(t.sha256)}}function de(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function fe(e){let t=V(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:U(t.recordId),version:I(t.version,1),field:R(t.field,ie),bytes:I(t.bytes,0,k.detailBytes),sha256:W(t.sha256)}}function pe(e){let t=V(e,[`start`,`end`]),n=I(t.start);return{start:n,end:I(t.end,n+1,k.detailBytes)}}function me(e){let t=V(e,[`source`,`range`,`requireCompleteObservation`]),n=J(t.source),r;if(n===`current`)r={kind:n,assignmentId:te(V(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=V(t.source,[`kind`,`runId`,`childRunId`,`result`]);z(n,`historical`);let i=fe(e.result);z(i.field,`final-text`),r={kind:`historical`,runId:U(e.runId),childRunId:U(e.childRunId),result:i}}let i=B(t.range,pe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&N(),{source:r,range:i,requireCompleteObservation:L(t.requireCompleteObservation)}}function J(e,t=`kind`){(typeof e!=`object`||!e)&&N();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&N(),P(n.value,64,!0)}function he(e){K(e,k.graphBytes);let t=V(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=fe(t.plan);z(n.field,`plan`);let r=I(t.planRevision,1);n.version!==r&&N();let i={schema:z(t.schema,D),taskId:U(t.taskId),taskKind:R(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:I(t.taskRevision,1),revision:I(t.revision,1),planRevision:r,plan:n,assignments:H(t.assignments,k.assignments,e=>{let t=V(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:te(t.id),purpose:R(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:P(t.instructions,k.instructionsBytes,!0),expectedOutput:P(t.expectedOutput,k.expectedOutputBytes,!0),role:ue(t.role),model:le(t.model),dependencies:H(t.dependencies,k.assignments,me)}})};i.assignments.length||N();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&N();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&N(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=K(n.source);if(t.has(e)&&N(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||N(),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!==de(e.purpose))throw new j(`forbidden`);c(e)}return i}function ge(e){let t=V(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=B(t.graphRevision,e=>I(e,1)),r=B(t.graphIdentity,W);return n===null!=(r===null)&&N(),{id:U(t.id),kind:R(t.kind,[`code`,`research`,`diagnosis`]),revision:I(t.revision,1),identity:W(t.identity),graphRevision:n,graphIdentity:r}}function Y(e){let t=V(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=V(t.observation,[`identity`,`complete`]);return{epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),configRev:I(t.configRev,1),controlRev:I(t.controlRev,1),workspaceId:U(t.workspaceId),cwdId:U(t.cwdId),model:le(t.model),checkEnvGeneration:I(t.checkEnvGeneration,1),checkoutGeneration:I(t.checkoutGeneration),observation:{identity:W(n.identity),complete:L(n.complete)},task:B(t.task,ge)}}function _e(e){let t=V(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:R(t.kind,[`configured`,`manual`]),name:P(t.name,128,!0),command:P(t.command,4096,!0),timeoutMs:I(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`)&&N(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&N(),n}function ve(e){switch(K(e),J(e)){case`create`:{let t=V(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:R(t.taskKind,[`code`,`research`,`diagnosis`]),goal:P(t.goal,8192,!0)}}case`save-plan`:{let t=V(e,[`kind`,`taskId`,`plan`,`graph`]),n=he(t.graph),r=U(t.taskId);return n.taskId!==r&&N(),{kind:`save-plan`,taskId:r,plan:P(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:J(e),taskId:U(V(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=V(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:U(t.taskId),check:_e(t.check)}}case`review`:{let t=V(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:U(t.taskId),runId:U(t.runId),changesIdentity:W(t.changesIdentity),checksRevision:I(t.checksRevision),acceptIssues:L(t.acceptIssues)}}default:return N()}}function ye(e){K(e);let t=V(e,[`expected`,`action`]);return{expected:Y(t.expected),action:ve(t.action)}}function be(e){K(e);let t=V(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:U(t.commandId),grant:U(t.grant),expected:Y(t.expected),action:ve(t.action)}}function xe(e){if(K(e),J(e)===`action`){let t=V(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:Y(t.expected),action:ve(t.action)}}let t=V(e,[`kind`,`epoch`,`runId`]);return z(t.kind,`cancel`),{kind:`cancel`,epoch:U(t.epoch),runId:U(t.runId)}}function Se(e){let t=V(e,[`commandId`,`epoch`,`runId`]);return{commandId:U(t.commandId),epoch:U(t.epoch),runId:U(t.runId)}}function Ce(e){K(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=V(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=H(n.configuredChecks,32,_e);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&N(),{...t?{checkEnvironmentPolicy:z(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:I(n.checksRevision),reviewRunId:B(n.reviewRunId,U),version:Y(n.version),action:ve(n.action),rootLabel:P(n.rootLabel,4096,!0),cwdLabel:P(n.cwdLabel,4096,!0),readablePlan:P(n.readablePlan,32768),graph:B(n.graph,he),activeRunId:B(n.activeRunId,U),issues:H(n.issues,7,e=>R(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function we(e){K(e);let t=V(e,[`grant`,`expiresAt`,`preview`]),n=P(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)&&N(),{grant:U(t.grant),expiresAt:n,preview:Ce(t.preview)}}function X(e){let t=V(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:R(t.observed,[`complete`,`incomplete`]),source:R(t.source,[`complete`,`limited`,`unavailable`]),redacted:L(t.redacted),omissions:H(t.omissions,6,e=>R(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&N(),n}function Te(e){let t=V(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:I(t.graphRevision,1),inputs:H(t.inputs,k.assignments,e=>{let t=V(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=fe(t.result);z(i.field,`final-text`);let a=B(t.range,pe);a&&a.end>i.bytes&&N();let o=P(t.text,k.predecessorBytes);if(n+=F(o),n>k.handoffBytes)throw new j(`oversize`);let s=I(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&N(),r.add(s),F(o)!==(a?a.end-a.start:i.bytes)&&N(),{assignmentId:te(t.assignmentId),dependencyIndex:s,runId:U(t.runId),childRunId:U(t.childRunId),result:i,range:a,text:o,coverage:X(t.coverage)}})}}function Ee(e){let t=V(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:R(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:R(t.closure,oe),exitCode:B(t.exitCode,e=>I(e,-2147483648,4294967295)),signal:B(t.signal,e=>P(e,32,!0)),durationMs:I(t.durationMs),stdin:R(t.stdin,[`delivered`,`failed`,`not-required`]),final:R(t.final,[`valid`,`missing`,`invalid`]),cleanup:R(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:X(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&N(),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`)&&N(),n}function De(e){let t=V(e,[`kind`,`id`]);return{kind:R(t.kind,[`task`,`run`,`child`]),id:U(t.id)}}function Oe(e){let t=P(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||N(),t}function ke(e){K(e);let t=V(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:U(t.storeId),scope:De(t.scope),query:B(t.query,e=>{let t=P(e,k.queryBytes);return t.length||N(),t}),snapshotSeq:G(t.snapshotSeq),recordId:B(t.recordId,U),recordVersion:B(t.recordVersion,e=>I(e,1)),field:B(t.field,e=>R(e,ie)),offset:I(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&N(),n}function Ae(e){let t=V(e,[`disposition`,`value`]),n=R(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&N(),{disposition:n,value:r}}function je(e){let t=V(e,[`messageId`,`blockId`]);return{messageId:U(t.messageId),blockId:U(t.blockId)}}function Me(e){let t=J(e);if(t===`message-final`)return{kind:t,messageId:U(V(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:R(V(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=V(e,[`kind`,`dependencyIndex`,`source`]),r=fe(n.source);return z(r.field,`final-text`),{kind:t,dependencyIndex:I(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=V(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:U(n.messageId),blockId:U(n.blockId),index:I(n.index,0,k.dataFrames),stage:R(n.stage,[`stream`,`final`])}}let n=V(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return z(t,`tool`),{kind:`tool`,callId:U(n.callId),blockId:U(n.blockId),index:I(n.index,0,k.dataFrames),stage:R(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=V(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=R(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=R(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&N(),{owner:n,field:r,encoding:i}}function Pe(e){let t=V(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=R(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=R(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=B(t.mimeType,e=>P(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)))&&N(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=P(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||N(),t}function Ie(e){let t=J(e);switch(t){case`ready`:{let n=V(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:z(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=V(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:P(e.sdkVersion,128,!0),workerHash:W(e.workerHash)}})()}}}case`message-start`:{let n=V(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=R(n.role,[`user`,`assistant`,`tool-result`]),i=B(n.resultCallId,U);return r!==`tool-result`&&i!==null&&N(),{kind:t,messageId:U(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=V(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:U(n.detailId)}}case`message-end`:{let n=V(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:U(n.messageId),finalDetailId:B(n.finalDetailId,U),finalBlockCount:I(n.finalBlockCount,0,k.dataFrames),stopReason:R(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=V(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:U(n.callId),declaration:je(n.declaration),index:I(n.index,0,k.dataFrames),source:Ae(n.source),name:P(n.name,128,!0),argsDetailId:B(n.argsDetailId,U),stage:R(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=V(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:U(n.callId),declaration:B(n.declaration,je),source:Ae(n.source),name:P(n.name,128,!0),argsDetailId:B(n.argsDetailId,U)}}case`tool-update`:{let n=V(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:U(n.callId),detailId:U(n.detailId),semantics:z(n.semantics,`snapshot`)}}case`tool-end`:{let n=V(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=R(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=B(n.declaration,je),a=L(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&N(),{kind:t,callId:U(n.callId),declaration:i,source:Ae(n.source),name:P(n.name,128,!0),resultDetailId:U(n.resultDetailId),isError:L(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(V(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=V(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:U(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=V(e,[`kind`,`detailId`,`offset`,`text`]),r=P(n.text,k.chunkBytes),i=I(n.offset,0,k.detailBytes);return i+F(r)>k.detailBytes&&N(),{kind:t,detailId:U(n.detailId),offset:i,text:r}}case`detail-end`:{let n=V(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:U(n.detailId),bytes:I(n.bytes,0,k.detailBytes),sha256:W(n.sha256),coverage:X(n.coverage)}}case`capture-status`:return{kind:t,coverage:X(V(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:R(V(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=V(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:U(n.messageId),detailId:U(n.detailId),stopReason:z(n.stopReason,`stop`)}}default:return N()}}function Le(e){let t=V(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:R(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:R(t.closure,oe),exitCode:B(t.exitCode,e=>I(e,-2147483648,4294967295)),signal:B(t.signal,e=>P(e,32,!0)),durationMs:I(t.durationMs),stdin:z(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&N(),n}function Re(e){let t=V(e,[`messageId`,`detailId`]);return{messageId:U(t.messageId),detailId:U(t.detailId)}}function ze(e){let t=V(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=G(t.committedSeq);return n===`0`&&N(),{childRunId:U(t.childRunId),detailId:U(t.detailId),content:fe(t.content),committedSeq:n}}function Be(e){let t=J(e,`status`);if(t===`committed`){let n=V(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&N(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=V(e,[`status`,`selected`,`error`]);return{status:t,selected:B(n.selected,Re),error:re(n.error)}}let n=V(e,[`status`,`selected`]);return{status:R(t,[`pending`,`uncertain`]),selected:B(n.selected,Re)}}function Ve(e,t){let n=B(e,G);return(n===`0`||n!==null&&t.status===`committed`&&ee(n,t.detail.committedSeq)<0)&&N(),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=J(e);if(t===`sdk`){let n=V(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=V(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=B(n.settlementSeq,G);return r===`0`&&N(),{kind:t,native:Le(n.native),capture:X(n.capture),settlementSeq:r}}let n=V(e,[`kind`,`outcome`,`required`]);z(t,`parent`);let r=H(n.required,k.assignments,e=>{let t=V(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=U(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&N(),{assignmentId:te(t.assignmentId),childRunId:n,native:B(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=R(n.outcome,ae);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&N(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=V(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=I(t.first,1,k.dataFrames+k.controlFrames),r=I(t.last,n,k.dataFrames+k.controlFrames),i=I(t.firstObservedMs),a=I(t.lastObservedMs,i);return n===r&&i!==a&&N(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=V(e,[`source`,`event`]),n=Ge(t.source),r=J(t.event);if(r===`stored-chunk`){let e=V(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:U(e.detailId),text:P(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=V(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:U(e.detailId),coverage:X(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&N(),{source:n,event:i}}function qe(e){let t=V(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:U(t.epoch),taskId:U(t.taskId),runId:U(t.runId),childRunId:U(t.childRunId)}}function Je(e){K({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=V(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:U(n.storeId),workspaceId:U(n.workspaceId),epoch:U(n.epoch)};if(!t)return z(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=H(n.runs,k.episodes,e=>{let t=V(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:U(t.taskId),runId:U(t.runId),operationId:U(t.operationId),epoch:U(t.epoch),kind:R(t.kind,[`start`,`generate-plan`,`check`]),stage:R(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&N(),{...r,status:`complete`,runs:i}}function Ye(e){let t=re(e);return z(t.effect,`none`),t}function Xe(e){let t=V(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:W(t.sourceHash),contractHash:W(t.contractHash),buildId:W(t.buildId)}}function Ze(e){let t=R(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=V(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:W(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=V(e,[`contractHash`,`assets`]);return{contractHash:W(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){K(e);let t=V(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:U(t.commandId),operationId:U(t.operationId),runId:B(t.runId,U),admission:R(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:G(t.committedSeq),execution:B(t.execution,e=>R(e,ae)),settlement:B(t.settlement,We),created:B(t.created,e=>{let t=V(e,[`kind`,`taskId`,`state`]);return{kind:z(t.kind,`task`),taskId:U(t.taskId),state:R(t.state,[`reserved`,`published`])}}),publication:R(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&N(),n}function tt(e){K(e);let t=V(e,[`identity`,`receipt`]),n=xe(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&N();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&N(),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`))&&N()}return{identity:n,receipt:r}}function Z(e,t){if(J(e)===`ok`)return{kind:`ok`,value:t(V(e,[`kind`,`value`]).value)};let n=V(e,[`kind`,`error`]);return z(n.kind,`error`),{kind:`error`,error:re(n.error)}}function nt(e){switch(K(e),J(e,`status`)){case`found`:return{status:`found`,receipt:et(V(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:G(V(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:re(V(e,[`status`,`error`]).error)};default:return N()}}function rt(e){let t=V(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:U(t.runId),taskId:U(t.taskId),childRunId:B(t.childRunId,U),assignmentId:B(t.assignmentId,te),admission:pt(t.admission),lifecycle:R(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:B(t.outcome,e=>R(e,ae)),settlement:B(t.settlement,We),reason:B(t.reason,e=>R(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:R(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:X(t.coverage),result:B(t.result,fe)};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`&&K(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==K(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&K(n.result)!==K(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`))&&N(),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){K(e,k.pageBytes);let t=V(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:z(t.protocol,1),storeId:U(t.storeId),epoch:U(t.epoch),scope:De(t.scope),committedSeq:G(t.committedSeq),context:mt(t.context),runs:H(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||K(n.horizon.historicalRuns.scope)!==K(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)&&N(),n}function st(e){K(e,k.pageBytes);let t=J(e),n=V(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:U(n.storeId),epoch:U(n.epoch),scope:De(n.scope),committedSeq:G(n.committedSeq)};if(t===`update`){let e=G(n.previousSeq);ee(r.committedSeq,e)<=0&&N();let i=mt(n.context);_t(i,r.epoch,r.scope)||N();let a=H(n.runs,k.maxPageEntries,rt),o=H(n.removed,k.maxPageEntries,U),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)))&&N(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return z(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||K(ct(e))!==K(ct(t)))&&N()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);K({kind:`ok`,value:e},k.pageBytes);let t=V(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){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:fe(t.content),range:B(t.range,pe),text:P(t.text,k.detailPageBytes),next:B(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!==F(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&N(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&N(),n.next&&(n.next.offset!==n.range?.end||K(ct({...n.next,offset:n.cursor.offset}))!==K(ct(n.cursor)))&&N(),n}function ft(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||N();let r=F(n.query),i=H(t.hits,k.maxPageEntries,e=>{let t=V(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=fe(t.content),a=bt(t.owner);xt(a,n.scope)||N();let o=pe(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||K(s.scope)!==K(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&N(),{content:i,owner:a,range:o,preview:P(t.preview,k.previewBytes),cursor:s}}),a=B(t.next,ke);return a&&(a.storeId!==n.storeId||K(a.scope)!==K(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)))&&N(),{cursor:n,hits:i,next:a,coverage:X(t.coverage)}}function pt(e){let t=V(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=Y(t.context),r=B(t.graph,e=>{let t=V(e,[`recordId`,`revision`,`sha256`]);return{recordId:U(t.recordId),revision:I(t.revision,1),sha256:W(t.sha256)}}),i=R(t.kind,[`start`,`generate-plan`,`check`]),a=H(t.assignments,k.assignments,e=>{let t=V(e,[`assignmentId`,`childRunId`]);return{assignmentId:te(t.assignmentId),childRunId:U(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&N(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&N(),{operationId:U(t.operationId),commandId:U(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(J(e,`status`)===`available`)return{status:`available`,version:Y(V(e,[`status`,`version`]).version)};let t=V(e,[`status`,`workspaceId`,`taskId`,`error`]);z(t.status,`unavailable`);let n=re(t.error);return z(n.effect,`none`),{status:`unavailable`,workspaceId:U(t.workspaceId),taskId:B(t.taskId,U),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=V(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=V(t.capabilities,[`actions`,`manualChecks`,`history`]),r=R(t.authority,[`browser`,`local`]),i=B(t.csrf,U),a={actions:L(n.actions),manualChecks:L(n.manualChecks),history:L(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&N(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:z(t.protocol,1),storeId:U(t.storeId),epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:U(t.workspaceId),storeId:U(t.storeId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),rootLabel:P(t.rootLabel,4096,!0),context:mt(t.context),models:H(t.models,k.maxPageEntries,le)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&N(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&N(),n}function bt(e){let t=V(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=V(t.entity,[`kind`,`id`,`version`]),r={taskId:U(t.taskId),runId:B(t.runId,U),childRunId:B(t.childRunId,U),entity:{kind:R(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:U(n.id),version:I(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&N(),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=V(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:W(t.identity),complete:L(t.complete),checkoutGeneration:I(t.checkoutGeneration)}}function Ct(e){K(e,k.controlBytes);let t=J(e);switch(t){case`assignment-state`:{let n=V(e,[`kind`,`childRunId`,`state`,`reason`]),r=R(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=B(n.reason,e=>R(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&N(),(r===`ready`||r===`preparing`)&&i!==null&&N(),{kind:t,childRunId:U(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:R(V(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=V(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:U(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=V(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&N(),{kind:t,runId:U(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=V(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:U(r.reservationId)}:{},lane:R(r.lane,[`reader`,`writer`,`check`]),state:R(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:I(r.checkoutGeneration)}}case`handoff`:{let n=V(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:U(n.childRunId),handoff:Te(n.handoff),observation:St(n.observation)}}case`changes`:{let n=V(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=fe(n.content);return z(r.field,`changes`),{kind:t,observationId:U(n.observationId),stage:R(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=V(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:U(n.checkId),selection:_e(n.selection),cwdId:U(n.cwdId),cwdLabel:P(n.cwdLabel,4096,!0),checkEnvGeneration:I(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=V(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=V(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:U(e.operationId),reservationId:U(e.reservationId),from:I(e.from),to:I(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&N()}let a=Le(r.native),o=R(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=B(r.output,fe),u=X(r.coverage);return l&&l.field!==`check`&&N(),o===`passed`&&(a.outcome!==`completed`||K({...s,checkoutGeneration:c.checkoutGeneration})!==K(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&N(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&N(),{kind:t,...i?{ownAdvance:i}:{},checkId:U(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=V(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=L(n.acceptIssues),i=R(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=fe(n.content);return z(a.field,`review`),i===`reviewed-with-issues`&&!r&&N(),{kind:t,reviewId:U(n.reviewId),runId:U(n.runId),checksRevision:I(n.checksRevision),changesIdentity:W(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=V(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=I(n.expectedRevision),i=B(n.expectedIdentity,W),a=I(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&N(),{kind:t,publicationId:U(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:W(n.nextIdentity)}}case`publication-settled`:{let n=V(e,[`kind`,`publicationId`,`status`,`observed`]),r=R(n.status,[`published`,`conflict`,`uncertain`]),i=B(n.observed,e=>{let t=V(e,[`revision`,`identity`]);return{revision:I(t.revision,1),identity:W(t.identity)}});return r===`published`&&i===null&&N(),{kind:t,publicationId:U(n.publicationId),status:r,observed:i}}default:return N()}}function wt(e){let t=V(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:U(t.epoch),operationId:U(t.operationId),taskId:U(t.taskId),runId:B(t.runId,U)}}function Tt(e){K(e,k.ownerQueueBytes);let t=V(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=H(t.events,k.ownerQueueFrames,e=>{let t=J(e);if(t===`fact`){let r=Ct(V(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&N(),{kind:t,fact:r}}if(t===`content-begin`){let r=V(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=R(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&N(),{kind:t,detailId:U(r.detailId),owner:i,field:a,encoding:z(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=V(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:U(n.detailId),text:P(n.text,k.chunkBytes)}}let r=V(e,[`kind`,`detailId`,`coverage`]);return z(t,`content-end`),{kind:`content-end`,detailId:U(r.detailId),coverage:X(r.coverage)}});return{observedMs:I(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=V(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=R(t.reader,Et),r=V(t.scope,[`kind`,`id`]),i={kind:R(r.kind,[`workspace`,`task`,`run`,`child`]),id:U(r.id)},a=B(t.snapshotSeq,G),o=B(t.after,e=>{let t=V(e,[`recordId`,`version`,`offset`]);return{recordId:U(t.recordId),version:I(t.version,1),offset:I(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&N(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:U(t.storeId),scope:i,snapshotSeq:a,after:o,limit:I(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=V(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&N(),{policy:z(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=J(e);if(t===`run`)return{kind:t,projection:rt(V(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=V(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=G(n.committedSeq);return r===`0`&&N(),{kind:t,recordId:U(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=V(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`&&N();let a=G(n.committedSeq);return a===`0`&&N(),{kind:t,recordId:U(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=V(e,[...n,...r]),a=bt(i.owner),o=I(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&N(),t===`task`){let e=B(i.plan,fe);return e&&e.field!==`plan`&&N(),{kind:t,owner:a,version:o,goal:P(i.goal,8192,!0),plan:e}}if(t===`message`){let e=R(i.role,[`user`,`assistant`,`tool-result`]),n=R(i.state,[`partial`,`final`]),r=B(i.finalBlockCount,e=>I(e,0,k.dataFrames)),s=B(i.finalText,fe),c=B(i.resultCallId,U);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&N(),{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=B(i.declaration,je),n=B(i.declarationStage,e=>R(e,[`partial`,`final`])),r=L(i.startObserved),s=B(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&N(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||K(s.declaration)!==K(e)))&&N(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:P(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=fe(i.content);return(e.field!==n.field||!At(e.owner,a))&&N(),{kind:t,owner:a,version:o,detailId:U(i.detailId),descriptor:e,content:n,coverage:X(i.coverage)}}z(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||N(),{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){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&N();let r=H(t.records,n.limit,kt),i=B(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||K(ct({...i,after:n.after}))!==K(ct(n))||K(i.after)===K(n.after)))&&N(),{request:n,records:r,next:i,coverage:X(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){K({kind:`ok`,value:e},k.pageBytes);let t=V(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||K(ct({...r,snapshotSeq:null}))!==K(ct(n)))&&N(),{kind:`snapshot`,request:n,next:r,coverage:X(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);K({kind:`ok`,value:e},k.pageBytes);let t=V(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 K({...t.request,snapshotSeq:e.snapshotSeq})===K(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=V(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=V(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:U(t.storeId),scope:De(t.scope),snapshotSeq:G(t.snapshotSeq),graph:{recordId:U(n.recordId),revision:I(n.revision,1),sha256:W(n.sha256)}}}function It(e){K({kind:`ok`,value:e});let t=V(e,[`request`,`graph`]),n=Ft(t.request),r=he(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&N(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);K({kind:`ok`,value:e},k.pageBytes);let t=V(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=V(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:U(t.storeId),scope:De(t.scope),snapshotSeq:G(t.snapshotSeq),format:R(t.format,[`ndjson`,`markdown`])}}function zt(e){K(e,k.controlBytes);let t=V(e,[`exportId`,`ordinal`,`event`]),n=J(t.event),r;switch(n){case`manifest`:{let e=V(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=V(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:W(i.exporterBuildSha256),capturePolicy:z(i.capturePolicy,`public-text-tools/2`)},schema:z(e.schema,O),request:Rt(e.request),coverage:X(e.coverage),serviceProtocol:z(e.serviceProtocol,1),workerProtocol:z(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(V(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(V(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=V(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=fe(e.content),a=B(e.range,pe),o=P(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==F(o):i.bytes!==0||o!==``)&&N(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:X(e.coverage)};break}case`markdown`:r={kind:n,text:P(V(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=V(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=X(e.coverage),a=L(e.complete);a&&i.observed!==`complete`&&N(),r={kind:n,complete:a,frames:I(e.frames,1),encodedBytes:I(e.encodedBytes),sha256:W(e.sha256),committedSeq:G(e.committedSeq),coverage:i};break}default:return N()}return{exportId:U(t.exportId),ordinal:I(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${K(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&N(),`\n\n\`\`\`json\n${K(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)&&N(),this.ordinal===0?(n.kind!==`manifest`||K(n.request)!==K(this.request))&&N():n.kind===`manifest`&&N(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&N(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&N(),this.request.format===`ndjson`&&n.kind===`markdown`&&N(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&N(),n.kind===`graph`&&(K(n.graph.request.scope)!==K(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&N(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&N(),this.bytes+=F(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=V(e,[`taskId`,`revision`,`definitions`]),n=H(t.definitions,32,e=>{let t=V(e,[`selection`,`status`,`checkId`]),n=_e(t.selection),r=R(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=B(t.checkId,U);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&N(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&N(),{taskId:U(t.taskId),revision:I(t.revision),definitions:n}}function Wt(e){let t=V(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:U(t.storeId),scope:De(t.scope),snapshotSeq:G(t.snapshotSeq),kind:R(t.kind,[`task`,`message`,`tool`]),id:U(t.id),version:I(t.version,1)}}function Gt(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(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))&&N(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);K({kind:`ok`,value:e},k.pageBytes);let t=V(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=re(e);return z(t.effect,`none`),t};function Jt(e){let t=V(e,[`storeId`,`taskId`]);return{storeId:U(t.storeId),taskId:B(t.taskId,U)}}function Yt(e){let t=Jt(e);return t.taskId===null&&N(),t}function Xt(e){let t=V(e,[`id`,`kind`,`revision`,`identity`]);return{id:U(t.id),kind:R(t.kind,[`code`,`research`,`diagnosis`]),revision:I(t.revision,1),identity:W(t.identity)}}function Zt(e){let t=H(e,3,ue);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&N(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return V(e,[`status`]),{status:t};if(t===`saved`){let n=V(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:I(n.planRevision,1)}}let n=V(e,[`status`,`error`]);return z(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)&&N(),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))&&N()}}function en(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:U(t.workspaceId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),context:mt(t.context),task:B(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:B(t.readablePlan,e=>{let t=V(e,[`source`,`text`,`editable`,`coverage`]),n=X(t.coverage),r=L(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&N(),{source:z(t.source,`current-v1`),text:P(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&N();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))&&N(),r.status===`unavailable`&&n.context.status===`available`&&N(),n}function tn(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=V(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:U(t.workspaceId),epoch:U(t.epoch),committedSeq:G(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:W(n.identity),complete:L(n.complete),checkoutGeneration:I(n.checkoutGeneration,0)},text:P(t.text,131072),git:L(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)&&N()}return r}function nn(e){let t=V(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`]);return{epoch:U(t.epoch),accessGeneration:I(t.accessGeneration,1),configRev:I(t.configRev,1),catalogId:U(t.catalogId)}}function rn(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`version`,`selected`]);return{version:nn(t.version),selected:B(t.selected,le)}}function an(e){K(e);let t=V(e,[`expected`,`choice`]);return{expected:nn(t.expected),choice:ce(t.choice)}}function on(e){let t=V(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:P(t.provider,128,!0),model:P(t.model,256,!0),api:B(t.api,e=>R(e,q)),thinking:H(t.thinking,7,e=>{let t=V(e,[`level`,`selectable`]);return{level:R(t.level,se),selectable:L(t.selectable)}}),eligibility:R(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&N(),n}function sn(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 cn(e){K({kind:`ok`,value:e},k.pageBytes);let t=V(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=H(t.entries,k.maxPageEntries,on),r=B(t.remembered,ce),i=R(t.status,[`complete`,`capacity`]),a=I(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>K([e.provider,e.model]))).size!==n.length||r&&!sn(n,r))&&N(),{version:nn(t.version),selected:B(t.selected,le),status:i,entries:n,withheld:a,remembered:r}}function ln(e){let t=V(e,[`id`,`path`,`cwd`,`epoch`]);return{id:W(t.id),path:P(t.path,4096,!0),cwd:P(t.cwd,4096,!0),epoch:U(t.epoch)}}var un=[`registry`,`workbench`,`project`],dn=[`reboot`,`crash`,`restart`,`storage`],fn=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function pn(e){let t=V(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:U(t.id),at:I(t.at,0),scope:R(t.scope,un),path:t.path===null?null:P(t.path,4096,!0),cause:R(t.cause,dn),actions:H(t.actions,fn.length,e=>R(e,fn)),workers:I(t.workers,0,1e6),archived:L(t.archived)}}function mn(e){let t=V(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:z(t.kind,`workbench`),epoch:U(t.epoch),csrf:U(t.csrf),home:P(t.home,4096,!0),projects:H(t.projects,128,ln),recoveries:H(t.recoveries,20,pn),build:Qe(t.build)}}var hn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function gn(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function _n(e,t=!1){let n=P(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 vn=(e,t=!1)=>{let n=P(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function yn(e){let t=V(e,[`name`,`command`,`timeoutMs`]);return{name:P(t.name,128,!0),command:P(t.command,4096,!0),timeoutMs:I(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 xn(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 Sn(e,t={}){let n=t.strict===!0;K(e,hn.bytes);let r=V(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=H(r.tasks,hn.tasks,e=>{let t=V(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:vn(t.id,n),title:P(t.title,256,!0),instructions:P(t.instructions,8192,!0),writes:H(t.writes,128,e=>_n(e,n)),after:H(t.after,hn.tasks,e=>vn(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`);bn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||xn(i,e.id).some(e=>e.id===t.id)||xn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>gn(t.writes,e))||t.writes.some(t=>gn(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=H(r.checks,hn.checks,yn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:P(r.goal,8192,!0),design:P(r.design,32768,!0),decisions:P(r.decisions,16384),acceptance:P(r.acceptance,16384,!0),projectContext:P(r.projectContext,16384),tasks:i,checks:a,setup:H(r.setup,4,yn),baselineChecks:H(r.baselineChecks,hn.checks,yn),repairAttempts:I(r.repairAttempts,0,hn.repairs),delivery:R(r.delivery,[`local-merge`,`working-copy`])};Cn(o),P(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
2
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function
|
|
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={"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Long messages and tool results continue on the next transcript page.":`长消息和工具结果会在下一页记录中继续。`,"Transcript page {page} of {pages}":`记录第 {page} 页,共 {pages} 页`,"Full transcript ({pages} pages)":`完整记录({pages} 页)`,"Turn transcript":`本轮完整记录`,"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 开始新工作。`,"Scanning retained workflow IDs; no complete page yet.":`正在扫描保留的工作流 ID;尚未形成完整页面。`,"Continue reading history":`继续读取历史`,"Workflow history":`工作流历史`,"ID order; refresh to observe new runs. Unreadable records are not removed.":`按 ID 排序;刷新查看新运行。无法读取的记录不会被删除。`,"No retained workflows on this page.":`此页没有保留的工作流。`,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 状态。请先刷新观察会话再发送。`,"The last turn did not complete. A new message continues from the last complete checkpoint; incomplete work is not replayed.":`上一轮未完成。新消息会从最近一次完整的检查点继续;未完成的工作不会被重放。`,"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 工作流`,"Earlier workflow results":`较早的工作流结果`,"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":`工作流进度`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Project {name}":`项目 {name}`,Workbench:`工作台`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,"Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.":`暂时无法发送。请检查消息是否超过 16 KiB;如有待确认的命令,请先观察其结果,不要重复发送。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Earlier messages":`较早的消息`,"Latest messages":`最新消息`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,"Observe this send before sending again. No automatic retry.":`请先观察此次发送的结果,不会自动重试。`,"This turn has no complete continuation context. Start a new conversation; retained messages are preserved.":`此轮没有完整的续聊上下文。请新建对话,已记录的消息会保留。`,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.":`还没有对话。`,"Your last project {name} is not running. Click it below to open it again.":`上次的项目 {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:`关闭`},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.`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-graph/2`,O=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),A=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],j=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function ee(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function M(){throw new j}function N(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&M(),P(e)>t)throw new j(`oversize`);return e}function P(e){return new TextEncoder().encode(e).length}function F(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&M(),e}function I(e){return typeof e!=`boolean`&&M(),e}function L(e,t){return(typeof e!=`string`||!t.includes(e))&&M(),e}function R(e,t){return e!==t&&M(),t}function z(e,t){return e===null?null:t(e)}function B(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&M();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&M();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&M(),r[n]=t.value}return r}function V(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&M();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&M(),r.push(n(i.value))}return r}function H(e){let t=N(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||M(),t}function U(e){let t=N(e,64);return/^[0-9a-f]{64}$/.test(t)||M(),t}function W(e){let t=N(e,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||M(),t}function te(e,t){return W(e),W(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ne(e){let t=N(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||M(),t}function G(e,t=k.controlBytes){let n=t,r=e=>{if(n-=P(e),n<0)throw new j(`oversize`);return e};function i(e,n){if(n>64&&M(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return N(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||M(),r(JSON.stringify(e));if(Array.isArray(e)){let a=V(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&M();let a=t.sort(),o=B(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return M()}return i(e,0)}function re(e,t=k.controlBytes){N(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return N(JSON.parse(e.slice(r,n)),t)}catch{return M()}i=!i&&a===`\\`}return M()}function a(t){if(t>64&&M(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&M(),d=i(),u.has(d)&&M(),u.add(d),r(),e[n++]!==`:`&&M());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&M()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||M(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&M(),s}let o=a(0);return r(),n!==e.length&&M(),o}function K(e){let t=B(e,[`code`,`effect`,`recovery`]);return{code:L(t.code,A),effect:L(t.effect,[`none`,`accepted`,`uncertain`]),recovery:L(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ie=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],ae=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],oe=[`not-launched`,`direct-child-closed`,`unconfirmed`],q=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],se=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ce(e){let t=B(e,[`provider`,`model`,`api`,`thinking`]);return{provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:L(t.api,q),thinking:L(t.thinking,se)}}function le(e){let{sourceSelectionId:t,...n}=B(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:H(t),...ce(n)}}function ue(e){let t=B(e,[`role`,`sha256`]);return{role:L(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:U(t.sha256)}}function de(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function fe(e){let t=B(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:H(t.recordId),version:F(t.version,1),field:L(t.field,ie),bytes:F(t.bytes,0,k.detailBytes),sha256:U(t.sha256)}}function J(e){let t=B(e,[`start`,`end`]),n=F(t.start);return{start:n,end:F(t.end,n+1,k.detailBytes)}}function pe(e){let t=B(e,[`source`,`range`,`requireCompleteObservation`]),n=Y(t.source),r;if(n===`current`)r={kind:n,assignmentId:ne(B(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=B(t.source,[`kind`,`runId`,`childRunId`,`result`]);R(n,`historical`);let i=fe(e.result);R(i.field,`final-text`),r={kind:`historical`,runId:H(e.runId),childRunId:H(e.childRunId),result:i}}let i=z(t.range,J);return r.kind===`historical`&&i&&i.end>r.result.bytes&&M(),{source:r,range:i,requireCompleteObservation:I(t.requireCompleteObservation)}}function Y(e,t=`kind`){(typeof e!=`object`||!e)&&M();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&M(),N(n.value,64,!0)}function me(e){G(e,k.graphBytes);let t=B(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=fe(t.plan);R(n.field,`plan`);let r=F(t.planRevision,1);n.version!==r&&M();let i={schema:R(t.schema,D),taskId:H(t.taskId),taskKind:L(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:F(t.taskRevision,1),revision:F(t.revision,1),planRevision:r,plan:n,assignments:V(t.assignments,k.assignments,e=>{let t=B(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ne(t.id),purpose:L(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:N(t.instructions,k.instructionsBytes,!0),expectedOutput:N(t.expectedOutput,k.expectedOutputBytes,!0),role:ue(t.role),model:le(t.model),dependencies:V(t.dependencies,k.assignments,pe)}})};i.assignments.length||M();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&M();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&M(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&M(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||M(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==de(e.purpose))throw new j(`forbidden`);c(e)}return i}function he(e){let t=B(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=z(t.graphRevision,e=>F(e,1)),r=z(t.graphIdentity,U);return n===null!=(r===null)&&M(),{id:H(t.id),kind:L(t.kind,[`code`,`research`,`diagnosis`]),revision:F(t.revision,1),identity:U(t.identity),graphRevision:n,graphIdentity:r}}function ge(e){let t=B(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=B(t.observation,[`identity`,`complete`]);return{epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),configRev:F(t.configRev,1),controlRev:F(t.controlRev,1),workspaceId:H(t.workspaceId),cwdId:H(t.cwdId),model:le(t.model),checkEnvGeneration:F(t.checkEnvGeneration,1),checkoutGeneration:F(t.checkoutGeneration),observation:{identity:U(n.identity),complete:I(n.complete)},task:z(t.task,he)}}function _e(e){let t=B(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:L(t.kind,[`configured`,`manual`]),name:N(t.name,128,!0),command:N(t.command,4096,!0),timeoutMs:F(t.timeoutMs,100,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&M(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&M(),n}function ve(e){switch(G(e),Y(e)){case`create`:{let t=B(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:L(t.taskKind,[`code`,`research`,`diagnosis`]),goal:N(t.goal,8192,!0)}}case`save-plan`:{let t=B(e,[`kind`,`taskId`,`plan`,`graph`]),n=me(t.graph),r=H(t.taskId);return n.taskId!==r&&M(),{kind:`save-plan`,taskId:r,plan:N(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:Y(e),taskId:H(B(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=B(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:H(t.taskId),check:_e(t.check)}}case`review`:{let t=B(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:H(t.taskId),runId:H(t.runId),changesIdentity:U(t.changesIdentity),checksRevision:F(t.checksRevision),acceptIssues:I(t.acceptIssues)}}default:return M()}}function ye(e){G(e);let t=B(e,[`expected`,`action`]);return{expected:ge(t.expected),action:ve(t.action)}}function be(e){G(e);let t=B(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:H(t.commandId),grant:H(t.grant),expected:ge(t.expected),action:ve(t.action)}}function xe(e){if(G(e),Y(e)===`action`){let t=B(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:ge(t.expected),action:ve(t.action)}}let t=B(e,[`kind`,`epoch`,`runId`]);return R(t.kind,`cancel`),{kind:`cancel`,epoch:H(t.epoch),runId:H(t.runId)}}function Se(e){let t=B(e,[`commandId`,`epoch`,`runId`]);return{commandId:H(t.commandId),epoch:H(t.epoch),runId:H(t.runId)}}function Ce(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=B(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=V(n.configuredChecks,32,_e);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&M(),{...t?{checkEnvironmentPolicy:R(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:F(n.checksRevision),reviewRunId:z(n.reviewRunId,H),version:ge(n.version),action:ve(n.action),rootLabel:N(n.rootLabel,4096,!0),cwdLabel:N(n.cwdLabel,4096,!0),readablePlan:N(n.readablePlan,32768),graph:z(n.graph,me),activeRunId:z(n.activeRunId,H),issues:V(n.issues,7,e=>L(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function we(e){G(e);let t=B(e,[`grant`,`expiresAt`,`preview`]),n=N(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&M(),{grant:H(t.grant),expiresAt:n,preview:Ce(t.preview)}}function X(e){let t=B(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:L(t.observed,[`complete`,`incomplete`]),source:L(t.source,[`complete`,`limited`,`unavailable`]),redacted:I(t.redacted),omissions:V(t.omissions,6,e=>L(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&M(),n}function Te(e){let t=B(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:F(t.graphRevision,1),inputs:V(t.inputs,k.assignments,e=>{let t=B(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=fe(t.result);R(i.field,`final-text`);let a=z(t.range,J);a&&a.end>i.bytes&&M();let o=N(t.text,k.predecessorBytes);if(n+=P(o),n>k.handoffBytes)throw new j(`oversize`);let s=F(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&M(),r.add(s),P(o)!==(a?a.end-a.start:i.bytes)&&M(),{assignmentId:ne(t.assignmentId),dependencyIndex:s,runId:H(t.runId),childRunId:H(t.childRunId),result:i,range:a,text:o,coverage:X(t.coverage)}})}}function Ee(e){let t=B(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:L(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:L(t.closure,oe),exitCode:z(t.exitCode,e=>F(e,-2147483648,4294967295)),signal:z(t.signal,e=>N(e,32,!0)),durationMs:F(t.durationMs),stdin:L(t.stdin,[`delivered`,`failed`,`not-required`]),final:L(t.final,[`valid`,`missing`,`invalid`]),cleanup:L(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:X(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&M(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&M(),n}function De(e){let t=B(e,[`kind`,`id`]);return{kind:L(t.kind,[`task`,`run`,`child`]),id:H(t.id)}}function Oe(e){let t=N(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||M(),t}function ke(e){G(e);let t=B(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:H(t.storeId),scope:De(t.scope),query:z(t.query,e=>{let t=N(e,k.queryBytes);return t.length||M(),t}),snapshotSeq:W(t.snapshotSeq),recordId:z(t.recordId,H),recordVersion:z(t.recordVersion,e=>F(e,1)),field:z(t.field,e=>L(e,ie)),offset:F(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&M(),n}function Ae(e){let t=B(e,[`disposition`,`value`]),n=L(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&M(),{disposition:n,value:r}}function je(e){let t=B(e,[`messageId`,`blockId`]);return{messageId:H(t.messageId),blockId:H(t.blockId)}}function Me(e){let t=Y(e);if(t===`message-final`)return{kind:t,messageId:H(B(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:L(B(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=B(e,[`kind`,`dependencyIndex`,`source`]),r=fe(n.source);return R(r.field,`final-text`),{kind:t,dependencyIndex:F(n.dependencyIndex,0,k.assignments-1),source:r}}if(t===`message`){let n=B(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:H(n.messageId),blockId:H(n.blockId),index:F(n.index,0,k.dataFrames),stage:L(n.stage,[`stream`,`final`])}}let n=B(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return R(t,`tool`),{kind:`tool`,callId:H(n.callId),blockId:H(n.blockId),index:F(n.index,0,k.dataFrames),stage:L(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=B(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=L(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=L(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&M(),{owner:n,field:r,encoding:i}}function Pe(e){let t=B(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=L(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=L(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=z(t.mimeType,e=>N(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&M(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=N(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||M(),t}function Ie(e){let t=Y(e);switch(t){case`ready`:{let n=B(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:R(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=B(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:N(e.sdkVersion,128,!0),workerHash:U(e.workerHash)}})()}}}case`message-start`:{let n=B(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=L(n.role,[`user`,`assistant`,`tool-result`]),i=z(n.resultCallId,H);return r!==`tool-result`&&i!==null&&M(),{kind:t,messageId:H(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=B(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:H(n.detailId)}}case`message-end`:{let n=B(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:H(n.messageId),finalDetailId:z(n.finalDetailId,H),finalBlockCount:F(n.finalBlockCount,0,k.dataFrames),stopReason:L(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=B(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:H(n.callId),declaration:je(n.declaration),index:F(n.index,0,k.dataFrames),source:Ae(n.source),name:N(n.name,128,!0),argsDetailId:z(n.argsDetailId,H),stage:L(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=B(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:H(n.callId),declaration:z(n.declaration,je),source:Ae(n.source),name:N(n.name,128,!0),argsDetailId:z(n.argsDetailId,H)}}case`tool-update`:{let n=B(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:H(n.callId),detailId:H(n.detailId),semantics:R(n.semantics,`snapshot`)}}case`tool-end`:{let n=B(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=L(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=z(n.declaration,je),a=I(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&M(),{kind:t,callId:H(n.callId),declaration:i,source:Ae(n.source),name:N(n.name,128,!0),resultDetailId:H(n.resultDetailId),isError:I(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(B(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=B(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:H(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=B(e,[`kind`,`detailId`,`offset`,`text`]),r=N(n.text,k.chunkBytes),i=F(n.offset,0,k.detailBytes);return i+P(r)>k.detailBytes&&M(),{kind:t,detailId:H(n.detailId),offset:i,text:r}}case`detail-end`:{let n=B(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:H(n.detailId),bytes:F(n.bytes,0,k.detailBytes),sha256:U(n.sha256),coverage:X(n.coverage)}}case`capture-status`:return{kind:t,coverage:X(B(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:L(B(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=B(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:H(n.messageId),detailId:H(n.detailId),stopReason:R(n.stopReason,`stop`)}}default:return M()}}function Le(e){let t=B(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:L(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:L(t.closure,oe),exitCode:z(t.exitCode,e=>F(e,-2147483648,4294967295)),signal:z(t.signal,e=>N(e,32,!0)),durationMs:F(t.durationMs),stdin:R(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&M(),n}function Re(e){let t=B(e,[`messageId`,`detailId`]);return{messageId:H(t.messageId),detailId:H(t.detailId)}}function ze(e){let t=B(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=W(t.committedSeq);return n===`0`&&M(),{childRunId:H(t.childRunId),detailId:H(t.detailId),content:fe(t.content),committedSeq:n}}function Be(e){let t=Y(e,`status`);if(t===`committed`){let n=B(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&M(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=B(e,[`status`,`selected`,`error`]);return{status:t,selected:z(n.selected,Re),error:K(n.error)}}let n=B(e,[`status`,`selected`]);return{status:L(t,[`pending`,`uncertain`]),selected:z(n.selected,Re)}}function Ve(e,t){let n=z(e,W);return(n===`0`||n!==null&&t.status===`committed`&&te(n,t.detail.committedSeq)<0)&&M(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=Y(e);if(t===`sdk`){let n=B(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:Ee(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=B(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=z(n.settlementSeq,W);return r===`0`&&M(),{kind:t,native:Le(n.native),capture:X(n.capture),settlementSeq:r}}let n=B(e,[`kind`,`outcome`,`required`]);R(t,`parent`);let r=V(n.required,k.assignments,e=>{let t=B(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=H(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&M(),{assignmentId:ne(t.assignmentId),childRunId:n,native:z(t.native,Ee),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=L(n.outcome,ae);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&M(),{kind:`parent`,outcome:i,required:r}}function Ge(e){let t=B(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=F(t.first,1,k.dataFrames+k.controlFrames),r=F(t.last,n,k.dataFrames+k.controlFrames),i=F(t.firstObservedMs),a=F(t.lastObservedMs,i);return n===r&&i!==a&&M(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ke(e){let t=B(e,[`source`,`event`]),n=Ge(t.source),r=Y(t.event);if(r===`stored-chunk`){let e=B(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:H(e.detailId),text:N(e.text,k.chunkBytes)}}}if(r===`stored-end`){let e=B(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:H(e.detailId),coverage:X(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&M(),{source:n,event:i}}function qe(e){let t=B(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:H(t.epoch),taskId:H(t.taskId),runId:H(t.runId),childRunId:H(t.childRunId)}}function Je(e){G({kind:`ok`,value:e},k.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=B(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:H(n.storeId),workspaceId:H(n.workspaceId),epoch:H(n.epoch)};if(!t)return R(n.status,`unavailable`),{...r,status:`unavailable`,error:Ye(n.error)};let i=V(n.runs,k.episodes,e=>{let t=B(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:H(t.taskId),runId:H(t.runId),operationId:H(t.operationId),epoch:H(t.epoch),kind:L(t.kind,[`start`,`generate-plan`,`check`]),stage:L(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&M(),{...r,status:`complete`,runs:i}}function Ye(e){let t=K(e);return R(t.effect,`none`),t}function Xe(e){let t=B(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:U(t.sourceHash),contractHash:U(t.contractHash),buildId:U(t.buildId)}}function Ze(e){let t=L(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=B(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:U(n.contractHash)}:{kind:t,...Xe({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Qe(e){let t=B(e,[`contractHash`,`assets`]);return{contractHash:U(t.contractHash),assets:Xe(t.assets)}}function $e(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function et(e){G(e);let t=B(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:H(t.commandId),operationId:H(t.operationId),runId:z(t.runId,H),admission:L(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:W(t.committedSeq),execution:z(t.execution,e=>L(e,ae)),settlement:z(t.settlement,We),created:z(t.created,e=>{let t=B(e,[`kind`,`taskId`,`state`]);return{kind:R(t.kind,`task`),taskId:H(t.taskId),state:L(t.state,[`reserved`,`published`])}}),publication:L(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&M(),n}function tt(e){G(e);let t=B(e,[`identity`,`receipt`]),n=xe(t.identity),r=et(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&M();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&M(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&M()}return{identity:n,receipt:r}}function Z(e,t){if(Y(e)===`ok`)return{kind:`ok`,value:t(B(e,[`kind`,`value`]).value)};let n=B(e,[`kind`,`error`]);return R(n.kind,`error`),{kind:`error`,error:K(n.error)}}function nt(e){switch(G(e),Y(e,`status`)){case`found`:return{status:`found`,receipt:et(B(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:W(B(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:K(B(e,[`status`,`error`]).error)};default:return M()}}function rt(e){let t=B(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:H(t.runId),taskId:H(t.taskId),childRunId:z(t.childRunId,H),assignmentId:z(t.assignmentId,ne),admission:pt(t.admission),lifecycle:L(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:z(t.outcome,e=>L(e,ae)),settlement:z(t.settlement,We),reason:z(t.reason,e=>L(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:L(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:X(t.coverage),result:z(t.result,fe)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&G(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==G(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&G(n.result)!==G(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&M(),n}function it(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function at(e,t,n){return it(e,t)&&e.taskId===gt(n)&&e.admission.context.workspaceId===ht(n)}function ot(e){G(e,k.pageBytes);let t=B(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:R(t.protocol,1),storeId:H(t.storeId),epoch:H(t.epoch),scope:De(t.scope),committedSeq:W(t.committedSeq),context:mt(t.context),runs:V(t.runs,k.maxPageEntries,rt),horizon:Ot(t.horizon)};return(!_t(n.context,n.epoch,n.scope)||G(n.horizon.historicalRuns.scope)!==G(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!at(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&M(),n}function st(e){G(e,k.pageBytes);let t=Y(e),n=B(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:H(n.storeId),epoch:H(n.epoch),scope:De(n.scope),committedSeq:W(n.committedSeq)};if(t===`update`){let e=W(n.previousSeq);te(r.committedSeq,e)<=0&&M();let i=mt(n.context);_t(i,r.epoch,r.scope)||M();let a=V(n.runs,k.maxPageEntries,rt),o=V(n.removed,k.maxPageEntries,H),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!at(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&M(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return R(t,`heartbeat`),{kind:`heartbeat`,...r}}function ct(e){let{navigation:t,...n}=e;return n}function lt(e,t){(!t.navigation||t.navigation===e.navigation||G(ct(e))!==G(ct(t)))&&M()}function ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return dt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return lt(n,r),{kind:`progress`,cursor:n,next:r,coverage:X(t.coverage)}}function dt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:fe(t.content),range:z(t.range,J),text:N(t.text,k.detailPageBytes),next:z(t.next,ke),coverage:X(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==P(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&M(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&M(),n.next&&(n.next.offset!==n.range?.end||G(ct({...n.next,offset:n.cursor.offset}))!==G(ct(n.cursor)))&&M(),n}function ft(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||M();let r=P(n.query),i=V(t.hits,k.maxPageEntries,e=>{let t=B(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=fe(t.content),a=bt(t.owner);xt(a,n.scope)||M();let o=J(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||G(s.scope)!==G(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&M(),{content:i,owner:a,range:o,preview:N(t.preview,k.previewBytes),cursor:s}}),a=z(t.next,ke);return a&&(a.storeId!==n.storeId||G(a.scope)!==G(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&M(),{cursor:n,hits:i,next:a,coverage:X(t.coverage)}}function pt(e){let t=B(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=ge(t.context),r=z(t.graph,e=>{let t=B(e,[`recordId`,`revision`,`sha256`]);return{recordId:H(t.recordId),revision:F(t.revision,1),sha256:U(t.sha256)}}),i=L(t.kind,[`start`,`generate-plan`,`check`]),a=V(t.assignments,k.assignments,e=>{let t=B(e,[`assignmentId`,`childRunId`]);return{assignmentId:ne(t.assignmentId),childRunId:H(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&M(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&M(),{operationId:H(t.operationId),commandId:H(t.commandId),kind:i,context:n,assignments:a,graph:r}}function mt(e){if(Y(e,`status`)===`available`)return{status:`available`,version:ge(B(e,[`status`,`version`]).version)};let t=B(e,[`status`,`workspaceId`,`taskId`,`error`]);R(t.status,`unavailable`);let n=K(t.error);return R(n.effect,`none`),{status:`unavailable`,workspaceId:H(t.workspaceId),taskId:z(t.taskId,H),error:n}}function ht(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function gt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function _t(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||gt(e)===n.id)}function vt(e){let t=B(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=B(t.capabilities,[`actions`,`manualChecks`,`history`]),r=L(t.authority,[`browser`,`local`]),i=z(t.csrf,H),a={actions:I(n.actions),manualChecks:I(n.manualChecks),history:I(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&M(),{...t.build===void 0?{}:{build:Qe(t.build)},protocol:R(t.protocol,1),storeId:H(t.storeId),epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function yt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Je(t.activeRuns)},workspaceId:H(t.workspaceId),storeId:H(t.storeId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),rootLabel:N(t.rootLabel,4096,!0),context:mt(t.context),models:V(t.models,k.maxPageEntries,le)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&M(),(ht(n.context)!==n.workspaceId||gt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&M(),n}function bt(e){let t=B(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=B(t.entity,[`kind`,`id`,`version`]),r={taskId:H(t.taskId),runId:z(t.runId,H),childRunId:z(t.childRunId,H),entity:{kind:L(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:H(n.id),version:F(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&M(),r}function xt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function St(e){let t=B(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:U(t.identity),complete:I(t.complete),checkoutGeneration:F(t.checkoutGeneration)}}function Ct(e){G(e,k.controlBytes);let t=Y(e);switch(t){case`assignment-state`:{let n=B(e,[`kind`,`childRunId`,`state`,`reason`]),r=L(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=z(n.reason,e=>L(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&M(),(r===`ready`||r===`preparing`)&&i!==null&&M(),{kind:t,childRunId:H(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:L(B(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=B(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:H(n.runId),identity:pt(n.identity)}}case`parent-settled`:{let n=B(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&M(),{kind:t,runId:H(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=B(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:H(r.reservationId)}:{},lane:L(r.lane,[`reader`,`writer`,`check`]),state:L(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:F(r.checkoutGeneration)}}case`handoff`:{let n=B(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:H(n.childRunId),handoff:Te(n.handoff),observation:St(n.observation)}}case`changes`:{let n=B(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=fe(n.content);return R(r.field,`changes`),{kind:t,observationId:H(n.observationId),stage:L(n.stage,[`before`,`after`,`review`]),observation:St(n.observation),content:r}}case`check-start`:{let n=B(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:H(n.checkId),selection:_e(n.selection),cwdId:H(n.cwdId),cwdLabel:N(n.cwdLabel,4096,!0),checkEnvGeneration:F(n.checkEnvGeneration,1),before:St(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=B(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=B(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:H(e.operationId),reservationId:H(e.reservationId),from:F(e.from),to:F(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&M()}let a=Le(r.native),o=L(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=St(r.before),c=St(r.after),l=z(r.output,fe),u=X(r.coverage);return l&&l.field!==`check`&&M(),o===`passed`&&(a.outcome!==`completed`||G({...s,checkoutGeneration:c.checkoutGeneration})!==G(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&M(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&M(),{kind:t,...i?{ownAdvance:i}:{},checkId:H(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=B(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=I(n.acceptIssues),i=L(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=fe(n.content);return R(a.field,`review`),i===`reviewed-with-issues`&&!r&&M(),{kind:t,reviewId:H(n.reviewId),runId:H(n.runId),checksRevision:F(n.checksRevision),changesIdentity:U(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=B(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=F(n.expectedRevision),i=z(n.expectedIdentity,U),a=F(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&M(),{kind:t,publicationId:H(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:U(n.nextIdentity)}}case`publication-settled`:{let n=B(e,[`kind`,`publicationId`,`status`,`observed`]),r=L(n.status,[`published`,`conflict`,`uncertain`]),i=z(n.observed,e=>{let t=B(e,[`revision`,`identity`]);return{revision:F(t.revision,1),identity:U(t.identity)}});return r===`published`&&i===null&&M(),{kind:t,publicationId:H(n.publicationId),status:r,observed:i}}default:return M()}}function wt(e){let t=B(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:H(t.epoch),operationId:H(t.operationId),taskId:H(t.taskId),runId:z(t.runId,H)}}function Tt(e){G(e,k.ownerQueueBytes);let t=B(e,[`observedMs`,`link`,`events`]),n=wt(t.link),r=V(t.events,k.ownerQueueFrames,e=>{let t=Y(e);if(t===`fact`){let r=Ct(B(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&M(),{kind:t,fact:r}}if(t===`content-begin`){let r=B(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=bt(r.owner),a=L(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&M(),{kind:t,detailId:H(r.detailId),owner:i,field:a,encoding:R(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=B(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:H(n.detailId),text:N(n.text,k.chunkBytes)}}let r=B(e,[`kind`,`detailId`,`coverage`]);return R(t,`content-end`),{kind:`content-end`,detailId:H(r.detailId),coverage:X(r.coverage)}});return{observedMs:F(t.observedMs),link:n,events:r}}var Et=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Dt(e){let t=B(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=L(t.reader,Et),r=B(t.scope,[`kind`,`id`]),i={kind:L(r.kind,[`workspace`,`task`,`run`,`child`]),id:H(r.id)},a=z(t.snapshotSeq,W),o=z(t.after,e=>{let t=B(e,[`recordId`,`version`,`offset`]);return{recordId:H(t.recordId),version:F(t.version,1),offset:F(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&M(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:i,snapshotSeq:a,after:o,limit:F(t.limit,1,k.maxPageEntries)}}function Ot(e){let t=B(e,[`policy`,`historicalRuns`]),n=Dt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&M(),{policy:R(t.policy,`active-and-recent`),historicalRuns:n}}function kt(e){let t=Y(e);if(t===`run`)return{kind:t,projection:rt(B(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=B(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=W(n.committedSeq);return r===`0`&&M(),{kind:t,recordId:H(n.recordId),committedSeq:r,link:qe(n.link),capture:Ke(n.capture)}}if(t===`owner-fact`){let n=B(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Tt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&M();let a=W(n.committedSeq);return a===`0`&&M(),{kind:t,recordId:H(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=B(e,[...n,...r]),a=bt(i.owner),o=F(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&M(),t===`task`){let e=z(i.plan,fe);return e&&e.field!==`plan`&&M(),{kind:t,owner:a,version:o,goal:N(i.goal,8192,!0),plan:e}}if(t===`message`){let e=L(i.role,[`user`,`assistant`,`tool-result`]),n=L(i.state,[`partial`,`final`]),r=z(i.finalBlockCount,e=>F(e,0,k.dataFrames)),s=z(i.finalText,fe),c=z(i.resultCallId,H);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&M(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=z(i.declaration,je),n=z(i.declarationStage,e=>L(e,[`partial`,`final`])),r=I(i.startObserved),s=z(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&M(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&M(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:N(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=fe(i.content);return(e.field!==n.field||!At(e.owner,a))&&M(),{kind:t,owner:a,version:o,detailId:H(i.detailId),descriptor:e,content:n,coverage:X(i.coverage)}}R(t,`omitted`);let s=Pe(i.block);return At(s.owner,a)||M(),{kind:`omitted`,owner:a,version:o,block:s}}function At(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function jt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function Mt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`records`,`next`,`coverage`]),n=Dt(t.request);n.snapshotSeq===null&&M();let r=V(t.records,n.limit,kt),i=z(t.next,Dt);return(r.some(e=>!jt(e,n))||i&&(i.after===null||G(ct({...i,after:n.after}))!==G(ct(n))||G(i.after)===G(n.after)))&&M(),{request:n,records:r,next:i,coverage:X(t.coverage)}}function Nt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||G(ct({...r,snapshotSeq:null}))!==G(ct(n)))&&M(),{kind:`snapshot`,request:n,next:r,coverage:X(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Mt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Dt(t.request),r=Dt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Pt(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ft(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=B(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),graph:{recordId:H(n.recordId),revision:F(n.revision,1),sha256:U(n.sha256)}}}function It(e){G({kind:`ok`,value:e});let t=B(e,[`request`,`graph`]),n=Ft(t.request),r=me(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&M(),{request:n,graph:r}}function Lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return It(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}function Rt(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),format:L(t.format,[`ndjson`,`markdown`])}}function zt(e){G(e,k.controlBytes);let t=B(e,[`exportId`,`ordinal`,`event`]),n=Y(t.event),r;switch(n){case`manifest`:{let e=B(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=B(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:U(i.exporterBuildSha256),capturePolicy:R(i.capturePolicy,`public-text-tools/2`)},schema:R(e.schema,O),request:Rt(e.request),coverage:X(e.coverage),serviceProtocol:R(e.serviceProtocol,1),workerProtocol:R(e.workerProtocol,2)};break}case`record`:r={kind:n,record:kt(B(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:It(B(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=B(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=fe(e.content),a=z(e.range,J),o=N(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==P(o):i.bytes!==0||o!==``)&&M(),r={kind:n,owner:bt(e.owner),content:i,range:a,text:o,coverage:X(e.coverage)};break}case`markdown`:r={kind:n,text:N(B(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=B(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=X(e.coverage),a=I(e.complete);a&&i.observed!==`complete`&&M(),r={kind:n,complete:a,frames:F(e.frames,1),encodedBytes:F(e.encodedBytes),sha256:U(e.sha256),committedSeq:W(e.committedSeq),coverage:i};break}default:return M()}return{exportId:H(t.exportId),ordinal:F(t.ordinal,1),event:r}}function Bt(e,t){let n=zt(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&M(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var Vt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Rt(e)}receive(e){let t=zt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&M(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&M():n.kind===`manifest`&&M(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&M(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&M(),this.request.format===`ndjson`&&n.kind===`markdown`&&M(),n.kind===`detail`&&!xt(n.owner,this.request.scope)&&M(),n.kind===`graph`&&(G(n.graph.request.scope)!==G(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&M(),n.kind===`record`&&!Ht(n.record,this.request.scope)&&M(),this.bytes+=P(Bt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Ht(e,t){return e.kind===`run`?it(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:xt(e.owner,t)}function Ut(e){let t=B(e,[`taskId`,`revision`,`definitions`]),n=V(t.definitions,32,e=>{let t=B(e,[`selection`,`status`,`checkId`]),n=_e(t.selection),r=L(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=z(t.checkId,H);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&M(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&M(),{taskId:H(t.taskId),revision:F(t.revision),definitions:n}}function Wt(e){let t=B(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:H(t.storeId),scope:De(t.scope),snapshotSeq:W(t.snapshotSeq),kind:L(t.kind,[`task`,`message`,`tool`]),id:H(t.id),version:F(t.version,1)}}function Gt(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`record`]),n=Wt(t.request),r=kt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!xt(r.owner,n.scope))&&M(),{request:n,record:r}}function Kt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Gt(e);G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`kind`,`request`,`next`,`coverage`]),n=Wt(t.request),r=Wt(t.next);return lt(n,r),{kind:`progress`,request:n,next:r,coverage:X(t.coverage)}}var qt=e=>{let t=K(e);return R(t.effect,`none`),t};function Jt(e){let t=B(e,[`storeId`,`taskId`]);return{storeId:H(t.storeId),taskId:z(t.taskId,H)}}function Yt(e){let t=Jt(e);return t.taskId===null&&M(),t}function Xt(e){let t=B(e,[`id`,`kind`,`revision`,`identity`]);return{id:H(t.id),kind:L(t.kind,[`code`,`research`,`diagnosis`]),revision:F(t.revision,1),identity:U(t.identity)}}function Zt(e){let t=V(e,3,ue);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&M(),t}function Qt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return B(e,[`status`]),{status:t};if(t===`saved`){let n=B(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ft(n.request),planRevision:F(n.planRevision,1)}}let n=B(e,[`status`,`error`]);return R(n.status,`unavailable`),{status:`unavailable`,error:qt(n.error)}}function $t(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||ht(e.context)!==e.workspaceId||gt(e.context)!==e.request.taskId)&&M(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&M()}}function en(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Jt(t.request),workspaceId:H(t.workspaceId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),context:mt(t.context),task:z(t.task,Xt),roles:Zt(t.roles),savedGraph:Qt(t.savedGraph),readablePlan:z(t.readablePlan,e=>{let t=B(e,[`source`,`text`,`editable`,`coverage`]),n=X(t.coverage),r=I(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&M(),{source:R(t.source,`current-v1`),text:N(t.text,32768),editable:r,coverage:n}})};$t(n),!!n.task!=!!n.readablePlan&&M();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&M(),r.status===`unavailable`&&n.context.status===`available`&&M(),n}function tn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=B(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:Yt(t.request),workspaceId:H(t.workspaceId),epoch:H(t.epoch),committedSeq:W(t.committedSeq),context:mt(t.context),task:Xt(t.task),observation:{identity:U(n.identity),complete:I(n.complete),checkoutGeneration:F(n.checkoutGeneration,0)},text:N(t.text,131072),git:I(t.git),coverage:X(t.coverage)};if($t(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&M()}return r}function nn(e){let t=B(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`]);return{epoch:H(t.epoch),accessGeneration:F(t.accessGeneration,1),configRev:F(t.configRev,1),catalogId:H(t.catalogId)}}function rn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`version`,`selected`]);return{version:nn(t.version),selected:z(t.selected,le)}}function an(e){G(e);let t=B(e,[`expected`,`choice`]);return{expected:nn(t.expected),choice:ce(t.choice)}}function on(e){let t=B(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:N(t.provider,128,!0),model:N(t.model,256,!0),api:z(t.api,e=>L(e,q)),thinking:V(t.thinking,7,e=>{let t=B(e,[`level`,`selectable`]);return{level:L(t.level,se),selectable:I(t.selectable)}}),eligibility:L(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&M(),n}function sn(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 cn(e){G({kind:`ok`,value:e},k.pageBytes);let t=B(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]),n=V(t.entries,k.maxPageEntries,on),r=z(t.remembered,ce),i=L(t.status,[`complete`,`capacity`]),a=F(t.withheld,0,k.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>k.maxPageEntries||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length||r&&!sn(n,r))&&M(),{version:nn(t.version),selected:z(t.selected,le),status:i,entries:n,withheld:a,remembered:r}}function ln(e){let t=B(e,[`id`,`path`,`cwd`,`epoch`]);return{id:U(t.id),path:N(t.path,4096,!0),cwd:N(t.cwd,4096,!0),epoch:H(t.epoch)}}var un=[`registry`,`workbench`,`project`],dn=[`reboot`,`crash`,`restart`,`storage`],fn=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function pn(e){let t=B(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:H(t.id),at:F(t.at,0),scope:L(t.scope,un),path:t.path===null?null:N(t.path,4096,!0),cause:L(t.cause,dn),actions:V(t.actions,fn.length,e=>L(e,fn)),workers:F(t.workers,0,1e6),archived:I(t.archived)}}function mn(e){let t=B(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:R(t.kind,`workbench`),epoch:H(t.epoch),csrf:H(t.csrf),home:N(t.home,4096,!0),projects:V(t.projects,128,ln),recoveries:V(t.recoveries,20,pn),build:Qe(t.build)}}var hn=[`restart`,`upgrade`],gn=[`running`,`ready`,`failed`,`rolled-back`],_n=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],vn=/^(?: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 yn(e){let t=N(e,96,!0);if(!vn.test(t))throw new j(`invalid`);return t}function bn(e){let t=B(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:H(t.id),action:L(t.action,hn),from:yn(t.from),to:t.to===null?null:yn(t.to),state:L(t.state,gn),reason:t.reason===null?null:L(t.reason,_n),version:t.version===null?null:yn(t.version),at:F(t.at,0),endedAt:t.endedAt===null?null:F(t.endedAt,0)}}var xn=[`npm`,`not-npm-global`,`not-writable`];function Sn(e){let t=B(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=B(t.unit,[`name`,`scope`]);n={name:N(e.name,96,!0),scope:L(e.scope,[`user`,`system`])}}return{kind:R(t.kind,`service`),version:yn(t.version),unit:n,upgrade:L(t.upgrade,xn),work:F(t.work,0,1e6),job:t.job===null?null:bn(t.job)}}function Cn(e){let t=B(e,[`kind`,`version`,`deprecated`]);return{kind:R(t.kind,`release`),version:yn(t.version),deprecated:I(t.deprecated)}}function wn(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 Tn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function En(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function Dn(e,t=!1){let n=N(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`Invalid workflow file path`);return n}var On=(e,t=!1)=>{let n=N(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function kn(e){let t=B(e,[`name`,`command`,`timeoutMs`]);return{name:N(t.name,128,!0),command:N(t.command,4096,!0),timeoutMs:F(t.timeoutMs,100,12e5)}}function An(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 jn(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 An(e),r(t),An(e).filter(e=>n.has(e.id))}function Mn(e,t={}){let n=t.strict===!0;G(e,Tn.bytes);let r=B(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=V(r.tasks,Tn.tasks,e=>{let t=B(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:On(t.id,n),title:N(t.title,256,!0),instructions:N(t.instructions,8192,!0),writes:V(t.writes,128,e=>Dn(e,n)),after:V(t.after,Tn.tasks,e=>On(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`);An(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||jn(i,e.id).some(e=>e.id===t.id)||jn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>En(t.writes,e))||t.writes.some(t=>En(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=V(r.checks,Tn.checks,kn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:N(r.goal,8192,!0),design:N(r.design,32768,!0),decisions:N(r.decisions,16384),acceptance:N(r.acceptance,16384,!0),projectContext:N(r.projectContext,16384),tasks:i,checks:a,setup:V(r.setup,4,kn),baselineChecks:V(r.baselineChecks,Tn.checks,kn),repairAttempts:F(r.repairAttempts,0,Tn.repairs),delivery:L(r.delivery,[`local-merge`,`working-copy`])};Nn(o),N(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
2
|
+
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function Nn(e){return N(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function Pn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=B(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...t?[`display`]:[]]);return{id:H(n.id),epoch:H(n.epoch),digest:U(n.digest),observation:U(n.observation),model:nn(n.model),plan:Mn(n.plan),cwd:N(n.cwd,4096,!0),...t?{display:(()=>{let e=B(n.display,[`model`,`branch`,`baseCommit`]);return{model:N(e.model,1024,!0),branch:N(e.branch,1024),baseCommit:N(e.baseCommit,64)}})()}:{}}}function Fn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=B(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=V(n.questions,Tn.parallel,e=>N(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:V(n.roots,8,e=>N(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:N(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:nn(n.model)}}if(t===`propose`){let n=B(e,[`action`,`plan`,`model`]);return{action:t,plan:Mn(n.plan),model:nn(n.model)}}if(t===`prepare`||t===`execute`){let n=B(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:H(n.proposalId),digest:U(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:H(n.grant)}}let n=B(e,[`action`,`runId`]);return{action:L(n.action,[`cancel`]),runId:H(n.runId)}}function In(e){let t=B(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[]]),n=e=>L(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.diagnostics===void 0?{}:{diagnostics:Vn(t.diagnostics)},id:H(t.id),epoch:H(t.epoch),goal:N(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:L(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:N(t.notice,2048),mergedCommit:z(t.mergedCommit,e=>N(e,64,!0)),humanReviewed:!1,steps:V(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=B(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Bn(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=B(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:N(e.sdkVersion,128,!0),workerHash:U(e.workerHash)}})()},id:N(r.id,160,!0),...t?{childRunId:H(r.childRunId)}:{},kind:L(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:N(r.text,65536),exitCode:z(r.exitCode,e=>F(e,-2147483648,2147483647)),truncated:I(r.truncated)}})}}function Ln(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:In(B(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Pn(B(e,[`type`,`proposal`]).proposal)};let n=B(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:L(n.type,[`grant`]),proposal:Pn(n.proposal),grant:H(n.grant),expiresAt:F(n.expiresAt,0)}}function Rn(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${An(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
|
|
3
3
|
|
|
4
4
|
`)}\n\n## Setup (explicitly authorized commands)\n${e.setup.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
|
|
5
5
|
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
|
|
6
6
|
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(e=>`${e.name}: ${e.command} (${e.timeoutMs}ms)`).join(`
|
|
7
|
-
`)}\n\n## Automation boundary\nAt most ${e.repairAttempts} repair rounds. ${e.delivery===`local-merge`?`Authorize isolated task worktrees, local task commits and fast-forward integration into the current branch.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Generated project context and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project context\n${e.projectContext}\n`}var
|
|
8
|
-
`)}function Nn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=V(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:U(n.id),revision:I(n.revision,0),enabled:L(n.enabled),head:B(n.head,U),proposal:B(n.proposal,wn),runs:H(n.runs,200,U),...t?{notice:P(n.notice,1024,!0)}:{}}}var Pn=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Fn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`cadence-conversation`:return{kind:t,id:U(V(e,[`kind`,`id`]).id)};case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=V(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:B(r.after,U),...n?{scan:U(r.scan)}:{}}}case`workflow-active`:return V(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=V(e,[`kind`,`id`,`stepId`]);return{kind:t,id:U(n.id),stepId:P(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:U(V(e,[`kind`,`id`]).id)};case`conversations`:case`projects`:return V(e,[`kind`]),{kind:t};case`task-origin`:return{kind:t,taskId:U(V(e,[`kind`,`taskId`]).taskId)};case`conversation`:{let n=V(e,[`kind`,`id`,`before`]);return{kind:t,id:U(n.id),before:B(n.before,U)}}default:{let t=V(e,[`kind`,`path`]);return{kind:R(t.kind,[`files`,`file`,`directories`]),path:P(t.path,4096)}}}}function In(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`restore-model`||t===`workflow-cancel`){let n=V(e,t===`restore-model`?[`kind`,`commandId`,`epoch`]:[`kind`,`commandId`,`epoch`,`runId`]),r={commandId:U(n.commandId),epoch:U(n.epoch)};return t===`restore-model`?{kind:t,...r}:{kind:t,...r,runId:U(n.runId)}}if(t===`cadence-exit`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`]);return{kind:t,commandId:U(n.commandId),conversationId:U(n.conversationId),head:B(n.head,U),revision:I(n.revision,0)}}if(t===`cadence-send`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`,`revision`,`intent`]);return{kind:t,commandId:U(n.commandId),conversationId:U(n.conversationId),head:B(n.head,U),text:P(n.text,16384,!0),model:nn(n.model),revision:I(n.revision,0),intent:R(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=V(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:U(r.commandId),conversationId:U(r.conversationId),revision:I(r.revision,0),proposalId:U(r.proposalId),digest:W(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:U(r.grant)}}if(t===`workflow`){let n=V(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:U(n.commandId),epoch:U(n.epoch),request:Tn(n.request)}}if(t===`send`){let n=V(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:U(n.commandId),conversationId:U(n.conversationId),head:B(n.head,U),text:P(n.text,16384,!0),model:nn(n.model)}}if(t===`interrupt`){let n=V(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:U(n.commandId),conversationId:U(n.conversationId),turnId:U(n.turnId),epoch:U(n.epoch)}}let n=V(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:R(n.kind,[`open-project`]),commandId:U(n.commandId),path:P(n.path,4096,!0),epoch:U(n.epoch)}}function Ln(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=V(e,n?[...t,`omitted`]:t),i=n?V(r.omitted,[`thinking`,`media`,`other`]):null;return{id:U(r.id),epoch:U(r.epoch),status:R(r.status,Pn),notice:P(r.notice,1024),omitted:{thinking:i?L(i.thinking):!1,media:i?L(i.media):!1,other:i?L(i.other):!1},items:H(r.items,256,e=>{let t=V(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:P(t.id,160,!0),role:R(t.role,[`user`,`assistant`,`tool`]),text:P(t.text,262144),name:P(t.name,128),args:P(t.args,65536),error:L(t.error)}})}}function Rn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`cadence`),n=V(e,[`id`,`title`,`head`,`status`,`updatedAt`,...t?[`cadence`]:[]]);return{id:U(n.id),title:P(n.title,512,!0),head:U(n.head),status:R(n.status,Pn),updatedAt:I(n.updatedAt,0),...t?{cadence:L(n.cadence)}:{}}}function zn(e){K(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`workflow-transcript`){let n=V(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:U(n.runId),stepId:P(n.stepId,160,!0),turn:B(n.turn,Ln)}}if(t===`cadence-conversation`)return{kind:t,state:Nn(V(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=V(e,[`kind`,`after`,`scan`]);return{kind:t,after:B(n.after,U),scan:U(n.scan)}}if(t===`workflow-history`){let n=V(e,[`kind`,`entries`,`next`]),r=H(n.entries,hn.historyPage,e=>{let t=V(e,[`id`,`run`]),n=U(t.id),r=B(t.run,En);if(r&&r.id!==n)throw new j(`invalid`);return{id:n,run:r}}),i=B(n.next,U);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new j(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=V(e,[`kind`,`runs`,...n?[`links`]:[]]),i=H(r.runs,4,En),a=n?H(r.links,4,e=>{let t=V(e,[`runId`,`conversationId`]);return{runId:U(t.runId),conversationId:U(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new j(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=V(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:U(n.commandId),grant:U(n.grant),expiresAt:I(n.expiresAt,0),revision:I(n.revision,0),proposal:wn(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=V(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:B(t.commandId,U),response:Dn(t.response)}}if(n===`task-origin`){let t=V(e,[`kind`,`taskId`,`conversationId`]);return{kind:n,taskId:U(t.taskId),conversationId:B(t.conversationId,U)}}if(n===`conversations`)return{kind:n,entries:H(V(e,[`kind`,`entries`]).entries,200,Rn)};if(n===`conversation`){let t=V(e,[`kind`,`summary`,`turns`,`before`]);return{kind:n,summary:B(t.summary,Rn),turns:H(t.turns,20,Ln),before:B(t.before,U)}}if(n===`files`||n===`directories`){let t=V(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:P(t.path,4096),parent:B(t.parent,e=>P(e,4096)),limited:L(t.limited),entries:H(t.entries,200,e=>{let t=V(e,[`name`,`path`,`directory`]);return{name:P(t.name,1024,!0),path:P(t.path,4096,!0),directory:L(t.directory)}})}}if(n===`file`){let t=V(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:P(t.path,4096),text:P(t.text,262144),limited:L(t.limited)}}if(n===`projects`)return{kind:n,entries:H(V(e,[`kind`,`entries`]).entries,128,e=>{let t=V(e,[`path`,`current`]);return{path:P(t.path,4096,!0),current:L(t.current)}})};if(n===`accepted`)return{kind:n,commandId:U(V(e,[`kind`,`commandId`]).commandId)};let r=V(e,[`kind`,`commandId`,`path`,`link`]);return{kind:R(r.kind,[`project`]),commandId:U(r.commandId),path:P(r.path,4096,!0),link:P(r.link,8192,!0)}}var Bn={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`},Vn=`/api/v1/events`,Hn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Un(e,t){if(Hn.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 Wn(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Gn(e,t){switch(e){case`workbenchRead`:return Fn(t);case`workbenchCommand`:return In(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new j(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new j(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return U(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 an(t);case`preflight`:return ye(t);case`command`:return be(t);case`cancel`:return Se(t)}}function Kn(e,t){if(Hn.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,zn);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,cn);case`chooseModel`:return Z(t,rn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,we);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new j(`invalid`);return null});default:throw new j(`invalid`)}}function qn(e){return[...Hn,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Jn(e,t){let n=Bn[e];return t===null||Wn(e)?n:`${n}?request=${encodeURIComponent(K(t))}`}function Yn(e,t){let n=Gn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Bn[e]:Jn(e,n);return Wn(e)||qn(e)&&(r||F(i)>k.headerBytes/4)?{path:Bn[e],method:`POST`,body:K(n)}:{path:i,method:`GET`}}function Xn(e){K(e,k.viewerBytes);let t=R(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(V(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(V(e,[`kind`,`event`]).event)}:(V(e,[`kind`]),{kind:t})}var Zn=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new j(`invalid`);this.origin=e.origin,e.build&&=Ze(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=K(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new j(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Yn(e,Gn(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:this.options.requestTimeoutMs===void 0?n:AbortSignal.any([...n?[n]:[],AbortSignal.timeout(this.options.requestTimeoutMs)]),...i?{body:r.body}:{}}),o;try{e===`session`&&a.ok&&(o=U(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await Qn(a,Un(e)),c=ne(s);if(F(s)>Un(e,c))throw new j(`oversize`);let l=Kn(e,c);if(e===`session`){let e=Z(l,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new j(`forbidden`);this.attachment=o??U(a.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return l}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,an(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,U(e),t)}entity(e,t){return this.request(`entity`,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`,U(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new j(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new j(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Yn(`export`,Rt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new j(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new j(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
9
|
-
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(
|
|
10
|
-
`)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new j(`oversize`)}if(n){if(o)throw new j(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=De(e);if(!this.attachment||!this.options.socket)throw new j(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Vn}?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(K({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(K({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new j(`invalid`);let n=Xn(ne(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Qn(e,t){if(!e.body)throw new j(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new j(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var $n={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=f.createContext&&f.createContext($n),tr=[`attr`,`size`,`title`];function nr(e,t){if(e==null)return{};var n,r,i=rr(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 rr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ir.apply(null,arguments)}function ar(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 or(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ar(Object(n),!0).forEach(function(t){sr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ar(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sr(e,t,n){return(t=cr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cr(e){var t=lr(e,`string`);return typeof t==`symbol`?t:t+``}function lr(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 ur(e){return e&&e.map((e,t)=>f.createElement(e.tag,or({key:t},e.attr),ur(e.child)))}function Q(e){return t=>f.createElement(dr,ir({attr:or({},e.attr)},t),ur(e.child))}function dr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=nr(e,tr),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,ir({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:or(or({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 er===void 0?t($n):f.createElement(er.Consumer,null,e=>t(e))}function fr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 mr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},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:`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:`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 _r(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 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:`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 br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 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:`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 Sr(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 Cr(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 wr(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 Tr(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 Er(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 Dr(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 Or(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function Ar(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z`},child:[]},{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`3`},child:[]}]})(e)}function jr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function Mr(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 Nr(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 Pr(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 Fr(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 Ir(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 Lr(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 Rr(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 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:`20 6 9 17 4 12`},child:[]}]})(e)}function Br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 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:`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:M(`unavailable`,e?`uncertain`:`none`)}),Hr=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Fn(e);try{return this.transport.workbenchRead?Z(await this.transport.workbenchRead(n,t),zn):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=In(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),zn);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`&&K(e.value.request)!==K(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`&&K(e.value.request)!==K(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){try{return this.transport.models?Z(await this.transport.models(e),cn):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=an(e);try{if(!this.transport.chooseModel)return $(!1);let e=Z(await this.transport.chooseModel(t),rn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(K(r)!==K(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){U(e);try{let n=Z(await this.transport.checkObligations(e,t),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`&&K(e.value.request)!==K(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`&&K(e.value.request)!==K(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new j(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new j(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new j(`unavailable`);yield i}catch{throw new j(`unavailable`)}}async preflight(e,t){let n=ye({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),we);return e.kind===`ok`&&(K(e.value.preview.version)!==K(n.expected)||K(e.value.preview.action)!==K(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:M(`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){U(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:M(`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`&&K(e.value.scope)!==K(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`&&K(e.value.cursor)!==K(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`&&K(e.value.cursor)!==K(n)?$(!1):e}catch{return $(!1)}}},Ur=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&&K(i.scope)===K(r.scope)&&ee(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||K(i.scope)!==K(a.scope))return this.resync();let o=ee(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||K(t.admission)!==K(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`}},Wr={sourceHash:`de4d8dec690b6c7d174c038a201ad1246e86f5d3343441880279b69d0480cdb4`,contractHash:`b6935a8daa09f70de094136c18d8e3588fdd34fc24b9a8fe95e465de11ddae8d`,buildId:`72da6f745737cd5088de68439d3b84a7f311aa294ddcd17d57c6919b2ab759eb`};function Gr(e){let t=new Zn({origin:window.location.origin,...e?{project:e}:{},...Wr?{build:{kind:`browser`,...Wr}}:{},socket:e=>new WebSocket(e)});return{client:new Hr(t),transport:t}}function Kr(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&&ee(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&&K(t.settlement)!==K(r.settlement))?i=!0:(!r||ee(t.committedSeq,r.committedSeq)>0||K(r)===K(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 qr(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(Fn(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 Jr(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}var Yr=e=>e===`unauthenticated`||e===`forbidden`,Xr=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;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 Ur,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0},v=()=>!r&&n===this.version,y=()=>{v()&&t({..._,observation:c.state})},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 Ur,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,Yr(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(Yr(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,Yr(o.error.code)&&w();return}if(!t&&K(_.workspace?.models??[])!==K(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,Yr(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 Ur,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Wr?{kind:`browser`,...Wr}: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 Ur,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Ur,_={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 Zr(e,t,n){let r=(0,f.useMemo)(()=>new Xr(e),[e]),[i,a]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),o=t?.kind,s=t?.id;return(0,f.useEffect)(()=>{if(a({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return r.observe(o&&s?{kind:o,id:s}:null,a)},[r,o,s,n]),{...i,refresh:(e=!1)=>r.refresh(e)}}var Qr=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 $r({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 ei(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 ti(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 ni(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 ri(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=ei(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 ii(e,t){let n=t?K({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),ti(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 ai({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)(ai,{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 oi(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 si(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return oi(e)}return oi(e)}function ci(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 si(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 li(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
11
|
-
`).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 ui=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:di(!0)},text:{92:di(!1)}});let t={enter:{backslashMathInline:fi,backslashMathDisplay:fi,backslashMathBlock:fi},exit:{backslashMathInline:pi,backslashMathDisplay:pi,backslashMathBlock:pi}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function di(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 fi=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)},pi=function(e){this.exit(e)},mi=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ci();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)(zr,{}):(0,h.jsx)(Pr,{}),n&&t(`Copy unavailable`)]})}),hi=[s,d,ui],gi=[s,l,d,ui],_i=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function vi(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 yi({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?gi:hi,rehypePlugins:t?[i,o,..._i]:_i,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Si,a:xi,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var bi=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(yi,{...e})})});function xi({href:e,children:t}){let n=e&&vi(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 Si({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=li(r).map(e=>{let t=`code-offset:${i}`;return i+=Ci(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)(mi,{text:Ci(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 Ci(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ci).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ci(t?.children)}return``}function wi(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 Ti=new Map;function Ei(e,t){t.length?Ti.set(e,t):Ti.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Ti].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 Di(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 Oi(e,t){let n=t.startContainer.parentElement;for(let r of Di(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 ki({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?wi(n,r):[];return l.current=i,c(i.length),o(0),Ei(u,i),()=>Ei(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Oi(e.current,l.current[n]),Ei(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Ei(`${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 Ai({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=K(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 ri(e,t,n.signal);if(n.signal.aborted)return;let i=await si(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)(ai,{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)(ki,{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)(bi,{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 ji({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)(ai,{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)(_r,{"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 Mi({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=ii(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)(ji,{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)(ai,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ni(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)(Ai,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ni({client:e,seed:t}){return(0,h.jsx)(Pi,{client:e,seed:t},K(t))}function Pi({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)(ai,{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 Fi(e=typeof window>`u`?``:window.location.search){let t=new URLSearchParams(e).get(`project`);return t&&/^[a-f0-9]{64}$/.test(t)?t:null}function Ii(){let e=Fi();return e?`/projects/${e}`:``}function Li(e){let t=Yn(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Ii()+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 Ri({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}),(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)(fr,{"aria-hidden":`true`})})]}),t]})}function zi({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)(Ri,{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{Li({...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 Bi(e,t){if(!t||F(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 Vi(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 Hi({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=Bi(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)(Ri,{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)(gr,{}),(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)(ai,{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(Vi(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 Ui({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)(ai,{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 Wi({client:e,seed:t}){return(0,h.jsx)(Gi,{client:e,seed:t},K(t))}function Gi({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)(ai,{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)(Ai,{client:e,cursor:ni(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)(bi,{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 Ki({client:e,seed:t,onScope:n}){let{t:r}=T(),i=ii(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(ji,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ui,{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)(Wi,{client:e,seed:o},o.graph.recordId)]})}function qi({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)(gr,{"aria-hidden":`true`})})}function Ji(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 Yi(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 Xi(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)??Zi(n.role,n.customType)}return r}function Zi(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 Qi(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var $i=(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`})}),ea=(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)(Ir,{"aria-hidden":`true`}):(0,h.jsx)(Ar,{"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)(Ai,{compact:!0,client:t,cursor:ni(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)(Mi,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function ta({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),[o,s]=(0,f.useState)(()=>new Set),c=(0,f.useRef)(o);c.current=o;let l=(0,f.useRef)(new Map),u=(0,f.useRef)(new Map),d=(0,f.useRef)(new Map),p=(0,f.useRef)(0),m=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,message:e})),[e]),g=(0,f.useRef)(new Map);g.current=new Map(m.map(e=>[e.id,e.message.version]));let _=(0,f.useRef)(new Set);_.current=Xi(m,l.current,1800);let v=(0,f.useCallback)((e,t)=>{let n=g.current.get(e);n!==void 0&&(u.current.set(e,{h:t,len:n}),l.current.set(e,t))},[]),y=(0,f.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.getBoundingClientRect(),n=[];for(let[e,t]of d.current){let r=t.getBoundingClientRect();n.push({id:e,top:r.top,bottom:r.bottom}),c.current.has(e)||v(e,r.height)}let r=Ji(n,{top:t.top-1200,bottom:t.bottom+1200},_.current,c.current,{top:t.top-2400,bottom:t.bottom+2400});for(let e of r.hide){let t=d.current.get(e);t&&v(e,t.offsetHeight)}s(e=>Yi(e,r))},[v]),b=(0,f.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,y()})},[y]);return(0,f.useLayoutEffect)(()=>{m.length?y():s(new Set)},[y,m]),(0,f.useEffect)(()=>{let e=new ResizeObserver(b);return i.current&&e.observe(i.current),()=>{e.disconnect(),cancelAnimationFrame(p.current)}},[b]),(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,b()},children:m.map(({id:e,role:r,message:a})=>(0,h.jsx)($i,{id:e,show:!o.has(e),height:Qi(e,a.version,u.current,r===`user`?100:280),containerRef:i,onMeasured:v,lazyRef:t=>{t?d.current.set(e,t):d.current.delete(e)},children:(0,h.jsx)(ea,{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)(Vr,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function na({client:e,seed:t}){let{t:n}=T(),r=ii(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(ji,{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)(ta,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function ra({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)(Rr,{}):(0,h.jsx)(Lr,{})}):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 ia=(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)(ra,{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)(Mi,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),aa=[`queued`,`running`];function oa(e){return e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,``)}function sa(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>new Map),[a,o]=(0,f.useState)(!1),s=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r,a=new Map,c=async()=>{let l=!1;for(let n of JSON.parse(s)){let r=a.get(n);if(r&&!aa.includes(r.status))continue;let i=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return;i.kind===`ok`&&i.value.kind===`workflow`&&i.value.response.type===`run`?a.set(n,i.value.response.run):l=!0}t.signal.aborted||(i(new Map(a)),o(l),(l||[...a.values()].some(e=>aa.includes(e.status)))&&(r=setTimeout(()=>void c(),n)))};return c(),()=>{t.abort(),clearTimeout(r)}},[e,s,n]),{runs:r,failed:a}}function ca({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=sa(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(!aa.includes(e.step.status))-Number(!aa.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>aa.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)(Rr,{}),(0,h.jsx)(Nr,{}),(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=oa(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))]})]})}async function la(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||K(r.value.proposal)!==K(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 ua(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function da(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var fa={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},pa={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.`},ma=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,ha=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function ga(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>se.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function _a(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(fa[t.thinking])}`,[e])}function va({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,awaitingSend:c=!1}){let{t:l}=T(),u=_a(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(0),E=(0,f.useRef)(null),D=(0,f.useRef)(null),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useCallback)(()=>w(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(p(e.value),g(``)):g(e.error.code))}).catch(()=>{t.signal.aborted||g(`unavailable`)}),()=>t.abort()},[e,r,C]),(0,f.useEffect)(()=>{i&&A()},[i,A]);let j=(0,f.useCallback)((e=!0)=>{a(!1),S(``),e&&D.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;v(``),O.current?.focus({preventScroll:!0});let e=e=>{E.current?.contains(e.target)||j(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,j]);let M=d?.selected??null,N=M??d?.remembered??null,P=(0,f.useMemo)(()=>{let e=x.trim().toLowerCase(),t=new Map;for(let n of d?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[d,x]),F=d?.entries.find(e=>ha(e,N)),I=async(t,r)=>{if(!d||!t.api||y||n)return;let i=ce({provider:t.provider,model:t.model,api:t.api,thinking:r});if(M&&ma(M,i))j(),s?.();else{b(!0),v(``);try{let t=await e.chooseModel({expected:d.version,choice:i});if(t.kind===`error`){v(t.error.code),A();return}p({...d,version:t.value.version,selected:t.value.selected}),o(),j(),s?.()}catch{v(`uncertain`),A()}finally{b(!1)}}},L=()=>[...k.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?O.current?.focus():t[Math.min(n,t.length-1)]?.focus()},z=!t||!d&&!!m,B=d?N?u(N):l(`Choose a model`):l(m?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:E,children:[(0,h.jsxs)(`button`,{ref:D,type:`button`,className:`model-trigger${N&&!M?` remembered`:``}${d&&!N?` empty`:``}`,"aria-label":l(`Model: {model}`,{model:B}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?l(`Switch models after the current reply finishes.`):N&&!M?l(`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)(Nr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:B}),(0,h.jsx)(Rr,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":l(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),j())},children:[c&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:l(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(gr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:O,type:`search`,"aria-label":l(`Search models`),placeholder:l(`Search models…`),value:x,onChange:e=>S(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":l(`Models`),ref:k,onKeyDown:R,children:[!d&&!m&&(0,h.jsx)(`p`,{className:`model-empty`,children:l(`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=ha(e,N);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||y||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void I(e,ga(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`?l(`Credentials unavailable`):l(`Not supported`)}),r&&!M&&(0,h.jsx)(`span`,{className:`model-option-note`,children:l(`Used when you send`)}),r&&(0,h.jsx)(zr,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),d?.status===`complete`&&P.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:x.trim()?l(`No matching models.`):l(`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:l(`Thinking`)}),F.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":l(`Thinking level: {level}`,{level:l(fa[e.level])}),"aria-pressed":N?.thinking===e.level,disabled:!e.selectable||y||n,onClick:()=>void I(F,e.level),children:l(fa[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:l(`Switch models after the current reply finishes.`)}),d?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:l(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!d?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:l(d.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:d.withheld})}),m&&(0,h.jsxs)(`p`,{role:`alert`,children:[l(`The model list could not be read ({code}).`,{code:m}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:A,children:l(`Read again`)})]}),_&&(0,h.jsx)(`p`,{role:`alert`,children:pa[_]?l(pa[_]):l(`The model was not changed ({code}).`,{code:_})}),!z&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:l(y?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}var ya=/^\s{0,3}(`{3,}|~{3,})/,ba=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function xa(e){return e.trim()===``}function Sa(e){let t=ya.exec(e);return t?t[1]:null}function Ca(e){let t=e.split(`
|
|
12
|
-
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=
|
|
7
|
+
`)}\n\n## Automation boundary\nAt most ${e.repairAttempts} repair rounds. ${e.delivery===`local-merge`?`Authorize isolated task worktrees, local task commits and fast-forward integration into the current branch.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment, unplanned installation or recursive delegation. Generated project context and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project context\n${e.projectContext}\n`}var zn=e=>F(e,0,864e13);function Bn(e){let t=B(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:zn(t.createdAt),preparedAt:z(t.preparedAt,zn),startedAt:z(t.startedAt,zn),stopRequestedAt:z(t.stopRequestedAt,zn),closedAt:z(t.closedAt,zn),settledAt:z(t.settledAt,zn),timeoutMs:F(t.timeoutMs,100,12e5),stopReason:z(t.stopReason,e=>N(e,32,!0))}}function Vn(e){let t=B(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=B(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:zn(t.acceptedAt),acquiredAt:z(t.acquiredAt,zn),settledAt:z(t.settledAt,zn),owner:{version:N(n.version,128,!0),build:N(n.build,64,!0),entry:N(n.entry,4096,!0),pid:F(n.pid,1),node:N(n.node,128,!0),platform:N(n.platform,32,!0),startedAt:zn(n.startedAt)}}}function Hn(e){let t=e.diagnostics;if(!t)return`Owner timing/runtime observations not recorded.`;let n=e=>e===null?`not observed`:new Date(e).toISOString();return[`Owner: Cadence ${t.owner.version} · ${t.owner.platform} · Node ${t.owner.node} · PID ${t.owner.pid} · epoch ${e.epoch}`,`Build: ${t.owner.build} · entry: ${t.owner.entry} · owner started: ${n(t.owner.startedAt)}`,`Accepted: ${n(t.acceptedAt)} · checkout acquired: ${n(t.acquiredAt)} · settled: ${n(t.settledAt)}`,`Checkout wait: ${t.acquiredAt===null?`still waiting or not acquired`:`${Math.max(0,t.acquiredAt-t.acceptedAt)}ms`}. Runs share an exclusive checkout; questions within one research run may overlap.`,...e.steps.flatMap(e=>e.timing?[`${e.id}: preparing ${n(e.timing.createdAt)} · prepared ${n(e.timing.preparedAt)} · spawned ${n(e.timing.startedAt)} · stop ${n(e.timing.stopRequestedAt)} (${e.timing.stopReason??`none`}) · direct child closed ${n(e.timing.closedAt)} · settled ${n(e.timing.settledAt)} · total process budget ${e.timing.timeoutMs}ms${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
|
|
8
|
+
`)}function Un(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=B(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:H(n.id),revision:F(n.revision,0),enabled:I(n.enabled),head:z(n.head,H),proposal:z(n.proposal,Pn),runs:V(n.runs,200,H),...t?{notice:N(n.notice,1024,!0)}:{}}}function Wn(e){let t=B(e,[`id`,`updatedAt`]);return{id:H(t.id),updatedAt:F(t.updatedAt,0)}}var Gn=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Kn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-transcript`:{let n=B(e,[`kind`,`id`,`turnId`,`page`]);return{kind:t,id:H(n.id),turnId:H(n.turnId),page:F(n.page,0)}}case`cadence-conversation`:return{kind:t,id:H(B(e,[`kind`,`id`]).id)};case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=B(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:z(r.after,H),...n?{scan:H(r.scan)}:{}}}case`workflow-active`:return B(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=B(e,[`kind`,`id`,`stepId`]);return{kind:t,id:H(n.id),stepId:N(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:H(B(e,[`kind`,`id`]).id)};case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`scan`),i=B(e,[`kind`,...n?[`after`]:[],...r?[`scan`]:[]]);return{kind:t,...n?{after:z(i.after,Wn)}:{},...r?{scan:H(i.scan)}:{}}}case`conversation-active`:case`projects`:return B(e,[`kind`]),{kind:t};case`task-origin`:return{kind:t,taskId:H(B(e,[`kind`,`taskId`]).taskId)};case`conversation`:{let n=B(e,[`kind`,`id`,`before`]);return{kind:t,id:H(n.id),before:z(n.before,H)}}default:{let t=B(e,[`kind`,`path`]);return{kind:L(t.kind,[`files`,`file`,`directories`]),path:N(t.path,4096)}}}}function qn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`restore-model`||t===`workflow-cancel`){let n=B(e,t===`restore-model`?[`kind`,`commandId`,`epoch`]:[`kind`,`commandId`,`epoch`,`runId`]),r={commandId:H(n.commandId),epoch:H(n.epoch)};return t===`restore-model`?{kind:t,...r}:{kind:t,...r,runId:H(n.runId)}}if(t===`cadence-exit`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`]);return{kind:t,commandId:H(n.commandId),conversationId:H(n.conversationId),head:z(n.head,H),revision:F(n.revision,0)}}if(t===`cadence-send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`,`revision`,`intent`]);return{kind:t,commandId:H(n.commandId),conversationId:H(n.conversationId),head:z(n.head,H),text:N(n.text,16384,!0),model:nn(n.model),revision:F(n.revision,0),intent:L(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=B(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:H(r.commandId),conversationId:H(r.conversationId),revision:F(r.revision,0),proposalId:H(r.proposalId),digest:U(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:H(r.grant)}}if(t===`workflow`){let n=B(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:H(n.commandId),epoch:H(n.epoch),request:Fn(n.request)}}if(t===`send`){let n=B(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:H(n.commandId),conversationId:H(n.conversationId),head:z(n.head,H),text:N(n.text,16384,!0),model:nn(n.model)}}if(t===`interrupt`){let n=B(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:H(n.commandId),conversationId:H(n.conversationId),turnId:H(n.turnId),epoch:H(n.epoch)}}let n=B(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:L(n.kind,[`open-project`]),commandId:H(n.commandId),path:N(n.path,4096,!0),epoch:H(n.epoch)}}function Jn(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=B(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[]]),a=r?B(i.transcript,[`pages`]):null,o=n?B(i.omitted,[`thinking`,`media`,`other`]):null;return{id:H(i.id),epoch:H(i.epoch),status:L(i.status,Gn),notice:N(i.notice,1024),...a?{transcript:{pages:F(a.pages,0)}}:{},omitted:{thinking:o?I(o.thinking):!1,media:o?I(o.media):!1,other:o?I(o.other):!1},items:V(i.items,256,e=>{let t=B(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:N(t.id,160,!0),role:L(t.role,[`user`,`assistant`,`tool`]),text:N(t.text,262144),name:N(t.name,128),args:N(t.args,65536),error:I(t.error)}})}}function Yn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`cadence`),n=B(e,[`id`,`title`,`head`,`status`,`updatedAt`,...t?[`cadence`]:[]]);return{id:H(n.id),title:N(n.title,512,!0),head:H(n.head),status:L(n.status,Gn),updatedAt:F(n.updatedAt,0),...t?{cadence:I(n.cadence)}:{}}}function Xn(e){G(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-transcript`){let n=B(e,[`kind`,`conversationId`,`page`,`turn`]),r=Jn(n.turn),i=F(n.page,0);if(!r.transcript||i>=r.transcript.pages)throw new j(`invalid`);return{kind:t,conversationId:H(n.conversationId),page:i,turn:r}}if(t===`workflow-transcript`){let n=B(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:H(n.runId),stepId:N(n.stepId,160,!0),turn:z(n.turn,Jn)}}if(t===`cadence-conversation`)return{kind:t,state:Un(B(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=B(e,[`kind`,`after`,`scan`]);return{kind:t,after:z(n.after,H),scan:H(n.scan)}}if(t===`workflow-history`){let n=B(e,[`kind`,`entries`,`next`]),r=V(n.entries,Tn.historyPage,e=>{let t=B(e,[`id`,`run`]),n=H(t.id),r=z(t.run,In);if(r&&r.id!==n)throw new j(`invalid`);return{id:n,run:r}}),i=z(n.next,H);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new j(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=B(e,[`kind`,`runs`,...n?[`links`]:[]]),i=V(r.runs,4,In),a=n?V(r.links,4,e=>{let t=B(e,[`runId`,`conversationId`]);return{runId:H(t.runId),conversationId:H(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new j(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=B(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:H(n.commandId),grant:H(n.grant),expiresAt:F(n.expiresAt,0),revision:F(n.revision,0),proposal:Pn(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=B(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:z(t.commandId,H),response:Ln(t.response)}}if(n===`task-origin`){let t=B(e,[`kind`,`taskId`,`conversationId`]);return{kind:n,taskId:H(t.taskId),conversationId:z(t.conversationId,H)}}if(n===`conversations-progress`){let t=B(e,[`kind`,`after`,`scan`]);return{kind:n,after:z(t.after,Wn),scan:H(t.scan)}}if(n===`conversation-active`)return{kind:n,entries:V(B(e,[`kind`,`entries`]).entries,8,Yn)};if(n===`conversations`){let t=Object.hasOwn(e,`next`),r=B(e,[`kind`,`entries`,...t?[`next`]:[]]);return{kind:n,entries:V(r.entries,200,Yn),...t?{next:z(r.next,Wn)}:{}}}if(n===`conversation`){let t=B(e,[`kind`,`summary`,`turns`,`before`]);return{kind:n,summary:z(t.summary,Yn),turns:V(t.turns,20,Jn),before:z(t.before,H)}}if(n===`files`||n===`directories`){let t=B(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:N(t.path,4096),parent:z(t.parent,e=>N(e,4096)),limited:I(t.limited),entries:V(t.entries,200,e=>{let t=B(e,[`name`,`path`,`directory`]);return{name:N(t.name,1024,!0),path:N(t.path,4096,!0),directory:I(t.directory)}})}}if(n===`file`){let t=B(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:N(t.path,4096),text:N(t.text,262144),limited:I(t.limited)}}if(n===`projects`)return{kind:n,entries:V(B(e,[`kind`,`entries`]).entries,128,e=>{let t=B(e,[`path`,`current`]);return{path:N(t.path,4096,!0),current:I(t.current)}})};if(n===`accepted`)return{kind:n,commandId:H(B(e,[`kind`,`commandId`]).commandId)};let r=B(e,[`kind`,`commandId`,`path`,`link`]);return{kind:L(r.kind,[`project`]),commandId:H(r.commandId),path:N(r.path,4096,!0),link:N(r.link,8192,!0)}}var Zn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Qn=f.createContext&&f.createContext(Zn),$n=[`attr`,`size`,`title`];function er(e,t){if(e==null)return{};var n,r,i=tr(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 tr(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 rr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function ir(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?rr(Object(n),!0).forEach(function(t){ar(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):rr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ar(e,t,n){return(t=or(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function or(e){var t=sr(e,`string`);return typeof t==`symbol`?t:t+``}function sr(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 cr(e){return e&&e.map((e,t)=>f.createElement(e.tag,ir({key:t},e.attr),cr(e.child)))}function Q(e){return t=>f.createElement(lr,nr({attr:ir({},e.attr)},t),cr(e.child))}function lr(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=er(e,$n),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:ir(ir({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return Qn===void 0?t(Zn):f.createElement(Qn.Consumer,null,e=>t(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:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function dr(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 pr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function mr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function hr(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 gr(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 _r(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 yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},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:`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 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:`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 Sr(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 Cr(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 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:`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 Tr(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 Er(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 Dr(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 Or(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 kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 Ar(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 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:`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 Mr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`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 Nr(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 Pr(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 Fr(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 Ir(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 Lr(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 Rr(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 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:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function Br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 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:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var $=e=>({kind:`error`,error:ee(`unavailable`,e?`uncertain`:`none`)}),Hr=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Kn(e);try{return this.transport.workbenchRead?Z(await this.transport.workbenchRead(n,t),Xn):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=qn(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Xn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Jt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),en);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=Yt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),tn);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Z(await this.transport.activeRuns(e),Je):$(!1)}catch{return $(!1)}}async models(e){try{return this.transport.models?Z(await this.transport.models(e),cn):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=an(e);try{if(!this.transport.chooseModel)return $(!1);let e=Z(await this.transport.chooseModel(t),rn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(G(r)!==G(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){H(e);try{let n=Z(await this.transport.checkObligations(e,t),Ut);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Wt({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Kt);return e.kind===`ok`&&G(e.value.request)!==G(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return Z(await this.transport.session(e),vt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),yt)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Dt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),Nt);return t.kind===`ok`&&!Pt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Ft(e);try{let e=Z(await this.transport.graph(n,t),Lt);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=Rt(e),r=new Vt(n),i;try{if(t.aborted)throw new j(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new j(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new j(`unavailable`);yield i}catch{throw new j(`unavailable`)}}async preflight(e,t){let n=ye({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),we);return e.kind===`ok`&&(G(e.value.preview.version)!==G(n.expected)||G(e.value.preview.action)!==G(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=be(t);if(n.action.kind!==e)return{kind:`error`,error:ee(`invalid`)};try{let e=Z(await this.transport.command(n),et);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);tt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Se(e);try{let e=Z(await this.transport.cancel(t),et);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);tt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){H(e);try{let n=nt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:ee(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=De(e);try{let e=Z(await this.transport.snapshot(n,t),ot);return e.kind===`ok`&&G(e.value.scope)!==G(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=Z(await this.transport.detail(n,t),ut);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=Z(await this.transport.search(n,t),ft);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}},Ur=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=ot(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&te(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=st(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||G(i.scope)!==G(a.scope))return this.resync();let o=te(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||ht(i.context)!==ht(a.context)||gt(i.context)!==gt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||G(t.admission)!==G(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{ot(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}},Wr={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`},Gr=`/api/v1/events`,Kr=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function qr(e,t){if(Kr.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 Jr(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Yr(e,t){switch(e){case`workbenchRead`:return Kn(t);case`workbenchCommand`:return qn(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new j(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Dt(t);if(n.reader!==e)throw new j(`invalid`);return n}case`current`:return Jt(t);case`currentChanges`:return Yt(t);case`checkObligations`:case`receipt`:return H(t);case`entity`:return Wt(t);case`graph`:return Ft(t);case`snapshot`:return De(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return Rt(t);case`chooseModel`:return an(t);case`preflight`:return ye(t);case`command`:return be(t);case`cancel`:return Se(t)}}function Xr(e,t){if(Kr.includes(e))return Z(t,Nt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Xn);case`current`:return Z(t,en);case`currentChanges`:return Z(t,tn);case`activeRuns`:return Z(t,Je);case`models`:return Z(t,cn);case`chooseModel`:return Z(t,rn);case`session`:return Z(t,vt);case`workspace`:return Z(t,yt);case`checkObligations`:return Z(t,Ut);case`entity`:return Z(t,Kt);case`graph`:return Z(t,Lt);case`snapshot`:return Z(t,ot);case`detail`:return Z(t,ut);case`search`:return Z(t,ft);case`preflight`:return Z(t,we);case`command`:case`cancel`:return Z(t,et);case`receipt`:return nt(t);case`detach`:return Z(t,e=>{if(e!==null)throw new j(`invalid`);return null});default:throw new j(`invalid`)}}function Zr(e){return[...Kr,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Qr(e,t){let n=Wr[e];return t===null||Jr(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function $r(e,t){let n=Yr(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Wr[e]:Qr(e,n);return Jr(e)||Zr(e)&&(r||P(i)>k.headerBytes/4)?{path:Wr[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function ei(e){G(e,k.viewerBytes);let t=L(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:ot(B(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:st(B(e,[`kind`,`event`]).event)}:(B(e,[`kind`]),{kind:t})}var ti=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new j(`invalid`);this.origin=e.origin,e.build&&=Ze(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=G(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new j(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=$r(e,Yr(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:this.options.requestTimeoutMs===void 0?n:AbortSignal.any([...n?[n]:[],AbortSignal.timeout(this.options.requestTimeoutMs)]),...i?{body:r.body}:{}}),o;try{e===`session`&&a.ok&&(o=H(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await ni(a,qr(e)),c=re(s);if(P(s)>qr(e,c))throw new j(`oversize`);let l=Xr(e,c);if(e===`session`){let e=Z(l,vt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new j(`forbidden`);this.attachment=o??H(a.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return l}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,an(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,H(e),t)}entity(e,t){return this.request(`entity`,Wt(e),t)}tasks(e,t){return this.request(`tasks`,Dt(e),t)}runs(e,t){return this.request(`runs`,Dt(e),t)}messages(e,t){return this.request(`messages`,Dt(e),t)}tools(e,t){return this.request(`tools`,Dt(e),t)}contents(e,t){return this.request(`contents`,Dt(e),t)}events(e,t){return this.request(`events`,Dt(e),t)}checks(e,t){return this.request(`checks`,Dt(e),t)}changes(e,t){return this.request(`changes`,Dt(e),t)}reviews(e,t){return this.request(`reviews`,Dt(e),t)}graph(e,t){return this.request(`graph`,Ft(e),t)}preflight(e){return this.request(`preflight`,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`,H(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new j(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new j(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=$r(`export`,Rt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new j(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new j(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
9
|
+
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield zt(re(e,k.controlBytes)),r=o.indexOf(`
|
|
10
|
+
`)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new j(`oversize`)}if(n){if(o)throw new j(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=De(e);if(!this.attachment||!this.options.socket)throw new j(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Gr}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(G({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new j(`invalid`);let n=ei(re(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function ni(e,t){if(!e.body)throw new j(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new j(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var ri={sourceHash:`56d61dbb96ce4ef1dd8f83d6ca150105d8417059a1f2f5f9bfe4762f05151a88`,contractHash:`70b7d387e5677a43ff0a80f82aad39684362496916c796150a4e326cd7756b65`,buildId:`4a07fe3e72c45001d5e3589fc580f60780a434069f353573bbe8de3a4b94674b`};function ii(e){let t=new ti({origin:window.location.origin,...e?{project:e}:{},...ri?{build:{kind:`browser`,...ri}}:{},socket:e=>new WebSocket(e)});return{client:new Hr(t),transport:t}}function ai(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&te(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&G(t.settlement)!==G(r.settlement))?i=!0:(!r||te(t.committedSeq,r.committedSeq)>0||G(r)===G(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function oi(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(Kn(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 si(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 ci(e,t){let[n,r]=(0,f.useState)(null),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)([]),[c,l]=(0,f.useState)(0),[u,d]=(0,f.useState)(),p=JSON.stringify(n),m=JSON.stringify([n,c]),h=oi(e,t?{kind:`conversations`,after:n,...i?{scan:i}:{}}:null),g=(0,f.useCallback)(()=>{a(void 0),l(e=>e+1),h.refresh()},[h.refresh]);(0,f.useEffect)(()=>{h.loading||h.error||!h.value||(h.value.kind===`conversations-progress`?a(h.value.scan):h.value.kind===`conversations`&&d({key:m,boundary:p,page:h.value}))},[h.value,h.error,h.loading,m,p]);let _=t&&!h.error&&(h.loading||u?.key!==m||h.value?.kind===`conversations-progress`);return(0,f.useEffect)(()=>{if(!t||n!==null||_)return;let e=setTimeout(g,2e3);return()=>clearTimeout(e)},[t,n,_,g]),{value:u?.boundary===p?u.page:void 0,error:h.error,loading:_,refresh:g,canPrevious:o.length>0,first:()=>{r(null),s([]),g()},previous:()=>{!_&&o.length&&(r(o.at(-1)??null),s(e=>e.slice(0,-1)),a(void 0))},next:()=>{!_&&u?.page.next&&(s(e=>[...e,n]),r(u.page.next),a(void 0))}}}var li=e=>e===`unauthenticated`||e===`forbidden`,ui=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;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 Ur,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0},v=()=>!r&&n===this.version,y=()=>{v()&&t({..._,observation:c.state})},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 Ur,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,li(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(li(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,li(o.error.code)&&w();return}if(!t&&G(_.workspace?.models??[])!==G(o.value.models)&&!await i())return;if(_.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,li(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 Ur,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=ri?{kind:`browser`,...ri}:null;_.compatible=$e(e.build,t),_.cancelCompatible=$e(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new Ur,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Ur,_={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 di(e,t,n){let r=(0,f.useMemo)(()=>new ui(e),[e]),[i,a]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),o=t?.kind,s=t?.id;return(0,f.useEffect)(()=>{if(a({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return r.observe(o&&s?{kind:o,id:s}:null,a)},[r,o,s,n]),{...i,refresh:(e=!1)=>r.refresh(e)}}var fi=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 pi({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 mi(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 hi(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 gi(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 _i(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=mi(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 vi(e,t){let n=t?G({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),hi(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 yi({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)(yi,{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 bi(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 xi(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return bi(e)}return bi(e)}function Si(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 xi(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 Ci(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
11
|
+
`).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 wi=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Ti(!0)},text:{92:Ti(!1)}});let t={enter:{backslashMathInline:Ei,backslashMathDisplay:Ei,backslashMathBlock:Ei},exit:{backslashMathInline:Di,backslashMathDisplay:Di,backslashMathBlock:Di}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Ti(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 Ei=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)},Di=function(e){this.exit(e)},Oi=(0,f.memo)(function({text:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=Si();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)(Rr,{}):(0,h.jsx)(Nr,{}),n&&t(`Copy unavailable`)]})}),ki=[s,d,wi],Ai=[s,l,d,wi],ji=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Mi(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 Ni({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?Ai:ki,rehypePlugins:t?[i,o,...ji]:ji,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Ii,a:Fi,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var Pi=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(Ni,{...e})})});function Fi({href:e,children:t}){let n=e&&Mi(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 Ii({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Ci(r).map(e=>{let t=`code-offset:${i}`;return i+=Li(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)(Oi,{text:Li(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 Li(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Li).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Li(t?.children)}return``}function Ri(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 zi=new Map;function Bi(e,t){t.length?zi.set(e,t):zi.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...zi].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 Vi(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 Hi(e,t){let n=t.startContainer.parentElement;for(let r of Vi(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 Ui({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?Ri(n,r):[];return l.current=i,c(i.length),o(0),Bi(u,i),()=>Bi(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Hi(e.current,l.current[n]),Bi(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Bi(`${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 Wi({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=G(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await _i(e,t,n.signal);if(n.signal.aborted)return;let i=await xi(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)(yi,{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)(Ui,{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)(Pi,{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 Gi({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)(yi,{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)(gr,{"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 Ki({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=vi(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)(Gi,{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)(yi,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(gi(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)(Wi,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function qi({client:e,seed:t}){return(0,h.jsx)(Ji,{client:e,seed:t},G(t))}function Ji({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)(yi,{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 Yi(e=typeof window>`u`?``:window.location.search){let t=new URLSearchParams(e).get(`project`);return t&&/^[a-f0-9]{64}$/.test(t)?t:null}function Xi(){let e=Yi();return e?`/projects/${e}`:``}function Zi(e){let t=$r(`download`,Rt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Xi()+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 Qi({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)(ur,{"aria-hidden":`true`})})]}),t]})}function $i({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)(Qi,{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{Zi({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,h.jsx)(`p`,{role:`status`,children:s})]})}function ea(e,t){if(!t||P(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ta(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 na({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=T(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=ea(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(Qi,{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)(hr,{}),(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)(yi,{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(ta(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 ra({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)(yi,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function ia({client:e,seed:t}){return(0,h.jsx)(aa,{client:e,seed:t},G(t))}function aa({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)(yi,{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)(Wi,{client:e,cursor:gi(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)(Pi,{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 oa({client:e,seed:t,onScope:n}){let{t:r}=T(),i=vi(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Gi,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(ra,{run:e.projection,historical:!0}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,h.jsx)(ia,{client:e,seed:o},o.graph.recordId)]})}function sa({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)(hr,{"aria-hidden":`true`})})}function ca(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 la(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 ua(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)??da(n.role,n.customType)}return r}function da(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 fa(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var pa=(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`})}),ma=(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)(Fr,{"aria-hidden":`true`}):(0,h.jsx)(kr,{"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)(Wi,{compact:!0,client:t,cursor:gi(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)(Ki,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function ha({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),[o,s]=(0,f.useState)(()=>new Set),c=(0,f.useRef)(o);c.current=o;let l=(0,f.useRef)(new Map),u=(0,f.useRef)(new Map),d=(0,f.useRef)(new Map),p=(0,f.useRef)(0),m=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,message:e})),[e]),g=(0,f.useRef)(new Map);g.current=new Map(m.map(e=>[e.id,e.message.version]));let _=(0,f.useRef)(new Set);_.current=ua(m,l.current,1800);let v=(0,f.useCallback)((e,t)=>{let n=g.current.get(e);n!==void 0&&(u.current.set(e,{h:t,len:n}),l.current.set(e,t))},[]),y=(0,f.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.getBoundingClientRect(),n=[];for(let[e,t]of d.current){let r=t.getBoundingClientRect();n.push({id:e,top:r.top,bottom:r.bottom}),c.current.has(e)||v(e,r.height)}let r=ca(n,{top:t.top-1200,bottom:t.bottom+1200},_.current,c.current,{top:t.top-2400,bottom:t.bottom+2400});for(let e of r.hide){let t=d.current.get(e);t&&v(e,t.offsetHeight)}s(e=>la(e,r))},[v]),b=(0,f.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,y()})},[y]);return(0,f.useLayoutEffect)(()=>{m.length?y():s(new Set)},[y,m]),(0,f.useEffect)(()=>{let e=new ResizeObserver(b);return i.current&&e.observe(i.current),()=>{e.disconnect(),cancelAnimationFrame(p.current)}},[b]),(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,b()},children:m.map(({id:e,role:r,message:a})=>(0,h.jsx)(pa,{id:e,show:!o.has(e),height:fa(e,a.version,u.current,r===`user`?100:280),containerRef:i,onMeasured:v,lazyRef:t=>{t?d.current.set(e,t):d.current.delete(e)},children:(0,h.jsx)(ma,{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)(Vr,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function ga({client:e,seed:t}){let{t:n}=T(),r=vi(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Gi,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,h.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,h.jsxs)(h.Fragment,{children:[i.records.length===0&&(0,h.jsx)(`p`,{className:`empty-note panel-empty`,children:i.next?n(`No message records on this page; more history remains.`):n(`No message records on this page.`)}),(0,h.jsx)(ha,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function _a({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)(Lr,{}):(0,h.jsx)(Ir,{})}):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 va=(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)(_a,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(dr,{}),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)(Ki,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),ya=[`queued`,`running`];function ba(e){return e.replace(/-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,``)}function xa(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>new Map),[a,o]=(0,f.useState)(!1),s=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r,a=new Map,c=async()=>{let l=!1;for(let n of JSON.parse(s)){let r=a.get(n);if(r&&!ya.includes(r.status))continue;let i=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return;i.kind===`ok`&&i.value.kind===`workflow`&&i.value.response.type===`run`?a.set(n,i.value.response.run):l=!0}t.signal.aborted||(i(new Map(a)),o(l),(l||[...a.values()].some(e=>ya.includes(e.status)))&&(r=setTimeout(()=>void c(),n)))};return c(),()=>{t.abort(),clearTimeout(r)}},[e,s,n]),{runs:r,failed:a}}function Sa({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=xa(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,f.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(b)){let r=await e.snapshot({kind:`task`,id:n},t.signal);if(t.signal.aborted)return;if(r.kind===`ok`)for(let e of r.value.runs)e.childRunId&&i.push({taskId:n,run:e,snapshot:r.value.committedSeq});else a=!0}t.signal.aborted||(g(i),v(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,b]);let x=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],S=[...m,...x.filter(e=>!m.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=[...new Set(a)].flatMap(e=>{let t=y.runs.get(e);return t?t.steps.filter(e=>e.childRunId).map(e=>({run:t,step:e})):[]}).reverse().sort((e,t)=>Number(!ya.includes(e.step.status))-Number(!ya.includes(t.step.status))),w=S.length+C.length,E=C.filter(({step:e})=>ya.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)(Lr,{}),(0,h.jsx)(Mr,{}),(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=ba(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))]})]})}async function Ca(e){let t=e.state.proposal;if(!t||!e.state.enabled||!e.current())throw Error(`stale`);let n={conversationId:e.state.id,revision:e.state.revision,proposalId:t.id,digest:t.digest},r=await e.client.workbenchCommand({kind:`cadence-prepare`,commandId:crypto.randomUUID(),...n});if(r.kind!==`ok`)throw Error(r.error.code);if(r.value.kind!==`cadence-grant`||!e.current()||r.value.revision!==e.state.revision||G(r.value.proposal)!==G(t)||Date.now()>=r.value.expiresAt)throw Error(`stale`);let i=crypto.randomUUID();return e.submitting(i),e.client.workbenchCommand({kind:`cadence-approve`,commandId:i,...n,grant:r.value.grant})}function wa(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function Ta(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Ea={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Da={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.`},Oa=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,ka=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Aa(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>se.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function ja(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Ea[t.thinking])}`,[e])}function Ma({client:e,enabled:t,locked:n,refresh:r,open:i,onOpenChange:a,onChanged:o,onChosen:s,awaitingSend:c=!1}){let{t:l}=T(),u=ja(),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)(``),[_,v]=(0,f.useState)(``),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(``),[C,w]=(0,f.useState)(0),E=(0,f.useRef)(null),D=(0,f.useRef)(null),O=(0,f.useRef)(null),k=(0,f.useRef)(null),A=(0,f.useCallback)(()=>w(e=>e+1),[]);(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?(p(e.value),g(``)):g(e.error.code))}).catch(()=>{t.signal.aborted||g(`unavailable`)}),()=>t.abort()},[e,r,C]),(0,f.useEffect)(()=>{i&&A()},[i,A]);let j=(0,f.useCallback)((e=!0)=>{a(!1),S(``),e&&D.current?.focus({preventScroll:!0})},[a]);(0,f.useEffect)(()=>{if(!i)return;v(``),O.current?.focus({preventScroll:!0});let e=e=>{E.current?.contains(e.target)||j(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[i,j]);let ee=d?.selected??null,M=ee??d?.remembered??null,N=(0,f.useMemo)(()=>{let e=x.trim().toLowerCase(),t=new Map;for(let n of d?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[d,x]),P=d?.entries.find(e=>ka(e,M)),F=async(t,r)=>{if(!d||!t.api||y||n)return;let i=ce({provider:t.provider,model:t.model,api:t.api,thinking:r});if(ee&&Oa(ee,i))j(),s?.();else{b(!0),v(``);try{let t=await e.chooseModel({expected:d.version,choice:i});if(t.kind===`error`){v(t.error.code),A();return}p({...d,version:t.value.version,selected:t.value.selected}),o(),j(),s?.()}catch{v(`uncertain`),A()}finally{b(!1)}}},I=()=>[...k.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],L=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=I(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?O.current?.focus():t[Math.min(n,t.length-1)]?.focus()},R=!t||!d&&!!m,z=d?M?u(M):l(`Choose a model`):l(m?`Model unavailable`:`Model`);return(0,h.jsxs)(`div`,{className:`model-picker`,ref:E,children:[(0,h.jsxs)(`button`,{ref:D,type:`button`,className:`model-trigger${M&&!ee?` remembered`:``}${d&&!M?` empty`:``}`,"aria-label":l(`Model: {model}`,{model:z}),"aria-haspopup":`dialog`,"aria-expanded":i,disabled:!t,title:n?l(`Switch models after the current reply finishes.`):M&&!ee?l(`Last used model; it is used again when you send.`):M?`${M.provider}/${M.model} · ${M.api}`:void 0,onClick:()=>i?j():a(!0),children:[(0,h.jsx)(Mr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:z}),(0,h.jsx)(Lr,{"aria-hidden":`true`})]}),i&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":l(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),j())},children:[c&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:l(`Choose a model; your message is sent right after.`)}),(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(hr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:O,type:`search`,"aria-label":l(`Search models`),placeholder:l(`Search models…`),value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),I()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),I()[0]?.click())}})]}),(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":l(`Models`),ref:k,onKeyDown:L,children:[!d&&!m&&(0,h.jsx)(`p`,{className:`model-empty`,children:l(`Reading models…`)}),N.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=ka(e,M);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`model-option`,disabled:!t||y||n,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void F(e,Aa(e,M?.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`?l(`Credentials unavailable`):l(`Not supported`)}),r&&!ee&&(0,h.jsx)(`span`,{className:`model-option-note`,children:l(`Used when you send`)}),r&&(0,h.jsx)(Rr,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),d?.status===`complete`&&N.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:x.trim()?l(`No matching models.`):l(`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),P&&P.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:l(`Thinking`)}),P.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":l(`Thinking level: {level}`,{level:l(Ea[e.level])}),"aria-pressed":M?.thinking===e.level,disabled:!e.selectable||y||n,onClick:()=>void F(P,e.level),children:l(Ea[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[n&&(0,h.jsx)(`p`,{children:l(`Switch models after the current reply finishes.`)}),d?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:l(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!d?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:l(d.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:d.withheld})}),m&&(0,h.jsxs)(`p`,{role:`alert`,children:[l(`The model list could not be read ({code}).`,{code:m}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:A,children:l(`Read again`)})]}),_&&(0,h.jsx)(`p`,{role:`alert`,children:Da[_]?l(Da[_]):l(`The model was not changed ({code}).`,{code:_})}),!R&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:l(y?`Switching model…`:`Every conversation in this project uses this model.`)})]})]})]})}var Na=/^\s{0,3}(`{3,}|~{3,})/,Pa=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Fa(e){return e.trim()===``}function Ia(e){let t=Na.exec(e);return t?t[1]:null}function La(e){let t=e.split(`
|
|
12
|
+
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Ia(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Ia(a);if(o&&!Fa(a))i=o,r.push(a);else if(Fa(a)){let i=e;for(;i<t.length&&Fa(t[i]);)i++;if(!(i<t.length&&Pa.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
13
13
|
`)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
|
|
14
|
-
`),inFence:i!==null}}function
|
|
15
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}var
|
|
16
|
-
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":t(`Conversation turn`),children:[e.items.filter(e=>e.role===`user`).map(e=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:t(`You`)}),(0,h.jsx)(
|
|
17
|
-
`)}),![`completed`,`running`,`queued`].includes(e.status)&&(0,h.jsx)(`p`,{className:`ep-state ${e.status}`,children:n(e.status)})]})}function
|
|
18
|
-
`:``}@${l}`),u(),fe.current?.focus())},[l,u]),(0,f.useEffect)(()=>{let e=H?.summary?`${H.summary.head}:${H.summary.status}`:``;e&&_e.current!==e&&(_e.current=e,c()),ie.current&&W?.runs.includes(ie.current)&&(ie.current=``,re(``),A(``)),j&&H?.turns.some(e=>e.id===j)&&(M(``),x(e=>e===ve.current?``:e),c()),J.current&&pe.current&&(pe.current.scrollTop=pe.current.scrollHeight)},[H,j,c,W]),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${v}:approval`)}catch{}},[v]);let ye=JSON.stringify(W?.runs.slice(-4)??[]);(0,f.useEffect)(()=>{m?.(JSON.parse(ye))},[ye,m]);let be=async()=>{if(!W?.proposal){A(g(`No plan is awaiting approval.`));return}if(!te||!oe||se||ne||!ue)return;let t=W;O(!0),A(``);try{let n=await la({client:e,state:t,current:()=>Y.current&&K.current?.revision===t.revision&&K.current?.enabled===!0,submitting:e=>{ie.current=e,re(e)}});if(!Y.current)return;n.kind===`error`?(A(n.error.code),re(``)):x(e=>da(e)?``:e)}catch(e){Y.current&&A(e instanceof Error?e.message:`unavailable`)}finally{Y.current&&(O(!1),U.refresh(),V.refresh(),c())}},xe=async n=>{let r=n??y;if(!(G&&ua(r)?le:oe)||se||!r.trim()||w!==null)return;if(!n&&G&&da(r)){await be();return}let i=Jr(r,S).mode===`cadence`;if((G||i)&&!te)A(g(`Cadence state unavailable. Observe the conversation before sending.`));else if(!ce||G&&q?.status!==`unknown`){O(!0),A(``);try{if(G&&ua(r)&&W){let n=crypto.randomUUID();ve.current=r,M(n);let i=await e.workbenchCommand({kind:`cadence-exit`,commandId:n,conversationId:t,head:q?.head??null,revision:W.revision});if(!Y.current)return;i.kind===`error`?(A(i.error.code),i.error.effect===`none`&&M(``)):(M(``),C(`chat`),x(e=>e===r?``:e)),U.refresh(),V.refresh(),c();return}let n=()=>{I(!0),P(!0)},a=await e.models();if(!Y.current)return;if(a.kind===`ok`&&!a.value.selected&&a.value.remembered){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:a.value.version.epoch});if(!Y.current)return;if(t.kind===`error`){A(t.error.code),n();return}if(a=await e.models(),!Y.current)return;B(e=>e+1)}if(a.kind!==`ok`||!a.value.selected){n();return}let o={commandId:crypto.randomUUID(),conversationId:t,head:q?.head??null,text:r,model:a.value.version},s=(G||i)&&W?{kind:`cadence-send`,...o,revision:W.revision,intent:ua(r)?`exit`:G?`message`:`enter`}:{kind:`send`,...o};In(s),ve.current=r,M(s.commandId);let l=await e.workbenchCommand(s);if(!Y.current)return;l.kind===`error`?(A(`${l.error.code}. ${g(`Observe this send before sending again. No automatic retry.`)}`),l.error.effect===`none`&&M(``)):(x(e=>e===ve.current?``:e),M(``),s.kind===`cadence-send`&&C(`chat`)),U.refresh(),V.refresh(),c()}catch{Y.current&&A(g(`Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.`))}finally{Y.current&&O(!1)}}},Se=(0,f.useRef)(xe);Se.current=xe,(0,f.useEffect)(()=>{L&&oe&&!se&&(R(!1),Se.current())},[L,oe,se]),(0,f.useEffect)(()=>{if(!L)return;let e=setTimeout(()=>R(!1),1e4);return()=>clearTimeout(e)},[L]);let Ce=async()=>{let n=H?.turns.find(e=>e.id===q?.head);if(!n||D)return;O(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.id,epoch:n.epoch});Y.current&&(r.kind===`error`&&A(r.error.code),O(!1),V.refresh())};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:d,"aria-label":g(G?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(br,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:q?.title??g(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(G?`Cadence on`:`Ordinary`)})]}),q&&(0,h.jsx)(`span`,{className:`ep-state ${q.status}`,children:G?se?g(`Discussing`):ce?_(q.status):W?.proposal?g(`Awaiting plan approval`):g(`Ready for conversation`):_(q.status)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:pe,onScroll:()=>{let e=pe.current;e&&!d&&(me.current=e.scrollTop,J.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,ge(!J.current))},children:[!q&&(0,h.jsx)(Ga,{hint:g(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),H?.before&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{J.current=!1,E(H.before)},children:g(`Earlier messages`)}),w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{J.current=!0,E(null)},children:g(`Latest messages`)}),H?.turns.map(e=>(0,h.jsx)(Wa,{turn:e},e.id)),W&&(0,h.jsx)(Ka,{client:e,state:W,canApprove:oe&&te&&ue&&!se&&!ne&&w===null,approvalHint:de,onApprove:()=>void be(),onOpenAgent:p,onChanged:()=>{U.refresh(),c()}}),W?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_(W.notice)}),(k||V.error||U.error)&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(g,k||V.error||U.error||``)}),j&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[g(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:j}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:V.refresh,children:g(`Observe current state`)})]}),ce&&G&&q?.status!==`unknown`&&(0,h.jsx)(`p`,{className:`inspector-note`,children:g(`The last turn did not complete. A new message continues from the last complete checkpoint; incomplete work is not replayed.`)}),ce&&!G&&(0,h.jsx)(`p`,{className:`inspector-note`,children:g(`This turn has no complete continuation context. Start a new conversation; retained messages are preserved.`)})]}),he&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":g(`Latest messages`),onClick:()=>{pe.current&&(pe.current.scrollTop=pe.current.scrollHeight),J.current=!0},children:(0,h.jsx)(Vr,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onSubmit:e=>{e.preventDefault(),xe()},children:[(0,h.jsx)(`textarea`,{ref:fe,disabled:!r&&!(G&&a)||!H||!ee||!!V.error||D||!!j,"aria-label":g(`Message`),value:y,placeholder:g(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),xe())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${G||ae.mode===`cadence`?` on`:``}`,"aria-label":g(`Cadence mode`),"aria-pressed":G||ae.mode===`cadence`,disabled:G?!le:se||D,title:G?g(`Cadence mode is on. Click to exit it.`):ae.mode===`cadence`?g(`Your next message turns on Cadence mode. Click to cancel.`):g(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{G?xe(`exit cadence`):ae.mode===`cadence`?(C(`chat`),Jr(y,`chat`).mode===`cadence`&&x(ae.text)):C(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(va,{client:e,enabled:o&&i,locked:!!se,refresh:String(z),open:N,onOpenChange:e=>{P(e),e||I(!1)},onChanged:s,onChosen:()=>{F&&(I(!1),A(``),R(!0))},awaitingSend:F}),(0,h.jsx)(`span`,{className:`composer-hint`,children:G?g(`Cadence stays on. Confirm one plan before implementation.`):ae.mode===`cadence`?g(`Your next message turns on Cadence mode.`):``}),se?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:D||!a,onClick:()=>void Ce(),children:[(0,h.jsx)(mr,{}),g(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(G&&ua(y)?le:oe)||!y.trim()||ce&&(!G||q?.status===`unknown`)||w!==null,children:[(0,h.jsx)(Br,{}),g(`Send`)]})]})]})]})}function Za({client:e,enabled:t,onReference:n}){let{t:r}=T(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(``),u=qr(e,t?{kind:`files`,path:i}:null),d=qr(e,t&&o?{kind:`file`,path:o}:null),p=u.value?.kind===`files`?u.value:void 0,m=d.value?.kind===`file`?d.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":r(`Parent folder`),disabled:p?.parent==null,onClick:()=>{p?.parent!=null&&a(p.parent)},children:(0,h.jsx)(Br,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:i,children:i||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":r(`Refresh files`),onClick:()=>{u.refresh(),d.refresh()},children:(0,h.jsx)(_r,{})})]}),u.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:u.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":r(`File list`),children:[p?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${o===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?a(e.path):s(e.path),children:[e.directory?(0,h.jsx)(Or,{}):(0,h.jsx)(kr,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":r(`Reference {path}`,{path:e.name}),onClick:()=>n(e.path),children:(0,h.jsx)(vr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":r(`Copy path {path}`,{path:e.name}),onClick:()=>void si(e.path).then(e=>l(e?``:r(`Link copy unavailable.`))),children:(0,h.jsx)(Pr,{})})]},e.path)),p?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:r(`No visible files`)}),p?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`Bounded listing; narrow the directory to see more.`)})]}),o&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:o,children:o}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":r(`Close preview`),onClick:()=>s(null),children:(0,h.jsx)(fr,{})})]}),d.error&&(0,h.jsx)(`p`,{role:`alert`,children:d.error}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:m.text}),m.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`File preview is limited; this is not the complete file.`)})]})]}),c&&(0,h.jsx)(`p`,{role:`alert`,children:c}),(0,h.jsx)(`p`,{className:`files-policy`,children:r(`Readonly preview · references send paths, not file contents`)})]})}var Qa=`未命名章节`;function $a(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 eo(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=$a(r||Qa),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Qa}})}function to(e){return e.length>=2}function no(e){let t=0,n=0;return e.split(`
|
|
19
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function
|
|
20
|
-
`);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=
|
|
21
|
-
`):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:[to(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)(bi,{text:e})})]}):n===`diff`?(0,h.jsx)(ro,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:no(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 ao({client:e,seed:t}){let{t:n,tx:r}=T(),i=ii(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(ji,{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(ni(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)(Ai,{client:e,cursor:a,render:e=>(0,h.jsx)(io,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var oo=[`contents`,`checks`,`changes`,`reviews`];function so(){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 co({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:oo.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)(Mi,{client:e,seed:t}):(0,h.jsx)(ao,{client:e,seed:{...t,reader:i}},i)})]})}var lo={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.`},uo=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function fo(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 po({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[]}){let{t:c,tx:l}=T(),[u,d]=(0,f.useState)(),[p,m]=(0,f.useState)(n??t),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(!0),[S,C]=(0,f.useState)(!0),[w,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),j=(0,f.useRef)(n??t),M=(0,f.useRef)(null),N=(0,f.useRef)(null),P=async t=>{A.current?.abort();let n=new AbortController;A.current=n,x(!0),O(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&k.current){if(A.current=void 0,x(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),m(r.value.path),_(!1),y(``),r.value;O({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},F=(0,f.useRef)(P);(0,f.useEffect)(()=>(k.current=!0,F.current(j.current).then(()=>{k.current&&C(!1)}),()=>{k.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{g&&M.current?.select()},[g]),(0,f.useEffect)(()=>{N.current&&(N.current.scrollLeft=N.current.scrollWidth)});let I=e=>{w||P(e)},L=()=>{let e=p.trim();w||(uo(e)?P(e):O({step:`read`,code:`relative`}))},R=(g||!u)&&p.trim()||u?.path||``,z=!w&&!b&&!!R,B=async n=>{if(w||!n||b&&n===u?.path)return;if(n!==u?.path&&!uo(n)){O({step:`read`,code:`relative`});return}E(!0),O(null);let r=n===u?.path?u.path:(await P(n))?.path;if(!k.current)return;if(!r){E(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),k.current&&a()}catch(e){k.current&&(O({step:`open`,code:e instanceof Error?e.message:`unavailable`}),E(!1))}return}if(!e.workbenchCommand){O({step:`open`,code:`unavailable`}),E(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(k.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(O({step:`open`,code:`unsupported-context`}),E(!1))}else O({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),E(!1)}},V=u?fo(u.path,r):void 0,H=v.trim().toLowerCase(),U=u?.entries.filter(e=>e.name.toLowerCase().includes(H))??[],W=D&&(D.step===`read`&&lo[D.code]?c(lo[D.code]):l(D.code));return(0,h.jsxs)(Ri,{title:c(`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:c(`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":c(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:c(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:c(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:w,onClick:()=>e.current?a():void B(e.path),children:[(0,h.jsx)(Or,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[V&&!g?(0,h.jsxs)(`nav`,{ref:N,className:`cwd-crumbs`,"aria-label":c(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":c(`Home folder`),title:c(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:w,onClick:()=>I(`~`),children:[(0,h.jsx)(Tr,{"aria-hidden":`true`}),V.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),V.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||V.inside)&&(0,h.jsx)(Lr,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:w,onClick:()=>I(e.path),children:e.name})]},e.path))]}):S?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),L()},children:(0,h.jsx)(`input`,{ref:M,"aria-label":c(`Folder path`),placeholder:c(`Type or paste a path, then press Enter`),value:p,disabled:w,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{m(e.target.value),D?.step===`read`&&O(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),_(!1),m(u.path),O(null))}})}),u&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":c(`Edit path`),title:c(`Edit path`),"aria-pressed":g,disabled:w,onClick:()=>{m(u.path),_(!g),O(null)},children:(0,h.jsx)(jr,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(gr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":c(`Filter folders`),placeholder:c(`Filter this folder…`),value:v,disabled:w,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":b||void 0,children:[b&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:c(`Reading folder…`)}),u?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:w,onClick:()=>I(u.parent),children:[(0,h.jsx)(Br,{}),c(`Parent folder`)]}),U.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:w,onClick:()=>I(e.path),children:[(0,h.jsx)(Or,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),u&&!b&&U.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:c(H?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:c(`Bounded listing; narrow the directory to see more.`)}),W&&(0,h.jsxs)(`p`,{role:`alert`,children:[W,D?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,c(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[R&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:c(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:R})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!z,onClick:()=>void B(R),children:c(w?`Opening folder…`:`Open this folder`)})]})]})}function mo(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 ho({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)(vr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function go({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)(Rr,{"aria-hidden":`true`}):(0,h.jsx)(Lr,{"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 _o({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=mo(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)(Lr,{"aria-hidden":`true`}):(0,h.jsx)(Rr,{"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)(Nr,{"aria-hidden":`true`}):(0,h.jsx)(br,{"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 vo({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)(_o,{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)(ji,{pager:e,compact:!0})]})}function yo({client:e,workspace:t,taskId:n,scope:r,runs:i,snapshot:a,activeRuns:o,cancelCompatible:s,canceling:c,onCancel:l,onTask:u,onScope:d,chats:p=[],conversationId:m,onConversation:g,onNewConversation:_,workflows:v,workflowLinks:y=[],workflowError:b=!1,selectedWorkflow:x,onWorkflow:S,onCancelWorkflow:C}){let{t:w,tx:E}=T(),D={reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50},O=ii(e,D),k=ii(e,n?{...D,reader:`runs`,scope:{kind:`task`,id:n},snapshotSeq:a??t.committedSeq}:null),A=O.page&&!(`kind`in O.page)?O.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],j=o?.status===`complete`?o.runs:[],M=A.filter(e=>!j.some(t=>t.taskId===e.owner.taskId)),N=n&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":w(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:w(`Task conversations`)}),(0,h.jsx)(vo,{pager:k,scope:r,onScope:d,exclude:j.map(e=>e.runId)},n)]}),[P,F]=(0,f.useState)(()=>new Set),I=e=>{let t=y.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${x===e.id||t&&t===m?` active`:``}`,onClick:()=>S?.(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:[w(`Cadence workflow`),` · `,E(e.phase),` · `,E(e.status)]})]})]}),C&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:P.has(e.id),onClick:()=>{F(t=>new Set(t).add(e.id)),C(e).finally(()=>F(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),w(`Cancel workflow — request stop`)]})]},e.id)},L=p.filter(e=>e.status===`running`||e.status===`queued`),R=p.filter(e=>!L.includes(e)),z=e=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===m?` active`:``}`,onClick:()=>g?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(br,{})}),(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.cadence?w(`Cadence on`):w(`Ordinary`),` ·`,` `,e.cadence&&[`running`,`queued`].includes(e.status)?w(`Discussing`):e.cadence&&e.status===`completed`?w(`Ready for conversation`):E(e.status)]})]})]},e.id);return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(ho,{onConversation:_}),(0,h.jsxs)(go,{title:w(`Running conversations`),count:o?.status===`complete`&&v&&!b?String(j.length+L.length+v.length):`?`,className:`running-conversations`,children:[o?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:w(`Active roster unavailable; absence is not proof of settlement.`)}),b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:w(`Workflow activity unavailable; retained work may still be running.`)}),L.map(z),v?.map(I),o?.status===`complete`&&j.length===0&&L.length===0&&v?.length===0&&!b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:w(`No active runs`)}),j.map(e=>{let t=A.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${n===e.taskId&&r?.kind===`task`?` active`:``}`,onClick:()=>u(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??w(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[E(e.kind),` · `,E(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!s||c.has(e.runId),onClick:()=>l(e.runId),children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),w(`Cancel run — request stop`)]}),n===e.taskId&&(0,h.jsx)(_o,{runs:i.filter(t=>t.runId===e.runId),scope:r,onScope:d})]},e.runId)})]}),(0,h.jsxs)(go,{title:w(`Conversation history`),count:O.page&&!(`kind`in O.page)?`${R.length+M.length}${O.page.next||O.canPrevious?`+`:``}`:`?`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":w(`Tasks`),className:`task-list`,children:[R.map(z),M.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===n&&r?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===n&&r?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>u(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(br,{"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:w(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===n&&N]},e.owner.taskId)),O.page&&!(`kind`in O.page)&&M.length===0&&R.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:w(`No conversations yet.`)}),(0,h.jsx)(ji,{pager:O,compact:!0})]}),!M.some(e=>e.owner.taskId===n)&&N]})]})}var bo=[`queued`,`running`];function xo({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=qr(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?bo.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!bo.includes(u.status)&&c(0)},[u]);let m=qr(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,[_,v]=(0,f.useState)(!1),y=qr(e,_&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),b=(0,f.useRef)(null),x=(0,f.useRef)(!0),S=g?.items.length??0;return(0,f.useEffect)(()=>{S&&x.current&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[S]),(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)(Nr,{"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:b,onScroll:e=>{let t=e.currentTarget;x.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&&(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)(Ja,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(g?(0,h.jsx)(Wa,{turn:g}):(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)(bi,{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:()=>v(!0),children:a(`Read retained step result`)}),_&&y.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),_&&y.error&&(0,h.jsx)(`p`,{role:`alert`,children:y.error})]})]})]})}function So({client:e,onOpen:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),p=qr(e,i?{kind:`workflow-history`,after:o,...c?{scan:c}:{}}:null),m=p.value?.kind===`workflow-history`?p.value:void 0,g=p.value?.kind===`workflow-history-progress`?p.value:void 0,_=p.error??(g&&g.after!==o?`invalid`:void 0);return(0,h.jsxs)(`details`,{className:`lp-section workflow-history`,onToggle:e=>{a(e.currentTarget.open),e.currentTarget.open||l(void 0)},children:[(0,h.jsx)(`summary`,{className:`lp-section-heading`,children:n(`Workflow history`)}),i&&(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`ID order; refresh to observe new runs. Unreadable records are not removed.`)}),_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),!m&&!g&&!_&&(0,h.jsx)(`p`,{children:n(`Reading…`)}),g&&!_&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{children:n(`Scanning retained workflow IDs; no complete page yet.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:p.loading,onClick:()=>l(g.scan),children:n(`Continue reading history`)})]}),m?.entries.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,onClick:()=>t({runId:e.id,stepId:null,label:e.run?.goal||e.id}),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.run?.goal||e.id}),(0,h.jsx)(`span`,{className:`session-sub`,children:r(e.run?.status??`unavailable`)})]})},e.id)),m&&!_&&m.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`No retained workflows on this page.`)}),(0,h.jsxs)(`div`,{className:`page-controls`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:!u.length,onClick:()=>{l(void 0),s(u.at(-1)??null),d(u.slice(0,-1))},children:n(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!m?.next||!!_||p.loading,onClick:()=>{m?.next&&(l(void 0),d([...u,o]),s(m.next))},children:n(`Next`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{l(void 0),p.refresh()},children:n(`Observe current state`)})]})]})]})}function Co({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)(Or,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(Rr,{"aria-hidden":`true`})]})}function wo(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Fi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:U(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,G(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function To(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=U(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(ne(r)):void 0,o=i?G(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(ne(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function Eo(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 Do({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=Eo({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 Oo(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 ko=.4,Ao=1.05;function jo(e){return Math.min(300,e*.86)}function Mo(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function No(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Po(e,t){return e===`left`?t:-t}function Fo(e,t){return Math.max(-e,Math.min(0,-e+t))}function Io(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Lo(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Io(r*Ao,n,t)>=ko}var Ro=new Set([`auto`,`scroll`,`overlay`]);function zo(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Ro.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Bo(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Vo(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=Mo(r.clientX,window.innerWidth,n);i&&!zo(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=No(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=jo(window.innerWidth),h=m*Ao;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=Po(r,d);let b=Fo(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Io(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Lo({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Bo(),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 Ho(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 Uo=`modulepreload`,Wo=function(e){return`/`+e},Go={},Ko=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=Wo(t,n),t=s(t),t in Go)return;Go[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`:Uo,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 qo({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=ii(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)(ji,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Jo,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Jo({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 Ko(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Ho(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)(Mi,{client:e,seed:t})]})}function Yo(){let e=new URLSearchParams(window.location.hash?.slice(1)).get(`chat`);return e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(e)?e:null}var Xo=[[`tools`,pr],[`context`,wr],[`timeline`,Fr],[`runs`,Dr]];function Zo({error:e,observationError:t}){let{t:n,tx:r}=T();return!e&&!t?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[n(`{message}.`,{message:r(t)}),` `,t===`stale`?n(`Context changed. Observe again and request a fresh confirmation.`):(0,h.jsx)(x,{text:n(`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 Qo({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a}){let{t:o,tx:s,locale:c,setLocale:l}=T(),[u]=(0,f.useState)(()=>e??Gr()),[d,p]=(0,f.useState)(!1),[m]=(0,f.useState)(To),[g,_]=(0,f.useState)(m?.taskId??null),[v,y]=(0,f.useState)(()=>m?null:Yo()??crypto.randomUUID()),[b,S]=(0,f.useState)(null),[C,w]=(0,f.useState)([]),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(m?`task`:`files`),[A,j]=(0,f.useState)(),M=(0,f.useCallback)(()=>j(void 0),[]),[N,P]=(0,f.useState)(m?m.scope??{kind:`task`,id:m.taskId}:null),F=Zr(u,g?{kind:`task`,id:g}:null,!d),I=(0,f.useRef)(null);F.workspace&&(I.current=F.workspace.workspaceId);let L=qr(u.client,F.workspace&&!d?{kind:`conversations`}:null,2e3),R=qr(u.client,F.workspace&&!d?{kind:`workflow-active`}:null,2e3),z=R.value?.kind===`workflow-active`?R.value:void 0,B=(0,f.useMemo)(()=>[...new Set([...z?.runs.map(e=>e.id)??[],...C])],[z,C]),V=qr(u.client,F.workspace&&!d?{kind:`projects`}:null),H=(V.value?.kind===`projects`?V.value.entries.find(e=>e.current)?.path:void 0)??F.workspace?.rootLabel,U=qr(u.client,g&&F.workspace&&!d?{kind:`task-origin`,taskId:g}:null),W=U.value?.kind===`task-origin`?U.value.conversationId:null,G={state:F.observation,transportStatus:F.transportStatus,error:F.error,refresh:F.refresh},ee=G.state?.snapshot.scope.kind===`task`&&G.state.snapshot.scope.id===g?G.state.snapshot.context:void 0,[te,ne]=(0,f.useState)(null),[re,ie]=(0,f.useState)(!1),ae=(0,f.useRef)(null),[oe,q]=(0,f.useState)(260),[se,ce]=(0,f.useState)(360),le=(0,f.useCallback)(()=>ne(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>ie(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Vo({enabled:re&&!d,open:te,onOpenChange:ne,container:ae}),Oo(ae,te,re&&!d,le);let[ue,de]=(0,f.useState)(m?.snapshotSeq),[fe,pe]=(0,f.useState)(``),[me,J]=(0,f.useState)(``),[he,ge]=(0,f.useState)(!0),Y=(0,f.useRef)(null),_e=(0,f.useRef)(null),ve=()=>{_e.current&&(_e.current.open=!1)},[ye,be]=(0,f.useState)(`messages`),[xe,Se]=(0,f.useState)(!1),[Ce,we]=(0,f.useState)(!1),[X,Te]=(0,f.useState)(),[Ee,De]=(0,f.useState)(m?.cursor),[Oe,ke]=(0,f.useState)(``),[Ae,je]=(0,f.useState)([]),[Me,Ne]=(0,f.useState)(new Set),Pe=(0,f.useRef)(!0),Fe=e=>{Pe.current&&je(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Kr(t,e):t)})},Ie=(0,f.useRef)(new Qr),Le=K({taskId:g,scope:N,selectedSnapshot:ue??null,detached:d,attachment:F.attachmentVersion,workspaceContext:F.workspace?.context??null,observationError:F.error??null});Ie.current.select(Le),(0,f.useEffect)(()=>(Pe.current=!0,()=>{Pe.current=!1,Ie.current.depart()}),[]);let Re=(e=crypto.randomUUID())=>{S(null),e!==v&&w([]),Ie.current.depart(),y(e),_(null),P(null),pe(``),J(``),Te(void 0),De(void 0),de(void 0),be(`messages`),k(`files`),le(),history.replaceState(null,``,`${location.pathname}${location.search}#chat=${e}`)};(0,f.useEffect)(()=>{v&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${v}`)},[v]);let ze=(e,t)=>{S(null),w([]),y(null),k(`task`),pe(t??``),J(``),de(void 0),Ie.current.depart(),_(e),P({kind:`task`,id:e}),Te(void 0),De(void 0),be(`messages`),le(),history.replaceState(null,``,wo(e))};(0,f.useEffect)(()=>{let e=()=>{let e=To();if(e)S(null),w([]),y(null),k(`task`),Ie.current.depart(),de(e.snapshotSeq),pe(``),J(``),_(e.taskId),P(e.scope??{kind:`task`,id:e.taskId}),Te(void 0),De(e.cursor),be(`messages`),le();else{let e=Yo();e&&(S(null),w([]),y(e),_(null),P(null),k(`files`),Ie.current.depart(),le())}};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[le]);let Be=(e,t,n)=>{S(null),de(t),J(n??``),Ie.current.depart(),P(e),Te(void 0),De(void 0),be(`messages`),le(),g&&history.replaceState(null,``,wo(g,void 0,{scope:e,snapshotSeq:t}))},Ve=ue??G.state?.snapshot.committedSeq??F.workspace?.committedSeq,He=F.workspace?.storeId,Ue=N&&He&&Ve?{storeId:He,scope:N,snapshotSeq:Ve,reader:`messages`,after:null,limit:50}:null,We=N&&He&&Ve?{storeId:He,scope:N,snapshotSeq:Ve,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,Ge=ee?G.state?.snapshot.runs??[]:[],Ke=Ie.current.ticket(),qe=e=>{Fe(e),e.receipt&&Ie.current.current(Ke)&&F.refresh()},Je=e=>{if(Me.has(e)||!F.cancelCompatible||!F.activeRuns)return;let t=crypto.randomUUID(),n=F.activeRuns.epoch;Ne(t=>new Set(t).add(e)),Fe({commandId:t,error:o(`Stop requested; settlement is not yet confirmed.`)}),u.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{qe(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:o(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>Fe({commandId:t,error:o(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Pe.current&&Ne(t=>{let n=new Set(t);return n.delete(e),n})})};if(d)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:o(`Detached`)}),(0,h.jsx)(`p`,{children:o(`Accepted service work continues. No Cancel was requested.`)}),Ae.map(e=>(0,h.jsxs)(`p`,{children:[o(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>p(!1),children:o(`Reconnect as a viewer`)})]});let Ye=F.activeRuns,Xe=Ye?.status===`complete`?Ye.runs:[],Ze=G.state?.connection??(F.workspace?g?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${he?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":o(`Tasks`),onClick:()=>ne(e=>e===`left`?null:`left`),children:(0,h.jsx)(xr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":o(`Workbench projects`),title:o(`Workbench projects`),onClick:n,children:(0,h.jsx)(Or,{})}),(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`}),N&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":o(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":ye===`messages`&&!Ee,onClick:()=>{De(void 0),Te(void 0),be(`messages`)},children:[(0,h.jsx)(br,{"aria-hidden":`true`}),o(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:Y,onKeyDown:e=>{e.key===`Escape`&&Y.current&&(Y.current.open=!1,Y.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[ye===`messages`?o(`Details`):s(ye),(0,h.jsx)(Rr,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Xo.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":ye===e,onClick:()=>{De(void 0),Te(void 0),be(e),Y.current&&(Y.current.open=!1,Y.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),s(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":o(`Export selected scope`),disabled:!Ue,onClick:()=>{Y.current&&(Y.current.open=!1,Y.current.querySelector(`summary`)?.focus()),we(!0)},children:[(0,h.jsx)(Mr,{"aria-hidden":`true`}),o(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":o(`Copy token-free link`),disabled:!g,onClick:()=>{g&&si(wo(g,Ee,N?{scope:N,snapshotSeq:ue}:void 0)).then(e=>ke(e?``:o(`Link copy unavailable.`)))},children:[(0,h.jsx)(Cr,{"aria-hidden":`true`}),o(`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)(qi,{disabled:!We,onOpen:()=>Se(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:c===`zh`?`en`:`zh-CN`,"aria-label":c===`zh`?`Switch to English`:`切换到中文`,"data-tip":c===`zh`?`Switch to English`:`切换到中文`,onClick:()=>l(c===`zh`?`en`:`zh`),children:[(0,h.jsx)(Er,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:_e,onKeyDown:e=>{e.key===`Escape`&&_e.current&&(_e.current.open=!1,_e.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":o(`More`),title:o(`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":o(`Observe current state`),onClick:()=>{ve(),F.refresh(),G.refresh()},children:[(0,h.jsx)(_r,{"aria-hidden":`true`}),o(`Refresh status`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":o(`Disconnect this page`),title:o(`Return — accepted work continues`),onClick:()=>{ve(),ne(null),Se(!1),we(!1),Ie.current.depart(),p(!0)},children:[(0,h.jsx)(Sr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[o(`Disconnect this page`),(0,h.jsx)(`small`,{children:o(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${F.compatible?``:` warn`}`,title:Wr?.buildId??o(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:o(`Shared compatibility: {state}.`,{state:F.compatible?o(`compatible`):o(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:o(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Wr?.buildId??o(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":o(`Files / history`),"aria-expanded":re?te===`right`:he,onClick:()=>re?ne(e=>e===`right`?null:`right`):ge(e=>!e),children:[(0,h.jsx)(hr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:o(v?`Files`:`History`)})]})]}),!F.workspace&&Xe.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":o(`Execution and cancellation`),children:Xe.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:[s(e.kind),` `,e.runId,` · `,s(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ze(e.taskId),children:o(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!F.cancelCompatible||Me.has(e.runId),onClick:()=>Je(e.runId),children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),o(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(Zo,{error:Oe,observationError:F.error}),(0,h.jsxs)(`div`,{ref:ae,className:`layout`,style:{"--left-w":`${oe}px`,"--right-w":`${se}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":o(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${te?` on`:``}`,onClick:le}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${te===`left`?` open`:``}`,"aria-label":o(`Task navigation drawer`),tabIndex:-1,inert:re&&te!==`left`,children:[F.workspace&&(0,h.jsx)(yo,{client:u.client,workspace:F.workspace,taskId:g,scope:N,runs:Ge,snapshot:G.state?.snapshot.committedSeq,activeRuns:F.activeRuns,cancelCompatible:!!F.cancelCompatible,canceling:Me,onCancel:Je,chats:L.value?.kind===`conversations`?L.value.entries:[],conversationId:v,onConversation:Re,onNewConversation:()=>Re(),workflows:z?.runs,workflowLinks:z?.links,workflowError:!!R.error,selectedWorkflow:b?.runId,onWorkflow:(e,t)=>{t?Re(t):(S({runId:e.id,stepId:null,label:e.goal}),le())},onCancelWorkflow:async e=>{let t=await qa(u.client,e);t&&ke(t),R.refresh()},onTask:ze,onScope:Be}),F.workspace&&(0,h.jsx)(So,{client:u.client,onOpen:e=>{S(e),le()}}),F.workspace&&(0,h.jsx)(ca,{client:u.client,active:F.activeRuns,taskId:g,runs:Ge,snapshot:Ve,workflowRuns:B,selected:b,onOpenWorkflow:e=>{S(e),le()},onOpen:(e,t,n,r)=>{ze(e),P({kind:`child`,id:t}),J(r),de(n),history.replaceState(null,``,wo(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Do,{side:`left`,width:oe,onResize:q}),(0,h.jsxs)(`main`,{className:`main`,inert:re&&te!==null,children:[b&&(0,h.jsx)(xo,{client:u.client,agent:b,backLabel:o(v?`Back to conversation`:g?`Back to task`:`Back`),onBack:()=>S(null),onOpenAgent:S},`${b.runId}:${b.stepId??``}`),v&&(0,h.jsx)(Xa,{client:u.client,id:v,hidden:!!b,onOpenAgent:S,onWorkflowRuns:w,workspaceId:I.current??`connecting`,available:!!F.workspace,canInterrupt:!!F.cancelCompatible,enabled:!!F.workspace&&!!F.compatible&&!F.error,modelEnabled:!!F.compatible&&F.transportStatus===`current`&&!F.error,onModelChanged:()=>{Ie.current.depart(),F.refresh(!0)},onChanged:()=>{L.refresh(),F.refresh()},reference:A,onReferenceUsed:M},`${I.current??`connecting`}:${v}`),N&&!b&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[N.kind!==`task`&&g&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ze(g,fe),children:o(`Back to task`)}),W&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Re(W),children:o(`Back to ordinary conversation`)}),(0,h.jsx)(`h2`,{title:fe||N.id,children:N.kind===`task`?fe||o(`Task {id}`,{id:N.id.slice(0,8)}):me||o(`{kind} {id}`,{kind:s(N.kind),id:N.id.slice(0,8)})}),N.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:o(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[o(`Recorded conversation`),` ·`,` `,o(`snapshot {seq}`,{seq:Ve??``})]}),(0,h.jsx)(`code`,{children:N.id}),(0,h.jsx)(`p`,{children:o(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!v||!!b,children:[!Ue&&(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:o(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:o(`History is readonly. Start new work in a conversation with /cadence.`)})]}),Ue&&Ee?(0,h.jsxs)(`div`,{className:`tab-body`,children:[X&&(X.owner.entity.kind===`task`||X.owner.entity.kind===`message`||X.owner.entity.kind===`tool`)&&(0,h.jsx)(Ni,{client:u.client,seed:{storeId:Ee.storeId,scope:Ee.scope,snapshotSeq:Ee.snapshotSeq,kind:X.owner.entity.kind,id:X.owner.entity.id,version:X.owner.entity.version}},`${X.owner.entity.id}:${X.owner.entity.version}`),(0,h.jsx)(Ai,{client:u.client,cursor:Ee,highlight:X?.range},`${Ee.recordId}:${Ee.recordVersion}`)]}):Ue&&(0,h.jsxs)(`div`,{className:ye===`messages`||ye===`tools`?`tab-body transcript-body`:`tab-body`,children:[ye===`messages`&&(0,h.jsx)(na,{client:u.client,seed:Ue}),ye===`tools`&&(0,h.jsx)($o,{client:u.client,seed:Ue}),ye===`context`&&(0,h.jsx)(Mi,{client:u.client,seed:Ue}),ye===`timeline`&&(0,h.jsx)(qo,{client:u.client,seed:Ue,onSearch:()=>Se(!0)}),ye===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:o(`Runs in the current snapshot`)}),Ge.length>0?Ge.map(e=>(0,h.jsx)(Ui,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:ee&&G.state?o(`No owner run projection in this snapshot.`):o(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:o(`Retained runs`)}),(0,h.jsx)(Ki,{client:u.client,seed:{...Ue,scope:{kind:`task`,id:g??Ue.scope.id}},onScope:Be},g)]})]},`${N?.kind}:${N?.id}:${ue??`current`}`)]}),F.workspace&&Ae.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Ae.map(e=>(0,h.jsx)($r,{client:u.client,value:e,onChange:Fe},e.commandId))})]}),(0,h.jsx)(Do,{side:`right`,width:se,onResize:ce}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${te===`right`?` open`:``}`,"aria-label":o(`Files and history drawer`),tabIndex:-1,inert:re&&te!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":o(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":O===`files`,onClick:()=>k(`files`),children:[(0,h.jsx)(Or,{}),o(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":O===`task`,disabled:!Ue,onClick:()=>k(`task`),children:[(0,h.jsx)(wr,{}),o(`History details`)]})]}),O===`files`?(0,h.jsx)(Za,{client:u.client,enabled:!!F.workspace,onReference:e=>{v||Re(W??void 0),j(e),le()}}):Ue?(0,h.jsx)(co,{client:u.client,seed:{...Ue,scope:{kind:`task`,id:g??Ue.scope.id}}},g):(0,h.jsx)(so,{})]})})]}),(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:o(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${G.error||!F.workspace?`error`:G.transportStatus===`current`?G.state?G.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),s(Ze),G.transportStatus!==`current`&&o(` · transport {status}`,{status:s(G.transportStatus)}),G.error?` · ${s(G.error)}`:``]}),Ye?.status===`complete`?Xe.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:o(Xe.length===1?`{count} active run`:`{count} active runs`,{count:Xe.length})}):(0,h.jsx)(`span`,{className:`status-item faint`,children:o(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[F.workspace&&(0,h.jsx)(Co,{path:H,onClick:()=>D(``)}),!F.compatible&&(0,h.jsx)(`span`,{className:`status-item warn`,children:o(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),E!==null&&F.workspace&&(0,h.jsx)(po,{onOpen:t,projects:i??(V.value?.kind===`projects`?V.value.entries:[]),client:u.client,current:H??F.workspace.rootLabel,initial:E||void 0,home:r,epoch:F.workspace.epoch,onClose:()=>D(null)}),xe&&We&&(0,h.jsx)(Hi,{client:u.client,seed:We,onClose:()=>Se(!1),onHit:e=>{Te(e),De(e.cursor),g&&history.replaceState(null,``,wo(g,e.cursor,N?{scope:N,snapshotSeq:ue}:void 0))}}),Ce&&We&&(0,h.jsx)(zi,{request:{storeId:We.storeId,scope:We.scope,snapshotSeq:We.snapshotSeq,format:`ndjson`},onClose:()=>we(!1)})]})}function $o({client:e,seed:t}){let n=ii(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(ji,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(ia,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var es=`cadence-last-project`;function ts(){try{let e=localStorage.getItem(es);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function ns(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(es,e)}catch{}}function rs(e){let t=ts();return t?e.projects.find(e=>e.id===t):void 0}async function is(e,t){try{return(await Gr(e).client.workbenchRead({kind:`conversations`},t)).kind===`ok`&&!t.aborted}catch{return!1}}var as=`cadence-recovery-dismissed`,os={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.`},ss={"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 cs(){try{let e=JSON.parse(localStorage.getItem(as)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function ls(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function us({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(cs),[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(as,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:ls(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(os[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(ss[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}function ds({ready:e,projects:t=[],restore:n=null,opening:r=null,onOpenFolder:i,onOpenProject:a,children:o}){let{t:s,locale:c,setLocale:l}=T(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!0),v=(0,f.useRef)(null),y=(0,f.useCallback)(()=>d(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>m(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Vo({enabled:p,open:u,onOpenChange:d,container:v}),Oo(v,u,p,y);let b=e=>{y(),i(e)},x=e=>{y(),a?a(e):i(e)},S=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${g?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":s(`Tasks`),onClick:()=>d(e=>e===`left`?null:`left`),children:(0,h.jsx)(xr,{"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.jsx)(`div`,{className:`tb-actions`,children:(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:c===`zh`?`en`:`zh-CN`,onClick:()=>l(c===`zh`?`en`:`zh`),"aria-label":c===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(Er,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:c===`zh`?`EN`:`中文`})]})})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":s(`Files`),"aria-expanded":p?u===`right`:g,onClick:()=>p?d(e=>e===`right`?null:`right`):_(e=>!e),children:[(0,h.jsx)(hr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:s(`Files`)})]})]}),o,(0,h.jsxs)(`div`,{className:`layout`,ref:v,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":s(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${u?` on`:``}`,onClick:y}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${u===`left`?` open`:``}`,"aria-label":s(`Task navigation drawer`),tabIndex:-1,inert:p&&u!==`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:s(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?s(`Returning to your last project {name}…`,{name:S(n.path)}):n?.status===`stopped`?s(`Your last project {name} is not running. Click it below to open it again.`,{name:S(n.path)}):t.length?s(`Conversations are kept with each project. Click a project to open it.`):s(`Conversations are kept with each project. Open a working folder to see its 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:()=>x(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Or,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:S(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:r===t?s(`Opening…`):t})]})]},t))]})]})})}),(0,h.jsx)(`main`,{className:`main`,inert:p&&u!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":s(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Ga,{hint:s(`Open a working folder to start. Each project keeps its own conversations.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>b(),children:[(0,h.jsx)(Or,{"aria-hidden":`true`}),s(`Open a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":s(`Message`),rows:3,placeholder:s(`Open a working folder to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:s(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(Br,{"aria-hidden":`true`}),s(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${u===`right`?` open`:``}`,"aria-label":s(`Files`),tabIndex:-1,inert:p&&u!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(Or,{"aria-hidden":`true`}),s(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:s(`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:s(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(Co,{disabled:!e,onClick:()=>b()})})]})]})}async function fs(e){return ne(await Qn(e,1048576),1048576)}function ps(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`}function ms(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Fi),[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)(null),y=(0,f.useRef)(new Map),b=(0,f.useRef)(!r),x=(0,f.useRef)(null),S=(0,f.useCallback)(()=>{x.current&&(x.current.abort(),x.current=null,v(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 fs(t);t.status===400&&ps(r)===`invalid`?n(null):t.ok?(n(mn(r)),p(``)):p(ps(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{S(),v(null),i(Fi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[S]),(0,f.useEffect)(()=>{if(!t||!b.current)return;b.current=!1;let e=rs(t);if(!e)return;let n=new AbortController;x.current=n,v({status:`checking`,path:e.cwd}),is(e.id,n.signal).then(t=>{n.signal.aborted||(x.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),v(null),i(e.id)):v({status:`stopped`,path:e.cwd}))})},[t]);let C=(0,f.useCallback)(e=>{S(),v(null),r&&y.current.set(r,window.location.hash),history.pushState(null,``,e?`/app?project=${e.id}${y.current.get(e.id)??``}`:`/app`),i(e?.id??null),o(null)},[r,S]),w=(0,f.useCallback)(async e=>{if(!t||!Wr)throw Error(`unavailable`);let r=crypto.randomUUID(),i=await fetch(`/workbench/v1/open`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t.csrf,"X-Cadence-Build":JSON.stringify({kind:`browser`,...Wr})},body:JSON.stringify({commandId:r,path:e,epoch:t.epoch})}),a=await fs(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(ps(a));let o=ln(a.project);n(e=>e&&{...e,projects:[...e.projects.filter(e=>e.id!==o.id),o]}),C(o)},[t,C]),E=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new j(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await fs(n);if(!n.ok){let e=ps(r);return{kind:`error`,error:M(A.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:zn(r)}}catch{return{kind:`error`,error:M(`unavailable`)}}}}),[]),D=(0,f.useMemo)(()=>r?Gr(r):void 0,[r]),O=t?.projects.find(e=>e.id===r);return(0,f.useEffect)(()=>{O&&ns(O.id)},[O]),t===null?(0,h.jsx)(Qo,{}):t&&O&&D?(0,h.jsx)(Qo,{api:D,onOpenProject:w,onWorkbenchHome:()=>C(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(us,{notices:t.recoveries,project:O.path})},`${O.id}:${O.epoch}`):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(ds,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:_,opening:s,onOpenFolder:e=>{S(),u(``),o(e??t?.home??``)},onOpenProject:t=>{s||(S(),u(``),c(t),w(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)(us,{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&&!O&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.`)})]}),t&&a!==null&&(0,h.jsx)(po,{client:E,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:w})]})}function hs(){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 gs=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(hs,{}):this.props.children}},_s=document.getElementById(`root`);if(!_s)throw Error(`Application root unavailable`);(0,p.createRoot)(_s).render((0,h.jsx)(E,{children:(0,h.jsx)(gs,{children:(0,h.jsx)(ms,{})})}));export{Ko as t};
|
|
14
|
+
`),inFence:i!==null}}function Ra(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 za=(0,f.memo)(function({text:e}){return(0,h.jsx)(Ni,{text:e})}),Ba=22,Va=14,Ha=()=>typeof document<`u`&&document.hidden;function Ua(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||Ha()||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(Ha()){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?Va:Ba;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=Ra(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 Wa=600,Ga=32;function Ka({text:e,inFence:t}){let n=!t&&e.length>=Wa,[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>=Ga)r();else return o.current=setTimeout(r,Ga-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)(Ni,{text:n?r:e})}var qa=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=Ua(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>La(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)(za,{text:e},t)),a.length>0&&(0,h.jsx)(Ka,{text:a,inFence:o},i.length)]})});function Ja(e){let t=e.filter(e=>e.role!==`user`),n=t.findLastIndex(e=>e.role===`tool`),r=e=>e.role===`tool`||e.text.trim()!==``;return{steps:t.slice(0,n+1).filter(r),answer:t.slice(n+1).filter(r)}}function Ya(e){let t;try{t=JSON.parse(e)}catch{return null}return t&&typeof t==`object`&&!Array.isArray(t)?t:null}function Xa(e){let t=Ya(e);if(!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(`
|
|
15
|
+
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}var Za={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},Qa=e=>Object.hasOwn(Za,e)?Za[e]:`other`,$a={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`]},eo=new Set([`read`,`list`,`edit`]);function to(e,t){return eo.has(t)?Xa(e.args)||(t===`list`&&Ya(e.args)?`.`:e.id):e.id}function no({turn:e,steps:t,live:n,answered:r}){let{t:i}=T(),[a,o]=(0,f.useState)(null),s=a??(!n&&!r),c=t.filter(e=>e.role===`tool`),l=c.filter(e=>e.error).length,{thinking:u,media:d,other:p}=e.omitted,m=[u&&i(`Thinking is not retained.`),d&&i(`Media is not retained.`),p&&i(`Other content is not retained.`)].filter(e=>e!==!1),g;if(n){let e=c.at(-1);g=e?`${i(`Working…`)} ${e.name||i(`Tool`)} ${Xa(e.args)}`.trim():i(`Working…`)}else{let e=new Map;for(let t of c){let n=Qa(t.name);e.set(n,(e.get(n)??new Set).add(to(t,n)))}g=[...e].map(([e,t])=>t.size===1?i($a[e][0]):i($a[e][1],{n:t.size})).join(` · `)||(u?i(`Thought`):d?i(`Media not retained`):p?i(`Content not retained`):``)}let _=(0,h.jsxs)(h.Fragment,{children:[n?(0,h.jsx)(`span`,{className:`chat-steps-live`,"aria-hidden":`true`}):(0,h.jsx)(Ir,{className:`chat-steps-chevron`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chat-steps-title`,children:g}),l>0&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:i(`{n} failed`,{n:l})})]});return t.length===0&&m.length===0?(0,h.jsx)(`div`,{className:`chat-steps`,role:`status`,children:(0,h.jsx)(`div`,{className:`chat-steps-head`,children:_})}):(0,h.jsxs)(`details`,{className:`chat-steps`,"aria-label":i(`Working steps`),open:s,onToggle:e=>o(e.currentTarget.open),children:[(0,h.jsx)(`summary`,{className:`chat-steps-head`,children:_}),t.length>0&&(0,h.jsx)(`ol`,{className:`chat-steps-list`,children:t.map(e=>(0,h.jsx)(`li`,{children:e.role===`tool`?(0,h.jsx)(ro,{item:e}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(Pi,{text:e.text})})},e.id))}),m.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function ro({item:e}){let{t}=T(),n=Xa(e.args);return(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsxs)(`summary`,{children:[(0,h.jsx)(`span`,{className:`chat-tool-name`,children:e.name||t(`Tool`)}),n&&(0,h.jsx)(`span`,{className:`chat-tool-target`,title:n,children:n}),e.error&&(0,h.jsx)(`span`,{className:`ep-state failed`,children:t(`failed`)})]}),e.args&&(0,h.jsx)(`pre`,{children:e.args}),e.text&&(0,h.jsx)(`pre`,{children:e.text})]})}function io({turn:e}){let{t,tx:n}=T(),{steps:r,answer:i}=Ja(e.items),a=e.status===`running`&&i.length===0,o=r.length>0||a||Object.values(e.omitted).some(Boolean),s=e.notice.split(`
|
|
16
|
+
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`);return(0,h.jsxs)(`section`,{className:`chat-turn`,"aria-label":t(`Conversation turn`),children:[e.items.filter(e=>e.role===`user`).map(e=>(0,h.jsxs)(`article`,{className:`chat-message user`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:t(`You`)}),(0,h.jsx)(Pi,{text:e.text})]},e.id)),(o||i.length>0)&&(0,h.jsxs)(`article`,{className:`chat-message assistant`,children:[(0,h.jsx)(`div`,{className:`chat-message-role`,children:`Cadence`}),o&&(0,h.jsx)(no,{turn:e,steps:r,live:a,answered:i.length>0}),i.map(t=>e.status===`running`?(0,h.jsx)(qa,{text:t.text},t.id):(0,h.jsx)(Pi,{text:t.text},t.id))]}),s.length>0&&(0,h.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:s.map(e=>n(e)).join(`
|
|
17
|
+
`)}),![`completed`,`running`,`queued`].includes(e.status)&&(0,h.jsx)(`p`,{className:`ep-state ${e.status}`,children:n(e.status)})]})}function ao({client:e,conversationId:t,turn:n}){let{t:r}=T(),[i,a]=(0,f.useState)(null),o=oi(e,i===null?null:{kind:`conversation-transcript`,id:t,turnId:n.id,page:i}),s=o.value?.kind===`conversation-transcript`?o.value:void 0,c=n.transcript?.pages??0;return(0,h.jsxs)(`div`,{children:[c>0&&(0,h.jsx)(`nav`,{"aria-label":r(`Turn transcript`),children:i===null?(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(0),children:r(`Full transcript ({pages} pages)`,{pages:c})}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,disabled:i===0||o.loading,onClick:()=>a(i-1),children:r(`Previous page`)}),(0,h.jsx)(`span`,{children:r(`Transcript page {page} of {pages}`,{page:i+1,pages:c})}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,disabled:i+1>=c||o.loading,onClick:()=>a(i+1),children:r(`Next page`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(null),children:r(`Latest messages`)})]})}),i!==null&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`Long messages and tool results continue on the next transcript page.`)}),o.error&&(0,h.jsxs)(`p`,{role:`alert`,children:[b(r,o.error),` `,(0,h.jsx)(`button`,{type:`button`,onClick:o.refresh,children:r(`Observe current state`)})]}),i===null?(0,h.jsx)(io,{turn:n}):s&&(0,h.jsx)(io,{turn:s.turn})]})}function oo({hint:e,children:t}){let{t:n}=T();return(0,h.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e}),t]})}function so({client:e,state:t,canApprove:n,approvalHint:r,onApprove:i,onChanged:a,onOpenAgent:o}){let{t:s}=T(),[c,l]=(0,f.useState)(2),u=[...new Set(t.runs)];return(0,h.jsxs)(`section`,{className:`workflow-panel`,"aria-label":s(`Cadence workflow`),children:[u.length>c&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(e=>e+5),children:s(`Earlier workflow results`)}),u.slice(-c).map(t=>(0,h.jsx)(lo,{client:e,id:t,onChanged:a,onOpenAgent:o},t)),t.enabled&&t.proposal&&(0,h.jsxs)(`section`,{className:`workflow-plan banner-notice`,"aria-label":s(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:s(`Current implementation plan`)}),(0,h.jsx)(`p`,{children:s(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:t.proposal.cwd}),` · `,t.proposal.display?.model]}),t.proposal.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:t.proposal.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:t.proposal.display.baseCommit})]}),(0,h.jsx)(`p`,{children:s(`Approval covers only this plan: implementation, checks, bounded repairs and the displayed local delivery. No push, publication or deployment.`)}),(0,h.jsx)(Pi,{text:Rn(t.proposal.plan)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!n,onClick:i,children:s(`Implement this plan`)}),r&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r}),(0,h.jsx)(`p`,{children:s(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]}),t.enabled&&!t.proposal&&u.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:s(`Cadence stays on for this conversation until you explicitly exit.`)})]})}async function co(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 lo({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),c=oi(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=oi(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?.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:Hn(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),` · `,ba(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(Pi,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:ba(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),co(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`)})]})}function uo(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function fo({client:e,id:t,workspaceId:n,enabled:r,available:i=r,canInterrupt:a=r,modelEnabled:o=r,onModelChanged:s,onChanged:c,reference:l,onReferenceUsed:u,hidden:d=!1,onOpenAgent:p,onWorkflowRuns:m}){let{t:g,tx:_}=T(),v=`cadence:draft:${n}:${t}`,[y,x]=(0,f.useState)(()=>uo(v)),[S,C]=(0,f.useState)(()=>uo(`${v}:mode`)===`cadence`?`cadence`:`chat`),[w,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(!1),[k,A]=(0,f.useState)(``),[j,ee]=(0,f.useState)(()=>uo(`${v}:pending`)),[M,N]=(0,f.useState)(!1),[P,F]=(0,f.useState)(!1),[I,L]=(0,f.useState)(!1),[R,z]=(0,f.useState)(0),B=oi(e,i?{kind:`conversation`,id:t,before:w}:null,1e3),V=B.value?.kind===`conversation`?B.value:void 0,H=oi(e,i?{kind:`cadence-conversation`,id:t}:null,1e3),U=H.value?.kind===`cadence-conversation`?H.value.state:void 0,W=U?.enabled===!0,te=!!U||!!H.error,ne=!!U&&!H.error&&!U.notice,G=(0,f.useRef)(U);G.current=U;let[re,K]=(0,f.useState)(``),ie=(0,f.useRef)(``),ae=si(y,W?`cadence`:S),oe=r&&!!V&&!B.error&&te&&!(W&&(H.error||U?.notice))&&!D&&!j,q=V?.summary,se=q&&(q.status===`queued`||q.status===`running`),ce=!!q&&q.status!==`completed`&&!se,le=a&&!!V&&ne&&!B.error&&!D&&!j&&!se,ue=!!U?.proposal&&!!q&&!se&&q.status!==`unknown`,de=U?.proposal&&q?.status===`unknown`?g(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,fe=(0,f.useRef)(null),J=(0,f.useRef)(null),pe=(0,f.useRef)(0),Y=(0,f.useRef)(!0),[me,he]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!d&&J.current&&!Y.current&&(J.current.scrollTop=pe.current)},[d]);let ge=(0,f.useRef)(!0),_e=(0,f.useRef)(``),ve=(0,f.useRef)(y);(0,f.useEffect)(()=>(ge.current=!0,()=>{ge.current=!1}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${v}:mode`,S)}catch{}},[v,S]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(v,y)}catch{}},[y,v]),(0,f.useEffect)(()=>{try{j?sessionStorage.setItem(`${v}:pending`,j):sessionStorage.removeItem(`${v}:pending`)}catch{}},[v,j]),(0,f.useEffect)(()=>{l&&(x(e=>`${e}${e?`
|
|
18
|
+
`:``}@${l}`),u(),fe.current?.focus())},[l,u]),(0,f.useEffect)(()=>{let e=V?.summary?`${V.summary.head}:${V.summary.status}`:``;e&&_e.current!==e&&(_e.current=e,c()),ie.current&&U?.runs.includes(ie.current)&&(ie.current=``,K(``),A(``)),j&&V?.turns.some(e=>e.id===j)&&(ee(``),x(e=>e===ve.current?``:e),c()),Y.current&&J.current&&(J.current.scrollTop=J.current.scrollHeight)},[V,j,c,U]),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${v}:approval`)}catch{}},[v]);let ye=JSON.stringify(U?.runs.slice(-4)??[]);(0,f.useEffect)(()=>{m?.(JSON.parse(ye))},[ye,m]);let be=async()=>{if(!U?.proposal){A(g(`No plan is awaiting approval.`));return}if(!ne||!oe||se||re||!ue)return;let t=U;O(!0),A(``);try{let n=await Ca({client:e,state:t,current:()=>ge.current&&G.current?.revision===t.revision&&G.current?.enabled===!0,submitting:e=>{ie.current=e,K(e)}});if(!ge.current)return;n.kind===`error`?(A(n.error.code),K(``)):x(e=>Ta(e)?``:e)}catch(e){ge.current&&A(e instanceof Error?e.message:`unavailable`)}finally{ge.current&&(O(!1),H.refresh(),B.refresh(),c())}},xe=async n=>{let r=n??y;if(!(W&&wa(r)?le:oe)||se||!r.trim()||w!==null)return;if(!n&&W&&Ta(r)){await be();return}let i=si(r,S).mode===`cadence`;if((W||i)&&!ne)A(g(`Cadence state unavailable. Observe the conversation before sending.`));else if(!ce||W&&q?.status!==`unknown`){O(!0),A(``);try{if(W&&wa(r)&&U){let n=crypto.randomUUID();ve.current=r,ee(n);let i=await e.workbenchCommand({kind:`cadence-exit`,commandId:n,conversationId:t,head:q?.head??null,revision:U.revision});if(!ge.current)return;i.kind===`error`?(A(i.error.code),i.error.effect===`none`&&ee(``)):(ee(``),C(`chat`),x(e=>e===r?``:e)),H.refresh(),B.refresh(),c();return}let n=()=>{F(!0),N(!0)},a=await e.models();if(!ge.current)return;if(a.kind===`ok`&&!a.value.selected&&a.value.remembered){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:a.value.version.epoch});if(!ge.current)return;if(t.kind===`error`){A(t.error.code),n();return}if(a=await e.models(),!ge.current)return;z(e=>e+1)}if(a.kind!==`ok`||!a.value.selected){n();return}let o={commandId:crypto.randomUUID(),conversationId:t,head:q?.head??null,text:r,model:a.value.version},s=(W||i)&&U?{kind:`cadence-send`,...o,revision:U.revision,intent:wa(r)?`exit`:W?`message`:`enter`}:{kind:`send`,...o};qn(s),ve.current=r,ee(s.commandId);let l=await e.workbenchCommand(s);if(!ge.current)return;l.kind===`error`?(A(`${l.error.code}. ${g(`Observe this send before sending again. No automatic retry.`)}`),l.error.effect===`none`&&ee(``)):(x(e=>e===ve.current?``:e),ee(``),s.kind===`cadence-send`&&C(`chat`)),H.refresh(),B.refresh(),c()}catch{ge.current&&A(g(`Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.`))}finally{ge.current&&O(!1)}}},Se=(0,f.useRef)(xe);Se.current=xe,(0,f.useEffect)(()=>{I&&oe&&!se&&(L(!1),Se.current())},[I,oe,se]),(0,f.useEffect)(()=>{if(!I)return;let e=setTimeout(()=>L(!1),1e4);return()=>clearTimeout(e)},[I]);let Ce=async()=>{let n=V?.turns.find(e=>e.id===q?.head);if(!n||D)return;O(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.id,epoch:n.epoch});ge.current&&(r.kind===`error`&&A(r.error.code),O(!1),B.refresh())};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:d,"aria-label":g(W?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(yr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:q?.title??g(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(W?`Cadence on`:`Ordinary`)})]}),q&&(0,h.jsx)(`span`,{className:`ep-state ${q.status}`,children:W?se?g(`Discussing`):ce?_(q.status):U?.proposal?g(`Awaiting plan approval`):g(`Ready for conversation`):_(q.status)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:J,onScroll:()=>{let e=J.current;e&&!d&&(pe.current=e.scrollTop,Y.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,he(!Y.current))},children:[!q&&(0,h.jsx)(oo,{hint:g(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),V?.before&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{Y.current=!1,E(V.before)},children:g(`Earlier messages`)}),w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{Y.current=!0,E(null)},children:g(`Latest messages`)}),V?.turns.map(n=>(0,h.jsx)(ao,{client:e,conversationId:t,turn:n},n.id)),U&&(0,h.jsx)(so,{client:e,state:U,canApprove:oe&&ne&&ue&&!se&&!re&&w===null,approvalHint:de,onApprove:()=>void be(),onOpenAgent:p,onChanged:()=>{H.refresh(),c()}}),U?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_(U.notice)}),(k||B.error||H.error)&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(g,k||B.error||H.error||``)}),j&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[g(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:j}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:B.refresh,children:g(`Observe current state`)})]}),ce&&W&&q?.status!==`unknown`&&(0,h.jsx)(`p`,{className:`inspector-note`,children:g(`The last turn did not complete. A new message continues from the last complete checkpoint; incomplete work is not replayed.`)}),ce&&!W&&(0,h.jsx)(`p`,{className:`inspector-note`,children:g(`This turn has no complete continuation context. Start a new conversation; retained messages are preserved.`)})]}),me&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":g(`Latest messages`),onClick:()=>{J.current&&(J.current.scrollTop=J.current.scrollHeight),Y.current=!0},children:(0,h.jsx)(Vr,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onSubmit:e=>{e.preventDefault(),xe()},children:[(0,h.jsx)(`textarea`,{ref:fe,disabled:!r&&!(W&&a)||!V||!te||!!B.error||D||!!j,"aria-label":g(`Message`),value:y,placeholder:g(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),xe())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle${W||ae.mode===`cadence`?` on`:``}`,"aria-label":g(`Cadence mode`),"aria-pressed":W||ae.mode===`cadence`,disabled:W?!le:se||D,title:W?g(`Cadence mode is on. Click to exit it.`):ae.mode===`cadence`?g(`Your next message turns on Cadence mode. Click to cancel.`):g(`Turn on Cadence mode: agree on a plan before implementation.`),onClick:()=>{W?xe(`exit cadence`):ae.mode===`cadence`?(C(`chat`),si(y,`chat`).mode===`cadence`&&x(ae.text)):C(`cadence`)},children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),`Cadence`]}),(0,h.jsx)(Ma,{client:e,enabled:o&&i,locked:!!se,refresh:String(R),open:M,onOpenChange:e=>{N(e),e||F(!1)},onChanged:s,onChosen:()=>{P&&(F(!1),A(``),L(!0))},awaitingSend:P}),(0,h.jsx)(`span`,{className:`composer-hint`,children:W?g(`Cadence stays on. Confirm one plan before implementation.`):ae.mode===`cadence`?g(`Your next message turns on Cadence mode.`):``}),se?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:D||!a,onClick:()=>void Ce(),children:[(0,h.jsx)(fr,{}),g(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(W&&wa(y)?le:oe)||!y.trim()||ce&&(!W||q?.status===`unknown`)||w!==null,children:[(0,h.jsx)(zr,{}),g(`Send`)]})]})]})]})}function po({client:e,enabled:t,onReference:n}){let{t:r}=T(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(``),u=oi(e,t?{kind:`files`,path:i}:null),d=oi(e,t&&o?{kind:`file`,path:o}:null),p=u.value?.kind===`files`?u.value:void 0,m=d.value?.kind===`file`?d.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":r(`Parent folder`),disabled:p?.parent==null,onClick:()=>{p?.parent!=null&&a(p.parent)},children:(0,h.jsx)(zr,{})}),(0,h.jsx)(`span`,{className:`files-path`,title:i,children:i||`/`}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":r(`Refresh files`),onClick:()=>{u.refresh(),d.refresh()},children:(0,h.jsx)(gr,{})})]}),u.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:u.error}),(0,h.jsxs)(`section`,{className:`file-list`,"aria-label":r(`File list`),children:[p?.entries.map(e=>(0,h.jsxs)(`div`,{className:`file-row`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`file-name${o===e.path?` selected`:``}`,title:e.path,onClick:()=>e.directory?a(e.path):s(e.path),children:[e.directory?(0,h.jsx)(Dr,{}):(0,h.jsx)(Or,{}),(0,h.jsx)(`span`,{children:e.name})]}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":r(`Reference {path}`,{path:e.name}),onClick:()=>n(e.path),children:(0,h.jsx)(_r,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":r(`Copy path {path}`,{path:e.name}),onClick:()=>void xi(e.path).then(e=>l(e?``:r(`Link copy unavailable.`))),children:(0,h.jsx)(Nr,{})})]},e.path)),p?.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-empty`,children:r(`No visible files`)}),p?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`Bounded listing; narrow the directory to see more.`)})]}),o&&(0,h.jsxs)(`section`,{className:`file-preview`,children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`span`,{title:o,children:o}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":r(`Close preview`),onClick:()=>s(null),children:(0,h.jsx)(ur,{})})]}),d.error&&(0,h.jsx)(`p`,{role:`alert`,children:d.error}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`pre`,{children:m.text}),m.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`File preview is limited; this is not the complete file.`)})]})]}),c&&(0,h.jsx)(`p`,{role:`alert`,children:c}),(0,h.jsx)(`p`,{className:`files-policy`,children:r(`Readonly preview · references send paths, not file contents`)})]})}var mo=`未命名章节`;function ho(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 go(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=ho(r||mo),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||mo}})}function _o(e){return e.length>=2}function vo(e){let t=0,n=0;return e.split(`
|
|
19
|
+
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function yo({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:vo(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 bo({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(`
|
|
20
|
+
`);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=go(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)(Oi,{text:u?g.slice(u.start-1,u.end).join(`
|
|
21
|
+
`):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:[_o(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)(Pi,{text:e})})]}):n===`diff`?(0,h.jsx)(yo,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:vo(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 xo({client:e,seed:t}){let{t:n,tx:r}=T(),i=vi(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Gi,{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(gi(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)(Wi,{client:e,cursor:a,render:e=>(0,h.jsx)(bo,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var So=[`contents`,`checks`,`changes`,`reviews`];function Co(){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 wo({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:So.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)(Ki,{client:e,seed:t}):(0,h.jsx)(xo,{client:e,seed:{...t,reader:i}},i)})]})}var To={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.`},Eo=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Do(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 Oo({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[]}){let{t:c,tx:l}=T(),[u,d]=(0,f.useState)(),[p,m]=(0,f.useState)(n??t),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(!0),[S,C]=(0,f.useState)(!0),[w,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),j=(0,f.useRef)(n??t),ee=(0,f.useRef)(null),M=(0,f.useRef)(null),N=async t=>{A.current?.abort();let n=new AbortController;A.current=n,x(!0),O(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&k.current){if(A.current=void 0,x(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),m(r.value.path),_(!1),y(``),r.value;O({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},P=(0,f.useRef)(N);(0,f.useEffect)(()=>(k.current=!0,P.current(j.current).then(()=>{k.current&&C(!1)}),()=>{k.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{g&&ee.current?.select()},[g]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let F=e=>{w||N(e)},I=()=>{let e=p.trim();w||(Eo(e)?N(e):O({step:`read`,code:`relative`}))},L=(g||!u)&&p.trim()||u?.path||``,R=!w&&!b&&!!L,z=async n=>{if(w||!n||b&&n===u?.path)return;if(n!==u?.path&&!Eo(n)){O({step:`read`,code:`relative`});return}E(!0),O(null);let r=n===u?.path?u.path:(await N(n))?.path;if(!k.current)return;if(!r){E(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),k.current&&a()}catch(e){k.current&&(O({step:`open`,code:e instanceof Error?e.message:`unavailable`}),E(!1))}return}if(!e.workbenchCommand){O({step:`open`,code:`unavailable`}),E(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(k.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(O({step:`open`,code:`unsupported-context`}),E(!1))}else O({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),E(!1)}},B=u?Do(u.path,r):void 0,V=v.trim().toLowerCase(),H=u?.entries.filter(e=>e.name.toLowerCase().includes(V))??[],U=D&&(D.step===`read`&&To[D.code]?c(To[D.code]):l(D.code));return(0,h.jsxs)(Qi,{title:c(`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:c(`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":c(`Recent projects`),children:[(0,h.jsx)(`h3`,{children:c(`Recent projects`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:c(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:w,onClick:()=>e.current?a():void z(e.path),children:[(0,h.jsx)(Dr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[B&&!g?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":c(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":c(`Home folder`),title:c(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:w,onClick:()=>F(`~`),children:[(0,h.jsx)(wr,{"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)(Ir,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:w,onClick:()=>F(e.path),children:e.name})]},e.path))]}):S?(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:ee,"aria-label":c(`Folder path`),placeholder:c(`Type or paste a path, then press Enter`),value:p,disabled:w,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{m(e.target.value),D?.step===`read`&&O(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),_(!1),m(u.path),O(null))}})}),u&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":c(`Edit path`),title:c(`Edit path`),"aria-pressed":g,disabled:w,onClick:()=>{m(u.path),_(!g),O(null)},children:(0,h.jsx)(Ar,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(hr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":c(`Filter folders`),placeholder:c(`Filter this folder…`),value:v,disabled:w,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":b||void 0,children:[b&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:c(`Reading folder…`)}),u?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:w,onClick:()=>F(u.parent),children:[(0,h.jsx)(zr,{}),c(`Parent folder`)]}),H.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:w,onClick:()=>F(e.path),children:[(0,h.jsx)(Dr,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),u&&!b&&H.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:c(V?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:c(`Bounded listing; narrow the directory to see more.`)}),U&&(0,h.jsxs)(`p`,{role:`alert`,children:[U,D?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,c(`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:c(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:L})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!R,onClick:()=>void z(L),children:c(w?`Opening folder…`:`Open this folder`)})]})]})}function ko(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 Ao({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)(_r,{"aria-hidden":`true`}),n(`New conversation`)]})})}function jo({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)(Lr,{"aria-hidden":`true`}):(0,h.jsx)(Ir,{"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 Mo({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=ko(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)(Ir,{"aria-hidden":`true`}):(0,h.jsx)(Lr,{"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)(Mr,{"aria-hidden":`true`}):(0,h.jsx)(yr,{"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 No({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)(Mo,{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)(Gi,{pager:e,compact:!0})]})}function Po({client:e,workspace:t,taskId:n,scope:r,runs:i,snapshot:a,activeRuns:o,cancelCompatible:s,canceling:c,onCancel:l,onTask:u,onScope:d,chats:p=[],chatActivityKnown:m=!0,chatHistoryPartial:g=!1,chatHistoryControls:_,conversationId:v,onConversation:y,onNewConversation:b,workflows:x,workflowLinks:S=[],workflowError:C=!1,selectedWorkflow:w,onWorkflow:E,onCancelWorkflow:D}){let{t:O,tx:k}=T(),A={reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50},j=vi(e,A),ee=vi(e,n?{...A,reader:`runs`,scope:{kind:`task`,id:n},snapshotSeq:a??t.committedSeq}:null),M=j.page&&!(`kind`in j.page)?j.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],N=o?.status===`complete`?o.runs:[],P=M.filter(e=>!N.some(t=>t.taskId===e.owner.taskId)),F=n&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":O(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:O(`Task conversations`)}),(0,h.jsx)(No,{pager:ee,scope:r,onScope:d,exclude:N.map(e=>e.runId)},n)]}),[I,L]=(0,f.useState)(()=>new Set),R=e=>{let t=S.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${w===e.id||t&&t===v?` active`:``}`,onClick:()=>E?.(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:[O(`Cadence workflow`),` · `,k(e.phase),` · `,k(e.status)]})]})]}),D&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:I.has(e.id),onClick:()=>{L(t=>new Set(t).add(e.id)),D(e).finally(()=>L(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(fr,{"aria-hidden":`true`}),O(`Cancel workflow — request stop`)]})]},e.id)},z=p.filter(e=>e.status===`running`||e.status===`queued`),B=p.filter(e=>!z.includes(e)),V=e=>(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.id===v?` active`:``}`,onClick:()=>y?.(e.id),title:e.title,children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(yr,{})}),(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.cadence?O(`Cadence on`):O(`Ordinary`),` ·`,` `,e.cadence&&[`running`,`queued`].includes(e.status)?O(`Discussing`):e.cadence&&e.status===`completed`?O(`Ready for conversation`):k(e.status)]})]})]},e.id);return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(Ao,{onConversation:b}),(0,h.jsxs)(jo,{title:O(`Running conversations`),count:o?.status===`complete`&&x&&!C&&m?String(N.length+z.length+x.length):`?`,className:`running-conversations`,children:[o?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:O(`Active roster unavailable; absence is not proof of settlement.`)}),C&&(0,h.jsx)(`p`,{className:`panel-hint`,children:O(`Workflow activity unavailable; retained work may still be running.`)}),!m&&(0,h.jsx)(`p`,{className:`panel-hint`,children:O(`Conversation activity unavailable.`)}),z.map(V),x?.map(R),o?.status===`complete`&&N.length===0&&z.length===0&&x?.length===0&&!C&&m&&(0,h.jsx)(`p`,{className:`panel-hint`,children:O(`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${n===e.taskId&&r?.kind===`task`?` active`:``}`,onClick:()=>u(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??O(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[k(e.kind),` · `,k(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!s||c.has(e.runId),onClick:()=>l(e.runId),children:[(0,h.jsx)(fr,{"aria-hidden":`true`}),O(`Cancel run — request stop`)]}),n===e.taskId&&(0,h.jsx)(Mo,{runs:i.filter(t=>t.runId===e.runId),scope:r,onScope:d})]},e.runId)})]}),(0,h.jsxs)(jo,{title:O(`Conversation history`),count:j.page&&!(`kind`in j.page)?`${B.length+P.length}${j.page.next||j.canPrevious||g?`+`:``}`:`?`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":O(`Tasks`),className:`task-list`,children:[B.map(V),P.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===n&&r?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===n&&r?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>u(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(yr,{"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:O(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===n&&F]},e.owner.taskId)),j.page&&!(`kind`in j.page)&&P.length===0&&B.length===0&&!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:O(`No conversations yet.`)}),_,(0,h.jsx)(Gi,{pager:j,compact:!0})]}),!P.some(e=>e.owner.taskId===n)&&F]})]})}var Fo=[`queued`,`running`];function Io({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=oi(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?Fo.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!Fo.includes(u.status)&&c(0)},[u]);let m=oi(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,[_,v]=(0,f.useState)(!1),y=oi(e,_&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),b=(0,f.useRef)(null),x=(0,f.useRef)(!0),S=g?.items.length??0;return(0,f.useEffect)(()=>{S&&x.current&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[S]),(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)(Mr,{"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:b,onScroll:e=>{let t=e.currentTarget;x.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&&(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)(lo,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(g?(0,h.jsx)(io,{turn:g}):(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)(Pi,{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:()=>v(!0),children:a(`Read retained step result`)}),_&&y.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),_&&y.error&&(0,h.jsx)(`p`,{role:`alert`,children:y.error})]})]})]})}function Lo({client:e,onOpen:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),p=oi(e,i?{kind:`workflow-history`,after:o,...c?{scan:c}:{}}:null),m=p.value?.kind===`workflow-history`?p.value:void 0,g=p.value?.kind===`workflow-history-progress`?p.value:void 0,_=p.error??(g&&g.after!==o?`invalid`:void 0);return(0,h.jsxs)(`details`,{className:`lp-section workflow-history`,onToggle:e=>{a(e.currentTarget.open),e.currentTarget.open||l(void 0)},children:[(0,h.jsx)(`summary`,{className:`lp-section-heading`,children:n(`Workflow history`)}),i&&(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`ID order; refresh to observe new runs. Unreadable records are not removed.`)}),_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),!m&&!g&&!_&&(0,h.jsx)(`p`,{children:n(`Reading…`)}),g&&!_&&(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{children:n(`Scanning retained workflow IDs; no complete page yet.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:p.loading,onClick:()=>l(g.scan),children:n(`Continue reading history`)})]}),m?.entries.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,onClick:()=>t({runId:e.id,stepId:null,label:e.run?.goal||e.id}),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.run?.goal||e.id}),(0,h.jsx)(`span`,{className:`session-sub`,children:r(e.run?.status??`unavailable`)})]})},e.id)),m&&!_&&m.entries.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`No retained workflows on this page.`)}),(0,h.jsxs)(`div`,{className:`page-controls`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:!u.length,onClick:()=>{l(void 0),s(u.at(-1)??null),d(u.slice(0,-1))},children:n(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!m?.next||!!_||p.loading,onClick:()=>{m?.next&&(l(void 0),d([...u,o]),s(m.next))},children:n(`Next`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{l(void 0),p.refresh()},children:n(`Observe current state`)})]})]})]})}function Ro({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)(Dr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(Lr,{"aria-hidden":`true`})]})}function zo(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Yi();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:H(e)});if(n&&(a.set(`scope`,JSON.stringify(De(n.scope))),n.snapshotSeq&&a.set(`snapshot`,W(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Bo(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=H(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?De(re(r)):void 0,o=i?W(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ke(re(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function Vo(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 Ho({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=Vo({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 Uo(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 Wo=.4,Go=1.05;function Ko(e){return Math.min(300,e*.86)}function qo(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Jo(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Yo(e,t){return e===`left`?t:-t}function Xo(e,t){return Math.max(-e,Math.min(0,-e+t))}function Zo(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Qo(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Zo(r*Go,n,t)>=Wo}var $o=new Set([`auto`,`scroll`,`overlay`]);function es(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&$o.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function ts(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function ns(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=qo(r.clientX,window.innerWidth,n);i&&!es(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=Jo(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Ko(window.innerWidth),h=m*Go;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=Yo(r,d);let b=Xo(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Zo(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Qo({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(ts(),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 rs(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 is=`modulepreload`,as=function(e){return`/`+e},os={},ss=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=as(t,n),t=s(t),t in os)return;os[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`:is,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 cs({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=vi(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)(Gi,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(ls,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function ls({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 ss(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,rs(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)(Ki,{client:e,seed:t})]})}function us(){let e=new URLSearchParams(window.location.hash?.slice(1)).get(`chat`);return e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(e)?e:null}var ds=[[`tools`,dr],[`context`,Cr],[`timeline`,Pr],[`runs`,Er]];function fs({error:e,observationError:t}){let{t:n,tx:r}=T();return!e&&!t?null:(0,h.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[e&&(0,h.jsxs)(h.Fragment,{children:[e,` `]}),t&&(0,h.jsxs)(h.Fragment,{children:[n(`{message}.`,{message:r(t)}),` `,t===`stale`?n(`Context changed. Observe again and request a fresh confirmation.`):(0,h.jsx)(x,{text:n(`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 ps({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i,notices:a,onOpenService:o}){let{t:s,tx:c,locale:l,setLocale:u}=T(),[d]=(0,f.useState)(()=>e??ii()),[p,m]=(0,f.useState)(!1),[g]=(0,f.useState)(Bo),[_,v]=(0,f.useState)(g?.taskId??null),[y,b]=(0,f.useState)(()=>g?null:us()??crypto.randomUUID()),[S,C]=(0,f.useState)(null),[w,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(g?`task`:`files`),[j,ee]=(0,f.useState)(),M=(0,f.useCallback)(()=>ee(void 0),[]),[N,P]=(0,f.useState)(g?g.scope??{kind:`task`,id:g.taskId}:null),F=di(d,_?{kind:`task`,id:_}:null,!p),I=(0,f.useRef)(null);F.workspace&&(I.current=F.workspace.workspaceId);let L=ci(d.client,!!F.workspace&&!p),R=oi(d.client,F.workspace&&!p?{kind:`conversation-active`}:null,1e3),z=R.value?.kind===`conversation-active`?R.value.entries:[],B=[...z,...(L.value?.entries??[]).filter(e=>!z.some(t=>t.id===e.id))],V=oi(d.client,F.workspace&&!p?{kind:`workflow-active`}:null,2e3),H=V.value?.kind===`workflow-active`?V.value:void 0,U=(0,f.useMemo)(()=>[...new Set([...H?.runs.map(e=>e.id)??[],...w])],[H,w]),W=oi(d.client,F.workspace&&!p?{kind:`projects`}:null),te=(W.value?.kind===`projects`?W.value.entries.find(e=>e.current)?.path:void 0)??F.workspace?.rootLabel,ne=oi(d.client,_&&F.workspace&&!p?{kind:`task-origin`,taskId:_}:null),re=ne.value?.kind===`task-origin`?ne.value.conversationId:null,K={state:F.observation,transportStatus:F.transportStatus,error:F.error,refresh:F.refresh},ie=K.state?.snapshot.scope.kind===`task`&&K.state.snapshot.scope.id===_?K.state.snapshot.context:void 0,[ae,oe]=(0,f.useState)(null),[q,se]=(0,f.useState)(!1),ce=(0,f.useRef)(null),[le,ue]=(0,f.useState)(260),[de,fe]=(0,f.useState)(360),J=(0,f.useCallback)(()=>oe(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>se(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),ns({enabled:q&&!p,open:ae,onOpenChange:oe,container:ce}),Uo(ce,ae,q&&!p,J);let[pe,Y]=(0,f.useState)(g?.snapshotSeq),[me,he]=(0,f.useState)(``),[ge,_e]=(0,f.useState)(``),[ve,ye]=(0,f.useState)(!0),be=(0,f.useRef)(null),xe=(0,f.useRef)(null),Se=()=>{xe.current&&(xe.current.open=!1)},[Ce,we]=(0,f.useState)(`messages`),[X,Te]=(0,f.useState)(!1),[Ee,De]=(0,f.useState)(!1),[Oe,ke]=(0,f.useState)(),[Ae,je]=(0,f.useState)(g?.cursor),[Me,Ne]=(0,f.useState)(``),[Pe,Fe]=(0,f.useState)([]),[Ie,Le]=(0,f.useState)(new Set),Re=(0,f.useRef)(!0),ze=e=>{Re.current&&Fe(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?ai(t,e):t)})},Be=(0,f.useRef)(new fi),Ve=G({taskId:_,scope:N,selectedSnapshot:pe??null,detached:p,attachment:F.attachmentVersion,workspaceContext:F.workspace?.context??null,observationError:F.error??null});Be.current.select(Ve),(0,f.useEffect)(()=>(Re.current=!0,()=>{Re.current=!1,Be.current.depart()}),[]);let He=(e=crypto.randomUUID())=>{C(null),e!==y&&E([]),Be.current.depart(),b(e),v(null),P(null),he(``),_e(``),ke(void 0),je(void 0),Y(void 0),we(`messages`),A(`files`),J(),history.replaceState(null,``,`${location.pathname}${location.search}#chat=${e}`)};(0,f.useEffect)(()=>{y&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${y}`)},[y]);let Ue=(e,t)=>{C(null),E([]),b(null),A(`task`),he(t??``),_e(``),Y(void 0),Be.current.depart(),v(e),P({kind:`task`,id:e}),ke(void 0),je(void 0),we(`messages`),J(),history.replaceState(null,``,zo(e))};(0,f.useEffect)(()=>{let e=()=>{let e=Bo();if(e)C(null),E([]),b(null),A(`task`),Be.current.depart(),Y(e.snapshotSeq),he(``),_e(``),v(e.taskId),P(e.scope??{kind:`task`,id:e.taskId}),ke(void 0),je(e.cursor),we(`messages`),J();else{let e=us();e&&(C(null),E([]),b(e),v(null),P(null),A(`files`),Be.current.depart(),J())}};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[J]);let We=(e,t,n)=>{C(null),Y(t),_e(n??``),Be.current.depart(),P(e),ke(void 0),je(void 0),we(`messages`),J(),_&&history.replaceState(null,``,zo(_,void 0,{scope:e,snapshotSeq:t}))},Ge=pe??K.state?.snapshot.committedSeq??F.workspace?.committedSeq,Ke=F.workspace?.storeId,qe=N&&Ke&&Ge?{storeId:Ke,scope:N,snapshotSeq:Ge,reader:`messages`,after:null,limit:50}:null,Je=N&&Ke&&Ge?{storeId:Ke,scope:N,snapshotSeq:Ge,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,Ye=ie?K.state?.snapshot.runs??[]:[],Xe=Be.current.ticket(),Ze=e=>{ze(e),e.receipt&&Be.current.current(Xe)&&F.refresh()},Qe=e=>{if(Ie.has(e)||!F.cancelCompatible||!F.activeRuns)return;let t=crypto.randomUUID(),n=F.activeRuns.epoch;Le(t=>new Set(t).add(e)),ze({commandId:t,error:s(`Stop requested; settlement is not yet confirmed.`)}),d.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{Ze(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:s(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>ze({commandId:t,error:s(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Re.current&&Le(t=>{let n=new Set(t);return n.delete(e),n})})};if(p)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:s(`Detached`)}),(0,h.jsx)(`p`,{children:s(`Accepted service work continues. No Cancel was requested.`)}),Pe.map(e=>(0,h.jsxs)(`p`,{children:[s(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>m(!1),children:s(`Reconnect as a viewer`)})]});let $e=F.activeRuns,et=$e?.status===`complete`?$e.runs:[],tt=K.state?.connection??(F.workspace?_?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${ve?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":s(`Tasks`),onClick:()=>oe(e=>e===`left`?null:`left`),children:(0,h.jsx)(br,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":s(`Workbench projects`),title:s(`Workbench projects`),onClick:n,children:(0,h.jsx)(Dr,{})}),(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`}),N&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":s(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ce===`messages`&&!Ae,onClick:()=>{je(void 0),ke(void 0),we(`messages`)},children:[(0,h.jsx)(yr,{"aria-hidden":`true`}),s(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:be,onKeyDown:e=>{e.key===`Escape`&&be.current&&(be.current.open=!1,be.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsxs)(`summary`,{className:`chip`,children:[Ce===`messages`?s(`Details`):c(Ce),(0,h.jsx)(Lr,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[ds.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":Ce===e,onClick:()=>{je(void 0),ke(void 0),we(e),be.current&&(be.current.open=!1,be.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),c(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":s(`Export selected scope`),disabled:!qe,onClick:()=>{be.current&&(be.current.open=!1,be.current.querySelector(`summary`)?.focus()),De(!0)},children:[(0,h.jsx)(jr,{"aria-hidden":`true`}),s(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":s(`Copy token-free link`),disabled:!_,onClick:()=>{_&&xi(zo(_,Ae,N?{scope:N,snapshotSeq:pe}:void 0)).then(e=>Ne(e?``:s(`Link copy unavailable.`)))},children:[(0,h.jsx)(Sr,{"aria-hidden":`true`}),s(`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)(sa,{disabled:!Je,onOpen:()=>Te(!0)}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,"aria-label":l===`zh`?`Switch to English`:`切换到中文`,"data-tip":l===`zh`?`Switch to English`:`切换到中文`,onClick:()=>u(l===`zh`?`en`:`zh`),children:[(0,h.jsx)(Tr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:l===`zh`?`EN`:`中文`})]}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:xe,onKeyDown:e=>{e.key===`Escape`&&xe.current&&(xe.current.open=!1,xe.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":s(`More`),title:s(`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":s(`Observe current state`),onClick:()=>{Se(),F.refresh(),K.refresh()},children:[(0,h.jsx)(gr,{"aria-hidden":`true`}),s(`Refresh status`)]}),o&&(0,h.jsxs)(`button`,{type:`button`,onClick:()=>{Se(),o()},children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[s(`Cadence service`),(0,h.jsx)(`small`,{children:s(`Version, restart and upgrade.`)})]})]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":s(`Disconnect this page`),title:s(`Return — accepted work continues`),onClick:()=>{Se(),oe(null),Te(!1),De(!1),Be.current.depart(),m(!0)},children:[(0,h.jsx)(xr,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[s(`Disconnect this page`),(0,h.jsx)(`small`,{children:s(`Started work keeps running.`)})]})]}),(0,h.jsxs)(`div`,{className:`more-menu-build${F.compatible?``:` warn`}`,title:ri?.buildId??s(`unbuilt source`),children:[(0,h.jsx)(`span`,{children:s(`Shared compatibility: {state}.`,{state:F.compatible?s(`compatible`):s(`unavailable / mismatch — reload built assets; normal actions disabled`)})}),(0,h.jsx)(x,{text:s(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:ri?.buildId??s(`unbuilt source`)})}})]})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":s(`Files / history`),"aria-expanded":q?ae===`right`:ve,onClick:()=>q?oe(e=>e===`right`?null:`right`):ye(e=>!e),children:[(0,h.jsx)(pr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:s(y?`Files`:`History`)})]})]}),!F.workspace&&et.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":s(`Execution and cancellation`),children:et.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:[c(e.kind),` `,e.runId,` · `,c(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>Ue(e.taskId),children:s(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!F.cancelCompatible||Ie.has(e.runId),onClick:()=>Qe(e.runId),children:[(0,h.jsx)(fr,{"aria-hidden":`true`}),s(`Cancel run — request stop`)]})]},e.runId))}),a,(0,h.jsx)(fs,{error:Me,observationError:F.error}),(0,h.jsxs)(`div`,{ref:ce,className:`layout`,style:{"--left-w":`${le}px`,"--right-w":`${de}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":s(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${ae?` on`:``}`,onClick:J}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${ae===`left`?` open`:``}`,"aria-label":s(`Task navigation drawer`),tabIndex:-1,inert:q&&ae!==`left`,children:[F.workspace&&(0,h.jsx)(Po,{client:d.client,workspace:F.workspace,taskId:_,scope:N,runs:Ye,snapshot:K.state?.snapshot.committedSeq,activeRuns:F.activeRuns,cancelCompatible:!!F.cancelCompatible,canceling:Ie,onCancel:Qe,chats:B,chatActivityKnown:R.value?.kind===`conversation-active`&&!R.error,chatHistoryPartial:L.loading||L.canPrevious||!!L.value?.next,chatHistoryControls:(0,h.jsxs)(h.Fragment,{children:[L.error&&(0,h.jsx)(`p`,{role:`alert`,children:L.error}),L.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:s(`Reading conversation history…`)}),L.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:L.loading,onClick:L.previous,children:s(`Newer conversations`)}),L.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:L.loading,onClick:L.next,children:s(`Older conversations`)}),L.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:L.first,children:s(`Latest conversations`)}),L.error&&(0,h.jsx)(`button`,{type:`button`,onClick:L.refresh,children:s(`Observe current state`)})]}),conversationId:y,onConversation:He,onNewConversation:()=>He(),workflows:H?.runs,workflowLinks:H?.links,workflowError:!!V.error,selectedWorkflow:S?.runId,onWorkflow:(e,t)=>{t?He(t):(C({runId:e.id,stepId:null,label:e.goal}),J())},onCancelWorkflow:async e=>{let t=await co(d.client,e);t&&Ne(t),V.refresh()},onTask:Ue,onScope:We}),F.workspace&&(0,h.jsx)(Lo,{client:d.client,onOpen:e=>{C(e),J()}}),F.workspace&&(0,h.jsx)(Sa,{client:d.client,active:F.activeRuns,taskId:_,runs:Ye,snapshot:Ge,workflowRuns:U,selected:S,onOpenWorkflow:e=>{C(e),J()},onOpen:(e,t,n,r)=>{Ue(e),P({kind:`child`,id:t}),_e(r),Y(n),history.replaceState(null,``,zo(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(Ho,{side:`left`,width:le,onResize:ue}),(0,h.jsxs)(`main`,{className:`main`,inert:q&&ae!==null,children:[S&&(0,h.jsx)(Io,{client:d.client,agent:S,backLabel:s(y?`Back to conversation`:_?`Back to task`:`Back`),onBack:()=>C(null),onOpenAgent:C},`${S.runId}:${S.stepId??``}`),y&&(0,h.jsx)(fo,{client:d.client,id:y,hidden:!!S,onOpenAgent:C,onWorkflowRuns:E,workspaceId:I.current??`connecting`,available:!!F.workspace,canInterrupt:!!F.cancelCompatible,enabled:!!F.workspace&&!!F.compatible&&!F.error,modelEnabled:!!F.compatible&&F.transportStatus===`current`&&!F.error,onModelChanged:()=>{Be.current.depart(),F.refresh(!0)},onChanged:()=>{L.refresh(),F.refresh()},reference:j,onReferenceUsed:M},`${I.current??`connecting`}:${y}`),N&&!S&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[N.kind!==`task`&&_&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Ue(_,me),children:s(`Back to task`)}),re&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>He(re),children:s(`Back to ordinary conversation`)}),(0,h.jsx)(`h2`,{title:me||N.id,children:N.kind===`task`?me||s(`Task {id}`,{id:N.id.slice(0,8)}):ge||s(`{kind} {id}`,{kind:c(N.kind),id:N.id.slice(0,8)})}),N.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:s(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[s(`Recorded conversation`),` ·`,` `,s(`snapshot {seq}`,{seq:Ge??``})]}),(0,h.jsx)(`code`,{children:N.id}),(0,h.jsx)(`p`,{children:s(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!y||!!S,children:[!qe&&(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:s(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:s(`History is readonly. Start new work in a conversation with /cadence.`)})]}),qe&&Ae?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Oe&&(Oe.owner.entity.kind===`task`||Oe.owner.entity.kind===`message`||Oe.owner.entity.kind===`tool`)&&(0,h.jsx)(qi,{client:d.client,seed:{storeId:Ae.storeId,scope:Ae.scope,snapshotSeq:Ae.snapshotSeq,kind:Oe.owner.entity.kind,id:Oe.owner.entity.id,version:Oe.owner.entity.version}},`${Oe.owner.entity.id}:${Oe.owner.entity.version}`),(0,h.jsx)(Wi,{client:d.client,cursor:Ae,highlight:Oe?.range},`${Ae.recordId}:${Ae.recordVersion}`)]}):qe&&(0,h.jsxs)(`div`,{className:Ce===`messages`||Ce===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ce===`messages`&&(0,h.jsx)(ga,{client:d.client,seed:qe}),Ce===`tools`&&(0,h.jsx)(ms,{client:d.client,seed:qe}),Ce===`context`&&(0,h.jsx)(Ki,{client:d.client,seed:qe}),Ce===`timeline`&&(0,h.jsx)(cs,{client:d.client,seed:qe,onSearch:()=>Te(!0)}),Ce===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:s(`Runs in the current snapshot`)}),Ye.length>0?Ye.map(e=>(0,h.jsx)(ra,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:ie&&K.state?s(`No owner run projection in this snapshot.`):s(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:s(`Retained runs`)}),(0,h.jsx)(oa,{client:d.client,seed:{...qe,scope:{kind:`task`,id:_??qe.scope.id}},onScope:We},_)]})]},`${N?.kind}:${N?.id}:${pe??`current`}`)]}),F.workspace&&Pe.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:Pe.map(e=>(0,h.jsx)(pi,{client:d.client,value:e,onChange:ze},e.commandId))})]}),(0,h.jsx)(Ho,{side:`right`,width:de,onResize:fe}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${ae===`right`?` open`:``}`,"aria-label":s(`Files and history drawer`),tabIndex:-1,inert:q&&ae!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":s(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`files`,onClick:()=>A(`files`),children:[(0,h.jsx)(Dr,{}),s(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`task`,disabled:!qe,onClick:()=>A(`task`),children:[(0,h.jsx)(Cr,{}),s(`History details`)]})]}),k===`files`?(0,h.jsx)(po,{client:d.client,enabled:!!F.workspace,onReference:e=>{y||He(re??void 0),ee(e),J()}}):qe?(0,h.jsx)(wo,{client:d.client,seed:{...qe,scope:{kind:`task`,id:_??qe.scope.id}}},_):(0,h.jsx)(Co,{})]})})]}),(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:s(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${K.error||!F.workspace?`error`:K.transportStatus===`current`?K.state?K.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),c(tt),K.transportStatus!==`current`&&s(` · transport {status}`,{status:c(K.transportStatus)}),K.error?` · ${c(K.error)}`:``]}),$e?.status===`complete`?et.length>0&&(0,h.jsx)(`span`,{className:`status-item warn`,children:s(et.length===1?`{count} active run`:`{count} active runs`,{count:et.length})}):(0,h.jsx)(`span`,{className:`status-item faint`,children:s(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[F.workspace&&(0,h.jsx)(Ro,{path:te,onClick:()=>O(``)}),!F.compatible&&(0,h.jsx)(`span`,{className:`status-item warn`,children:s(`unavailable / mismatch — reload built assets; normal actions disabled`)})]})]}),D!==null&&F.workspace&&(0,h.jsx)(Oo,{onOpen:t,projects:i??(W.value?.kind===`projects`?W.value.entries:[]),client:d.client,current:te??F.workspace.rootLabel,initial:D||void 0,home:r,epoch:F.workspace.epoch,onClose:()=>O(null)}),X&&Je&&(0,h.jsx)(na,{client:d.client,seed:Je,onClose:()=>Te(!1),onHit:e=>{ke(e),je(e.cursor),_&&history.replaceState(null,``,zo(_,e.cursor,N?{scope:N,snapshotSeq:pe}:void 0))}}),Ee&&Je&&(0,h.jsx)($i,{request:{storeId:Je.storeId,scope:Je.scope,snapshotSeq:Je.snapshotSeq,format:`ndjson`},onClose:()=>De(!1)})]})}function ms({client:e,seed:t}){let n=vi(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Gi,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(va,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var hs=`cadence-last-project`;function gs(){try{let e=localStorage.getItem(hs);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function _s(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(hs,e)}catch{}}function vs(e){let t=gs();return t?e.projects.find(e=>e.id===t):void 0}async function ys(e,t){try{return(await ii(e).client.workbenchRead({kind:`conversation-active`},t)).kind===`ok`&&!t.aborted}catch{return!1}}async function bs(e){return re(await ni(e,1048576),1048576)}function xs(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 Ss(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await bs(r);if(!r.ok)throw Error(xs(i));return t(i)}function Cs(e){return Ss(`/workbench/v1/service`,Sn,e)}function ws(e){return Ss(`/workbench/v1/service/release`,Cn,e)}async function Ts(e,t){if(!ri)throw Error(`unavailable`);let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t,"X-Cadence-Build":JSON.stringify({kind:`browser`,...ri})},body:JSON.stringify(e)}),r=await bs(n);if(!n.ok)throw Error(xs(r));let i=B(r,[`kind`,`job`]);return R(i.kind,`service-job`),bn(i.job)}var Es=`cadence-recovery-dismissed`,Ds={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.`},Os={"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 ks(){try{let e=JSON.parse(localStorage.getItem(Es)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function As(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function js({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(ks),[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(Es,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Project {name}`,{name:As(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(Ds[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(Os[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Ms={restart:18e4,upgrade:12e5},Ns=1e3,Ps={"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.`},Fs=e=>e instanceof Error?e.message:`unavailable`;function Is(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(Ps[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 Ls(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Rs({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 Cs(e.signal).then(a,t=>{e.signal.aborted||s(Fs(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>Ms[e.action])return w(`timeout`);try{let t=await Cs(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof j||e instanceof Error&&e.message===`invalid`)return w(`changed`);S(!0)}r=setTimeout(i,Ns)};return r=setTimeout(i,Ns),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),ws().then(l,()=>l(`failed`))},k=n=>{i&&(_(!0),s(``),Ts({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(Fs(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`&&Ls(C),o=i?.unit;return(0,h.jsxs)(Qi,{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:Ms[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Is(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)(Qi,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`npm downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let A=i&&c&&typeof c==`object`?wn(c.version,i.version)>0:!1;return(0,h.jsxs)(Qi,{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:Is(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`npm could not be reached.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking npm for the latest version…`)}):A?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):i.upgrade===`npm`?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(Br,{"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)(gr,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function zs({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)},[]),ns({enabled:m,open:d,onOpenChange:p,container:y}),Uo(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)(br,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o&&(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":c(`Cadence service`),"data-tip":c(`Cadence service`),onClick:o,children:(0,h.jsx)(mr,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:l===`zh`?`en`:`zh-CN`,onClick:()=>u(l===`zh`?`en`:`zh`),"aria-label":l===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(Tr,{"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)(pr,{"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===`stopped`?c(`Your last project {name} is not running. Click it below to open it again.`,{name:C(n.path)}):t.length?c(`Conversations are kept with each project. Click a project to open it.`):c(`Conversations are kept with each project. Open a working folder to see its 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)(Dr,{"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(`Opening…`):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)(oo,{hint:c(`Open a working folder to start. Each project keeps its own conversations.`),children:(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:()=>x(),children:[(0,h.jsx)(Dr,{"aria-hidden":`true`}),c(`Open a folder…`)]})})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":c(`Message`),rows:3,placeholder:c(`Open 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)(zr,{"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)(Dr,{"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)(Ro,{disabled:!e,onClick:()=>x()})})]})]})}function Bs(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Yi),[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 bs(t);t.status===400&&xs(r)===`invalid`?n(null):t.ok?(n(mn(r)),p(``)):p(xs(r))}catch{e.signal.aborted||p(`unavailable`)}})(),()=>e.abort()},[m]),(0,f.useEffect)(()=>{let e=()=>{w(),b(null),i(Yi())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[w]),(0,f.useEffect)(()=>{if(!t||!S.current)return;S.current=!1;let e=vs(t);if(!e)return;let n=new AbortController;C.current=n,b({status:`checking`,path:e.cwd}),ys(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:`stopped`,path:e.cwd}))})},[t]);let E=(0,f.useCallback)(e=>{w(),b(null),r&&x.current.set(r,window.location.hash),history.pushState(null,``,e?`/app?project=${e.id}${x.current.get(e.id)??``}`:`/app`),i(e?.id??null),o(null)},[r,w]),D=(0,f.useCallback)(async e=>{if(!t||!ri)throw Error(`unavailable`);let r=crypto.randomUUID(),i=await fetch(`/workbench/v1/open`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t.csrf,"X-Cadence-Build":JSON.stringify({kind:`browser`,...ri})},body:JSON.stringify({commandId:r,path:e,epoch:t.epoch})}),a=await bs(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(xs(a));let o=ln(a.project);n(e=>e&&{...e,projects:[...e.projects.filter(e=>e.id!==o.id),o]}),E(o)},[t,E]),O=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new j(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await bs(n);if(!n.ok){let e=xs(r);return{kind:`error`,error:ee(A.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Xn(r)}}catch{return{kind:`error`,error:ee(`unavailable`)}}}}),[]),k=(0,f.useMemo)(()=>r?ii(r):void 0,[r]),M=t?.projects.find(e=>e.id===r);if((0,f.useEffect)(()=>{M&&_s(M.id)},[M]),t===null)return(0,h.jsx)(ps,{});let N=t&&_&&(0,h.jsx)(Rs,{epoch:t.epoch,csrf:t.csrf,onClose:()=>v(!1)}),P=()=>v(!0);return t&&M&&k?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(ps,{api:k,onOpenProject:D,onWorkbenchHome:()=>E(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r})),notices:(0,h.jsx)(js,{notices:t.recoveries,project:M.path}),onOpenService:P},`${M.id}:${M.epoch}`),N]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(zs,{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)(js,{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.`)})]}),t&&a!==null&&(0,h.jsx)(Oo,{client:O,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:D}),N]})}function Vs(){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 Hs=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Vs,{}):this.props.children}},Us=document.getElementById(`root`);if(!Us)throw Error(`Application root unavailable`);(0,p.createRoot)(Us).render((0,h.jsx)(E,{children:(0,h.jsx)(Hs,{children:(0,h.jsx)(Bs,{})})}));export{ss as t};
|