@abelxiaoxing/cadence 2.0.23 → 2.0.25
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/docs/conversation-mode.md +19 -0
- package/package.json +2 -1
- package/src/agent-panel-model.ts +362 -122
- package/src/agent-panel.ts +142 -49
- package/src/cadence-mode.ts +283 -165
- package/src/coordinator-tools.mjs +9 -0
- package/src/native-build.ts +1 -1
- package/src/native-workflow-history.ts +3 -1
- package/src/research-tools.mjs +365 -0
- package/src/sdk-worker.mjs +59 -9
- package/src/service/contracts/workflow.ts +132 -1
- package/src/service-cli.mjs +15 -2
- package/src/service-host.mjs +217 -29
- package/src/worker-public.mjs +16 -1
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +15 -14
- package/web/dist/manifest.json +7 -7
|
@@ -1,20 +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`,"The shared registry lock is blocking projects. On the service host, run cadence recover inspect --workspace <project> with the same --state-home, then use recover resolve in a local terminal if eligible. Do not delete lock files manually.":`共享注册表锁正在阻止项目打开。请在服务所在主机运行 cadence recover inspect --workspace <project>,使用相同的 --state-home;符合恢复条件时,在本机终端运行 recover resolve。请勿手动删除锁文件。`,"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.":`尚未关联任何项目。`,"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:`子代理`,"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":`旧版上下文`},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}function y({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 b(){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 x(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var S=(0,f.createContext)(x(`en`,()=>{}));function C(){return(0,f.useContext)(S)}function w({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??b()),i=(0,f.useMemo)(()=>x(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)(S.Provider,{value:i,children:t})}var T=`cadence-graph/2`,E=`cadence-public-export/2`,D=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}),O=[`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`],k=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function A(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function j(){throw new k}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new k(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,D.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function W(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ee(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function G(e,t=D.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new k(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&j();let a=t.sort(),o=z(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return j()}return i(e,0)}function K(e,t=D.controlBytes){M(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function te(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,O),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ne=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],re=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],ie=[`not-launched`,`direct-child-closed`,`unconfirmed`],ae=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],oe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function se(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,ae),thinking:I(t.thinking,oe)}}function ce(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...se(n)}}function le(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function ue(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function q(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ne),bytes:P(t.bytes,0,D.detailBytes),sha256:H(t.sha256)}}function de(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,D.detailBytes)}}function fe(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=J(t.source),r;if(n===`current`)r={kind:n,assignmentId:ee(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=q(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,de);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function J(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function pe(e){G(e,D.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=q(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,T),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,D.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ee(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,D.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,D.expectedOutputBytes,!0),role:le(t.role),model:ce(t.model),dependencies:B(t.dependencies,D.assignments,fe)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==ue(e.purpose))throw new k(`forbidden`);c(e)}return i}function me(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function he(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:ce(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,me)}}function ge(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,D.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function _e(e){switch(G(e),J(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=pe(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:J(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:ge(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function ve(e){G(e);let t=z(e,[`expected`,`action`]);return{expected:he(t.expected),action:_e(t.action)}}function ye(e){G(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:he(t.expected),action:_e(t.action)}}function be(e){if(G(e),J(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:he(t.expected),action:_e(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function xe(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function Se(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,ge);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:he(n.version),action:_e(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,pe),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ce(e){G(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:Se(t.preview)}}function Y(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&j(),n}function we(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,D.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=q(t.result);L(i.field,`final-text`);let a=R(t.range,de);a&&a.end>i.bytes&&j();let o=M(t.text,D.predecessorBytes);if(n+=N(o),n>D.handoffBytes)throw new k(`oversize`);let s=P(t.dependencyIndex,0,D.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:ee(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:Y(t.coverage)}})}}function Te(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,ie),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Y(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&j(),n}function X(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Ee(e){let t=M(e,D.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function De(e){G(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:X(t.scope),query:R(t.query,e=>{let t=M(e,D.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,ne)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Oe(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Ne(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function ke(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Ae(e){let t=J(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=q(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,D.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function je(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Ae(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&j(),{owner:n,field:r,encoding:i}}function Me(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&j(),{owner:Ae(t.owner),sourceType:n,mimeType:i,reason:r}}function Ne(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Pe(e){let t=J(e);switch(t){case`ready`:return{kind:t,requestProtocol:L(z(e,[`kind`,`requestProtocol`]).requestProtocol,2)};case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Oe(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...ke({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,D.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:ke(n.declaration),index:P(n.index,0,D.dataFrames),source:Oe(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,ke),source:Oe(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,ke),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Oe(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Me(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:je(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,D.chunkBytes),i=P(n.offset,0,D.detailBytes);return i+N(r)>D.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,D.detailBytes),sha256:H(n.sha256),coverage:Y(n.coverage)}}case`capture-status`:return{kind:t,coverage:Y(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Fe(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,ie),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&j(),n}function Ie(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function Le(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:q(t.content),committedSeq:n}}function Re(e){let t=J(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Ie(n.selected),i=Le(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Ie),error:te(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Ie)}}function ze(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&W(n,t.detail.committedSeq)<0)&&j(),n}function Be(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ve(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Be(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function He(e){let t=J(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Re(n.recording),i=ze(n.settlementSeq,r);return{kind:t,native:Te(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Fe(n.native),capture:Y(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Re(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:ee(t.assignmentId),childRunId:n,native:R(t.native,Te),recording:r,settlementSeq:ze(t.settlementSeq,r)}}),i=I(n.outcome,re);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(Be))&&j(),{kind:`parent`,outcome:i,required:r}}function Ue(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,D.dataFrames+D.controlFrames),r=P(t.last,n,D.dataFrames+D.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function We(e){let t=z(e,[`source`,`event`]),n=Ue(t.source),r=J(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,D.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:Y(e.coverage)}}}let i=Pe(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ge(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Ke(e){G({kind:`ok`,value:e},D.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:qe(n.error)};let i=B(n.runs,D.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&j(),{...r,status:`complete`,runs:i}}function qe(e){let t=te(e);return L(t.effect,`none`),t}function Je(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ye(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Je({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Xe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Je(t.assets)}}function Ze(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 Qe(e){G(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,re)),settlement:R(t.settlement,He),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ve(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function $e(e){G(e);let t=z(e,[`identity`,`receipt`]),n=be(t.identity),r=Qe(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(J(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:te(n.error)}}function et(e){switch(G(e),J(e,`status`)){case`found`:return{status:`found`,receipt:Qe(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:te(z(e,[`status`,`error`]).error)};default:return j()}}function tt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,ee),admission:dt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,re)),settlement:R(t.settlement,He),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Y(t.coverage),result:R(t.result,q)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&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&&Ve(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ve(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function nt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function rt(e,t,n){return nt(e,t)&&e.taskId===mt(n)&&e.admission.context.workspaceId===pt(n)}function it(e){G(e,D.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:X(t.scope),committedSeq:U(t.committedSeq),context:ft(t.context),runs:B(t.runs,D.maxPageEntries,tt),horizon:Et(t.horizon)};return(!ht(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=>!rt(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function at(e){G(e,D.pageBytes);let t=J(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:X(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);W(r.committedSeq,e)<=0&&j();let i=ft(n.context);ht(i,r.epoch,r.scope)||j();let a=B(n.runs,D.maxPageEntries,tt),o=B(n.removed,D.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!rt(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function ot(e){let{navigation:t,...n}=e;return n}function st(e,t){(!t.navigation||t.navigation===e.navigation||G(ot(e))!==G(ot(t)))&&j()}function ct(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return lt(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=De(t.cursor),r=De(t.next);return st(n,r),{kind:`progress`,cursor:n,next:r,coverage:Y(t.coverage)}}function lt(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:De(t.cursor),content:q(t.content),range:R(t.range,de),text:M(t.text,D.detailPageBytes),next:R(t.next,De),coverage:Y(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||G(ot({...n.next,offset:n.cursor.offset}))!==G(ot(n.cursor)))&&j(),n}function ut(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=De(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,D.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=q(t.content),a=vt(t.owner);yt(a,n.scope)||j();let o=de(t.range),s=De(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)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,D.previewBytes),cursor:s}}),a=R(t.next,De);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)))&&j(),{cursor:n,hits:i,next:a,coverage:Y(t.coverage)}}function dt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=he(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:ee(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function ft(e){if(J(e,`status`)===`available`)return{status:`available`,version:he(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=te(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function pt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function mt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function ht(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||mt(e)===n.id)}function gt(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Xe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function _t(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Ke(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:ft(t.context),models:B(t.models,D.maxPageEntries,ce)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(pt(n.context)!==n.workspaceId||mt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function vt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&j(),r}function yt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function bt(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function xt(e){G(e,D.controlBytes);let t=J(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:dt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=He(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:we(n.handoff),observation:bt(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=q(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:bt(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:ge(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:bt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Fe(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=bt(r.before),c=bt(r.after),l=R(r.output,q),u=Y(r.coverage);return l&&l.field!==`check`&&j(),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`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=q(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function St(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Ct(e){G(e,D.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=St(t.link),r=B(t.events,D.ownerQueueFrames,e=>{let t=J(e);if(t===`fact`){let r=xt(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=vt(r.owner),a=I(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,D.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:Y(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var wt=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Tt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,wt),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,D.maxPageEntries)}}function Et(e){let t=z(e,[`policy`,`historicalRuns`]),n=Tt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function Dt(e){let t=J(e);if(t===`run`)return{kind:t,projection:tt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:Ge(n.link),capture:We(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Ct({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=z(e,[...n,...r]),a=vt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,q);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,D.dataFrames)),s=R(i.finalText,q),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Oe(i.source)}}if(t===`tool`){let e=R(i.declaration,ke),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Pe(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Oe(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=je(i.descriptor),n=q(i.content);return(e.field!==n.field||!Ot(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:Y(i.coverage)}}L(t,`omitted`);let s=Me(i.block);return Ot(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function Ot(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 kt(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 At(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Tt(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,Dt),i=R(t.next,Tt);return(r.some(e=>!kt(e,n))||i&&(i.after===null||G(ot({...i,after:n.after}))!==G(ot(n))||G(i.after)===G(n.after)))&&j(),{request:n,records:r,next:i,coverage:Y(t.coverage)}}function jt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tt(t.request),r=Tt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||G(ot({...r,snapshotSeq:null}))!==G(ot(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:Y(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return At(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tt(t.request),r=Tt(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function Mt(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Nt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function Pt(e){G({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Nt(t.request),r=pe(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Ft(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Pt(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Nt(t.request),r=Nt(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function It(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function Lt(e){G(e,D.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=J(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,E),request:It(e.request),coverage:Y(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Dt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Pt(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=q(e.content),a=R(e.range,de),o=M(e.text,D.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:vt(e.owner),content:i,range:a,text:o,coverage:Y(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,D.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Y(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Rt(e,t){let n=Lt(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=It(e)}receive(e){let t=Lt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!yt(n.owner,this.request.scope)&&j(),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)&&j(),n.kind===`record`&&!Bt(n.record,this.request.scope)&&j(),this.bytes+=N(Rt(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 Bt(e,t){return e.kind===`run`?nt(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:yt(e.owner,t)}function Vt(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=ge(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Ht(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Ut(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`record`]),n=Ht(t.request),r=Dt(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||!yt(r.owner,n.scope))&&j(),{request:n,record:r}}function Wt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ut(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ht(t.request),r=Ht(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}var Gt=e=>{let t=te(e);return L(t.effect,`none`),t};function Kt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function qt(e){let t=Kt(e);return t.taskId===null&&j(),t}function Jt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Yt(e){let t=B(e,3,le);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Xt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Nt(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:Gt(n.error)}}function Zt(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||pt(e.context)!==e.workspaceId||mt(e.context)!==e.request.taskId)&&j(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&j()}}function Qt(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Kt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:ft(t.context),task:R(t.task,Jt),roles:Yt(t.roles),savedGraph:Xt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=Y(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};Zt(n),!!n.task!=!!n.readablePlan&&j();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function $t(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:qt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:ft(t.context),task:Jt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:Y(t.coverage)};if(Zt(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&j()}return r}function en(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function tn(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`]);return{version:en(t.version),selected:R(t.selected,ce)}}function nn(e){G(e);let t=z(e,[`expected`,`choice`]);return{expected:en(t.expected),choice:se(t.choice)}}function rn(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,ae)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,oe),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function an(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`]),n=B(t.entries,D.maxPageEntries,rn),r=I(t.status,[`complete`,`capacity`]),i=P(t.withheld,0,D.maxPageEntries);return(r===`capacity`&&(n.length||i)||n.length+i>D.maxPageEntries||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length)&&j(),{version:en(t.version),selected:R(t.selected,ce),status:r,entries:n,withheld:i}}function on(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:V(t.epoch)}}function sn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,on),build:Xe(t.build)}}var cn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function ln(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function un(e,t=!1){let n=M(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`Invalid workflow file path`);return n}var dn=(e,t=!1)=>{let n=M(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function fn(e){let t=z(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,12e5)}}function pn(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 mn(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 pn(e),r(t),pn(e).filter(e=>n.has(e.id))}function hn(e,t={}){let n=t.strict===!0;G(e,cn.bytes);let r=z(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=B(r.tasks,cn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:dn(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>un(e,n)),after:B(t.after,cn.tasks,e=>dn(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`);pn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||mn(i,e.id).some(e=>e.id===t.id)||mn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>ln(t.writes,e))||t.writes.some(t=>ln(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=B(r.checks,cn.checks,fn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:M(r.goal,8192,!0),design:M(r.design,32768,!0),decisions:M(r.decisions,16384),acceptance:M(r.acceptance,16384,!0),projectContext:M(r.projectContext,16384),tasks:i,checks:a,setup:B(r.setup,4,fn),baselineChecks:B(r.baselineChecks,cn.checks,fn),repairAttempts:P(r.repairAttempts,0,cn.repairs),delivery:I(r.delivery,[`local-merge`,`working-copy`])};gn(o),M(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
2
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function gn(e){return M(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function _n(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=z(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...t?[`display`]:[]]);return{id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:en(n.model),plan:hn(n.plan),cwd:M(n.cwd,4096,!0),...t?{display:(()=>{let e=z(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function vn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=z(e,[`action`,`goal`,`questions`,`model`]),r=B(n.questions,cn.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);return{action:t,goal:M(n.goal,8192,!0),questions:r,model:en(n.model)}}if(t===`propose`){let n=z(e,[`action`,`plan`,`model`]);return{action:t,plan:hn(n.plan),model:en(n.model)}}if(t===`prepare`||t===`execute`){let n=z(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:V(n.proposalId),digest:H(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:V(n.grant)}}let n=z(e,[`action`,`runId`]);return{action:I(n.action,[`cancel`]),runId:V(n.runId)}}function yn(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`]),n=e=>I(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{id:V(t.id),epoch:V(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:I(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:R(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:B(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=z(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...t?[`childRunId`]:[]]);return{id:M(r.id,160,!0),...t?{childRunId:V(r.childRunId)}:{},kind:I(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function bn(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:yn(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:_n(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:_n(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function xn(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${pn(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}\n${e.instructions}`).join(`
|
|
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`,"The shared registry lock is blocking projects. On the service host, run cadence recover inspect --workspace <project> with the same --state-home, then use recover resolve in a local terminal if eligible. Do not delete lock files manually.":`共享注册表锁正在阻止项目打开。请在服务所在主机运行 cadence recover inspect --workspace <project>,使用相同的 --state-home;符合恢复条件时,在本机终端运行 recover resolve。请勿手动删除锁文件。`,"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.":`尚未关联任何项目。`,"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":`旧版上下文`},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}function y({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 b(){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 x(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var S=(0,f.createContext)(x(`en`,()=>{}));function C(){return(0,f.useContext)(S)}function w({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??b()),i=(0,f.useMemo)(()=>x(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)(S.Provider,{value:i,children:t})}var T=`cadence-graph/2`,E=`cadence-public-export/2`,D=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}),O=[`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`],k=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function A(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function j(){throw new k}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new k(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,D.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function W(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function ee(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function G(e,t=D.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new k(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&j();let a=t.sort(),o=z(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return j()}return i(e,0)}function K(e,t=D.controlBytes){M(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function te(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,O),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ne=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],re=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],ie=[`not-launched`,`direct-child-closed`,`unconfirmed`],ae=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],oe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function se(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,ae),thinking:I(t.thinking,oe)}}function ce(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...se(n)}}function le(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function ue(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function q(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ne),bytes:P(t.bytes,0,D.detailBytes),sha256:H(t.sha256)}}function de(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,D.detailBytes)}}function fe(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=J(t.source),r;if(n===`current`)r={kind:n,assignmentId:ee(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=q(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,de);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function J(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function pe(e){G(e,D.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=q(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,T),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,D.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:ee(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,D.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,D.expectedOutputBytes,!0),role:le(t.role),model:ce(t.model),dependencies:B(t.dependencies,D.assignments,fe)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==ue(e.purpose))throw new k(`forbidden`);c(e)}return i}function me(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function he(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:ce(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,me)}}function ge(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,D.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function _e(e){switch(G(e),J(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=pe(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:J(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:ge(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function ve(e){G(e);let t=z(e,[`expected`,`action`]);return{expected:he(t.expected),action:_e(t.action)}}function ye(e){G(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:he(t.expected),action:_e(t.action)}}function be(e){if(G(e),J(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:he(t.expected),action:_e(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function xe(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function Se(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,ge);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:he(n.version),action:_e(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,pe),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Ce(e){G(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:Se(t.preview)}}function Y(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&j(),n}function we(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,D.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=q(t.result);L(i.field,`final-text`);let a=R(t.range,de);a&&a.end>i.bytes&&j();let o=M(t.text,D.predecessorBytes);if(n+=N(o),n>D.handoffBytes)throw new k(`oversize`);let s=P(t.dependencyIndex,0,D.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:ee(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:Y(t.coverage)}})}}function Te(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,ie),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Y(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&j(),n}function X(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Ee(e){let t=M(e,D.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function De(e){G(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:X(t.scope),query:R(t.query,e=>{let t=M(e,D.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,ne)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Oe(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Ne(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function ke(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Ae(e){let t=J(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=q(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,D.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function je(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Ae(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&j(),{owner:n,field:r,encoding:i}}function Me(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&j(),{owner:Ae(t.owner),sourceType:n,mimeType:i,reason:r}}function Ne(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Pe(e){let t=J(e);switch(t){case`ready`:{let n=z(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:L(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=z(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()}}}case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Oe(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...ke({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,D.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:ke(n.declaration),index:P(n.index,0,D.dataFrames),source:Oe(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,ke),source:Oe(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,ke),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Oe(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Me(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:je(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,D.chunkBytes),i=P(n.offset,0,D.detailBytes);return i+N(r)>D.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,D.detailBytes),sha256:H(n.sha256),coverage:Y(n.coverage)}}case`capture-status`:return{kind:t,coverage:Y(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Fe(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,ie),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&j(),n}function Ie(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function Le(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:q(t.content),committedSeq:n}}function Re(e){let t=J(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Ie(n.selected),i=Le(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Ie),error:te(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Ie)}}function ze(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&W(n,t.detail.committedSeq)<0)&&j(),n}function Be(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ve(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Be(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function He(e){let t=J(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Re(n.recording),i=ze(n.settlementSeq,r);return{kind:t,native:Te(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Fe(n.native),capture:Y(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Re(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:ee(t.assignmentId),childRunId:n,native:R(t.native,Te),recording:r,settlementSeq:ze(t.settlementSeq,r)}}),i=I(n.outcome,re);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(Be))&&j(),{kind:`parent`,outcome:i,required:r}}function Ue(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,D.dataFrames+D.controlFrames),r=P(t.last,n,D.dataFrames+D.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function We(e){let t=z(e,[`source`,`event`]),n=Ue(t.source),r=J(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,D.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:Y(e.coverage)}}}let i=Pe(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ge(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function Ke(e){G({kind:`ok`,value:e},D.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:qe(n.error)};let i=B(n.runs,D.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&j(),{...r,status:`complete`,runs:i}}function qe(e){let t=te(e);return L(t.effect,`none`),t}function Je(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Ye(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Je({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Xe(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Je(t.assets)}}function Ze(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 Qe(e){G(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,re)),settlement:R(t.settlement,He),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ve(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function $e(e){G(e);let t=z(e,[`identity`,`receipt`]),n=be(t.identity),r=Qe(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function Z(e,t){if(J(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:te(n.error)}}function et(e){switch(G(e),J(e,`status`)){case`found`:return{status:`found`,receipt:Qe(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:te(z(e,[`status`,`error`]).error)};default:return j()}}function tt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,ee),admission:dt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,re)),settlement:R(t.settlement,He),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Y(t.coverage),result:R(t.result,q)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&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&&Ve(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ve(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function nt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function rt(e,t,n){return nt(e,t)&&e.taskId===mt(n)&&e.admission.context.workspaceId===pt(n)}function it(e){G(e,D.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:X(t.scope),committedSeq:U(t.committedSeq),context:ft(t.context),runs:B(t.runs,D.maxPageEntries,tt),horizon:Et(t.horizon)};return(!ht(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=>!rt(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function at(e){G(e,D.pageBytes);let t=J(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:X(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);W(r.committedSeq,e)<=0&&j();let i=ft(n.context);ht(i,r.epoch,r.scope)||j();let a=B(n.runs,D.maxPageEntries,tt),o=B(n.removed,D.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!rt(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function ot(e){let{navigation:t,...n}=e;return n}function st(e,t){(!t.navigation||t.navigation===e.navigation||G(ot(e))!==G(ot(t)))&&j()}function ct(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return lt(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=De(t.cursor),r=De(t.next);return st(n,r),{kind:`progress`,cursor:n,next:r,coverage:Y(t.coverage)}}function lt(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:De(t.cursor),content:q(t.content),range:R(t.range,de),text:M(t.text,D.detailPageBytes),next:R(t.next,De),coverage:Y(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||G(ot({...n.next,offset:n.cursor.offset}))!==G(ot(n.cursor)))&&j(),n}function ut(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=De(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,D.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=q(t.content),a=vt(t.owner);yt(a,n.scope)||j();let o=de(t.range),s=De(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)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,D.previewBytes),cursor:s}}),a=R(t.next,De);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)))&&j(),{cursor:n,hits:i,next:a,coverage:Y(t.coverage)}}function dt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=he(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:ee(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function ft(e){if(J(e,`status`)===`available`)return{status:`available`,version:he(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=te(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function pt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function mt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function ht(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||mt(e)===n.id)}function gt(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Xe(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function _t(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:Ke(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:ft(t.context),models:B(t.models,D.maxPageEntries,ce)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(pt(n.context)!==n.workspaceId||mt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function vt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&j(),r}function yt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function bt(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function xt(e){G(e,D.controlBytes);let t=J(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:dt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=He(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:we(n.handoff),observation:bt(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=q(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:bt(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:ge(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:bt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Fe(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=bt(r.before),c=bt(r.after),l=R(r.output,q),u=Y(r.coverage);return l&&l.field!==`check`&&j(),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`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=q(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function St(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function Ct(e){G(e,D.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=St(t.link),r=B(t.events,D.ownerQueueFrames,e=>{let t=J(e);if(t===`fact`){let r=xt(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=vt(r.owner),a=I(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,D.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:Y(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var wt=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Tt(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,wt),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,D.maxPageEntries)}}function Et(e){let t=z(e,[`policy`,`historicalRuns`]),n=Tt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function Dt(e){let t=J(e);if(t===`run`)return{kind:t,projection:tt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:Ge(n.link),capture:We(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Ct({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=z(e,[...n,...r]),a=vt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,q);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,D.dataFrames)),s=R(i.finalText,q),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Oe(i.source)}}if(t===`tool`){let e=R(i.declaration,ke),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Pe(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Oe(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=je(i.descriptor),n=q(i.content);return(e.field!==n.field||!Ot(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:Y(i.coverage)}}L(t,`omitted`);let s=Me(i.block);return Ot(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function Ot(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 kt(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 At(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Tt(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,Dt),i=R(t.next,Tt);return(r.some(e=>!kt(e,n))||i&&(i.after===null||G(ot({...i,after:n.after}))!==G(ot(n))||G(i.after)===G(n.after)))&&j(),{request:n,records:r,next:i,coverage:Y(t.coverage)}}function jt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tt(t.request),r=Tt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||G(ot({...r,snapshotSeq:null}))!==G(ot(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:Y(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return At(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tt(t.request),r=Tt(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function Mt(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Nt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function Pt(e){G({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Nt(t.request),r=pe(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Ft(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Pt(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Nt(t.request),r=Nt(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}function It(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function Lt(e){G(e,D.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=J(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,E),request:It(e.request),coverage:Y(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Dt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Pt(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=q(e.content),a=R(e.range,de),o=M(e.text,D.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:vt(e.owner),content:i,range:a,text:o,coverage:Y(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,D.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Y(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Rt(e,t){let n=Lt(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=It(e)}receive(e){let t=Lt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!yt(n.owner,this.request.scope)&&j(),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)&&j(),n.kind===`record`&&!Bt(n.record,this.request.scope)&&j(),this.bytes+=N(Rt(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 Bt(e,t){return e.kind===`run`?nt(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:yt(e.owner,t)}function Vt(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=ge(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Ht(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Ee(t.navigation)}:{},storeId:V(t.storeId),scope:X(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Ut(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`record`]),n=Ht(t.request),r=Dt(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||!yt(r.owner,n.scope))&&j(),{request:n,record:r}}function Wt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ut(e);G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ht(t.request),r=Ht(t.next);return st(n,r),{kind:`progress`,request:n,next:r,coverage:Y(t.coverage)}}var Gt=e=>{let t=te(e);return L(t.effect,`none`),t};function Kt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function qt(e){let t=Kt(e);return t.taskId===null&&j(),t}function Jt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Yt(e){let t=B(e,3,le);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Xt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Nt(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:Gt(n.error)}}function Zt(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||pt(e.context)!==e.workspaceId||mt(e.context)!==e.request.taskId)&&j(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&j()}}function Qt(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Kt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:ft(t.context),task:R(t.task,Jt),roles:Yt(t.roles),savedGraph:Xt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=Y(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};Zt(n),!!n.task!=!!n.readablePlan&&j();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function $t(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:qt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:ft(t.context),task:Jt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:Y(t.coverage)};if(Zt(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&j()}return r}function en(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function tn(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`]);return{version:en(t.version),selected:R(t.selected,ce)}}function nn(e){G(e);let t=z(e,[`expected`,`choice`]);return{expected:en(t.expected),choice:se(t.choice)}}function rn(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,ae)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,oe),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function an(e){G({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`]),n=B(t.entries,D.maxPageEntries,rn),r=I(t.status,[`complete`,`capacity`]),i=P(t.withheld,0,D.maxPageEntries);return(r===`capacity`&&(n.length||i)||n.length+i>D.maxPageEntries||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length)&&j(),{version:en(t.version),selected:R(t.selected,ce),status:r,entries:n,withheld:i}}function on(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:V(t.epoch)}}function sn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,on),build:Xe(t.build)}}var cn={tasks:16,parallel:2,checks:16,repairs:2,bytes:262144,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4,durationMs:54e5};function ln(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function un(e,t=!1){let n=M(e,1024,!0);if(n.startsWith(`/`)||n.includes(`\\`)||[...n].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127||e===`:`)||t&&/[\p{Cf}\p{Zl}\p{Zp}]/u.test(n)||n.split(`/`).some(e=>!e||e===`.`||e===`..`||e.toLowerCase()===`.git`)||/(^|\/)\.env(?:\.|$)/iu.test(n))throw Error(`Invalid workflow file path`);return n}var dn=(e,t=!1)=>{let n=M(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`Invalid task id`);return n};function fn(e){let t=z(e,[`name`,`command`,`timeoutMs`]);return{name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,12e5)}}function pn(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 mn(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 pn(e),r(t),pn(e).filter(e=>n.has(e.id))}function hn(e,t={}){let n=t.strict===!0;G(e,cn.bytes);let r=z(e,[`goal`,`design`,`decisions`,`acceptance`,`projectContext`,`tasks`,`checks`,`setup`,`baselineChecks`,`repairAttempts`,`delivery`]),i=B(r.tasks,cn.tasks,e=>{let t=z(e,[`id`,`title`,`instructions`,`writes`,`after`]);return{id:dn(t.id,n),title:M(t.title,256,!0),instructions:M(t.instructions,8192,!0),writes:B(t.writes,128,e=>un(e,n)),after:B(t.after,cn.tasks,e=>dn(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`);pn(i);for(let e of i)for(let t of i)if(!(e.id>=t.id||mn(i,e.id).some(e=>e.id===t.id)||mn(i,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>ln(t.writes,e))||t.writes.some(t=>ln(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let a=B(r.checks,cn.checks,fn);if(!a.length)throw Error(`At least one real verification command is required`);let o={goal:M(r.goal,8192,!0),design:M(r.design,32768,!0),decisions:M(r.decisions,16384),acceptance:M(r.acceptance,16384,!0),projectContext:M(r.projectContext,16384),tasks:i,checks:a,setup:B(r.setup,4,fn),baselineChecks:B(r.baselineChecks,cn.checks,fn),repairAttempts:P(r.repairAttempts,0,cn.repairs),delivery:I(r.delivery,[`local-merge`,`working-copy`])};gn(o),M(o.tasks.flatMap(e=>e.writes).join(`, `),16384);for(let e of[o.goal,o.design,o.decisions,o.acceptance,o.projectContext,...o.tasks.flatMap(e=>[e.title,e.instructions]),...[...o.checks,...o.setup,...o.baselineChecks].flatMap(e=>[e.name,e.command])])if([...e].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
2
|
+
`&&e!==` `||e.charCodeAt(0)===127||/[\u202a-\u202e\u2066-\u2069]/u.test(e)))throw Error(`Plan contains invisible terminal controls`);return o}function gn(e){return M(`# ${e.goal}\n\n${e.design}\n\nDecisions: ${e.decisions}\n\nAcceptance: ${e.acceptance}`,32768,!0)}function _n(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=z(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...t?[`display`]:[]]);return{id:V(n.id),epoch:V(n.epoch),digest:H(n.digest),observation:H(n.observation),model:en(n.model),plan:hn(n.plan),cwd:M(n.cwd,4096,!0),...t?{display:(()=>{let e=z(n.display,[`model`,`branch`,`baseCommit`]);return{model:M(e.model,1024,!0),branch:M(e.branch,1024),baseCommit:M(e.baseCommit,64)}})()}:{}}}function vn(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=z(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=B(n.questions,cn.parallel,e=>M(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:B(n.roots,8,e=>M(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:M(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:en(n.model)}}if(t===`propose`){let n=z(e,[`action`,`plan`,`model`]);return{action:t,plan:hn(n.plan),model:en(n.model)}}if(t===`prepare`||t===`execute`){let n=z(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:V(n.proposalId),digest:H(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:V(n.grant)}}let n=z(e,[`action`,`runId`]);return{action:I(n.action,[`cancel`]),runId:V(n.runId)}}function yn(e){let t=z(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[]]),n=e=>I(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:wn(t.diagnostics)},id:V(t.id),epoch:V(t.epoch),goal:M(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:I(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`integrating`,`finished`]),notice:M(t.notice,2048),mergedCommit:R(t.mergedCommit,e=>M(e,64,!0)),humanReviewed:!1,steps:B(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=z(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Cn(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=z(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:M(e.sdkVersion,128,!0),workerHash:H(e.workerHash)}})()},id:M(r.id,160,!0),...t?{childRunId:V(r.childRunId)}:{},kind:I(r.kind,[`research`,`implementation`,`review`,`check`,`git`]),status:n(r.status),text:M(r.text,65536),exitCode:R(r.exitCode,e=>P(e,-2147483648,2147483647)),truncated:F(r.truncated)}})}}function bn(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:yn(z(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:_n(z(e,[`type`,`proposal`]).proposal)};let n=z(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:I(n.type,[`grant`]),proposal:_n(n.proposal),grant:V(n.grant),expiresAt:P(n.expiresAt,0)}}function xn(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${pn(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`}function Sn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=z(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:V(n.id),revision:P(n.revision,0),enabled:F(n.enabled),head:R(n.head,V),proposal:R(n.proposal,_n),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}var Cn=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function wn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`cadence-conversation`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=z(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:R(r.after,V),...n?{scan:V(r.scan)}:{}}}case`workflow-active`:return z(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=z(e,[`kind`,`id`,`stepId`]);return{kind:t,id:V(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`conversations`:case`projects`:return z(e,[`kind`]),{kind:t};case`task-origin`:return{kind:t,taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`conversation`:{let n=z(e,[`kind`,`id`,`before`]);return{kind:t,id:V(n.id),before:R(n.before,V)}}default:{let t=z(e,[`kind`,`path`]);return{kind:I(t.kind,[`files`,`file`,`directories`]),path:M(t.path,4096)}}}}function Tn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`restore-model`||t===`workflow-cancel`){let n=z(e,t===`restore-model`?[`kind`,`commandId`,`epoch`]:[`kind`,`commandId`,`epoch`,`runId`]),r={commandId:V(n.commandId),epoch:V(n.epoch)};return t===`restore-model`?{kind:t,...r}:{kind:t,...r,runId:V(n.runId)}}if(t===`cadence-exit`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),revision:P(n.revision,0)}}if(t===`cadence-send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`,`revision`,`intent`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),text:M(n.text,16384,!0),model:en(n.model),revision:P(n.revision,0),intent:I(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=z(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:V(r.commandId),conversationId:V(r.conversationId),revision:P(r.revision,0),proposalId:V(r.proposalId),digest:H(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:V(r.grant)}}if(t===`workflow`){let n=z(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),request:vn(n.request)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),text:M(n.text,16384,!0),model:en(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function En(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=z(e,n?[...t,`omitted`]:t),i=n?z(r.omitted,[`thinking`,`media`,`other`]):null;return{id:V(r.id),epoch:V(r.epoch),status:I(r.status,Cn),notice:M(r.notice,1024),omitted:{thinking:i?F(i.thinking):!1,media:i?F(i.media):!1,other:i?F(i.other):!1},items:B(r.items,256,e=>{let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}})}}function Dn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`cadence`),n=z(e,[`id`,`title`,`head`,`status`,`updatedAt`,...t?[`cadence`]:[]]);return{id:V(n.id),title:M(n.title,512,!0),head:V(n.head),status:I(n.status,Cn),updatedAt:P(n.updatedAt,0),...t?{cadence:F(n.cadence)}:{}}}function On(e){G(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`workflow-transcript`){let n=z(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:V(n.runId),stepId:M(n.stepId,160,!0),turn:R(n.turn,En)}}if(t===`cadence-conversation`)return{kind:t,state:Sn(z(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=z(e,[`kind`,`after`,`scan`]);return{kind:t,after:R(n.after,V),scan:V(n.scan)}}if(t===`workflow-history`){let n=z(e,[`kind`,`entries`,`next`]),r=B(n.entries,cn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,yn);if(r&&r.id!==n)throw new k(`invalid`);return{id:n,run:r}}),i=R(n.next,V);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new k(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=z(e,[`kind`,`runs`,...n?[`links`]:[]]),i=B(r.runs,4,yn),a=n?B(r.links,4,e=>{let t=z(e,[`runId`,`conversationId`]);return{runId:V(t.runId),conversationId:V(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 k(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=z(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:V(n.commandId),grant:V(n.grant),expiresAt:P(n.expiresAt,0),revision:P(n.revision,0),proposal:_n(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=z(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:R(t.commandId,V),response:bn(t.response)}}if(n===`task-origin`){let t=z(e,[`kind`,`taskId`,`conversationId`]);return{kind:n,taskId:V(t.taskId),conversationId:R(t.conversationId,V)}}if(n===`conversations`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,200,Dn)};if(n===`conversation`){let t=z(e,[`kind`,`summary`,`turns`,`before`]);return{kind:n,summary:R(t.summary,Dn),turns:B(t.turns,20,En),before:R(t.before,V)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:R(t.parent,e=>M(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:F(t.limited)}}if(n===`projects`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(n===`accepted`)return{kind:n,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let r=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(r.kind,[`project`]),commandId:V(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var kn={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`},An=`/api/v1/events`,jn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Mn(e,t){if(jn.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 D.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 D.pageBytes}return D.controlBytes}function Nn(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Pn(e,t){switch(e){case`workbenchRead`:return wn(t);case`workbenchCommand`:return Tn(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new k(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Tt(t);if(n.reader!==e)throw new k(`invalid`);return n}case`current`:return Kt(t);case`currentChanges`:return qt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Ht(t);case`graph`:return Nt(t);case`snapshot`:return X(t);case`detail`:case`search`:return De(t);case`export`:case`download`:return It(t);case`chooseModel`:return nn(t);case`preflight`:return ve(t);case`command`:return ye(t);case`cancel`:return xe(t)}}function Fn(e,t){if(jn.includes(e))return Z(t,jt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,On);case`current`:return Z(t,Qt);case`currentChanges`:return Z(t,$t);case`activeRuns`:return Z(t,Ke);case`models`:return Z(t,an);case`chooseModel`:return Z(t,tn);case`session`:return Z(t,gt);case`workspace`:return Z(t,_t);case`checkObligations`:return Z(t,Vt);case`entity`:return Z(t,Wt);case`graph`:return Z(t,Ft);case`snapshot`:return Z(t,it);case`detail`:return Z(t,ct);case`search`:return Z(t,ut);case`preflight`:return Z(t,Ce);case`command`:case`cancel`:return Z(t,Qe);case`receipt`:return et(t);case`detach`:return Z(t,e=>{if(e!==null)throw new k(`invalid`);return null});default:throw new k(`invalid`)}}function In(e){return[...jn,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ln(e,t){let n=kn[e];return t===null||Nn(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function Rn(e,t){let n=Pn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?kn[e]:Ln(e,n);return Nn(e)||In(e)&&(r||N(i)>D.headerBytes/4)?{path:kn[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function zn(e){G(e,D.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:it(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:at(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Bn=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 k(`invalid`);this.origin=e.origin,e.build&&=Ye(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 k(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Rn(e,Pn(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=V(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await Vn(a,Mn(e)),c=K(s);if(N(s)>Mn(e,c))throw new k(`oversize`);let l=Fn(e,c);if(e===`session`){let e=Z(l,gt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new k(`forbidden`);this.attachment=o??V(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`,nn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Ht(e),t)}tasks(e,t){return this.request(`tasks`,Tt(e),t)}runs(e,t){return this.request(`runs`,Tt(e),t)}messages(e,t){return this.request(`messages`,Tt(e),t)}tools(e,t){return this.request(`tools`,Tt(e),t)}contents(e,t){return this.request(`contents`,Tt(e),t)}events(e,t){return this.request(`events`,Tt(e),t)}checks(e,t){return this.request(`checks`,Tt(e),t)}changes(e,t){return this.request(`changes`,Tt(e),t)}reviews(e,t){return this.request(`reviews`,Tt(e),t)}graph(e,t){return this.request(`graph`,Nt(e),t)}preflight(e){return this.request(`preflight`,ve(e))}command(e){return this.request(`command`,ye(e))}cancel(e){return this.request(`cancel`,xe(e))}receipt(e,t){return this.request(`receipt`,V(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new k(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new k(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Rn(`export`,It(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 k(`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 k(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=D.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+D.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
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 Sn=e=>P(e,0,864e13);function Cn(e){let t=z(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,`timeoutMs`,`stopReason`]);return{createdAt:Sn(t.createdAt),preparedAt:R(t.preparedAt,Sn),startedAt:R(t.startedAt,Sn),stopRequestedAt:R(t.stopRequestedAt,Sn),closedAt:R(t.closedAt,Sn),settledAt:R(t.settledAt,Sn),timeoutMs:P(t.timeoutMs,100,12e5),stopReason:R(t.stopReason,e=>M(e,32,!0))}}function wn(e){let t=z(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=z(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Sn(t.acceptedAt),acquiredAt:R(t.acquiredAt,Sn),settledAt:R(t.settledAt,Sn),owner:{version:M(n.version,128,!0),build:M(n.build,64,!0),entry:M(n.entry,4096,!0),pid:P(n.pid,1),node:M(n.node,128,!0),platform:M(n.platform,32,!0),startedAt:Sn(n.startedAt)}}}function Tn(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 En(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=z(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:V(n.id),revision:P(n.revision,0),enabled:F(n.enabled),head:R(n.head,V),proposal:R(n.proposal,_n),runs:B(n.runs,200,V),...t?{notice:M(n.notice,1024,!0)}:{}}}var Dn=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function On(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`cadence-conversation`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=z(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:R(r.after,V),...n?{scan:V(r.scan)}:{}}}case`workflow-active`:return z(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=z(e,[`kind`,`id`,`stepId`]);return{kind:t,id:V(n.id),stepId:M(n.stepId,160,!0)}}case`workflow`:return{kind:t,id:V(z(e,[`kind`,`id`]).id)};case`conversations`:case`projects`:return z(e,[`kind`]),{kind:t};case`task-origin`:return{kind:t,taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`conversation`:{let n=z(e,[`kind`,`id`,`before`]);return{kind:t,id:V(n.id),before:R(n.before,V)}}default:{let t=z(e,[`kind`,`path`]);return{kind:I(t.kind,[`files`,`file`,`directories`]),path:M(t.path,4096)}}}}function kn(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`restore-model`||t===`workflow-cancel`){let n=z(e,t===`restore-model`?[`kind`,`commandId`,`epoch`]:[`kind`,`commandId`,`epoch`,`runId`]),r={commandId:V(n.commandId),epoch:V(n.epoch)};return t===`restore-model`?{kind:t,...r}:{kind:t,...r,runId:V(n.runId)}}if(t===`cadence-exit`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),revision:P(n.revision,0)}}if(t===`cadence-send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`,`revision`,`intent`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),text:M(n.text,16384,!0),model:en(n.model),revision:P(n.revision,0),intent:I(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=z(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:V(r.commandId),conversationId:V(r.conversationId),revision:P(r.revision,0),proposalId:V(r.proposalId),digest:H(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:V(r.grant)}}if(t===`workflow`){let n=z(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),request:vn(n.request)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),text:M(n.text,16384,!0),model:en(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function An(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=z(e,n?[...t,`omitted`]:t),i=n?z(r.omitted,[`thinking`,`media`,`other`]):null;return{id:V(r.id),epoch:V(r.epoch),status:I(r.status,Dn),notice:M(r.notice,1024),omitted:{thinking:i?F(i.thinking):!1,media:i?F(i.media):!1,other:i?F(i.other):!1},items:B(r.items,256,e=>{let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}})}}function jn(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`cadence`),n=z(e,[`id`,`title`,`head`,`status`,`updatedAt`,...t?[`cadence`]:[]]);return{id:V(n.id),title:M(n.title,512,!0),head:V(n.head),status:I(n.status,Dn),updatedAt:P(n.updatedAt,0),...t?{cadence:F(n.cadence)}:{}}}function Mn(e){G(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`workflow-transcript`){let n=z(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:V(n.runId),stepId:M(n.stepId,160,!0),turn:R(n.turn,An)}}if(t===`cadence-conversation`)return{kind:t,state:En(z(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=z(e,[`kind`,`after`,`scan`]);return{kind:t,after:R(n.after,V),scan:V(n.scan)}}if(t===`workflow-history`){let n=z(e,[`kind`,`entries`,`next`]),r=B(n.entries,cn.historyPage,e=>{let t=z(e,[`id`,`run`]),n=V(t.id),r=R(t.run,yn);if(r&&r.id!==n)throw new k(`invalid`);return{id:n,run:r}}),i=R(n.next,V);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new k(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=z(e,[`kind`,`runs`,...n?[`links`]:[]]),i=B(r.runs,4,yn),a=n?B(r.links,4,e=>{let t=z(e,[`runId`,`conversationId`]);return{runId:V(t.runId),conversationId:V(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 k(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-grant`){let n=z(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:V(n.commandId),grant:V(n.grant),expiresAt:P(n.expiresAt,0),revision:P(n.revision,0),proposal:_n(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=z(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:R(t.commandId,V),response:bn(t.response)}}if(n===`task-origin`){let t=z(e,[`kind`,`taskId`,`conversationId`]);return{kind:n,taskId:V(t.taskId),conversationId:R(t.conversationId,V)}}if(n===`conversations`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,200,jn)};if(n===`conversation`){let t=z(e,[`kind`,`summary`,`turns`,`before`]);return{kind:n,summary:R(t.summary,jn),turns:B(t.turns,20,An),before:R(t.before,V)}}if(n===`files`||n===`directories`){let t=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:M(t.path,4096),parent:R(t.parent,e=>M(e,4096)),limited:F(t.limited),entries:B(t.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(n===`file`){let t=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:M(t.path,4096),text:M(t.text,262144),limited:F(t.limited)}}if(n===`projects`)return{kind:n,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(n===`accepted`)return{kind:n,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let r=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(r.kind,[`project`]),commandId:V(r.commandId),path:M(r.path,4096,!0),link:M(r.link,8192,!0)}}var Nn={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`},Pn=`/api/v1/events`,Fn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function In(e,t){if(Fn.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 D.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 D.pageBytes}return D.controlBytes}function Ln(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Rn(e,t){switch(e){case`workbenchRead`:return On(t);case`workbenchCommand`:return kn(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new k(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Tt(t);if(n.reader!==e)throw new k(`invalid`);return n}case`current`:return Kt(t);case`currentChanges`:return qt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Ht(t);case`graph`:return Nt(t);case`snapshot`:return X(t);case`detail`:case`search`:return De(t);case`export`:case`download`:return It(t);case`chooseModel`:return nn(t);case`preflight`:return ve(t);case`command`:return ye(t);case`cancel`:return xe(t)}}function zn(e,t){if(Fn.includes(e))return Z(t,jt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Z(t,Mn);case`current`:return Z(t,Qt);case`currentChanges`:return Z(t,$t);case`activeRuns`:return Z(t,Ke);case`models`:return Z(t,an);case`chooseModel`:return Z(t,tn);case`session`:return Z(t,gt);case`workspace`:return Z(t,_t);case`checkObligations`:return Z(t,Vt);case`entity`:return Z(t,Wt);case`graph`:return Z(t,Ft);case`snapshot`:return Z(t,it);case`detail`:return Z(t,ct);case`search`:return Z(t,ut);case`preflight`:return Z(t,Ce);case`command`:case`cancel`:return Z(t,Qe);case`receipt`:return et(t);case`detach`:return Z(t,e=>{if(e!==null)throw new k(`invalid`);return null});default:throw new k(`invalid`)}}function Bn(e){return[...Fn,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Vn(e,t){let n=Nn[e];return t===null||Ln(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function Hn(e,t){let n=Rn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Nn[e]:Vn(e,n);return Ln(e)||Bn(e)&&(r||N(i)>D.headerBytes/4)?{path:Nn[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function Un(e){G(e,D.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:it(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:at(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Wn=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 k(`invalid`);this.origin=e.origin,e.build&&=Ye(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 k(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Hn(e,Rn(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=V(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await Gn(a,In(e)),c=K(s);if(N(s)>In(e,c))throw new k(`oversize`);let l=zn(e,c);if(e===`session`){let e=Z(l,gt);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new k(`forbidden`);this.attachment=o??V(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`,nn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Ht(e),t)}tasks(e,t){return this.request(`tasks`,Tt(e),t)}runs(e,t){return this.request(`runs`,Tt(e),t)}messages(e,t){return this.request(`messages`,Tt(e),t)}tools(e,t){return this.request(`tools`,Tt(e),t)}contents(e,t){return this.request(`contents`,Tt(e),t)}events(e,t){return this.request(`events`,Tt(e),t)}checks(e,t){return this.request(`checks`,Tt(e),t)}changes(e,t){return this.request(`changes`,Tt(e),t)}reviews(e,t){return this.request(`reviews`,Tt(e),t)}graph(e,t){return this.request(`graph`,Nt(e),t)}preflight(e){return this.request(`preflight`,ve(e))}command(e){return this.request(`command`,ye(e))}cancel(e){return this.request(`cancel`,xe(e))}receipt(e,t){return this.request(`receipt`,V(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=Z(await this.request(`detach`,null),e=>{if(e!==null)throw new k(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new k(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Hn(`export`,It(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 k(`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 k(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=D.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+D.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
8
9
|
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield Lt(K(e,D.controlBytes)),r=o.indexOf(`
|
|
9
|
-
`)}if(new TextEncoder().encode(o).length>D.controlBytes)throw new k(`oversize`)}if(n){if(o)throw new k(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=X(e);if(!this.attachment||!this.options.socket)throw new k(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${An}?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>=D.staleMs&&u(`stale`);try{Date.now()-c>=D.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},D.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 k(`invalid`);let n=zn(K(e.data,D.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Vn(e,t){if(!e.body)throw new k(`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 k(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Hn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Un=f.createContext&&f.createContext(Hn),Wn=[`attr`,`size`,`title`];function Gn(e,t){if(e==null)return{};var n,r,i=Kn(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 Kn(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 qn(){return qn=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},qn.apply(null,arguments)}function Jn(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 Yn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Jn(Object(n),!0).forEach(function(t){Xn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Xn(e,t,n){return(t=Zn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zn(e){var t=Qn(e,`string`);return typeof t==`symbol`?t:t+``}function Qn(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 $n(e){return e&&e.map((e,t)=>f.createElement(e.tag,Yn({key:t},e.attr),$n(e.child)))}function Q(e){return t=>f.createElement(er,qn({attr:Yn({},e.attr)},t),$n(e.child))}function er(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Gn(e,Wn),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,qn({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Yn(Yn({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 Un===void 0?t(Hn):f.createElement(Un.Consumer,null,e=>t(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:`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 nr(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 rr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function ir(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function ar(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 or(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 sr(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 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:`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 lr(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 ur(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 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:`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 fr(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 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:`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 mr(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 hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 _r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 vr(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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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 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 xr(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 Sr(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 Cr(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 wr(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 Tr(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 Er(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 Dr(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 Or(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 kr(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:A(`unavailable`,e?`uncertain`:`none`)}),Ar=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=wn(e);try{return this.transport.workbenchRead?Z(await this.transport.workbenchRead(n,t),On):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=Tn(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),On);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Kt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),Qt);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=qt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),$t);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),Ke):$(!1)}catch{return $(!1)}}async models(e){try{return this.transport.models?Z(await this.transport.models(e),an):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=nn(e);try{if(!this.transport.chooseModel)return $(!1);let e=Z(await this.transport.chooseModel(t),tn);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){V(e);try{let n=Z(await this.transport.checkObligations(e,t),Vt);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=Ht({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Wt);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),gt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),_t)}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=Tt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),jt);return t.kind===`ok`&&!Mt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Nt(e);try{let e=Z(await this.transport.graph(n,t),Ft);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=It(e),r=new zt(n),i;try{if(t.aborted)throw new k(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new k(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new k(`unavailable`);yield i}catch{throw new k(`unavailable`)}}async preflight(e,t){let n=ve({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Ce);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=ye(t);if(n.action.kind!==e)return{kind:`error`,error:A(`invalid`)};try{let e=Z(await this.transport.command(n),Qe);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);$e({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=xe(e);try{let e=Z(await this.transport.cancel(t),Qe);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);$e({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=et(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:A(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=X(e);try{let e=Z(await this.transport.snapshot(n,t),it);return e.kind===`ok`&&G(e.value.scope)!==G(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=De(e);try{let e=Z(await this.transport.detail(n,t),ct);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=De(e);try{let e=Z(await this.transport.search(n,t),ut);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}},jr=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=it(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&W(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>=D.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=D.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=at(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=W(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||pt(i.context)!==pt(a.context)||mt(i.context)!==mt(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>D.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{it(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`}},Mr={sourceHash:`893e862f3d75d9f785390a932c5f4c0926693e57f2f6fe3f0a72d2c39151744c`,contractHash:`f0ff0c9d0481dab9fd21cdbc7c0d72b427bee60033a9af4c789f859c4c83fe75`,buildId:`489c8a8d322ab1d43ac577231cb8effcb3248b1925c1730d574f239f2dacbeb3`};function Nr(e){let t=new Bn({origin:window.location.origin,...e?{project:e}:{},...Mr?{build:{kind:`browser`,...Mr}}:{},socket:e=>new WebSocket(e)});return{client:new Ar(t),transport:t}}function Pr(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&&W(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||W(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 Fr(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(wn(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 Ir(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 Lr=e=>e===`unauthenticated`||e===`forbidden`,Rr=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 jr,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 jr,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,Lr(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(Lr(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,Lr(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,Lr(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 jr,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Mr?{kind:`browser`,...Mr}:null;_.compatible=Ze(e.build,t),_.cancelCompatible=Ze(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 jr,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new jr,_={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 Rr(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 Br=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 Vr({title:e,children:t,onClose:n}){let{t:r}=C(),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)(tr,{"aria-hidden":`true`})})]}),t]})}function Hr({client:e,compatible:t,onClose:n,onChanged:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?s(e.value):d(e.error.code))}).catch(()=>{t.signal.aborted||d(`unavailable`)}),()=>t.abort()},[e]),(0,h.jsxs)(Vr,{title:i(`Choose owner model`),onClose:n,children:[(0,h.jsx)(`p`,{children:i(`Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.`)}),(0,h.jsx)(`p`,{children:i(`Current: {model}`,{model:o?.selected?`${o.selected.provider}/${o.selected.model} · ${o.selected.thinking}`:i(`No model selected`)})}),(0,h.jsxs)(`label`,{children:[i(`Exact model / API / thinking`),(0,h.jsxs)(`select`,{value:c,disabled:!o,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:i(`Select explicitly`)}),o?.entries.flatMap(e=>e.thinking.filter(e=>e.selectable).map(t=>{let n=JSON.stringify({provider:e.provider,model:e.model,api:e.api,thinking:t.level});return(0,h.jsxs)(`option`,{value:n,children:[e.provider,`/`,e.model,` · `,e.api,` · `,t.level]},n)}))]})]}),o?.status===`capacity`&&(0,h.jsx)(`p`,{children:i(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!o?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:i(o.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:o.withheld})}),u&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Model catalog unavailable ({code}); no model is selectable. No automatic retry.`,{code:a(u)})}),p&&(0,h.jsx)(`p`,{role:`alert`,children:i(`{error}. No automatic replacement or retry.`,{error:a(p)})}),(0,h.jsx)(`button`,{type:`button`,disabled:!t||!o||!c||g,onClick:()=>{o&&(_(!0),e.chooseModel({expected:o.version,choice:se(JSON.parse(c))}).then(e=>{e.kind===`error`?m(e.error.code):(r(),n())}).catch(()=>m(`Choice response unconfirmed; observe catalog before another explicit choice.`)).finally(()=>_(!1)))},children:i(`Confirm owner model choice`)})]})}function Ur({client:e,value:t,onChange:n}){let{t:r,tx:i}=C(),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 Wr(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 Gr(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 Kr(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 qr(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=Wr(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 Jr(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),Gr(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 Yr({value:e,compact:t=!1}){let{t:n,tx:r}=C();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)(Yr,{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 Xr(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 Zr(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Xr(e)}return Xr(e)}function Qr(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 Zr(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 $r(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
10
|
-
`).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 ei=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ti(!0)},text:{92:ti(!1)}});let t={enter:{backslashMathInline:ni,backslashMathDisplay:ni,backslashMathBlock:ni},exit:{backslashMathInline:ri,backslashMathDisplay:ri,backslashMathBlock:ri}};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 ni=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)},ri=function(e){this.exit(e)},ii=(0,f.memo)(function({text:e}){let{t}=C(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=Qr();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)(Dr,{}):(0,h.jsx)(Sr,{}),n&&t(`Copy unavailable`)]})}),ai=[s,d,ei],oi=[s,l,d,ei],si=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function ci(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 li({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?oi:ai,rehypePlugins:t?[i,o,...si]:si,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:fi,a:di,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ui=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(li,{...e})})});function di({href:e,children:t}){let n=e&&ci(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 fi({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=$r(r).map(e=>{let t=`code-offset:${i}`;return i+=pi(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)(ii,{text:pi(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 pi(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(pi).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return pi(t?.children)}return``}function mi(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 hi=new Map;function gi(e,t){t.length?hi.set(e,t):hi.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...hi].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 _i(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 vi(e,t){let n=t.startContainer.parentElement;for(let r of _i(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 yi({container:e,version:t}){let{t:n}=C(),[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?mi(n,r):[];return l.current=i,c(i.length),o(0),gi(u,i),()=>gi(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(vi(e.current,l.current[n]),gi(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>gi(`${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 bi({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=C(),s=G(t),c=(0,f.useMemo)(()=>De(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`),[w,T]=(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,T(a(`Reading all retained field pages…`));try{let r=await qr(e,t,n.signal);if(n.signal.aborted)return;let i=await Zr(r.text);if(n.signal.aborted)return;T(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||T(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,T(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),w&&(0,h.jsx)(`p`,{role:`status`,children:w}),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)(Yr,{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)(yi,{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)(ui,{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 xi({pager:e,compact:t=!1}){let{t:n,tx:r}=C(),{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&&(0,h.jsx)(Yr,{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)(or,{"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 Si({client:e,seed:t,entityId:n}){let{t:r,tx:i}=C(),a=Jr(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)(xi,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(y,{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)(Yr,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Kr(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)(bi,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ci({client:e,seed:t}){return(0,h.jsx)(wi,{client:e,seed:t},G(t))}function wi({client:e,seed:t}){let{t:n,tx:r}=C(),[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)(Yr,{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 Ti(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 Ei(){let e=Ti();return e?`/projects/${e}`:``}function Di(e){let t=Rn(`download`,It(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Ei()+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 Oi({request:e,onClose:t}){let{t:n,tx:r}=C(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(Vr,{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{Di({...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 ki(e,t){if(!t||N(t)>D.queryBytes)throw Error(`Query must be 1–${D.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return De({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Ai(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 ji({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=C(),[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=ki(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)(Vr,{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)(ar,{}),(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)(Yr,{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(Ai(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 Mi({run:e,historical:t=!1}){let{t:n,tx:r}=C();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)(Yr,{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 Ni({client:e,seed:t}){return(0,h.jsx)(Pi,{client:e,seed:t},G(t))}function Pi({client:e,seed:t}){let{t:n,tx:r}=C(),[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)(Yr,{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)(bi,{client:e,cursor:Kr(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)(ui,{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 Fi({client:e,seed:t,onScope:n}){let{t:r}=C(),i=Jr(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(xi,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Mi,{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)(Ni,{client:e,seed:o},o.graph.recordId)]})}function Ii({onOpen:e,disabled:t}){let{t:n}=C();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)(ar,{"aria-hidden":`true`})})}function Li(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 Ri(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 zi(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)??Bi(n.role,n.customType)}return r}function Bi(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 Vi(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var Hi=(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`})}),Ui=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=C(),[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)(wr,{"aria-hidden":`true`}):(0,h.jsx)(vr,{"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)(bi,{compact:!0,client:t,cursor:Kr(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)(Si,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Wi({messages:e,client:t,seed:n}){let{t:r}=C(),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=zi(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=Li(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=>Ri(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)(Hi,{id:e,show:!o.has(e),height:Vi(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)(Ui,{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)(kr,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Gi({client:e,seed:t}){let{t:n}=C(),r=Jr(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(xi,{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)(Wi,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Ki({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)(Er,{}):(0,h.jsx)(Tr,{})}):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 qi=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=C(),[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)(Ki,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(nr,{}),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)(Si,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Ji=[`queued`,`running`];function Yi(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 Xi(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&&!Ji.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=>Ji.includes(e.status)))&&(r=setTimeout(()=>void c(),n)))};return c(),()=>{t.abort(),clearTimeout(r)}},[e,s,n]),{runs:r,failed:a}}function Zi({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=C(),[d,p]=(0,f.useState)(!0),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=Xi(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`)),w=[...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(!Ji.includes(e.step.status))-Number(!Ji.includes(t.step.status))),T=S.length+w.length;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(e=>!e),children:[(0,h.jsx)(Er,{}),(0,h.jsx)(xr,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count`,children:T})]}),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`)}),T===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),w.map(({run:e,step:t})=>{let n=Yi(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 Qi(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 $i(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function ea(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var ta=/^\s{0,3}(`{3,}|~{3,})/,na=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function ra(e){return e.trim()===``}function ia(e){let t=ta.exec(e);return t?t[1]:null}function aa(e){let t=e.split(`
|
|
11
|
-
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=
|
|
10
|
+
`)}if(new TextEncoder().encode(o).length>D.controlBytes)throw new k(`oversize`)}if(n){if(o)throw new k(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=X(e);if(!this.attachment||!this.options.socket)throw new k(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Pn}?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>=D.staleMs&&u(`stale`);try{Date.now()-c>=D.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},D.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 k(`invalid`);let n=Un(K(e.data,D.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Gn(e,t){if(!e.body)throw new k(`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 k(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Kn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},qn=f.createContext&&f.createContext(Kn),Jn=[`attr`,`size`,`title`];function Yn(e,t){if(e==null)return{};var n,r,i=Xn(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 Xn(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 Zn(){return Zn=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},Zn.apply(null,arguments)}function Qn(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 $n(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Qn(Object(n),!0).forEach(function(t){er(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function er(e,t,n){return(t=tr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tr(e){var t=nr(e,`string`);return typeof t==`symbol`?t:t+``}function nr(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 rr(e){return e&&e.map((e,t)=>f.createElement(e.tag,$n({key:t},e.attr),rr(e.child)))}function Q(e){return t=>f.createElement(ir,Zn({attr:$n({},e.attr)},t),rr(e.child))}function ir(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Yn(e,Jn),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Zn({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:$n($n({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(Kn):f.createElement(qn.Consumer,null,e=>t(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:`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 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:`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 sr(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 cr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function lr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 ur(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 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:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},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:`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 pr(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 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:`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 hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 gr(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 _r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 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:`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 yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 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:`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 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:`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 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:`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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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:`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 Tr(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 Er(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 Dr(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 Or(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 kr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},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:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function jr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},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:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},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:`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:A(`unavailable`,e?`uncertain`:`none`)}),Pr=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=On(e);try{return this.transport.workbenchRead?Z(await this.transport.workbenchRead(n,t),Mn):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=kn(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=Z(await this.transport.workbenchCommand(t),Mn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Kt(e);try{if(!this.transport.current)return $(!1);let e=Z(await this.transport.current(n,t),Qt);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=qt(e);try{if(!this.transport.currentChanges)return $(!1);let e=Z(await this.transport.currentChanges(n,t),$t);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),Ke):$(!1)}catch{return $(!1)}}async models(e){try{return this.transport.models?Z(await this.transport.models(e),an):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=nn(e);try{if(!this.transport.chooseModel)return $(!1);let e=Z(await this.transport.chooseModel(t),tn);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){V(e);try{let n=Z(await this.transport.checkObligations(e,t),Vt);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=Ht({...t,kind:e});try{let e=Z(await this.transport.entity(r,n),Wt);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),gt)}catch{return $(!1)}}async workspace(e){try{return Z(await this.transport.workspace(e),_t)}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=Tt({...t,reader:e});try{let t=Z(await this.transport[e](r,n),jt);return t.kind===`ok`&&!Mt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Nt(e);try{let e=Z(await this.transport.graph(n,t),Ft);return e.kind===`ok`&&G(e.value.request)!==G(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=It(e),r=new zt(n),i;try{if(t.aborted)throw new k(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new k(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new k(`unavailable`);yield i}catch{throw new k(`unavailable`)}}async preflight(e,t){let n=ve({expected:e,action:t});try{let e=Z(await this.transport.preflight(n),Ce);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=ye(t);if(n.action.kind!==e)return{kind:`error`,error:A(`invalid`)};try{let e=Z(await this.transport.command(n),Qe);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);$e({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=xe(e);try{let e=Z(await this.transport.cancel(t),Qe);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);$e({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=et(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:A(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=X(e);try{let e=Z(await this.transport.snapshot(n,t),it);return e.kind===`ok`&&G(e.value.scope)!==G(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=De(e);try{let e=Z(await this.transport.detail(n,t),ct);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=De(e);try{let e=Z(await this.transport.search(n,t),ut);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?$(!1):e}catch{return $(!1)}}},Fr=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=it(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&W(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>=D.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=D.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=at(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=W(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||pt(i.context)!==pt(a.context)||mt(i.context)!==mt(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>D.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{it(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`}},Ir={sourceHash:`6924b600302f932616a818781c0ae204f25155c4a964091ed9e1f6574b6e2a50`,contractHash:`b855efce6a9694452dd77fcdad0b5dbecce617643cc81ac7c55dafb0f2ca7848`,buildId:`12a9304fd00eb2d344ae8e4ea603011b2795453bbf519dec7bfff8d713e8bf69`};function Lr(e){let t=new Wn({origin:window.location.origin,...e?{project:e}:{},...Ir?{build:{kind:`browser`,...Ir}}:{},socket:e=>new WebSocket(e)});return{client:new Pr(t),transport:t}}function Rr(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&&W(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||W(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 zr(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(On(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 Br(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 Vr=e=>e===`unauthenticated`||e===`forbidden`,Hr=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 Fr,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 Fr,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,Vr(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(Vr(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,Vr(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,Vr(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 Fr,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Ir?{kind:`browser`,...Ir}:null;_.compatible=Ze(e.build,t),_.cancelCompatible=Ze(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 Fr,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new Fr,_={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 Ur(e,t,n){let r=(0,f.useMemo)(()=>new Hr(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 Wr=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 Gr({title:e,children:t,onClose:n}){let{t:r}=C(),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)(ar,{"aria-hidden":`true`})})]}),t]})}function Kr({client:e,compatible:t,onClose:n,onChanged:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?s(e.value):d(e.error.code))}).catch(()=>{t.signal.aborted||d(`unavailable`)}),()=>t.abort()},[e]),(0,h.jsxs)(Gr,{title:i(`Choose owner model`),onClose:n,children:[(0,h.jsx)(`p`,{children:i(`Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.`)}),(0,h.jsx)(`p`,{children:i(`Current: {model}`,{model:o?.selected?`${o.selected.provider}/${o.selected.model} · ${o.selected.thinking}`:i(`No model selected`)})}),(0,h.jsxs)(`label`,{children:[i(`Exact model / API / thinking`),(0,h.jsxs)(`select`,{value:c,disabled:!o,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:i(`Select explicitly`)}),o?.entries.flatMap(e=>e.thinking.filter(e=>e.selectable).map(t=>{let n=JSON.stringify({provider:e.provider,model:e.model,api:e.api,thinking:t.level});return(0,h.jsxs)(`option`,{value:n,children:[e.provider,`/`,e.model,` · `,e.api,` · `,t.level]},n)}))]})]}),o?.status===`capacity`&&(0,h.jsx)(`p`,{children:i(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!o?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:i(o.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:o.withheld})}),u&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Model catalog unavailable ({code}); no model is selectable. No automatic retry.`,{code:a(u)})}),p&&(0,h.jsx)(`p`,{role:`alert`,children:i(`{error}. No automatic replacement or retry.`,{error:a(p)})}),(0,h.jsx)(`button`,{type:`button`,disabled:!t||!o||!c||g,onClick:()=>{o&&(_(!0),e.chooseModel({expected:o.version,choice:se(JSON.parse(c))}).then(e=>{e.kind===`error`?m(e.error.code):(r(),n())}).catch(()=>m(`Choice response unconfirmed; observe catalog before another explicit choice.`)).finally(()=>_(!1)))},children:i(`Confirm owner model choice`)})]})}function qr({client:e,value:t,onChange:n}){let{t:r,tx:i}=C(),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 Jr(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 Yr(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 Xr(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 Zr(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=Jr(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 Qr(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),Yr(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 $r({value:e,compact:t=!1}){let{t:n,tx:r}=C();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)($r,{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 ei(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 ti(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ei(e)}return ei(e)}function ni(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 ti(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 ri(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 ii=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:ai(!0)},text:{92:ai(!1)}});let t={enter:{backslashMathInline:oi,backslashMathDisplay:oi,backslashMathBlock:oi},exit:{backslashMathInline:si,backslashMathDisplay:si,backslashMathBlock:si}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function ai(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 oi=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)},si=function(e){this.exit(e)},ci=(0,f.memo)(function({text:e}){let{t}=C(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ni();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)(jr,{}):(0,h.jsx)(Er,{}),n&&t(`Copy unavailable`)]})}),li=[s,d,ii],ui=[s,l,d,ii],di=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function fi(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 pi({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?ui:li,rehypePlugins:t?[i,o,...di]:di,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:gi,a:hi,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var mi=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(pi,{...e})})});function hi({href:e,children:t}){let n=e&&fi(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 gi({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=ri(r).map(e=>{let t=`code-offset:${i}`;return i+=_i(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)(ci,{text:_i(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 _i(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(_i).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return _i(t?.children)}return``}function vi(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 yi=new Map;function bi(e,t){t.length?yi.set(e,t):yi.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...yi].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 xi(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 Si(e,t){let n=t.startContainer.parentElement;for(let r of xi(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 Ci({container:e,version:t}){let{t:n}=C(),[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?vi(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]&&(Si(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}=C(),s=G(t),c=(0,f.useMemo)(()=>De(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`),[w,T]=(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,T(a(`Reading all retained field pages…`));try{let r=await Zr(e,t,n.signal);if(n.signal.aborted)return;let i=await ti(r.text);if(n.signal.aborted)return;T(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||T(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,T(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),w&&(0,h.jsx)(`p`,{role:`status`,children:w}),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)($r,{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)(Ci,{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)(mi,{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 Ti({pager:e,compact:t=!1}){let{t:n,tx:r}=C(),{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&&(0,h.jsx)($r,{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)(ur,{"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 Ei({client:e,seed:t,entityId:n}){let{t:r,tx:i}=C(),a=Qr(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)(Ti,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(y,{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)($r,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Xr(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 Di({client:e,seed:t}){return(0,h.jsx)(Oi,{client:e,seed:t},G(t))}function Oi({client:e,seed:t}){let{t:n,tx:r}=C(),[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)($r,{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 ki(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 Ai(){let e=ki();return e?`/projects/${e}`:``}function ji(e){let t=Hn(`download`,It(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Ai()+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 Mi({request:e,onClose:t}){let{t:n,tx:r}=C(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(Gr,{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{ji({...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 Ni(e,t){if(!t||N(t)>D.queryBytes)throw Error(`Query must be 1–${D.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return De({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Pi(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 Fi({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=C(),[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=Ni(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)(Gr,{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)(lr,{}),(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)($r,{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(Pi(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 Ii({run:e,historical:t=!1}){let{t:n,tx:r}=C();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)($r,{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 Li({client:e,seed:t}){return(0,h.jsx)(Ri,{client:e,seed:t},G(t))}function Ri({client:e,seed:t}){let{t:n,tx:r}=C(),[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)($r,{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:Xr(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)(mi,{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 zi({client:e,seed:t,onScope:n}){let{t:r}=C(),i=Qr(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Ti,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ii,{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)(Li,{client:e,seed:o},o.graph.recordId)]})}function Bi({onOpen:e,disabled:t}){let{t:n}=C();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)(lr,{"aria-hidden":`true`})})}function Vi(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 Hi(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 Ui(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)??Wi(n.role,n.customType)}return r}function Wi(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 Gi(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var Ki=(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`})}),qi=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=C(),[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)(Or,{"aria-hidden":`true`}):(0,h.jsx)(Sr,{"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:Xr(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)(Ei,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Ji({messages:e,client:t,seed:n}){let{t:r}=C(),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=Ui(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=Vi(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=>Hi(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)(Ki,{id:e,show:!o.has(e),height:Gi(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)(qi,{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)(Nr,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Yi({client:e,seed:t}){let{t:n}=C(),r=Qr(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Ti,{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)(Ji,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Xi({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)(Ar,{}):(0,h.jsx)(kr,{})}):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 Zi=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=C(),[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)(Xi,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(or,{}),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)(Ei,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Qi=[`queued`,`running`];function $i(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 ea(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&&!Qi.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=>Qi.includes(e.status)))&&(r=setTimeout(()=>void c(),n)))};return c(),()=>{t.abort(),clearTimeout(r)}},[e,s,n]),{runs:r,failed:a}}function ta({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=C(),[d,p]=(0,f.useState)(!0),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=ea(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`)),w=[...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(!Qi.includes(e.step.status))-Number(!Qi.includes(t.step.status))),T=S.length+w.length,E=w.filter(({step:e})=>Qi.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length;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(e=>!e),children:[(0,h.jsx)(Ar,{}),(0,h.jsx)(Tr,{}),(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:T}):T})]}),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`)}),T===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),w.map(({run:e,step:t})=>{let n=$i(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 na(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 ra(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function ia(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var aa=/^\s{0,3}(`{3,}|~{3,})/,oa=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function sa(e){return e.trim()===``}function ca(e){let t=aa.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=ca(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=ca(a);if(o&&!sa(a))i=o,r.push(a);else if(sa(a)){let i=e;for(;i<t.length&&sa(t[i]);)i++;if(!(i<t.length&&oa.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
12
13
|
`)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
|
|
13
|
-
`),inFence:i!==null}}function
|
|
14
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}var
|
|
15
|
-
`).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)(
|
|
16
|
-
`)}),![`completed`,`running`,`queued`].includes(e.status)&&(0,h.jsx)(`p`,{className:`ep-state ${e.status}`,children:n(e.status)})]})}function
|
|
17
|
-
`:``}@${c}`),l(),re.current?.focus())},[c,l]),(0,f.useEffect)(()=>{let e=M?.summary?`${M.summary.head}:${M.summary.status}`:``;e&&ue.current!==e&&(ue.current=e,s()),V.current&&P?.runs.includes(V.current)&&(V.current=``,B(``),O(``)),k&&M?.turns.some(e=>e.id===k)&&(A(``),y(e=>e===q.current?``:e),s()),oe.current&&ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[M,k,s,P]),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${_}:approval`)}catch{}},[_]);let de=JSON.stringify(P?.runs.slice(-4)??[]);(0,f.useEffect)(()=>{p?.(JSON.parse(de))},[de,p]);let fe=async()=>{if(!P?.proposal){O(m(`No plan is awaiting approval.`));return}if(!L||!U||ee||z||!te)return;let t=P;E(!0),O(``);try{let n=await
|
|
18
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function
|
|
19
|
-
`);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=
|
|
20
|
-
`):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:[La(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)(ui,{text:e})})]}):n===`diff`?(0,h.jsx)(za,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Ra(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 Va({client:e,seed:t}){let{t:n,tx:r}=C(),i=Jr(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(xi,{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(Kr(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)(bi,{client:e,cursor:a,render:e=>(0,h.jsx)(Ba,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Ha=[`contents`,`checks`,`changes`,`reviews`];function Ua(){let{t:e}=C();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 Wa({client:e,seed:t}){let{t:n,tx:r}=C(),[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:Ha.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)(Si,{client:e,seed:t}):(0,h.jsx)(Va,{client:e,seed:{...t,reader:i}},i)})]})}var Ga={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.`},Ka=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function qa(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 Ja({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[]}){let{t:c,tx:l}=C(),[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,w]=(0,f.useState)(!0),[T,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&&w(!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=>{T||P(e)},L=()=>{let e=p.trim();T||(Ka(e)?P(e):O({step:`read`,code:`relative`}))},R=(g||!u)&&p.trim()||u?.path||``,z=!T&&!b&&!!R,B=async n=>{if(T||!n||b&&n===u?.path)return;if(n!==u?.path&&!Ka(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?qa(u.path,r):void 0,H=v.trim().toLowerCase(),U=u?.entries.filter(e=>e.name.toLowerCase().includes(H))??[],W=D&&(D.step===`read`&&Ga[D.code]?c(Ga[D.code]):l(D.code));return(0,h.jsxs)(Vr,{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:T,onClick:()=>e.current?a():void B(e.path),children:[(0,h.jsx)(gr,{"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:T,onClick:()=>I(`~`),children:[(0,h.jsx)(pr,{"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)(Tr,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:T,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:T,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:T,onClick:()=>{m(u.path),_(!g),O(null)},children:(0,h.jsx)(yr,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(ar,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":c(`Filter folders`),placeholder:c(`Filter this folder…`),value:v,disabled:T,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:T,onClick:()=>I(u.parent),children:[(0,h.jsx)(Or,{}),c(`Parent folder`)]}),U.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>I(e.path),children:[(0,h.jsx)(gr,{}),(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(`The shared registry lock is blocking projects. On the service host, run cadence recover inspect --workspace <project> with the same --state-home, then use recover resolve in a local terminal if eligible. Do not delete lock files manually.`)]})]}),(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(T?`Opening folder…`:`Open this folder`)})]})]})}function Ya(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 Xa({onConversation:e,disabled:t=!1}){let{t:n}=C();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)(sr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function Za({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)(Er,{"aria-hidden":`true`}):(0,h.jsx)(Tr,{"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 Qa({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(new Set),c=Ya(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)(Tr,{"aria-hidden":`true`}):(0,h.jsx)(Er,{"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)(xr,{"aria-hidden":`true`}):(0,h.jsx)(cr,{"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 $a({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=C(),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)(Qa,{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)(xi,{pager:e,compact:!0})]})}function eo({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:w}){let{t:T,tx:E}=C(),D={reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50},O=Jr(e,D),k=Jr(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":T(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:T(`Task conversations`)}),(0,h.jsx)($a,{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:[T(`Cadence workflow`),` · `,E(e.phase),` · `,E(e.status)]})]})]}),w&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:P.has(e.id),onClick:()=>{F(t=>new Set(t).add(e.id)),w(e).finally(()=>F(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(rr,{"aria-hidden":`true`}),T(`Cancel workflow — request stop`)]})]},e.id)},L=p.filter(e=>e.status===`running`||e.status===`queued`||e.id===m),R=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)(cr,{})}),(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?T(`Cadence on`):T(`Ordinary`),` ·`,` `,e.cadence&&[`running`,`queued`].includes(e.status)?T(`Discussing`):e.cadence&&e.status===`completed`?T(`Ready for conversation`):E(e.status)]})]})]},e.id);return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(Xa,{onConversation:_}),(0,h.jsxs)(Za,{title:T(`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:T(`Active roster unavailable; absence is not proof of settlement.`)}),b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`Workflow activity unavailable; retained work may still be running.`)}),L.map(R),v?.map(I),o?.status===`complete`&&j.length===0&&L.length===0&&v?.length===0&&!b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`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??T(`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)(rr,{"aria-hidden":`true`}),T(`Cancel run — request stop`)]}),n===e.taskId&&(0,h.jsx)(Qa,{runs:i.filter(t=>t.runId===e.runId),scope:r,onScope:d})]},e.runId)})]}),(0,h.jsxs)(Za,{title:T(`Conversation history`),count:O.page&&!(`kind`in O.page)?`${M.length}${O.page.next||O.canPrevious?`+`:``}`:`?`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":T(`Tasks`),className:`task-list`,children:[p.filter(e=>!L.includes(e)).map(R),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)(cr,{"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:T(`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&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`No retained task on this page.`)}),(0,h.jsx)(xi,{pager:O,compact:!0})]}),!M.some(e=>e.owner.taskId===n)&&N]})]})}var to=[`queued`,`running`];function no({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=C(),[s,c]=(0,f.useState)(1e3),l=Fr(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?to.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!to.includes(u.status)&&c(0)},[u]);let m=Fr(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=Fr(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)(xr,{"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)(Aa,{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)(Ea,{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)(ui,{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 ro({client:e,onOpen:t}){let{t:n,tx:r}=C(),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),p=Fr(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 io({path:e,disabled:t=!1,onClick:n}){let{t:r}=C();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)(gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(Er,{"aria-hidden":`true`})]})}function ao(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=Ti();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(X(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function oo(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?X(K(r)):void 0,o=i?U(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=De(K(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function so(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 co({side:e,width:t,onResize:n}){let{t:r}=C(),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=so({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 lo(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 uo=.4,fo=1.05;function po(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 ho(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function go(e,t){return e===`left`?t:-t}function _o(e,t){return Math.max(-e,Math.min(0,-e+t))}function vo(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function yo(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:vo(r*fo,n,t)>=uo}var bo=new Set([`auto`,`scroll`,`overlay`]);function xo(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&bo.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function So(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Co(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&&!xo(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=ho(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=po(window.innerWidth),h=m*fo;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=go(r,d);let b=_o(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(vo(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?yo({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(So(),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 wo(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 To=`modulepreload`,Eo=function(e){return`/`+e},Do={},Oo=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=Eo(t,n),t=s(t),t in Do)return;Do[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`:To,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 ko({client:e,seed:t,onSearch:n}){let{t:r}=C(),i=Jr(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)(xi,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Ao,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Ao({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=C(),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 Oo(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,wo(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)(Si,{client:e,seed:t})]})}function jo(){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 Mo=[[`tools`,nr],[`context`,fr],[`timeline`,Cr],[`runs`,hr]];function No({error:e,observationError:t}){let{t:n,tx:r}=C();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)(y,{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 Po({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i}){let{t:a,tx:o,locale:s,setLocale:c}=C(),[l]=(0,f.useState)(()=>e??Nr()),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(!1),[g]=(0,f.useState)(oo),[_,v]=(0,f.useState)(g?.taskId??null),[b,x]=(0,f.useState)(()=>g?null:jo()??crypto.randomUUID()),[S,w]=(0,f.useState)(null),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(g?`task`:`files`),[j,M]=(0,f.useState)(),N=(0,f.useCallback)(()=>M(void 0),[]),[P,F]=(0,f.useState)(g?g.scope??{kind:`task`,id:g.taskId}:null),I=zr(l,_?{kind:`task`,id:_}:null,!p),L=(0,f.useRef)(null);I.workspace&&(L.current=I.workspace.workspaceId);let R=Fr(l.client,I.workspace&&!p?{kind:`conversations`}:null,2e3),z=Fr(l.client,I.workspace&&!p?{kind:`workflow-active`}:null,2e3),B=z.value?.kind===`workflow-active`?z.value:void 0,V=(0,f.useMemo)(()=>[...new Set([...B?.runs.map(e=>e.id)??[],...T])],[B,T]),H=Fr(l.client,I.workspace&&!p?{kind:`projects`}:null),U=(H.value?.kind===`projects`?H.value.entries.find(e=>e.current)?.path:void 0)??I.workspace?.rootLabel,W=Fr(l.client,_&&I.workspace&&!p?{kind:`task-origin`,taskId:_}:null),ee=W.value?.kind===`task-origin`?W.value.conversationId:null,K={state:I.observation,transportStatus:I.transportStatus,error:I.error,refresh:I.refresh},te=K.state?.snapshot.scope.kind===`task`&&K.state.snapshot.scope.id===_?K.state.snapshot.context:void 0,[ne,re]=(0,f.useState)(null),[ie,ae]=(0,f.useState)(!1),oe=(0,f.useRef)(null),[se,ce]=(0,f.useState)(260),[le,ue]=(0,f.useState)(360),q=(0,f.useCallback)(()=>re(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>ae(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Co({enabled:ie&&!p,open:ne,onOpenChange:re,container:oe}),lo(oe,ne,ie&&!p,q);let[de,fe]=(0,f.useState)(g?.snapshotSeq),[J,pe]=(0,f.useState)(``),[me,he]=(0,f.useState)(``),[ge,_e]=(0,f.useState)(!0),ve=(0,f.useRef)(null),[ye,be]=(0,f.useState)(`messages`),[xe,Se]=(0,f.useState)(!1),[Ce,Y]=(0,f.useState)(!1),[we,Te]=(0,f.useState)(),[X,Ee]=(0,f.useState)(g?.cursor),[De,Oe]=(0,f.useState)(``),[ke,Ae]=(0,f.useState)([]),[je,Me]=(0,f.useState)(new Set),Ne=(0,f.useRef)(!0),Pe=e=>{Ne.current&&Ae(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Pr(t,e):t)})},Fe=(0,f.useRef)(new Br),Ie=G({taskId:_,scope:P,selectedSnapshot:de??null,detached:p,attachment:I.attachmentVersion,workspaceContext:I.workspace?.context??null,observationError:I.error??null});Fe.current.select(Ie),(0,f.useEffect)(()=>(Ne.current=!0,()=>{Ne.current=!1,Fe.current.depart()}),[]);let Le=(e=crypto.randomUUID())=>{w(null),e!==b&&E([]),Fe.current.depart(),x(e),v(null),F(null),pe(``),he(``),Te(void 0),Ee(void 0),fe(void 0),be(`messages`),A(`files`),q(),history.replaceState(null,``,`${location.pathname}${location.search}#chat=${e}`)};(0,f.useEffect)(()=>{b&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${b}`)},[b]);let Re=(e,t)=>{w(null),E([]),x(null),A(`task`),pe(t??``),he(``),fe(void 0),Fe.current.depart(),v(e),F({kind:`task`,id:e}),Te(void 0),Ee(void 0),be(`messages`),q(),history.replaceState(null,``,ao(e))};(0,f.useEffect)(()=>{let e=()=>{let e=oo();if(e)w(null),E([]),x(null),A(`task`),Fe.current.depart(),fe(e.snapshotSeq),pe(``),he(``),v(e.taskId),F(e.scope??{kind:`task`,id:e.taskId}),Te(void 0),Ee(e.cursor),be(`messages`),q();else{let e=jo();e&&(w(null),E([]),x(e),v(null),F(null),A(`files`),Fe.current.depart(),q())}};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[q]);let ze=(e,t,n)=>{w(null),fe(t),he(n??``),Fe.current.depart(),F(e),Te(void 0),Ee(void 0),be(`messages`),q(),_&&history.replaceState(null,``,ao(_,void 0,{scope:e,snapshotSeq:t}))},Be=de??K.state?.snapshot.committedSeq??I.workspace?.committedSeq,Ve=I.workspace?.storeId,He=P&&Ve&&Be?{storeId:Ve,scope:P,snapshotSeq:Be,reader:`messages`,after:null,limit:50}:null,Ue=P&&Ve&&Be?{storeId:Ve,scope:P,snapshotSeq:Be,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,We=te?K.state?.snapshot.runs??[]:[],Ge=Fe.current.ticket(),Ke=e=>{Pe(e),e.receipt&&Fe.current.current(Ge)&&I.refresh()},qe=e=>{if(je.has(e)||!I.cancelCompatible||!I.activeRuns)return;let t=crypto.randomUUID(),n=I.activeRuns.epoch;Me(t=>new Set(t).add(e)),Pe({commandId:t,error:a(`Stop requested; settlement is not yet confirmed.`)}),l.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{Ke(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:a(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>Pe({commandId:t,error:a(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Ne.current&&Me(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:a(`Detached`)}),(0,h.jsx)(`p`,{children:a(`Accepted service work continues. No Cancel was requested.`)}),ke.map(e=>(0,h.jsxs)(`p`,{children:[a(`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:a(`Reconnect as a viewer`)})]});let Je=I.activeRuns,Ye=Je?.status===`complete`?Je.runs:[],Xe=K.state?.connection??(I.workspace?_?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${ge?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":a(`Tasks`),onClick:()=>re(e=>e===`left`?null:`left`),children:(0,h.jsx)(lr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":a(`Workbench projects`),title:a(`Workbench projects`),onClick:n,children:(0,h.jsx)(gr,{})}),(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`})]}),I.workspace&&(0,h.jsxs)(`span`,{className:`chip static chip-root`,title:I.workspace.rootLabel,children:[(0,h.jsx)(gr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:I.workspace.rootLabel})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),P&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":a(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":ye===`messages`&&!X,onClick:()=>{Ee(void 0),Te(void 0),be(`messages`)},children:[(0,h.jsx)(cr,{"aria-hidden":`true`}),a(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:ve,onKeyDown:e=>{e.key===`Escape`&&ve.current&&(ve.current.open=!1,ve.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`?a(`Details`):o(ye),(0,h.jsx)(Er,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Mo.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":ye===e,onClick:()=>{Ee(void 0),Te(void 0),be(e),ve.current&&(ve.current.open=!1,ve.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),o(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":a(`Export selected scope`),disabled:!He,onClick:()=>{ve.current&&(ve.current.open=!1,ve.current.querySelector(`summary`)?.focus()),Y(!0)},children:[(0,h.jsx)(br,{"aria-hidden":`true`}),a(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":a(`Copy token-free link`),disabled:!_,onClick:()=>{_&&Zr(ao(_,X,P?{scope:P,snapshotSeq:de}:void 0)).then(e=>Oe(e?``:a(`Link copy unavailable.`)))},children:[(0,h.jsx)(dr,{"aria-hidden":`true`}),a(`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)(Ii,{disabled:!Ue,onOpen:()=>Se(!0)}),(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Observe current state`),"data-tip":a(`Observe current state`),onClick:()=>{I.refresh(),K.refresh()},children:(0,h.jsx)(or,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Choose owner model`),"data-tip":a(`Choose owner model`),onClick:()=>d(!0),children:[(0,h.jsx)(xr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chip-label`,children:a(`Model`)})]}),(0,h.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Return — work continues`),"data-tip":a(`Return — accepted work continues`),onClick:()=>{re(null),Se(!1),Y(!1),Fe.current.depart(),m(!0)},children:[(0,h.jsx)(ur,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chip-label`,children:a(`Return`)})]}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:s===`zh`?`en`:`zh-CN`,"aria-label":s===`zh`?`Switch to English`:`切换到中文`,"data-tip":s===`zh`?`Switch to English`:`切换到中文`,onClick:()=>c(s===`zh`?`en`:`zh`),children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:s===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":a(`Files / history`),"aria-expanded":ie?ne===`right`:ge,onClick:()=>ie?re(e=>e===`right`?null:`right`):_e(e=>!e),children:[(0,h.jsx)(ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:a(b?`Files`:`History`)})]})]}),!I.workspace&&Ye.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":a(`Execution and cancellation`),children:Ye.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:[o(e.kind),` `,e.runId,` · `,o(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>Re(e.taskId),children:a(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!I.cancelCompatible||je.has(e.runId),onClick:()=>qe(e.runId),children:[(0,h.jsx)(rr,{"aria-hidden":`true`}),a(`Cancel run — request stop`)]})]},e.runId))}),(0,h.jsx)(No,{error:De,observationError:I.error}),(0,h.jsxs)(`div`,{ref:oe,className:`layout`,style:{"--left-w":`${se}px`,"--right-w":`${le}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":a(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${ne?` on`:``}`,onClick:q}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${ne===`left`?` open`:``}`,"aria-label":a(`Task navigation drawer`),tabIndex:-1,inert:ie&&ne!==`left`,children:[I.workspace&&(0,h.jsx)(eo,{client:l.client,workspace:I.workspace,taskId:_,scope:P,runs:We,snapshot:K.state?.snapshot.committedSeq,activeRuns:I.activeRuns,cancelCompatible:!!I.cancelCompatible,canceling:je,onCancel:qe,chats:R.value?.kind===`conversations`?R.value.entries:[],conversationId:b,onConversation:Le,onNewConversation:()=>Le(),workflows:B?.runs,workflowLinks:B?.links,workflowError:!!z.error,selectedWorkflow:S?.runId,onWorkflow:(e,t)=>{t?Le(t):(w({runId:e.id,stepId:null,label:e.goal}),q())},onCancelWorkflow:async e=>{let t=await ka(l.client,e);t&&Oe(t),z.refresh()},onTask:Re,onScope:ze}),I.workspace&&(0,h.jsx)(ro,{client:l.client,onOpen:e=>{w(e),q()}}),I.workspace&&(0,h.jsx)(Zi,{client:l.client,active:I.activeRuns,taskId:_,runs:We,snapshot:Be,workflowRuns:V,selected:S,onOpenWorkflow:e=>{w(e),q()},onOpen:(e,t,n,r)=>{Re(e),F({kind:`child`,id:t}),he(r),fe(n),history.replaceState(null,``,ao(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(co,{side:`left`,width:se,onResize:ce}),(0,h.jsxs)(`main`,{className:`main`,inert:ie&&ne!==null,children:[S&&(0,h.jsx)(no,{client:l.client,agent:S,backLabel:a(b?`Back to conversation`:_?`Back to task`:`Back`),onBack:()=>w(null),onOpenAgent:w},`${S.runId}:${S.stepId??``}`),b&&(0,h.jsx)(Ma,{client:l.client,id:b,hidden:!!S,onOpenAgent:w,onWorkflowRuns:E,workspaceId:L.current??`connecting`,available:!!I.workspace,canInterrupt:!!I.cancelCompatible,enabled:!!I.workspace&&!!I.compatible&&!I.error,onModel:()=>d(!0),onChanged:()=>{R.refresh(),I.refresh()},reference:j,onReferenceUsed:N},`${L.current??`connecting`}:${b}`),P&&!S&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[P.kind!==`task`&&_&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Re(_,J),children:a(`Back to task`)}),ee&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Le(ee),children:a(`Back to ordinary conversation`)}),(0,h.jsx)(`h2`,{title:J||P.id,children:P.kind===`task`?J||a(`Task {id}`,{id:P.id.slice(0,8)}):me||a(`{kind} {id}`,{kind:o(P.kind),id:P.id.slice(0,8)})}),P.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:a(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[a(`Recorded conversation`),` ·`,` `,a(`snapshot {seq}`,{seq:Be??``})]}),(0,h.jsx)(`code`,{children:P.id}),(0,h.jsx)(`p`,{children:a(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!b||!!S,children:[!He&&(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:a(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:a(`History is readonly. Start new work in a conversation with /cadence.`)})]}),He&&X?(0,h.jsxs)(`div`,{className:`tab-body`,children:[we&&(we.owner.entity.kind===`task`||we.owner.entity.kind===`message`||we.owner.entity.kind===`tool`)&&(0,h.jsx)(Ci,{client:l.client,seed:{storeId:X.storeId,scope:X.scope,snapshotSeq:X.snapshotSeq,kind:we.owner.entity.kind,id:we.owner.entity.id,version:we.owner.entity.version}},`${we.owner.entity.id}:${we.owner.entity.version}`),(0,h.jsx)(bi,{client:l.client,cursor:X,highlight:we?.range},`${X.recordId}:${X.recordVersion}`)]}):He&&(0,h.jsxs)(`div`,{className:ye===`messages`||ye===`tools`?`tab-body transcript-body`:`tab-body`,children:[ye===`messages`&&(0,h.jsx)(Gi,{client:l.client,seed:He}),ye===`tools`&&(0,h.jsx)(Fo,{client:l.client,seed:He}),ye===`context`&&(0,h.jsx)(Si,{client:l.client,seed:He}),ye===`timeline`&&(0,h.jsx)(ko,{client:l.client,seed:He,onSearch:()=>Se(!0)}),ye===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:a(`Runs in the current snapshot`)}),We.length>0?We.map(e=>(0,h.jsx)(Mi,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:te&&K.state?a(`No owner run projection in this snapshot.`):a(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:a(`Retained runs`)}),(0,h.jsx)(Fi,{client:l.client,seed:{...He,scope:{kind:`task`,id:_??He.scope.id}},onScope:ze},_)]})]},`${P?.kind}:${P?.id}:${de??`current`}`)]}),I.workspace&&ke.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:ke.map(e=>(0,h.jsx)(Ur,{client:l.client,value:e,onChange:Pe},e.commandId))})]}),(0,h.jsx)(co,{side:`right`,width:le,onResize:ue}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${ne===`right`?` open`:``}`,"aria-label":a(`Files and history drawer`),tabIndex:-1,inert:ie&&ne!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":a(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`files`,onClick:()=>A(`files`),children:[(0,h.jsx)(gr,{}),a(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`task`,disabled:!He,onClick:()=>A(`task`),children:[(0,h.jsx)(fr,{}),a(`History details`)]})]}),k===`files`?(0,h.jsx)(Na,{client:l.client,enabled:!!I.workspace,onReference:e=>{b||Le(ee??void 0),M(e),q()}}):He?(0,h.jsx)(Wa,{client:l.client,seed:{...He,scope:{kind:`task`,id:_??He.scope.id}}},_):(0,h.jsx)(Ua,{})]})})]}),(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:a(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${K.error||!I.workspace?`error`:K.transportStatus===`current`?K.state?K.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),o(Xe),a(` · transport {status}`,{status:o(K.transportStatus)}),K.error?` · ${o(K.error)}`:``]}),(0,h.jsx)(`span`,{className:`status-item${Je?.status===`complete`?Ye.length>0?` warn`:``:` faint`}`,children:Je?.status===`complete`?Ye.length>0?a(Ye.length===1?`{count} active run`:`{count} active runs`,{count:Ye.length}):a(`No active runs`):a(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[I.workspace&&(0,h.jsx)(io,{path:U,onClick:()=>O(``)}),(0,h.jsxs)(`div`,{className:`status-item${I.compatible?` faint`:` warn`}`,title:Mr?.buildId??a(`unbuilt source`),children:[(0,h.jsxs)(`details`,{className:`build-part`,children:[(0,h.jsx)(`summary`,{children:a(`Build information`)}),(0,h.jsx)(y,{text:a(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Mr?.buildId??a(`unbuilt source`)})}}),` `]}),(0,h.jsx)(`span`,{children:a(`Shared compatibility: {state}.`,{state:I.compatible?a(`compatible`):a(`unavailable / mismatch — reload built assets; normal actions disabled`)})})]})]})]}),D!==null&&I.workspace&&(0,h.jsx)(Ja,{onOpen:t,projects:i??(H.value?.kind===`projects`?H.value.entries:[]),client:l.client,current:U??I.workspace.rootLabel,initial:D||void 0,home:r,epoch:I.workspace.epoch,onClose:()=>O(null)}),u&&(0,h.jsx)(Hr,{client:l.client,compatible:!!I.compatible&&I.transportStatus===`current`&&!I.error,onClose:()=>d(!1),onChanged:()=>{Fe.current.depart(),I.refresh(!0)}}),xe&&Ue&&(0,h.jsx)(ji,{client:l.client,seed:Ue,onClose:()=>Se(!1),onHit:e=>{Te(e),Ee(e.cursor),_&&history.replaceState(null,``,ao(_,e.cursor,P?{scope:P,snapshotSeq:de}:void 0))}}),Ce&&Ue&&(0,h.jsx)(Oi,{request:{storeId:Ue.storeId,scope:Ue.scope,snapshotSeq:Ue.snapshotSeq,format:`ndjson`},onClose:()=>Y(!1)})]})}function Fo({client:e,seed:t}){let n=Jr(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(xi,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(qi,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Io=`cadence-last-project`;function Lo(){try{let e=localStorage.getItem(Io);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Ro(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Io,e)}catch{}}function zo(e){let t=Lo();return t?e.projects.find(e=>e.id===t):void 0}async function Bo(e,t){try{return(await Nr(e).client.workbenchRead({kind:`conversations`},t)).kind===`ok`&&!t.aborted}catch{return!1}}function Vo({ready:e,projects:t=[],restore:n=null,onOpenFolder:r,children:i}){let{t:a,locale:o,setLocale:s}=C(),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(!0),g=(0,f.useRef)(null),_=(0,f.useCallback)(()=>l(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>d(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Co({enabled:u,open:c,onOpenChange:l,container:g}),lo(g,c,u,_);let v=e=>{_(),r(e)},y=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${p?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":a(`Tasks`),onClick:()=>l(e=>e===`left`?null:`left`),children:(0,h.jsx)(lr,{"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:o===`zh`?`en`:`zh-CN`,onClick:()=>s(o===`zh`?`en`:`zh`),"aria-label":o===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:o===`zh`?`EN`:`中文`})]})})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":a(`Files`),"aria-expanded":u?c===`right`:p,onClick:()=>u?l(e=>e===`right`?null:`right`):m(e=>!e),children:[(0,h.jsx)(ir,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:a(`Files`)})]})]}),i,(0,h.jsxs)(`div`,{className:`layout`,ref:g,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":a(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${c?` on`:``}`,onClick:_}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${c===`left`?` open`:``}`,"aria-label":a(`Task navigation drawer`),tabIndex:-1,inert:u&&c!==`left`,children:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(Xa,{onConversation:()=>v(),disabled:!e}),(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:a(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?a(`Returning to your last project {name}…`,{name:y(n.path)}):n?.status===`stopped`?a(`Your last project {name} is not running. Choose it below and open it again to see its conversations.`,{name:y(n.path)}):t.length?a(`Conversations are kept with each project. Choose a project below and open it to see its history.`):a(`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,onClick:()=>v(t),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(gr,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:y(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:t})]})]},t))]})]})]})}),(0,h.jsx)(`main`,{className:`main`,inert:u&&c!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":a(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(Da,{})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":a(`Message`),rows:3,placeholder:a(`Choose a working folder at the bottom right to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:a(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(Or,{"aria-hidden":`true`}),a(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${c===`right`?` open`:``}`,"aria-label":a(`Files`),tabIndex:-1,inert:u&&c!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(gr,{"aria-hidden":`true`}),a(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`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:a(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(io,{disabled:!e,onClick:()=>v()})})]})]})}async function Ho(e){return K(await Vn(e,1048576),1048576)}function Uo(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 Wo(){let{t:e}=C(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(Ti),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(0),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(new Map),g=(0,f.useRef)(!r),_=(0,f.useRef)(null),v=(0,f.useCallback)(()=>{_.current&&(_.current.abort(),_.current=null,p(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 Ho(t);t.status===400&&Uo(r)===`invalid`?n(null):t.ok?(n(sn(r)),c(``)):c(Uo(r))}catch{e.signal.aborted||c(`unavailable`)}})(),()=>e.abort()},[l]),(0,f.useEffect)(()=>{let e=()=>{v(),p(null),i(Ti())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[v]),(0,f.useEffect)(()=>{if(!t||!g.current)return;g.current=!1;let e=zo(t);if(!e)return;let n=new AbortController;_.current=n,p({status:`checking`,path:e.cwd}),Bo(e.id,n.signal).then(t=>{n.signal.aborted||(_.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),p(null),i(e.id)):p({status:`stopped`,path:e.cwd}))})},[t]);let y=(0,f.useCallback)(e=>{v(),p(null),r&&m.current.set(r,window.location.hash),history.pushState(null,``,e?`/app?project=${e.id}${m.current.get(e.id)??``}`:`/app`),i(e?.id??null),o(null)},[r,v]),b=(0,f.useCallback)(async e=>{if(!t||!Mr)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`,...Mr})},body:JSON.stringify({commandId:r,path:e,epoch:t.epoch})}),a=await Ho(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(Uo(a));let o=on(a.project);n(e=>e&&{...e,projects:[...e.projects.filter(e=>e.id!==o.id),o]}),y(o)},[t,y]),x=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new k(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Ho(n);if(!n.ok){let e=Uo(r);return{kind:`error`,error:A(O.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:On(r)}}catch{return{kind:`error`,error:A(`unavailable`)}}}}),[]),S=(0,f.useMemo)(()=>r?Nr(r):void 0,[r]),w=t?.projects.find(e=>e.id===r);return(0,f.useEffect)(()=>{w&&Ro(w.id)},[w]),t===null?(0,h.jsx)(Po,{}):t&&w&&S?(0,h.jsx)(Po,{api:S,onOpenProject:b,onWorkbenchHome:()=>y(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r}))},`${w.id}:${w.epoch}`):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Vo,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:d,onOpenFolder:e=>{v(),o(e??t?.home??``)},children:[s&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[s,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>u(e=>e+1),children:e(`Reload observation`)})]}),r&&!w&&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)(Ja,{client:x,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:b})]})}function Go(){let{t:e}=C();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 Ko=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Go,{}):this.props.children}},qo=document.getElementById(`root`);if(!qo)throw Error(`Application root unavailable`);(0,p.createRoot)(qo).render((0,h.jsx)(w,{children:(0,h.jsx)(Ko,{children:(0,h.jsx)(Wo,{})})}));export{Oo as t};
|
|
14
|
+
`),inFence:i!==null}}function ua(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 da=(0,f.memo)(function({text:e}){return(0,h.jsx)(pi,{text:e})}),fa=22,pa=14,ma=()=>typeof document<`u`&&document.hidden;function ha(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||ma()||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(ma()){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?pa:fa;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=ua(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 ga=600,_a=32;function va({text:e,inFence:t}){let n=!t&&e.length>=ga,[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>=_a)r();else return o.current=setTimeout(r,_a-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)(pi,{text:n?r:e})}var ya=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=ha(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)(da,{text:e},t)),a.length>0&&(0,h.jsx)(va,{text:a,inFence:o},i.length)]})});function ba(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 xa(e){let t;try{t=JSON.parse(e)}catch{return null}return t&&typeof t==`object`&&!Array.isArray(t)?t:null}function Sa(e){let t=xa(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 Ca={read:`read`,ls:`list`,find:`search`,grep:`search`,bash:`run`,powershell:`run`,edit:`edit`,write:`edit`},wa=e=>Object.hasOwn(Ca,e)?Ca[e]:`other`,Ta={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`]},Ea=new Set([`read`,`list`,`edit`]);function Da(e,t){return Ea.has(t)?Sa(e.args)||(t===`list`&&xa(e.args)?`.`:e.id):e.id}function Oa({turn:e,steps:t,live:n,answered:r}){let{t:i}=C(),[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`)} ${Sa(e.args)}`.trim():i(`Working…`)}else{let e=new Map;for(let t of c){let n=wa(t.name);e.set(n,(e.get(n)??new Set).add(Da(t,n)))}g=[...e].map(([e,t])=>t.size===1?i(Ta[e][0]):i(Ta[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)(kr,{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)(ka,{item:e}):(0,h.jsx)(`div`,{className:`chat-step-note`,children:(0,h.jsx)(mi,{text:e.text})})},e.id))}),m.map(e=>(0,h.jsx)(`p`,{className:`chat-steps-omitted`,children:e},e))]})}function ka({item:e}){let{t}=C(),n=Sa(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 Aa({turn:e}){let{t,tx:n}=C(),{steps:r,answer:i}=ba(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)(mi,{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)(Oa,{turn:e,steps:r,live:a,answered:i.length>0}),i.map(t=>e.status===`running`?(0,h.jsx)(ya,{text:t.text},t.id):(0,h.jsx)(mi,{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 ja(){let{t:e}=C();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:e(`What would you like to work on?`)}),(0,h.jsx)(`p`,{children:e(`Start a conversation from the sidebar.`)})]})}function Ma({client:e,state:t,canApprove:n,approvalHint:r,onApprove:i,onChanged:a,onOpenAgent:o}){let{t:s}=C(),[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)(Pa,{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)(mi,{text:xn(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 Na(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 Pa({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(1e3),c=zr(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=zr(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:Tn(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),` · `,$i(e.id),` · `,a(e.status)]}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(mi,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:$i(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),Na(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 Fa(e){try{return sessionStorage.getItem(e)??``}catch{return``}}function Ia({client:e,id:t,workspaceId:n,enabled:r,available:i=r,canInterrupt:a=r,onModel:o,onChanged:s,reference:c,onReferenceUsed:l,hidden:u=!1,onOpenAgent:d,onWorkflowRuns:p}){let{t:m,tx:g}=C(),_=`cadence:draft:${n}:${t}`,[v,y]=(0,f.useState)(()=>Fa(_)),[b,x]=(0,f.useState)(()=>Fa(`${_}:mode`)===`cadence`?`cadence`:`chat`),[S,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(``),[k,A]=(0,f.useState)(()=>Fa(`${_}:pending`)),j=zr(e,i?{kind:`conversation`,id:t,before:S}:null,1e3),M=j.value?.kind===`conversation`?j.value:void 0,N=zr(e,i?{kind:`cadence-conversation`,id:t}:null,1e3),P=N.value?.kind===`cadence-conversation`?N.value.state:void 0,F=P?.enabled===!0,I=!!P||!!N.error,L=!!P&&!N.error&&!P.notice,R=(0,f.useRef)(P);R.current=P;let[z,B]=(0,f.useState)(``),V=(0,f.useRef)(``),H=Br(v,F?`cadence`:b),U=r&&!!M&&!j.error&&I&&!(F&&(N.error||P?.notice))&&!T&&!k,W=M?.summary,ee=W&&(W.status===`queued`||W.status===`running`),G=!!W&&W.status!==`completed`&&!ee,K=a&&!!M&&L&&!j.error&&!T&&!k&&!ee,te=!!P?.proposal&&!!W&&!ee&&W.status!==`unknown`,ne=P?.proposal&&W?.status===`unknown`?m(`The latest turn's outcome is unknown. Approval waits until it is observed.`):void 0,re=(0,f.useRef)(null),ie=(0,f.useRef)(null),ae=(0,f.useRef)(0),oe=(0,f.useRef)(!0),[se,ce]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!u&&ie.current&&!oe.current&&(ie.current.scrollTop=ae.current)},[u]);let le=(0,f.useRef)(!0),ue=(0,f.useRef)(``),q=(0,f.useRef)(v);(0,f.useEffect)(()=>(le.current=!0,()=>{le.current=!1}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${_}:mode`,b)}catch{}},[_,b]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(_,v)}catch{}},[v,_]),(0,f.useEffect)(()=>{try{k?sessionStorage.setItem(`${_}:pending`,k):sessionStorage.removeItem(`${_}:pending`)}catch{}},[_,k]),(0,f.useEffect)(()=>{c&&(y(e=>`${e}${e?`
|
|
18
|
+
`:``}@${c}`),l(),re.current?.focus())},[c,l]),(0,f.useEffect)(()=>{let e=M?.summary?`${M.summary.head}:${M.summary.status}`:``;e&&ue.current!==e&&(ue.current=e,s()),V.current&&P?.runs.includes(V.current)&&(V.current=``,B(``),O(``)),k&&M?.turns.some(e=>e.id===k)&&(A(``),y(e=>e===q.current?``:e),s()),oe.current&&ie.current&&(ie.current.scrollTop=ie.current.scrollHeight)},[M,k,s,P]),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${_}:approval`)}catch{}},[_]);let de=JSON.stringify(P?.runs.slice(-4)??[]);(0,f.useEffect)(()=>{p?.(JSON.parse(de))},[de,p]);let fe=async()=>{if(!P?.proposal){O(m(`No plan is awaiting approval.`));return}if(!L||!U||ee||z||!te)return;let t=P;E(!0),O(``);try{let n=await na({client:e,state:t,current:()=>le.current&&R.current?.revision===t.revision&&R.current?.enabled===!0,submitting:e=>{V.current=e,B(e)}});if(!le.current)return;n.kind===`error`?(O(n.error.code),B(``)):y(e=>ia(e)?``:e)}catch(e){le.current&&O(e instanceof Error?e.message:`unavailable`)}finally{le.current&&(E(!1),N.refresh(),j.refresh(),s())}},J=async n=>{let r=n??v;if(!(F&&ra(r)?K:U)||ee||!r.trim()||S!==null)return;if(!n&&F&&ia(r)){await fe();return}let i=Br(r,b).mode===`cadence`;if((F||i)&&!L)O(m(`Cadence state unavailable. Observe the conversation before sending.`));else if(!G||F&&W?.status!==`unknown`){E(!0),O(``);try{if(F&&ra(r)&&P){let n=crypto.randomUUID();q.current=r,A(n);let i=await e.workbenchCommand({kind:`cadence-exit`,commandId:n,conversationId:t,head:W?.head??null,revision:P.revision});if(!le.current)return;i.kind===`error`?(O(i.error.code),i.error.effect===`none`&&A(``)):(A(``),x(`chat`),y(e=>e===r?``:e)),N.refresh(),j.refresh(),s();return}let n=await e.models();if(!le.current)return;if(n.kind===`ok`&&!n.value.selected){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:n.value.version.epoch});if(!le.current)return;if(t.kind===`error`){O(t.error.code),o();return}n=await e.models()}if(n.kind!==`ok`||!n.value.selected){o();return}let a={commandId:crypto.randomUUID(),conversationId:t,head:W?.head??null,text:r,model:n.value.version},c=(F||i)&&P?{kind:`cadence-send`,...a,revision:P.revision,intent:ra(r)?`exit`:F?`message`:`enter`}:{kind:`send`,...a};kn(c),q.current=r,A(c.commandId);let l=await e.workbenchCommand(c);if(!le.current)return;l.kind===`error`?(O(`${l.error.code}. ${m(`Observe this send before sending again. No automatic retry.`)}`),l.error.effect===`none`&&A(``)):(y(e=>e===q.current?``:e),A(``),c.kind===`cadence-send`&&x(`chat`)),N.refresh(),j.refresh(),s()}catch{le.current&&O(m(`Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.`))}finally{le.current&&E(!1)}}},pe=async()=>{let n=M?.turns.find(e=>e.id===W?.head);if(!n||T)return;E(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.id,epoch:n.epoch});le.current&&(r.kind===`error`&&O(r.error.code),E(!1),j.refresh())};return(0,h.jsxs)(`section`,{className:`chat-workspace`,hidden:u,"aria-label":m(F?`Cadence conversation`:`Ordinary conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(fr,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:W?.title??m(`New conversation`)}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:m(F?`Cadence on`:`Ordinary`)}),F&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,disabled:!K,onClick:()=>void J(`exit cadence`),children:m(`Exit Cadence`)})]}),W&&(0,h.jsx)(`span`,{className:`ep-state ${W.status}`,children:F?ee?m(`Discussing`):G?g(W.status):P?.proposal?m(`Awaiting plan approval`):m(`Ready for conversation`):g(W.status)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:ie,onScroll:()=>{let e=ie.current;e&&!u&&(ae.current=e.scrollTop,oe.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,ce(!oe.current))},children:[!W&&(0,h.jsx)(ja,{}),M?.before&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{oe.current=!1,w(M.before)},children:m(`Earlier messages`)}),S&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{oe.current=!0,w(null)},children:m(`Latest messages`)}),M?.turns.map(e=>(0,h.jsx)(Aa,{turn:e},e.id)),P&&(0,h.jsx)(Ma,{client:e,state:P,canApprove:U&&L&&te&&!ee&&!z&&S===null,approvalHint:ne,onApprove:()=>void fe(),onOpenAgent:d,onChanged:()=>{N.refresh(),s()}}),P?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g(P.notice)}),(D||j.error||N.error)&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:D||j.error||N.error}),k&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[m(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:k}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:j.refresh,children:m(`Observe current state`)})]}),G&&F&&W?.status!==`unknown`&&(0,h.jsx)(`p`,{className:`inspector-note`,children:m(`The last turn did not complete. A new message continues from the last complete checkpoint; incomplete work is not replayed.`)}),G&&!F&&(0,h.jsx)(`p`,{className:`inspector-note`,children:m(`This turn has no complete continuation context. Start a new conversation; retained messages are preserved.`)})]}),se&&(0,h.jsx)(`button`,{type:`button`,className:`chat-scroll-bottom`,"aria-label":m(`Latest messages`),onClick:()=>{ie.current&&(ie.current.scrollTop=ie.current.scrollHeight),oe.current=!0},children:(0,h.jsx)(Nr,{})}),(0,h.jsxs)(`form`,{className:`chat-composer`,onSubmit:e=>{e.preventDefault(),J()},children:[(0,h.jsx)(`textarea`,{ref:re,disabled:!r&&!(F&&a)||!M||!I||!!j.error||T||!!k,"aria-label":m(`Message`),value:v,placeholder:m(`Message, or /cadence to enter continuous Cadence mode…`),rows:3,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),J())}}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsxs)(`select`,{"aria-label":m(`Conversation mode`),value:F?`cadence`:H.mode,disabled:F||ee||T,onChange:e=>{let t=e.target.value===`cadence`?`cadence`:`chat`;x(t),t===`chat`&&Br(v,`chat`).mode===`cadence`&&y(H.text)},children:[(0,h.jsx)(`option`,{value:`chat`,children:m(`Ordinary conversation`)}),(0,h.jsx)(`option`,{value:`cadence`,children:m(`Cadence on Send`)})]}),(0,h.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:o,children:[(0,h.jsx)(Tr,{}),m(`Model`)]}),(0,h.jsx)(`span`,{className:`composer-hint`,children:H.mode===`cadence`?m(`Cadence stays on. Confirm one plan before implementation.`):m(`Direct host tools · no Cadence task`)}),ee?(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:T||!a,onClick:()=>void pe(),children:[(0,h.jsx)(sr,{}),m(`Stop response`)]}):(0,h.jsxs)(`button`,{type:`submit`,className:`primary`,disabled:!(F&&ra(v)?K:U)||!v.trim()||G&&(!F||W?.status===`unknown`)||S!==null,children:[(0,h.jsx)(Mr,{}),m(`Send`)]})]})]})]})}function La({client:e,enabled:t,onReference:n}){let{t:r}=C(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(``),u=zr(e,t?{kind:`files`,path:i}:null),d=zr(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)(Mr,{})}),(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)(ur,{})})]}),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)(br,{}):(0,h.jsx)(xr,{}),(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)(dr,{})}),(0,h.jsx)(`button`,{type:`button`,className:`file-action`,"aria-label":r(`Copy path {path}`,{path:e.name}),onClick:()=>void ti(e.path).then(e=>l(e?``:r(`Link copy unavailable.`))),children:(0,h.jsx)(Er,{})})]},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)(ar,{})})]}),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 Ra=`未命名章节`;function za(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 Ba(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=za(r||Ra),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Ra}})}function Va(e){return e.length>=2}function Ha(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 Ua({text:e}){return(0,h.jsx)(`pre`,{className:`scm-diff-pre`,children:Ha(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 Wa({text:e}){let{t}=C(),[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=Ba(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)(ci,{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:[Va(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)(mi,{text:e})})]}):n===`diff`?(0,h.jsx)(Ua,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Ha(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 Ga({client:e,seed:t}){let{t:n,tx:r}=C(),i=Qr(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(Ti,{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(Xr(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)(Wa,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Ka=[`contents`,`checks`,`changes`,`reviews`];function qa(){let{t:e}=C();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 Ja({client:e,seed:t}){let{t:n,tx:r}=C(),[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:Ka.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)(Ei,{client:e,seed:t}):(0,h.jsx)(Ga,{client:e,seed:{...t,reader:i}},i)})]})}var Ya={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.`},Xa=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Za(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 Qa({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[]}){let{t:c,tx:l}=C(),[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,w]=(0,f.useState)(!0),[T,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&&w(!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=>{T||P(e)},L=()=>{let e=p.trim();T||(Xa(e)?P(e):O({step:`read`,code:`relative`}))},R=(g||!u)&&p.trim()||u?.path||``,z=!T&&!b&&!!R,B=async n=>{if(T||!n||b&&n===u?.path)return;if(n!==u?.path&&!Xa(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?Za(u.path,r):void 0,H=v.trim().toLowerCase(),U=u?.entries.filter(e=>e.name.toLowerCase().includes(H))??[],W=D&&(D.step===`read`&&Ya[D.code]?c(Ya[D.code]):l(D.code));return(0,h.jsxs)(Gr,{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:T,onClick:()=>e.current?a():void B(e.path),children:[(0,h.jsx)(br,{"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:T,onClick:()=>I(`~`),children:[(0,h.jsx)(_r,{"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)(kr,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:T,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:T,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:T,onClick:()=>{m(u.path),_(!g),O(null)},children:(0,h.jsx)(Cr,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(lr,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":c(`Filter folders`),placeholder:c(`Filter this folder…`),value:v,disabled:T,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:T,onClick:()=>I(u.parent),children:[(0,h.jsx)(Mr,{}),c(`Parent folder`)]}),U.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>I(e.path),children:[(0,h.jsx)(br,{}),(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(`The shared registry lock is blocking projects. On the service host, run cadence recover inspect --workspace <project> with the same --state-home, then use recover resolve in a local terminal if eligible. Do not delete lock files manually.`)]})]}),(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(T?`Opening folder…`:`Open this folder`)})]})]})}function $a(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 eo({onConversation:e,disabled:t=!1}){let{t:n}=C();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)(dr,{"aria-hidden":`true`}),n(`New conversation`)]})})}function to({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)(Ar,{"aria-hidden":`true`}):(0,h.jsx)(kr,{"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 no({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(new Set),c=$a(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)(kr,{"aria-hidden":`true`}):(0,h.jsx)(Ar,{"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)(Tr,{"aria-hidden":`true`}):(0,h.jsx)(fr,{"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 ro({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=C(),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)(no,{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)(Ti,{pager:e,compact:!0})]})}function io({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:w}){let{t:T,tx:E}=C(),D={reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50},O=Qr(e,D),k=Qr(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":T(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:T(`Task conversations`)}),(0,h.jsx)(ro,{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:[T(`Cadence workflow`),` · `,E(e.phase),` · `,E(e.status)]})]})]}),w&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:P.has(e.id),onClick:()=>{F(t=>new Set(t).add(e.id)),w(e).finally(()=>F(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(sr,{"aria-hidden":`true`}),T(`Cancel workflow — request stop`)]})]},e.id)},L=p.filter(e=>e.status===`running`||e.status===`queued`||e.id===m),R=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)(fr,{})}),(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?T(`Cadence on`):T(`Ordinary`),` ·`,` `,e.cadence&&[`running`,`queued`].includes(e.status)?T(`Discussing`):e.cadence&&e.status===`completed`?T(`Ready for conversation`):E(e.status)]})]})]},e.id);return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(eo,{onConversation:_}),(0,h.jsxs)(to,{title:T(`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:T(`Active roster unavailable; absence is not proof of settlement.`)}),b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`Workflow activity unavailable; retained work may still be running.`)}),L.map(R),v?.map(I),o?.status===`complete`&&j.length===0&&L.length===0&&v?.length===0&&!b&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`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??T(`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)(sr,{"aria-hidden":`true`}),T(`Cancel run — request stop`)]}),n===e.taskId&&(0,h.jsx)(no,{runs:i.filter(t=>t.runId===e.runId),scope:r,onScope:d})]},e.runId)})]}),(0,h.jsxs)(to,{title:T(`Conversation history`),count:O.page&&!(`kind`in O.page)?`${M.length}${O.page.next||O.canPrevious?`+`:``}`:`?`,className:`grow`,children:[(0,h.jsxs)(`nav`,{"aria-label":T(`Tasks`),className:`task-list`,children:[p.filter(e=>!L.includes(e)).map(R),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)(fr,{"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:T(`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&&(0,h.jsx)(`p`,{className:`panel-hint`,children:T(`No retained task on this page.`)}),(0,h.jsx)(Ti,{pager:O,compact:!0})]}),!M.some(e=>e.owner.taskId===n)&&N]})]})}var ao=[`queued`,`running`];function oo({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=C(),[s,c]=(0,f.useState)(1e3),l=zr(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?ao.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!ao.includes(u.status)&&c(0)},[u]);let m=zr(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=zr(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)(Tr,{"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)(Pa,{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)(Aa,{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)(mi,{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}=C(),[i,a]=(0,f.useState)(!1),[o,s]=(0,f.useState)(null),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),p=zr(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}=C();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)(br,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e||r(`Open working folder`)}),(0,h.jsx)(Ar,{"aria-hidden":`true`})]})}function lo(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=ki();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:V(e)});if(n&&(a.set(`scope`,JSON.stringify(X(n.scope))),n.snapshotSeq&&a.set(`snapshot`,U(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function uo(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?X(K(r)):void 0,o=i?U(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=De(K(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}function fo(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 po({side:e,width:t,onResize:n}){let{t:r}=C(),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=fo({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 mo(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 ho=.4,go=1.05;function _o(e){return Math.min(300,e*.86)}function vo(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function yo(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function bo(e,t){return e===`left`?t:-t}function xo(e,t){return Math.max(-e,Math.min(0,-e+t))}function So(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Co(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:So(r*go,n,t)>=ho}var wo=new Set([`auto`,`scroll`,`overlay`]);function To(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&wo.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function Eo(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Do(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=vo(r.clientX,window.innerWidth,n);i&&!To(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=yo(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=_o(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=bo(r,d);let b=xo(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(So(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Co({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(Eo(),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 Oo(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 ko=`modulepreload`,Ao=function(e){return`/`+e},jo={},Mo=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=Ao(t,n),t=s(t),t in jo)return;jo[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`:ko,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 No({client:e,seed:t,onSearch:n}){let{t:r}=C(),i=Qr(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)(Ti,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(Po,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Po({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=C(),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 Mo(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Oo(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)(Ei,{client:e,seed:t})]})}function Fo(){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 Io=[[`tools`,or],[`context`,gr],[`timeline`,Dr],[`runs`,yr]];function Lo({error:e,observationError:t}){let{t:n,tx:r}=C();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)(y,{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 Ro({api:e,onOpenProject:t,onWorkbenchHome:n,workbenchHome:r,projectEntries:i}){let{t:a,tx:o,locale:s,setLocale:c}=C(),[l]=(0,f.useState)(()=>e??Lr()),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(!1),[g]=(0,f.useState)(uo),[_,v]=(0,f.useState)(g?.taskId??null),[b,x]=(0,f.useState)(()=>g?null:Fo()??crypto.randomUUID()),[S,w]=(0,f.useState)(null),[T,E]=(0,f.useState)([]),[D,O]=(0,f.useState)(null),[k,A]=(0,f.useState)(g?`task`:`files`),[j,M]=(0,f.useState)(),N=(0,f.useCallback)(()=>M(void 0),[]),[P,F]=(0,f.useState)(g?g.scope??{kind:`task`,id:g.taskId}:null),I=Ur(l,_?{kind:`task`,id:_}:null,!p),L=(0,f.useRef)(null);I.workspace&&(L.current=I.workspace.workspaceId);let R=zr(l.client,I.workspace&&!p?{kind:`conversations`}:null,2e3),z=zr(l.client,I.workspace&&!p?{kind:`workflow-active`}:null,2e3),B=z.value?.kind===`workflow-active`?z.value:void 0,V=(0,f.useMemo)(()=>[...new Set([...B?.runs.map(e=>e.id)??[],...T])],[B,T]),H=zr(l.client,I.workspace&&!p?{kind:`projects`}:null),U=(H.value?.kind===`projects`?H.value.entries.find(e=>e.current)?.path:void 0)??I.workspace?.rootLabel,W=zr(l.client,_&&I.workspace&&!p?{kind:`task-origin`,taskId:_}:null),ee=W.value?.kind===`task-origin`?W.value.conversationId:null,K={state:I.observation,transportStatus:I.transportStatus,error:I.error,refresh:I.refresh},te=K.state?.snapshot.scope.kind===`task`&&K.state.snapshot.scope.id===_?K.state.snapshot.context:void 0,[ne,re]=(0,f.useState)(null),[ie,ae]=(0,f.useState)(!1),oe=(0,f.useRef)(null),[se,ce]=(0,f.useState)(260),[le,ue]=(0,f.useState)(360),q=(0,f.useCallback)(()=>re(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>ae(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Do({enabled:ie&&!p,open:ne,onOpenChange:re,container:oe}),mo(oe,ne,ie&&!p,q);let[de,fe]=(0,f.useState)(g?.snapshotSeq),[J,pe]=(0,f.useState)(``),[me,he]=(0,f.useState)(``),[ge,_e]=(0,f.useState)(!0),ve=(0,f.useRef)(null),[ye,be]=(0,f.useState)(`messages`),[xe,Se]=(0,f.useState)(!1),[Ce,Y]=(0,f.useState)(!1),[we,Te]=(0,f.useState)(),[X,Ee]=(0,f.useState)(g?.cursor),[De,Oe]=(0,f.useState)(``),[ke,Ae]=(0,f.useState)([]),[je,Me]=(0,f.useState)(new Set),Ne=(0,f.useRef)(!0),Pe=e=>{Ne.current&&Ae(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Rr(t,e):t)})},Fe=(0,f.useRef)(new Wr),Ie=G({taskId:_,scope:P,selectedSnapshot:de??null,detached:p,attachment:I.attachmentVersion,workspaceContext:I.workspace?.context??null,observationError:I.error??null});Fe.current.select(Ie),(0,f.useEffect)(()=>(Ne.current=!0,()=>{Ne.current=!1,Fe.current.depart()}),[]);let Le=(e=crypto.randomUUID())=>{w(null),e!==b&&E([]),Fe.current.depart(),x(e),v(null),F(null),pe(``),he(``),Te(void 0),Ee(void 0),fe(void 0),be(`messages`),A(`files`),q(),history.replaceState(null,``,`${location.pathname}${location.search}#chat=${e}`)};(0,f.useEffect)(()=>{b&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${b}`)},[b]);let Re=(e,t)=>{w(null),E([]),x(null),A(`task`),pe(t??``),he(``),fe(void 0),Fe.current.depart(),v(e),F({kind:`task`,id:e}),Te(void 0),Ee(void 0),be(`messages`),q(),history.replaceState(null,``,lo(e))};(0,f.useEffect)(()=>{let e=()=>{let e=uo();if(e)w(null),E([]),x(null),A(`task`),Fe.current.depart(),fe(e.snapshotSeq),pe(``),he(``),v(e.taskId),F(e.scope??{kind:`task`,id:e.taskId}),Te(void 0),Ee(e.cursor),be(`messages`),q();else{let e=Fo();e&&(w(null),E([]),x(e),v(null),F(null),A(`files`),Fe.current.depart(),q())}};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[q]);let ze=(e,t,n)=>{w(null),fe(t),he(n??``),Fe.current.depart(),F(e),Te(void 0),Ee(void 0),be(`messages`),q(),_&&history.replaceState(null,``,lo(_,void 0,{scope:e,snapshotSeq:t}))},Be=de??K.state?.snapshot.committedSeq??I.workspace?.committedSeq,Ve=I.workspace?.storeId,He=P&&Ve&&Be?{storeId:Ve,scope:P,snapshotSeq:Be,reader:`messages`,after:null,limit:50}:null,Ue=P&&Ve&&Be?{storeId:Ve,scope:P,snapshotSeq:Be,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,We=te?K.state?.snapshot.runs??[]:[],Ge=Fe.current.ticket(),Ke=e=>{Pe(e),e.receipt&&Fe.current.current(Ge)&&I.refresh()},qe=e=>{if(je.has(e)||!I.cancelCompatible||!I.activeRuns)return;let t=crypto.randomUUID(),n=I.activeRuns.epoch;Me(t=>new Set(t).add(e)),Pe({commandId:t,error:a(`Stop requested; settlement is not yet confirmed.`)}),l.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{Ke(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:a(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>Pe({commandId:t,error:a(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{Ne.current&&Me(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:a(`Detached`)}),(0,h.jsx)(`p`,{children:a(`Accepted service work continues. No Cancel was requested.`)}),ke.map(e=>(0,h.jsxs)(`p`,{children:[a(`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:a(`Reconnect as a viewer`)})]});let Je=I.activeRuns,Ye=Je?.status===`complete`?Je.runs:[],Xe=K.state?.connection??(I.workspace?_?`Task snapshot not observed yet`:`Chat ready`:`Service unavailable`);return(0,h.jsxs)(`div`,{className:`app${ge?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":a(`Tasks`),onClick:()=>re(e=>e===`left`?null:`left`),children:(0,h.jsx)(pr,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[n&&(0,h.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":a(`Workbench projects`),title:a(`Workbench projects`),onClick:n,children:(0,h.jsx)(br,{})}),(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`})]}),I.workspace&&(0,h.jsxs)(`span`,{className:`chip static chip-root`,title:I.workspace.rootLabel,children:[(0,h.jsx)(br,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:I.workspace.rootLabel})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),P&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":a(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":ye===`messages`&&!X,onClick:()=>{Ee(void 0),Te(void 0),be(`messages`)},children:[(0,h.jsx)(fr,{"aria-hidden":`true`}),a(`Conversation`)]}),(0,h.jsxs)(`details`,{className:`view-menu`,ref:ve,onKeyDown:e=>{e.key===`Escape`&&ve.current&&(ve.current.open=!1,ve.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`?a(`Details`):o(ye),(0,h.jsx)(Ar,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[Io.map(([e,t])=>(0,h.jsxs)(`button`,{type:`button`,"aria-pressed":ye===e,onClick:()=>{Ee(void 0),Te(void 0),be(e),ve.current&&(ve.current.open=!1,ve.current.querySelector(`summary`)?.focus())},children:[(0,h.jsx)(t,{"aria-hidden":`true`}),o(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":a(`Export selected scope`),disabled:!He,onClick:()=>{ve.current&&(ve.current.open=!1,ve.current.querySelector(`summary`)?.focus()),Y(!0)},children:[(0,h.jsx)(wr,{"aria-hidden":`true`}),a(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":a(`Copy token-free link`),disabled:!_,onClick:()=>{_&&ti(lo(_,X,P?{scope:P,snapshotSeq:de}:void 0)).then(e=>Oe(e?``:a(`Link copy unavailable.`)))},children:[(0,h.jsx)(hr,{"aria-hidden":`true`}),a(`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)(Bi,{disabled:!Ue,onOpen:()=>Se(!0)}),(0,h.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Observe current state`),"data-tip":a(`Observe current state`),onClick:()=>{I.refresh(),K.refresh()},children:(0,h.jsx)(ur,{"aria-hidden":`true`})}),(0,h.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Choose owner model`),"data-tip":a(`Choose owner model`),onClick:()=>d(!0),children:[(0,h.jsx)(Tr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chip-label`,children:a(`Model`)})]}),(0,h.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":a(`Return — work continues`),"data-tip":a(`Return — accepted work continues`),onClick:()=>{re(null),Se(!1),Y(!1),Fe.current.depart(),m(!0)},children:[(0,h.jsx)(mr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`chip-label`,children:a(`Return`)})]}),(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:s===`zh`?`en`:`zh-CN`,"aria-label":s===`zh`?`Switch to English`:`切换到中文`,"data-tip":s===`zh`?`Switch to English`:`切换到中文`,onClick:()=>c(s===`zh`?`en`:`zh`),children:[(0,h.jsx)(vr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:s===`zh`?`EN`:`中文`})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":a(`Files / history`),"aria-expanded":ie?ne===`right`:ge,onClick:()=>ie?re(e=>e===`right`?null:`right`):_e(e=>!e),children:[(0,h.jsx)(cr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:a(b?`Files`:`History`)})]})]}),!I.workspace&&Ye.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":a(`Execution and cancellation`),children:Ye.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:[o(e.kind),` `,e.runId,` · `,o(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>Re(e.taskId),children:a(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!I.cancelCompatible||je.has(e.runId),onClick:()=>qe(e.runId),children:[(0,h.jsx)(sr,{"aria-hidden":`true`}),a(`Cancel run — request stop`)]})]},e.runId))}),(0,h.jsx)(Lo,{error:De,observationError:I.error}),(0,h.jsxs)(`div`,{ref:oe,className:`layout`,style:{"--left-w":`${se}px`,"--right-w":`${le}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":a(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${ne?` on`:``}`,onClick:q}),(0,h.jsxs)(`section`,{className:`panel-drawer drawer-left${ne===`left`?` open`:``}`,"aria-label":a(`Task navigation drawer`),tabIndex:-1,inert:ie&&ne!==`left`,children:[I.workspace&&(0,h.jsx)(io,{client:l.client,workspace:I.workspace,taskId:_,scope:P,runs:We,snapshot:K.state?.snapshot.committedSeq,activeRuns:I.activeRuns,cancelCompatible:!!I.cancelCompatible,canceling:je,onCancel:qe,chats:R.value?.kind===`conversations`?R.value.entries:[],conversationId:b,onConversation:Le,onNewConversation:()=>Le(),workflows:B?.runs,workflowLinks:B?.links,workflowError:!!z.error,selectedWorkflow:S?.runId,onWorkflow:(e,t)=>{t?Le(t):(w({runId:e.id,stepId:null,label:e.goal}),q())},onCancelWorkflow:async e=>{let t=await Na(l.client,e);t&&Oe(t),z.refresh()},onTask:Re,onScope:ze}),I.workspace&&(0,h.jsx)(so,{client:l.client,onOpen:e=>{w(e),q()}}),I.workspace&&(0,h.jsx)(ta,{client:l.client,active:I.activeRuns,taskId:_,runs:We,snapshot:Be,workflowRuns:V,selected:S,onOpenWorkflow:e=>{w(e),q()},onOpen:(e,t,n,r)=>{Re(e),F({kind:`child`,id:t}),he(r),fe(n),history.replaceState(null,``,lo(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),(0,h.jsx)(po,{side:`left`,width:se,onResize:ce}),(0,h.jsxs)(`main`,{className:`main`,inert:ie&&ne!==null,children:[S&&(0,h.jsx)(oo,{client:l.client,agent:S,backLabel:a(b?`Back to conversation`:_?`Back to task`:`Back`),onBack:()=>w(null),onOpenAgent:w},`${S.runId}:${S.stepId??``}`),b&&(0,h.jsx)(Ia,{client:l.client,id:b,hidden:!!S,onOpenAgent:w,onWorkflowRuns:E,workspaceId:L.current??`connecting`,available:!!I.workspace,canInterrupt:!!I.cancelCompatible,enabled:!!I.workspace&&!!I.compatible&&!I.error,onModel:()=>d(!0),onChanged:()=>{R.refresh(),I.refresh()},reference:j,onReferenceUsed:N},`${L.current??`connecting`}:${b}`),P&&!S&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[P.kind!==`task`&&_&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Re(_,J),children:a(`Back to task`)}),ee&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Le(ee),children:a(`Back to ordinary conversation`)}),(0,h.jsx)(`h2`,{title:J||P.id,children:P.kind===`task`?J||a(`Task {id}`,{id:P.id.slice(0,8)}):me||a(`{kind} {id}`,{kind:o(P.kind),id:P.id.slice(0,8)})}),P.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:a(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[a(`Recorded conversation`),` ·`,` `,a(`snapshot {seq}`,{seq:Be??``})]}),(0,h.jsx)(`code`,{children:P.id}),(0,h.jsx)(`p`,{children:a(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!b||!!S,children:[!He&&(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:a(`Select retained history to inspect`)}),(0,h.jsx)(`p`,{children:a(`History is readonly. Start new work in a conversation with /cadence.`)})]}),He&&X?(0,h.jsxs)(`div`,{className:`tab-body`,children:[we&&(we.owner.entity.kind===`task`||we.owner.entity.kind===`message`||we.owner.entity.kind===`tool`)&&(0,h.jsx)(Di,{client:l.client,seed:{storeId:X.storeId,scope:X.scope,snapshotSeq:X.snapshotSeq,kind:we.owner.entity.kind,id:we.owner.entity.id,version:we.owner.entity.version}},`${we.owner.entity.id}:${we.owner.entity.version}`),(0,h.jsx)(wi,{client:l.client,cursor:X,highlight:we?.range},`${X.recordId}:${X.recordVersion}`)]}):He&&(0,h.jsxs)(`div`,{className:ye===`messages`||ye===`tools`?`tab-body transcript-body`:`tab-body`,children:[ye===`messages`&&(0,h.jsx)(Yi,{client:l.client,seed:He}),ye===`tools`&&(0,h.jsx)(zo,{client:l.client,seed:He}),ye===`context`&&(0,h.jsx)(Ei,{client:l.client,seed:He}),ye===`timeline`&&(0,h.jsx)(No,{client:l.client,seed:He,onSearch:()=>Se(!0)}),ye===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:a(`Runs in the current snapshot`)}),We.length>0?We.map(e=>(0,h.jsx)(Ii,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:te&&K.state?a(`No owner run projection in this snapshot.`):a(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:a(`Retained runs`)}),(0,h.jsx)(zi,{client:l.client,seed:{...He,scope:{kind:`task`,id:_??He.scope.id}},onScope:ze},_)]})]},`${P?.kind}:${P?.id}:${de??`current`}`)]}),I.workspace&&ke.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:ke.map(e=>(0,h.jsx)(qr,{client:l.client,value:e,onChange:Pe},e.commandId))})]}),(0,h.jsx)(po,{side:`right`,width:le,onResize:ue}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${ne===`right`?` open`:``}`,"aria-label":a(`Files and history drawer`),tabIndex:-1,inert:ie&&ne!==`right`,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":a(`Workspace panels`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`files`,onClick:()=>A(`files`),children:[(0,h.jsx)(br,{}),a(`Files`)]}),(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":k===`task`,disabled:!He,onClick:()=>A(`task`),children:[(0,h.jsx)(gr,{}),a(`History details`)]})]}),k===`files`?(0,h.jsx)(La,{client:l.client,enabled:!!I.workspace,onReference:e=>{b||Le(ee??void 0),M(e),q()}}):He?(0,h.jsx)(Ja,{client:l.client,seed:{...He,scope:{kind:`task`,id:_??He.scope.id}}},_):(0,h.jsx)(qa,{})]})})]}),(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:a(`Connection freshness is not execution outcome.`),children:[(0,h.jsx)(`span`,{className:`status-dot ${K.error||!I.workspace?`error`:K.transportStatus===`current`?K.state?K.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),o(Xe),a(` · transport {status}`,{status:o(K.transportStatus)}),K.error?` · ${o(K.error)}`:``]}),(0,h.jsx)(`span`,{className:`status-item${Je?.status===`complete`?Ye.length>0?` warn`:``:` faint`}`,children:Je?.status===`complete`?Ye.length>0?a(Ye.length===1?`{count} active run`:`{count} active runs`,{count:Ye.length}):a(`No active runs`):a(`Active roster unavailable; absence is not proof of settlement.`)})]}),(0,h.jsxs)(`div`,{className:`statusbar-right`,children:[I.workspace&&(0,h.jsx)(co,{path:U,onClick:()=>O(``)}),(0,h.jsxs)(`div`,{className:`status-item${I.compatible?` faint`:` warn`}`,title:Ir?.buildId??a(`unbuilt source`),children:[(0,h.jsxs)(`details`,{className:`build-part`,children:[(0,h.jsx)(`summary`,{children:a(`Build information`)}),(0,h.jsx)(y,{text:a(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ir?.buildId??a(`unbuilt source`)})}}),` `]}),(0,h.jsx)(`span`,{children:a(`Shared compatibility: {state}.`,{state:I.compatible?a(`compatible`):a(`unavailable / mismatch — reload built assets; normal actions disabled`)})})]})]})]}),D!==null&&I.workspace&&(0,h.jsx)(Qa,{onOpen:t,projects:i??(H.value?.kind===`projects`?H.value.entries:[]),client:l.client,current:U??I.workspace.rootLabel,initial:D||void 0,home:r,epoch:I.workspace.epoch,onClose:()=>O(null)}),u&&(0,h.jsx)(Kr,{client:l.client,compatible:!!I.compatible&&I.transportStatus===`current`&&!I.error,onClose:()=>d(!1),onChanged:()=>{Fe.current.depart(),I.refresh(!0)}}),xe&&Ue&&(0,h.jsx)(Fi,{client:l.client,seed:Ue,onClose:()=>Se(!1),onHit:e=>{Te(e),Ee(e.cursor),_&&history.replaceState(null,``,lo(_,e.cursor,P?{scope:P,snapshotSeq:de}:void 0))}}),Ce&&Ue&&(0,h.jsx)(Mi,{request:{storeId:Ue.storeId,scope:Ue.scope,snapshotSeq:Ue.snapshotSeq,format:`ndjson`},onClose:()=>Y(!1)})]})}function zo({client:e,seed:t}){let n=Qr(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(Ti,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Zi,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Bo=`cadence-last-project`;function Vo(){try{let e=localStorage.getItem(Bo);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Ho(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Bo,e)}catch{}}function Uo(e){let t=Vo();return t?e.projects.find(e=>e.id===t):void 0}async function Wo(e,t){try{return(await Lr(e).client.workbenchRead({kind:`conversations`},t)).kind===`ok`&&!t.aborted}catch{return!1}}function Go({ready:e,projects:t=[],restore:n=null,onOpenFolder:r,children:i}){let{t:a,locale:o,setLocale:s}=C(),[c,l]=(0,f.useState)(null),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(!0),g=(0,f.useRef)(null),_=(0,f.useCallback)(()=>l(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>d(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),Do({enabled:u,open:c,onOpenChange:l,container:g}),mo(g,c,u,_);let v=e=>{_(),r(e)},y=e=>e.split(/[\\/]/).filter(Boolean).at(-1)??e;return(0,h.jsxs)(`div`,{className:`app workbench-entry${p?``:` inspector-hidden`}`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":a(`Tasks`),onClick:()=>l(e=>e===`left`?null:`left`),children:(0,h.jsx)(pr,{"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:o===`zh`?`en`:`zh-CN`,onClick:()=>s(o===`zh`?`en`:`zh`),"aria-label":o===`zh`?`Switch to English`:`切换到中文`,children:[(0,h.jsx)(vr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:o===`zh`?`EN`:`中文`})]})})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":a(`Files`),"aria-expanded":u?c===`right`:p,onClick:()=>u?l(e=>e===`right`?null:`right`):m(e=>!e),children:[(0,h.jsx)(cr,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:a(`Files`)})]})]}),i,(0,h.jsxs)(`div`,{className:`layout`,ref:g,children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":a(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${c?` on`:``}`,onClick:_}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${c===`left`?` open`:``}`,"aria-label":a(`Task navigation drawer`),tabIndex:-1,inert:u&&c!==`left`,children:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(eo,{onConversation:()=>v(),disabled:!e}),(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:a(`Conversation history`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:n?.status===`checking`?a(`Returning to your last project {name}…`,{name:y(n.path)}):n?.status===`stopped`?a(`Your last project {name} is not running. Choose it below and open it again to see its conversations.`,{name:y(n.path)}):t.length?a(`Conversations are kept with each project. Choose a project below and open it to see its history.`):a(`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,onClick:()=>v(t),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:y(t)}),(0,h.jsx)(`span`,{className:`session-sub`,children:t})]})]},t))]})]})]})}),(0,h.jsx)(`main`,{className:`main`,inert:u&&c!==null,children:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":a(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsx)(ja,{})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{disabled:!0,"aria-label":a(`Message`),rows:3,placeholder:a(`Choose a working folder at the bottom right to start chatting.`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`span`,{className:`composer-hint`,children:a(`Ordinary conversation`)}),(0,h.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!0,children:[(0,h.jsx)(Mr,{"aria-hidden":`true`}),a(`Send`)]})]})]})]})}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${c===`right`?` open`:``}`,"aria-label":a(`Files`),tabIndex:-1,inert:u&&c!==`right`,children:(0,h.jsxs)(`aside`,{className:`panel files-panel`,children:[(0,h.jsxs)(`header`,{className:`files-toolbar`,children:[(0,h.jsx)(br,{"aria-hidden":`true`}),a(`Files`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`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:a(`No working folder selected`)})}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:(0,h.jsx)(co,{disabled:!e,onClick:()=>v()})})]})]})}async function Ko(e){return K(await Gn(e,1048576),1048576)}function qo(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 Jo(){let{t:e}=C(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(ki),[a,o]=(0,f.useState)(null),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(0),[d,p]=(0,f.useState)(null),m=(0,f.useRef)(new Map),g=(0,f.useRef)(!r),_=(0,f.useRef)(null),v=(0,f.useCallback)(()=>{_.current&&(_.current.abort(),_.current=null,p(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 Ko(t);t.status===400&&qo(r)===`invalid`?n(null):t.ok?(n(sn(r)),c(``)):c(qo(r))}catch{e.signal.aborted||c(`unavailable`)}})(),()=>e.abort()},[l]),(0,f.useEffect)(()=>{let e=()=>{v(),p(null),i(ki())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[v]),(0,f.useEffect)(()=>{if(!t||!g.current)return;g.current=!1;let e=Uo(t);if(!e)return;let n=new AbortController;_.current=n,p({status:`checking`,path:e.cwd}),Wo(e.id,n.signal).then(t=>{n.signal.aborted||(_.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),p(null),i(e.id)):p({status:`stopped`,path:e.cwd}))})},[t]);let y=(0,f.useCallback)(e=>{v(),p(null),r&&m.current.set(r,window.location.hash),history.pushState(null,``,e?`/app?project=${e.id}${m.current.get(e.id)??``}`:`/app`),i(e?.id??null),o(null)},[r,v]),b=(0,f.useCallback)(async e=>{if(!t||!Ir)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`,...Ir})},body:JSON.stringify({commandId:r,path:e,epoch:t.epoch})}),a=await Ko(i);if(!i.ok||!a||typeof a!=`object`||!(`kind`in a)||a.kind!==`project`||!(`project`in a))throw Error(qo(a));let o=on(a.project);n(e=>e&&{...e,projects:[...e.projects.filter(e=>e.id!==o.id),o]}),y(o)},[t,y]),x=(0,f.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new k(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await Ko(n);if(!n.ok){let e=qo(r);return{kind:`error`,error:A(O.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Mn(r)}}catch{return{kind:`error`,error:A(`unavailable`)}}}}),[]),S=(0,f.useMemo)(()=>r?Lr(r):void 0,[r]),w=t?.projects.find(e=>e.id===r);return(0,f.useEffect)(()=>{w&&Ho(w.id)},[w]),t===null?(0,h.jsx)(Ro,{}):t&&w&&S?(0,h.jsx)(Ro,{api:S,onOpenProject:b,onWorkbenchHome:()=>y(null),workbenchHome:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===r}))},`${w.id}:${w.epoch}`):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(Go,{ready:!!t,projects:t?.projects.map(e=>e.cwd)??[],restore:d,onOpenFolder:e=>{v(),o(e??t?.home??``)},children:[s&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[s,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>u(e=>e+1),children:e(`Reload observation`)})]}),r&&!w&&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)(Qa,{client:x,current:``,projects:t.projects.map(e=>({path:e.cwd,current:!1})),initial:a,home:t.home,epoch:t.epoch,onClose:()=>o(null),onOpen:b})]})}function Yo(){let{t:e}=C();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 Xo=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(Yo,{}):this.props.children}},Zo=document.getElementById(`root`);if(!Zo)throw Error(`Application root unavailable`);(0,p.createRoot)(Zo).render((0,h.jsx)(w,{children:(0,h.jsx)(Xo,{children:(0,h.jsx)(Jo,{})})}));export{Mo as t};
|