@abelxiaoxing/cadence 2.1.13 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/cadence-instructions.ts +3 -2
- package/src/cadence-mode.ts +190 -7
- package/src/coordinator-tools.mjs +72 -0
- package/src/native-build.ts +1 -1
- package/src/service/contracts/design.ts +217 -0
- package/src/service/contracts/workbench.ts +75 -3
- package/src/service/project-knowledge.ts +106 -8
- package/src/service-host.mjs +707 -286
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +26 -25
- package/web/dist/assets/timeline-client.js +5 -5
- package/web/dist/manifest.json +9 -9
|
@@ -1,31 +1,32 @@
|
|
|
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,l as s,n as c,o as l,r as u,s as d,t as f,u as p}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 m=e(n(),1),h=t(),g={"Thinking activity observed":`已观察到思考活动`,"Thinking activity ended":`思考活动已结束`,"Thinking content unavailable":`思考内容不可用`,"Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.":`不传输思考正文;可读取的思考内容落盘后可展开查看。`,"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The provider said: {reason}":`供应商返回:{reason}`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"The model request failed and automatic retries did not recover it.":`模型请求失败,自动重试后仍未恢复。`,"Partial work is preserved.":`已有工作已保留。`,"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Validate the plan with this model before approving it.":`请先使用此模型重新核验计划,再确认实施。`,"Restore execution and validate plan":`恢复执行服务并核验计划`,"Validate plan again":`重新核验计划`,"Validating plan…":`正在核验计划…`,"Confirm implementation":`确认实施`,"Previous execution context":`核验前的执行上下文`,"Preparing execution and validating the plan; no implementation is approved.":`正在准备执行服务并核验计划;尚未批准任何实施。`,"Reading the validated plan…":`正在读取核验后的计划…`,"The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.":`计划内容未变,已重新核验执行上下文。请查看下方当前计划后确认实施;尚未批准任何实施。`,"Repository or execution-environment evidence changed. Review the current context before confirming.":`仓库或执行环境的核验证据已变化,请查看当前上下文后再确认。`,"Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.":`核验可能启动执行服务并应用界面中选择的模型,但不会发送聊天消息或实施计划;核验后仍需确认。`,"Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.":`计划核验未完成({code})。未批准任何实施;请读取当前计划后再决定是否重新核验。`,"Preparing execution…":`正在准备执行环境…`,"Checking execution state…":`正在确认执行状态…`,"Execution state unavailable":`执行状态暂时无法确认`,"Model list unavailable":`模型目录读取失败`,"Last used: {model}":`上次使用:{model}`,"Last used model; availability is checked when you send.":`上次使用的模型,发送时会验证其可用性。`,"Execution is being prepared for your Send. Models will load when it is ready.":`正在为本次发送准备执行环境,就绪后会加载模型。`,"The model list changed. Read the current list before choosing again.":`模型列表已变化,请读取当前列表后再选择。`,"The choice was not confirmed. Read the current model before choosing again.":`模型选择结果尚未确认,请读取当前模型后再决定是否重新选择。`,"Recorded history could not be read.":`暂时无法读取历史证据。`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Observing approval request {id}; no approval is replayed.":`正在查询审批请求 {id} 的结果;不会重放审批。`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,"Context {used} / {window} · {percent}%":`上下文 {used} / {window} · {percent}%`,"Context {used} tokens":`上下文 {used} tokens`,"Context unknown after compaction":`压缩后上下文大小未知`,"Context window in use":`上下文窗口占用`,"Context size not observed yet":`尚未读取到上下文大小`,"No completed model response is within reach of this branch's end, so no context size is stated.":`这条分支末尾附近还没有完成的模型回复,因此没有上下文大小。`,"Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).":`网络延迟:{ms}ms(最近一分钟内到服务最快的一次请求,从发出到收到回复首字节)。`,"Cache hit":`缓存命中`,"Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)":`缓存命中:{rate} · 缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,"Summed over every usage record of this session, on every branch.":`按本会话全部用量记录累计,包含所有分支。`,"Cache hit: this session's usage records state no input tokens yet.":`缓存命中:本会话的用量记录里还没有输入 token。`,"Context size as of the last completed model response ({model}). Messages after that response are not counted.":`上下文大小以最近一次完成的模型回复({model})为准,不包含那次回复之后的消息。`,"A compaction followed that response, so the size is unknown until the next one.":`那次回复之后做过压缩,下一次模型回复完成前无法得知大小。`,"The model list states no context window for this model, so no percentage is shown.":`模型列表没有给出这个模型的上下文窗口,因此不显示占比。`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files appear once this folder has been observed.":`读取到该目录的状态后即可浏览文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Active Pi work":`Pi 活动工作`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder":`选择工作文件夹`,"Choose a working folder to start. You can write a draft below.":`选择工作文件夹即可开始,也可以先在下方写草稿。`,"Write a message. Choose a folder before sending…":`输入消息,发送前请选择文件夹…`,"Choose a folder before sending.":`发送前请选择文件夹。`,"Returning to your last folder {path}…":`正在返回上次的文件夹 {path}…`,"Could not restore {path}. Choose a folder to continue; nothing was started.":`无法恢复 {path},请选择文件夹以继续;没有启动任何服务。`,"Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.":`选择服务所在主机上的文件夹。会话保留在原文件夹中,运行中的工作不受影响;仅在发送消息时按需启动执行服务。`,"Connecting…":`正在连接…`,"Ready to prepare execution":`可按需准备执行服务`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.":`执行服务准备被拒绝,未产生任何变更({code})。本次未启动执行服务;消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.":`批准覆盖本目标及其决定、验收标准和假设。之后由服务自行完成:它可以在仓库内调整路线和写入范围;对验收的任何偏离都会记录下来,交给自动审查确认,并在最终报告中置顶。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Waiting messages":`等待中的消息`,"Steering: read at the model's next step":`插队:模型下一步就会读到`,"Queued: sent when this reply ends":`排队:这条回复结束后发送`,Withdraw:`撤回`,"Withdraw and put back in the message box":`撤回并放回输入框`,"Not delivered.":`未送达。`,"Not delivered: the reply ended before this message reached the model. Nothing was replayed; send it again.":`未送达:回复在这条消息到达模型之前就结束了。没有任何内容被重放;需要的话请重新发送。`,"Not observed: the session could not be read when the reply ended, so whether this message was delivered was not recorded. Nothing was replayed.":`未观察到:回复结束时会话无法读取,因此没有记录这条消息是否送达。没有任何内容被重放。`,"Put back in the message box":`放回输入框`,"Queue behind this reply":`排在这条回复之后`,"Queue: sent when this reply ends (Alt+Enter)":`排队:这条回复结束后发送(Alt+Enter)`,"Steer this reply":`插队到这条回复`,"Steer: read at the model's next step (Enter)":`插队:模型下一步就会读到(Enter)`,"Enter steers this reply · Alt+Enter queues behind it":`Enter 插队 · Alt+Enter 排队`,"The running reply did not take the message ({reason}). Your text stays here.":`进行中的回复没有接收这条消息({reason})。你的文字仍在输入框里。`,"That message has already been handed to the model and can no longer be withdrawn.":`这条消息已经交给模型,无法再撤回。`,"The message was not withdrawn ({reason}).":`消息没有撤回({reason})。`,"A message into a running reply carries no images. Remove them, or send after the reply ends.":`发给进行中回复的消息不能带图片。请移除图片,或等回复结束后再发送。`,"Cadence mode is not changed by a message into a running reply. Send this after the reply ends.":`发给进行中回复的消息不会切换 Cadence 模式。请等回复结束后再发送。`,"Eight messages already wait for this reply. Withdraw one, or wait.":`已有 8 条消息在等这条回复。请撤回一条,或稍等。`,"A message into a running reply continues that reply, not another entry.":`发给进行中回复的消息只能接在这条回复上,不能接到别的位置。`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Download file {path}":`下载文件 {path}`,"Reference path only: {path} (the agent reads it on demand)":`仅引用路径 {path}(AI 按需读取)`,"Link folder path {path} to the chat":`链接文件夹路径 {path} 到对话`,"Copy name {path}":`复制名称 {path}`,"Copy path {path}":`复制路径 {path}`,"Download of {path} failed: {error}":`{path} 下载失败:{error}`,"the file is larger than the 64 MiB download limit":`文件超过 64 MiB 的下载上限`,"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 · a download is the file's own bytes, unredacted":`只读预览 · 引用只发送路径,不自动注入文件内容 · 下载的是文件原始字节,不做脱敏`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking that could not be read is not shown.":`无法读取的思考内容不显示。`,"Show thinking":`展开思考内容`,"Thinking still being recorded":`思考内容仍在记录中`,"No thinking text is recorded for this block.":`这段思考没有记录文本。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Link copied.":`链接已复制。`,"Dismiss notification":`关闭通知`,"Theme: {current}. Switch to {next}.":`主题:{current}。点击切换为{next}。`,System:`跟随系统`,Light:`浅色`,Dark:`深色`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"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.":`观察不可用。`,"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; reopen the picker 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; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"Attempts shown: {partial} partial · {blocked} blocked · {failed} failed":`当前显示的尝试:{partial} 项部分完成 · {blocked} 项受阻 · {failed} 项失败`,"Partial or blocked assignments preserve work; they are not process failures or delivery approval.":`部分完成或受阻的任务保留已有成果,不代表进程故障,也不代表交付通过。`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,superseded:`已被取代`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重新打开模型选择器。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`包管理器会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade now":`立即升级`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},_=r(),v=`cadence-locale`,y=new Map(Object.entries(g));function b(e,t,n){let r=e===`zh`?y.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var x={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function S(e,t){let n=Object.hasOwn(x,t)?x[t]:void 0;return n?e(n,{code:t}):t}function C({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,_.jsx)(m.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function w(){try{let e=localStorage.getItem(v);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 T(e,t){return{locale:e,t:(t,n)=>b(e,t,n),tx:t=>b(e,t),setLocale:t}}var E=(0,m.createContext)(T(`en`,()=>{}));function D(){return(0,m.useContext)(E)}function O({initial:e,children:t}){let[n,r]=(0,m.useState)(()=>e??w()),i=(0,m.useMemo)(()=>T(n,e=>{try{localStorage.setItem(v,e)}catch{}r(e)}),[n]);return(0,m.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=b(n,`Cadence task workspace`)},[n]),(0,_.jsx)(E.Provider,{value:i,children:t})}var k=`cadence-theme`,A=[`system`,`light`,`dark`],ee=e=>e===`light`||e===`dark`;function j(){try{let e=localStorage.getItem(k);if(ee(e))return e}catch{}return`system`}function te(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function M(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return ee(e)?e:`system`}function ne(e){try{e===`system`?localStorage.removeItem(k):localStorage.setItem(k,e)}catch{}te(e)}var N=e=>A[(A.indexOf(e)+1)%A.length],re=`cadence-graph/2`,ie=`cadence-public-export/2`,P=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,cookieLifetimeMs:31536e6,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,coordinatorBytes:393216,chunkBytes:8192,detailBytes:33554432,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),ae=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],F=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function oe(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function I(){throw new F}function L(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&I(),R(e)>t)throw new F(`oversize`);return e}function R(e){return new TextEncoder().encode(e).length}function z(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&I(),e}function B(e){return typeof e!=`boolean`&&I(),e}function V(e,t){return(typeof e!=`string`||!t.includes(e))&&I(),e}function H(e,t){return e!==t&&I(),t}function U(e,t){return e===null?null:t(e)}function W(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&I();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&I();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&I(),r[n]=t.value}return r}function G(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&I();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&I(),r.push(n(i.value))}return r}function K(e){let t=L(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)||I(),t}function q(e){let t=L(e,64);return/^[0-9a-f]{64}$/.test(t)||I(),t}function se(e){let t=L(e,P.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||I(),t}function ce(e,t){return se(e),se(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function le(e){let t=L(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||I(),t}function J(e,t=P.controlBytes){let n=t,r=e=>{if(n-=R(e),n<0)throw new F(`oversize`);return e};function i(e,n){if(n>64&&I(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return L(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||I(),r(JSON.stringify(e));if(Array.isArray(e)){let a=G(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`)&&I();let a=t.sort(),o=W(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 I()}return i(e,0)}function ue(e,t=P.controlBytes){L(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 L(JSON.parse(e.slice(r,n)),t)}catch{return I()}i=!i&&a===`\\`}return I()}function a(t){if(t>64&&I(),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]!==`"`&&I(),d=i(),u.has(d)&&I(),u.add(d),r(),e[n++]!==`:`&&I());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&I()}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||I(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&I(),s}let o=a(0);return r(),n!==e.length&&I(),o}function Y(e){let t=W(e,[`code`,`effect`,`recovery`]);return{code:V(t.code,ae),effect:V(t.effect,[`none`,`accepted`,`uncertain`]),recovery:V(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var de=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],fe=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],pe=[`not-launched`,`direct-child-closed`,`unconfirmed`],me=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],he=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ge(e){let t=W(e,[`provider`,`model`,`api`,`thinking`]);return{provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:V(t.api,me),thinking:V(t.thinking,he)}}function _e(e){let{sourceSelectionId:t,...n}=W(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:K(t),...ge(n)}}function ve(e){let t=W(e,[`role`,`sha256`]);return{role:V(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:q(t.sha256)}}function ye(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function be(e){let t=W(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:K(t.recordId),version:z(t.version,1),field:V(t.field,de),bytes:z(t.bytes,0,P.detailBytes),sha256:q(t.sha256)}}function xe(e){let t=W(e,[`start`,`end`]),n=z(t.start);return{start:n,end:z(t.end,n+1,P.detailBytes)}}function Se(e){let t=W(e,[`source`,`range`,`requireCompleteObservation`]),n=Ce(t.source),r;if(n===`current`)r={kind:n,assignmentId:le(W(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=W(t.source,[`kind`,`runId`,`childRunId`,`result`]);H(n,`historical`);let i=be(e.result);H(i.field,`final-text`),r={kind:`historical`,runId:K(e.runId),childRunId:K(e.childRunId),result:i}}let i=U(t.range,xe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&I(),{source:r,range:i,requireCompleteObservation:B(t.requireCompleteObservation)}}function Ce(e,t=`kind`){(typeof e!=`object`||!e)&&I();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&I(),L(n.value,64,!0)}function we(e){J(e,P.graphBytes);let t=W(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=be(t.plan);H(n.field,`plan`);let r=z(t.planRevision,1);n.version!==r&&I();let i={schema:H(t.schema,re),taskId:K(t.taskId),taskKind:V(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:z(t.taskRevision,1),revision:z(t.revision,1),planRevision:r,plan:n,assignments:G(t.assignments,P.assignments,e=>{let t=W(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:le(t.id),purpose:V(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:L(t.instructions,P.instructionsBytes,!0),expectedOutput:L(t.expectedOutput,P.expectedOutputBytes,!0),role:ve(t.role),model:_e(t.model),dependencies:G(t.dependencies,P.assignments,Se)}})};i.assignments.length||I();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&I();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&I(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=J(n.source);if(t.has(e)&&I(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||I(),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!==ye(e.purpose))throw new F(`forbidden`);c(e)}return i}function Te(e){let t=W(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=U(t.graphRevision,e=>z(e,1)),r=U(t.graphIdentity,q);return n===null!=(r===null)&&I(),{id:K(t.id),kind:V(t.kind,[`code`,`research`,`diagnosis`]),revision:z(t.revision,1),identity:q(t.identity),graphRevision:n,graphIdentity:r}}function Ee(e){let t=W(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=W(t.observation,[`identity`,`complete`]);return{epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),configRev:z(t.configRev,1),controlRev:z(t.controlRev,1),workspaceId:K(t.workspaceId),cwdId:K(t.cwdId),model:_e(t.model),checkEnvGeneration:z(t.checkEnvGeneration,1),checkoutGeneration:z(t.checkoutGeneration),observation:{identity:q(n.identity),complete:B(n.complete)},task:U(t.task,Te)}}function De(e){let t=W(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:V(t.kind,[`configured`,`manual`]),name:L(t.name,128,!0),command:L(t.command,4096,!0),timeoutMs:z(t.timeoutMs,100,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&I(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&I(),n}function Oe(e){switch(J(e),Ce(e)){case`create`:{let t=W(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:V(t.taskKind,[`code`,`research`,`diagnosis`]),goal:L(t.goal,8192,!0)}}case`save-plan`:{let t=W(e,[`kind`,`taskId`,`plan`,`graph`]),n=we(t.graph),r=K(t.taskId);return n.taskId!==r&&I(),{kind:`save-plan`,taskId:r,plan:L(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:Ce(e),taskId:K(W(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=W(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:K(t.taskId),check:De(t.check)}}case`review`:{let t=W(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:K(t.taskId),runId:K(t.runId),changesIdentity:q(t.changesIdentity),checksRevision:z(t.checksRevision),acceptIssues:B(t.acceptIssues)}}default:return I()}}function ke(e){J(e);let t=W(e,[`expected`,`action`]);return{expected:Ee(t.expected),action:Oe(t.action)}}function Ae(e){J(e);let t=W(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:K(t.commandId),grant:K(t.grant),expected:Ee(t.expected),action:Oe(t.action)}}function je(e){if(J(e),Ce(e)===`action`){let t=W(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:Ee(t.expected),action:Oe(t.action)}}let t=W(e,[`kind`,`epoch`,`runId`]);return H(t.kind,`cancel`),{kind:`cancel`,epoch:K(t.epoch),runId:K(t.runId)}}function Me(e){let t=W(e,[`commandId`,`epoch`,`runId`]);return{commandId:K(t.commandId),epoch:K(t.epoch),runId:K(t.runId)}}function Ne(e){J(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=W(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=G(n.configuredChecks,32,De);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&I(),{...t?{checkEnvironmentPolicy:H(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:z(n.checksRevision),reviewRunId:U(n.reviewRunId,K),version:Ee(n.version),action:Oe(n.action),rootLabel:L(n.rootLabel,4096,!0),cwdLabel:L(n.cwdLabel,4096,!0),readablePlan:L(n.readablePlan,32768),graph:U(n.graph,we),activeRunId:U(n.activeRunId,K),issues:G(n.issues,7,e=>V(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Pe(e){J(e);let t=W(e,[`grant`,`expiresAt`,`preview`]),n=L(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)&&I(),{grant:K(t.grant),expiresAt:n,preview:Ne(t.preview)}}function Fe(e){let t=W(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:V(t.observed,[`complete`,`incomplete`]),source:V(t.source,[`complete`,`limited`,`unavailable`]),redacted:B(t.redacted),omissions:G(t.omissions,6,e=>V(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`))&&I(),n}function Ie(e){let t=W(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:z(t.graphRevision,1),inputs:G(t.inputs,P.assignments,e=>{let t=W(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=be(t.result);H(i.field,`final-text`);let a=U(t.range,xe);a&&a.end>i.bytes&&I();let o=L(t.text,P.predecessorBytes);if(n+=R(o),n>P.handoffBytes)throw new F(`oversize`);let s=z(t.dependencyIndex,0,P.assignments-1);return r.has(s)&&I(),r.add(s),R(o)!==(a?a.end-a.start:i.bytes)&&I(),{assignmentId:le(t.assignmentId),dependencyIndex:s,runId:K(t.runId),childRunId:K(t.childRunId),result:i,range:a,text:o,coverage:Fe(t.coverage)}})}}function Le(e){let t=W(e,[`source`,`reason`,`target`]);return{source:V(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:L(t.reason,128,!0),target:L(t.target,128,!0)}}function Re(e){let t=W(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Le(t.stop)},outcome:V(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:V(t.closure,pe),exitCode:U(t.exitCode,e=>z(e,-2147483648,4294967295)),signal:U(t.signal,e=>L(e,32,!0)),durationMs:z(t.durationMs),stdin:V(t.stdin,[`delivered`,`failed`,`not-required`]),final:V(t.final,[`valid`,`missing`,`invalid`]),cleanup:V(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Fe(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&I(),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`)&&I(),n}function ze(e){let t=W(e,[`kind`,`id`]);return{kind:V(t.kind,[`task`,`run`,`child`]),id:K(t.id)}}function Be(e){let t=L(e,P.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||I(),t}function Ve(e){J(e);let t=W(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:K(t.storeId),scope:ze(t.scope),query:U(t.query,e=>{let t=L(e,P.queryBytes);return t.length||I(),t}),snapshotSeq:se(t.snapshotSeq),recordId:U(t.recordId,K),recordVersion:U(t.recordVersion,e=>z(e,1)),field:U(t.field,e=>V(e,de)),offset:z(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&I(),n}function He(e){let t=W(e,[`disposition`,`value`]),n=V(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Z(t.value);return n===`observed`!=(r!==null)&&I(),{disposition:n,value:r}}function X(e){let t=W(e,[`messageId`,`blockId`]);return{messageId:K(t.messageId),blockId:K(t.blockId)}}function Ue(e){let t=Ce(e);if(t===`message-final`)return{kind:t,messageId:K(W(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:V(W(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=W(e,[`kind`,`dependencyIndex`,`source`]),r=be(n.source);return H(r.field,`final-text`),{kind:t,dependencyIndex:z(n.dependencyIndex,0,P.assignments-1),source:r}}if(t===`message`){let n=W(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:K(n.messageId),blockId:K(n.blockId),index:z(n.index,0,P.dataFrames),stage:V(n.stage,[`stream`,`final`])}}let n=W(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return H(t,`tool`),{kind:`tool`,callId:K(n.callId),blockId:K(n.blockId),index:z(n.index,0,P.dataFrames),stage:V(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function We(e){let t=W(e,[`owner`,`field`,`encoding`]),n=Ue(t.owner),r=V(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=V(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`))&&I(),{owner:n,field:r,encoding:i}}function Ge(e){let t=W(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=V(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=V(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=U(t.mimeType,e=>L(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)))&&I(),{owner:Ue(t.owner),sourceType:n,mimeType:i,reason:r}}function Z(e){if(e===null)return null;let t=L(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||I(),t}function Ke(e){let t=W(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`,...Object.hasOwn(e??{},`reason`)?[`reason`]:[]]),n=z(t.maxAttempts,1),r={phase:V(t.phase,[`waiting`,`requesting`]),attempt:z(t.attempt,1,n),maxAttempts:n,delayMs:z(t.delayMs,0,2147483647),...t.reason===void 0?{}:{reason:L(t.reason,256,!0)}};if(r.phase===`requesting`&&r.delayMs!==0)throw new F(`invalid`);return r}function qe(e){let t=Ce(e);switch(t){case`ready`:{let n=W(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:H(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=W(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:q(e.workerHash)}})()}}}case`message-start`:{let n=W(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=V(n.role,[`user`,`assistant`,`tool-result`]),i=U(n.resultCallId,K);return r!==`tool-result`&&i!==null&&I(),{kind:t,messageId:K(n.messageId),role:r,source:He(n.source),resultCallId:i}}case`thinking-activity`:{let n=W(e,[`kind`,`messageId`,`index`,`phase`]);return{kind:t,messageId:K(n.messageId),index:z(n.index,0,P.dataFrames),phase:V(n.phase,[`active`,`complete`,`unavailable`])}}case`message-text`:{let n=W(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...X({messageId:n.messageId,blockId:n.blockId}),detailId:K(n.detailId)}}case`message-end`:{let n=W(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:K(n.messageId),finalDetailId:U(n.finalDetailId,K),finalBlockCount:z(n.finalBlockCount,0,P.dataFrames),stopReason:V(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=W(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:K(n.callId),declaration:X(n.declaration),index:z(n.index,0,P.dataFrames),source:He(n.source),name:L(n.name,128,!0),argsDetailId:U(n.argsDetailId,K),stage:V(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=W(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:K(n.callId),declaration:U(n.declaration,X),source:He(n.source),name:L(n.name,128,!0),argsDetailId:U(n.argsDetailId,K)}}case`tool-update`:{let n=W(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:K(n.callId),detailId:K(n.detailId),semantics:H(n.semantics,`snapshot`)}}case`tool-end`:{let n=W(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=V(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=U(n.declaration,X),a=B(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&I(),{kind:t,callId:K(n.callId),declaration:i,source:He(n.source),name:L(n.name,128,!0),resultDetailId:K(n.resultDetailId),isError:B(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Ge(W(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=W(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:K(n.detailId),descriptor:We(n.descriptor)}}case`detail-chunk`:{let n=W(e,[`kind`,`detailId`,`offset`,`text`]),r=L(n.text,P.chunkBytes),i=z(n.offset,0,P.detailBytes);return i+R(r)>P.detailBytes&&I(),{kind:t,detailId:K(n.detailId),offset:i,text:r}}case`detail-end`:{let n=W(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:K(n.detailId),bytes:z(n.bytes,0,P.detailBytes),sha256:q(n.sha256),coverage:Fe(n.coverage)}}case`model-retry`:return{kind:t,progress:U(W(e,[`kind`,`progress`]).progress,Ke)};case`capture-status`:return{kind:t,coverage:Fe(W(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:V(W(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=W(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:K(n.messageId),detailId:K(n.detailId),stopReason:H(n.stopReason,`stop`)}}default:return I()}}function Je(e){let t=W(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Le(t.stop)},outcome:V(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:V(t.closure,pe),exitCode:U(t.exitCode,e=>z(e,-2147483648,4294967295)),signal:U(t.signal,e=>L(e,32,!0)),durationMs:z(t.durationMs),stdin:H(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))&&I(),n}function Ye(e){let t=W(e,[`messageId`,`detailId`]);return{messageId:K(t.messageId),detailId:K(t.detailId)}}function Xe(e){let t=W(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=se(t.committedSeq);return n===`0`&&I(),{childRunId:K(t.childRunId),detailId:K(t.detailId),content:be(t.content),committedSeq:n}}function Ze(e){let t=Ce(e,`status`);if(t===`committed`){let n=W(e,[`status`,`selected`,`detail`]),r=Ye(n.selected),i=Xe(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&I(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=W(e,[`status`,`selected`,`error`]);return{status:t,selected:U(n.selected,Ye),error:Y(n.error)}}let n=W(e,[`status`,`selected`]);return{status:V(t,[`pending`,`uncertain`]),selected:U(n.selected,Ye)}}function Qe(e,t){let n=U(e,se);return(n===`0`||n!==null&&t.status===`committed`&&ce(n,t.detail.committedSeq)<0)&&I(),n}function $e(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function et(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?$e(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function tt(e){let t=Ce(e);if(t===`sdk`){let n=W(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ze(n.recording),i=Qe(n.settlementSeq,r);return{kind:t,native:Re(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=W(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=U(n.settlementSeq,se);return r===`0`&&I(),{kind:t,native:Je(n.native),capture:Fe(n.capture),settlementSeq:r}}let n=W(e,[`kind`,`outcome`,`required`]);H(t,`parent`);let r=G(n.required,P.assignments,e=>{let t=W(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=K(t.childRunId),r=Ze(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&I(),{assignmentId:le(t.assignmentId),childRunId:n,native:U(t.native,Re),recording:r,settlementSeq:Qe(t.settlementSeq,r)}}),i=V(n.outcome,fe);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($e))&&I(),{kind:`parent`,outcome:i,required:r}}function nt(e){let t=W(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=z(t.first,1,2**53-1),r=z(t.last,n,2**53-1),i=z(t.firstObservedMs),a=z(t.lastObservedMs,i);return n===r&&i!==a&&I(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function rt(e){let t=W(e,[`source`,`event`]),n=nt(t.source),r=Ce(t.event);if(r===`stored-chunk`){let e=W(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:K(e.detailId),text:L(e.text,P.chunkBytes)}}}if(r===`stored-end`){let e=W(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:K(e.detailId),coverage:Fe(e.coverage)}}}let i=qe(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&I(),{source:n,event:i}}function it(e){let t=W(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:K(t.epoch),taskId:K(t.taskId),runId:K(t.runId),childRunId:K(t.childRunId)}}function at(e){J({kind:`ok`,value:e},P.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=W(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:K(n.storeId),workspaceId:K(n.workspaceId),epoch:K(n.epoch)};if(!t)return H(n.status,`unavailable`),{...r,status:`unavailable`,error:ot(n.error)};let i=G(n.runs,P.episodes,e=>{let t=W(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:K(t.taskId),runId:K(t.runId),operationId:K(t.operationId),epoch:K(t.epoch),kind:V(t.kind,[`start`,`generate-plan`,`check`]),stage:V(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)&&I(),{...r,status:`complete`,runs:i}}function ot(e){let t=Y(e);return H(t.effect,`none`),t}function st(e){let t=W(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:q(t.sourceHash),contractHash:q(t.contractHash),buildId:q(t.buildId)}}function ct(e){let t=V(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=W(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:q(n.contractHash)}:{kind:t,...st({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function lt(e){let t=W(e,[`contractHash`,`assets`]);return{contractHash:q(t.contractHash),assets:st(t.assets)}}function ut(e){J(e);let t=W(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:K(t.commandId),operationId:K(t.operationId),runId:U(t.runId,K),admission:V(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:se(t.committedSeq),execution:U(t.execution,e=>V(e,fe)),settlement:U(t.settlement,tt),created:U(t.created,e=>{let t=W(e,[`kind`,`taskId`,`state`]);return{kind:H(t.kind,`task`),taskId:K(t.taskId),state:V(t.state,[`reserved`,`published`])}}),publication:V(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&&et(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&I(),n}function dt(e){J(e);let t=W(e,[`identity`,`receipt`]),n=je(t.identity),r=ut(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&I();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&I(),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`))&&I()}return{identity:n,receipt:r}}function Q(e,t){if(Ce(e)===`ok`)return{kind:`ok`,value:t(W(e,[`kind`,`value`]).value)};let n=W(e,[`kind`,`error`]);return H(n.kind,`error`),{kind:`error`,error:Y(n.error)}}function ft(e){switch(J(e),Ce(e,`status`)){case`found`:return{status:`found`,receipt:ut(W(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:se(W(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:Y(W(e,[`status`,`error`]).error)};default:return I()}}function pt(e){let t=W(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:K(t.runId),taskId:K(t.taskId),childRunId:U(t.childRunId,K),assignmentId:U(t.assignmentId,le),admission:Ct(t.admission),lifecycle:V(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:U(t.outcome,e=>V(e,fe)),settlement:U(t.settlement,tt),reason:U(t.reason,e=>V(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:V(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Fe(t.coverage),result:U(t.result,be)};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`&&J(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==J(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&J(n.result)!==J(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&&et(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||et(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&I(),n}function mt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function ht(e,t,n){return mt(e,t)&&e.taskId===Et(n)&&e.admission.context.workspaceId===Tt(n)}function gt(e){J(e,P.pageBytes);let t=W(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:H(t.protocol,1),storeId:K(t.storeId),epoch:K(t.epoch),scope:ze(t.scope),committedSeq:se(t.committedSeq),context:wt(t.context),runs:G(t.runs,P.maxPageEntries,pt),horizon:Rt(t.horizon)};return(!Dt(n.context,n.epoch,n.scope)||J(n.horizon.historicalRuns.scope)!==J(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!ht(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&I(),n}function _t(e){J(e,P.pageBytes);let t=Ce(e),n=W(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:K(n.storeId),epoch:K(n.epoch),scope:ze(n.scope),committedSeq:se(n.committedSeq)};if(t===`update`){let e=se(n.previousSeq);ce(r.committedSeq,e)<=0&&I();let i=wt(n.context);Dt(i,r.epoch,r.scope)||I();let a=G(n.runs,P.maxPageEntries,pt),o=G(n.removed,P.maxPageEntries,K),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!ht(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&I(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return H(t,`heartbeat`),{kind:`heartbeat`,...r}}function vt(e){let{navigation:t,...n}=e;return n}function yt(e,t){(!t.navigation||t.navigation===e.navigation||J(vt(e))!==J(vt(t)))&&I()}function bt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return xt(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`cursor`,`next`,`coverage`]),n=Ve(t.cursor),r=Ve(t.next);return yt(n,r),{kind:`progress`,cursor:n,next:r,coverage:Fe(t.coverage)}}function xt(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Ve(t.cursor),content:be(t.content),range:U(t.range,xe),text:L(t.text,P.detailPageBytes),next:U(t.next,Ve),coverage:Fe(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!==R(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&I(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&I(),n.next&&(n.next.offset!==n.range?.end||J(vt({...n.next,offset:n.cursor.offset}))!==J(vt(n.cursor)))&&I(),n}function St(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`cursor`,`hits`,`next`,`coverage`]),n=Ve(t.cursor);n.query||I();let r=R(n.query),i=G(t.hits,P.maxPageEntries,e=>{let t=W(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=be(t.content),a=At(t.owner);jt(a,n.scope)||I();let o=xe(t.range),s=Ve(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||J(s.scope)!==J(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&I(),{content:i,owner:a,range:o,preview:L(t.preview,P.previewBytes),cursor:s}}),a=U(t.next,Ve);return a&&(a.storeId!==n.storeId||J(a.scope)!==J(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)))&&I(),{cursor:n,hits:i,next:a,coverage:Fe(t.coverage)}}function Ct(e){let t=W(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=Ee(t.context),r=U(t.graph,e=>{let t=W(e,[`recordId`,`revision`,`sha256`]);return{recordId:K(t.recordId),revision:z(t.revision,1),sha256:q(t.sha256)}}),i=V(t.kind,[`start`,`generate-plan`,`check`]),a=G(t.assignments,P.assignments,e=>{let t=W(e,[`assignmentId`,`childRunId`]);return{assignmentId:le(t.assignmentId),childRunId:K(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)&&I(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&I(),{operationId:K(t.operationId),commandId:K(t.commandId),kind:i,context:n,assignments:a,graph:r}}function wt(e){if(Ce(e,`status`)===`available`)return{status:`available`,version:Ee(W(e,[`status`,`version`]).version)};let t=W(e,[`status`,`workspaceId`,`taskId`,`error`]);H(t.status,`unavailable`);let n=Y(t.error);return H(n.effect,`none`),{status:`unavailable`,workspaceId:K(t.workspaceId),taskId:U(t.taskId,K),error:n}}function Tt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Et(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Dt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Et(e)===n.id)}function Ot(e){let t=W(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=W(t.capabilities,[`actions`,`manualChecks`,`history`]),r=V(t.authority,[`browser`,`local`]),i=U(t.csrf,K),a={actions:B(n.actions),manualChecks:B(n.manualChecks),history:B(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&I(),{...t.build===void 0?{}:{build:lt(t.build)},protocol:H(t.protocol,1),storeId:K(t.storeId),epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function kt(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:at(t.activeRuns)},workspaceId:K(t.workspaceId),storeId:K(t.storeId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),rootLabel:L(t.rootLabel,4096,!0),context:wt(t.context),models:G(t.models,P.maxPageEntries,_e)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&I(),(Tt(n.context)!==n.workspaceId||Et(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&I(),n}function At(e){let t=W(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=W(t.entity,[`kind`,`id`,`version`]),r={taskId:K(t.taskId),runId:U(t.runId,K),childRunId:U(t.childRunId,K),entity:{kind:V(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:K(n.id),version:z(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)&&I(),r}function jt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Mt(e){let t=W(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:q(t.identity),complete:B(t.complete),checkoutGeneration:z(t.checkoutGeneration)}}function Nt(e){J(e,P.controlBytes);let t=Ce(e);switch(t){case`assignment-state`:{let n=W(e,[`kind`,`childRunId`,`state`,`reason`]),r=V(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=U(n.reason,e=>V(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&I(),(r===`ready`||r===`preparing`)&&i!==null&&I(),{kind:t,childRunId:K(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:V(W(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=W(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:K(n.runId),identity:Ct(n.identity)}}case`parent-settled`:{let n=W(e,[`kind`,`runId`,`settlement`]),r=tt(n.settlement);return r.kind!==`parent`&&I(),{kind:t,runId:K(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=W(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:K(r.reservationId)}:{},lane:V(r.lane,[`reader`,`writer`,`check`]),state:V(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:z(r.checkoutGeneration)}}case`handoff`:{let n=W(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:K(n.childRunId),handoff:Ie(n.handoff),observation:Mt(n.observation)}}case`changes`:{let n=W(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=be(n.content);return H(r.field,`changes`),{kind:t,observationId:K(n.observationId),stage:V(n.stage,[`before`,`after`,`review`]),observation:Mt(n.observation),content:r}}case`check-start`:{let n=W(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:K(n.checkId),selection:De(n.selection),cwdId:K(n.cwdId),cwdLabel:L(n.cwdLabel,4096,!0),checkEnvGeneration:z(n.checkEnvGeneration,1),before:Mt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=W(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=W(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:K(e.operationId),reservationId:K(e.reservationId),from:z(e.from),to:z(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&I()}let a=Je(r.native),o=V(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=Mt(r.before),c=Mt(r.after),l=U(r.output,be),u=Fe(r.coverage);return l&&l.field!==`check`&&I(),o===`passed`&&(a.outcome!==`completed`||J({...s,checkoutGeneration:c.checkoutGeneration})!==J(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&I(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&I(),{kind:t,...i?{ownAdvance:i}:{},checkId:K(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=W(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=B(n.acceptIssues),i=V(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=be(n.content);return H(a.field,`review`),i===`reviewed-with-issues`&&!r&&I(),{kind:t,reviewId:K(n.reviewId),runId:K(n.runId),checksRevision:z(n.checksRevision),changesIdentity:q(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=W(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=z(n.expectedRevision),i=U(n.expectedIdentity,q),a=z(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&I(),{kind:t,publicationId:K(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:q(n.nextIdentity)}}case`publication-settled`:{let n=W(e,[`kind`,`publicationId`,`status`,`observed`]),r=V(n.status,[`published`,`conflict`,`uncertain`]),i=U(n.observed,e=>{let t=W(e,[`revision`,`identity`]);return{revision:z(t.revision,1),identity:q(t.identity)}});return r===`published`&&i===null&&I(),{kind:t,publicationId:K(n.publicationId),status:r,observed:i}}default:return I()}}function Pt(e){let t=W(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:K(t.epoch),operationId:K(t.operationId),taskId:K(t.taskId),runId:U(t.runId,K)}}function Ft(e){J(e,P.ownerQueueBytes);let t=W(e,[`observedMs`,`link`,`events`]),n=Pt(t.link),r=G(t.events,P.ownerQueueFrames,e=>{let t=Ce(e);if(t===`fact`){let r=Nt(W(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)&&I(),{kind:t,fact:r}}if(t===`content-begin`){let r=W(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=At(r.owner),a=V(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))&&I(),{kind:t,detailId:K(r.detailId),owner:i,field:a,encoding:H(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=W(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:K(n.detailId),text:L(n.text,P.chunkBytes)}}let r=W(e,[`kind`,`detailId`,`coverage`]);return H(t,`content-end`),{kind:`content-end`,detailId:K(r.detailId),coverage:Fe(r.coverage)}});return{observedMs:z(t.observedMs),link:n,events:r}}var It=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Lt(e){let t=W(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=V(t.reader,It),r=W(t.scope,[`kind`,`id`]),i={kind:V(r.kind,[`workspace`,`task`,`run`,`child`]),id:K(r.id)},a=U(t.snapshotSeq,se),o=U(t.after,e=>{let t=W(e,[`recordId`,`version`,`offset`]);return{recordId:K(t.recordId),version:z(t.version,1),offset:z(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&I(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:i,snapshotSeq:a,after:o,limit:z(t.limit,1,P.maxPageEntries)}}function Rt(e){let t=W(e,[`policy`,`historicalRuns`]),n=Lt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&I(),{policy:H(t.policy,`active-and-recent`),historicalRuns:n}}function zt(e){let t=Ce(e);if(t===`run`)return{kind:t,projection:pt(W(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=W(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=se(n.committedSeq);return r===`0`&&I(),{kind:t,recordId:K(n.recordId),committedSeq:r,link:it(n.link),capture:rt(n.capture)}}if(t===`owner-fact`){let n=W(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Ft({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&I();let a=se(n.committedSeq);return a===`0`&&I(),{kind:t,recordId:K(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=W(e,[...n,...r]),a=At(i.owner),o=z(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&I(),t===`task`){let e=U(i.plan,be);return e&&e.field!==`plan`&&I(),{kind:t,owner:a,version:o,goal:L(i.goal,8192,!0),plan:e}}if(t===`message`){let e=V(i.role,[`user`,`assistant`,`tool-result`]),n=V(i.state,[`partial`,`final`]),r=U(i.finalBlockCount,e=>z(e,0,P.dataFrames)),s=U(i.finalText,be),c=U(i.resultCallId,K);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&I(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:He(i.source)}}if(t===`tool`){let e=U(i.declaration,X),n=U(i.declarationStage,e=>V(e,[`partial`,`final`])),r=B(i.startObserved),s=U(i.result,e=>{let t=qe(e);return t.kind!==`tool-end`&&I(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||J(s.declaration)!==J(e)))&&I(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:He(i.source),name:L(i.name,128,!0)}}if(t===`content`){let e=We(i.descriptor),n=be(i.content);return(e.field!==n.field||!Bt(e.owner,a))&&I(),{kind:t,owner:a,version:o,detailId:K(i.detailId),descriptor:e,content:n,coverage:Fe(i.coverage)}}H(t,`omitted`);let s=Ge(i.block);return Bt(s.owner,a)||I(),{kind:`omitted`,owner:a,version:o,block:s}}function Bt(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function Vt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function Ht(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`records`,`next`,`coverage`]),n=Lt(t.request);n.snapshotSeq===null&&I();let r=G(t.records,n.limit,zt),i=U(t.next,Lt);return(r.some(e=>!Vt(e,n))||i&&(i.after===null||J(vt({...i,after:n.after}))!==J(vt(n))||J(i.after)===J(n.after)))&&I(),{request:n,records:r,next:i,coverage:Fe(t.coverage)}}function Ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||J(vt({...r,snapshotSeq:null}))!==J(vt(n)))&&I(),{kind:`snapshot`,request:n,next:r,coverage:Fe(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ht(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}function Wt(e,t){return J({...t.request,snapshotSeq:e.snapshotSeq})===J(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Gt(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=W(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),graph:{recordId:K(n.recordId),revision:z(n.revision,1),sha256:q(n.sha256)}}}function Kt(e){J({kind:`ok`,value:e});let t=W(e,[`request`,`graph`]),n=Gt(t.request),r=we(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&I(),{request:n,graph:r}}function qt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Kt(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Gt(t.request),r=Gt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}function Jt(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),format:V(t.format,[`ndjson`,`markdown`])}}function Yt(e){J(e,P.controlBytes);let t=W(e,[`exportId`,`ordinal`,`event`]),n=Ce(t.event),r;switch(n){case`manifest`:{let e=W(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=W(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:q(i.exporterBuildSha256),capturePolicy:H(i.capturePolicy,`public-text-tools/2`)},schema:H(e.schema,ie),request:Jt(e.request),coverage:Fe(e.coverage),serviceProtocol:H(e.serviceProtocol,1),workerProtocol:H(e.workerProtocol,2)};break}case`record`:r={kind:n,record:zt(W(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Kt(W(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=W(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=be(e.content),a=U(e.range,xe),o=L(e.text,P.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==R(o):i.bytes!==0||o!==``)&&I(),r={kind:n,owner:At(e.owner),content:i,range:a,text:o,coverage:Fe(e.coverage)};break}case`markdown`:r={kind:n,text:L(W(t.event,[`kind`,`text`]).text,P.detailPageBytes)};break;case`trailer`:{let e=W(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Fe(e.coverage),a=B(e.complete);a&&i.observed!==`complete`&&I(),r={kind:n,complete:a,frames:z(e.frames,1),encodedBytes:z(e.encodedBytes),sha256:q(e.sha256),committedSeq:se(e.committedSeq),coverage:i};break}default:return I()}return{exportId:K(t.exportId),ordinal:z(t.ordinal,1),event:r}}function Xt(e,t){let n=Yt(e);return t===`ndjson`?`${J(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&I(),`\n\n\`\`\`json\n${J(n)}\n\`\`\`\n`)}var Zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Jt(e)}receive(e){let t=Yt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&I(),this.ordinal===0?(n.kind!==`manifest`||J(n.request)!==J(this.request))&&I():n.kind===`manifest`&&I(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&I(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&I(),this.request.format===`ndjson`&&n.kind===`markdown`&&I(),n.kind===`detail`&&!jt(n.owner,this.request.scope)&&I(),n.kind===`graph`&&(J(n.graph.request.scope)!==J(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&I(),n.kind===`record`&&!Qt(n.record,this.request.scope)&&I(),this.bytes+=R(Xt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Qt(e,t){return e.kind===`run`?mt(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:jt(e.owner,t)}function $t(e){let t=W(e,[`taskId`,`revision`,`definitions`]),n=G(t.definitions,32,e=>{let t=W(e,[`selection`,`status`,`checkId`]),n=De(t.selection),r=V(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=U(t.checkId,K);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&I(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&I(),{taskId:K(t.taskId),revision:z(t.revision),definitions:n}}function en(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),kind:V(t.kind,[`task`,`message`,`tool`]),id:K(t.id),version:z(t.version,1)}}function tn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`record`]),n=en(t.request),r=zt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!jt(r.owner,n.scope))&&I(),{request:n,record:r}}function nn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return tn(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=en(t.request),r=en(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}var rn=e=>{let t=Y(e);return H(t.effect,`none`),t};function an(e){let t=W(e,[`storeId`,`taskId`]);return{storeId:K(t.storeId),taskId:U(t.taskId,K)}}function on(e){let t=an(e);return t.taskId===null&&I(),t}function sn(e){let t=W(e,[`id`,`kind`,`revision`,`identity`]);return{id:K(t.id),kind:V(t.kind,[`code`,`research`,`diagnosis`]),revision:z(t.revision,1),identity:q(t.identity)}}function cn(e){let t=G(e,3,ve);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&I(),t}function ln(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return W(e,[`status`]),{status:t};if(t===`saved`){let n=W(e,[`status`,`request`,`planRevision`]);return{status:t,request:Gt(n.request),planRevision:z(n.planRevision,1)}}let n=W(e,[`status`,`error`]);return H(n.status,`unavailable`),{status:`unavailable`,error:rn(n.error)}}function un(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Tt(e.context)!==e.workspaceId||Et(e.context)!==e.request.taskId)&&I(),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))&&I()}}function dn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:an(t.request),workspaceId:K(t.workspaceId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),context:wt(t.context),task:U(t.task,sn),roles:cn(t.roles),savedGraph:ln(t.savedGraph),readablePlan:U(t.readablePlan,e=>{let t=W(e,[`source`,`text`,`editable`,`coverage`]),n=Fe(t.coverage),r=B(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&I(),{source:H(t.source,`current-v1`),text:L(t.text,32768),editable:r,coverage:n}})};un(n),!!n.task!=!!n.readablePlan&&I();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))&&I(),r.status===`unavailable`&&n.context.status===`available`&&I(),n}function fn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=W(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:on(t.request),workspaceId:K(t.workspaceId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),context:wt(t.context),task:sn(t.task),observation:{identity:q(n.identity),complete:B(n.complete),checkoutGeneration:z(n.checkoutGeneration,0)},text:L(t.text,131072),git:B(t.git),coverage:Fe(t.coverage)};if(un(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&I()}return r}function pn(e){let t=L(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||I(),t}function mn(e){let t=W(e,[`id`,`cwd`]);return{id:pn(t.id),cwd:L(t.cwd,4096,!0)}}function hn(e){let t=W(e,[`id`,`cwd`,`revision`,`model`]);return{id:pn(t.id),cwd:L(t.cwd,4096,!0),revision:z(t.revision,0,2**53-1-1),model:U(t.model,ge)}}function gn(e){let t=W(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:L(t.cwd,4096,!0),checkoutRoot:L(t.checkoutRoot,4096,!0),version:_n(t.version),model:U(t.model,_e)}}function _n(e){let t=W(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:mn(t.conversation)},epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),configRev:z(t.configRev,1),catalogId:K(t.catalogId)}}function vn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`version`,`selected`]);return{version:_n(t.version),selected:U(t.selected,_e)}}function yn(e){J(e);let t=W(e,[`expected`,`choice`]);return{expected:_n(t.expected),choice:ge(t.choice)}}function bn(e){let t=W(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:B(t.images)},...t.contextWindow===void 0?{}:{contextWindow:z(t.contextWindow,1)},provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:U(t.api,e=>V(e,me)),thinking:G(t.thinking,7,e=>{let t=W(e,[`level`,`selectable`]);return{level:V(t.level,he),selectable:B(t.selectable)}}),eligibility:V(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))&&I(),n}function xn(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function Sn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`status`,`entries`,`withheld`,`remembered`]),n=G(t.entries,P.maxPageEntries,bn),r=U(t.remembered,ge),i=V(t.status,[`complete`,`capacity`]),a=z(t.withheld,0,P.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>P.maxPageEntries||new Set(n.map(e=>J([e.provider,e.model]))).size!==n.length||r&&!xn(n,r))&&I(),{status:i,entries:n,withheld:a,remembered:r}}function Cn(e){let{version:t,selected:n,...r}=W(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return J({kind:`ok`,value:e},P.pageBytes),{...Sn(r),version:_n(t),selected:U(n,_e)}}function wn(e){let t=W(e,[`id`,`path`,`cwd`,`epoch`]);return{id:q(t.id),path:L(t.path,4096,!0),cwd:L(t.cwd,4096,!0),epoch:t.epoch===null?null:K(t.epoch)}}function Tn(e){let t=W(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:H(t.kind,`project-observation`),status:V(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:K(t.epoch),workspaceId:t.workspaceId===null?null:K(t.workspaceId)}}var En=[`registry`,`workbench`,`project`],Dn=[`reboot`,`crash`,`restart`,`storage`],On=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function kn(e){let t=W(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:K(t.id),at:z(t.at,0),scope:V(t.scope,En),path:t.path===null?null:L(t.path,4096,!0),cause:V(t.cause,Dn),actions:G(t.actions,On.length,e=>V(e,On)),workers:z(t.workers,0,1e6),archived:B(t.archived)}}function An(e){let t=W(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:H(t.kind,`workbench`),epoch:K(t.epoch),csrf:K(t.csrf),home:L(t.home,4096,!0),projects:G(t.projects,128,wn),recoveries:G(t.recoveries,20,kn),build:lt(t.build)}}var jn=[`restart`,`upgrade`],Mn=[`running`,`ready`,`failed`,`rolled-back`],Nn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Pn=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function Fn(e){let t=L(e,96,!0);if(!Pn.test(t))throw new F(`invalid`);return t}function In(e){let t=W(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:K(t.id),action:V(t.action,jn),from:Fn(t.from),to:t.to===null?null:Fn(t.to),state:V(t.state,Mn),reason:t.reason===null?null:V(t.reason,Nn),version:t.version===null?null:Fn(t.version),at:z(t.at,0),endedAt:t.endedAt===null?null:z(t.endedAt,0)}}var Ln=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Rn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function zn(e){let t=W(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=W(t.unit,[`name`,`scope`]);n={name:L(e.name,96,!0),scope:V(e.scope,[`user`,`system`])}}return{kind:H(t.kind,`service`),version:Fn(t.version),unit:n,upgrade:V(t.upgrade,Ln),work:z(t.work,0,1e6),job:t.job===null?null:In(t.job)}}function Bn(e){let t=W(e,[`kind`,`version`,`deprecated`]);return{kind:H(t.kind,`release`),version:Fn(t.version),deprecated:B(t.deprecated)}}function Vn(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}var Hn=Object.freeze({chunkChars:262144,idleMs:6e5}),Un=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Wn(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Gn(e,t){if(!Un.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
|
|
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,l as s,n as c,o as l,r as u,s as d,t as f,u as p}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 m=e(n(),1),h=t(),g={"Design choices":`设计选项`,"Use all recommendations":`采用全部推荐`,"Plan identity":`计划标识`,Questions:`问题`,Recommended:`推荐`,Acceptance:`验收`,"Other idea":`其他想法`,"Use this answer":`采用这项回答`,"Design submitted":`设计已提交`,"Submit design and use recommendations for unanswered questions":`整批提交,未回答的问题采用推荐项`,"Thinking activity observed":`已观察到思考活动`,"Thinking activity ended":`思考活动已结束`,"Thinking content unavailable":`思考内容不可用`,"Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.":`不传输思考正文;可读取的思考内容落盘后可展开查看。`,"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The provider said: {reason}":`供应商返回:{reason}`,"The model request failed after automatic recovery or was not retryable. Partial work is preserved; no workflow step was replayed.":`模型请求在自动恢复后仍失败,或该错误不可重试。已有工作已保留,未重放工作流步骤。`,"The model request failed and automatic retries did not recover it.":`模型请求失败,自动重试后仍未恢复。`,"Partial work is preserved.":`已有工作已保留。`,"Refresh models":`刷新模型列表`,"The connection changed. Your model choice and draft are kept; send again when ready.":`连接状态已变化,模型选择和草稿已保留,请就绪后重新发送。`,"Used for your next new conversation after choosing a folder.":`选择工作目录后,用于下一个新会话。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.":`尚未配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供商,然后重新读取列表。`,"Choose now; the model is verified when you send.":`现在选择模型,发送时验证可用性。`,"Validate the plan with this model before approving it.":`请先使用此模型重新核验计划,再确认实施。`,"Restore execution and validate plan":`恢复执行服务并核验计划`,"Validate plan again":`重新核验计划`,"Validating plan…":`正在核验计划…`,"Confirm implementation":`确认实施`,"Previous execution context":`核验前的执行上下文`,"Preparing execution and validating the plan; no implementation is approved.":`正在准备执行服务并核验计划;尚未批准任何实施。`,"Reading the validated plan…":`正在读取核验后的计划…`,"The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.":`计划内容未变,已重新核验执行上下文。请查看下方当前计划后确认实施;尚未批准任何实施。`,"Repository or execution-environment evidence changed. Review the current context before confirming.":`仓库或执行环境的核验证据已变化,请查看当前上下文后再确认。`,"Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.":`核验可能启动执行服务并应用界面中选择的模型,但不会发送聊天消息或实施计划;核验后仍需确认。`,"Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.":`计划核验未完成({code})。未批准任何实施;请读取当前计划后再决定是否重新核验。`,"Preparing execution…":`正在准备执行环境…`,"Checking execution state…":`正在确认执行状态…`,"Execution state unavailable":`执行状态暂时无法确认`,"Model list unavailable":`模型目录读取失败`,"Last used: {model}":`上次使用:{model}`,"Last used model; availability is checked when you send.":`上次使用的模型,发送时会验证其可用性。`,"Execution is being prepared for your Send. Models will load when it is ready.":`正在为本次发送准备执行环境,就绪后会加载模型。`,"The model list changed. Read the current list before choosing again.":`模型列表已变化,请读取当前列表后再选择。`,"The choice was not confirmed. Read the current model before choosing again.":`模型选择结果尚未确认,请读取当前模型后再决定是否重新选择。`,"Recorded history could not be read.":`暂时无法读取历史证据。`,"Reading recorded history…":`正在读取历史证据…`,"The context changed ({code}). Read the current state before trying this action again.":`上下文已变化({code})。请先读取当前状态,再决定是否重新操作。`,"Observation status":`状态读取`,"Latest state unavailable.":`当前无法获取最新状态。`,"Started work may still be running. No message is resent.":`已开始的工作可能仍在运行,不会重发消息。`,"Diagnostic details":`诊断详情`,"Viewer observation: {code}.":`页面状态读取:{code}。`,"Context changed. Read the current state before confirming a plan.":`上下文已变化,请先读取当前状态,再确认计划。`,"Toggle conversation navigation":`展开或收起会话导航`,"Toggle workspace panels":`展开或收起辅助面板`,"Conversation navigation":`会话导航`,"Conversation history could not be read. This is not an empty history.":`暂时无法读取会话历史,这不代表没有历史记录。`,"Model selection is unavailable until the current conversation and execution state are observed.":`读取当前会话和执行状态后才能选择模型。`,"Cadence state unavailable":`Cadence 状态未确认`,"Cadence on next Send":`下次发送开启 Cadence`,"Cadence off":`Cadence 已关闭`,"Read the current execution state before approving this plan.":`请先读取当前执行状态,再批准此计划。`,"Wait for the current reply before approving this plan.":`请等待当前回复结束,再批准此计划。`,"Observing plan approval…":`正在确认计划审批结果…`,"Observing approval request {id}; no approval is replayed.":`正在查询审批请求 {id} 的结果;不会重放审批。`,"Read the current conversation context before approving this plan.":`请先读取当前会话上下文,再批准此计划。`,"Conversation folder:":`会话目录:`,"Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.":`尚未读取到会话内容。可以先编辑草稿,上下文可用前不会发送。`,"The last Send is not yet confirmed. No message is resent.":`上次发送的结果尚未确认,不会重发消息。`,"Sending…":`正在发送…`,"Sending is unavailable until the current context is observed. Your draft stays here.":`读取当前上下文后才能发送,草稿会保留在这里。`,"Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.":`会话状态尚未更新。页面可能显示之前读取的内容,这不表示工作已停止。`,"Not observed":`未读取`,"Turns in this conversation: {count}":`本会话轮次:{count}`,"Context {used} / {window} · {percent}%":`上下文 {used} / {window} · {percent}%`,"Context {used} tokens":`上下文 {used} tokens`,"Context unknown after compaction":`压缩后上下文大小未知`,"Context window in use":`上下文窗口占用`,"Context size not observed yet":`尚未读取到上下文大小`,"No completed model response is within reach of this branch's end, so no context size is stated.":`这条分支末尾附近还没有完成的模型回复,因此没有上下文大小。`,"Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).":`网络延迟:{ms}ms(最近一分钟内到服务最快的一次请求,从发出到收到回复首字节)。`,"Cache hit":`缓存命中`,"Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)":`缓存命中:{rate} · 缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)`,"Summed over every usage record of this session, on every branch.":`按本会话全部用量记录累计,包含所有分支。`,"Cache hit: this session's usage records state no input tokens yet.":`缓存命中:本会话的用量记录里还没有输入 token。`,"Context size as of the last completed model response ({model}). Messages after that response are not counted.":`上下文大小以最近一次完成的模型回复({model})为准,不包含那次回复之后的消息。`,"A compaction followed that response, so the size is unknown until the next one.":`那次回复之后做过压缩,下一次模型回复完成前无法得知大小。`,"The model list states no context window for this model, so no percentage is shown.":`模型列表没有给出这个模型的上下文窗口,因此不显示占比。`,Working:`工作中`,"Collapse panel":`收起面板`,"About this panel":`面板说明`,"No matching files":`没有匹配的文件`,"Tool call in progress":`工具调用进行中`,"Tool result recorded":`已记录工具结果`,"Tool error recorded":`已记录工具错误`,"No tool result observed":`未观察到工具结果`,"Show arguments and output":`查看参数与输出`,"Nothing more is recorded for this call.":`此调用没有更多记录。`,Output:`输出`,"Error output":`错误输出`,"Files appear once this folder has been observed.":`读取到该目录的状态后即可浏览文件。`,"The conversation folder has not been observed.":`尚未读取到当前会话目录。`,"Reading files…":`正在读取文件…`,"Plan approval is currently unavailable.":`当前无法批准此计划。`,"Running work":`正在进行的工作`,"History configuration differs. Activity remains observe-only.":`历史读取配置不同。此活动仅供观察。`,"Discovered session":`发现的会话`,"Active Pi work":`Pi 活动工作`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.":`执行服务已准备就绪,但发送前无法读取会话。请查看恢复的上下文后再次发送;本次消息尚未发送。`,"Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.":`当前无法读取会话上下文。点击发送可准备执行服务,但在确认上下文之前不会提交此草稿。`,"Choose a working folder to see its conversation history.":`选择工作目录后,即可查看它的历史会话。`,"Choose a working folder; its files become available when execution is prepared.":`选择工作目录;执行服务就绪后即可浏览文件。`,"Choose working folder":`选择工作目录`,"Use this folder":`使用此目录`,"Selecting folder…":`正在选择目录…`,"Choose a folder…":`选择目录…`,"Choose a working folder":`选择工作文件夹`,"Choose a working folder to start. You can write a draft below.":`选择工作文件夹即可开始,也可以先在下方写草稿。`,"Write a message. Choose a folder before sending…":`输入消息,发送前请选择文件夹…`,"Choose a folder before sending.":`发送前请选择文件夹。`,"Returning to your last folder {path}…":`正在返回上次的文件夹 {path}…`,"Could not restore {path}. Choose a folder to continue; nothing was started.":`无法恢复 {path},请选择文件夹以继续;没有启动任何服务。`,"Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.":`选择服务所在主机上的文件夹。会话保留在原文件夹中,运行中的工作不受影响;仅在发送消息时按需启动执行服务。`,"Connecting…":`正在连接…`,"Ready to prepare execution":`可按需准备执行服务`,"Preparing execution for this Send…":`正在为本次发送准备执行服务…`,"Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.":`准备结果未知({code});执行服务可能已启动。消息尚未发送,草稿已保留。`,"Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.":`执行服务准备被拒绝,未产生任何变更({code})。本次未启动执行服务;消息尚未发送,草稿已保留。`,"Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.":`执行服务准备已确认,但消息尚未发送({code})。草稿已保留。`,"The message was not accepted ({code}). Its draft is kept.":`消息未被接受({code})。草稿已保留。`,"Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.":`发送结果未知({code})。再次发送前请观察原命令的结果;不会自动重试。`,"Project observation: {code}.":`项目观察:{code}。`,"Project readiness unknown":`项目准备状态未知`,"Project observation stale":`项目观察已过期`,"Viewer observation stale":`当前页面观察已过期`,"Viewer observation unavailable":`当前页面观察不可用`,"Viewer disconnected":`当前页面已断开`,"Execution service: {status}":`执行服务:{status}`,"Last observed: {count} active runs":`上次观察:{count} 个活动运行`,"not-started":`尚未启动`,"Execution is stopped. Conversation history remains readable; open this folder to send a new message.":`执行服务已停止。仍可查看历史会话;发送新消息前请打开此目录。`,"Execution stopped · history only":`执行已停止 · 仅查看历史`,"Newer conversations":`较新的会话`,"Latest conversations":`最近会话`,"Reading conversation history…":`正在读取会话历史…`,"Older conversations":`更早的会话`,"Conversation activity unavailable.":`当前无法读取会话运行状态。`,"Files / history":`文件 / 历史`,"Files and history drawer":`文件与历史面板`,History:`历史`,"History details":`历史详情`,"History is readonly. Start new work in a conversation with /cadence.":`历史记录只读。请在对话中通过 /cadence 开始新工作。`,Next:`下一页`,"Cadence research, implementation and review agents appear here.":`Cadence 的调研、实施和审查代理会显示在这里。`,"Subagent context":`子代理上下文`,"Open subagent context":`打开子代理上下文`,"Back to conversation":`返回对话`,Back:`返回`,Workflow:`工作流`,"Step result":`步骤结果`,"No result yet.":`暂无结果。`,"The latest turn's outcome is unknown. Approval waits until it is observed.":`最新一轮的结果未知。需要先观察到结果才能批准。`,"Cadence control state for this conversation is missing, incomplete or unreadable. No mode, plan or run is inferred and nothing was repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话的 Cadence 控制状态缺失、不完整或无法读取。系统不会推断模式、计划或运行,也没有做任何修复。请新建会话;保留这些状态以便本地诊断。`,"The last Cadence message of this conversation was not durably recorded. Its plan is not approvable and nothing was replayed or repaired. Start a new conversation; preserve this state for local diagnosis.":`此会话最后一条 Cadence 消息没有被持久记录。它的计划不可批准,系统没有重放或修复任何内容。请新建会话;保留这些状态以便本地诊断。`,"No plan is awaiting approval.":`当前没有等待批准的计划。`,"Cadence state unavailable. Observe the conversation before sending.":`暂时无法获取 Cadence 状态。请先刷新观察会话再发送。`,"No retained transcript observed yet; absence is not proof of no activity.":`暂未观察到保留记录;这不代表没有活动。`,"Tools and checks run on the service host, not in a sandbox.":`工具和检查直接在服务主机运行,不是安全沙箱。`,Discussing:`对话中`,"Awaiting plan approval":`等待批准计划`,"Cadence conversation":`Cadence 对话`,"Cadence on":`Cadence 已开启`,"Exit Cadence":`退出 Cadence`,"Message, or /cadence to enter continuous Cadence mode…":`输入消息,或输入 /cadence 进入持续 Cadence 模式…`,"Cadence on Send":`发送时进入 Cadence`,"Cadence stays on. Confirm one plan before implementation.":`Cadence 将持续开启。确认一次计划后开始实施。`,"Cadence workflow":`Cadence 工作流`,"Current implementation plan":`当前实施计划`,"Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.":`批准覆盖本目标及其决定、验收标准和假设。之后由服务自行完成:它可以在仓库内调整路线和写入范围;对验收的任何偏离都会记录下来,交给自动审查确认,并在最终报告中置顶。不包含推送、发布或部署。`,"Implement this plan":`按此计划实施`,"To change the plan, continue the conversation. A changed plan requires fresh approval.":`需要修改计划时继续对话。计划变更后需要重新批准。`,"Cadence stays on for this conversation until you explicitly exit.":`本对话将持续使用 Cadence,直到你明确退出。`,"Workflow progress":`工作流进度`,"Open workflow details":`打开工作流详情`,Stop:`停止`,researching:`调研中`,"merged {commit}":`合并 {commit}`,"{s}s":`{s} 秒`,"{m}m {s}s":`{m} 分 {s} 秒`,"{h}h {m}m":`{h} 小时 {m} 分`,"Observing workflow":`正在观察工作流`,"State unavailable is not completion. No automatic resubmission.":`状态不可用不代表已经完成。不会自动重新提交。`,"Actual local merge commit:":`实际本地合并提交:`,"Agent review is not human review. Worktrees and retained results are preserved.":`Agent 审查不是人工审阅。工作树和保留结果不会自动清理。`,"Exit code":`退出码`,"Preview is truncated.":`预览已截断。`,"Read retained step result":`读取保留的步骤结果`,"Cancel workflow — request stop":`取消工作流 — 请求停止`,"Workflow activity unavailable; retained work may still be running.":`工作流状态不可用;已接受的工作可能仍在运行。`,"Cadence is off. Accepted work continues; exit does not cancel it.":`Cadence 模式已关闭。已接受的工作继续执行;退出不会取消执行。`,"Incomplete work is not replayed. A new explicit message may continue from the last complete checkpoint.":`不会重放未完成工作。明确发送新消息后,可从上一次完整上下文继续。`,implementing:`实施中`,verifying:`验证中`,reviewing:`审查中`,integrating:`集成中`,finished:`已结束`,implementation:`实施`,git:`Git`,"Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.":`另一个 Cadence 进程正在更新项目注册表,请稍后再试;如果一直这样,请在服务所在主机运行 cadence doctor。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"This folder is unavailable. Choose another folder; nothing was moved or recreated.":`此文件夹不可用,请选择其他文件夹;没有移动或重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"The machine restarted while Cadence was running. Cadence recovered automatically.":`Cadence 运行期间机器重启过,已自动恢复。`,"Cadence ended unexpectedly last time. It recovered automatically.":`Cadence 上次意外退出,已自动恢复。`,"Cadence ran into a problem and restarted itself.":`Cadence 遇到问题,已自动重启。`,"Cadence repaired some incomplete files automatically.":`Cadence 已自动修复部分不完整的文件。`,"Work that was running is marked as interrupted; start it again when you are ready.":`当时正在运行的工作已标记为“已中断”,需要时可重新开始。`,"Released the previous run's locks.":`已释放上次运行留下的锁。`,"Stopped {count} leftover worker processes.":`已停止 {count} 个残留的工作进程。`,"Stopped the unresponsive previous process.":`已停止无响应的旧进程。`,"History continues after the last complete entry.":`历史记录从最后一条完整记录之后继续。`,"Unreadable history was archived and a new one was started.":`无法读取的历史记录已归档,并已新建历史记录。`,"Damaged state was archived; it started afresh.":`损坏的状态已归档,已重新开始。`,"Rebuilt the project registry.":`已重建项目注册表。`,"Set aside interrupted temporary files.":`已移走中断时留下的临时文件。`,"Archived files are kept for 30 days; cadence doctor shows where.":`归档文件保留 30 天,可用 cadence doctor 查看位置。`,"Folder {name}":`文件夹 {name}`,"Project registry":`项目注册表`,"Hide details":`收起详情`,Dismiss:`知道了`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Waiting messages":`等待中的消息`,"Steering: read at the model's next step":`插队:模型下一步就会读到`,"Queued: sent when this reply ends":`排队:这条回复结束后发送`,Withdraw:`撤回`,"Withdraw and put back in the message box":`撤回并放回输入框`,"Not delivered.":`未送达。`,"Not delivered: the reply ended before this message reached the model. Nothing was replayed; send it again.":`未送达:回复在这条消息到达模型之前就结束了。没有任何内容被重放;需要的话请重新发送。`,"Not observed: the session could not be read when the reply ended, so whether this message was delivered was not recorded. Nothing was replayed.":`未观察到:回复结束时会话无法读取,因此没有记录这条消息是否送达。没有任何内容被重放。`,"Put back in the message box":`放回输入框`,"Queue behind this reply":`排在这条回复之后`,"Queue: sent when this reply ends (Alt+Enter)":`排队:这条回复结束后发送(Alt+Enter)`,"Steer this reply":`插队到这条回复`,"Steer: read at the model's next step (Enter)":`插队:模型下一步就会读到(Enter)`,"Enter steers this reply · Alt+Enter queues behind it":`Enter 插队 · Alt+Enter 排队`,"The running reply did not take the message ({reason}). Your text stays here.":`进行中的回复没有接收这条消息({reason})。你的文字仍在输入框里。`,"That message has already been handed to the model and can no longer be withdrawn.":`这条消息已经交给模型,无法再撤回。`,"The message was not withdrawn ({reason}).":`消息没有撤回({reason})。`,"A message into a running reply carries no images. Remove them, or send after the reply ends.":`发给进行中回复的消息不能带图片。请移除图片,或等回复结束后再发送。`,"Cadence mode is not changed by a message into a running reply. Send this after the reply ends.":`发给进行中回复的消息不会切换 Cadence 模式。请等回复结束后再发送。`,"Eight messages already wait for this reply. Withdraw one, or wait.":`已有 8 条消息在等这条回复。请撤回一条,或稍等。`,"A message into a running reply continues that reply, not another entry.":`发给进行中回复的消息只能接在这条回复上,不能接到别的位置。`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Latest messages":`最新消息`,"Reading this conversation…":`正在读取对话…`,"Reading earlier messages…":`正在读取更早的消息…`,"Reading the rest of this message…":`正在读取这条消息的其余部分…`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,Subagents:`子代理`,"{active} active · {total} total":`{active} 个进行中 · 共 {total} 个`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Download file {path}":`下载文件 {path}`,"Reference path only: {path} (the agent reads it on demand)":`仅引用路径 {path}(AI 按需读取)`,"Link folder path {path} to the chat":`链接文件夹路径 {path} 到对话`,"Copy name {path}":`复制名称 {path}`,"Copy path {path}":`复制路径 {path}`,"Download of {path} failed: {error}":`{path} 下载失败:{error}`,"the file is larger than the 64 MiB download limit":`文件超过 64 MiB 的下载上限`,"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 · a download is the file's own bytes, unredacted":`只读预览 · 引用只发送路径,不自动注入文件内容 · 下载的是文件原始字节,不做脱敏`,"Working steps":`工作过程`,"Working…":`处理中…`,Thought:`已思考`,"Media not retained":`媒体内容未保留`,"Content not retained":`内容未保留`,"Thinking that could not be read is not shown.":`无法读取的思考内容不显示。`,"Show thinking":`展开思考内容`,"Thinking still being recorded":`思考内容仍在记录中`,"No thinking text is recorded for this block.":`这段思考没有记录文本。`,"Media is not retained.":`媒体内容不保留。`,"Other content is not retained.":`其他类型的内容不保留。`,"Read 1 file":`读取 1 个文件`,"Read {n} files":`读取 {n} 个文件`,"Listed 1 directory":`列出 1 个目录`,"Listed {n} directories":`列出 {n} 个目录`,"Searched once":`搜索 1 次`,"Searched {n} times":`搜索 {n} 次`,"Ran 1 command":`运行 1 条命令`,"Ran {n} commands":`运行 {n} 条命令`,"Edited 1 file":`修改 1 个文件`,"Edited {n} files":`修改 {n} 个文件`,"Used 1 tool":`调用 1 次工具`,"Used {n} tools":`调用 {n} 次工具`,"{n} failed":`{n} 个失败`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent folders":`最近文件夹`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Link copied.":`链接已复制。`,"Dismiss notification":`关闭通知`,"Theme: {current}. Switch to {next}.":`主题:{current}。点击切换为{next}。`,System:`跟随系统`,Light:`浅色`,Dark:`深色`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"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.":`观察不可用。`,"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; reopen the picker 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; reopen the picker after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后重新打开模型选择器。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"Attempts shown: {partial} partial · {blocked} blocked · {failed} failed":`当前显示的尝试:{partial} 项部分完成 · {blocked} 项受阻 · {failed} 项失败`,"Partial or blocked assignments preserve work; they are not process failures or delivery approval.":`部分完成或受阻的任务保留已有成果,不代表进程故障,也不代表交付通过。`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,superseded:`已被取代`,rejected:`已拒绝`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`,Off:`关闭`,Minimal:`最低`,Low:`低`,Medium:`中`,High:`高`,"Extra high":`极高`,Max:`最大`,"A reply or workflow is still running in this project. Switch models after it finishes.":`此项目中还有回复或工作流正在运行,结束后再切换模型。`,"This model's credentials are unavailable. Check auth.json or the provider's API key.":`此模型的凭据不可用,请检查 auth.json 或提供方的 API key。`,"This model or thinking level is not supported.":`不支持此模型或思考级别。`,"Choose a model":`选择模型`,"Model: {model}":`模型:{model}`,"Switch models after the current reply finishes.":`当前回复结束后才能切换模型。`,"Last used model; it is used again when you send.":`上次使用的模型,发送时会再次启用。`,"Choose a model; your message is sent right after.":`选择模型后会立即发送你的消息。`,"Search models":`搜索模型`,"Search models…":`搜索模型…`,Models:`模型列表`,"Reading models…":`正在读取模型…`,"Credentials unavailable":`凭据不可用`,"Not supported":`不支持`,"Used when you send":`发送时启用`,"No matching models.":`没有匹配的模型。`,"No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重新打开模型选择器。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`包管理器会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade now":`立即升级`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},_=r(),v=`cadence-locale`,y=new Map(Object.entries(g));function b(e,t,n){let r=e===`zh`?y.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var x={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function S(e,t){let n=Object.hasOwn(x,t)?x[t]:void 0;return n?e(n,{code:t}):t}function C({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,_.jsx)(m.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function w(){try{let e=localStorage.getItem(v);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 T(e,t){return{locale:e,t:(t,n)=>b(e,t,n),tx:t=>b(e,t),setLocale:t}}var E=(0,m.createContext)(T(`en`,()=>{}));function D(){return(0,m.useContext)(E)}function O({initial:e,children:t}){let[n,r]=(0,m.useState)(()=>e??w()),i=(0,m.useMemo)(()=>T(n,e=>{try{localStorage.setItem(v,e)}catch{}r(e)}),[n]);return(0,m.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=b(n,`Cadence task workspace`)},[n]),(0,_.jsx)(E.Provider,{value:i,children:t})}var k=`cadence-theme`,A=[`system`,`light`,`dark`],ee=e=>e===`light`||e===`dark`;function j(){try{let e=localStorage.getItem(k);if(ee(e))return e}catch{}return`system`}function te(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function M(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return ee(e)?e:`system`}function ne(e){try{e===`system`?localStorage.removeItem(k):localStorage.setItem(k,e)}catch{}te(e)}var N=e=>A[(A.indexOf(e)+1)%A.length],re=`cadence-graph/2`,ie=`cadence-public-export/2`,P=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,cookieLifetimeMs:31536e6,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,coordinatorBytes:393216,chunkBytes:8192,detailBytes:33554432,dataFrames:1e5,controlFrames:256,captureEntries:4096,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,episodes:8,childReservations:2,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),ae=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`retired-conversation`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],F=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function oe(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function I(){throw new F}function L(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&I(),R(e)>t)throw new F(`oversize`);return e}function R(e){return new TextEncoder().encode(e).length}function z(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&I(),e}function B(e){return typeof e!=`boolean`&&I(),e}function V(e,t){return(typeof e!=`string`||!t.includes(e))&&I(),e}function H(e,t){return e!==t&&I(),t}function U(e,t){return e===null?null:t(e)}function W(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&I();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&I();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&I(),r[n]=t.value}return r}function G(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&I();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&I(),r.push(n(i.value))}return r}function K(e){let t=L(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)||I(),t}function q(e){let t=L(e,64);return/^[0-9a-f]{64}$/.test(t)||I(),t}function se(e){let t=L(e,P.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||I(),t}function ce(e,t){return se(e),se(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function le(e){let t=L(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||I(),t}function J(e,t=P.controlBytes){let n=t,r=e=>{if(n-=R(e),n<0)throw new F(`oversize`);return e};function i(e,n){if(n>64&&I(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return L(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||I(),r(JSON.stringify(e));if(Array.isArray(e)){let a=G(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`)&&I();let a=t.sort(),o=W(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 I()}return i(e,0)}function ue(e,t=P.controlBytes){L(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 L(JSON.parse(e.slice(r,n)),t)}catch{return I()}i=!i&&a===`\\`}return I()}function a(t){if(t>64&&I(),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]!==`"`&&I(),d=i(),u.has(d)&&I(),u.add(d),r(),e[n++]!==`:`&&I());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&I()}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||I(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&I(),s}let o=a(0);return r(),n!==e.length&&I(),o}function Y(e){let t=W(e,[`code`,`effect`,`recovery`]);return{code:V(t.code,ae),effect:V(t.effect,[`none`,`accepted`,`uncertain`]),recovery:V(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var de=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],fe=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],pe=[`not-launched`,`direct-child-closed`,`unconfirmed`],me=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],he=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function ge(e){let t=W(e,[`provider`,`model`,`api`,`thinking`]);return{provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:V(t.api,me),thinking:V(t.thinking,he)}}function _e(e){let{sourceSelectionId:t,...n}=W(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:K(t),...ge(n)}}function ve(e){let t=W(e,[`role`,`sha256`]);return{role:V(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:q(t.sha256)}}function ye(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function be(e){let t=W(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:K(t.recordId),version:z(t.version,1),field:V(t.field,de),bytes:z(t.bytes,0,P.detailBytes),sha256:q(t.sha256)}}function xe(e){let t=W(e,[`start`,`end`]),n=z(t.start);return{start:n,end:z(t.end,n+1,P.detailBytes)}}function Se(e){let t=W(e,[`source`,`range`,`requireCompleteObservation`]),n=Ce(t.source),r;if(n===`current`)r={kind:n,assignmentId:le(W(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=W(t.source,[`kind`,`runId`,`childRunId`,`result`]);H(n,`historical`);let i=be(e.result);H(i.field,`final-text`),r={kind:`historical`,runId:K(e.runId),childRunId:K(e.childRunId),result:i}}let i=U(t.range,xe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&I(),{source:r,range:i,requireCompleteObservation:B(t.requireCompleteObservation)}}function Ce(e,t=`kind`){(typeof e!=`object`||!e)&&I();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&I(),L(n.value,64,!0)}function we(e){J(e,P.graphBytes);let t=W(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=be(t.plan);H(n.field,`plan`);let r=z(t.planRevision,1);n.version!==r&&I();let i={schema:H(t.schema,re),taskId:K(t.taskId),taskKind:V(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:z(t.taskRevision,1),revision:z(t.revision,1),planRevision:r,plan:n,assignments:G(t.assignments,P.assignments,e=>{let t=W(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:le(t.id),purpose:V(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:L(t.instructions,P.instructionsBytes,!0),expectedOutput:L(t.expectedOutput,P.expectedOutputBytes,!0),role:ve(t.role),model:_e(t.model),dependencies:G(t.dependencies,P.assignments,Se)}})};i.assignments.length||I();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&I();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&I(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=J(n.source);if(t.has(e)&&I(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||I(),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!==ye(e.purpose))throw new F(`forbidden`);c(e)}return i}function Te(e){let t=W(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=U(t.graphRevision,e=>z(e,1)),r=U(t.graphIdentity,q);return n===null!=(r===null)&&I(),{id:K(t.id),kind:V(t.kind,[`code`,`research`,`diagnosis`]),revision:z(t.revision,1),identity:q(t.identity),graphRevision:n,graphIdentity:r}}function Ee(e){let t=W(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=W(t.observation,[`identity`,`complete`]);return{epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),configRev:z(t.configRev,1),controlRev:z(t.controlRev,1),workspaceId:K(t.workspaceId),cwdId:K(t.cwdId),model:_e(t.model),checkEnvGeneration:z(t.checkEnvGeneration,1),checkoutGeneration:z(t.checkoutGeneration),observation:{identity:q(n.identity),complete:B(n.complete)},task:U(t.task,Te)}}function De(e){let t=W(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:V(t.kind,[`configured`,`manual`]),name:L(t.name,128,!0),command:L(t.command,4096,!0),timeoutMs:z(t.timeoutMs,100,12e5)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&I(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&I(),n}function Oe(e){switch(J(e),Ce(e)){case`create`:{let t=W(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:V(t.taskKind,[`code`,`research`,`diagnosis`]),goal:L(t.goal,8192,!0)}}case`save-plan`:{let t=W(e,[`kind`,`taskId`,`plan`,`graph`]),n=we(t.graph),r=K(t.taskId);return n.taskId!==r&&I(),{kind:`save-plan`,taskId:r,plan:L(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:Ce(e),taskId:K(W(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=W(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:K(t.taskId),check:De(t.check)}}case`review`:{let t=W(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:K(t.taskId),runId:K(t.runId),changesIdentity:q(t.changesIdentity),checksRevision:z(t.checksRevision),acceptIssues:B(t.acceptIssues)}}default:return I()}}function ke(e){J(e);let t=W(e,[`expected`,`action`]);return{expected:Ee(t.expected),action:Oe(t.action)}}function Ae(e){J(e);let t=W(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:K(t.commandId),grant:K(t.grant),expected:Ee(t.expected),action:Oe(t.action)}}function je(e){if(J(e),Ce(e)===`action`){let t=W(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:Ee(t.expected),action:Oe(t.action)}}let t=W(e,[`kind`,`epoch`,`runId`]);return H(t.kind,`cancel`),{kind:`cancel`,epoch:K(t.epoch),runId:K(t.runId)}}function Me(e){let t=W(e,[`commandId`,`epoch`,`runId`]);return{commandId:K(t.commandId),epoch:K(t.epoch),runId:K(t.runId)}}function Ne(e){J(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=W(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=G(n.configuredChecks,32,De);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&I(),{...t?{checkEnvironmentPolicy:H(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:z(n.checksRevision),reviewRunId:U(n.reviewRunId,K),version:Ee(n.version),action:Oe(n.action),rootLabel:L(n.rootLabel,4096,!0),cwdLabel:L(n.cwdLabel,4096,!0),readablePlan:L(n.readablePlan,32768),graph:U(n.graph,we),activeRunId:U(n.activeRunId,K),issues:G(n.issues,7,e=>V(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Pe(e){J(e);let t=W(e,[`grant`,`expiresAt`,`preview`]),n=L(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)&&I(),{grant:K(t.grant),expiresAt:n,preview:Ne(t.preview)}}function Fe(e){let t=W(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:V(t.observed,[`complete`,`incomplete`]),source:V(t.source,[`complete`,`limited`,`unavailable`]),redacted:B(t.redacted),omissions:G(t.omissions,6,e=>V(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`))&&I(),n}function Ie(e){let t=W(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:z(t.graphRevision,1),inputs:G(t.inputs,P.assignments,e=>{let t=W(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=be(t.result);H(i.field,`final-text`);let a=U(t.range,xe);a&&a.end>i.bytes&&I();let o=L(t.text,P.predecessorBytes);if(n+=R(o),n>P.handoffBytes)throw new F(`oversize`);let s=z(t.dependencyIndex,0,P.assignments-1);return r.has(s)&&I(),r.add(s),R(o)!==(a?a.end-a.start:i.bytes)&&I(),{assignmentId:le(t.assignmentId),dependencyIndex:s,runId:K(t.runId),childRunId:K(t.childRunId),result:i,range:a,text:o,coverage:Fe(t.coverage)}})}}function Le(e){let t=W(e,[`source`,`reason`,`target`]);return{source:V(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:L(t.reason,128,!0),target:L(t.target,128,!0)}}function Re(e){let t=W(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Le(t.stop)},outcome:V(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:V(t.closure,pe),exitCode:U(t.exitCode,e=>z(e,-2147483648,4294967295)),signal:U(t.signal,e=>L(e,32,!0)),durationMs:z(t.durationMs),stdin:V(t.stdin,[`delivered`,`failed`,`not-required`]),final:V(t.final,[`valid`,`missing`,`invalid`]),cleanup:V(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Fe(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&I(),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`)&&I(),n}function ze(e){let t=W(e,[`kind`,`id`]);return{kind:V(t.kind,[`task`,`run`,`child`]),id:K(t.id)}}function Be(e){let t=L(e,P.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||I(),t}function Ve(e){J(e);let t=W(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:K(t.storeId),scope:ze(t.scope),query:U(t.query,e=>{let t=L(e,P.queryBytes);return t.length||I(),t}),snapshotSeq:se(t.snapshotSeq),recordId:U(t.recordId,K),recordVersion:U(t.recordVersion,e=>z(e,1)),field:U(t.field,e=>V(e,de)),offset:z(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&I(),n}function He(e){let t=W(e,[`disposition`,`value`]),n=V(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Ke(t.value);return n===`observed`!=(r!==null)&&I(),{disposition:n,value:r}}function X(e){let t=W(e,[`messageId`,`blockId`]);return{messageId:K(t.messageId),blockId:K(t.blockId)}}function Ue(e){let t=Ce(e);if(t===`message-final`)return{kind:t,messageId:K(W(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:V(W(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=W(e,[`kind`,`dependencyIndex`,`source`]),r=be(n.source);return H(r.field,`final-text`),{kind:t,dependencyIndex:z(n.dependencyIndex,0,P.assignments-1),source:r}}if(t===`message`){let n=W(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:K(n.messageId),blockId:K(n.blockId),index:z(n.index,0,P.dataFrames),stage:V(n.stage,[`stream`,`final`])}}let n=W(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return H(t,`tool`),{kind:`tool`,callId:K(n.callId),blockId:K(n.blockId),index:z(n.index,0,P.dataFrames),stage:V(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function We(e){let t=W(e,[`owner`,`field`,`encoding`]),n=Ue(t.owner),r=V(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=V(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`))&&I(),{owner:n,field:r,encoding:i}}function Ge(e){let t=W(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=V(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=V(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=U(t.mimeType,e=>L(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)))&&I(),{owner:Ue(t.owner),sourceType:n,mimeType:i,reason:r}}function Ke(e){if(e===null)return null;let t=L(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||I(),t}function qe(e){let t=W(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`,...Object.hasOwn(e??{},`reason`)?[`reason`]:[]]),n=z(t.maxAttempts,1),r={phase:V(t.phase,[`waiting`,`requesting`]),attempt:z(t.attempt,1,n),maxAttempts:n,delayMs:z(t.delayMs,0,2147483647),...t.reason===void 0?{}:{reason:L(t.reason,256,!0)}};if(r.phase===`requesting`&&r.delayMs!==0)throw new F(`invalid`);return r}function Je(e){let t=Ce(e);switch(t){case`ready`:{let n=W(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:H(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=W(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:q(e.workerHash)}})()}}}case`message-start`:{let n=W(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=V(n.role,[`user`,`assistant`,`tool-result`]),i=U(n.resultCallId,K);return r!==`tool-result`&&i!==null&&I(),{kind:t,messageId:K(n.messageId),role:r,source:He(n.source),resultCallId:i}}case`thinking-activity`:{let n=W(e,[`kind`,`messageId`,`index`,`phase`]);return{kind:t,messageId:K(n.messageId),index:z(n.index,0,P.dataFrames),phase:V(n.phase,[`active`,`complete`,`unavailable`])}}case`message-text`:{let n=W(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...X({messageId:n.messageId,blockId:n.blockId}),detailId:K(n.detailId)}}case`message-end`:{let n=W(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:K(n.messageId),finalDetailId:U(n.finalDetailId,K),finalBlockCount:z(n.finalBlockCount,0,P.dataFrames),stopReason:V(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=W(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:K(n.callId),declaration:X(n.declaration),index:z(n.index,0,P.dataFrames),source:He(n.source),name:L(n.name,128,!0),argsDetailId:U(n.argsDetailId,K),stage:V(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=W(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:K(n.callId),declaration:U(n.declaration,X),source:He(n.source),name:L(n.name,128,!0),argsDetailId:U(n.argsDetailId,K)}}case`tool-update`:{let n=W(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:K(n.callId),detailId:K(n.detailId),semantics:H(n.semantics,`snapshot`)}}case`tool-end`:{let n=W(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=V(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=U(n.declaration,X),a=B(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&I(),{kind:t,callId:K(n.callId),declaration:i,source:He(n.source),name:L(n.name,128,!0),resultDetailId:K(n.resultDetailId),isError:B(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Ge(W(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=W(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:K(n.detailId),descriptor:We(n.descriptor)}}case`detail-chunk`:{let n=W(e,[`kind`,`detailId`,`offset`,`text`]),r=L(n.text,P.chunkBytes),i=z(n.offset,0,P.detailBytes);return i+R(r)>P.detailBytes&&I(),{kind:t,detailId:K(n.detailId),offset:i,text:r}}case`detail-end`:{let n=W(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:K(n.detailId),bytes:z(n.bytes,0,P.detailBytes),sha256:q(n.sha256),coverage:Fe(n.coverage)}}case`model-retry`:return{kind:t,progress:U(W(e,[`kind`,`progress`]).progress,qe)};case`capture-status`:return{kind:t,coverage:Fe(W(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:V(W(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=W(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:K(n.messageId),detailId:K(n.detailId),stopReason:H(n.stopReason,`stop`)}}default:return I()}}function Z(e){let t=W(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Le(t.stop)},outcome:V(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:V(t.closure,pe),exitCode:U(t.exitCode,e=>z(e,-2147483648,4294967295)),signal:U(t.signal,e=>L(e,32,!0)),durationMs:z(t.durationMs),stdin:H(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))&&I(),n}function Ye(e){let t=W(e,[`messageId`,`detailId`]);return{messageId:K(t.messageId),detailId:K(t.detailId)}}function Xe(e){let t=W(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=se(t.committedSeq);return n===`0`&&I(),{childRunId:K(t.childRunId),detailId:K(t.detailId),content:be(t.content),committedSeq:n}}function Ze(e){let t=Ce(e,`status`);if(t===`committed`){let n=W(e,[`status`,`selected`,`detail`]),r=Ye(n.selected),i=Xe(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&I(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=W(e,[`status`,`selected`,`error`]);return{status:t,selected:U(n.selected,Ye),error:Y(n.error)}}let n=W(e,[`status`,`selected`]);return{status:V(t,[`pending`,`uncertain`]),selected:U(n.selected,Ye)}}function Qe(e,t){let n=U(e,se);return(n===`0`||n!==null&&t.status===`committed`&&ce(n,t.detail.committedSeq)<0)&&I(),n}function $e(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function et(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?$e(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function tt(e){let t=Ce(e);if(t===`sdk`){let n=W(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ze(n.recording),i=Qe(n.settlementSeq,r);return{kind:t,native:Re(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=W(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=U(n.settlementSeq,se);return r===`0`&&I(),{kind:t,native:Z(n.native),capture:Fe(n.capture),settlementSeq:r}}let n=W(e,[`kind`,`outcome`,`required`]);H(t,`parent`);let r=G(n.required,P.assignments,e=>{let t=W(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=K(t.childRunId),r=Ze(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&I(),{assignmentId:le(t.assignmentId),childRunId:n,native:U(t.native,Re),recording:r,settlementSeq:Qe(t.settlementSeq,r)}}),i=V(n.outcome,fe);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($e))&&I(),{kind:`parent`,outcome:i,required:r}}function nt(e){let t=W(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=z(t.first,1,2**53-1),r=z(t.last,n,2**53-1),i=z(t.firstObservedMs),a=z(t.lastObservedMs,i);return n===r&&i!==a&&I(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function rt(e){let t=W(e,[`source`,`event`]),n=nt(t.source),r=Ce(t.event);if(r===`stored-chunk`){let e=W(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:K(e.detailId),text:L(e.text,P.chunkBytes)}}}if(r===`stored-end`){let e=W(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:K(e.detailId),coverage:Fe(e.coverage)}}}let i=Je(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&I(),{source:n,event:i}}function it(e){let t=W(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:K(t.epoch),taskId:K(t.taskId),runId:K(t.runId),childRunId:K(t.childRunId)}}function at(e){J({kind:`ok`,value:e},P.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=W(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:K(n.storeId),workspaceId:K(n.workspaceId),epoch:K(n.epoch)};if(!t)return H(n.status,`unavailable`),{...r,status:`unavailable`,error:ot(n.error)};let i=G(n.runs,P.episodes,e=>{let t=W(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:K(t.taskId),runId:K(t.runId),operationId:K(t.operationId),epoch:K(t.epoch),kind:V(t.kind,[`start`,`generate-plan`,`check`]),stage:V(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)&&I(),{...r,status:`complete`,runs:i}}function ot(e){let t=Y(e);return H(t.effect,`none`),t}function st(e){let t=W(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:q(t.sourceHash),contractHash:q(t.contractHash),buildId:q(t.buildId)}}function ct(e){let t=V(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=W(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:q(n.contractHash)}:{kind:t,...st({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function lt(e){let t=W(e,[`contractHash`,`assets`]);return{contractHash:q(t.contractHash),assets:st(t.assets)}}function ut(e){J(e);let t=W(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:K(t.commandId),operationId:K(t.operationId),runId:U(t.runId,K),admission:V(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:se(t.committedSeq),execution:U(t.execution,e=>V(e,fe)),settlement:U(t.settlement,tt),created:U(t.created,e=>{let t=W(e,[`kind`,`taskId`,`state`]);return{kind:H(t.kind,`task`),taskId:K(t.taskId),state:V(t.state,[`reserved`,`published`])}}),publication:V(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&&et(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&I(),n}function dt(e){J(e);let t=W(e,[`identity`,`receipt`]),n=je(t.identity),r=ut(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&I();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&I(),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`))&&I()}return{identity:n,receipt:r}}function Q(e,t){if(Ce(e)===`ok`)return{kind:`ok`,value:t(W(e,[`kind`,`value`]).value)};let n=W(e,[`kind`,`error`]);return H(n.kind,`error`),{kind:`error`,error:Y(n.error)}}function ft(e){switch(J(e),Ce(e,`status`)){case`found`:return{status:`found`,receipt:ut(W(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:se(W(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:Y(W(e,[`status`,`error`]).error)};default:return I()}}function pt(e){let t=W(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:K(t.runId),taskId:K(t.taskId),childRunId:U(t.childRunId,K),assignmentId:U(t.assignmentId,le),admission:Ct(t.admission),lifecycle:V(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:U(t.outcome,e=>V(e,fe)),settlement:U(t.settlement,tt),reason:U(t.reason,e=>V(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:V(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Fe(t.coverage),result:U(t.result,be)};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`&&J(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==J(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&J(n.result)!==J(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&&et(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||et(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&I(),n}function mt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function ht(e,t,n){return mt(e,t)&&e.taskId===Et(n)&&e.admission.context.workspaceId===Tt(n)}function gt(e){J(e,P.pageBytes);let t=W(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:H(t.protocol,1),storeId:K(t.storeId),epoch:K(t.epoch),scope:ze(t.scope),committedSeq:se(t.committedSeq),context:wt(t.context),runs:G(t.runs,P.maxPageEntries,pt),horizon:Rt(t.horizon)};return(!Dt(n.context,n.epoch,n.scope)||J(n.horizon.historicalRuns.scope)!==J(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!ht(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&I(),n}function _t(e){J(e,P.pageBytes);let t=Ce(e),n=W(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:K(n.storeId),epoch:K(n.epoch),scope:ze(n.scope),committedSeq:se(n.committedSeq)};if(t===`update`){let e=se(n.previousSeq);ce(r.committedSeq,e)<=0&&I();let i=wt(n.context);Dt(i,r.epoch,r.scope)||I();let a=G(n.runs,P.maxPageEntries,pt),o=G(n.removed,P.maxPageEntries,K),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!ht(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&I(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return H(t,`heartbeat`),{kind:`heartbeat`,...r}}function vt(e){let{navigation:t,...n}=e;return n}function yt(e,t){(!t.navigation||t.navigation===e.navigation||J(vt(e))!==J(vt(t)))&&I()}function bt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return xt(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`cursor`,`next`,`coverage`]),n=Ve(t.cursor),r=Ve(t.next);return yt(n,r),{kind:`progress`,cursor:n,next:r,coverage:Fe(t.coverage)}}function xt(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Ve(t.cursor),content:be(t.content),range:U(t.range,xe),text:L(t.text,P.detailPageBytes),next:U(t.next,Ve),coverage:Fe(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!==R(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&I(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&I(),n.next&&(n.next.offset!==n.range?.end||J(vt({...n.next,offset:n.cursor.offset}))!==J(vt(n.cursor)))&&I(),n}function St(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`cursor`,`hits`,`next`,`coverage`]),n=Ve(t.cursor);n.query||I();let r=R(n.query),i=G(t.hits,P.maxPageEntries,e=>{let t=W(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=be(t.content),a=At(t.owner);jt(a,n.scope)||I();let o=xe(t.range),s=Ve(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||J(s.scope)!==J(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&I(),{content:i,owner:a,range:o,preview:L(t.preview,P.previewBytes),cursor:s}}),a=U(t.next,Ve);return a&&(a.storeId!==n.storeId||J(a.scope)!==J(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)))&&I(),{cursor:n,hits:i,next:a,coverage:Fe(t.coverage)}}function Ct(e){let t=W(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=Ee(t.context),r=U(t.graph,e=>{let t=W(e,[`recordId`,`revision`,`sha256`]);return{recordId:K(t.recordId),revision:z(t.revision,1),sha256:q(t.sha256)}}),i=V(t.kind,[`start`,`generate-plan`,`check`]),a=G(t.assignments,P.assignments,e=>{let t=W(e,[`assignmentId`,`childRunId`]);return{assignmentId:le(t.assignmentId),childRunId:K(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)&&I(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&I(),{operationId:K(t.operationId),commandId:K(t.commandId),kind:i,context:n,assignments:a,graph:r}}function wt(e){if(Ce(e,`status`)===`available`)return{status:`available`,version:Ee(W(e,[`status`,`version`]).version)};let t=W(e,[`status`,`workspaceId`,`taskId`,`error`]);H(t.status,`unavailable`);let n=Y(t.error);return H(n.effect,`none`),{status:`unavailable`,workspaceId:K(t.workspaceId),taskId:U(t.taskId,K),error:n}}function Tt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Et(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Dt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Et(e)===n.id)}function Ot(e){let t=W(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=W(t.capabilities,[`actions`,`manualChecks`,`history`]),r=V(t.authority,[`browser`,`local`]),i=U(t.csrf,K),a={actions:B(n.actions),manualChecks:B(n.manualChecks),history:B(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&I(),{...t.build===void 0?{}:{build:lt(t.build)},protocol:H(t.protocol,1),storeId:K(t.storeId),epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function kt(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:at(t.activeRuns)},workspaceId:K(t.workspaceId),storeId:K(t.storeId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),rootLabel:L(t.rootLabel,4096,!0),context:wt(t.context),models:G(t.models,P.maxPageEntries,_e)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&I(),(Tt(n.context)!==n.workspaceId||Et(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&I(),n}function At(e){let t=W(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=W(t.entity,[`kind`,`id`,`version`]),r={taskId:K(t.taskId),runId:U(t.runId,K),childRunId:U(t.childRunId,K),entity:{kind:V(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:K(n.id),version:z(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)&&I(),r}function jt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Mt(e){let t=W(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:q(t.identity),complete:B(t.complete),checkoutGeneration:z(t.checkoutGeneration)}}function Nt(e){J(e,P.controlBytes);let t=Ce(e);switch(t){case`assignment-state`:{let n=W(e,[`kind`,`childRunId`,`state`,`reason`]),r=V(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=U(n.reason,e=>V(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&I(),(r===`ready`||r===`preparing`)&&i!==null&&I(),{kind:t,childRunId:K(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:V(W(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=W(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:K(n.runId),identity:Ct(n.identity)}}case`parent-settled`:{let n=W(e,[`kind`,`runId`,`settlement`]),r=tt(n.settlement);return r.kind!==`parent`&&I(),{kind:t,runId:K(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=W(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:K(r.reservationId)}:{},lane:V(r.lane,[`reader`,`writer`,`check`]),state:V(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:z(r.checkoutGeneration)}}case`handoff`:{let n=W(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:K(n.childRunId),handoff:Ie(n.handoff),observation:Mt(n.observation)}}case`changes`:{let n=W(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=be(n.content);return H(r.field,`changes`),{kind:t,observationId:K(n.observationId),stage:V(n.stage,[`before`,`after`,`review`]),observation:Mt(n.observation),content:r}}case`check-start`:{let n=W(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:K(n.checkId),selection:De(n.selection),cwdId:K(n.cwdId),cwdLabel:L(n.cwdLabel,4096,!0),checkEnvGeneration:z(n.checkEnvGeneration,1),before:Mt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=W(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=W(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:K(e.operationId),reservationId:K(e.reservationId),from:z(e.from),to:z(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&I()}let a=Z(r.native),o=V(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=Mt(r.before),c=Mt(r.after),l=U(r.output,be),u=Fe(r.coverage);return l&&l.field!==`check`&&I(),o===`passed`&&(a.outcome!==`completed`||J({...s,checkoutGeneration:c.checkoutGeneration})!==J(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&I(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&I(),{kind:t,...i?{ownAdvance:i}:{},checkId:K(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=W(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=B(n.acceptIssues),i=V(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=be(n.content);return H(a.field,`review`),i===`reviewed-with-issues`&&!r&&I(),{kind:t,reviewId:K(n.reviewId),runId:K(n.runId),checksRevision:z(n.checksRevision),changesIdentity:q(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=W(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=z(n.expectedRevision),i=U(n.expectedIdentity,q),a=z(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&I(),{kind:t,publicationId:K(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:q(n.nextIdentity)}}case`publication-settled`:{let n=W(e,[`kind`,`publicationId`,`status`,`observed`]),r=V(n.status,[`published`,`conflict`,`uncertain`]),i=U(n.observed,e=>{let t=W(e,[`revision`,`identity`]);return{revision:z(t.revision,1),identity:q(t.identity)}});return r===`published`&&i===null&&I(),{kind:t,publicationId:K(n.publicationId),status:r,observed:i}}default:return I()}}function Pt(e){let t=W(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:K(t.epoch),operationId:K(t.operationId),taskId:K(t.taskId),runId:U(t.runId,K)}}function Ft(e){J(e,P.ownerQueueBytes);let t=W(e,[`observedMs`,`link`,`events`]),n=Pt(t.link),r=G(t.events,P.ownerQueueFrames,e=>{let t=Ce(e);if(t===`fact`){let r=Nt(W(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)&&I(),{kind:t,fact:r}}if(t===`content-begin`){let r=W(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=At(r.owner),a=V(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))&&I(),{kind:t,detailId:K(r.detailId),owner:i,field:a,encoding:H(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=W(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:K(n.detailId),text:L(n.text,P.chunkBytes)}}let r=W(e,[`kind`,`detailId`,`coverage`]);return H(t,`content-end`),{kind:`content-end`,detailId:K(r.detailId),coverage:Fe(r.coverage)}});return{observedMs:z(t.observedMs),link:n,events:r}}var It=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Lt(e){let t=W(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=V(t.reader,It),r=W(t.scope,[`kind`,`id`]),i={kind:V(r.kind,[`workspace`,`task`,`run`,`child`]),id:K(r.id)},a=U(t.snapshotSeq,se),o=U(t.after,e=>{let t=W(e,[`recordId`,`version`,`offset`]);return{recordId:K(t.recordId),version:z(t.version,1),offset:z(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&I(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:i,snapshotSeq:a,after:o,limit:z(t.limit,1,P.maxPageEntries)}}function Rt(e){let t=W(e,[`policy`,`historicalRuns`]),n=Lt(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&I(),{policy:H(t.policy,`active-and-recent`),historicalRuns:n}}function zt(e){let t=Ce(e);if(t===`run`)return{kind:t,projection:pt(W(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=W(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=se(n.committedSeq);return r===`0`&&I(),{kind:t,recordId:K(n.recordId),committedSeq:r,link:it(n.link),capture:rt(n.capture)}}if(t===`owner-fact`){let n=W(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Ft({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&I();let a=se(n.committedSeq);return a===`0`&&I(),{kind:t,recordId:K(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=W(e,[...n,...r]),a=At(i.owner),o=z(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&I(),t===`task`){let e=U(i.plan,be);return e&&e.field!==`plan`&&I(),{kind:t,owner:a,version:o,goal:L(i.goal,8192,!0),plan:e}}if(t===`message`){let e=V(i.role,[`user`,`assistant`,`tool-result`]),n=V(i.state,[`partial`,`final`]),r=U(i.finalBlockCount,e=>z(e,0,P.dataFrames)),s=U(i.finalText,be),c=U(i.resultCallId,K);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&I(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:He(i.source)}}if(t===`tool`){let e=U(i.declaration,X),n=U(i.declarationStage,e=>V(e,[`partial`,`final`])),r=B(i.startObserved),s=U(i.result,e=>{let t=Je(e);return t.kind!==`tool-end`&&I(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||J(s.declaration)!==J(e)))&&I(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:He(i.source),name:L(i.name,128,!0)}}if(t===`content`){let e=We(i.descriptor),n=be(i.content);return(e.field!==n.field||!Bt(e.owner,a))&&I(),{kind:t,owner:a,version:o,detailId:K(i.detailId),descriptor:e,content:n,coverage:Fe(i.coverage)}}H(t,`omitted`);let s=Ge(i.block);return Bt(s.owner,a)||I(),{kind:`omitted`,owner:a,version:o,block:s}}function Bt(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function Vt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function Ht(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`records`,`next`,`coverage`]),n=Lt(t.request);n.snapshotSeq===null&&I();let r=G(t.records,n.limit,zt),i=U(t.next,Lt);return(r.some(e=>!Vt(e,n))||i&&(i.after===null||J(vt({...i,after:n.after}))!==J(vt(n))||J(i.after)===J(n.after)))&&I(),{request:n,records:r,next:i,coverage:Fe(t.coverage)}}function Ut(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||J(vt({...r,snapshotSeq:null}))!==J(vt(n)))&&I(),{kind:`snapshot`,request:n,next:r,coverage:Fe(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ht(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Lt(t.request),r=Lt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}function Wt(e,t){return J({...t.request,snapshotSeq:e.snapshotSeq})===J(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Gt(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=W(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),graph:{recordId:K(n.recordId),revision:z(n.revision,1),sha256:q(n.sha256)}}}function Kt(e){J({kind:`ok`,value:e});let t=W(e,[`request`,`graph`]),n=Gt(t.request),r=we(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&I(),{request:n,graph:r}}function qt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Kt(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=Gt(t.request),r=Gt(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}function Jt(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),format:V(t.format,[`ndjson`,`markdown`])}}function Yt(e){J(e,P.controlBytes);let t=W(e,[`exportId`,`ordinal`,`event`]),n=Ce(t.event),r;switch(n){case`manifest`:{let e=W(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=W(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:q(i.exporterBuildSha256),capturePolicy:H(i.capturePolicy,`public-text-tools/2`)},schema:H(e.schema,ie),request:Jt(e.request),coverage:Fe(e.coverage),serviceProtocol:H(e.serviceProtocol,1),workerProtocol:H(e.workerProtocol,2)};break}case`record`:r={kind:n,record:zt(W(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Kt(W(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=W(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=be(e.content),a=U(e.range,xe),o=L(e.text,P.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==R(o):i.bytes!==0||o!==``)&&I(),r={kind:n,owner:At(e.owner),content:i,range:a,text:o,coverage:Fe(e.coverage)};break}case`markdown`:r={kind:n,text:L(W(t.event,[`kind`,`text`]).text,P.detailPageBytes)};break;case`trailer`:{let e=W(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Fe(e.coverage),a=B(e.complete);a&&i.observed!==`complete`&&I(),r={kind:n,complete:a,frames:z(e.frames,1),encodedBytes:z(e.encodedBytes),sha256:q(e.sha256),committedSeq:se(e.committedSeq),coverage:i};break}default:return I()}return{exportId:K(t.exportId),ordinal:z(t.ordinal,1),event:r}}function Xt(e,t){let n=Yt(e);return t===`ndjson`?`${J(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&I(),`\n\n\`\`\`json\n${J(n)}\n\`\`\`\n`)}var Zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Jt(e)}receive(e){let t=Yt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&I(),this.ordinal===0?(n.kind!==`manifest`||J(n.request)!==J(this.request))&&I():n.kind===`manifest`&&I(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&I(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&I(),this.request.format===`ndjson`&&n.kind===`markdown`&&I(),n.kind===`detail`&&!jt(n.owner,this.request.scope)&&I(),n.kind===`graph`&&(J(n.graph.request.scope)!==J(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&I(),n.kind===`record`&&!Qt(n.record,this.request.scope)&&I(),this.bytes+=R(Xt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Qt(e,t){return e.kind===`run`?mt(e.projection,t):e.kind===`owner-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`&&e.link.runId===t.id:e.kind===`capture-fact`?t.kind===`task`?e.link.taskId===t.id:t.kind===`run`?e.link.runId===t.id:e.link.childRunId===t.id:jt(e.owner,t)}function $t(e){let t=W(e,[`taskId`,`revision`,`definitions`]),n=G(t.definitions,32,e=>{let t=W(e,[`selection`,`status`,`checkId`]),n=De(t.selection),r=V(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=U(t.checkId,K);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&I(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&I(),{taskId:K(t.taskId),revision:z(t.revision),definitions:n}}function en(e){let t=W(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Be(t.navigation)}:{},storeId:K(t.storeId),scope:ze(t.scope),snapshotSeq:se(t.snapshotSeq),kind:V(t.kind,[`task`,`message`,`tool`]),id:K(t.id),version:z(t.version,1)}}function tn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`record`]),n=en(t.request),r=zt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!jt(r.owner,n.scope))&&I(),{request:n,record:r}}function nn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return tn(e);J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`kind`,`request`,`next`,`coverage`]),n=en(t.request),r=en(t.next);return yt(n,r),{kind:`progress`,request:n,next:r,coverage:Fe(t.coverage)}}var rn=e=>{let t=Y(e);return H(t.effect,`none`),t};function an(e){let t=W(e,[`storeId`,`taskId`]);return{storeId:K(t.storeId),taskId:U(t.taskId,K)}}function on(e){let t=an(e);return t.taskId===null&&I(),t}function sn(e){let t=W(e,[`id`,`kind`,`revision`,`identity`]);return{id:K(t.id),kind:V(t.kind,[`code`,`research`,`diagnosis`]),revision:z(t.revision,1),identity:q(t.identity)}}function cn(e){let t=G(e,3,ve);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&I(),t}function ln(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return W(e,[`status`]),{status:t};if(t===`saved`){let n=W(e,[`status`,`request`,`planRevision`]);return{status:t,request:Gt(n.request),planRevision:z(n.planRevision,1)}}let n=W(e,[`status`,`error`]);return H(n.status,`unavailable`),{status:`unavailable`,error:rn(n.error)}}function un(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Tt(e.context)!==e.workspaceId||Et(e.context)!==e.request.taskId)&&I(),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))&&I()}}function dn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:an(t.request),workspaceId:K(t.workspaceId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),context:wt(t.context),task:U(t.task,sn),roles:cn(t.roles),savedGraph:ln(t.savedGraph),readablePlan:U(t.readablePlan,e=>{let t=W(e,[`source`,`text`,`editable`,`coverage`]),n=Fe(t.coverage),r=B(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&I(),{source:H(t.source,`current-v1`),text:L(t.text,32768),editable:r,coverage:n}})};un(n),!!n.task!=!!n.readablePlan&&I();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))&&I(),r.status===`unavailable`&&n.context.status===`available`&&I(),n}function fn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=W(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:on(t.request),workspaceId:K(t.workspaceId),epoch:K(t.epoch),committedSeq:se(t.committedSeq),context:wt(t.context),task:sn(t.task),observation:{identity:q(n.identity),complete:B(n.complete),checkoutGeneration:z(n.checkoutGeneration,0)},text:L(t.text,131072),git:B(t.git),coverage:Fe(t.coverage)};if(un(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&I()}return r}function pn(e){let t=L(e,128,!0);return/^[A-Za-z0-9](?:[A-Za-z0-9._-]*[A-Za-z0-9])?$/.test(t)||I(),t}function mn(e){let t=W(e,[`id`,`cwd`]);return{id:pn(t.id),cwd:L(t.cwd,4096,!0)}}function hn(e){let t=W(e,[`id`,`cwd`,`revision`,`model`]);return{id:pn(t.id),cwd:L(t.cwd,4096,!0),revision:z(t.revision,0,2**53-1-1),model:U(t.model,ge)}}function gn(e){let t=W(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:L(t.cwd,4096,!0),checkoutRoot:L(t.checkoutRoot,4096,!0),version:_n(t.version),model:U(t.model,_e)}}function _n(e){let t=W(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:mn(t.conversation)},epoch:K(t.epoch),accessGeneration:z(t.accessGeneration,1),configRev:z(t.configRev,1),catalogId:K(t.catalogId)}}function vn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`version`,`selected`]);return{version:_n(t.version),selected:U(t.selected,_e)}}function yn(e){J(e);let t=W(e,[`expected`,`choice`]);return{expected:_n(t.expected),choice:ge(t.choice)}}function bn(e){let t=W(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:B(t.images)},...t.contextWindow===void 0?{}:{contextWindow:z(t.contextWindow,1)},provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:U(t.api,e=>V(e,me)),thinking:G(t.thinking,7,e=>{let t=W(e,[`level`,`selectable`]);return{level:V(t.level,he),selectable:B(t.selectable)}}),eligibility:V(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))&&I(),n}function xn(e,t){return e.some(e=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking.some(e=>e.selectable&&e.level===t.thinking))}function Sn(e){J({kind:`ok`,value:e},P.pageBytes);let t=W(e,[`status`,`entries`,`withheld`,`remembered`]),n=G(t.entries,P.maxPageEntries,bn),r=U(t.remembered,ge),i=V(t.status,[`complete`,`capacity`]),a=z(t.withheld,0,P.maxPageEntries);return(i===`capacity`&&(n.length||a)||n.length+a>P.maxPageEntries||new Set(n.map(e=>J([e.provider,e.model]))).size!==n.length||r&&!xn(n,r))&&I(),{status:i,entries:n,withheld:a,remembered:r}}function Cn(e){let{version:t,selected:n,...r}=W(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return J({kind:`ok`,value:e},P.pageBytes),{...Sn(r),version:_n(t),selected:U(n,_e)}}function wn(e){let t=W(e,[`id`,`path`,`cwd`,`epoch`]);return{id:q(t.id),path:L(t.path,4096,!0),cwd:L(t.cwd,4096,!0),epoch:t.epoch===null?null:K(t.epoch)}}function Tn(e){let t=W(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:H(t.kind,`project-observation`),status:V(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:K(t.epoch),workspaceId:t.workspaceId===null?null:K(t.workspaceId)}}var En=[`registry`,`workbench`,`project`],Dn=[`reboot`,`crash`,`restart`,`storage`],On=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function kn(e){let t=W(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:K(t.id),at:z(t.at,0),scope:V(t.scope,En),path:t.path===null?null:L(t.path,4096,!0),cause:V(t.cause,Dn),actions:G(t.actions,On.length,e=>V(e,On)),workers:z(t.workers,0,1e6),archived:B(t.archived)}}function An(e){let t=W(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:H(t.kind,`workbench`),epoch:K(t.epoch),csrf:K(t.csrf),home:L(t.home,4096,!0),projects:G(t.projects,128,wn),recoveries:G(t.recoveries,20,kn),build:lt(t.build)}}var jn=[`restart`,`upgrade`],Mn=[`running`,`ready`,`failed`,`rolled-back`],Nn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Pn=/^(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})\.(?:0|[1-9][0-9]{0,8})(?:-[0-9A-Za-z.-]{1,64})?$/;function Fn(e){let t=L(e,96,!0);if(!Pn.test(t))throw new F(`invalid`);return t}function In(e){let t=W(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:K(t.id),action:V(t.action,jn),from:Fn(t.from),to:t.to===null?null:Fn(t.to),state:V(t.state,Mn),reason:t.reason===null?null:V(t.reason,Nn),version:t.version===null?null:Fn(t.version),at:z(t.at,0),endedAt:t.endedAt===null?null:z(t.endedAt,0)}}var Ln=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function Rn(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function zn(e){let t=W(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=W(t.unit,[`name`,`scope`]);n={name:L(e.name,96,!0),scope:V(e.scope,[`user`,`system`])}}return{kind:H(t.kind,`service`),version:Fn(t.version),unit:n,upgrade:V(t.upgrade,Ln),work:z(t.work,0,1e6),job:t.job===null?null:In(t.job)}}function Bn(e){let t=W(e,[`kind`,`version`,`deprecated`]);return{kind:H(t.kind,`release`),version:Fn(t.version),deprecated:B(t.deprecated)}}function Vn(e,t){let n=e=>{let[t,n]=e.split(/-(.*)/s);return{core:t.split(`.`).map(Number),pre:n}},r=n(e),i=n(t);for(let e=0;e<3;e++)if(r.core[e]!==i.core[e])return r.core[e]<i.core[e]?-1:1;return r.pre===i.pre?0:r.pre===void 0?1:i.pre===void 0||r.pre<i.pre?-1:1}var Hn=Object.freeze({chunkChars:262144,idleMs:6e5}),Un=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Wn(e){if(typeof e!=`string`||!e.length||e.length%4||!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Invalid image encoding`);let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}function Gn(e,t){if(!Un.includes(t)||!e.length)throw Error(`Unsupported or empty image`);let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=(t,n)=>[...n].every((n,r)=>e[t+r]===n.charCodeAt(0)),i=0,a=0;if(t===`image/png`&&e.length>=33&&e[0]===137&&r(1,`PNG\r
|
|
2
2
|
|
|
3
|
-
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Kn=
|
|
4
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[--]/u.test(e))&&Yn(e,`contains an invisible control character (only newline and tab are accepted)`);return f}function dr(e){return e.documents??e.knowledge??[]}function fr(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...dr(e)])]}function pr(e,t,n){return $n(n,e,16,(e,n)=>{if(Object.hasOwn(e??{},`research`)){let t=er(n,e,[`research`,`reason`]),r=typeof t.research==`string`?nr(t.research):null;return r===null&&Yn(`${n}.research`,`${typeof t.research==`string`?`${Xn(t.research)} `:``}is not an investigation; give the "investigation" value of a completed research step`),{research:r,reason:Qn(`${n}.reason`,t.reason,Kn.reason,!0)}}let r=er(n,e,[`path`,`reason`],[`section`]);return{path:Zn(`${n}.path`,()=>ar(r.path,t)),...r.section===void 0?{}:{section:Qn(`${n}.section`,r.section,256,!0)},reason:Qn(`${n}.reason`,r.reason,Kn.reason,!0)}})}var mr=e=>`# ${e.goal}\n\nInitial route (${e.version===3?`the owner may revise it`:`adapt within the approved boundary`}): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}${e.assumptions?`\n\nAssumptions confirmed with the agreement: ${e.assumptions}`:``}\n\nAcceptance: ${e.acceptance}`;function hr(e){let t=L(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function gr(e){let t=L(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function _r(e){let t=L(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function vr(e){let t=W(e,[`policy`,`target`]),n=W(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:V(t.policy,[`task-branch-v1`]),target:{checkoutRoot:_r(n.checkoutRoot),repository:_r(n.repository),repositoryIdentity:q(n.repositoryIdentity),branch:gr(n.branch),head:hr(n.head)}}}function yr(e){let t=W(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=W(t.integration,[`status`,`before`,`after`,`reason`]),r=W(t.cleanup,[`status`,`reason`]),i=e=>L(e,160,!0),a=U(t.acceptance,e=>{let t=W(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=G(t.checks,Kn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:hr(t.candidate),tree:hr(t.tree),planDigest:q(t.planDigest),contextDigest:q(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:G(t.waived,Kn.checks,i).filter(e=>n.includes(e))}}}),o=U(t.candidate,hr);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=U(t.workspace,e=>{let t=W(e,[`head`,`state`]);return{head:hr(t.head),state:V(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=vr(t.binding),l=gr(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:_r(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:G(t.artifacts,256,e=>{let t=W(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:or(t.id),path:_r(t.path),base:hr(t.base),head:hr(t.head),applied:U(t.applied,hr),state:V(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:V(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:V(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:hr(n.before),after:U(n.after,hr),reason:L(n.reason,2048)},postChecks:V(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:V(r.status,[`pending`,`removed`,`retained`]),reason:L(r.reason,2048)}}}function br(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate. Independent conversations may use separate candidates concurrently.\nAcceptance: checks and automatic Agent review of the exact candidate. A verified, non-overlapping sibling delivery may be merged into the isolated candidate, followed by fresh checks and review.\nDelivery: serialized fast-forward only into the bound target at its approved, verified-sibling or own last confirmed baseline. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function xr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=W(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...Object.hasOwn(e??{},`revalidatedFrom`)?[`revalidatedFrom`]:[],...t?[`display`]:[]]);return{...n.revalidatedFrom===void 0?{}:{revalidatedFrom:K(n.revalidatedFrom)},...n.delivery===void 0?{}:{delivery:vr(n.delivery)},id:K(n.id),epoch:K(n.epoch),digest:q(n.digest),observation:q(n.observation),model:_n(n.model),plan:ur(n.plan),cwd:L(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:L(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=W(n.display,[`model`,`branch`,`baseCommit`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:L(e.runtime,4096,!0)},model:L(e.model,1024,!0),branch:L(e.branch,1024),baseCommit:L(e.baseCommit,64)}})()}:{}}}function Sr(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=W(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=G(n.questions,Kn.questions,e=>L(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:G(n.roots,8,e=>L(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:L(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:_n(n.model)}}if(t===`propose`){let n=W(e,[`action`,`plan`,`model`]);return{action:t,plan:ur(n.plan),model:_n(n.model)}}if(t===`prepare`||t===`execute`){let n=W(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:K(n.proposalId),digest:q(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:K(n.grant)}}let n=W(e,[`action`,`runId`]);return{action:V(n.action,[`cancel`]),runId:K(n.runId)}}function Cr(e){let t=W(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`scope`)?[`scope`]:[],...Object.hasOwn(e??{},`deviations`)?[`deviations`]:[],...Object.hasOwn(e??{},`tasks`)?[`tasks`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>V(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=W(t.verification,[`id`,`source`,`steps`]);return{id:K(e.id),source:q(e.source),steps:G(e.steps,32,e=>L(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:z(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:z(t.revision,0)},...t.scope===void 0?{}:{scope:G(t.scope,1024,e=>ar(e))},...t.deviations===void 0?{}:{deviations:G(t.deviations,16,e=>{let t=W(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:z(t.revision,0),item:L(t.item,2048,!0),reason:L(t.reason,4096,!0),delivered:L(t.delivered,4096,!0),waives:G(t.waives,16,e=>L(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:G(t.tasks,Kn.route,e=>{let t=W(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:or(t.id),title:L(t.title,256,!0),after:G(t.after,Kn.tasks,e=>or(e)),state:V(t.state,qn),...t.revision===void 0?{}:{revision:z(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:yr(t.delivery)},...t.execution===void 0?{}:{execution:gn(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:jr(t.diagnostics)},id:K(t.id),epoch:K(t.epoch),goal:L(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:V(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:L(t.notice,2048),mergedCommit:U(t.mergedCommit,e=>L(e,64,!0)),humanReviewed:!1,steps:G(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=W(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:Ar(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=W(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:q(e.workerHash)}})()},id:L(r.id,160,!0),...t?{childRunId:K(r.childRunId)}:{},kind:V(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:[`implementation`,`knowledge`].includes(r.kind)&&[`partial`,`blocked`].includes(r.status)?V(r.status,[`partial`,`blocked`]):n(r.status),text:L(r.text,65536),exitCode:U(r.exitCode,e=>z(e,-2147483648,2147483647)),truncated:B(r.truncated)}})}}function wr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Cr(W(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:xr(W(e,[`type`,`proposal`]).proposal)};let n=W(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:V(n.type,[`grant`]),proposal:xr(n.proposal),grant:K(n.grant),expiresAt:z(n.expiresAt,0)}}var Tr=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,Er=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function Dr(e){return e.version===3?`After approval the service works to completion without further confirmation. It may on its own: retry and repair a failed assignment; revise the route, the assignments and their order; and bring further repository files into the write scope (never credentials, keys, .env, .git or files outside the repository). When an acceptance item or decision proves impossible it delivers the closest achievable result as a recorded deviation, which names the item, the evidence and what was delivered instead, must be confirmed necessary and minimal by the independent Agent review, and leads the final report. Declared checks always run; a check is set aside only through such a deviation, never silently. At the end it maintains the project's knowledge store under .cadence/ within its fixed budget, adding what this delivery taught and removing what went stale, when a fast-forward can carry it. It stops only for a condition outside the repository: an unavailable model, failed authentication, storage or permission limits, a target branch changed from outside, or a required installation this agreement does not allow. ${e.policy?.installs?`Revisions may add dependency-installation commands with the project's own package manager.`:`No dependency installation beyond the setup commands listed here.`}`:e.version===2?`Retained agreement (readonly): diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`}function Or(e){let t=dr(e);return`# ${e.goal}\n\n## Initial route (the service may revise it)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}${e.version===3?`\n\n## Assumptions (confirmed by approval)\n${e.assumptions||`None beyond the decisions above.`}`:``}\n\n## Tasks\n${cr(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}${e.reads?.length?`\nReads first: ${e.reads.map(Er).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
3
|
+
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Kn=e=>L(e,1024,!0),qn=e=>{let t=L(e,48,!0);if(!/^[a-z][a-z0-9-]*$/u.test(t))throw Error(`id: use lowercase letters, digits and hyphens`);return t};function Jn(e){let{questions:t}=W(e,[`questions`]),n=new Map,r=G(t,12,e=>{let t=W(e,[`id`,`question`,`options`,`recommended`,`reason`,`acceptance`,...Object.hasOwn(e??{},`when`)?[`when`]:[]]),r=qn(t.id),i=G(t.options,6,e=>{let t=W(e,[`id`,`label`,`cost`]);return{id:qn(t.id),label:Kn(t.label),cost:Kn(t.cost)}}),a=new Set(i.map(e=>e.id)),o=qn(t.recommended);if(n.has(r)||a.size!==i.length||a.size<2||!a.has(o))throw Error(`questions: use distinct question and option IDs and identify one recommended option`);let s=t.when===void 0?null:W(t.when,[`question`,`option`]),c=s&&{question:qn(s.question),option:qn(s.option)};if(c&&!n.get(c.question)?.has(c.option))throw Error(`when: name an option of an earlier question`);return n.set(r,a),{id:r,question:Kn(t.question),options:i,recommended:o,reason:Kn(t.reason),acceptance:Kn(t.acceptance),...c?{when:c}:{}}});if(!r.length)throw Error(`questions: supply a material product decision`);return J(r,24576),r}function Yn(e){return G(e,12,e=>{let t=Object.hasOwn(e??{},`other`),n=W(e,[`question`,t?`other`:`option`]),r=qn(n.question);return t?{question:r,other:Kn(n.other)}:{question:r,option:qn(n.option)}})}function Xn(e,t){let n=e.when;return!n||t.some(e=>e.question===n.question&&`option`in e&&e.option===n.option)}function Zn(e,t,n=!1){let r=[],i=new Map(t.map(e=>[e.question,e]));if(i.size!==t.length||t.some(t=>!e.some(e=>e.id===t.question)))throw new F(`invalid`);for(let t of e){if(!Xn(t,r))continue;let e=i.get(t.id);if(e&&`option`in e&&!t.options.some(t=>t.id===e.option))throw new F(`invalid`);e?r.push(e):n&&r.push({question:t.id,option:t.recommended})}return r}function Qn(e){let t=W(e,[`id`,`revision`,`questions`,`answers`,`submitted`]),n=Jn({questions:t.questions}),r=B(t.submitted),i=Yn(t.answers);if(J(Zn(n,i,r))!==J(i))throw new F(`invalid`);return{id:K(t.id),revision:z(t.revision,1),questions:n,answers:i,submitted:r}}function $n(e,t){return t&&(`other`in t?t.other:e.options.find(e=>e.id===t.option)?.label)}function er(e){return e.questions.filter(t=>Xn(t,e.answers)).map(t=>`- ${t.question} — ${$n(t,e.answers.find(e=>e.question===t.id))??`…`}\n Acceptance: ${t.acceptance}`).join(`
|
|
4
|
+
`)}function tr(e,t){let n=er(e);return new TextEncoder().encode(n).length<=t?n:`Submit design ${e.id}, revision ${e.revision}. Read the confirmed decisions in cadence_status and publish the implementation plan.`}function nr(e,t,n){return{...e,revision:e.revision+1,answers:Zn(e.questions,t,n),submitted:n}}var rr={tasks:16,route:48,questions:32,checks:16,bytes:262144,context:32768,reason:1024,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4},ir=[`queued`,`running`,`completed`,`failed`,`superseded`],ar=class extends Error{};function or(e,t){throw new ar(`${e}: ${t}`)}var sr=e=>JSON.stringify(mr(e,80));function cr(e,t){try{return t()}catch(t){if(t instanceof ar)throw t;return or(e,t instanceof F?t.code===`oversize`?`is too long`:`is not valid`:t instanceof Error?t.message:`is not valid`)}}function lr(e,t,n,r=!1){if(t===void 0)return or(e,`is missing`);if(typeof t!=`string`)return or(e,`must be text`);if(r&&!t.trim())return or(e,`must not be empty`);let i=R(t);return i>n?or(e,`is ${i} bytes; at most ${n}`):cr(e,()=>L(t,n,r))}function ur(e,t,n,r){return t===void 0?or(e,`is missing`):Array.isArray(t)?t.length>n?or(e,`has ${t.length} entries; at most ${n}`):cr(e,()=>G(t,n,e=>e)).map((t,n)=>r(t,`${e}[${n}]`)):or(e,`must be a list`)}function dr(e,t,n,r=[]){if(t===void 0)return or(e,`is missing`);if(typeof t!=`object`||!t||Array.isArray(t))return or(e,`must be an object`);let i=Object.keys(t),a=[...n,...r],o=i.filter(e=>!a.includes(e));if(o.length)return or(e,`has no field ${o.map(sr).join(`, `)}; its fields are ${a.join(`, `)}`);let s=n.filter(e=>!i.includes(e));return s.length?or(e,`is missing ${s.join(`, `)}`):cr(e,()=>W(t,a.filter(e=>i.includes(e))))}var fr=/^(?:research-[0-9]{1,4}-)?([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})$/u;function pr(e){return fr.exec(e)?.[1]??null}function mr(e,t){if(e.length<=t)return e;let n=e.charCodeAt(t-1);return e.slice(0,n>=55296&&n<=56319?t-1:t)}function hr(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function gr(e,t=!1){let n=L(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(`is not a plain path inside the repository (relative, forward slashes, no . or .. segment, no colon, not .git or .env)`);return n}var _r=(e,t=!1)=>{let n=L(e,64,!0);if(!/^[a-z][a-z0-9-]*$/u.test(n)||t&&n.length>48)throw Error(`is not an assignment id (lowercase letters, digits and hyphens, starting with a letter, at most 48 characters)`);return n};function vr(e,t=`check`){let n=dr(t,e,[`name`,`command`],[`timeoutMs`]);return{name:lr(`${t}.name`,n.name,128,!0),command:lr(`${t}.command`,n.command,4096,!0),...n.timeoutMs===void 0?{}:{timeoutMs:cr(`${t}.timeoutMs`,()=>{try{return z(n.timeoutMs,100,2147483647)}catch{throw Error(`is a whole number of milliseconds from 100 to 2147483647, or left out for no timeout`)}})}}}function yr(e){let t=new Set,n=[];if(new Set(e.map(e=>e.id)).size!==e.length)throw Error(`an assignment id is used twice`);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(`the after lists name a missing assignment or form a cycle`);n.push(r),t.add(r.id)}return n}function br(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 yr(e),r(t),yr(e).filter(e=>n.has(e.id))}function xr(e,t={}){let n=t.strict===!0,r=Object.hasOwn(e??{},`version`);if(n&&!r)throw Error(`Publish a new delivery agreement; retained fixed-pipeline plans are readonly`);try{J(e,rr.bytes)}catch(e){or(`plan`,e instanceof F&&e.code===`oversize`?`is larger than ${rr.bytes} bytes as a whole`:`is not plain JSON data`)}let i=r?e.version:void 0;if(r&&i!==2&&i!==3)throw Error(`Unsupported delivery agreement version`);let a=i===3;if(n&&!a)throw Error(`Publish a new delivery agreement; earlier agreements are readonly`);let o=dr(`plan`,e,[`goal`,`design`,`decisions`,`acceptance`,...a?[`version`,`assumptions`,`documents`,`reviewReads`,`policy`]:r?[`version`,`knowledge`]:[`projectContext`,`repairAttempts`],`tasks`,`checks`,`setup`,`baselineChecks`,`delivery`]),s=(e,t)=>ur(t,e,16,(e,t)=>cr(t,()=>{let t=gr(e,n);if(!t.endsWith(`.md`))throw Error(`must be a Markdown file (.md)`);return t})),c=ur(`tasks`,o.tasks,rr.tasks,(e,t)=>{let r=dr(t,e,[`id`,`title`,`instructions`,`writes`,`after`,...a?[`reads`]:[]]);return{id:cr(`${t}.id`,()=>_r(r.id,n)),title:lr(`${t}.title`,r.title,256,!0),instructions:lr(`${t}.instructions`,r.instructions,8192,!0),writes:ur(`${t}.writes`,r.writes,128,(e,t)=>cr(t,()=>gr(e,n))),after:ur(`${t}.after`,r.after,rr.tasks,(e,t)=>cr(t,()=>_r(e,n))),...a?{reads:wr(r.reads,n,`${t}.reads`)}:{}}});c.length||or(`tasks`,`needs at least one assignment`);let l=c.map(e=>e.id);for(let[e,t]of c.entries()){let n=`tasks[${e}]`;l.indexOf(t.id)!==e&&or(`${n}.id`,`${sr(t.id)} is already the id of tasks[${l.indexOf(t.id)}]`),t.writes.length||or(`${n}.writes`,`needs at least one path this assignment writes`),new Set(t.writes).size!==t.writes.length&&or(`${n}.writes`,`lists a path twice`),new Set(t.after).size!==t.after.length&&or(`${n}.after`,`lists an assignment twice`);let r=t.after.find(e=>!l.includes(e));r!==void 0&&or(`${n}.after`,`names ${sr(r)}, which is not the id of an assignment in tasks`)}cr(`tasks`,()=>yr(c));for(let e of r?[]:c)for(let t of c)if(!(e.id>=t.id||br(c,e.id).some(e=>e.id===t.id)||br(c,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>hr(t.writes,e))||t.writes.some(t=>hr(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let u=(e,t,n)=>ur(t,e,n,vr),d=u(o.checks,`checks`,rr.checks);d.length||or(`checks`,`needs at least one real verification command`);let f={goal:lr(`goal`,o.goal,8192,!0),design:lr(`design`,o.design,32768,!0),decisions:lr(`decisions`,o.decisions,16384),acceptance:lr(`acceptance`,o.acceptance,16384,!0),...a?{version:3,assumptions:lr(`assumptions`,o.assumptions,16384),documents:s(o.documents,`documents`),reviewReads:wr(o.reviewReads,n,`reviewReads`),policy:{installs:cr(`policy.installs`,()=>{try{return B(dr(`policy`,o.policy,[`installs`]).installs)}catch(e){throw e instanceof ar?e:Error(`must be true or false`)}})}}:r?{version:2,knowledge:s(o.knowledge,`knowledge`)}:{projectContext:lr(`projectContext`,o.projectContext,16384),repairAttempts:cr(`repairAttempts`,()=>z(o.repairAttempts,0,2))},tasks:c,checks:d,setup:ur(`setup`,o.setup,4,(e,t)=>{let{placement:r,...i}=dr(t,e,[`name`,`command`,...n?[`placement`]:[]],[`timeoutMs`,...n?[]:[`placement`]]);return{...vr(i,t),...r===void 0?{}:{placement:cr(`${t}.placement`,()=>V(r,[`target`,`candidate`,`worktree`]))}}}),baselineChecks:u(o.baselineChecks,`baselineChecks`,rr.checks),delivery:cr(`delivery`,()=>{try{return V(o.delivery,[`local-merge`,`working-copy`])}catch{throw Error(`is local-merge or working-copy`)}})},p=R(Tr(f));p>rr.context&&or(`plan`,`goal, design, decisions, assumptions and acceptance are ${p} bytes together (${[`goal`,`design`,`decisions`,`assumptions`,`acceptance`].map(e=>`${e} ${R(f[e]??``)}`).join(`, `)}); together at most ${rr.context}`);let m=R(Cr(f).join(`, `));m>16384&&or(`tasks`,`the write paths of all assignments and documents are ${m} bytes together; at most 16384`);let h=(e,t)=>(e??[]).flatMap((e,n)=>[[`${t}[${n}].reason`,e.reason],[`${t}[${n}].section`,`section`in e?e.section??``:``]]);for(let[e,t]of[[`goal`,f.goal],[`design`,f.design],[`decisions`,f.decisions],[`acceptance`,f.acceptance],[`assumptions`,f.assumptions??``],[`projectContext`,f.projectContext??``],...h(f.reviewReads,`reviewReads`),...f.tasks.flatMap((e,t)=>[[`tasks[${t}].title`,e.title],[`tasks[${t}].instructions`,e.instructions],...h(e.reads,`tasks[${t}].reads`)]),...[`checks`,`setup`,`baselineChecks`].flatMap(e=>f[e].flatMap((t,n)=>[[`${e}[${n}].name`,t.name],[`${e}[${n}].command`,t.command]]))])[...t].some(e=>e.charCodeAt(0)<32&&e!==`
|
|
5
|
+
`&&e!==` `||e.charCodeAt(0)===127||/[--]/u.test(e))&&or(e,`contains an invisible control character (only newline and tab are accepted)`);return f}function Sr(e){return e.documents??e.knowledge??[]}function Cr(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...Sr(e)])]}function wr(e,t,n){return ur(n,e,16,(e,n)=>{if(Object.hasOwn(e??{},`research`)){let t=dr(n,e,[`research`,`reason`]),r=typeof t.research==`string`?pr(t.research):null;return r===null&&or(`${n}.research`,`${typeof t.research==`string`?`${sr(t.research)} `:``}is not an investigation; give the "investigation" value of a completed research step`),{research:r,reason:lr(`${n}.reason`,t.reason,rr.reason,!0)}}let r=dr(n,e,[`path`,`reason`],[`section`]);return{path:cr(`${n}.path`,()=>gr(r.path,t)),...r.section===void 0?{}:{section:lr(`${n}.section`,r.section,256,!0)},reason:lr(`${n}.reason`,r.reason,rr.reason,!0)}})}var Tr=e=>`# ${e.goal}\n\nInitial route (${e.version===3?`the owner may revise it`:`adapt within the approved boundary`}): ${e.design}\n\nExplicit decisions and non-goals: ${e.decisions}${e.assumptions?`\n\nAssumptions confirmed with the agreement: ${e.assumptions}`:``}\n\nAcceptance: ${e.acceptance}`;function Er(e){let t=L(e,64,!0);if(!/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(t))throw Error(`Invalid Git object`);return t}function Dr(e){let t=L(e,1024,!0);if(!t.startsWith(`refs/heads/`)||/[\s~^:?*[\\]/u.test(t)||[...t].some(e=>e.charCodeAt(0)<32||e.charCodeAt(0)===127)||t.includes(`..`)||t.includes(`@{`)||t.split(`/`).some(e=>!e||e.startsWith(`.`)||e.endsWith(`.`)||e.endsWith(`.lock`)))throw Error(`Invalid local ref`);return t}function Or(e){let t=L(e,4096,!0);if(!/^(?:\/|[A-Za-z]:[\\/]|\\\\)/u.test(t)||t.includes(`\0`))throw Error(`Invalid delivery path`);return t}function kr(e){let t=W(e,[`policy`,`target`]),n=W(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:V(t.policy,[`task-branch-v1`]),target:{checkoutRoot:Or(n.checkoutRoot),repository:Or(n.repository),repositoryIdentity:q(n.repositoryIdentity),branch:Dr(n.branch),head:Er(n.head)}}}function Ar(e){let t=W(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=W(t.integration,[`status`,`before`,`after`,`reason`]),r=W(t.cleanup,[`status`,`reason`]),i=e=>L(e,160,!0),a=U(t.acceptance,e=>{let t=W(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=G(t.checks,rr.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:Er(t.candidate),tree:Er(t.tree),planDigest:q(t.planDigest),contextDigest:q(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:G(t.waived,rr.checks,i).filter(e=>n.includes(e))}}}),o=U(t.candidate,Er);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=U(t.workspace,e=>{let t=W(e,[`head`,`state`]);return{head:Er(t.head),state:V(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=kr(t.binding),l=Dr(t.taskBranch);if(!l.startsWith(`refs/heads/cadence/`)||n.status===`applied`&&n.after===null)throw Error(`Inconsistent delivery evidence`);return{binding:c,taskBranch:l,worktreeRoot:Or(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:G(t.artifacts,256,e=>{let t=W(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:_r(t.id),path:Or(t.path),base:Er(t.base),head:Er(t.head),applied:U(t.applied,Er),state:V(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:V(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:V(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:Er(n.before),after:U(n.after,Er),reason:L(n.reason,2048)},postChecks:V(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:V(r.status,[`pending`,`removed`,`retained`]),reason:L(r.reason,2048)}}}function jr(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate. Independent conversations may use separate candidates concurrently.\nAcceptance: checks and automatic Agent review of the exact candidate. A verified, non-overlapping sibling delivery may be merged into the isolated candidate, followed by fresh checks and review.\nDelivery: serialized fast-forward only into the bound target at its approved, verified-sibling or own last confirmed baseline. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function Mr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=W(e,[`id`,`epoch`,`digest`,`observation`,`model`,`plan`,`cwd`,...Object.hasOwn(e??{},`checkoutRoot`)?[`checkoutRoot`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[],...Object.hasOwn(e??{},`revalidatedFrom`)?[`revalidatedFrom`]:[],...t?[`display`]:[]]);return{...n.revalidatedFrom===void 0?{}:{revalidatedFrom:K(n.revalidatedFrom)},...n.delivery===void 0?{}:{delivery:kr(n.delivery)},id:K(n.id),epoch:K(n.epoch),digest:q(n.digest),observation:q(n.observation),model:_n(n.model),plan:xr(n.plan),cwd:L(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:L(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=W(n.display,[`model`,`branch`,`baseCommit`,...Object.hasOwn(n.display??{},`runtime`)?[`runtime`]:[]]);return{...e.runtime===void 0?{}:{runtime:L(e.runtime,4096,!0)},model:L(e.model,1024,!0),branch:L(e.branch,1024),baseCommit:L(e.baseCommit,64)}})()}:{}}}function Nr(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=W(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=G(n.questions,rr.questions,e=>L(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:G(n.roots,8,e=>L(e,4096,!0));if(i&&!i.length)throw Error(`Research needs a specific root`);return{action:t,goal:L(n.goal,8192,!0),questions:r,...i?{roots:i}:{},model:_n(n.model)}}if(t===`propose`){let n=W(e,[`action`,`plan`,`model`]);return{action:t,plan:xr(n.plan),model:_n(n.model)}}if(t===`prepare`||t===`execute`){let n=W(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:K(n.proposalId),digest:q(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:K(n.grant)}}let n=W(e,[`action`,`runId`]);return{action:V(n.action,[`cancel`]),runId:K(n.runId)}}function Pr(e){let t=W(e,[`id`,`epoch`,`goal`,`status`,`phase`,`steps`,`notice`,`mergedCommit`,`humanReviewed`,...Object.hasOwn(e??{},`stepsBefore`)?[`stepsBefore`]:[],...Object.hasOwn(e??{},`revision`)?[`revision`]:[],...Object.hasOwn(e??{},`scope`)?[`scope`]:[],...Object.hasOwn(e??{},`deviations`)?[`deviations`]:[],...Object.hasOwn(e??{},`tasks`)?[`tasks`]:[],...Object.hasOwn(e??{},`verification`)?[`verification`]:[],...Object.hasOwn(e??{},`diagnostics`)?[`diagnostics`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`delivery`)?[`delivery`]:[]]),n=e=>V(e,[`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`]);if(t.humanReviewed!==!1)throw Error(`Automatic execution is not human review`);return{...t.verification===void 0?{}:{verification:(()=>{let e=W(t.verification,[`id`,`source`,`steps`]);return{id:K(e.id),source:q(e.source),steps:G(e.steps,32,e=>L(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:z(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:z(t.revision,0)},...t.scope===void 0?{}:{scope:G(t.scope,1024,e=>gr(e))},...t.deviations===void 0?{}:{deviations:G(t.deviations,16,e=>{let t=W(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:z(t.revision,0),item:L(t.item,2048,!0),reason:L(t.reason,4096,!0),delivered:L(t.delivered,4096,!0),waives:G(t.waives,16,e=>L(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:G(t.tasks,rr.route,e=>{let t=W(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:_r(t.id),title:L(t.title,256,!0),after:G(t.after,rr.tasks,e=>_r(e)),state:V(t.state,ir),...t.revision===void 0?{}:{revision:z(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:Ar(t.delivery)},...t.execution===void 0?{}:{execution:gn(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:Hr(t.diagnostics)},id:K(t.id),epoch:K(t.epoch),goal:L(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:V(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:L(t.notice,2048),mergedCommit:U(t.mergedCommit,e=>L(e,64,!0)),humanReviewed:!1,steps:G(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=W(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:Vr(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=W(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:q(e.workerHash)}})()},id:L(r.id,160,!0),...t?{childRunId:K(r.childRunId)}:{},kind:V(r.kind,[`research`,`implementation`,`diagnosis`,`knowledge`,`review`,`check`,`git`]),status:r.kind===`review`&&r.status===`rejected`?`rejected`:[`implementation`,`knowledge`].includes(r.kind)&&[`partial`,`blocked`].includes(r.status)?V(r.status,[`partial`,`blocked`]):n(r.status),text:L(r.text,65536),exitCode:U(r.exitCode,e=>z(e,-2147483648,2147483647)),truncated:B(r.truncated)}})}}function Fr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:Pr(W(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:Mr(W(e,[`type`,`proposal`]).proposal)};let n=W(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:V(n.type,[`grant`]),proposal:Mr(n.proposal),grant:K(n.grant),expiresAt:z(n.expiresAt,0)}}var Ir=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,Lr=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function Rr(e){return e.version===3?`After approval the service works to completion without further confirmation. It may on its own: retry and repair a failed assignment; revise the route, the assignments and their order; and bring further repository files into the write scope (never credentials, keys, .env, .git or files outside the repository). When an acceptance item or decision proves impossible it delivers the closest achievable result as a recorded deviation, which names the item, the evidence and what was delivered instead, must be confirmed necessary and minimal by the independent Agent review, and leads the final report. Declared checks always run; a check is set aside only through such a deviation, never silently. At the end it maintains the project's knowledge store under .cadence/ within its fixed budget, adding what this delivery taught and removing what went stale, when a fast-forward can carry it. It stops only for a condition outside the repository: an unavailable model, failed authentication, storage or permission limits, a target branch changed from outside, or a required installation this agreement does not allow. ${e.policy?.installs?`Revisions may add dependency-installation commands with the project's own package manager.`:`No dependency installation beyond the setup commands listed here.`}`:e.version===2?`Retained agreement (readonly): diagnosis, partial-work continuation, task splitting and alternative implementations within these goals, decisions, write paths and exact setup/check commands.`:`Historical fixed pipeline: at most ${e.repairAttempts} repair rounds.`}function zr(e){let t=Sr(e);return`# ${e.goal}\n\n## Initial route (the service may revise it)\n${e.design}\n\n## Decisions\n${e.decisions}\n\n## Acceptance\n${e.acceptance}${e.version===3?`\n\n## Assumptions (confirmed by approval)\n${e.assumptions||`None beyond the decisions above.`}`:``}\n\n## Tasks\n${yr(e.tasks).map(e=>`### ${e.id}: ${e.title}\nDepends on: ${e.after.join(`, `)||`none`}\nWrites: ${e.writes.join(`, `)}${e.reads?.length?`\nReads first: ${e.reads.map(Lr).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
5
6
|
|
|
6
|
-
`)}\n\n## Setup (explicitly authorized commands)\nExecution order: target once before worktree creation, candidate once, then worktree in the candidate and every detached child; listed order within each stage. Each command is a separate process; exports do not persist.\n${e.setup.map(e=>`[${e.placement??`worktree`}] ${
|
|
7
|
-
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(
|
|
8
|
-
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(
|
|
9
|
-
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(
|
|
10
|
-
`)}`:``}\n\n## Automation boundary\n${
|
|
11
|
-
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var
|
|
12
|
-
`)}function
|
|
13
|
-
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function Hr(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:Br(e.text,Rr);return{id:e.id,...$r(e),role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?Br(Vr(e.args),zr):``,error:e.error,parts:t}}function Ur(e){let t=W(e,[`id`,`updatedAt`]);return{id:pn(t.id),updatedAt:z(t.updatedAt,0)}}var Wr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Gr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`reload-conversation-models`:case`conversation-models`:return{kind:t,location:mn(W(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=W(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Pr),ordinal:z(n.ordinal,0),before:U(n.before,e=>z(e,0))}}case`conversation-image`:{let n=W(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=z(n.offset,0);if(r%Hn.chunkChars||n.live!==void 0&&n.live!==!0)throw new F(`invalid`);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Pr),...n.live===void 0?{}:{live:!0},entry:Pr(n.entry),index:z(n.index,0),offset:r}}case`conversation-step`:{let n=W(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Pr),turnId:Pr(n.turnId),step:z(n.step,0),part:z(n.part,0)}}case`cadence-conversation`:return{kind:t,id:pn(W(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=W(e,[`kind`,`id`,`leaf`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Pr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=W(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:U(r.after,K),...n?{scan:K(r.scan)}:{}}}case`workflow-active`:return W(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=W(e,[`kind`,`id`,`stepId`]);return{kind:t,id:K(n.id),stepId:L(n.stepId,160,!0)}}case`workflow`:{let n=W(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:K(n.id),...n.before===void 0?{}:{before:z(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=W(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new F(`invalid`);return{kind:t,...n?{after:U(i.after,Ur)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return W(e,[`kind`]),{kind:t};case`conversation`:{let n=W(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Pr),known:U(n.known,Pr)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=W(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=z(r.offset,0);if(i%196608||i>=67108864)throw new F(`invalid`);return{kind:t,path:L(r.path,4096),offset:i,...n?{location:mn(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=W(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:V(r.kind,[`files`,`file`,`directories`]),path:L(r.path,4096),...n?{location:mn(r.location)}:{}}}}}function Kr(e){let t=L(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new F(`invalid`);if([...t].length>100)throw new F(`oversize`);return t}function qr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=W(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:K(n.commandId),location:mn(n.location),expected:_n(n.expected),choice:ge(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=W(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new F(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:K(n.commandId),epoch:K(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:mn(n.location)},...r?{expected:_n(n.expected),choice:ge(n.choice)}:{}}:{kind:t,...i,runId:K(n.runId)}}if(t===`cadence-exit`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:mn(n.location)},commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Pr),revision:z(n.revision,0)}}if(t===`image-upload`){let n=W(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new F(`invalid`);let r=qr(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new F(`invalid`);return{kind:t,commandId:K(n.commandId),imageId:K(n.imageId),send:r,mimeType:V(n.mimeType,Un),size:z(n.size,1),offset:z(n.offset,0),data:L(n.data,Hn.chunkChars,!0)}}if(t===`cadence-send`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Pr),text:L(n.text,Ir),...n.images===void 0?{}:{images:G(n.images,2**53-1,K)},model:_n(n.model),revision:z(n.revision,0),intent:V(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-revalidate`){let n=W(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=pn(n.conversationId),i=hn(n.context);if(i.id!==r)throw new F(`invalid`);return{kind:t,commandId:K(n.commandId),conversationId:r,revision:z(n.revision,0),proposalId:K(n.proposalId),digest:q(n.digest),head:U(n.head,Pr),context:i,expected:_n(n.expected),model:ge(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=W(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:K(r.commandId),conversationId:pn(r.conversationId),revision:z(r.revision,0),proposalId:K(r.proposalId),digest:q(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:K(r.grant)}}if(t===`workflow`){let n=W(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:K(n.commandId),epoch:K(n.epoch),request:Sr(n.request)}}if(t===`send`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Pr),text:L(n.text,Ir),...n.images===void 0?{}:{images:G(n.images,2**53-1,K)},model:_n(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=W(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:K(n.commandId),conversationId:pn(n.conversationId),turnId:K(n.turnId),epoch:K(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:V(n.mode,[`steer`,`queue`]),text:L(n.text,Ir,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:K(n.inputId)}}if(t===`conversation-rename`){let n=W(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),name:Kr(n.name)}}if(t===`conversation-archive`){let n=W(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),archived:B(n.archived)}}let n=W(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:V(n.kind,[`open-project`]),commandId:K(n.commandId),path:L(n.path,4096,!0),epoch:K(n.epoch)}}function Jr(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=W(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?W(i.transcript,[`pages`]):null,o=n?W(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:gn(i.execution)},...i.retry===void 0?{}:{retry:Ke(i.retry)},id:K(i.id),epoch:K(i.epoch),status:V(i.status,Wr),notice:L(i.notice,1024),...a?{transcript:{pages:z(a.pages,0)}}:{},omitted:{thinking:o?B(o.thinking):!1,media:o?B(o.media):!1,other:o?B(o.other):!1},items:G(i.items,256,ni)}}var Yr=[`user`,`assistant`,`tool`,`thinking`];function Xr(e){return G(e,2**53-1,e=>{let t=W(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new F(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:Pr(t.entry),index:z(t.index,0),mimeType:V(t.mimeType,Un)}})}var Zr=[`renderId`,`version`,`state`];function Qr(e){return Zr.filter(t=>Object.hasOwn(e??{},t))}function $r(e){return{...e.renderId===void 0?{}:{renderId:e.renderId},...e.version===void 0?{}:{version:e.version},...e.state===void 0?{}:{state:e.state}}}function ei(e){return{...e.renderId===void 0?{}:{renderId:L(e.renderId,160,!0)},...e.version===void 0?{}:{version:q(e.version)},...e.state===void 0?{}:{state:V(e.state,[`pending`,`streaming`,`running`,`completed`,`failed`,`canceled`,`unavailable`])}}}function ti(e){let t=W(e,[`kind`,`sequence`,...Object.hasOwn(e??{},`name`)?[`name`]:[]]),n=V(t.kind,[`waiting`,`thinking`,`text`,`tool`]);if(t.name!==void 0&&n!==`tool`)throw new F(`invalid`);return{kind:n,sequence:z(t.sequence,0),...t.name===void 0?{}:{name:L(t.name,128)}}}function ni(e){let t=W(e,[...Qr(e),`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...ei(t),...t.images===void 0?{}:{images:Xr(t.images)},id:L(t.id,160,!0),role:V(t.role,Yr),text:L(t.text,262144),name:L(t.name,128),args:L(t.args,65536),error:B(t.error)}}function ri(e){let t=W(e,[...Qr(e),`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...ei(t),...t.images===void 0?{}:{images:Xr(t.images)},id:L(t.id,160,!0),role:V(t.role,Yr),text:L(t.text,Rr),clipped:B(t.clipped),name:L(t.name,128),target:L(t.target,zr),error:B(t.error),parts:z(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&(!n.parts&&!(n.renderId&&[`streaming`,`completed`,`unavailable`,`canceled`,`failed`].includes(n.state??``))||n.parts&&n.state!==void 0&&n.state!==`completed`))throw new F(`invalid`);return n}function ii(e){let t=W(e,[...Object.hasOwn(e??{},`activity`)?[`activity`]:[],`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=W(t.omitted,[`thinking`,`media`,`other`]),r=z(t.steps,0);return{...t.activity===void 0?{}:{activity:ti(t.activity)},...t.execution===void 0?{}:{execution:gn(t.execution)},...t.retry===void 0?{}:{retry:Ke(t.retry)},id:Pr(t.id),entry:U(t.entry,Pr),...t.parent===void 0?{}:{parent:U(t.parent,Pr)},at:z(t.at,0),status:V(t.status,Wr),notice:L(t.notice,1024),omitted:{thinking:B(n.thinking),media:B(n.media),other:B(n.other)},steps:r,stable:z(t.stable,0,r)}}function ai(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=W(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?W(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new F(`invalid`);return{id:pn(n.id),title:L(n.title,512,!0),leaf:U(n.leaf,Pr),status:V(n.status,Wr),updatedAt:z(n.updatedAt,0),origin:V(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:B(n.cadence)}:{},...r?{live:{commandId:K(r.commandId),epoch:K(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function oi(e){let t=W(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:K(t.commandId),text:L(t.text,16384),status:V(t.status,Wr),notice:L(t.notice,1024)}}function si(e){let t=W(e,[`commandId`,`mode`,`text`]);return{commandId:K(t.commandId),mode:V(t.mode,[`steer`,`queue`]),text:L(t.text,256)}}function ci(e){let t=W(e,[`tokens`,`provider`,`model`]);return{tokens:U(t.tokens,e=>z(e,1)),provider:L(t.provider,128),model:L(t.model,256)}}function li(e){let t=W(e,[`input`,`read`,`write`]);return{input:z(t.input,0),read:z(t.read,0),write:z(t.write,0)}}function ui(e){let t=W(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:Pr(t.id),parent:U(t.parent,Pr),text:L(t.text,1024),at:z(t.at,0),leaf:Pr(t.leaf),current:B(t.current)}}function di(e){J(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=W(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:K(n.commandId),imageId:K(n.imageId),offset:z(n.offset,0)}}if(t===`conversation-image`){let n=W(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:V(n.mimeType,Un),data:L(n.data,Hn.chunkChars,!0),next:U(n.next,e=>z(e,0))}}if(t===`conversation-context`)return{kind:t,context:hn(W(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:Cn(W(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=W(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:K(n.commandId),choice:vn(n.choice)}}if(t===`workflow-transcript`){let n=W(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:K(n.runId),stepId:L(n.stepId,160,!0),turn:U(n.turn,Jr)}}if(t===`cadence-conversation`)return{kind:t,state:Nr(W(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=W(e,[`kind`,`after`,`scan`]);return{kind:t,after:U(n.after,K),scan:K(n.scan)}}if(t===`workflow-history`){let n=W(e,[`kind`,`entries`,`next`]),r=G(n.entries,Kn.historyPage,e=>{let t=W(e,[`id`,`run`]),n=K(t.id),r=U(t.run,Cr);if(r&&r.id!==n)throw new F(`invalid`);return{id:n,run:r}}),i=U(n.next,K);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new F(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=W(e,[`kind`,`runs`,...n?[`links`]:[]]),i=G(r.runs,4,Cr),a=n?G(r.links,4,e=>{let t=W(e,[`runId`,`conversationId`]);return{runId:K(t.runId),conversationId:pn(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new F(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-revalidated`){let n=W(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:K(n.commandId),state:Nr(n.state)}}if(t===`cadence-grant`){let n=W(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:K(n.commandId),grant:K(n.grant),expiresAt:z(n.expiresAt,0),revision:z(n.revision,0),proposal:xr(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=W(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:U(t.commandId,K),response:wr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:G(W(e,[`kind`,`entries`]).entries,8,ai)};if(n===`conversations`){let t=W(e,[`kind`,`entries`,`next`]);return{kind:n,entries:G(t.entries,200,ai),next:U(t.next,Ur)}}if(n===`conversation`){let t=W(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`cache`)?[`cache`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=U(t.summary,ai),i=z(t.turns,0);if(!r&&i)throw new F(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:G(t.commands,64,K)},...t.context===void 0?{}:{context:ci(t.context)},...t.cache===void 0?{}:{cache:li(t.cache)},...t.pending===void 0?{}:{pending:G(t.pending,8,si)},...t.undelivered===void 0?{}:{undelivered:G(t.undelivered,8,oi)},summary:r,leaf:U(t.leaf,Pr),continues:B(t.continues),turns:i,branches:z(t.branches,0),runs:G(t.runs,200,K),attempt:U(t.attempt,oi)}}if(n===`conversation-tree`){let t=W(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:pn(t.conversationId),nodes:G(t.nodes,Lr,ui),truncated:B(t.truncated)}}if(n===`conversation-turn`){let t=W(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=ii(t.turn),i=z(t.start,0),a=G(t.steps,24,ri);if(i+a.length>r.steps)throw new F(`invalid`);return{kind:n,conversationId:pn(t.conversationId),leaf:U(t.leaf,Pr),ordinal:z(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=W(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:pn(t.conversationId),leaf:U(t.leaf,Pr),turnId:Pr(t.turnId),step:z(t.step,0),part:z(t.part,0),item:ni(t.item)}}if(n===`files`||n===`directories`){let t=W(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:L(t.path,4096),parent:U(t.parent,e=>L(e,4096)),limited:B(t.limited),entries:G(t.entries,200,e=>{let t=W(e,[`name`,`path`,`directory`]);return{name:L(t.name,1024,!0),path:L(t.path,4096,!0),directory:B(t.directory)}})}}if(n===`file`){let t=W(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:L(t.path,4096),text:L(t.text,262144),limited:B(t.limited)}}if(n===`file-part`){let t=W(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=z(t.size,0),i=L(t.data,Fr/3*4),a=U(t.next,e=>z(e,1)),o=L(t.version,32,!0);if(r>67108864||!/^[a-f0-9]{32}$/.test(o)||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)||a!==null&&(a%196608!=0||a>=r))throw new F(`invalid`);return{kind:n,path:L(t.path,4096),size:r,version:o,data:i,next:a}}if(n===`projects`)return{kind:n,entries:G(W(e,[`kind`,`entries`]).entries,128,e=>{let t=W(e,[`path`,`current`]);return{path:L(t.path,4096,!0),current:B(t.current)}})};if(n===`accepted`)return{kind:n,commandId:K(W(e,[`kind`,`commandId`]).commandId)};let r=W(e,[`kind`,`commandId`,`path`,`link`]);return{kind:V(r.kind,[`project`]),commandId:K(r.commandId),path:L(r.path,4096,!0),link:L(r.link,8192,!0)}}var fi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},pi=m.createContext&&m.createContext(fi),mi=[`attr`,`size`,`title`];function hi(e,t){if(e==null)return{};var n,r,i=gi(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 gi(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 _i(){return _i=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},_i.apply(null,arguments)}function vi(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 yi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?vi(Object(n),!0).forEach(function(t){bi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function bi(e,t,n){return(t=xi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function xi(e){var t=Si(e,`string`);return typeof t==`symbol`?t:t+``}function Si(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 Ci(e){return e&&e.map((e,t)=>m.createElement(e.tag,yi({key:t},e.attr),Ci(e.child)))}function $(e){return t=>m.createElement(wi,_i({attr:yi({},e.attr)},t),Ci(e.child))}function wi(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=hi(e,mi),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,_i({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:yi(yi({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return pi===void 0?t(fi):m.createElement(pi.Consumer,null,e=>t(e))}function Ti(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Ei(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Di(e){return $({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 Oi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function ki(e){return $({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 Ai(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function ji(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function Mi(e){return $({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 Ni(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function Pi(e){return $({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 Fi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function Ii(e){return $({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 Li(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function Ri(e){return $({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 zi(e){return $({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 Bi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function Vi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},child:[]}]})(e)}function Hi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function Ui(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Wi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function Gi(e){return $({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 Ki(e){return $({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 qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function Ji(e){return $({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 Yi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function Xi(e){return $({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 Zi(e){return $({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 Qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function $i(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function ea(e){return $({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 ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function na(e){return $({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 ra(e){return $({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 ia(e){return $({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 aa(e){return $({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 oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function sa(e){return $({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 ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function la(e){return $({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 ua(e){return $({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 da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function fa(e){return $({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 pa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function ma(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function ha(e){return $({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 ga(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function _a(e){return $({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 va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function ya(e){return $({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 ba(e){return $({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 xa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function Sa(e){return $({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 Ca(e){return $({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 wa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function Ta(e){return $({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 Ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function Da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function Oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function ka(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function ja(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var Ma=e=>({kind:`error`,error:oe(`unavailable`,e?`uncertain`:`none`)}),Na=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Gr(e);try{if(!this.transport.workbenchRead)return Ma(!1);let e=Q(await this.transport.workbenchRead(n,t),di);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?Ma(!1):e}catch{return Ma(!1)}}async workbenchCommand(e){let t=qr(e);try{if(!this.transport.workbenchCommand)return Ma(!0);let e=Q(await this.transport.workbenchCommand(t),di);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Ma(!0):e}catch{return Ma(!0)}}async current(e,t){let n=an(e);try{if(!this.transport.current)return Ma(!1);let e=Q(await this.transport.current(n,t),dn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}async currentChanges(e,t){let n=on(e);try{if(!this.transport.currentChanges)return Ma(!1);let e=Q(await this.transport.currentChanges(n,t),fn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),at):Ma(!1)}catch{return Ma(!1)}}async models(e,t,n=!1){try{if(t){let r=await this.workbenchRead({kind:n?`reload-conversation-models`:`conversation-models`,location:t},e);return r.kind===`error`?r:r.value.kind===`conversation-models`&&r.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:r.value.catalog}:Ma(!1)}return this.transport.models?Q(await this.transport.models(e),Cn):Ma(!1)}catch{return Ma(!1)}}async chooseModel(e,t){let n=yn(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:Ma(!0)}else{if(!this.transport.chooseModel)return Ma(!1);e=Q(await this.transport.chooseModel(n),vn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(J(i)!==J(n.choice)||J(e.value.version.conversation??null)!==J(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return Ma(!0)}return e}catch{return Ma(!0)}}async checkObligations(e,t){K(e);try{let n=Q(await this.transport.checkObligations(e,t),$t);return n.kind===`ok`&&n.value.taskId!==e?Ma(!1):n}catch{return Ma(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=en({...t,kind:e});try{let e=Q(await this.transport.entity(r,n),nn);return e.kind===`ok`&&J(e.value.request)!==J(r)?Ma(!1):e}catch{return Ma(!1)}}async session(e){try{return Q(await this.transport.session(e),Ot)}catch{return Ma(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),kt)}catch{return Ma(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Lt({...t,reader:e});try{let t=Q(await this.transport[e](r,n),Ut);return t.kind===`ok`&&!Wt(r,t.value)?Ma(!1):t}catch{return Ma(!1)}}async graph(e,t){let n=Gt(e);try{let e=Q(await this.transport.graph(n,t),qt);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}async*export(e,t){let n=Jt(e),r=new Zt(n),i;try{if(t.aborted)throw new F(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new F(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new F(`unavailable`);yield i}catch{throw new F(`unavailable`)}}async preflight(e,t){let n=ke({expected:e,action:t});try{let e=Q(await this.transport.preflight(n),Pe);return e.kind===`ok`&&(J(e.value.preview.version)!==J(n.expected)||J(e.value.preview.action)!==J(n.action))?Ma(!1):e}catch{return Ma(!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=Ae(t);if(n.action.kind!==e)return{kind:`error`,error:oe(`invalid`)};try{let e=Q(await this.transport.command(n),ut);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Ma(!0);dt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Ma(!0)}}async cancel(e){let t=Me(e);try{let e=Q(await this.transport.cancel(t),ut);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Ma(!0);dt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Ma(!0)}}async receipt(e,t){K(e);try{let n=ft(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:oe(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=ze(e);try{let e=Q(await this.transport.snapshot(n,t),gt);return e.kind===`ok`&&J(e.value.scope)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}async detail(e,t){let n=Ve(e);try{let e=Q(await this.transport.detail(n,t),bt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}async search(e,t){let n=Ve(e);try{let e=Q(await this.transport.search(n,t),St);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ma(!1):e}catch{return Ma(!1)}}},Pa=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=gt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&J(i.scope)===J(r.scope)&&ce(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>=P.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=P.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=_t(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||J(i.scope)!==J(a.scope))return this.resync();let o=ce(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Tt(i.context)!==Tt(a.context)||Et(i.context)!==Et(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||J(t.admission)!==J(e.admission))return this.resync();s[n]=e}}if(s.length>P.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{gt(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function Fa(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var Ia={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`},La=`/api/v1/events`,Ra=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function za(e,t){if(Ra.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 P.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 P.pageBytes}return P.controlBytes}function Ba(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Va(e,t){switch(e){case`workbenchRead`:return Gr(t);case`workbenchCommand`:return qr(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new F(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Lt(t);if(n.reader!==e)throw new F(`invalid`);return n}case`current`:return an(t);case`currentChanges`:return on(t);case`checkObligations`:case`receipt`:return K(t);case`entity`:return en(t);case`graph`:return Gt(t);case`snapshot`:return ze(t);case`detail`:case`search`:return Ve(t);case`export`:case`download`:return Jt(t);case`chooseModel`:return yn(t);case`preflight`:return ke(t);case`command`:return Ae(t);case`cancel`:return Me(t)}}function Ha(e,t){if(Ra.includes(e))return Q(t,Ut);switch(e){case`workbenchRead`:case`workbenchCommand`:return Q(t,di);case`current`:return Q(t,dn);case`currentChanges`:return Q(t,fn);case`activeRuns`:return Q(t,at);case`models`:return Q(t,Cn);case`chooseModel`:return Q(t,vn);case`session`:return Q(t,Ot);case`workspace`:return Q(t,kt);case`checkObligations`:return Q(t,$t);case`entity`:return Q(t,nn);case`graph`:return Q(t,qt);case`snapshot`:return Q(t,gt);case`detail`:return Q(t,bt);case`search`:return Q(t,St);case`preflight`:return Q(t,Pe);case`command`:case`cancel`:return Q(t,ut);case`receipt`:return ft(t);case`detach`:return Q(t,e=>{if(e!==null)throw new F(`invalid`);return null});default:throw new F(`invalid`)}}function Ua(e){return[...Ra,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Wa(e,t){let n=Ia[e];return t===null||Ba(e)?n:`${n}?request=${encodeURIComponent(J(t))}`}function Ga(e,t){let n=Va(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ia[e]:Wa(e,n);return Ba(e)||Ua(e)&&(r||R(i)>P.headerBytes/4)?{path:Ia[e],method:`POST`,body:J(n)}:{path:i,method:`GET`}}function Ka(e){J(e,P.viewerBytes);let t=V(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:gt(W(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:_t(W(e,[`kind`,`event`]).event)}:(W(e,[`kind`]),{kind:t})}var qa=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 F(`invalid`);this.origin=e.origin,e.build&&=ct(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,t=!1){let n={"Cache-Control":`no-store`};if(this.options.build&&(n[`X-Cadence-Build`]=J(this.options.build)),this.attachment&&(e||t)&&(n[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(n[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new F(`stale`);n[`Content-Type`]=`application/json`,this.csrf&&(n[`X-Cadence-CSRF`]=this.csrf)}return n}async request(e,t,n){let r=Ga(e,Va(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Fa([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;e===`session`&&(this.attachment??=crypto.randomUUID());let t=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i,e===`session`),credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),n;try{if(e===`session`&&t.ok&&(n=K(t.headers.get(`x-cadence-attachment`)),n!==this.attachment))throw new F(`invalid`)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await Ja(t,za(e)),s=ue(a);if(R(a)>za(e,s))throw new F(`oversize`);let c=Ha(e,s);if(e===`session`){let e=Q(c,Ot);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new F(`forbidden`);this.attachment=n??K(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,yn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,K(e),t)}entity(e,t){return this.request(`entity`,en(e),t)}tasks(e,t){return this.request(`tasks`,Lt(e),t)}runs(e,t){return this.request(`runs`,Lt(e),t)}messages(e,t){return this.request(`messages`,Lt(e),t)}tools(e,t){return this.request(`tools`,Lt(e),t)}contents(e,t){return this.request(`contents`,Lt(e),t)}events(e,t){return this.request(`events`,Lt(e),t)}checks(e,t){return this.request(`checks`,Lt(e),t)}changes(e,t){return this.request(`changes`,Lt(e),t)}reviews(e,t){return this.request(`reviews`,Lt(e),t)}graph(e,t){return this.request(`graph`,Gt(e),t)}preflight(e){return this.request(`preflight`,ke(e))}command(e){return this.request(`command`,Ae(e))}cancel(e){return this.request(`cancel`,Me(e))}receipt(e,t){return this.request(`receipt`,K(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;if(!this.options.localCapability&&!this.csrf){let t=Q(await this.session(),Ot);if(t.kind===`error`){if(![`stale`,`unauthenticated`].includes(t.error.code))throw new F(t.error.code);return this.attachment===e&&(this.attachment=void 0),t}}let t=Q(await this.request(`detach`,null),e=>{if(e!==null)throw new F(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw t.error.code===`forbidden`&&!this.options.localCapability&&this.attachment===e&&(this.csrf=null),new F(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Ga(`export`,Jt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new F(`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 F(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=P.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+P.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
7
|
+
`)}\n\n## Setup (explicitly authorized commands)\nExecution order: target once before worktree creation, candidate once, then worktree in the candidate and every detached child; listed order within each stage. Each command is a separate process; exports do not persist.\n${e.setup.map(e=>`[${e.placement??`worktree`}] ${Ir(e)}`).join(`
|
|
8
|
+
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(Ir).join(`
|
|
9
|
+
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(Ir).join(`
|
|
10
|
+
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(Lr).join(`
|
|
11
|
+
`)}`:``}\n\n## Automation boundary\n${Rr(e)} Only actual verification and independent Agent review permit delivery. ${e.delivery===`local-merge`?`Authorize one new named task branch and stable isolated worktree after approval, temporary worktrees beside it for assignments that run side by side, local commits and serialized fast-forward delivery of the exact checked and Agent-reviewed candidate into the displayed target. Independent conversations may implement in separate candidates; a verified non-overlapping sibling delivery may be merged into this candidate and checked/reviewed again. Conflicts, changed instructions, overlapping inputs or external target drift retain the candidate for a fresh plan. Keep the task branch; retain any worktree with uncommitted, untracked or ignored residue.`:`Direct working-copy edits; failures leave actual edits for inspection. No Git commit or merge.`} No push, publication, deployment or recursive delegation. Related project knowledge and workflow Markdown are included. Worktrees/tools are not a sandbox.\n\n## Project documents\n${e.version===void 0?e.projectContext:t.join(`
|
|
12
|
+
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var Br=e=>z(e,0,864e13);function Vr(e){let t=W(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,...Object.hasOwn(e??{},`timeoutMs`)?[`timeoutMs`]:[],`stopReason`]);return{createdAt:Br(t.createdAt),preparedAt:U(t.preparedAt,Br),startedAt:U(t.startedAt,Br),stopRequestedAt:U(t.stopRequestedAt,Br),closedAt:U(t.closedAt,Br),settledAt:U(t.settledAt,Br),...t.timeoutMs===void 0?{}:{timeoutMs:z(t.timeoutMs,100,2147483647)},stopReason:U(t.stopReason,e=>L(e,320,!0))}}function Hr(e){let t=W(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=W(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:Br(t.acceptedAt),acquiredAt:U(t.acquiredAt,Br),settledAt:U(t.settledAt,Br),owner:{version:L(n.version,128,!0),build:L(n.build,64,!0),entry:L(n.entry,4096,!0),pid:z(n.pid,1),node:L(n.node,128,!0),platform:L(n.platform,32,!0),startedAt:Br(n.startedAt)}}}function Ur(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`}. Readonly research shares access; isolated implementation holds no target checkout permit. Direct edits and final delivery are exclusive.`,...e.steps.flatMap(e=>e.timing?[`${e.id}: preparing ${n(e.timing.createdAt)} · prepared ${n(e.timing.preparedAt)} · spawned ${n(e.timing.startedAt)} · stop ${n(e.timing.stopRequestedAt)} (${e.timing.stopReason??`none`}) · direct child closed ${n(e.timing.closedAt)} · settled ${n(e.timing.settledAt)} · ${e.timing.timeoutMs===void 0?`no total runtime deadline`:`historical process budget ${e.timing.timeoutMs}ms`}${e.runtime?` · worker SDK ${e.runtime.sdkVersion} · worker hash ${e.runtime.workerHash}`:``}`]:[])].join(`
|
|
13
|
+
`)}function Wr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=W(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[],...Object.hasOwn(e??{},`design`)?[`design`]:[]]);return{id:pn(n.id),revision:z(n.revision,0),enabled:B(n.enabled),head:U(n.head,K),proposal:U(n.proposal,Mr),runs:G(n.runs,200,K),...n.design===void 0?{}:{design:Qn(n.design)},...t?{notice:L(n.notice,1024,!0)}:{}}}function Gr(e){let t=L(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new F(`invalid`);return t}function Kr(e){if(Object.hasOwn(e??{},`checkout`)){let{checkout:t}=W(e,[`checkout`]);return{checkout:G(t,8,e=>L(e,1024,!0))}}if(Object.hasOwn(e??{},`investigation`))return{investigation:K(W(e,[`investigation`]).investigation)};if(Object.hasOwn(e??{},`match`)){let t=W(e,[`path`,`match`]);return{path:L(t.path,1024,!0),match:L(t.match,256,!0)}}let t=W(e,[`path`,...Object.hasOwn(e??{},`section`)?[`section`]:[]]);return{path:L(t.path,1024,!0),...t.section===void 0?{}:{section:L(t.section,512,!0)}}}var qr=196608,Jr=16384,Yr=1e3,Xr=16384,Zr=1024;function Qr(e,t){let n=e=>new TextEncoder().encode(JSON.stringify(e)).length;if(n(e)<=t)return e;let r=0,i=Math.min(e.length,t);for(;r<i;){let a=Math.ceil((r+i)/2);n(e.slice(0,a))<=t?r=a:i=a-1}return/[\uD800-\uDBFF]/u.test(e.slice(r-1,r))?e.slice(0,r-1):e.slice(0,r)}function $r(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
|
|
14
|
+
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function ei(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:Qr(e.text,Xr);return{id:e.id,...di(e),role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?Qr($r(e.args),Zr):``,error:e.error,parts:t}}function ti(e){let t=W(e,[`id`,`updatedAt`]);return{id:pn(t.id),updatedAt:z(t.updatedAt,0)}}var ni=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function ri(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`project-knowledge`:return{kind:t,source:Kr(W(e,[`kind`,`source`]).source)};case`conversation-context`:case`reload-conversation-models`:case`conversation-models`:return{kind:t,location:mn(W(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=W(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Gr),ordinal:z(n.ordinal,0),before:U(n.before,e=>z(e,0))}}case`conversation-image`:{let n=W(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=z(n.offset,0);if(r%Hn.chunkChars||n.live!==void 0&&n.live!==!0)throw new F(`invalid`);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Gr),...n.live===void 0?{}:{live:!0},entry:Gr(n.entry),index:z(n.index,0),offset:r}}case`conversation-step`:{let n=W(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Gr),turnId:Gr(n.turnId),step:z(n.step,0),part:z(n.part,0)}}case`cadence-conversation`:return{kind:t,id:pn(W(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=W(e,[`kind`,`id`,`leaf`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Gr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=W(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:U(r.after,K),...n?{scan:K(r.scan)}:{}}}case`workflow-active`:return W(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=W(e,[`kind`,`id`,`stepId`]);return{kind:t,id:K(n.id),stepId:L(n.stepId,160,!0)}}case`workflow`:{let n=W(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:K(n.id),...n.before===void 0?{}:{before:z(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=W(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new F(`invalid`);return{kind:t,...n?{after:U(i.after,ti)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return W(e,[`kind`]),{kind:t};case`conversation`:{let n=W(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:pn(n.id),leaf:U(n.leaf,Gr),known:U(n.known,Gr)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=W(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=z(r.offset,0);if(i%196608||i>=67108864)throw new F(`invalid`);return{kind:t,path:L(r.path,4096),offset:i,...n?{location:mn(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=W(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:V(r.kind,[`files`,`file`,`directories`]),path:L(r.path,4096),...n?{location:mn(r.location)}:{}}}}}function ii(e){let t=L(e,400);if(t!==t.trim()||/\p{Cc}/u.test(t))throw new F(`invalid`);if([...t].length>100)throw new F(`oversize`);return t}function ai(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=W(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:K(n.commandId),location:mn(n.location),expected:_n(n.expected),choice:ge(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=W(e,t===`restore-model`?[`kind`,`commandId`,`epoch`,...Object.hasOwn(e??{},`location`)?[`location`]:[],...Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`)?[`expected`,`choice`]:[]]:[`kind`,`commandId`,`epoch`,`runId`]);if((n.expected!==void 0||n.choice!==void 0)&&n.location===void 0)throw new F(`invalid`);let r=Object.hasOwn(e??{},`expected`)||Object.hasOwn(e??{},`choice`),i={commandId:K(n.commandId),epoch:K(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:mn(n.location)},...r?{expected:_n(n.expected),choice:ge(n.choice)}:{}}:{kind:t,...i,runId:K(n.runId)}}if(t===`cadence-exit`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:mn(n.location)},commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Gr),revision:z(n.revision,0)}}if(t===`image-upload`){let n=W(e,[`kind`,`commandId`,`imageId`,`send`,`mimeType`,`size`,`offset`,`data`]);if(![`send`,`cadence-send`].includes(Object.getOwnPropertyDescriptor(n.send??{},`kind`)?.value))throw new F(`invalid`);let r=ai(n.send);if(r.kind!==`send`&&r.kind!==`cadence-send`||r.images?.length||r.kind===`cadence-send`&&r.intent===`exit`)throw new F(`invalid`);return{kind:t,commandId:K(n.commandId),imageId:K(n.imageId),send:r,mimeType:V(n.mimeType,Un),size:z(n.size,1),offset:z(n.offset,0),data:L(n.data,Hn.chunkChars,!0)}}if(t===`cadence-send`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Gr),text:L(n.text,Jr),...n.images===void 0?{}:{images:G(n.images,2**53-1,K)},model:_n(n.model),revision:z(n.revision,0),intent:V(n.intent,[`message`,`enter`,`exit`,`design`])}}if(t===`cadence-design-edit`){let n=W(e,[`kind`,`commandId`,`conversationId`,`revision`,`designId`,`answers`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),revision:z(n.revision,0),designId:K(n.designId),answers:Yn(n.answers)}}if(t===`cadence-revalidate`){let n=W(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=pn(n.conversationId),i=hn(n.context);if(i.id!==r)throw new F(`invalid`);return{kind:t,commandId:K(n.commandId),conversationId:r,revision:z(n.revision,0),proposalId:K(n.proposalId),digest:q(n.digest),head:U(n.head,Gr),context:i,expected:_n(n.expected),model:ge(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=W(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:K(r.commandId),conversationId:pn(r.conversationId),revision:z(r.revision,0),proposalId:K(r.proposalId),digest:q(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:K(r.grant)}}if(t===`workflow`){let n=W(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:K(n.commandId),epoch:K(n.epoch),request:Nr(n.request)}}if(t===`send`){let n=W(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),head:U(n.head,Gr),text:L(n.text,Jr),...n.images===void 0?{}:{images:G(n.images,2**53-1,K)},model:_n(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=W(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:K(n.commandId),conversationId:pn(n.conversationId),turnId:K(n.turnId),epoch:K(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:V(n.mode,[`steer`,`queue`]),text:L(n.text,Jr,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:K(n.inputId)}}if(t===`conversation-rename`){let n=W(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),name:ii(n.name)}}if(t===`conversation-archive`){let n=W(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:K(n.commandId),conversationId:pn(n.conversationId),archived:B(n.archived)}}let n=W(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:V(n.kind,[`open-project`]),commandId:K(n.commandId),path:L(n.path,4096,!0),epoch:K(n.epoch)}}function oi(e){let t=[`id`,`epoch`,`status`,`items`,`notice`],n=typeof e==`object`&&!!e&&Object.hasOwn(e,`omitted`),r=typeof e==`object`&&!!e&&Object.hasOwn(e,`transcript`),i=W(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?W(i.transcript,[`pages`]):null,o=n?W(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:gn(i.execution)},...i.retry===void 0?{}:{retry:qe(i.retry)},id:K(i.id),epoch:K(i.epoch),status:V(i.status,ni),notice:L(i.notice,1024),...a?{transcript:{pages:z(a.pages,0)}}:{},omitted:{thinking:o?B(o.thinking):!1,media:o?B(o.media):!1,other:o?B(o.other):!1},items:G(i.items,256,mi)}}var si=[`user`,`assistant`,`tool`,`thinking`];function ci(e){return G(e,2**53-1,e=>{let t=W(e,[`entry`,`index`,`mimeType`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]);if(t.live!==void 0&&t.live!==!0)throw new F(`invalid`);return{...t.live===void 0?{}:{live:!0},entry:Gr(t.entry),index:z(t.index,0),mimeType:V(t.mimeType,Un)}})}var li=[`renderId`,`version`,`state`];function ui(e){return li.filter(t=>Object.hasOwn(e??{},t))}function di(e){return{...e.renderId===void 0?{}:{renderId:e.renderId},...e.version===void 0?{}:{version:e.version},...e.state===void 0?{}:{state:e.state}}}function fi(e){return{...e.renderId===void 0?{}:{renderId:L(e.renderId,160,!0)},...e.version===void 0?{}:{version:q(e.version)},...e.state===void 0?{}:{state:V(e.state,[`pending`,`streaming`,`running`,`completed`,`failed`,`canceled`,`unavailable`])}}}function pi(e){let t=W(e,[`kind`,`sequence`,...Object.hasOwn(e??{},`name`)?[`name`]:[]]),n=V(t.kind,[`waiting`,`thinking`,`text`,`tool`]);if(t.name!==void 0&&n!==`tool`)throw new F(`invalid`);return{kind:n,sequence:z(t.sequence,0),...t.name===void 0?{}:{name:L(t.name,128)}}}function mi(e){let t=W(e,[...ui(e),`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...fi(t),...t.images===void 0?{}:{images:ci(t.images)},id:L(t.id,160,!0),role:V(t.role,si),text:L(t.text,262144),name:L(t.name,128),args:L(t.args,65536),error:B(t.error)}}function hi(e){let t=W(e,[...ui(e),`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...fi(t),...t.images===void 0?{}:{images:ci(t.images)},id:L(t.id,160,!0),role:V(t.role,si),text:L(t.text,Xr),clipped:B(t.clipped),name:L(t.name,128),target:L(t.target,Zr),error:B(t.error),parts:z(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&(!n.parts&&!(n.renderId&&[`streaming`,`completed`,`unavailable`,`canceled`,`failed`].includes(n.state??``))||n.parts&&n.state!==void 0&&n.state!==`completed`))throw new F(`invalid`);return n}function gi(e){let t=W(e,[...Object.hasOwn(e??{},`activity`)?[`activity`]:[],`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=W(t.omitted,[`thinking`,`media`,`other`]),r=z(t.steps,0);return{...t.activity===void 0?{}:{activity:pi(t.activity)},...t.execution===void 0?{}:{execution:gn(t.execution)},...t.retry===void 0?{}:{retry:qe(t.retry)},id:Gr(t.id),entry:U(t.entry,Gr),...t.parent===void 0?{}:{parent:U(t.parent,Gr)},at:z(t.at,0),status:V(t.status,ni),notice:L(t.notice,1024),omitted:{thinking:B(n.thinking),media:B(n.media),other:B(n.other)},steps:r,stable:z(t.stable,0,r)}}function _i(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=W(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?W(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new F(`invalid`);return{id:pn(n.id),title:L(n.title,512,!0),leaf:U(n.leaf,Gr),status:V(n.status,ni),updatedAt:z(n.updatedAt,0),origin:V(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:B(n.cadence)}:{},...r?{live:{commandId:K(r.commandId),epoch:K(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function vi(e){let t=W(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:K(t.commandId),text:L(t.text,16384),status:V(t.status,ni),notice:L(t.notice,1024)}}function yi(e){let t=W(e,[`commandId`,`mode`,`text`]);return{commandId:K(t.commandId),mode:V(t.mode,[`steer`,`queue`]),text:L(t.text,256)}}function bi(e){let t=W(e,[`tokens`,`provider`,`model`]);return{tokens:U(t.tokens,e=>z(e,1)),provider:L(t.provider,128),model:L(t.model,256)}}function xi(e){let t=W(e,[`input`,`read`,`write`]);return{input:z(t.input,0),read:z(t.read,0),write:z(t.write,0)}}function Si(e){let t=W(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:Gr(t.id),parent:U(t.parent,Gr),text:L(t.text,1024),at:z(t.at,0),leaf:Gr(t.leaf),current:B(t.current)}}function Ci(e){J(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=W(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:K(n.commandId),imageId:K(n.imageId),offset:z(n.offset,0)}}if(t===`conversation-image`){let n=W(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:V(n.mimeType,Un),data:L(n.data,Hn.chunkChars,!0),next:U(n.next,e=>z(e,0))}}if(t===`conversation-context`)return{kind:t,context:hn(W(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:Cn(W(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=W(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:K(n.commandId),choice:vn(n.choice)}}if(t===`workflow-transcript`){let n=W(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:K(n.runId),stepId:L(n.stepId,160,!0),turn:U(n.turn,oi)}}if(t===`cadence-conversation`)return{kind:t,state:Wr(W(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=W(e,[`kind`,`after`,`scan`]);return{kind:t,after:U(n.after,K),scan:K(n.scan)}}if(t===`workflow-history`){let n=W(e,[`kind`,`entries`,`next`]),r=G(n.entries,rr.historyPage,e=>{let t=W(e,[`id`,`run`]),n=K(t.id),r=U(t.run,Pr);if(r&&r.id!==n)throw new F(`invalid`);return{id:n,run:r}}),i=U(n.next,K);if(new Set(r.map(e=>e.id)).size!==r.length||i!==null&&i!==r.at(-1)?.id)throw new F(`invalid`);return{kind:t,entries:r,next:i}}if(t===`workflow-active`){let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`links`),r=W(e,[`kind`,`runs`,...n?[`links`]:[]]),i=G(r.runs,4,Pr),a=n?G(r.links,4,e=>{let t=W(e,[`runId`,`conversationId`]);return{runId:K(t.runId),conversationId:pn(t.conversationId)}}):[];if(new Set(a.map(e=>e.runId)).size!==a.length||a.some(e=>!i.some(t=>t.id===e.runId)))throw new F(`invalid`);return{kind:t,runs:i,links:a}}if(t===`cadence-revalidated`){let n=W(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:K(n.commandId),state:Wr(n.state)}}if(t===`cadence-grant`){let n=W(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:K(n.commandId),grant:K(n.grant),expiresAt:z(n.expiresAt,0),revision:z(n.revision,0),proposal:Mr(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=W(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:U(t.commandId,K),response:Fr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:G(W(e,[`kind`,`entries`]).entries,8,_i)};if(n===`conversations`){let t=W(e,[`kind`,`entries`,`next`]);return{kind:n,entries:G(t.entries,200,_i),next:U(t.next,ti)}}if(n===`conversation`){let t=W(e,[`kind`,`summary`,`leaf`,`continues`,`turns`,`branches`,`runs`,`attempt`,...Object.hasOwn(e??{},`commands`)?[`commands`]:[],...Object.hasOwn(e??{},`context`)?[`context`]:[],...Object.hasOwn(e??{},`cache`)?[`cache`]:[],...Object.hasOwn(e??{},`pending`)?[`pending`]:[],...Object.hasOwn(e??{},`undelivered`)?[`undelivered`]:[]]),r=U(t.summary,_i),i=z(t.turns,0);if(!r&&i)throw new F(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:G(t.commands,64,K)},...t.context===void 0?{}:{context:bi(t.context)},...t.cache===void 0?{}:{cache:xi(t.cache)},...t.pending===void 0?{}:{pending:G(t.pending,8,yi)},...t.undelivered===void 0?{}:{undelivered:G(t.undelivered,8,vi)},summary:r,leaf:U(t.leaf,Gr),continues:B(t.continues),turns:i,branches:z(t.branches,0),runs:G(t.runs,200,K),attempt:U(t.attempt,vi)}}if(n===`conversation-tree`){let t=W(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:pn(t.conversationId),nodes:G(t.nodes,Yr,Si),truncated:B(t.truncated)}}if(n===`conversation-turn`){let t=W(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=gi(t.turn),i=z(t.start,0),a=G(t.steps,24,hi);if(i+a.length>r.steps)throw new F(`invalid`);return{kind:n,conversationId:pn(t.conversationId),leaf:U(t.leaf,Gr),ordinal:z(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=W(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:pn(t.conversationId),leaf:U(t.leaf,Gr),turnId:Gr(t.turnId),step:z(t.step,0),part:z(t.part,0),item:mi(t.item)}}if(n===`files`||n===`directories`){let t=W(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:L(t.path,4096),parent:U(t.parent,e=>L(e,4096)),limited:B(t.limited),entries:G(t.entries,200,e=>{let t=W(e,[`name`,`path`,`directory`]);return{name:L(t.name,1024,!0),path:L(t.path,4096,!0),directory:B(t.directory)}})}}if(n===`file`){let t=W(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:L(t.path,4096),text:L(t.text,262144),limited:B(t.limited)}}if(n===`file-part`){let t=W(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=z(t.size,0),i=L(t.data,qr/3*4),a=U(t.next,e=>z(e,1)),o=L(t.version,32,!0);if(r>67108864||!/^[a-f0-9]{32}$/.test(o)||!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(i)||a!==null&&(a%196608!=0||a>=r))throw new F(`invalid`);return{kind:n,path:L(t.path,4096),size:r,version:o,data:i,next:a}}if(n===`projects`)return{kind:n,entries:G(W(e,[`kind`,`entries`]).entries,128,e=>{let t=W(e,[`path`,`current`]);return{path:L(t.path,4096,!0),current:B(t.current)}})};if(n===`accepted`)return{kind:n,commandId:K(W(e,[`kind`,`commandId`]).commandId)};let r=W(e,[`kind`,`commandId`,`path`,`link`]);return{kind:V(r.kind,[`project`]),commandId:K(r.commandId),path:L(r.path,4096,!0),link:L(r.link,8192,!0)}}var wi={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ti=m.createContext&&m.createContext(wi),Ei=[`attr`,`size`,`title`];function Di(e,t){if(e==null)return{};var n,r,i=Oi(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 Oi(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 ki(){return ki=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},ki.apply(null,arguments)}function Ai(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 ji(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ai(Object(n),!0).forEach(function(t){Mi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ai(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Mi(e,t,n){return(t=Ni(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ni(e){var t=Pi(e,`string`);return typeof t==`symbol`?t:t+``}function Pi(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 Fi(e){return e&&e.map((e,t)=>m.createElement(e.tag,ji({key:t},e.attr),Fi(e.child)))}function $(e){return t=>m.createElement(Ii,ki({attr:ji({},e.attr)},t),Fi(e.child))}function Ii(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=Di(e,Ei),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),m.createElement(`svg`,ki({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:ji(ji({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&m.createElement(`title`,null,i),e.children)};return Ti===void 0?t(wi):m.createElement(Ti.Consumer,null,e=>t(e))}function Li(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function Ri(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]},{tag:`line`,attr:{x1:`11`,y1:`8`,x2:`11`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`11`,x2:`14`,y2:`11`},child:[]}]})(e)}function zi(e){return $({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 Bi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`9`,x2:`9`,y2:`15`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`9`,x2:`15`,y2:`15`},child:[]}]})(e)}function Vi(e){return $({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 Hi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`4 17 10 11 4 5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`20`,y2:`19`},child:[]}]})(e)}function Ui(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`5`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`1`,x2:`12`,y2:`3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`21`,x2:`12`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`4.22`,x2:`5.64`,y2:`5.64`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`18.36`,x2:`19.78`,y2:`19.78`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`12`,x2:`3`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`23`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`4.22`,y1:`19.78`,x2:`5.64`,y2:`18.36`},child:[]},{tag:`line`,attr:{x1:`18.36`,y1:`5.64`,x2:`19.78`,y2:`4.22`},child:[]}]})(e)}function Wi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Gi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},child:[]}]})(e)}function Ki(e){return $({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 qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`2`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`2`,y:`14`,width:`20`,height:`8`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`6.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`18`,x2:`6.01`,y2:`18`},child:[]}]})(e)}function Ji(e){return $({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 Yi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`1 4 1 10 7 10`},child:[]},{tag:`path`,attr:{d:`M3.51 15a9 9 0 1 0 2.13-9.36L1 10`},child:[]}]})(e)}function Xi(e){return $({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 Zi(e){return $({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 Qi(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},child:[]}]})(e)}function $i(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},child:[]}]})(e)}function ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`21`,x2:`16`,y2:`21`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12`,y2:`21`},child:[]}]})(e)}function ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function na(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function ra(e){return $({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 ia(e){return $({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 aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3`},child:[]}]})(e)}function oa(e){return $({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 sa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`8`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`8`,y1:`18`,x2:`21`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`3.01`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`3.01`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`3.01`,y2:`18`},child:[]}]})(e)}function ca(e){return $({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 la(e){return $({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 ua(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},child:[]}]})(e)}function da(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`8.5`,r:`1.5`},child:[]},{tag:`polyline`,attr:{points:`21 15 16 10 5 21`},child:[]}]})(e)}function fa(e){return $({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 pa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`path`,attr:{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function ma(e){return $({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 ha(e){return $({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 ga(e){return $({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 _a(e){return $({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 va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`},child:[]},{tag:`polyline`,attr:{points:`14 2 14 8 20 8`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`13`,x2:`8`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`16`,y1:`17`,x2:`8`,y2:`17`},child:[]},{tag:`polyline`,attr:{points:`10 9 9 9 8 9`},child:[]}]})(e)}function ya(e){return $({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 ba(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M12 20h9`},child:[]},{tag:`path`,attr:{d:`M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z`},child:[]}]})(e)}function xa(e){return $({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 Sa(e){return $({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 Ca(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`ellipse`,attr:{cx:`12`,cy:`5`,rx:`9`,ry:`3`},child:[]},{tag:`path`,attr:{d:`M21 12c0 1.66-4 3-9 3s-9-1.34-9-3`},child:[]},{tag:`path`,attr:{d:`M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`},child:[]}]})(e)}function wa(e){return $({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 Ta(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},child:[]}]})(e)}function Ea(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},child:[]}]})(e)}function Da(e){return $({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 Oa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polygon`,attr:{points:`16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76`},child:[]}]})(e)}function ka(e){return $({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 Aa(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`},child:[]},{tag:`rect`,attr:{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,ry:`1`},child:[]}]})(e)}function ja(e){return $({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 Ma(e){return $({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 Na(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`15 18 9 12 15 6`},child:[]}]})(e)}function Pa(e){return $({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 Fa(e){return $({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 Ia(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function La(e){return $({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 Ra(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`16 12 12 8 8 12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12`,y2:`8`},child:[]}]})(e)}function za(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},child:[]}]})(e)}function Ba(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}function Va(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`21 8 21 21 3 21 3 8`},child:[]},{tag:`rect`,attr:{x:`1`,y:`3`,width:`22`,height:`5`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`12`,x2:`14`,y2:`12`},child:[]}]})(e)}function Ha(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`9`,x2:`12`,y2:`13`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`17`,x2:`12.01`,y2:`17`},child:[]}]})(e)}function Ua(e){return $({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},child:[]}]})(e)}var Wa=e=>({kind:`error`,error:oe(`unavailable`,e?`uncertain`:`none`)}),Ga=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=ri(e);try{if(!this.transport.workbenchRead)return Wa(!1);let e=Q(await this.transport.workbenchRead(n,t),Ci);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?Wa(!1):e}catch{return Wa(!1)}}async workbenchCommand(e){let t=ai(e);try{if(!this.transport.workbenchCommand)return Wa(!0);let e=Q(await this.transport.workbenchCommand(t),Ci);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Wa(!0):e}catch{return Wa(!0)}}async current(e,t){let n=an(e);try{if(!this.transport.current)return Wa(!1);let e=Q(await this.transport.current(n,t),dn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}async currentChanges(e,t){let n=on(e);try{if(!this.transport.currentChanges)return Wa(!1);let e=Q(await this.transport.currentChanges(n,t),fn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),at):Wa(!1)}catch{return Wa(!1)}}async models(e,t,n=!1){try{if(t){let r=await this.workbenchRead({kind:n?`reload-conversation-models`:`conversation-models`,location:t},e);return r.kind===`error`?r:r.value.kind===`conversation-models`&&r.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:r.value.catalog}:Wa(!1)}return this.transport.models?Q(await this.transport.models(e),Cn):Wa(!1)}catch{return Wa(!1)}}async chooseModel(e,t){let n=yn(e);try{let e;if(t){let r=await this.workbenchCommand({kind:`conversation-model`,commandId:crypto.randomUUID(),location:t,...n});e=r.kind===`error`?r:r.value.kind===`conversation-model`?{kind:`ok`,value:r.value.choice}:Wa(!0)}else{if(!this.transport.chooseModel)return Wa(!1);e=Q(await this.transport.chooseModel(n),vn)}if(e.kind===`ok`){let{sourceSelectionId:r,...i}=e.value.selected??{};if(J(i)!==J(n.choice)||J(e.value.version.conversation??null)!==J(n.expected.conversation??null)||e.value.version.epoch!==n.expected.epoch||e.value.version.accessGeneration!==n.expected.accessGeneration||![n.expected.configRev,n.expected.configRev+1].includes(e.value.version.configRev)||!t&&e.value.version.configRev===n.expected.configRev!=(e.value.version.catalogId===n.expected.catalogId)||t&&e.value.version.configRev!==n.expected.configRev&&e.value.version.catalogId===n.expected.catalogId)return Wa(!0)}return e}catch{return Wa(!0)}}async checkObligations(e,t){K(e);try{let n=Q(await this.transport.checkObligations(e,t),$t);return n.kind===`ok`&&n.value.taskId!==e?Wa(!1):n}catch{return Wa(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=en({...t,kind:e});try{let e=Q(await this.transport.entity(r,n),nn);return e.kind===`ok`&&J(e.value.request)!==J(r)?Wa(!1):e}catch{return Wa(!1)}}async session(e){try{return Q(await this.transport.session(e),Ot)}catch{return Wa(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),kt)}catch{return Wa(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Lt({...t,reader:e});try{let t=Q(await this.transport[e](r,n),Ut);return t.kind===`ok`&&!Wt(r,t.value)?Wa(!1):t}catch{return Wa(!1)}}async graph(e,t){let n=Gt(e);try{let e=Q(await this.transport.graph(n,t),qt);return e.kind===`ok`&&J(e.value.request)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}async*export(e,t){let n=Jt(e),r=new Zt(n),i;try{if(t.aborted)throw new F(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new F(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new F(`unavailable`);yield i}catch{throw new F(`unavailable`)}}async preflight(e,t){let n=ke({expected:e,action:t});try{let e=Q(await this.transport.preflight(n),Pe);return e.kind===`ok`&&(J(e.value.preview.version)!==J(n.expected)||J(e.value.preview.action)!==J(n.action))?Wa(!1):e}catch{return Wa(!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=Ae(t);if(n.action.kind!==e)return{kind:`error`,error:oe(`invalid`)};try{let e=Q(await this.transport.command(n),ut);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Wa(!0);dt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Wa(!0)}}async cancel(e){let t=Me(e);try{let e=Q(await this.transport.cancel(t),ut);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Wa(!0);dt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Wa(!0)}}async receipt(e,t){K(e);try{let n=ft(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:oe(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=ze(e);try{let e=Q(await this.transport.snapshot(n,t),gt);return e.kind===`ok`&&J(e.value.scope)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}async detail(e,t){let n=Ve(e);try{let e=Q(await this.transport.detail(n,t),bt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}async search(e,t){let n=Ve(e);try{let e=Q(await this.transport.search(n,t),St);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Wa(!1):e}catch{return Wa(!1)}}},Ka=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=gt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&J(i.scope)===J(r.scope)&&ce(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>=P.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=P.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=_t(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||J(i.scope)!==J(a.scope))return this.resync();let o=ce(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Tt(i.context)!==Tt(a.context)||Et(i.context)!==Et(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||J(t.admission)!==J(e.admission))return this.resync();s[n]=e}}if(s.length>P.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{gt(c)}catch{return this.resync()}return a.runs=s,a.horizon=c.horizon,a.context=i.context,a.committedSeq=i.committedSeq,r.lastObservedMs=n,r.connection=`current`,`applied`}};function qa(e=[],t){if(t!==void 0&&(!Number.isFinite(t)||t<0||t>2147483647))throw RangeError(`invalid abort timeout`);let n=new AbortController,r=new Map,i,a=!1,o=()=>{if(!a){a=!0,clearTimeout(i);for(let[e,t]of r)e.removeEventListener(`abort`,t);r.clear()}},s=e=>{a||(o(),n.abort(e))};for(let t of e){if(!t||r.has(t))continue;if(t.aborted){s(t.reason);break}let e=()=>s(t.reason);r.set(t,e),t.addEventListener(`abort`,e,{once:!0})}return!a&&t!==void 0&&(i=setTimeout(()=>s(new DOMException(`The wait timed out`,`TimeoutError`)),t)),{signal:n.signal,dispose:o}}var Ja={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`},Ya=`/api/v1/events`,Xa=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Za(e,t){if(Xa.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 P.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 P.pageBytes}return P.controlBytes}function Qa(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function $a(e,t){switch(e){case`workbenchRead`:return ri(t);case`workbenchCommand`:return ai(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new F(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Lt(t);if(n.reader!==e)throw new F(`invalid`);return n}case`current`:return an(t);case`currentChanges`:return on(t);case`checkObligations`:case`receipt`:return K(t);case`entity`:return en(t);case`graph`:return Gt(t);case`snapshot`:return ze(t);case`detail`:case`search`:return Ve(t);case`export`:case`download`:return Jt(t);case`chooseModel`:return yn(t);case`preflight`:return ke(t);case`command`:return Ae(t);case`cancel`:return Me(t)}}function eo(e,t){if(Xa.includes(e))return Q(t,Ut);switch(e){case`workbenchRead`:case`workbenchCommand`:return Q(t,Ci);case`current`:return Q(t,dn);case`currentChanges`:return Q(t,fn);case`activeRuns`:return Q(t,at);case`models`:return Q(t,Cn);case`chooseModel`:return Q(t,vn);case`session`:return Q(t,Ot);case`workspace`:return Q(t,kt);case`checkObligations`:return Q(t,$t);case`entity`:return Q(t,nn);case`graph`:return Q(t,qt);case`snapshot`:return Q(t,gt);case`detail`:return Q(t,bt);case`search`:return Q(t,St);case`preflight`:return Q(t,Pe);case`command`:case`cancel`:return Q(t,ut);case`receipt`:return ft(t);case`detach`:return Q(t,e=>{if(e!==null)throw new F(`invalid`);return null});default:throw new F(`invalid`)}}function to(e){return[...Xa,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function no(e,t){let n=Ja[e];return t===null||Qa(e)?n:`${n}?request=${encodeURIComponent(J(t))}`}function ro(e,t){let n=$a(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ja[e]:no(e,n);return Qa(e)||to(e)&&(r||R(i)>P.headerBytes/4)?{path:Ja[e],method:`POST`,body:J(n)}:{path:i,method:`GET`}}function io(e){J(e,P.viewerBytes);let t=V(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:gt(W(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:_t(W(e,[`kind`,`event`]).event)}:(W(e,[`kind`]),{kind:t})}var ao=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 F(`invalid`);this.origin=e.origin,e.build&&=ct(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,t=!1){let n={"Cache-Control":`no-store`};if(this.options.build&&(n[`X-Cadence-Build`]=J(this.options.build)),this.attachment&&(e||t)&&(n[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(n[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new F(`stale`);n[`Content-Type`]=`application/json`,this.csrf&&(n[`X-Cadence-CSRF`]=this.csrf)}return n}async request(e,t,n){let r=ro(e,$a(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:qa([n],this.options.requestTimeoutMs),o=a?.signal??n;try{if(o?.aborted)throw o.reason;e===`session`&&(this.attachment??=crypto.randomUUID());let t=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i,e===`session`),credentials:`same-origin`,redirect:`error`,signal:o,...i?{body:r.body}:{}}),n;try{if(e===`session`&&t.ok&&(n=K(t.headers.get(`x-cadence-attachment`)),n!==this.attachment))throw new F(`invalid`)}catch(e){throw await t.body?.cancel().catch(()=>{}),e}let a=await oo(t,Za(e)),s=ue(a);if(R(a)>Za(e,s))throw new F(`oversize`);let c=eo(e,s);if(e===`session`){let e=Q(c,Ot);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new F(`forbidden`);this.attachment=n??K(t.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return c}finally{a?.dispose()}}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,yn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,K(e),t)}entity(e,t){return this.request(`entity`,en(e),t)}tasks(e,t){return this.request(`tasks`,Lt(e),t)}runs(e,t){return this.request(`runs`,Lt(e),t)}messages(e,t){return this.request(`messages`,Lt(e),t)}tools(e,t){return this.request(`tools`,Lt(e),t)}contents(e,t){return this.request(`contents`,Lt(e),t)}events(e,t){return this.request(`events`,Lt(e),t)}checks(e,t){return this.request(`checks`,Lt(e),t)}changes(e,t){return this.request(`changes`,Lt(e),t)}reviews(e,t){return this.request(`reviews`,Lt(e),t)}graph(e,t){return this.request(`graph`,Gt(e),t)}preflight(e){return this.request(`preflight`,ke(e))}command(e){return this.request(`command`,Ae(e))}cancel(e){return this.request(`cancel`,Me(e))}receipt(e,t){return this.request(`receipt`,K(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;if(!this.options.localCapability&&!this.csrf){let t=Q(await this.session(),Ot);if(t.kind===`error`){if(![`stale`,`unauthenticated`].includes(t.error.code))throw new F(t.error.code);return this.attachment===e&&(this.attachment=void 0),t}}let t=Q(await this.request(`detach`,null),e=>{if(e!==null)throw new F(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw t.error.code===`forbidden`&&!this.options.localCapability&&this.attachment===e&&(this.csrf=null),new F(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=ro(`export`,Jt(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new F(`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 F(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=P.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+P.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
14
15
|
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield Yt(ue(e,P.controlBytes)),r=o.indexOf(`
|
|
15
|
-
`)}if(new TextEncoder().encode(o).length>P.controlBytes)throw new F(`oversize`)}if(n){if(o)throw new F(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=ze(e);if(!this.attachment||!this.options.socket)throw new F(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${La}?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>=P.staleMs&&u(`stale`);try{Date.now()-c>=P.reconcileMs?(i.send(J({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},P.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(J({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new F(`invalid`);let n=Ka(ue(e.data,P.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Ja(e,t){if(!e.body)throw new F(`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 F(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Ya={sourceHash:`a9d44553f1e157e046ca32ffc6cd0eb358de99e5989ab6f59565cfc291b8a02e`,contractHash:`103e212eee402600c29002528ccc3808b6fbe11ccee275a4d5f2a3d52576c520`,buildId:`7b479c8acc1e3233b2e4431ab026bb5d941452e43b98ee34eea5617f8fafd7ca`};function Xa(e){let t=new qa({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...Ya?{build:{kind:`browser`,...Ya}}:{},socket:e=>new WebSocket(e)});return{client:new Na(t),transport:t}}function Za(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function Qa(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var $a=[],eo=null,to,no,ro=new Set;function io(){let e=Qa($a,performance.now());if(e!==eo){eo=e;for(let e of ro)e()}}function ao(e){if(ro.add(e),ro.size===1&&typeof PerformanceObserver<`u`)try{to=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=Za(t,location.origin);e&&($a=[...$a.slice(-19),e])}io()}),to.observe({type:`resource`,buffered:!0}),no=setInterval(io,5e3)}catch{to=void 0}return()=>{ro.delete(e),!ro.size&&(to?.disconnect(),to=void 0,clearInterval(no),$a=[],eo=null)}}function oo(){return(0,m.useSyncExternalStore)(ao,()=>eo,()=>null)}function so(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?pn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function co(e=typeof window>`u`?``:window.location.search){return so(e,``).project}function lo(e=typeof window>`u`?``:window.location.hash){return so(``,e).chat}function uo(){let e=co();return e?`/projects/${e}`:``}function fo(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&so(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?Pr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function po(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Pr(t)),`#${n}`}function mo(e,t){if(typeof window>`u`||lo()!==e)return;let n=po(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function ho(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&&ce(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&&J(t.settlement)!==J(r.settlement))?i=!0:(!r||ce(t.committedSeq,r.committedSeq)>0||J(r)===J(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 go(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)({key:r,revision:-1});(0,m.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(Gr(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,m.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function _o(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function vo(e,t,n=!1){let[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)([]),s=go(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}async function yo(e){return ue(await Ja(e,1048576),1048576)}function bo(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 xo(e){let t=Error(bo(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function So(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await yo(r);if(!r.ok)throw Error(bo(i));return t(i)}function Co(e){return So(`/workbench/v1/service`,zn,e)}function wo(e){return So(`/workbench/v1/service/release`,Bn,e)}async function To(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await yo(n);if(!n.ok)throw Error(bo(r));let i=W(r,[`kind`,`job`]);return H(i.kind,`service-job`),In(i.job)}function Eo(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function Do(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function Oo(e,t){let[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useRef)(0),[o,s]=(0,m.useState)({});(0,m.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await yo(r);if(!r.ok)throw Error(bo(a));let c=Tn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...Do(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...Do(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,m.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:Eo(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var ko=e=>e===`unauthenticated`||e===`forbidden`,Ao=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.attached&&!t.error&&t.transportStatus===`current`&&a()},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Pa,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=()=>{clearTimeout(o),v()&&!h&&(o=setTimeout(C,1e3))},S=e=>{this.serial=this.serial.then(e).catch(e=>{v()&&!h&&(s.abort(),u++,i?.(),_.attached=!1,_.error=e instanceof Error?e.message:`unavailable`,_.actions=!1,_.transportStatus=`stale`,y(),x())})},C=()=>{!v()||h||f||(clearTimeout(o),f=!0,S(async()=>{try{await D()}finally{f=!1}}))},w=async()=>{await this.api.transport.detach()},T=async(t=!0)=>{if(!v()||!_.attached||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{if(t){let e=await this.api.client.session(r);if(!v()||r.aborted)return;if(e.kind===`error`){_.actions=!1,_.error=e.error.code,ko(e.error.code)&&E();return}if(e.value.epoch!==_.epoch){_.error=`stale`;return}g=e.value.capabilities.actions}e||(_.transportStatus=`current`);let i=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(i.kind===`ok`){if(i.value.epoch!==_.epoch){_.error=`stale`;return}_.activeRuns=i.value}else if(ko(i.error.code)){E();return}else _.activeRuns=void 0;y();let a=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(a.kind===`error`){_.error=a.error.code,ko(a.error.code)&&E();return}if(a.value.epoch!==_.epoch){_.error=`stale`;return}if(_.workspace=a.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,ko(i.error.code)&&E();else if(i.value.epoch!==_.epoch)_.error=`stale`;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()&&!r.aborted&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,v()&&!r.aborted&&(m=!n,_.actions=n&&g,y(),!n&&_.error===`stale`&&C())}},E=()=>{h=!0,_.attached=!1,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Pa,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),S(w),y()},D=async()=>{if(!v()||h||(_.attached=!1,_.actions=!1,s.abort(),u++,i?.(),await w(),!v()||h))return;let t=await this.api.client.session();if(!v()||h){await w();return}if(t.kind===`error`){if(ko(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Pa,_={epoch:t.value.epoch,attached:!0,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},g=t.value.capabilities.actions,y(),await T(!1),!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`&&T():T();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(_.attached=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,x()),y())})};return C(),this.pollCurrent=()=>{_.attached?T():C()},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&T())},1e3),()=>{v()&&(b(),S(w))}}};function jo(e,t,n,r){let i=(0,m.useMemo)(()=>new Ao(e),[e]),[a,o]=(0,m.useState)(0),[s,c]=(0,m.useState)({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,m.useEffect)(()=>{if(c({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:()=>i.refresh(),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var Mo=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function No({client:e,value:t,onChange:n}){let{t:r,tx:i}=D(),a=(0,m.useRef)(!0),o=(0,m.useRef)(null);(0,m.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,m.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,_.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,_.jsx)(`h3`,{children:r(`Command receipt`)}),(0,_.jsx)(`code`,{children:t.commandId}),t.error&&(0,_.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:r(`Admission`)}),(0,_.jsx)(`dd`,{children:i(l.admission)}),(0,_.jsx)(`dt`,{children:r(`Execution`)}),(0,_.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,_.jsx)(`dt`,{children:r(`Publication`)}),(0,_.jsx)(`dd`,{children:i(l.publication)}),(0,_.jsx)(`dt`,{children:r(`Run`)}),(0,_.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,_.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,_.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 Po(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 Fo(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 Io(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 Lo(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=Po(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 Ro(e,t){let n=t?J({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(t),[d,f]=(0,m.useState)([]),p=(0,m.useRef)(0),[h,g]=(0,m.useState)(n);return h!==n&&(p.current++,g(n),i(void 0),c(void 0),u(t),f([])),(0,m.useEffect)(()=>{let t=++p.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),Fo(e,l,n.signal).then(e=>{t===p.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===p.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),p.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&f(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),f(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),f([]),u(t?{...t}:null)}}}function zo({value:e,compact:t=!1}){let{t:n,tx:r}=D();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,_.jsxs)(`details`,{className:`coverage-details`,children:[(0,_.jsx)(`summary`,{children:n(`Recording details`)}),(0,_.jsx)(zo,{value:e})]}):(0,_.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 Bo(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 Vo(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Bo(e)}return Bo(e)}function Ho(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,m.useRef)(!0),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null),c=(0,m.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,m.useCallback)(()=>{c(),o(!1)},[c]);return(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,m.useCallback)(async e=>{let a=!1;try{a=await Vo(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 Uo(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
16
|
-
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,m.createElement)(n.type,i)]]:a.map(e=>[(0,m.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Wo=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Go(!0)},text:{92:Go(!1)}});let t={enter:{backslashMathInline:Ko,backslashMathDisplay:Ko,backslashMathBlock:Ko},exit:{backslashMathInline:qo,backslashMathDisplay:qo,backslashMathBlock:qo}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Go(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 Ko=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)},qo=function(e){this.exit(e)};function Jo(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var Yo=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function Xo(e,t,n=3){let r=[...e.filter(e=>!Yo(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var Zo=[],Qo=1,$o=new Set;function es(e){if(!(e.length===Zo.length&&e.every((e,t)=>e===Zo[t]))){Zo=e;for(let e of $o)e()}}function ts(e,t,n){let r=Qo++;return es(Xo(Zo,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function ns(e){es(Zo.filter(t=>t.id!==e))}function rs(e){es(Zo.filter(t=>t.key!==e))}function is(e){return $o.add(e),()=>{$o.delete(e)}}var as=()=>Zo,os=(0,m.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=D(),{copied:r,copy:i}=Ho();return(0,_.jsx)(`button`,{type:`button`,className:r?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(e).then(e=>{e||ts(`error`,n(`Copy unavailable`))})},children:r?(0,_.jsx)(Ca,{}):(0,_.jsx)(ha,{})})}),ss=[c,f,Wo],cs=[c,u,f,Wo],ls=[[l,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[d,{detect:!1,ignoreMissing:!0}]];function us(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 ds({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,_.jsx)(a,{remarkPlugins:n?cs:ss,rehypePlugins:t?[i,o,...ls]:ls,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ms,a:ps,img:({alt:e})=>(0,_.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var fs=(0,m.memo)(function(e){return(0,_.jsx)(`div`,{className:`md`,children:(0,_.jsx)(ds,{...e})})});function ps({href:e,children:t}){let n=e&&us(e);return n?(0,_.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,_.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function ms({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Uo(r).map(e=>{let t=`code-offset:${i}`;return i+=hs(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,_.jsxs)(`div`,{className:`codeblock`,children:[(0,_.jsx)(os,{text:hs(e)}),(0,_.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,_.jsxs)(`div`,{className:`code-line`,children:[o&&(0,_.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,_.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function hs(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(hs).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return hs(t?.children)}return``}function gs(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 _s=new Map;function vs(e,t){t.length?_s.set(e,t):_s.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[..._s].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 ys(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 bs(e,t){let n=t.startContainer.parentElement;for(let r of ys(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 xs({container:e,version:t}){let{t:n}=D(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(0),[s,c]=(0,m.useState)(0),l=(0,m.useRef)([]),u=`cadence-page-${(0,m.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,m.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?gs(n,r):[];return l.current=i,c(i.length),o(0),vs(u,i),()=>vs(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(bs(e.current,l.current[n]),vs(`${u}-active`,[l.current[n]]))};return(0,m.useEffect)(()=>()=>vs(`${u}-active`,[]),[u]),(0,_.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,_.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,_.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,_.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,_.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,_.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function Ss({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=D(),s=J(t),c=(0,m.useMemo)(()=>Ve(JSON.parse(s)),[s]),[l,u]=(0,m.useState)(t),[d,f]=(0,m.useState)(),[p,h]=(0,m.useState)([]),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(),[x,S]=(0,m.useState)(i?`markdown`:`raw`),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),E=(0,m.useRef)(null);(0,m.useEffect)(()=>(u(c),h([]),f(void 0),b(void 0),()=>T.current?.abort()),[c]),(0,m.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):f(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(T.current)return;let n=new AbortController;T.current=n,w(a(`Reading all retained field pages…`));try{let r=await Lo(e,t,n.signal);if(n.signal.aborted)return;let i=await Vo(r.text);if(n.signal.aborted)return;w(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||w(a(`Full-field copy refused/incomplete.`))}finally{T.current===n&&(T.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,_.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,_.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,_.jsx)(`summary`,{children:a(`Field details`)}),(0,_.jsxs)(`div`,{className:`detail-identity`,children:[(0,_.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,_.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,_.jsx)(`button`,{type:`button`,disabled:!!T.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!T.current&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>{T.current?.abort(),T.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,_.jsx)(`p`,{role:`status`,children:C}),y&&(0,_.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),g&&(0,_.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,_.jsx)(zo,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,_.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,_.jsxs)(_.Fragment,{children:[(!i||k.next)&&(0,_.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,_.jsx)(xs,{container:E,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,_.jsx)(`div`,{ref:E,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,_.jsx)(fs,{text:k.text}):(0,_.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,_.jsxs)(_.Fragment,{children:[i(0,e),(0,_.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||p.length>0||d?.next)&&(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:g||!p.length,onClick:()=>{u(p[p.length-1]),h(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,_.jsx)(`button`,{type:`button`,disabled:g||!d?.next,onClick:()=>{d?.next&&(h(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function Cs({pager:e,compact:t=!1}){let{t:n,tx:r}=D(),{page:i,busy:a,error:o}=e;return(0,_.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,_.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,_.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,_.jsx)(zo,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,_.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,_.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,_.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,_.jsx)(Ri,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,_.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function ws({client:e,seed:t,entityId:n}){let{t:r,tx:i}=D(),a=Ro(e,{...t,reader:`contents`}),[o,s]=(0,m.useState)(),c=a.page;return(0,_.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,_.jsx)(Cs,{pager:a}),n&&(0,_.jsx)(`p`,{children:(0,_.jsx)(C,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,_.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,_.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,_.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,_.jsxs)(`article`,{children:[(0,_.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,_.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,_.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,_.jsx)(zo,{value:e.coverage}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Io(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,_.jsx)(Ss,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ts({client:e,seed:t}){return(0,_.jsx)(Es,{client:e,seed:t},J(t))}function Es({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1);return(0,m.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,_.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,_.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,_.jsx)(zo,{value:o.coverage}),o&&(`kind`in o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,_.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,_.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function Ds(e){let t=Ga(`download`,Jt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=uo()+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 Os({title:e,children:t,onClose:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useId)(),o=(0,m.useRef)(n);return o.current=n,(0,m.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,_.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(`h2`,{id:a,children:e}),n&&(0,_.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,_.jsx)(Di,{"aria-hidden":`true`})})]}),t]})}function ks({request:e,onClose:t}){let{t:n,tx:r}=D(),[i]=(0,m.useState)(e),[a,o]=(0,m.useState)(e.format),[s,c]=(0,m.useState)(``);return(0,_.jsxs)(Os,{title:n(`Export retained history`),onClose:t,children:[(0,_.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,_.jsxs)(`label`,{children:[n(`Format`),(0,_.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,_.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,_.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,_.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,_.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,_.jsx)(`button`,{type:`button`,onClick:()=>{try{Ds({...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,_.jsx)(`p`,{role:`status`,children:s})]})}function As(e,t){if(!t||R(t)>P.queryBytes)throw Error(`Query must be 1–${P.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Ve({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function js(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 Ms({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=D(),[o]=(0,m.useState)(t),s=(0,m.useRef)(null),c=(0,m.useRef)(0),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(0),[p,h]=(0,m.useState)(),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(),x=(0,m.useRef)(null),S=(0,m.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):(h(i.value),f(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,m.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,m.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),h(void 0),f(0),b(void 0),!l)return;let t;try{t=As(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,_.jsx)(Os,{title:i(`Search retained history`),onClose:n,children:(0,_.jsxs)(`div`,{className:`gs-modal`,children:[(0,_.jsxs)(`div`,{className:`gs-input-row`,children:[(0,_.jsx)(Ii,{}),(0,_.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(),f(e=>Math.max(0,Math.min(e+1,(p?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),f(e=>Math.max(e-1,0))),e.key===`Enter`&&p?.hits[d]&&(e.preventDefault(),r(p.hits[d]),n())}})]}),(0,_.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,_.jsxs)(`div`,{className:`gs-results`,children:[g&&(0,_.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,_.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,_.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),p&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(zo,{value:p.coverage}),(0,_.jsxs)(`div`,{className:`gs-section`,children:[(0,_.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:p.hits.length})}),p.hits.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>f(t),onClick:()=>{r(e),n()},children:[(0,_.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,_.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,_.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}`)),p.hits.length===0&&(0,_.jsx)(`p`,{children:a(js(p))})]}),(0,_.jsx)(`button`,{type:`button`,disabled:g||!p.next,onClick:()=>{p.next&&S(p.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,_.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Ns({run:e,historical:t=!1}){let{t:n,tx:r}=D();return(0,_.jsxs)(`article`,{className:`run-summary`,children:[(0,_.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,_.jsx)(`p`,{children:(0,_.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,_.jsx)(`dd`,{children:r(e.lifecycle)}),(0,_.jsx)(`dt`,{children:n(`Execution`)}),(0,_.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,_.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,_.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,_.jsx)(`dt`,{children:n(`Summary publication`)}),(0,_.jsx)(`dd`,{children:r(e.publication)})]}),(0,_.jsx)(zo,{value:e.coverage}),(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,_.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Ps({client:e,seed:t}){return(0,_.jsx)(Fs,{client:e,seed:t},J(t))}function Fs({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1);return(0,m.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,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,_.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,_.jsx)(zo,{value:o.coverage}),o&&(`kind`in o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,_.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Ss,{client:e,cursor:Io(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,_.jsxs)(`article`,{children:[(0,_.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,_.jsx)(fs,{text:e.instructions}),(0,_.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,_.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function Is({client:e,seed:t,onScope:n}){let{t:r}=D(),i=Ro(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,m.useState)();return(0,_.jsxs)(`section`,{children:[(0,_.jsx)(Cs,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,_.jsxs)(`article`,{children:[(0,_.jsx)(Ns,{run:e.projection,historical:!0}),(0,_.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,_.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,_.jsx)(Ps,{client:e,seed:o},o.graph.recordId)]})}function Ls({onOpen:e,disabled:t}){let{t:n}=D();return(0,_.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,_.jsx)(Ii,{"aria-hidden":`true`})})}function Rs(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 zs(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 Bs(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)??Vs(n.role,n.customType)}return r}function Vs(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 Hs(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Us(e,t,n=null,r=1800,i){let a=(0,m.useRef)(i);a.current=i;let o=(0,m.useRef)(null),[s,c]=(0,m.useState)(()=>new Set),l=(0,m.useRef)(s);l.current=s;let u=(0,m.useRef)(new Map),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=(0,m.useRef)(0),h=(0,m.useRef)(new Map);h.current=new Map(t.map(e=>[e.id,e.version]));let g=(0,m.useRef)(new Set);g.current=Bs(t,u.current,r),n!==null&&g.current.add(n);let _=(0,m.useCallback)((e,t)=>{let n=h.current.get(e);n!==void 0&&(d.current.set(e,{h:t,len:n}),u.current.set(e,t))},[]),v=(0,m.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of f.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),l.current.has(e)||_(e,n.height)}let i=Rs(r,{top:n.top-1200,bottom:n.bottom+1200},g.current,l.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=f.current.get(e);t&&_(e,t.offsetHeight)}c(e=>zs(e,i))},[_,e]),y=(0,m.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,v()})},[v]);return(0,m.useLayoutEffect)(()=>{t.length?v():c(new Set)},[v,t,n]),(0,m.useEffect)(()=>{let t=new ResizeObserver(()=>{y(),a.current?.()});o.current=t,e.current&&t.observe(e.current);for(let e of f.current.values())t.observe(e);return()=>{o.current=null,t.disconnect(),cancelAnimationFrame(p.current),p.current=0}},[y,e]),{hidden:s,scheduleSweep:y,recordMeasured:_,register:(0,m.useCallback)(e=>t=>{let n=f.current.get(e);n&&n!==t&&o.current?.unobserve(n),t?(f.current.set(e,t),o.current?.observe(t)):f.current.delete(e)},[]),placeholder:(0,m.useCallback)((e,t,n)=>Hs(e,t,d.current,n),[])}}function Ws(e,t){e&&t&&(e.scrollTop=e.scrollHeight)}function Gs(e,t,n){(0,m.useEffect)(()=>{let r=new ResizeObserver(()=>Ws(e.current,n.current));return t.current&&r.observe(t.current),()=>r.disconnect()},[e,t,n])}var Ks=(0,m.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,m.useRef)(null);return(0,m.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,_.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,_.jsx)(`div`,{ref:s,children:o})}):(0,_.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),qs=(0,m.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=D(),[a,o]=(0,m.useState)(!1);return(0,_.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,_.jsxs)(`header`,{className:`msg-meta`,children:[(0,_.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,_.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,_.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,_.jsx)(ya,{"aria-hidden":`true`}):(0,_.jsx)(sa,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,_.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,_.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,_.jsx)(`div`,{className:`msg-text`,children:(0,_.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,_.jsx)(Ss,{compact:!0,client:t,cursor:Io(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,_.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,_.jsxs)(`div`,{className:`message-inspection`,children:[(0,_.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,_.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,_.jsxs)(`details`,{open:!0,children:[(0,_.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,_.jsx)(ws,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Js({messages:e,client:t,seed:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useRef)(!0),o=(0,m.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=Us(i,o);return(0,_.jsxs)(`div`,{className:`messages-wrap`,children:[(0,_.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,_.jsx)(Ks,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,_.jsx)(qs,{message:a,client:t,seed:n})},e))}),(0,_.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,_.jsx)(Oa,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Ys({client:e,seed:t}){let{t:n}=D(),r=Ro(e,{...t,reader:`messages`}),i=r.page;return(0,_.jsxs)(`section`,{className:`transcript`,children:[(0,_.jsx)(Cs,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,_.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,_.jsxs)(_.Fragment,{children:[i.records.length===0&&(0,_.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,_.jsx)(Js,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Xs({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,_.jsxs)(`div`,{className:`chead ${n}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,_.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,_.jsx)(Sa,{}):(0,_.jsx)(ba,{})}):c,(0,_.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,_.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Zs=(0,m.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=D(),[a,o]=(0,m.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,_.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,_.jsx)(Xs,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,_.jsx)(ki,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.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,_.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,_.jsxs)(`div`,{className:`toolcall-body`,children:[(0,_.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:r(`Source ID`)}),(0,_.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,_.jsx)(`dt`,{children:r(`Declaration`)}),(0,_.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,_.jsxs)(`div`,{className:`toolcall-output`,children:[(0,_.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,_.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,_.jsx)(`div`,{className:`toolcall-args`,children:(0,_.jsx)(ws,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Qs=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function $s({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=D(),s=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(Qs(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length),c=!!t||e?.completeness===`partial`;return!s?.length&&!c?null:(0,_.jsx)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:(0,_.jsxs)(`div`,{className:`lp-section-body`,children:[c&&(0,_.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),s?.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,_.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,_.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})})}function ec(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 tc(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var nc=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function rc(e,t){return nc.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function ic(e){let t=tc(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function ac(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>ec(e.id)===n.id),...r?{artifact:r}:{}}})}var oc=[`queued`,`running`];function sc(e,t){let n=e=>Number(!oc.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function cc(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(ec(t.id))):!1}var lc=[`queued`,`running`],uc=4,dc=1e4;function fc(e,t,n=2e3){let[r,i]=(0,m.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,m.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,m.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?lc.includes(t.status):i-(u.get(e)??0)>=dc}).reverse();for(let n=0;n<a.length;n+=uc){let r=await Promise.all(a.slice(n,n+uc).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+uc<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>lc.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),dc))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function pc({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=D(),o=tc(e),s=n?.runId===e.id?n.stepId:void 0;return(0,_.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${s===null?` active`:``}`,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,_.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,_.jsx)(`span`,{className:`agent-dock-run-state`,children:rc(o,i)})]}),t.map(t=>{let n=ec(t.id),o=e.tasks?.find(e=>e.id===n);return(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-row${s===t.id?` active`:``}`,title:o?`${o.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:n}),children:[(0,_.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,_.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,_.jsx)(`strong`,{children:`${a(t.kind)} · ${n}`}),o&&(0,_.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(o.state)})})]}),(0,_.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function mc({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=D(),[d,f]=(0,m.useState)(null),[p,h]=(0,m.useState)([]),[g,v]=(0,m.useState)(!1),y=fc(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,m.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||(h(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=[...p,...x.filter(e=>!p.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=sc(a,y.runs),w=C.flatMap(e=>e.steps),T=S.length+w.length,E=w.filter(e=>lc.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,O=d??(T>0||!!g);return(0,_.jsxs)(`section`,{className:`agent-dock${O?``:` collapsed`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":O,onClick:()=>f(!O),children:[(0,_.jsx)(Sa,{}),(0,_.jsx)(fa,{}),(0,_.jsx)(`span`,{children:l(`Subagents`)}),(0,_.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:T}):T})]}),O&&(0,_.jsxs)(`div`,{className:`agent-dock-body`,children:[(g||t?.status!==`complete`||y.failed)&&(0,_.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),T===0&&!g&&t?.status===`complete`&&(0,_.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,steps:t})=>(0,_.jsx)(pc,{run:e,steps:t,selected:o,onOpen:c},e.id)),S.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,_.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,_.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,_.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,_.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,_.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}function hc(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function gc(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var _c=e=>e.filter(e=>e.current);function vc(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function yc(e,t,n,r,i){let[a,o]=(0,m.useState)();(0,m.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=go(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,m.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,f]=(0,m.useState)();return(0,m.useEffect)(()=>{u&&f(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function bc({view:e,onChosen:t}){let{t:n,locale:r}=D(),[i,a]=(0,m.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,m.useMemo)(()=>hc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,_.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,_.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,_.jsxs)(`label`,{className:`lp-filter`,children:[(0,_.jsx)(Ii,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,_.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,_.jsx)(Ri,{"aria-hidden":`true`})})]}),(0,_.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,_.jsxs)(`p`,{className:`branches-pinned`,children:[(0,_.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:S(n,e.error)}),s?.truncated&&(0,_.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,_.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,_.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,_.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,_.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,_.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,_.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,_.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,_.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,_.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,_.jsx)(la,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,_.jsx)(ma,{"aria-hidden":`true`})})]},t.id))})]})}function xc(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function Sc(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function Cc(e,t){return Math.round(e/t*100)}var wc=e=>e.trim().split(`
|
|
17
|
-
`,1)[0].slice(0,200);function Tc(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var Ec=(e,t)=>e?e.entry:t,Dc=(e,t)=>e!==null&&t>=e.from;function Oc(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:Pr(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function kc(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function Ac(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function jc(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function Mc(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function Nc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var Pc=2e4;async function Fc(e,t,n,r){let i=Fa([t],Pc);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Ic(e,t){if(t===`none`)return`Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.`;switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function Lc(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function Rc(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function zc(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Bc(e){let t={commandId:crypto.randomUUID(),conversationId:pn(e.id),head:e.head===null?null:Pr(e.head)},n=e.location?mn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new F(`stale`);let r=L(e.text,Ir,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:z(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:z(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze(Vc(e.model))}:{}})}function Vc(e){return ge({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Hc(e,t){return Object.freeze({...e,model:Object.freeze(Vc(t))})}function Uc(e,t){if(e.model&&J(e.model)!==J(Vc(t)))throw new F(`stale`)}function Wc(e,t){return Object.freeze({...e,preparedEpoch:K(t)})}function Gc(e,t,n){return Object.freeze({...Hc(e,t),installModel:!n})}function Kc(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function qc(e,t){return!!e&&e===t}async function Jc(e,t,n,r){if(!r())throw new F(`stale`);if(!t.installModel||!t.model)return n;if(!xn(n.entries,t.model))throw new F(`unsupported-context`);if(n.selected&&J(Vc(n.selected))===J(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new F(`stale`);if(i.kind===`error`)throw new F(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new F(`stale`);if(a.kind===`error`)throw new F(a.error.code);if(!a.value.selected||J(a.value.version)!==J(i.value.version)||J(a.value.selected)!==J(i.value.selected))throw new F(`stale`);return Uc(t,a.value.selected),a.value}function Yc(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&J(e.location)!==J(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new F(`stale`);let n=qr(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new F(`invalid`);return n}function Xc(e,t,...n){let r=`cadence:draft:${e}:${t}`;try{let e=e=>[e,`${e}:pending`,`${e}:mode`].some(e=>sessionStorage.getItem(e)!==null);if(e(r))return r;for(let r of n){if(!r)continue;let n=`cadence:draft:${r}:${t}`;if(e(n))return n}}catch{}return r}function Zc(e){for(let t of e){if(!Un.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function Qc(e){Zc([e]);let t=new Uint8Array(await e.arrayBuffer());return Gn(t,e.type),t}var $c=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)};async function el(e,t,n,r){Zc(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await Qc(a);if(!r())throw Error(`stale`);let o=$c(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Hn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Hn.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function tl(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>Hn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Hn.chunkChars)throw Error(`invalid`)}let i=Wn(n.join(``));return Gn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var nl=e=>e.renderId??`legacy:${e.id}`;function rl(e,t){let n=new Map(e.map(e=>[nl(e),e])),r=new Set;return t.map(e=>{let t=nl(e);if(r.has(t))throw new cl(`stale`);r.add(t);let i=n.get(t);return i&&JSON.stringify(i)===JSON.stringify(e)?i:e})}var il=1e3,al=1e4,ol=4,sl=e=>e===`queued`||e===`running`,cl=class extends Error{},ll=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;cache;count=0;first=null;opening=null;turns=new Map;imageReaders=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...this.cache?{cache:this.cache}:{},count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof cl?e.message:`unavailable`)}finally{this.running=!1}if(this.closed)return;if(e&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=this.error===`stale`||sl(this.summary?.status)||[...this.turns.values()].some(e=>sl(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?il:al)}async sync(e){let t=this.pinned,n=await this.read({kind:`conversation`,id:this.id,leaf:t,known:this.leaf},e);if(e.aborted)return;if(n.kind!==`conversation`)throw new cl(`invalid`);let r=!n.continues||n.turns<this.count,i=n.leaf===this.leaf?this.count:this.count-1,a=Math.max(0,n.turns-2),o=Math.min((r?null:this.first)??this.opening??a,a),s=[];for(let e=o;e<n.turns;e++){let t=r?void 0:this.turns.get(e);(!t||e>=i||t.header.stable<t.header.steps||sl(t.header.status))&&s.push(e)}let c=await Promise.all(s.map(t=>this.load(t,n.leaf,e,r?void 0:this.turns.get(t))));if(!e.aborted){r&&this.forget(),this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.pending=n.pending??[],this.undelivered=n.undelivered??[],this.commands=n.commands??[],this.context=n.context,this.cache=n.cache,this.summary=n.summary,this.count=n.turns,this.first=Math.min(o,this.first??o),this.opening=null;for(let e of c)this.turns.set(e.ordinal,e)}}async load(e,t,n,r){let i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,a.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{let n=i.start+t;if(r?.header.id===a.id&&n<Math.min(r.header.stable,a.stable)&&nl(r.steps[n])!==nl(e))throw new cl(`stale`);o[n]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n)))){if(JSON.stringify(r.turn)!==JSON.stringify(a))throw new cl(`stale`);r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)})}if(n.aborted||o.includes(void 0))throw new cl(`stale`);let l=rl(r?.steps??[],o);return r&&r.image===this.imageReader(t,n)&&JSON.stringify(r.header)===JSON.stringify(a)&&r.steps.length===l.length&&l.every((e,t)=>e===r.steps[t])?r:{ordinal:e,renderId:l.find(e=>e.role===`user`)?.renderId??a.id,header:a,steps:l,detail:this.detail(t,a.id,l,n),image:this.imageReader(t,n)}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new cl(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Fa([t,r]);try{return await tl(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n,r){return async(i,a,o)=>{let s=n[i];if(!s)throw new cl(`stale`);let c=await Promise.all(Array.from({length:a},async(n,a)=>{let c=Fa([r,o]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:i,part:a},c.signal);if(n.kind!==`conversation-step`||n.part!==a||n.conversationId!==this.id||n.leaf!==e||n.turnId!==t||n.step!==i)throw new cl(`invalid`);if(s.renderId&&n.item.renderId!==s.renderId||s.version&&n.item.version!==s.version)throw new cl(`stale`);return n.item}finally{c.dispose()}}));return{text:c.map(e=>e.text).join(``),args:c.map(e=>e.args).join(``)}}}async read(e,t=this.abort.signal){this.reads>=ol&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new cl(`stale`);let n=await this.client.workbenchRead(e,t);if(this.closed||t.aborted)throw new cl(`stale`);if(n.kind===`error`)throw new cl(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function ul(e,t,n,r=null){let i=(0,m.useMemo)(()=>({client:e,id:t,initialLeaf:r}),[e,t,r]),a=(0,m.useRef)(i);a.current=i;let[o,s]=(0,m.useState)();(0,m.useEffect)(()=>{let n=new ll(e,t,()=>{a.current===i&&s({scope:i,reader:n,view:n.view()})});return n.choose(r),s({scope:i,reader:n,view:n.view()}),()=>n.close()},[e,t,r,i]);let c=o?.scope===i?o:void 0,l=c?.reader,u=c?.view;return(0,m.useEffect)(()=>{l?.setActive(n)},[l,n]),{...u??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:l?.refresh??dl,loadEarlier:l?.loadEarlier??dl,showFrom:l?.showFrom??dl,choose:l?.choose??dl}}function dl(){}function fl(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`preparing`?r:void 0,[s,c]=(0,m.useState)(0),l=(0,m.useRef)(0),u=(0,m.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,preview:o}),[e,i,a,n,o]),d=(0,m.useRef)(null),f=(0,m.useMemo)(()=>({...u,revision:s,reload:d.current===u}),[u,s]),p=(0,m.useRef)(f);p.current=f;let h=(0,m.useRef)(!0);(0,m.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,m.useCallback)(()=>h.current&&(f.epoch!==null||!!f.preview)&&p.current===f&&l.current===f.revision,[f]),[_,v]=(0,m.useState)();(0,m.useEffect)(()=>{if(f.epoch===null&&!f.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&g();return f.preview?(f.preview(t.signal).then(e=>{n()&&v({scope:f,preview:e})}).catch(e=>{n()&&v({scope:f,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal,f.reload).then(e=>{n()&&(e.kind===`error`?v({scope:f,error:e.error.code}):e.value.version.epoch===f.epoch?v({scope:f,catalog:e.value}):v({scope:f,error:`stale`}))}).catch(()=>{n()&&v({scope:f,error:`unavailable`})}),()=>t.abort())},[e,f,g]);let y=_?.scope===f&&g()?_:void 0;return{catalog:y?.catalog,preview:y?.preview,error:y?.error,loading:(i!==null||!!o)&&!y,isCurrent:g,reread(e=!1){g()&&(d.current=e?u:null,c(++l.current))},accept(e){return!g()||e.version.epoch!==f.epoch?!1:(v({scope:f,catalog:e}),!0)}}}function pl(e,t,n,r=!1){return t?r||!n||J(n)!==J(e.model)?`validate`:`approve`:`restore`}async function ml(e){let t=structuredClone(e.state),n=t.proposal,r=structuredClone(e.context),i={id:r.id,cwd:r.cwd},a=structuredClone(e.model),o=e.head,s=crypto.randomUUID(),c=()=>!e.signal.aborted&&e.current();if(!n||!t.enabled||r.id!==t.id||!c()||(e.prepare&&await Fc(e.prepare,e.signal,i,e.progress??(()=>{})),!c()))throw Error(`stale`);let l=await e.client.models(e.signal,i);if(!c())throw Error(`stale`);if(l.kind!==`ok`)throw Error(l.error.code);let u=await e.client.workbenchCommand({kind:`cadence-revalidate`,commandId:s,conversationId:t.id,revision:t.revision,proposalId:n.id,digest:n.digest,head:o,context:r,model:a,expected:l.value.version});if(!c())throw Error(`stale`);if(u.kind!==`ok`)throw Error(u.error.code);if(u.value.kind!==`cadence-revalidated`||u.value.state.id!==t.id||u.value.state.revision!==t.revision+1||!u.value.state.enabled||u.value.state.head!==t.head||J(u.value.state.runs)!==J(t.runs)||u.value.state.proposal?.id!==s||u.value.state.proposal.revalidatedFrom!==n.id||u.value.state.proposal.epoch!==l.value.version.epoch||u.value.state.proposal.cwd!==r.cwd||J(u.value.state.proposal.model.conversation??null)!==J(i)||J(u.value.state.proposal.plan)!==J(n.plan))throw Error(`stale`);return u.value.state}async function hl(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||J(r.value.proposal)!==J(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 gl(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function _l(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var vl=e=>`cadence:prompt-history:${e}`;function yl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function bl(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function xl(e){try{let t=sessionStorage.getItem(vl(e));return t?yl(JSON.parse(t)):[]}catch{return[]}}function Sl(e,t){let n=t;for(;n;)try{sessionStorage.setItem(vl(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function Cl(e,t){let n=xl(e),r=bl(n,t);r!==n&&Sl(e,r)}var wl={index:-1,draft:``};function Tl(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:wl,text:t.draft}}function El(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function Dl(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!El(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function Ol(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var kl=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function Al(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function jl(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function Ml(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Nl=``;function Pl(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function Fl(e,t){return{first:!e.slice(0,t).includes(`
|
|
16
|
+
`)}if(new TextEncoder().encode(o).length>P.controlBytes)throw new F(`oversize`)}if(n){if(o)throw new F(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=ze(e);if(!this.attachment||!this.options.socket)throw new F(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${Ya}?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>=P.staleMs&&u(`stale`);try{Date.now()-c>=P.reconcileMs?(i.send(J({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},P.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(J({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new F(`invalid`);let n=io(ue(e.data,P.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function oo(e,t){if(!e.body)throw new F(`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 F(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var so={sourceHash:`daa90b42da7cce45c414f9296556bef41b951d377e4b97ed279cc68d5d724974`,contractHash:`1b833e54ac91fb9d8e570f43da35e3e2faf6c9e214bd9d1bd7cce19c2fe7f243`,buildId:`1eb8055cd7b8198dd83f46d4f9bfd7890f513b3c50d7df6204e35ec82b319e65`};function co(e){let t=new ao({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...so?{build:{kind:`browser`,...so}}:{},socket:e=>new WebSocket(e)});return{client:new Ga(t),transport:t}}function lo(e,t){if(e.initiatorType!==`fetch`)return null;let n;try{n=new URL(e.name)}catch{return null}return n.origin!==t||!/^(?:\/projects\/[a-f0-9]{64})?\/api\/v1\//.test(n.pathname)||!(e.requestStart>0)||!(e.responseStart>=e.requestStart)?null:{at:e.responseStart,ms:e.responseStart-e.requestStart}}function uo(e,t){let n=null;for(let r of e)t-r.at<=6e4&&(n===null||r.ms<n)&&(n=r.ms);return n===null?null:Math.round(n)}var fo=[],po=null,mo,ho,go=new Set;function _o(){let e=uo(fo,performance.now());if(e!==po){po=e;for(let e of go)e()}}function vo(e){if(go.add(e),go.size===1&&typeof PerformanceObserver<`u`)try{mo=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=lo(t,location.origin);e&&(fo=[...fo.slice(-19),e])}_o()}),mo.observe({type:`resource`,buffered:!0}),ho=setInterval(_o,5e3)}catch{mo=void 0}return()=>{go.delete(e),!go.size&&(mo?.disconnect(),mo=void 0,clearInterval(ho),fo=[],po=null)}}function yo(){return(0,m.useSyncExternalStore)(vo,()=>po,()=>null)}function bo(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?pn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function xo(e=typeof window>`u`?``:window.location.search){return bo(e,``).project}function So(e=typeof window>`u`?``:window.location.hash){return bo(``,e).chat}function Co(){let e=xo();return e?`/projects/${e}`:``}function wo(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&bo(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?Gr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function To(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Gr(t)),`#${n}`}function Eo(e,t){if(typeof window>`u`||So()!==e)return;let n=To(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function Do(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&&ce(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&&J(t.settlement)!==J(r.settlement))?i=!0:(!r||ce(t.committedSeq,r.committedSeq)>0||J(r)===J(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 Oo(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,m.useState)(0),[o,s]=(0,m.useState)({key:r,revision:-1});(0,m.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(ri(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,m.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function ko(e,t){let n=/^\/cadence(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}function Ao(e,t,n=!1){let[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)([]),s=Oo(e,t?{kind:`conversations`,after:r,...n?{archived:n}:{}}:null,r===null&&!n?2e3:0),c=s.value?.kind===`conversations`?s.value:void 0;return{value:c,error:s.error,loading:t&&!c&&!s.error,refresh:s.refresh,canPrevious:a.length>0,first:()=>{i(null),o([])},previous:()=>{a.length&&(i(a.at(-1)??null),o(e=>e.slice(0,-1)))},next:()=>{c?.next&&(o(e=>[...e,r]),i(c.next))}}}async function jo(e){return ue(await oo(e,1048576),1048576)}function Mo(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 No(e){let t=Error(Mo(e));return e&&typeof e==`object`&&`kind`in e&&e.kind===`error`&&`error`in e&&e.error&&typeof e.error==`object`&&`effect`in e.error&&[`none`,`accepted`,`uncertain`].includes(String(e.error.effect))&&(t.effect=e.error.effect),t}async function Po(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await jo(r);if(!r.ok)throw Error(Mo(i));return t(i)}function Fo(e){return Po(`/workbench/v1/service`,zn,e)}function Io(e){return Po(`/workbench/v1/service/release`,Bn,e)}async function Lo(e,t){let n=await fetch(`/workbench/v1/service`,{method:`POST`,credentials:`same-origin`,redirect:`error`,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":t},body:JSON.stringify(e)}),r=await jo(n);if(!n.ok)throw Error(Mo(r));let i=W(r,[`kind`,`job`]);return H(i.kind,`service-job`),In(i.job)}function Ro(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function zo(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function Bo(e,t){let[n,r]=(0,m.useState)(0),i=(0,m.useRef)(0),a=(0,m.useRef)(0),[o,s]=(0,m.useState)({});(0,m.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await jo(r);if(!r.ok)throw Error(Mo(a));let c=Tn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...zo(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...zo(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,m.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:Ro(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var Vo=e=>e===`unauthenticated`||e===`forbidden`,Ho=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;latest;readiness=new Set;nextObservation(){return this.version+1}whenReady(e,t,n=0){return new Promise((r,i)=>{let a=e=>{this.readiness.delete(o),t.removeEventListener(`abort`,s),e?i(e):r()},o=t=>{this.version<n||t.epoch!==e||t.workspace?.epoch===e&&t.attached&&!t.error&&t.transportStatus===`current`&&a()},s=()=>a(Error(this.latest?.error??`unavailable`));t.aborted?s():(this.readiness.add(o),t.addEventListener(`abort`,s,{once:!0}),this.latest&&o(this.latest))})}constructor(e){this.api=e}refresh(){this.pollCurrent?.()}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new Ka,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0};this.latest=_;let v=()=>!r&&n===this.version,y=()=>{if(v()){this.latest={..._,observation:c.state},t(this.latest);for(let e of this.readiness)e(this.latest)}},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=()=>{clearTimeout(o),v()&&!h&&(o=setTimeout(C,1e3))},S=e=>{this.serial=this.serial.then(e).catch(e=>{v()&&!h&&(s.abort(),u++,i?.(),_.attached=!1,_.error=e instanceof Error?e.message:`unavailable`,_.actions=!1,_.transportStatus=`stale`,y(),x())})},C=()=>{!v()||h||f||(clearTimeout(o),f=!0,S(async()=>{try{await D()}finally{f=!1}}))},w=async()=>{await this.api.transport.detach()},T=async(t=!0)=>{if(!v()||!_.attached||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{if(t){let e=await this.api.client.session(r);if(!v()||r.aborted)return;if(e.kind===`error`){_.actions=!1,_.error=e.error.code,Vo(e.error.code)&&E();return}if(e.value.epoch!==_.epoch){_.error=`stale`;return}g=e.value.capabilities.actions}e||(_.transportStatus=`current`);let i=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(i.kind===`ok`){if(i.value.epoch!==_.epoch){_.error=`stale`;return}_.activeRuns=i.value}else if(Vo(i.error.code)){E();return}else _.activeRuns=void 0;y();let a=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(a.kind===`error`){_.error=a.error.code,Vo(a.error.code)&&E();return}if(a.value.epoch!==_.epoch){_.error=`stale`;return}if(_.workspace=a.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,Vo(i.error.code)&&E();else if(i.value.epoch!==_.epoch)_.error=`stale`;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()&&!r.aborted&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,v()&&!r.aborted&&(m=!n,_.actions=n&&g,y(),!n&&_.error===`stale`&&C())}},E=()=>{h=!0,_.attached=!1,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new Ka,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),S(w),y()},D=async()=>{if(!v()||h||(_.attached=!1,_.actions=!1,s.abort(),u++,i?.(),await w(),!v()||h))return;let t=await this.api.client.session();if(!v()||h){await w();return}if(t.kind===`error`){if(Vo(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Ka,_={epoch:t.value.epoch,attached:!0,actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},g=t.value.capabilities.actions,y(),await T(!1),!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`&&T():T();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(_.attached=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,x()),y())})};return C(),this.pollCurrent=()=>{_.attached?T():C()},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&T())},1e3),()=>{v()&&(b(),S(w))}}};function Uo(e,t,n,r){let i=(0,m.useMemo)(()=>new Ho(e),[e]),[a,o]=(0,m.useState)(0),[s,c]=(0,m.useState)({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,m.useEffect)(()=>{if(c({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),n)return i.observe(l&&u?{kind:l,id:u}:null,c)},[i,l,u,n,r,a]),{...s,refresh:()=>i.refresh(),whenReady:(e,t,n)=>i.whenReady(e,t,n),reconnect:()=>{let e=i.nextObservation();return o(e=>e+1),e}}}var Wo=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 Go({client:e,value:t,onChange:n}){let{t:r,tx:i}=D(),a=(0,m.useRef)(!0),o=(0,m.useRef)(null);(0,m.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,m.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,_.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,_.jsx)(`h3`,{children:r(`Command receipt`)}),(0,_.jsx)(`code`,{children:t.commandId}),t.error&&(0,_.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:r(`Admission`)}),(0,_.jsx)(`dd`,{children:i(l.admission)}),(0,_.jsx)(`dt`,{children:r(`Execution`)}),(0,_.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,_.jsx)(`dt`,{children:r(`Publication`)}),(0,_.jsx)(`dd`,{children:i(l.publication)}),(0,_.jsx)(`dt`,{children:r(`Run`)}),(0,_.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,_.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,_.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 Ko(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 qo(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 Jo(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 Yo(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=Ko(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 Xo(e,t){let n=t?J({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,m.useState)(),[a,o]=(0,m.useState)(!1),[s,c]=(0,m.useState)(),[l,u]=(0,m.useState)(t),[d,f]=(0,m.useState)([]),p=(0,m.useRef)(0),[h,g]=(0,m.useState)(n);return h!==n&&(p.current++,g(n),i(void 0),c(void 0),u(t),f([])),(0,m.useEffect)(()=>{let t=++p.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),qo(e,l,n.signal).then(e=>{t===p.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===p.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),p.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&f(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),f(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),f([]),u(t?{...t}:null)}}}function Zo({value:e,compact:t=!1}){let{t:n,tx:r}=D();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,_.jsxs)(`details`,{className:`coverage-details`,children:[(0,_.jsx)(`summary`,{children:n(`Recording details`)}),(0,_.jsx)(Zo,{value:e})]}):(0,_.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 Qo(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 $o(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Qo(e)}return Qo(e)}function es(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,m.useRef)(!0),[a,o]=(0,m.useState)(!1),s=(0,m.useRef)(null),c=(0,m.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,m.useCallback)(()=>{c(),o(!1)},[c]);return(0,m.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,m.useCallback)(async e=>{let a=!1;try{a=await $o(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 ts(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
17
|
+
`).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,m.createElement)(n.type,i)]]:a.map(e=>[(0,m.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var ns=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:rs(!0)},text:{92:rs(!1)}});let t={enter:{backslashMathInline:is,backslashMathDisplay:is,backslashMathBlock:is},exit:{backslashMathInline:as,backslashMathDisplay:as,backslashMathBlock:as}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function rs(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 is=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)},as=function(e){this.exit(e)};function os(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var ss=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function cs(e,t,n=3){let r=[...e.filter(e=>!ss(e,t)),t];for(;r.length>n;){let e=r.slice(0,-1).findIndex(e=>e.level!==`error`);r.splice(Math.max(e,0),1)}return r}var ls=[],us=1,ds=new Set;function fs(e){if(!(e.length===ls.length&&e.every((e,t)=>e===ls[t]))){ls=e;for(let e of ds)e()}}function ps(e,t,n){let r=us++;return fs(cs(ls,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function ms(e){fs(ls.filter(t=>t.id!==e))}function hs(e){fs(ls.filter(t=>t.key!==e))}function gs(e){return ds.add(e),()=>{ds.delete(e)}}var _s=()=>ls,vs=(0,m.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=D(),{copied:r,copy:i}=es();return(0,_.jsx)(`button`,{type:`button`,className:r?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(e).then(e=>{e||ps(`error`,n(`Copy unavailable`))})},children:r?(0,_.jsx)(Fa,{}):(0,_.jsx)(Da,{})})}),ys=[c,f,ns],bs=[c,u,f,ns],xs=[[l,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[d,{detect:!1,ignoreMissing:!0}]];function Ss(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 Cs({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,_.jsx)(a,{remarkPlugins:n?bs:ys,rehypePlugins:t?[i,o,...xs]:xs,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Es,a:Ts,img:({alt:e})=>(0,_.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ws=(0,m.memo)(function(e){return(0,_.jsx)(`div`,{className:`md`,children:(0,_.jsx)(Cs,{...e})})});function Ts({href:e,children:t}){let n=e&&Ss(e);return n?(0,_.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,_.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function Es({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=ts(r).map(e=>{let t=`code-offset:${i}`;return i+=Ds(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,_.jsxs)(`div`,{className:`codeblock`,children:[(0,_.jsx)(vs,{text:Ds(e)}),(0,_.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,_.jsxs)(`div`,{className:`code-line`,children:[o&&(0,_.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,_.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Ds(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Ds).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Ds(t?.children)}return``}function Os(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 ks=new Map;function As(e,t){t.length?ks.set(e,t):ks.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...ks].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 js(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 Ms(e,t){let n=t.startContainer.parentElement;for(let r of js(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 Ns({container:e,version:t}){let{t:n}=D(),[r,i]=(0,m.useState)(``),[a,o]=(0,m.useState)(0),[s,c]=(0,m.useState)(0),l=(0,m.useRef)([]),u=`cadence-page-${(0,m.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,m.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?Os(n,r):[];return l.current=i,c(i.length),o(0),As(u,i),()=>As(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Ms(e.current,l.current[n]),As(`${u}-active`,[l.current[n]]))};return(0,m.useEffect)(()=>()=>As(`${u}-active`,[]),[u]),(0,_.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,_.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,_.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,_.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,_.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,_.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function Ps({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=D(),s=J(t),c=(0,m.useMemo)(()=>Ve(JSON.parse(s)),[s]),[l,u]=(0,m.useState)(t),[d,f]=(0,m.useState)(),[p,h]=(0,m.useState)([]),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(),[x,S]=(0,m.useState)(i?`markdown`:`raw`),[C,w]=(0,m.useState)(``),T=(0,m.useRef)(null),E=(0,m.useRef)(null);(0,m.useEffect)(()=>(u(c),h([]),f(void 0),b(void 0),()=>T.current?.abort()),[c]),(0,m.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):f(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(T.current)return;let n=new AbortController;T.current=n,w(a(`Reading all retained field pages…`));try{let r=await Yo(e,t,n.signal);if(n.signal.aborted)return;let i=await $o(r.text);if(n.signal.aborted)return;w(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||w(a(`Full-field copy refused/incomplete.`))}finally{T.current===n&&(T.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,_.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,_.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,_.jsx)(`summary`,{children:a(`Field details`)}),(0,_.jsxs)(`div`,{className:`detail-identity`,children:[(0,_.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,_.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,_.jsx)(`button`,{type:`button`,disabled:!!T.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!T.current&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>{T.current?.abort(),T.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,_.jsx)(`p`,{role:`status`,children:C}),y&&(0,_.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),g&&(0,_.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,_.jsx)(Zo,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,_.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,_.jsxs)(_.Fragment,{children:[(!i||k.next)&&(0,_.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,_.jsx)(Ns,{container:E,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,_.jsx)(`div`,{ref:E,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,_.jsx)(ws,{text:k.text}):(0,_.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,_.jsxs)(_.Fragment,{children:[i(0,e),(0,_.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||p.length>0||d?.next)&&(0,_.jsxs)(`div`,{className:`toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,disabled:g||!p.length,onClick:()=>{u(p[p.length-1]),h(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,_.jsx)(`button`,{type:`button`,disabled:g||!d?.next,onClick:()=>{d?.next&&(h(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function Fs({pager:e,compact:t=!1}){let{t:n,tx:r}=D(),{page:i,busy:a,error:o}=e;return(0,_.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,_.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,_.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,_.jsx)(Zo,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,_.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,_.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,_.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,_.jsx)(Xi,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,_.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function Is({client:e,seed:t,entityId:n}){let{t:r,tx:i}=D(),a=Xo(e,{...t,reader:`contents`}),[o,s]=(0,m.useState)(),c=a.page;return(0,_.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,_.jsx)(Fs,{pager:a}),n&&(0,_.jsx)(`p`,{children:(0,_.jsx)(C,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,_.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,_.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,_.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,_.jsxs)(`article`,{children:[(0,_.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,_.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,_.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,_.jsx)(Zo,{value:e.coverage}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Jo(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,_.jsx)(Ps,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ls({client:e,seed:t}){return(0,_.jsx)(Rs,{client:e,seed:t},J(t))}function Rs({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1);return(0,m.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,_.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,_.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,_.jsx)(Zo,{value:o.coverage}),o&&(`kind`in o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,_.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,_.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function zs(e){let t=ro(`download`,Jt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Co()+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 Bs({title:e,children:t,onClose:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useId)(),o=(0,m.useRef)(n);return o.current=n,(0,m.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,_.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(`h2`,{id:a,children:e}),n&&(0,_.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,_.jsx)(zi,{"aria-hidden":`true`})})]}),t]})}function Vs({request:e,onClose:t}){let{t:n,tx:r}=D(),[i]=(0,m.useState)(e),[a,o]=(0,m.useState)(e.format),[s,c]=(0,m.useState)(``);return(0,_.jsxs)(Bs,{title:n(`Export retained history`),onClose:t,children:[(0,_.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,_.jsxs)(`label`,{children:[n(`Format`),(0,_.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,_.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,_.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,_.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,_.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,_.jsx)(`button`,{type:`button`,onClick:()=>{try{zs({...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,_.jsx)(`p`,{role:`status`,children:s})]})}function Hs(e,t){if(!t||R(t)>P.queryBytes)throw Error(`Query must be 1–${P.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Ve({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Us(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 Ws({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=D(),[o]=(0,m.useState)(t),s=(0,m.useRef)(null),c=(0,m.useRef)(0),[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(0),[p,h]=(0,m.useState)(),[g,v]=(0,m.useState)(!1),[y,b]=(0,m.useState)(),x=(0,m.useRef)(null),S=(0,m.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):(h(i.value),f(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,m.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,m.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),h(void 0),f(0),b(void 0),!l)return;let t;try{t=Hs(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,_.jsx)(Bs,{title:i(`Search retained history`),onClose:n,children:(0,_.jsxs)(`div`,{className:`gs-modal`,children:[(0,_.jsxs)(`div`,{className:`gs-input-row`,children:[(0,_.jsx)(Ji,{}),(0,_.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(),f(e=>Math.max(0,Math.min(e+1,(p?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),f(e=>Math.max(e-1,0))),e.key===`Enter`&&p?.hits[d]&&(e.preventDefault(),r(p.hits[d]),n())}})]}),(0,_.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,_.jsxs)(`div`,{className:`gs-results`,children:[g&&(0,_.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,_.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,_.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),p&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Zo,{value:p.coverage}),(0,_.jsxs)(`div`,{className:`gs-section`,children:[(0,_.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:p.hits.length})}),p.hits.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>f(t),onClick:()=>{r(e),n()},children:[(0,_.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,_.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,_.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}`)),p.hits.length===0&&(0,_.jsx)(`p`,{children:a(Us(p))})]}),(0,_.jsx)(`button`,{type:`button`,disabled:g||!p.next,onClick:()=>{p.next&&S(p.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,_.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Gs({run:e,historical:t=!1}){let{t:n,tx:r}=D();return(0,_.jsxs)(`article`,{className:`run-summary`,children:[(0,_.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,_.jsx)(`p`,{children:(0,_.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,_.jsx)(`dd`,{children:r(e.lifecycle)}),(0,_.jsx)(`dt`,{children:n(`Execution`)}),(0,_.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,_.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,_.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,_.jsx)(`dt`,{children:n(`Summary publication`)}),(0,_.jsx)(`dd`,{children:r(e.publication)})]}),(0,_.jsx)(Zo,{value:e.coverage}),(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,_.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Ks({client:e,seed:t}){return(0,_.jsx)(qs,{client:e,seed:t},J(t))}function qs({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(t),[o,s]=(0,m.useState)(),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(!1);return(0,m.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,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,_.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,_.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,_.jsx)(Zo,{value:o.coverage}),o&&(`kind`in o?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,_.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Ps,{client:e,cursor:Jo(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,_.jsxs)(`article`,{children:[(0,_.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,_.jsx)(ws,{text:e.instructions}),(0,_.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,_.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function Js({client:e,seed:t,onScope:n}){let{t:r}=D(),i=Xo(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,m.useState)();return(0,_.jsxs)(`section`,{children:[(0,_.jsx)(Fs,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,_.jsxs)(`article`,{children:[(0,_.jsx)(Gs,{run:e.projection,historical:!0}),(0,_.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,_.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,_.jsx)(Ks,{client:e,seed:o},o.graph.recordId)]})}function Ys({onOpen:e,disabled:t}){let{t:n}=D();return(0,_.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,_.jsx)(Ji,{"aria-hidden":`true`})})}function Xs(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 Zs(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 Qs(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)??$s(n.role,n.customType)}return r}function $s(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 ec(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function tc(e,t,n=null,r=1800,i){let a=(0,m.useRef)(i);a.current=i;let o=(0,m.useRef)(null),[s,c]=(0,m.useState)(()=>new Set),l=(0,m.useRef)(s);l.current=s;let u=(0,m.useRef)(new Map),d=(0,m.useRef)(new Map),f=(0,m.useRef)(new Map),p=(0,m.useRef)(0),h=(0,m.useRef)(new Map);h.current=new Map(t.map(e=>[e.id,e.version]));let g=(0,m.useRef)(new Set);g.current=Qs(t,u.current,r),n!==null&&g.current.add(n);let _=(0,m.useCallback)((e,t)=>{let n=h.current.get(e);n!==void 0&&(d.current.set(e,{h:t,len:n}),u.current.set(e,t))},[]),v=(0,m.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of f.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),l.current.has(e)||_(e,n.height)}let i=Xs(r,{top:n.top-1200,bottom:n.bottom+1200},g.current,l.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=f.current.get(e);t&&_(e,t.offsetHeight)}c(e=>Zs(e,i))},[_,e]),y=(0,m.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,v()})},[v]);return(0,m.useLayoutEffect)(()=>{t.length?v():c(new Set)},[v,t,n]),(0,m.useEffect)(()=>{let t=new ResizeObserver(()=>{y(),a.current?.()});o.current=t,e.current&&t.observe(e.current);for(let e of f.current.values())t.observe(e);return()=>{o.current=null,t.disconnect(),cancelAnimationFrame(p.current),p.current=0}},[y,e]),{hidden:s,scheduleSweep:y,recordMeasured:_,register:(0,m.useCallback)(e=>t=>{let n=f.current.get(e);n&&n!==t&&o.current?.unobserve(n),t?(f.current.set(e,t),o.current?.observe(t)):f.current.delete(e)},[]),placeholder:(0,m.useCallback)((e,t,n)=>ec(e,t,d.current,n),[])}}function nc(e,t){e&&t&&(e.scrollTop=e.scrollHeight)}function rc(e,t,n){(0,m.useEffect)(()=>{let r=new ResizeObserver(()=>nc(e.current,n.current));return t.current&&r.observe(t.current),()=>r.disconnect()},[e,t,n])}var ic=(0,m.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,m.useRef)(null);return(0,m.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,_.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,_.jsx)(`div`,{ref:s,children:o})}):(0,_.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),ac=(0,m.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=D(),[a,o]=(0,m.useState)(!1);return(0,_.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,_.jsxs)(`header`,{className:`msg-meta`,children:[(0,_.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,_.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,_.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,_.jsx)(ja,{"aria-hidden":`true`}):(0,_.jsx)(ya,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,_.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,_.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,_.jsx)(`div`,{className:`msg-text`,children:(0,_.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,_.jsx)(Ps,{compact:!0,client:t,cursor:Jo(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,_.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,_.jsxs)(`div`,{className:`message-inspection`,children:[(0,_.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,_.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,_.jsxs)(`details`,{open:!0,children:[(0,_.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,_.jsx)(Is,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function oc({messages:e,client:t,seed:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useRef)(!0),o=(0,m.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=tc(i,o);return(0,_.jsxs)(`div`,{className:`messages-wrap`,children:[(0,_.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,_.jsx)(ic,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,_.jsx)(ac,{message:a,client:t,seed:n})},e))}),(0,_.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,_.jsx)(Ba,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function sc({client:e,seed:t}){let{t:n}=D(),r=Xo(e,{...t,reader:`messages`}),i=r.page;return(0,_.jsxs)(`section`,{className:`transcript`,children:[(0,_.jsx)(Fs,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,_.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,_.jsxs)(_.Fragment,{children:[i.records.length===0&&(0,_.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,_.jsx)(oc,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function cc({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,_.jsxs)(`div`,{className:`chead ${n}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,_.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,_.jsx)(Pa,{}):(0,_.jsx)(Ma,{})}):c,(0,_.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,_.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var lc=(0,m.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=D(),[a,o]=(0,m.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,_.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,_.jsx)(cc,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,_.jsx)(Vi,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.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,_.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,_.jsxs)(`div`,{className:`toolcall-body`,children:[(0,_.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:r(`Source ID`)}),(0,_.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,_.jsx)(`dt`,{children:r(`Declaration`)}),(0,_.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,_.jsxs)(`div`,{className:`toolcall-output`,children:[(0,_.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,_.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,_.jsx)(`div`,{className:`toolcall-args`,children:(0,_.jsx)(Is,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),uc=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function dc({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=D(),s=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(uc(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length),c=!!t||e?.completeness===`partial`;return!s?.length&&!c?null:(0,_.jsx)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:(0,_.jsxs)(`div`,{className:`lp-section-body`,children:[c&&(0,_.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),s?.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,_.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,_.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})})}function fc(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 pc(e){if(!e.tasks?.length)return null;let t={queued:0,running:0,completed:0,failed:0,superseded:0};for(let n of e.tasks)t[n.state]+=1;return t}var mc=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function hc(e,t){return mc.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function gc(e){let t=pc(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function _c(e,t=e.steps){return(e.tasks??[]).map(n=>{let r=e.delivery?.artifacts?.findLast(e=>e.id===n.id);return{task:n,steps:t.filter(e=>fc(e.id)===n.id),...r?{artifact:r}:{}}})}var vc=[`queued`,`running`];function yc(e,t){let n=e=>Number(!vc.includes(e));return[...new Set(e)].flatMap(e=>{let r=t.get(e),i=(r?.steps.filter(e=>e.childRunId)??[]).reverse().sort((e,t)=>n(e.status)-n(t.status));return r&&i.length?[{run:r,steps:i}]:[]}).reverse().sort((e,t)=>n(e.steps[0].status)-n(t.steps[0].status))}function bc(e,t){return t.kind===`check`?e.delivery?.acceptance?.waived?.includes(t.id)?!0:t.status===`failed`&&!!e.verification?.steps.includes(t.id)&&(e.deviations??[]).some(e=>e.waives.includes(fc(t.id))):!1}var xc=[`queued`,`running`],Sc=4,Cc=1e4;function wc(e,t,n=2e3){let[r,i]=(0,m.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,m.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,m.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?xc.includes(t.status):i-(u.get(e)??0)>=Cc}).reverse();for(let n=0;n<a.length;n+=Sc){let r=await Promise.all(a.slice(n,n+Sc).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+Sc<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>xc.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),Cc))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function Tc({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=D(),o=pc(e),s=n?.runId===e.id?n.stepId:void 0;return(0,_.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${s===null?` active`:``}`,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,_.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,_.jsx)(`span`,{className:`agent-dock-run-state`,children:hc(o,i)})]}),t.map(t=>{let n=fc(t.id),o=e.tasks?.find(e=>e.id===n);return(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-row${s===t.id?` active`:``}`,title:o?`${o.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:n}),children:[(0,_.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,_.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,_.jsx)(`strong`,{children:`${a(t.kind)} · ${n}`}),o&&(0,_.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(o.state)})})]}),(0,_.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function Ec({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=D(),[d,f]=(0,m.useState)(null),[p,h]=(0,m.useState)([]),[g,v]=(0,m.useState)(!1),y=wc(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,m.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||(h(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=[...p,...x.filter(e=>!p.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=yc(a,y.runs),w=C.flatMap(e=>e.steps),T=S.length+w.length,E=w.filter(e=>xc.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,O=d??(T>0||!!g);return(0,_.jsxs)(`section`,{className:`agent-dock${O?``:` collapsed`}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":O,onClick:()=>f(!O),children:[(0,_.jsx)(Pa,{}),(0,_.jsx)(wa,{}),(0,_.jsx)(`span`,{children:l(`Subagents`)}),(0,_.jsx)(`span`,{className:`lp-count${E?` live`:``}`,children:E?l(`{active} active · {total} total`,{active:E,total:T}):T})]}),O&&(0,_.jsxs)(`div`,{className:`agent-dock-body`,children:[(g||t?.status!==`complete`||y.failed)&&(0,_.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),T===0&&!g&&t?.status===`complete`&&(0,_.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,steps:t})=>(0,_.jsx)(Tc,{run:e,steps:t,selected:o,onOpen:c},e.id)),S.map(e=>(0,_.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,_.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,_.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,_.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,_.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,_.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}function Dc(e){let t=new Set(e.map(e=>e.id)),n=new Map;for(let r of e){let e=r.parent!==null&&t.has(r.parent)?r.parent:null,i=n.get(e);i?i.push(r):n.set(e,[r])}let r=[],i=[],a=(e,t)=>{let n=e.length>1;for(let r=e.length-1;r>=0;r--)i.push({node:e[r],depth:n?t+1:t})};for(a(n.get(null)??[],-1);i.length;){let e=i.pop();r.push({...e,depth:Math.max(0,e.depth)}),a(n.get(e.node.id)??[],Math.max(0,e.depth))}return r}function Oc(e){let t=new Map;for(let n of e.nodes){if(n.parent===null&&e.truncated)continue;let r=t.get(n.parent);r?r.push(n):t.set(n.parent,[n])}let n=new Map;for(let e of t.values())if(e.length>1)for(let t of e)n.set(t.id,e);return n}var kc=e=>e.filter(e=>e.current);function Ac(e,t,n,r,i){let a=e.findIndex(e=>e.id===t);if(a<0)return;let o=new Map(e.map((e,t)=>[e.id,t])),s=n.find(e=>o.has(e.header.id)),c=s?s.ordinal-(o.get(s.header.id)-a):r-+!!i-(e.length-a);return c>=0&&c<r?c:void 0}function jc(e,t,n,r,i){let[a,o]=(0,m.useState)();(0,m.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=Oo(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,m.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,f]=(0,m.useState)();return(0,m.useEffect)(()=>{u&&f(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function Mc({view:e,onChosen:t}){let{t:n,locale:r}=D(),[i,a]=(0,m.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,m.useMemo)(()=>Dc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,_.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,_.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,_.jsxs)(`label`,{className:`lp-filter`,children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,_.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,_.jsx)(Xi,{"aria-hidden":`true`})})]}),(0,_.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,_.jsxs)(`p`,{className:`branches-pinned`,children:[(0,_.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:S(n,e.error)}),s?.truncated&&(0,_.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,_.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,_.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,_.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,_.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,_.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,_.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,_.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,_.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,_.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,_.jsx)(xa,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,_.jsx)(Ea,{"aria-hidden":`true`})})]},t.id))})]})}function Nc(e,t){if(!e)return;let n=t?.find(t=>t.provider===e.provider&&t.model===e.model)?.contextWindow;return{tokens:e.tokens,window:n&&n>0?n:null,provider:e.provider,model:e.model}}function Pc(e){let t=(e,t)=>`${e.toFixed(1).replace(/\.0$/,``)}${t}`;return e>=999950?t(e/1e6,`M`):e>=1e3?t(e/1e3,`K`):String(e)}function Fc(e,t){return Math.round(e/t*100)}var Ic=e=>e.trim().split(`
|
|
18
|
+
`,1)[0].slice(0,200);function Lc(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var Rc=(e,t)=>e?e.entry:t,zc=(e,t)=>e!==null&&t>=e.from;function Bc(e){if(!e)return null;try{let t=JSON.parse(e);return t.kind!==`edit`&&t.kind!==`continue`||typeof t.turnId!=`string`||!Number.isSafeInteger(t.from)||t.from<0||typeof t.label!=`string`||typeof t.stash!=`string`?null:{kind:t.kind,entry:t.entry===null?null:Gr(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function Vc(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function Hc(e,t,n,r,i=crypto.randomUUID()){return{kind:`conversation-input`,commandId:i,conversationId:e,turnId:t.commandId,epoch:t.epoch,mode:n,text:r}}function Uc(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function Wc(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function Gc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var Kc=2e4;async function qc(e,t,n,r){let i=qa([t],Kc);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Jc(e,t){if(t===`none`)return`Execution preparation was refused with no effect ({code}). This attempt started no execution service; the message was not sent and its draft is kept.`;switch(e){case`dispatched`:return`Preparation outcome is unknown ({code}); an execution service may have started. The message was not sent and its draft is kept.`;case`confirmed`:return`Execution preparation was confirmed, but the message was not sent ({code}). Its draft is kept.`;default:return`The message was not sent ({code}). Its draft is kept.`}}function Yc(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function Xc(e){return e===`none`?`The message was not accepted ({code}). Its draft is kept.`:`Send outcome is unknown ({code}). Observe the original command before sending again; no automatic retry.`}async function Zc(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Qc(e){let t={commandId:crypto.randomUUID(),conversationId:pn(e.id),head:e.head===null?null:Gr(e.head)},n=e.location?mn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new F(`stale`);let r=L(e.text,Jr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:z(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:z(e.revision,0)};return Object.freeze({text:r,...e.installModel?{installModel:!0}:{},images:Object.freeze([...e.images??[]]),command:Object.freeze(i),...n?{location:Object.freeze(n)}:{},...e.model?{model:Object.freeze($c(e.model))}:{}})}function $c(e){return ge({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function el(e,t){return Object.freeze({...e,model:Object.freeze($c(t))})}function tl(e,t){if(e.model&&J(e.model)!==J($c(t)))throw new F(`stale`)}function nl(e,t){return Object.freeze({...e,preparedEpoch:K(t)})}function rl(e,t,n){return Object.freeze({...el(e,t),installModel:!n})}function il(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function al(e,t){return!!e&&e===t}async function ol(e,t,n,r){if(!r())throw new F(`stale`);if(!t.installModel||!t.model)return n;if(!xn(n.entries,t.model))throw new F(`unsupported-context`);if(n.selected&&J($c(n.selected))===J(t.model))return n;let i=await e.chooseModel({expected:n.version,choice:t.model},t.location);if(!r())throw new F(`stale`);if(i.kind===`error`)throw new F(i.error.code);let a=await e.models(void 0,t.location);if(!r())throw new F(`stale`);if(a.kind===`error`)throw new F(a.error.code);if(!a.value.selected||J(a.value.version)!==J(i.value.version)||J(a.value.selected)!==J(i.value.selected))throw new F(`stale`);return tl(t,a.value.selected),a.value}function sl(e,t){if(e.location&&e.command.kind!==`cadence-exit`&&J(e.location)!==J(t?.conversation??null)||e.preparedEpoch&&e.command.kind!==`cadence-exit`&&t?.epoch!==e.preparedEpoch)throw new F(`stale`);let n=ai(e.command.kind===`cadence-exit`?e.command:{...e.command,model:t});if(n.kind!==`send`&&n.kind!==`cadence-send`&&n.kind!==`cadence-exit`)throw new F(`invalid`);return n}function cl(e,t,...n){let r=`cadence:draft:${e}:${t}`;try{let e=e=>[e,`${e}:pending`,`${e}:mode`].some(e=>sessionStorage.getItem(e)!==null);if(e(r))return r;for(let r of n){if(!r)continue;let n=`cadence:draft:${r}:${t}`;if(e(n))return n}}catch{}return r}function ll(e){for(let t of e){if(!Un.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function ul(e){ll([e]);let t=new Uint8Array(await e.arrayBuffer());return Gn(t,e.type),t}var dl=e=>{let t=``;for(let n=0;n<e.length;n+=8192)t+=String.fromCharCode(...e.subarray(n,n+8192));return btoa(t)};async function fl(e,t,n,r){ll(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await ul(a);if(!r())throw Error(`stale`);let o=dl(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Hn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Hn.chunkChars),l=await e.workbenchCommand({kind:`image-upload`,commandId:crypto.randomUUID(),imageId:s,send:t,mimeType:a.type,size:n.length,offset:i,data:c});if(!r())throw Error(`stale`);if(l.kind===`error`)throw Error(l.error.code);if(l.value.kind!==`image-upload`||l.value.imageId!==s||l.value.offset!==i+c.length)throw Error(`invalid`)}i.push(s)}return i.length?{...t,images:i}:t}async function pl(e,t){let n=[],r=0;for(;;){let i=await t(r);if(i.kind!==`conversation-image`||i.mimeType!==e.mimeType||!i.data.length||i.data.length>Hn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Hn.chunkChars)throw Error(`invalid`)}let i=Wn(n.join(``));return Gn(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var ml=e=>e.renderId??`legacy:${e.id}`;function hl(e,t){let n=new Map(e.map(e=>[ml(e),e])),r=new Set;return t.map(e=>{let t=ml(e);if(r.has(t))throw new bl(`stale`);r.add(t);let i=n.get(t);return i&&JSON.stringify(i)===JSON.stringify(e)?i:e})}var gl=1e3,_l=1e4,vl=4,yl=e=>e===`queued`||e===`running`,bl=class extends Error{},xl=class{client;id;notify;summary=void 0;leaf=null;pinned=null;branches=0;runs=[];attempt=null;pending=[];undelivered=[];commands=[];context;cache;count=0;first=null;opening=null;turns=new Map;imageReaders=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...this.cache?{cache:this.cache}:{},count:this.count,turns:e,earlier:(e[0]?.ordinal??this.count)>0,loadingEarlier:this.loadingEarlier,error:this.error}}async tick(){if(this.closed||!this.active)return;if(this.running){this.again=!0;return}this.running=!0,clearTimeout(this.timer);let e=this.loadingEarlier,t=this.abort;try{await this.sync(t.signal),t===this.abort&&(this.error=``)}catch(e){if(this.closed)return;t===this.abort&&(this.error=e instanceof bl?e.message:`unavailable`)}finally{this.running=!1}if(this.closed)return;if(e&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=this.error===`stale`||yl(this.summary?.status)||[...this.turns.values()].some(e=>yl(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?gl:_l)}async sync(e){let t=this.pinned,n=await this.read({kind:`conversation`,id:this.id,leaf:t,known:this.leaf},e);if(e.aborted)return;if(n.kind!==`conversation`)throw new bl(`invalid`);let r=!n.continues||n.turns<this.count,i=n.leaf===this.leaf?this.count:this.count-1,a=Math.max(0,n.turns-2),o=Math.min((r?null:this.first)??this.opening??a,a),s=[];for(let e=o;e<n.turns;e++){let t=r?void 0:this.turns.get(e);(!t||e>=i||t.header.stable<t.header.steps||yl(t.header.status))&&s.push(e)}let c=await Promise.all(s.map(t=>this.load(t,n.leaf,e,r?void 0:this.turns.get(t))));if(!e.aborted){r&&this.forget(),this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.pending=n.pending??[],this.undelivered=n.undelivered??[],this.commands=n.commands??[],this.context=n.context,this.cache=n.cache,this.summary=n.summary,this.count=n.turns,this.first=Math.min(o,this.first??o),this.opening=null;for(let e of c)this.turns.set(e.ordinal,e)}}async load(e,t,n,r){let i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,a.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{let n=i.start+t;if(r?.header.id===a.id&&n<Math.min(r.header.stable,a.stable)&&ml(r.steps[n])!==ml(e))throw new bl(`stale`);o[n]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n)))){if(JSON.stringify(r.turn)!==JSON.stringify(a))throw new bl(`stale`);r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)})}if(n.aborted||o.includes(void 0))throw new bl(`stale`);let l=hl(r?.steps??[],o);return r&&r.image===this.imageReader(t,n)&&JSON.stringify(r.header)===JSON.stringify(a)&&r.steps.length===l.length&&l.every((e,t)=>e===r.steps[t])?r:{ordinal:e,renderId:l.find(e=>e.role===`user`)?.renderId??a.id,header:a,steps:l,detail:this.detail(t,a.id,l,n),image:this.imageReader(t,n)}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new bl(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=qa([t,r]);try{return await pl(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n,r){return async(i,a,o)=>{let s=n[i];if(!s)throw new bl(`stale`);let c=await Promise.all(Array.from({length:a},async(n,a)=>{let c=qa([r,o]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:i,part:a},c.signal);if(n.kind!==`conversation-step`||n.part!==a||n.conversationId!==this.id||n.leaf!==e||n.turnId!==t||n.step!==i)throw new bl(`invalid`);if(s.renderId&&n.item.renderId!==s.renderId||s.version&&n.item.version!==s.version)throw new bl(`stale`);return n.item}finally{c.dispose()}}));return{text:c.map(e=>e.text).join(``),args:c.map(e=>e.args).join(``)}}}async read(e,t=this.abort.signal){this.reads>=vl&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new bl(`stale`);let n=await this.client.workbenchRead(e,t);if(this.closed||t.aborted)throw new bl(`stale`);if(n.kind===`error`)throw new bl(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function Sl(e,t,n,r=null){let i=(0,m.useMemo)(()=>({client:e,id:t,initialLeaf:r}),[e,t,r]),a=(0,m.useRef)(i);a.current=i;let[o,s]=(0,m.useState)();(0,m.useEffect)(()=>{let n=new xl(e,t,()=>{a.current===i&&s({scope:i,reader:n,view:n.view()})});return n.choose(r),s({scope:i,reader:n,view:n.view()}),()=>n.close()},[e,t,r,i]);let c=o?.scope===i?o:void 0,l=c?.reader,u=c?.view;return(0,m.useEffect)(()=>{l?.setActive(n)},[l,n]),{...u??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:l?.refresh??Cl,loadEarlier:l?.loadEarlier??Cl,showFrom:l?.showFrom??Cl,choose:l?.choose??Cl}}function Cl(){}function wl(e,t,n,r){let i=t.status===`ready`?t.epoch:null,a=t.status===`ready`?t.attachmentVersion:null,o=i===null&&t.status!==`preparing`?r:void 0,[s,c]=(0,m.useState)(0),l=(0,m.useRef)(0),u=(0,m.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,preview:o}),[e,i,a,n,o]),d=(0,m.useRef)(null),f=(0,m.useMemo)(()=>({...u,revision:s,reload:d.current===u}),[u,s]),p=(0,m.useRef)(f);p.current=f;let h=(0,m.useRef)(!0);(0,m.useEffect)(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=(0,m.useCallback)(()=>h.current&&(f.epoch!==null||!!f.preview)&&p.current===f&&l.current===f.revision,[f]),[_,v]=(0,m.useState)();(0,m.useEffect)(()=>{if(f.epoch===null&&!f.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&g();return f.preview?(f.preview(t.signal).then(e=>{n()&&v({scope:f,preview:e})}).catch(e=>{n()&&v({scope:f,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal,f.reload).then(e=>{n()&&(e.kind===`error`?v({scope:f,error:e.error.code}):e.value.version.epoch===f.epoch?v({scope:f,catalog:e.value}):v({scope:f,error:`stale`}))}).catch(()=>{n()&&v({scope:f,error:`unavailable`})}),()=>t.abort())},[e,f,g]);let y=_?.scope===f&&g()?_:void 0;return{catalog:y?.catalog,preview:y?.preview,error:y?.error,loading:(i!==null||!!o)&&!y,isCurrent:g,reread(e=!1){g()&&(d.current=e?u:null,c(++l.current))},accept(e){return!g()||e.version.epoch!==f.epoch?!1:(v({scope:f,catalog:e}),!0)}}}function Tl(e,t,n,r=!1){return t?r||!n||J(n)!==J(e.model)?`validate`:`approve`:`restore`}async function El(e){let t=structuredClone(e.state),n=t.proposal,r=structuredClone(e.context),i={id:r.id,cwd:r.cwd},a=structuredClone(e.model),o=e.head,s=crypto.randomUUID(),c=()=>!e.signal.aborted&&e.current();if(!n||!t.enabled||r.id!==t.id||!c()||(e.prepare&&await qc(e.prepare,e.signal,i,e.progress??(()=>{})),!c()))throw Error(`stale`);let l=await e.client.models(e.signal,i);if(!c())throw Error(`stale`);if(l.kind!==`ok`)throw Error(l.error.code);let u=await e.client.workbenchCommand({kind:`cadence-revalidate`,commandId:s,conversationId:t.id,revision:t.revision,proposalId:n.id,digest:n.digest,head:o,context:r,model:a,expected:l.value.version});if(!c())throw Error(`stale`);if(u.kind!==`ok`)throw Error(u.error.code);if(u.value.kind!==`cadence-revalidated`||u.value.state.id!==t.id||u.value.state.revision!==t.revision+1||!u.value.state.enabled||u.value.state.head!==t.head||J(u.value.state.runs)!==J(t.runs)||u.value.state.proposal?.id!==s||u.value.state.proposal.revalidatedFrom!==n.id||u.value.state.proposal.epoch!==l.value.version.epoch||u.value.state.proposal.cwd!==r.cwd||J(u.value.state.proposal.model.conversation??null)!==J(i)||J(u.value.state.proposal.plan)!==J(n.plan))throw Error(`stale`);return u.value.state}async function Dl(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||J(r.value.proposal)!==J(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 Ol(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function kl(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var Al=e=>`cadence:prompt-history:${e}`;function jl(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}return t}function Ml(e,t,n=100){let r=t.trim();if(!r||e.length>0&&e[e.length-1]===r)return e;let i=[...e,r];return i.length>n?i.slice(i.length-n):i}function Nl(e){try{let t=sessionStorage.getItem(Al(e));return t?jl(JSON.parse(t)):[]}catch{return[]}}function Pl(e,t){let n=t;for(;n;)try{sessionStorage.setItem(Al(e),JSON.stringify(n));return}catch(e){if(!(e instanceof DOMException&&(e.name===`QuotaExceededError`||e.code===22))||n.length<=1)return;n=n.slice(Math.ceil(n.length/2))}}function Fl(e,t){let n=Nl(e),r=Ml(n,t);r!==n&&Pl(e,r)}var Il={index:-1,draft:``};function Ll(e,t,n,r){if(n===`older`){if(!e.length||t.index===0)return null;let n=t.index===-1?e.length-1:Math.min(t.index,e.length)-1;return{cursor:{index:n,draft:t.index===-1?r:t.draft},text:e[n]}}if(t.index===-1)return null;let i=t.index+1;return i<e.length?{cursor:{index:i,draft:t.draft},text:e[i]}:{cursor:Il,text:t.draft}}function Rl(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function zl(e,t){let n=typeof e==`string`?e:``,r=Math.max(0,Math.min(typeof t==`number`&&Number.isFinite(t)?Math.floor(t):0,n.length)),i=n.slice(0,r),a=i.lastIndexOf(`@`);if(a===-1||!Rl(a>0?i[a-1]:void 0))return null;let o=i.slice(a+1);return/[\s@]/.test(o)?null:{start:a,query:o}}function Bl(e){let t=Math.max(e.lastIndexOf(`/`),e.lastIndexOf(`\\`));return t<0?{folder:``,name:e}:{folder:e.slice(0,t).replace(/[\\/]+$/,``),name:e.slice(t+1)}}var Vl=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function Hl(e,t,n=50){let r=t.toLowerCase();if(!r)return e.slice(0,n);let i=[],a=[];for(let t of e){let e=t.name.toLowerCase().indexOf(r);e===0?i.push(t):e>0&&a.push(t)}return[...i,...a].slice(0,n)}function Ul(e,t,n,r){let i=r.path.includes(`\\`)?`\\`:`/`,a=`@${r.path}${r.directory?i:` `}`,o=e.slice(n);return{text:e.slice(0,t.start)+a+(r.directory?o:o.replace(/^ /,``)),cursor:t.start+a.length}}function Wl(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Gl=``;function Kl(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function ql(e,t){return{first:!e.slice(0,t).includes(`
|
|
18
19
|
`),last:!e.slice(t).includes(`
|
|
19
|
-
`)}}var Il=null;function Ll(){if(Il?.isConnected)return Il;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),Il=e,e}function Rl(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function zl(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Nl,e.appendChild(n),n.offsetTop}function Bl(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=Fl(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Ll();if(Rl(e,i)<=0)return r;let a=zl(i,t.slice(0,n)),o=zl(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Pl(a,o,Ml(e))}var Vl={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Hl={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed. Read the current list before choosing again.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. Read the current model before choosing again.`},Ul=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Wl=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Gl(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>he.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function Kl(){let{t:e}=D();return(0,m.useCallback)(t=>`${t.model} · ${e(Vl[t.thinking])}`,[e])}function ql({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:f=`conversation`}){let{t:p}=D(),h=Kl(),g=t.status===`ready`,v=n.preview,y=g||!!v||n.loading&&t.status!==`preparing`,b=g?t.epoch:null,x=g?t.attachmentVersion:null,{error:S,loading:C,reread:w}=n,T=g?n.catalog:void 0,E=T??v,[O,k]=(0,m.useState)(``),[A,ee]=(0,m.useState)(!1),[j,te]=(0,m.useState)(``),M=(0,m.useRef)(null),ne=(0,m.useRef)(null),N=(0,m.useRef)(null),re=(0,m.useRef)(null),ie=(0,m.useRef)(c);ie.current=c,(0,m.useEffect)(()=>{k(``)},[e,b,x]);let P=(0,m.useCallback)((e=!0,t)=>{t?ie.current(!1,t):ie.current(!1),te(``),k(``),e&&ne.current?.focus({preventScroll:!0})},[]);(0,m.useEffect)(()=>{if(!s)return;y&&N.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||P(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,P,y]);let ae=T?.selected??null,F=i??ae??(v?r:null)??E?.remembered??null,oe=(0,m.useMemo)(()=>{let e=j.trim().toLowerCase(),t=new Map;for(let n of E?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[E,j]),I=E?.entries.find(e=>Wl(e,F)),L=(g||!!v)&&!!E&&!C&&!S&&n.isCurrent(),R=async(t,r)=>{if(!L||!n.isCurrent()||!E||!t.api||A||o)return;let i=ge({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),P(!0,`chosen`);else if(T&&e){if(ae&&Ul(ae,i))P(!0,`chosen`),u?.(i);else{ee(!0),k(``);try{let t=await e.chooseModel({expected:T.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){k(t.error.code),w();return}let r={...T,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),P(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(k(`uncertain`),w())}finally{ee(!1)}}}},z=()=>[...re.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],B=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=z(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?N.current?.focus():t[Math.min(n,t.length-1)]?.focus()},V=t.status===`stopped`||t.status===`not-started`,H=E?null:r,U=n.preview||n.loading&&a||S&&a?p(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):V?p(`Choose a model`):t.status===`preparing`?p(`Preparing execution…`):t.status===`connecting`?p(`Checking execution state…`):t.status===`unavailable`?p(`Execution state unavailable`):p(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`),W=F?h(F):V&&H?p(`Last used: {model}`,{model:h(H)}):U;return(0,_.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,_.jsxs)(`button`,{ref:ne,type:`button`,className:`model-trigger${F&&!ae||H?` remembered`:``}${E&&!F?` empty`:``}`,"aria-label":p(`Model: {model}`,{model:W}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?p(`Switch models after the current reply finishes.`):i?p(`Choose now; the model is verified when you send.`):H?p(`Last used model; availability is checked when you send.`):F&&!ae?p(`Last used model; it is used again when you send.`):F?`${F.provider}/${F.model} · ${F.api}`:U,onClick:()=>{s?P():(k(``),c(!0))},children:[(0,_.jsx)(fa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`model-trigger-text`,children:W}),(0,_.jsx)(Sa,{"aria-hidden":`true`})]}),s&&(0,_.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":p(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),P())},children:[d&&(0,_.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose a model; your message is sent right after.`)}),v&&(0,_.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose now; the model is verified when you send.`)}),!y&&!S&&(0,_.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?p(`Execution is being prepared for your Send. Models will load when it is ready.`):p(`Model selection is unavailable until the current conversation and execution state are observed.`)}),H&&(0,_.jsxs)(`p`,{className:`model-popover-lead`,children:[p(`Last used: {model}`,{model:h(H)}),(0,_.jsx)(`br`,{}),p(`Last used model; availability is checked when you send.`)]}),y&&(0,_.jsxs)(`label`,{className:`model-search`,children:[(0,_.jsx)(Ii,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{ref:N,type:`search`,"aria-label":p(`Search models`),placeholder:p(`Search models…`),value:j,onChange:e=>te(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),z()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),z()[0]?.click())}})]}),y&&(0,_.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":p(`Models`),ref:re,onKeyDown:B,children:[C&&(0,_.jsx)(`p`,{className:`model-empty`,role:`status`,children:p(`Reading models…`)}),oe.map(([e,t])=>(0,_.jsxs)(`fieldset`,{className:`model-group`,children:[(0,_.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=Wl(e,F);return(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!L||!t||A||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void R(e,Gl(e,F?.thinking??`medium`)),children:[(0,_.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,_.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?p(`Credentials unavailable`):p(`Not supported`)}),n&&(!ae||!!i)&&(0,_.jsx)(`span`,{className:`model-option-note`,children:p(`Used when you send`)}),n&&(0,_.jsx)(Ca,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),E?.status===`complete`&&oe.length===0&&(0,_.jsx)(`p`,{className:`model-empty`,children:j.trim()?p(`No matching models.`):p(v?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.`)})]}),y&&I&&I.thinking.length>1&&(0,_.jsxs)(`div`,{className:`model-thinking`,children:[(0,_.jsx)(`span`,{className:`model-thinking-label`,children:p(`Thinking`)}),I.thinking.map(e=>(0,_.jsx)(`button`,{type:`button`,"aria-label":p(`Thinking level: {level}`,{level:p(Vl[e.level])}),"aria-pressed":F?.thinking===e.level,disabled:!L||!e.selectable||A||o,onClick:()=>void R(I,e.level),children:p(Vl[e.level])},e.level))]}),(0,_.jsxs)(`div`,{className:`model-popover-notes`,children:[v&&!S&&(0,_.jsx)(`button`,{type:`button`,className:`link`,disabled:C||A,onClick:()=>w(!0),children:p(`Refresh models`)}),o&&(0,_.jsx)(`p`,{children:p(`Switch models after the current reply finishes.`)}),E?.status===`capacity`&&(0,_.jsx)(`p`,{role:`alert`,children:p(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!E?.withheld&&(0,_.jsx)(`p`,{role:`alert`,children:p(E.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; reopen the picker 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; reopen the picker after editing models.json.`,{count:E.withheld})}),(g||!!a)&&S&&(0,_.jsxs)(`p`,{role:`alert`,children:[p(`The model list could not be read ({code}).`,{code:S}),` `,(0,_.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>w(!0),children:p(`Read again`)})]}),O&&(0,_.jsx)(`p`,{role:`alert`,children:Hl[O]?p(Hl[O]):p(`The model was not changed ({code}).`,{code:O})}),L&&(0,_.jsx)(`p`,{className:`model-popover-scope`,children:p(A?`Switching model…`:f===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function Jl({active:e,armed:t,known:n,disabled:r,onClick:i}){let{t:a}=D(),o=n?e?`on`:t?`armed`:`off`:`unknown`,s=a(n?e?`Cadence on`:t?`Cadence on next Send`:`Cadence off`:`Cadence state unavailable`);return(0,_.jsxs)(`button`,{type:`button`,className:`mode-toggle ${o}`,"aria-label":s,disabled:r||!n,title:a(e?`Cadence mode is on. Click to exit it.`:t?`Your next message turns on Cadence mode. Click to cancel.`:`Turn on Cadence mode: agree on a plan before implementation.`),onClick:i,children:[(0,_.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),s]})}var Yl=.1,Xl=(e,t)=>Math.max(Yl,Math.min(4,e*t));function Zl({blob:e,label:t,onClose:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({width:0,height:0}),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null);(0,m.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,m.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let h=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;p(n=>Xl(n??t,e))},g=(e,t,n,r=!1)=>(0,_.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,_.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,_.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,_.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,_.jsx)(`span`,{className:`img-lightbox-name`,children:t}),g(r(`Close`),(0,_.jsx)(Di,{"aria-hidden":`true`}),n)]}),(0,_.jsxs)(`div`,{className:`img-lightbox-image${f===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,_.jsx)(`img`,{ref:a,src:o,alt:t,style:f===null||!c.width?void 0:{width:c.width*f,height:c.height*f},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,_.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,_.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,_.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),g(r(`Zoom out`),(0,_.jsx)(Ti,{"aria-hidden":`true`}),()=>h(1/1.25),!c.width||f!==null&&f<=.1),g(r(`Actual size`),(0,_.jsx)(qi,{"aria-hidden":`true`}),()=>p(1),!c.width||f===1),f!==null&&(0,_.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(f*100),`%`]}),g(r(`Zoom in`),(0,_.jsx)(Ei,{"aria-hidden":`true`}),()=>h(1.25),!c.width||f!==null&&f>=4),g(r(`Fit to window`),(0,_.jsx)(Wi,{"aria-hidden":`true`}),()=>p(null),f===null)]})]})})}function Ql(){let[e,t]=(0,m.useState)([]),n=(0,m.useRef)(e),r=(0,m.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];Zc(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,m.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),replace:(0,m.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function $l(e){let[t,n]=(0,m.useState)(null);return{open:n,lightbox:t&&(0,_.jsx)(Zl,{blob:t,label:e,onClose:()=>n(null)})}}function eu({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=D();return(0,_.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,_.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function tu({file:e,disabled:t,remove:n}){let{t:r}=D(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),{open:c,lightbox:l}=$l(e.name);return(0,m.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),Qc(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,_.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,_.jsx)(eu,{url:i,alt:e.name,onOpen:()=>c(e)}),o&&(0,_.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid image.`)}),(0,_.jsx)(`span`,{title:e.name,children:e.name}),(0,_.jsx)(`button`,{type:`button`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function nu({image:e,read:t}){let{t:n}=D(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(!1),{open:s,lightbox:c}=$l(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:f}=e;return(0,m.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...f?{live:f}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,f]),(0,_.jsxs)(_.Fragment,{children:[a?(0,_.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,_.jsx)(eu,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,_.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function ru({images:e,turn:t}){return(0,_.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,_.jsx)(nu,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var iu=`cadence:composer-height`,au=16;function ou(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var su=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,cu=()=>su(typeof window>`u`?0:window.innerHeight);function lu({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:f,hint:p,running:h,canStop:g,onStop:v,canSend:y,onSend:b,input:x,historyScope:C,files:w,onResized:T}){let{t:E}=D(),O=(0,m.useRef)(null),k=(0,m.useRef)(null),A=(0,m.useId)(),[ee,j]=(0,m.useState)(()=>{try{return ou(localStorage.getItem(iu))}catch{return null}}),[te,M]=(0,m.useState)(64),[ne,N]=(0,m.useState)(``);(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=cu();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(ee===null?Math.max(r,64):ee,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,M(i)},[t,ee,ne,e]);let re=(0,m.useRef)(T);re.current=T,(0,m.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.offsetHeight,n=()=>{N(`${e.clientWidth}:${window.innerHeight}`),e.offsetHeight!==t&&(t=e.offsetHeight,re.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let ie=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(j(n),t)try{n===null?localStorage.removeItem(iu):localStorage.setItem(iu,String(n))}catch{}},P=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>P.current?.(),[]);let ae=(0,m.useRef)(wl),F=(0,m.useRef)(null);(0,m.useEffect)(()=>{t!==F.current&&(ae.current=wl)},[t]);let oe=(0,m.useRef)(null),[I,L]=(0,m.useState)(-1);(0,m.useLayoutEffect)(()=>{let t=e.current;t&&oe.current!==null&&(t.setSelectionRange(oe.current,oe.current),L(oe.current),oe.current=null)},[t,e]);let R=e=>{F.current=e,oe.current=e.length,n(e)},[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)(-1),[U,W]=(0,m.useState)(null),{location:G}=w,K=G&&z&&!r&&U===t?Dl(t,I):null,q=Ol(K?.query??``),se=K!==null&&K.start!==V&&kl(q.folder),ce=go(w.client,se&&G?{kind:`files`,path:q.folder,location:G}:null),le=ce.value?.kind===`files`?ce.value:void 0,J=le?Al(le.entries,q.name):[],[ue,Y]=(0,m.useState)(0),de=K?`${K.start}:${K.query}`:``;(0,m.useEffect)(()=>{Y(0),de||H(-1)},[de]);let fe=Math.min(ue,J.length-1),pe=J[fe],me=pe?`${A}-${fe}`:void 0;(0,m.useEffect)(()=>{me&&document.getElementById(me)?.scrollIntoView({block:`nearest`})},[me]);let he=e=>{if(!K)return;let r=jl(t,K,I,e);oe.current=r.cursor,W(r.text),n(r.text)},ge=e=>{if(!e.nativeEvent.isComposing){if(se){if(e.key===`Escape`){e.preventDefault(),H(K.start);return}if(pe){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;Y((fe+t+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),he(pe);return}}}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){let n=e.key===`ArrowUp`;if(!n&&ae.current.index===-1)return;let r=Bl(e.currentTarget);if(n?!r.first:!r.last)return;let i=Tl(xl(C),ae.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),ae.current=i.cursor,R(i.text)}else if(e.key===`Escape`&&ae.current.index!==-1){e.preventDefault();let t=ae.current.draft;ae.current=wl,R(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),h&&x?x.enabled&&x.onInput(e.altKey?`queue`:`steer`):b())}},_e=E(ee===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,_.jsxs)(`form`,{ref:O,className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),h||b()},children:[(0,_.jsx)(`input`,{type:`range`,className:`composer-resize${ee===null?``:` is-manual`}`,min:64,max:320,step:au,value:Math.round(te),"aria-label":_e,title:_e,"aria-orientation":`vertical`,"aria-valuetext":ee===null?E(`Automatic`):E(`{pixels} pixels`,{pixels:Math.round(te)}),onChange:e=>ie(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),ie(null,!0))},onDoubleClick:()=>ie(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),P.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??te,i=null,a=e=>{i=Math.min(cu(),Math.max(64,r+(n-e.clientY))),ie(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),P.current=void 0,i!==null&&ie(i,!0)};P.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,_.jsx)(`input`,{ref:k,type:`file`,accept:Un.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":E(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,_.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,_.jsx)(tu,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,_.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),se&&(0,_.jsxs)(`div`,{className:`mention-menu`,id:A,role:`listbox`,"aria-label":E(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:[(0,_.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,_.jsx)(`span`,{className:`mention-menu-folder`,children:q.folder?`@${q.folder}`:E(`Files in the conversation folder`)}),(0,_.jsx)(`span`,{children:E(`Enter inserts the path · Esc closes`)})]}),ce.error?(0,_.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:S(E,ce.error)}):le?J.length===0?(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`No matching files`)}):null:(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`Reading files…`)}),J.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,id:`${A}-${t}`,className:`mention-item${e===pe?` active`:``}`,"aria-selected":e===pe,tabIndex:-1,title:e.path,onMouseEnter:()=>Y(t),onClick:()=>he(e),children:[e.directory?(0,_.jsx)(ia,{"aria-hidden":`true`}):(0,_.jsx)(aa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,_.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),le?.limited&&(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`Bounded listing; narrow the directory to see more.`)})]}),(0,_.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":E(`Message`),"aria-autocomplete":G?`list`:void 0,"aria-controls":se?A:void 0,"aria-activedescendant":se?me:void 0,value:t,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{L(e.target.selectionStart),W(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;L(t===n?t:-1)},onFocus:()=>B(!0),onBlur:()=>B(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:ge}),(0,_.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>k.current?.click(),children:(0,_.jsx)($i,{"aria-hidden":`true`})}),(0,_.jsx)(Jl,{...d}),(0,_.jsx)(ql,{...f}),(0,_.jsx)(`span`,{className:`composer-hint`,children:p}),h&&x?.enabled&&(0,_.jsxs)(`span`,{className:`composer-split`,children:[(0,_.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":E(`Queue behind this reply`),title:E(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>x.onInput(`queue`),children:(0,_.jsx)(Yi,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":E(`Steer this reply`),title:E(`Steer: read at the model's next step (Enter)`),onClick:()=>x.onInput(`steer`),children:(0,_.jsx)(Ta,{"aria-hidden":`true`})})]}),h?(0,_.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":E(`Stop response`),title:E(`Stop response`),disabled:!g,onClick:v,children:(0,_.jsx)(Mi,{"aria-hidden":`true`})}):(0,_.jsx)(`button`,{"aria-label":E(`Send`),title:E(`Send`),type:`submit`,className:`primary`,disabled:!y,children:(0,_.jsx)(Ta,{"aria-hidden":`true`})})]})]})}var uu={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,py:`python`,rs:`rust`,go:`go`,java:`java`,kt:`kotlin`,swift:`swift`,rb:`ruby`,php:`php`,lua:`lua`,pl:`perl`,r:`r`,cs:`csharp`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,md:`markdown`,sql:`sql`,diff:`diff`,patch:`diff`,graphql:`graphql`,mk:`makefile`};function du(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(uu,n)&&uu[n]||`plaintext`}var fu=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function pu(e,t){let n={oldTokens:[{type:`del`,text:e}],newTokens:[{type:`add`,text:t}]};if(!e||!t||e.length>800||t.length>800)return n;let r=e.match(fu)||[e],i=t.match(fu)||[t],a=r.length,o=i.length;if(a*o>4e3)return n;let s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=r[e-1]===i[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);if(s[a][o]/Math.max(a,o)<.25)return n;let c=[],l=[],u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(c.push({type:`same`,text:r[u-1]}),l.push({type:`same`,text:i[d-1]}),u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l.push({type:`add`,text:i[d-1]}),d--):(c.push({type:`del`,text:r[u-1]}),u--);let f=e=>{let t=[];for(let n of e.reverse()){let e=t.at(-1);e?.type===n.type?e.text+=n.text:t.push({...n})}return t};return{oldTokens:f(c),newTokens:f(l)}}function mu(e){if(!e)return[];let t=e.split(`
|
|
20
|
-
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function hu(e){let t=0,n=0;return{hunks:e.map(e=>{let r=typeof e.oldText==`string`?e.oldText:``,i=typeof e.newText==`string`?e.newText:``,a=mu(r),o=mu(i);n+=a.length,t+=o.length;let s=[];if(a.length===1&&o.length===1){let{oldTokens:e,newTokens:t}=pu(a[0],o[0]);s.push({type:`del`,content:a[0],tokens:e}),s.push({type:`add`,content:o[0],tokens:t})}else{for(let e of a)s.push({type:`del`,content:e});for(let e of o)s.push({type:`add`,content:e})}return{removed:a.length,added:o.length,lines:s}}),additions:t,deletions:n}}var gu=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function _u(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!gu(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:du(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=mu(n.content);return{...i,isWrite:!0,additions:e.length,deletions:0,hunks:[{removed:0,added:e.length,lines:e.map(e=>({type:`add`,content:e}))}]}}let a=[...Array.isArray(n.edits)?n.edits.filter(gu):[],...typeof n.oldText==`string`||typeof n.newText==`string`?[{oldText:n.oldText,newText:n.newText}]:[]];return a.length===0?null:{...i,isWrite:!1,...hu(a)}}function vu({line:e}){return(0,_.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,_.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,_.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,_.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function yu({data:e,failed:t=!1}){let{t:n}=D(),[r,i]=(0,m.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,_.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,_.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,_.jsxs)(`div`,{className:`file-diff-info`,children:[(0,_.jsx)(oa,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,_.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,_.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,_.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,_.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,_.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,_.jsx)(ja,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]})]}),(0,_.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,_.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,_.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,_.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,_.jsx)(`div`,{className:`diff-hunk-header`,children:(0,_.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,_.jsx)(vu,{line:e},t))]},r))})}),!r&&a>400&&(0,_.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function bu(e){let t=e.items.map(e=>({...Hr(e,1),text:e.role===`tool`||e.role===`thinking`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,...e.retry?{retry:e.retry}:{},omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function xu(e){return e.state===`pending`||e.state===`streaming`||e.state===`running`}function Su(e,t,n,r){let i=`${e.renderId??e.header.id}:${nl(n)}`,a=JSON.stringify([t,n.parts,n.version,n.state,n.error,e.header.status]),{detail:o}=e,s=(0,m.useMemo)(()=>({identity:i,revision:a,detail:o,wanted:r}),[i,a,o,r]),c=(0,m.useRef)(s);c.current=s;let[l,u]=(0,m.useState)(),d=n.parts;return(0,m.useEffect)(()=>{if(!r||d===0)return;let e=new AbortController,n=()=>!e.signal.aborted&&c.current===s;return o(t,d,e.signal).then(e=>{n()&&u({identity:i,value:e})},e=>{n()&&u(t=>({identity:i,...t?.identity===i?{value:t.value}:{},error:e instanceof Error?e.message:`unavailable`}))}),()=>e.abort()},[s,o,t,d,r,i]),r&&d>0&&l?.identity===i?l:{}}function Cu(e){let t=e.map((e,t)=>({step:e,index:t,key:nl(e)}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var wu={bash:[Ai,`exec`],powershell:[Ai,`exec`],read:[oa,`read`],ls:[ia,`read`],write:[ca,`edit`],edit:[la,`edit`],grep:[Ii,`search`],find:[ga,`search`]},Tu=[ki,`default`],Eu=e=>Object.hasOwn(wu,e)?wu[e]:Tu;function Du(e,t){let n=e.steps[t];return n?.error||n?.state===`failed`?`err`:n?.state===`completed`?`ok`:n&&xu(n)&&(e.header.status===`queued`||e.header.status===`running`)?`run`:`idle`}var Ou={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function ku(){return(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,_.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function Au({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,_.jsx)(fs,{text:e})}){let{t:a}=D(),o=t<e.header.stable,s=Su(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,_.jsxs)(_.Fragment,{children:[n.images?.length?(0,_.jsx)(ru,{images:n.images,turn:e}):null,c.trim()!==``&&(0,_.jsxs)(`div`,{className:`msg-text single`,children:[(0,_.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,_.jsx)(os,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,_.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?S(a,s.error):a(`Reading the rest of this message…`)})]})}function ju(e){try{let t=JSON.parse(e),n=t&&typeof t==`object`&&Object.hasOwn(t,`command`)?t.command:void 0;return typeof n==`string`&&n?n:void 0}catch{return}}function Mu(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Nu({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=Su(e,t,n,i),[s,c]=Eu(n.name),l=Du(e,t),u=r(Ou[l]),d=o.value?.args,f=d?ju(d):void 0,p=(0,m.useMemo)(()=>d?_u(n.name,d):null,[n.name,d]);return(0,_.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,_.jsx)(Xs,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,_.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,_.jsx)(Di,{"aria-hidden":`true`}):l===`ok`?(0,_.jsx)(Ca,{"aria-hidden":`true`}):l===`run`?(0,_.jsx)(ku,{}):(0,_.jsx)(Ui,{"aria-hidden":`true`})}),n.target&&(0,_.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,_.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,_.jsx)(os,{text:n.target,className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,_.jsxs)(`div`,{className:`toolcall-body`,children:[n.parts===0?(0,_.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,_.jsxs)(_.Fragment,{children:[o.value.args&&(0,_.jsx)(`div`,{className:`toolcall-args`,children:p?(0,_.jsx)(yu,{data:p,failed:l===`err`}):f?(0,_.jsxs)(`div`,{className:`termline`,children:[(0,_.jsx)(Ai,{className:`termline-icon`,"aria-hidden":`true`}),(0,_.jsx)(`code`,{children:f})]}):(0,_.jsx)(`pre`,{children:Mu(o.value.args)})}),o.value.text&&(0,_.jsxs)(`div`,{className:`toolcall-output`,children:[(0,_.jsx)(`div`,{className:`toolcall-output-label`,children:r(n.error?`Error output`:`Output`)}),(0,_.jsx)(`pre`,{children:o.value.text})]})]}):(0,_.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?S(r,o.error):r(`Reading…`)}),o.value&&o.error&&(0,_.jsx)(`p`,{className:`banner-notice`,children:S(r,o.error)})]})]})}function Pu({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=Su(e,t,n,i&&n.parts>0),s=xu(n)&&(e.header.status===`queued`||e.header.status===`running`);if(n.parts===0)return(0,_.jsx)(`div`,{className:`thinking`,children:(0,_.jsxs)(`div`,{className:`chead thinking-head`,title:r(`Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.`),children:[(0,_.jsx)(fa,{className:`thinking-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`thinking-label`,role:`status`,children:r(s?`Thinking activity observed`:n.state===`completed`?`Thinking activity ended`:`Thinking content unavailable`)}),s&&(0,_.jsx)(ku,{})]})});let c=o.value?.text.trim()??``;return(0,_.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,_.jsx)(Xs,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,_.jsx)(fa,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`toolcall-spacer`}),c&&(0,_.jsx)(os,{text:c,className:`chead-copy`})]}),children:r(`Thinking`)}),i&&(0,_.jsx)(`div`,{className:`thinking-body`,children:c||(0,_.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?S(r,o.error):o.value?r(`No thinking text is recorded for this block.`):r(`Reading…`)})})]})}var Fu=s().use(p).use(c).use(f).use(Wo);function Iu(e){return e.type===`definition`||e.type===`linkReference`||e.type===`imageReference`||e.type===`footnoteDefinition`||e.type===`footnoteReference`||(e.children?.some(Iu)??!1)}function Lu(e,t){if(e?.type!==`code`)return!1;let n=t.split(/\r\n|\r|\n/),r=/^ {0,3}(`{3,}|~{3,})/.exec(n[0]);if(!r)return!1;let i=r[1];return!n.slice(1).some(e=>{let t=/^ {0,3}(`{3,}|~{3,})[\t ]*$/.exec(e);return t&&t[1][0]===i[0]&&t[1].length>=i.length})}function Ru(e){let{children:t}=Fu.parse(e),n=e?[0]:[];for(let e=0;e<t.length;e++){let r=t[e],i=r.position?.start;if(e>0&&i?.offset!==void 0&&n.push(i.offset-(i.column-1)),Iu(r))break}let r=n.map((t,r)=>({start:t,text:e.slice(t,n[r+1])})),i=r.at(-1)?.text??``,a=t.at(-1),o=r.length===t.length&&Lu(a,e.slice(a?.position?.start.offset));return{segments:r,frozen:r.slice(0,-1).map(e=>e.text),active:i,inFence:o}}var zu=(0,m.memo)(function({text:e}){return(0,_.jsx)(ds,{text:e})}),Bu=(0,m.memo)(function({text:e}){let{segments:t}=(0,m.useMemo)(()=>Ru(e),[e]);return(0,_.jsx)(`div`,{className:`md`,children:t.map(e=>(0,_.jsx)(zu,{text:e.text},`stream-offset:${e.start}`))})});function Vu(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
20
|
+
`)}}var Jl=null;function Yl(){if(Jl?.isConnected)return Jl;let e=document.createElement(`div`);e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`data-caret-mirror`,``);let t=e.style;return t.position=`fixed`,t.top=`0`,t.left=`-99999px`,t.visibility=`hidden`,t.pointerEvents=`none`,t.margin=`0`,t.padding=`0`,t.border=`0`,t.boxSizing=`border-box`,t.overflow=`visible`,document.body.appendChild(e),Jl=e,e}function Xl(e,t){let n=getComputedStyle(e),r=t.style;r.fontFamily=n.fontFamily,r.fontSize=n.fontSize,r.fontStyle=n.fontStyle,r.fontWeight=n.fontWeight,r.fontVariant=n.fontVariant,r.fontStretch=n.fontStretch,r.lineHeight=n.lineHeight,r.letterSpacing=n.letterSpacing,r.wordSpacing=n.wordSpacing,r.textTransform=n.textTransform,r.textIndent=n.textIndent,r.tabSize=n.tabSize,r.whiteSpace=n.whiteSpace||`pre-wrap`,r.overflowWrap=n.overflowWrap||`break-word`,r.wordBreak=n.wordBreak||`normal`,r.direction=n.direction,r.writingMode=n.writingMode,r.paddingLeft=n.paddingLeft,r.paddingRight=n.paddingRight;let i=e.clientWidth;return i>0?(r.width=`${i}px`,i):0}function Zl(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Gl,e.appendChild(n),n.offsetTop}function Ql(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=ql(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=Yl();if(Xl(e,i)<=0)return r;let a=Zl(i,t.slice(0,n)),o=Zl(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Kl(a,o,Wl(e))}var $l={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},eu={conflict:`A reply or workflow is still running in this project. Switch models after it finishes.`,stale:`The model list changed. Read the current list before choosing again.`,"auth-unavailable":`This model's credentials are unavailable. Check auth.json or the provider's API key.`,"unsupported-context":`This model or thinking level is not supported.`,uncertain:`The choice was not confirmed. Read the current model before choosing again.`},tu=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,nu=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function ru(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>he.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function iu(){let{t:e}=D();return(0,m.useCallback)(t=>`${t.model} · ${e($l[t.thinking])}`,[e])}function au({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:f=`conversation`}){let{t:p}=D(),h=iu(),g=t.status===`ready`,v=n.preview,y=g||!!v||n.loading&&t.status!==`preparing`,b=g?t.epoch:null,x=g?t.attachmentVersion:null,{error:S,loading:C,reread:w}=n,T=g?n.catalog:void 0,E=T??v,[O,k]=(0,m.useState)(``),[A,ee]=(0,m.useState)(!1),[j,te]=(0,m.useState)(``),M=(0,m.useRef)(null),ne=(0,m.useRef)(null),N=(0,m.useRef)(null),re=(0,m.useRef)(null),ie=(0,m.useRef)(c);ie.current=c,(0,m.useEffect)(()=>{k(``)},[e,b,x]);let P=(0,m.useCallback)((e=!0,t)=>{t?ie.current(!1,t):ie.current(!1),te(``),k(``),e&&ne.current?.focus({preventScroll:!0})},[]);(0,m.useEffect)(()=>{if(!s)return;y&&N.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||P(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,P,y]);let ae=T?.selected??null,F=i??ae??(v?r:null)??E?.remembered??null,oe=(0,m.useMemo)(()=>{let e=j.trim().toLowerCase(),t=new Map;for(let n of E?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[E,j]),I=E?.entries.find(e=>nu(e,F)),L=(g||!!v)&&!!E&&!C&&!S&&n.isCurrent(),R=async(t,r)=>{if(!L||!n.isCurrent()||!E||!t.api||A||o)return;let i=ge({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),P(!0,`chosen`);else if(T&&e){if(ae&&tu(ae,i))P(!0,`chosen`),u?.(i);else{ee(!0),k(``);try{let t=await e.chooseModel({expected:T.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){k(t.error.code),w();return}let r={...T,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),P(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(k(`uncertain`),w())}finally{ee(!1)}}}},z=()=>[...re.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],B=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=z(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?N.current?.focus():t[Math.min(n,t.length-1)]?.focus()},V=t.status===`stopped`||t.status===`not-started`,H=E?null:r,U=n.preview||n.loading&&a||S&&a?p(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):V?p(`Choose a model`):t.status===`preparing`?p(`Preparing execution…`):t.status===`connecting`?p(`Checking execution state…`):t.status===`unavailable`?p(`Execution state unavailable`):p(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`),W=F?h(F):V&&H?p(`Last used: {model}`,{model:h(H)}):U;return(0,_.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,_.jsxs)(`button`,{ref:ne,type:`button`,className:`model-trigger${F&&!ae||H?` remembered`:``}${E&&!F?` empty`:``}`,"aria-label":p(`Model: {model}`,{model:W}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?p(`Switch models after the current reply finishes.`):i?p(`Choose now; the model is verified when you send.`):H?p(`Last used model; availability is checked when you send.`):F&&!ae?p(`Last used model; it is used again when you send.`):F?`${F.provider}/${F.model} · ${F.api}`:U,onClick:()=>{s?P():(k(``),c(!0))},children:[(0,_.jsx)(wa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`model-trigger-text`,children:W}),(0,_.jsx)(Pa,{"aria-hidden":`true`})]}),s&&(0,_.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":p(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),P())},children:[d&&(0,_.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose a model; your message is sent right after.`)}),v&&(0,_.jsx)(`p`,{className:`model-popover-lead`,children:p(`Choose now; the model is verified when you send.`)}),!y&&!S&&(0,_.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?p(`Execution is being prepared for your Send. Models will load when it is ready.`):p(`Model selection is unavailable until the current conversation and execution state are observed.`)}),H&&(0,_.jsxs)(`p`,{className:`model-popover-lead`,children:[p(`Last used: {model}`,{model:h(H)}),(0,_.jsx)(`br`,{}),p(`Last used model; availability is checked when you send.`)]}),y&&(0,_.jsxs)(`label`,{className:`model-search`,children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{ref:N,type:`search`,"aria-label":p(`Search models`),placeholder:p(`Search models…`),value:j,onChange:e=>te(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),z()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),z()[0]?.click())}})]}),y&&(0,_.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":p(`Models`),ref:re,onKeyDown:B,children:[C&&(0,_.jsx)(`p`,{className:`model-empty`,role:`status`,children:p(`Reading models…`)}),oe.map(([e,t])=>(0,_.jsxs)(`fieldset`,{className:`model-group`,children:[(0,_.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=nu(e,F);return(0,_.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!L||!t||A||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void R(e,ru(e,F?.thinking??`medium`)),children:[(0,_.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,_.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?p(`Credentials unavailable`):p(`Not supported`)}),n&&(!ae||!!i)&&(0,_.jsx)(`span`,{className:`model-option-note`,children:p(`Used when you send`)}),n&&(0,_.jsx)(Fa,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),E?.status===`complete`&&oe.length===0&&(0,_.jsx)(`p`,{className:`model-empty`,children:j.trim()?p(`No matching models.`):p(v?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then reopen the model picker.`)})]}),y&&I&&I.thinking.length>1&&(0,_.jsxs)(`div`,{className:`model-thinking`,children:[(0,_.jsx)(`span`,{className:`model-thinking-label`,children:p(`Thinking`)}),I.thinking.map(e=>(0,_.jsx)(`button`,{type:`button`,"aria-label":p(`Thinking level: {level}`,{level:p($l[e.level])}),"aria-pressed":F?.thinking===e.level,disabled:!L||!e.selectable||A||o,onClick:()=>void R(I,e.level),children:p($l[e.level])},e.level))]}),(0,_.jsxs)(`div`,{className:`model-popover-notes`,children:[v&&!S&&(0,_.jsx)(`button`,{type:`button`,className:`link`,disabled:C||A,onClick:()=>w(!0),children:p(`Refresh models`)}),o&&(0,_.jsx)(`p`,{children:p(`Switch models after the current reply finishes.`)}),E?.status===`capacity`&&(0,_.jsx)(`p`,{role:`alert`,children:p(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!E?.withheld&&(0,_.jsx)(`p`,{role:`alert`,children:p(E.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; reopen the picker 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; reopen the picker after editing models.json.`,{count:E.withheld})}),(g||!!a)&&S&&(0,_.jsxs)(`p`,{role:`alert`,children:[p(`The model list could not be read ({code}).`,{code:S}),` `,(0,_.jsx)(`button`,{type:`button`,className:`link`,onClick:()=>w(!0),children:p(`Read again`)})]}),O&&(0,_.jsx)(`p`,{role:`alert`,children:eu[O]?p(eu[O]):p(`The model was not changed ({code}).`,{code:O})}),L&&(0,_.jsx)(`p`,{className:`model-popover-scope`,children:p(A?`Switching model…`:f===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function ou({active:e,armed:t,known:n,disabled:r,onClick:i}){let{t:a}=D(),o=n?e?`on`:t?`armed`:`off`:`unknown`,s=a(n?e?`Cadence on`:t?`Cadence on next Send`:`Cadence off`:`Cadence state unavailable`);return(0,_.jsxs)(`button`,{type:`button`,className:`mode-toggle ${o}`,"aria-label":s,disabled:r||!n,title:a(e?`Cadence mode is on. Click to exit it.`:t?`Your next message turns on Cadence mode. Click to cancel.`:`Turn on Cadence mode: agree on a plan before implementation.`),onClick:i,children:[(0,_.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),s]})}var su=.1,cu=(e,t)=>Math.max(su,Math.min(4,e*t));function lu({blob:e,label:t,onClose:n}){let{t:r}=D(),i=(0,m.useRef)(null),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)({width:0,height:0}),[u,d]=(0,m.useState)(!1),[f,p]=(0,m.useState)(null);(0,m.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,m.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let h=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;p(n=>cu(n??t,e))},g=(e,t,n,r=!1)=>(0,_.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,_.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,_.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,_.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,_.jsx)(`span`,{className:`img-lightbox-name`,children:t}),g(r(`Close`),(0,_.jsx)(zi,{"aria-hidden":`true`}),n)]}),(0,_.jsxs)(`div`,{className:`img-lightbox-image${f===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,_.jsx)(`img`,{ref:a,src:o,alt:t,style:f===null||!c.width?void 0:{width:c.width*f,height:c.height*f},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,_.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,_.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,_.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),g(r(`Zoom out`),(0,_.jsx)(Li,{"aria-hidden":`true`}),()=>h(1/1.25),!c.width||f!==null&&f<=.1),g(r(`Actual size`),(0,_.jsx)(aa,{"aria-hidden":`true`}),()=>p(1),!c.width||f===1),f!==null&&(0,_.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(f*100),`%`]}),g(r(`Zoom in`),(0,_.jsx)(Ri,{"aria-hidden":`true`}),()=>h(1.25),!c.width||f!==null&&f>=4),g(r(`Fit to window`),(0,_.jsx)(na,{"aria-hidden":`true`}),()=>p(null),f===null)]})]})})}function uu(){let[e,t]=(0,m.useState)([]),n=(0,m.useRef)(e),r=(0,m.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];ll(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,m.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),replace:(0,m.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function du(e){let[t,n]=(0,m.useState)(null);return{open:n,lightbox:t&&(0,_.jsx)(lu,{blob:t,label:e,onClose:()=>n(null)})}}function fu({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=D();return(0,_.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,_.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function pu({file:e,disabled:t,remove:n}){let{t:r}=D(),[i,a]=(0,m.useState)(``),[o,s]=(0,m.useState)(!1),{open:c,lightbox:l}=du(e.name);return(0,m.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),ul(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,_.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,_.jsx)(fu,{url:i,alt:e.name,onOpen:()=>c(e)}),o&&(0,_.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid image.`)}),(0,_.jsx)(`span`,{title:e.name,children:e.name}),(0,_.jsx)(`button`,{type:`button`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function mu({image:e,read:t}){let{t:n}=D(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(!1),{open:s,lightbox:c}=du(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:f}=e;return(0,m.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...f?{live:f}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,f]),(0,_.jsxs)(_.Fragment,{children:[a?(0,_.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,_.jsx)(fu,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,_.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function hu({images:e,turn:t}){return(0,_.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,_.jsx)(mu,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var gu=`cadence:composer-height`,_u=16;function vu(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var yu=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,bu=()=>yu(typeof window>`u`?0:window.innerHeight);function xu({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:f,hint:p,running:h,canStop:g,onStop:v,canSend:y,onSend:b,input:x,historyScope:C,files:w,onResized:T}){let{t:E}=D(),O=(0,m.useRef)(null),k=(0,m.useRef)(null),A=(0,m.useId)(),[ee,j]=(0,m.useState)(()=>{try{return vu(localStorage.getItem(gu))}catch{return null}}),[te,M]=(0,m.useState)(64),[ne,N]=(0,m.useState)(``);(0,m.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=bu();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(ee===null?Math.max(r,64):ee,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,M(i)},[t,ee,ne,e]);let re=(0,m.useRef)(T);re.current=T,(0,m.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=e.offsetHeight,n=()=>{N(`${e.clientWidth}:${window.innerHeight}`),e.offsetHeight!==t&&(t=e.offsetHeight,re.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let ie=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(j(n),t)try{n===null?localStorage.removeItem(gu):localStorage.setItem(gu,String(n))}catch{}},P=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>P.current?.(),[]);let ae=(0,m.useRef)(Il),F=(0,m.useRef)(null);(0,m.useEffect)(()=>{t!==F.current&&(ae.current=Il)},[t]);let oe=(0,m.useRef)(null),[I,L]=(0,m.useState)(-1);(0,m.useLayoutEffect)(()=>{let t=e.current;t&&oe.current!==null&&(t.setSelectionRange(oe.current,oe.current),L(oe.current),oe.current=null)},[t,e]);let R=e=>{F.current=e,oe.current=e.length,n(e)},[z,B]=(0,m.useState)(!1),[V,H]=(0,m.useState)(-1),[U,W]=(0,m.useState)(null),{location:G}=w,K=G&&z&&!r&&U===t?zl(t,I):null,q=Bl(K?.query??``),se=K!==null&&K.start!==V&&Vl(q.folder),ce=Oo(w.client,se&&G?{kind:`files`,path:q.folder,location:G}:null),le=ce.value?.kind===`files`?ce.value:void 0,J=le?Hl(le.entries,q.name):[],[ue,Y]=(0,m.useState)(0),de=K?`${K.start}:${K.query}`:``;(0,m.useEffect)(()=>{Y(0),de||H(-1)},[de]);let fe=Math.min(ue,J.length-1),pe=J[fe],me=pe?`${A}-${fe}`:void 0;(0,m.useEffect)(()=>{me&&document.getElementById(me)?.scrollIntoView({block:`nearest`})},[me]);let he=e=>{if(!K)return;let r=Ul(t,K,I,e);oe.current=r.cursor,W(r.text),n(r.text)},ge=e=>{if(!e.nativeEvent.isComposing){if(se){if(e.key===`Escape`){e.preventDefault(),H(K.start);return}if(pe){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;Y((fe+t+J.length)%J.length);return}if(e.key===`Enter`||e.key===`Tab`){e.preventDefault(),he(pe);return}}}if((e.key===`ArrowUp`||e.key===`ArrowDown`)&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&!e.shiftKey){let n=e.key===`ArrowUp`;if(!n&&ae.current.index===-1)return;let r=Ql(e.currentTarget);if(n?!r.first:!r.last)return;let i=Ll(Nl(C),ae.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),ae.current=i.cursor,R(i.text)}else if(e.key===`Escape`&&ae.current.index!==-1){e.preventDefault();let t=ae.current.draft;ae.current=Il,R(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),h&&x?x.enabled&&x.onInput(e.altKey?`queue`:`steer`):b())}},_e=E(ee===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,_.jsxs)(`form`,{ref:O,className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),h||b()},children:[(0,_.jsx)(`input`,{type:`range`,className:`composer-resize${ee===null?``:` is-manual`}`,min:64,max:320,step:_u,value:Math.round(te),"aria-label":_e,title:_e,"aria-orientation":`vertical`,"aria-valuetext":ee===null?E(`Automatic`):E(`{pixels} pixels`,{pixels:Math.round(te)}),onChange:e=>ie(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),ie(null,!0))},onDoubleClick:()=>ie(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),P.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??te,i=null,a=e=>{i=Math.min(bu(),Math.max(64,r+(n-e.clientY))),ie(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),P.current=void 0,i!==null&&ie(i,!0)};P.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,_.jsx)(`input`,{ref:k,type:`file`,accept:Un.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":E(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,_.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,_.jsx)(pu,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,_.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),se&&(0,_.jsxs)(`div`,{className:`mention-menu`,id:A,role:`listbox`,"aria-label":E(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:[(0,_.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,_.jsx)(`span`,{className:`mention-menu-folder`,children:q.folder?`@${q.folder}`:E(`Files in the conversation folder`)}),(0,_.jsx)(`span`,{children:E(`Enter inserts the path · Esc closes`)})]}),ce.error?(0,_.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:S(E,ce.error)}):le?J.length===0?(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`No matching files`)}):null:(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`Reading files…`)}),J.map((e,t)=>(0,_.jsxs)(`button`,{type:`button`,role:`option`,id:`${A}-${t}`,className:`mention-item${e===pe?` active`:``}`,"aria-selected":e===pe,tabIndex:-1,title:e.path,onMouseEnter:()=>Y(t),onClick:()=>he(e),children:[e.directory?(0,_.jsx)(ga,{"aria-hidden":`true`}):(0,_.jsx)(_a,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,_.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),le?.limited&&(0,_.jsx)(`p`,{className:`mention-menu-note`,children:E(`Bounded listing; narrow the directory to see more.`)})]}),(0,_.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":E(`Message`),"aria-autocomplete":G?`list`:void 0,"aria-controls":se?A:void 0,"aria-activedescendant":se?me:void 0,value:t,placeholder:E(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{L(e.target.selectionStart),W(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;L(t===n?t:-1)},onFocus:()=>B(!0),onBlur:()=>B(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:ge}),(0,_.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":E(`Add images`),title:E(`Add images`),onClick:()=>k.current?.click(),children:(0,_.jsx)(da,{"aria-hidden":`true`})}),(0,_.jsx)(ou,{...d}),(0,_.jsx)(au,{...f}),(0,_.jsx)(`span`,{className:`composer-hint`,children:p}),h&&x?.enabled&&(0,_.jsxs)(`span`,{className:`composer-split`,children:[(0,_.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":E(`Queue behind this reply`),title:E(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>x.onInput(`queue`),children:(0,_.jsx)(sa,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":E(`Steer this reply`),title:E(`Steer: read at the model's next step (Enter)`),onClick:()=>x.onInput(`steer`),children:(0,_.jsx)(La,{"aria-hidden":`true`})})]}),h?(0,_.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":E(`Stop response`),title:E(`Stop response`),disabled:!g,onClick:v,children:(0,_.jsx)(Wi,{"aria-hidden":`true`})}):(0,_.jsx)(`button`,{"aria-label":E(`Send`),title:E(`Send`),type:`submit`,className:`primary`,disabled:!y,children:(0,_.jsx)(La,{"aria-hidden":`true`})})]})]})}var Su={ts:`typescript`,tsx:`typescript`,mts:`typescript`,cts:`typescript`,js:`javascript`,jsx:`javascript`,mjs:`javascript`,cjs:`javascript`,json:`json`,html:`xml`,htm:`xml`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,py:`python`,rs:`rust`,go:`go`,java:`java`,kt:`kotlin`,swift:`swift`,rb:`ruby`,php:`php`,lua:`lua`,pl:`perl`,r:`r`,cs:`csharp`,c:`c`,h:`c`,cpp:`cpp`,cc:`cpp`,hpp:`cpp`,sh:`bash`,bash:`bash`,zsh:`bash`,yml:`yaml`,yaml:`yaml`,toml:`ini`,ini:`ini`,md:`markdown`,sql:`sql`,diff:`diff`,patch:`diff`,graphql:`graphql`,mk:`makefile`};function Cu(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(Su,n)&&Su[n]||`plaintext`}var wu=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function Tu(e,t){let n={oldTokens:[{type:`del`,text:e}],newTokens:[{type:`add`,text:t}]};if(!e||!t||e.length>800||t.length>800)return n;let r=e.match(wu)||[e],i=t.match(wu)||[t],a=r.length,o=i.length;if(a*o>4e3)return n;let s=Array.from({length:a+1},()=>Array(o+1).fill(0));for(let e=1;e<=a;e++)for(let t=1;t<=o;t++)s[e][t]=r[e-1]===i[t-1]?s[e-1][t-1]+1:Math.max(s[e-1][t],s[e][t-1]);if(s[a][o]/Math.max(a,o)<.25)return n;let c=[],l=[],u=a,d=o;for(;u>0||d>0;)u>0&&d>0&&r[u-1]===i[d-1]?(c.push({type:`same`,text:r[u-1]}),l.push({type:`same`,text:i[d-1]}),u--,d--):d>0&&(u===0||s[u][d-1]>=s[u-1][d])?(l.push({type:`add`,text:i[d-1]}),d--):(c.push({type:`del`,text:r[u-1]}),u--);let f=e=>{let t=[];for(let n of e.reverse()){let e=t.at(-1);e?.type===n.type?e.text+=n.text:t.push({...n})}return t};return{oldTokens:f(c),newTokens:f(l)}}function Eu(e){if(!e)return[];let t=e.split(`
|
|
21
|
+
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function Du(e){let t=0,n=0;return{hunks:e.map(e=>{let r=typeof e.oldText==`string`?e.oldText:``,i=typeof e.newText==`string`?e.newText:``,a=Eu(r),o=Eu(i);n+=a.length,t+=o.length;let s=[];if(a.length===1&&o.length===1){let{oldTokens:e,newTokens:t}=Tu(a[0],o[0]);s.push({type:`del`,content:a[0],tokens:e}),s.push({type:`add`,content:o[0],tokens:t})}else{for(let e of a)s.push({type:`del`,content:e});for(let e of o)s.push({type:`add`,content:e})}return{removed:a.length,added:o.length,lines:s}}),additions:t,deletions:n}}var Ou=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function ku(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!Ou(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:Cu(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=Eu(n.content);return{...i,isWrite:!0,additions:e.length,deletions:0,hunks:[{removed:0,added:e.length,lines:e.map(e=>({type:`add`,content:e}))}]}}let a=[...Array.isArray(n.edits)?n.edits.filter(Ou):[],...typeof n.oldText==`string`||typeof n.newText==`string`?[{oldText:n.oldText,newText:n.newText}]:[]];return a.length===0?null:{...i,isWrite:!1,...Du(a)}}function Au({line:e}){return(0,_.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,_.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,_.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,_.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function ju({data:e,failed:t=!1}){let{t:n}=D(),[r,i]=(0,m.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,_.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,_.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,_.jsxs)(`div`,{className:`file-diff-info`,children:[(0,_.jsx)(va,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,_.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,_.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,_.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,_.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,_.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,_.jsx)(Ua,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]})]}),(0,_.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,_.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,_.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,_.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,_.jsx)(`div`,{className:`diff-hunk-header`,children:(0,_.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,_.jsx)(Au,{line:e},t))]},r))})}),!r&&a>400&&(0,_.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function Mu(e){let t=e.items.map(e=>({...ei(e,1),text:e.role===`tool`||e.role===`thinking`?``:e.text,clipped:!1}));return{header:{id:e.id,status:e.status,notice:e.notice,...e.retry?{retry:e.retry}:{},omitted:e.omitted,steps:t.length,stable:t.length,entry:null,at:0},steps:t,detail:async t=>({text:e.items[t]?.text??``,args:e.items[t]?.args??``})}}function Nu(e){return e.state===`pending`||e.state===`streaming`||e.state===`running`}function Pu(e,t,n,r){let i=`${e.renderId??e.header.id}:${ml(n)}`,a=JSON.stringify([t,n.parts,n.version,n.state,n.error,e.header.status]),{detail:o}=e,s=(0,m.useMemo)(()=>({identity:i,revision:a,detail:o,wanted:r}),[i,a,o,r]),c=(0,m.useRef)(s);c.current=s;let[l,u]=(0,m.useState)(),d=n.parts;return(0,m.useEffect)(()=>{if(!r||d===0)return;let e=new AbortController,n=()=>!e.signal.aborted&&c.current===s;return o(t,d,e.signal).then(e=>{n()&&u({identity:i,value:e})},e=>{n()&&u(t=>({identity:i,...t?.identity===i?{value:t.value}:{},error:e instanceof Error?e.message:`unavailable`}))}),()=>e.abort()},[s,o,t,d,r,i]),r&&d>0&&l?.identity===i?l:{}}function Fu(e){let t=e.map((e,t)=>({step:e,index:t,key:ml(e)}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var Iu={bash:[Hi,`exec`],powershell:[Hi,`exec`],read:[va,`read`],ls:[ga,`read`],write:[ba,`edit`],edit:[xa,`edit`],grep:[Ji,`search`],find:[Oa,`search`]},Lu=[Vi,`default`],Ru=e=>Object.hasOwn(Iu,e)?Iu[e]:Lu;function zu(e,t){let n=e.steps[t];return n?.error||n?.state===`failed`?`err`:n?.state===`completed`?`ok`:n&&Nu(n)&&(e.header.status===`queued`||e.header.status===`running`)?`run`:`idle`}var Bu={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function Vu(){return(0,_.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,_.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function Hu({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,_.jsx)(ws,{text:e})}){let{t:a}=D(),o=t<e.header.stable,s=Pu(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,_.jsxs)(_.Fragment,{children:[n.images?.length?(0,_.jsx)(hu,{images:n.images,turn:e}):null,c.trim()!==``&&(0,_.jsxs)(`div`,{className:`msg-text single`,children:[(0,_.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,_.jsx)(vs,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,_.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?S(a,s.error):a(`Reading the rest of this message…`)})]})}function Uu(e){try{let t=JSON.parse(e),n=t&&typeof t==`object`&&Object.hasOwn(t,`command`)?t.command:void 0;return typeof n==`string`&&n?n:void 0}catch{return}}function Wu(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Gu({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=Pu(e,t,n,i),[s,c]=Ru(n.name),l=zu(e,t),u=r(Bu[l]),d=o.value?.args,f=d?Uu(d):void 0,p=(0,m.useMemo)(()=>d?ku(n.name,d):null,[n.name,d]);return(0,_.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,_.jsx)(cc,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,_.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,_.jsx)(zi,{"aria-hidden":`true`}):l===`ok`?(0,_.jsx)(Fa,{"aria-hidden":`true`}):l===`run`?(0,_.jsx)(Vu,{}):(0,_.jsx)(ta,{"aria-hidden":`true`})}),n.target&&(0,_.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,_.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,_.jsx)(vs,{text:n.target,className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,_.jsxs)(`div`,{className:`toolcall-body`,children:[n.parts===0?(0,_.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,_.jsxs)(_.Fragment,{children:[o.value.args&&(0,_.jsx)(`div`,{className:`toolcall-args`,children:p?(0,_.jsx)(ju,{data:p,failed:l===`err`}):f?(0,_.jsxs)(`div`,{className:`termline`,children:[(0,_.jsx)(Hi,{className:`termline-icon`,"aria-hidden":`true`}),(0,_.jsx)(`code`,{children:f})]}):(0,_.jsx)(`pre`,{children:Wu(o.value.args)})}),o.value.text&&(0,_.jsxs)(`div`,{className:`toolcall-output`,children:[(0,_.jsx)(`div`,{className:`toolcall-output-label`,children:r(n.error?`Error output`:`Output`)}),(0,_.jsx)(`pre`,{children:o.value.text})]})]}):(0,_.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?S(r,o.error):r(`Reading…`)}),o.value&&o.error&&(0,_.jsx)(`p`,{className:`banner-notice`,children:S(r,o.error)})]})]})}function Ku({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=Pu(e,t,n,i&&n.parts>0),s=Nu(n)&&(e.header.status===`queued`||e.header.status===`running`);if(n.parts===0)return(0,_.jsx)(`div`,{className:`thinking`,children:(0,_.jsxs)(`div`,{className:`chead thinking-head`,title:r(`Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.`),children:[(0,_.jsx)(wa,{className:`thinking-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`thinking-label`,role:`status`,children:r(s?`Thinking activity observed`:n.state===`completed`?`Thinking activity ended`:`Thinking content unavailable`)}),s&&(0,_.jsx)(Vu,{})]})});let c=o.value?.text.trim()??``;return(0,_.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,_.jsx)(cc,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,_.jsx)(wa,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`toolcall-spacer`}),c&&(0,_.jsx)(vs,{text:c,className:`chead-copy`})]}),children:r(`Thinking`)}),i&&(0,_.jsx)(`div`,{className:`thinking-body`,children:c||(0,_.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?S(r,o.error):o.value?r(`No thinking text is recorded for this block.`):r(`Reading…`)})})]})}var qu=s().use(p).use(c).use(f).use(ns);function Ju(e){return e.type===`definition`||e.type===`linkReference`||e.type===`imageReference`||e.type===`footnoteDefinition`||e.type===`footnoteReference`||(e.children?.some(Ju)??!1)}function Yu(e,t){if(e?.type!==`code`)return!1;let n=t.split(/\r\n|\r|\n/),r=/^ {0,3}(`{3,}|~{3,})/.exec(n[0]);if(!r)return!1;let i=r[1];return!n.slice(1).some(e=>{let t=/^ {0,3}(`{3,}|~{3,})[\t ]*$/.exec(e);return t&&t[1][0]===i[0]&&t[1].length>=i.length})}function Xu(e){let{children:t}=qu.parse(e),n=e?[0]:[];for(let e=0;e<t.length;e++){let r=t[e],i=r.position?.start;if(e>0&&i?.offset!==void 0&&n.push(i.offset-(i.column-1)),Ju(r))break}let r=n.map((t,r)=>({start:t,text:e.slice(t,n[r+1])})),i=r.at(-1)?.text??``,a=t.at(-1),o=r.length===t.length&&Yu(a,e.slice(a?.position?.start.offset));return{segments:r,frozen:r.slice(0,-1).map(e=>e.text),active:i,inFence:o}}var Zu=(0,m.memo)(function({text:e}){return(0,_.jsx)(Cs,{text:e})}),Qu=(0,m.memo)(function({text:e}){let{segments:t}=(0,m.useMemo)(()=>Xu(e),[e]);return(0,_.jsx)(`div`,{className:`md`,children:t.map(e=>(0,_.jsx)(Zu,{text:e.text},`stream-offset:${e.start}`))})});function $u(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
21
22
|
|
|
22
|
-
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function
|
|
23
|
-
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:E}=u,O=h&&!f.some(({step:e})=>
|
|
24
|
-
`)}),![`completed`,`running`,`queued`].includes(u.status)&&(0,_.jsx)(`p`,{className:`ep-state ${u.status}`,children:c(u.status)})]})});function
|
|
25
|
-
`).find(e=>e.trim())??``,C=v([y,g,b]);return(0,_.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,_.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,_.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,_.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:C,children:g?(0,_.jsxs)(_.Fragment,{children:[`${y} · `,(0,_.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,_.jsx)(Aa,{"aria-hidden":`true`}),g]}),b&&` · ${b}`]}):C})]}),f&&(0,_.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),ld(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,_.jsx)(Mi,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,_.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:S(i,l)}):x&&(0,_.jsx)(`p`,{className:`workflow-line-reason`,title:x,children:a(x)})]})}function cd({proposal:e,canApprove:t,approvalHint:n,onApprove:r,action:i=`approve`,canValidate:a=!1,validating:o=!1,previous:s,onValidate:c}){let{t:l}=D();return(0,_.jsxs)(`section`,{className:`workflow-plan`,"aria-label":l(`Current implementation plan`),children:[(0,_.jsx)(`h3`,{children:l(`Current implementation plan`)}),e.revalidatedFrom&&(0,_.jsx)(`p`,{role:`status`,children:l(`The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.`)}),s&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:l(`Previous execution context`)}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:s.cwd}),` · `,s.display?.model]}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:s.display?.branch}),` ·`,` `,(0,_.jsx)(`code`,{children:s.display?.baseCommit})]}),s.display?.runtime&&(0,_.jsx)(`p`,{children:s.display.runtime}),s.delivery&&(0,_.jsx)(fs,{text:br(s.delivery)})]}),s&&s.observation!==e.observation&&(0,_.jsx)(`p`,{role:`status`,children:l(`Repository or execution-environment evidence changed. Review the current context before confirming.`)}),(0,_.jsx)(`p`,{children:l(`Tools and checks run on the service host, not in a sandbox.`)}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,_.jsxs)(`p`,{children:[l(`Declared write paths use the checkout root:`),` `,(0,_.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.runtime&&(0,_.jsx)(`p`,{children:e.display.runtime}),e.display?.branch&&(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,_.jsx)(`code`,{children:e.display.baseCommit})]}),(0,_.jsx)(`p`,{children:l(`Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.`)}),(0,_.jsx)(fs,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:l(`Complete delivery agreement`)}),(0,_.jsx)(fs,{text:Or(e.plan)})]}),e.delivery&&(0,_.jsx)(fs,{text:br(e.delivery)}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,disabled:i===`approve`?!t:!a,onClick:i===`approve`?r:c,children:l(o?`Validating plan…`:i===`restore`?`Restore execution and validate plan`:i===`validate`?`Validate plan again`:e.revalidatedFrom?`Confirm implementation`:`Implement this plan`)}),i===`approve`&&c&&(0,_.jsx)(`button`,{type:`button`,disabled:!a,onClick:c,children:l(`Validate plan again`)}),i!==`approve`&&(0,_.jsx)(`p`,{className:`inspector-note`,children:l(`Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.`)}),!t&&(i===`approve`||!a)&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??l(`Plan approval is currently unavailable.`)}),(0,_.jsx)(`p`,{children:l(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function ld(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 ud(e){return(0,_.jsx)(dd,{...e},e.id)}function dd({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=D(),[o,s]=(0,m.useState)(1e3),[c,l]=(0,m.useState)(),u=go(e,{kind:`workflow`,id:t},o),d=go(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),f=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,p=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,h=c===void 0?p:f,[g,v]=(0,m.useState)(null),y=go(e,g?{kind:`workflow-detail`,id:t,stepId:g}:null),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(``),w=p&&[`queued`,`running`].includes(p.status),T=(0,m.useRef)(!0);return(0,m.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,m.useEffect)(()=>{p&&![`queued`,`running`].includes(p.status)&&s(0)},[p]),(0,_.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(`strong`,{children:p?.goal??i(`Observing workflow`)}),p&&(0,_.jsxs)(`span`,{className:`ep-state ${p.status}`,children:[a(p.phase),` · `,a(p.status)]})]}),(u.error||d.error||S)&&(0,_.jsxs)(`p`,{role:`alert`,children:[S||u.error||d.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),p&&(0,_.jsx)(md,{run:p}),p?.execution&&(0,_.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,_.jsx)(`code`,{children:p.execution.cwd}),` ·`,` `,p.execution.model?`${p.execution.model.provider}/${p.execution.model.model} · ${p.execution.model.thinking}`:i(`No model`)]}),p?.notice&&(0,_.jsx)(`p`,{children:p.notice}),p&&h&&(0,_.jsx)(_d,{run:p,steps:h.steps,partial:(h.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:ec(e.id)}))}),p&&((p.revision??0)>0||!!p.scope?.length)&&(0,_.jsxs)(`section`,{className:`workflow-route`,"aria-label":i(`Route revisions`),children:[(p.revision??0)>0&&(0,_.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,p.revision]}),!!p.scope?.length&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:i(`Paths added to the write scope after approval:`)}),(0,_.jsx)(`ul`,{className:`workflow-scope`,children:p.scope.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(`code`,{children:e})},e))})]})]}),p?.delivery&&(0,_.jsx)(vd,{delivery:p.delivery}),p&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,_.jsx)(`pre`,{className:`workflow-detail`,children:Mr(p)})]}),p?.mergedCommit&&(0,_.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,_.jsx)(`code`,{children:p.mergedCommit})]}),p&&(0,_.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),p&&((h?.stepsBefore??0)>0||c!==void 0)&&(0,_.jsxs)(`nav`,{className:`workflow-actions`,children:[(h?.stepsBefore??0)>0&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(h?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),h&&(0,_.jsx)(fd,{steps:h.steps}),h?.steps.map(e=>(0,_.jsxs)(`details`,{className:`chat-tool`,children:[(0,_.jsx)(`summary`,{children:(0,_.jsx)(pd,{run:p??h,step:e})}),e.exitCode!==null&&(0,_.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,_.jsx)(fs,{text:e.text}),e.childRunId&&r&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:ec(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,_.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>v(e.id),children:i(`Read retained step result`)}),g===e.id&&y.value?.kind===`file`&&(0,_.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),g===e.id&&y.error&&(0,_.jsx)(`p`,{role:`alert`,children:y.error})]},e.id)),w&&(0,_.jsx)(`button`,{type:`button`,className:`danger`,disabled:b,onClick:()=>{p&&(x(!0),ld(e,p).then(e=>{T.current&&(C(e),u.refresh(),n?.())}).finally(()=>{T.current&&x(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:i(`Observe current state`)})]})}function fd({steps:e}){let{t}=D(),n=t=>e.filter(e=>e.status===t).length,r=n(`partial`),i=n(`blocked`);return!r&&!i?null:(0,_.jsxs)(`p`,{className:`inspector-note`,children:[t(`Attempts shown: {partial} partial · {blocked} blocked · {failed} failed`,{partial:r,blocked:i,failed:n(`failed`)}),` · `,t(`Partial or blocked assignments preserve work; they are not process failures or delivery approval.`)]})}function pd({run:e,step:t}){let{t:n,tx:r}=D();return(0,_.jsxs)(_.Fragment,{children:[`${r(t.kind)} · ${ec(t.id)} · ${r(t.status)}`,cc(e,t)&&(0,_.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function md({run:e}){let{t}=D(),n=e.deviations??[];return n.length?(0,_.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,_.jsxs)(`h3`,{children:[(0,_.jsx)(Aa,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,_.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,_.jsx)(`ol`,{children:n.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:t(`Could not be met`)}),(0,_.jsx)(`dd`,{children:e.item}),(0,_.jsx)(`dt`,{children:t(`Why`)}),(0,_.jsx)(`dd`,{children:e.reason}),(0,_.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,_.jsx)(`dd`,{children:e.delivered}),(0,_.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,_.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,_.jsx)(`code`,{children:e},e)):t(`None`)}),(0,_.jsx)(`dt`,{children:t(`Recorded at`)}),(0,_.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function hd({state:e}){return e===`running`?(0,_.jsx)(ku,{}):e===`completed`?(0,_.jsx)(wa,{"aria-hidden":`true`}):e===`failed`?(0,_.jsx)(Oi,{"aria-hidden":`true`}):e===`superseded`?(0,_.jsx)(Ni,{"aria-hidden":`true`}):(0,_.jsx)(_a,{"aria-hidden":`true`})}function gd(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function _d({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=D(),o=tc(e);return o?(0,_.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,_.jsxs)(`h3`,{children:[i(`Assignments`),(0,_.jsx)(`span`,{className:`workflow-board-counts`,children:rc(o,i)})]}),n&&(0,_.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,_.jsx)(`ul`,{children:ac(e,t).map(({task:e,steps:t,artifact:n})=>(0,_.jsxs)(`li`,{className:`workflow-task`,children:[(0,_.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,_.jsx)(hd,{state:e.state}),a(e.state)]}),(0,_.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,_.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,_.jsx)(`span`,{children:e.title}),(0,_.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,_.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,_.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,_.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,_.jsx)(`span`,{className:`workflow-task-worktree`,children:gd(n,i)})]}),n?.state===`retained`&&(0,_.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,_.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,_.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,_.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function vd({delivery:e}){let{t,tx:n}=D(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${e.acceptance.waived?.length?t(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,_.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,_.jsx)(`dl`,{children:r.map(([e,t])=>(0,_.jsxs)(m.Fragment,{children:[(0,_.jsx)(`dt`,{children:e}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,_.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,_.jsx)(`p`,{children:e.cleanup.reason}),(0,_.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var yd=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function bd(e){return e.scrollHeight-e.scrollTop-e.clientHeight<80}function xd(e,t){t&&e&&(e.scrollTop=e.scrollHeight)}function Sd(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Cd({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,prepareForSend:u,prepareForPlan:d,legacyWorkspaceId:f,directoryNamespaces:p=[],available:h=c,canInterrupt:g=c,modelAvailability:v,previewModels:y,initialDraft:b,onDraftApplied:x,onModelChanged:C,onChanged:w,reference:T,onReferenceUsed:E,hidden:O=!1,observe:k=0,onOpenAgent:A,onWorkflowRuns:ee,onBranches:j,onOpenBranches:te}){let{t:M,tx:ne}=D(),[N]=(0,m.useState)(()=>Xc(n,t,f,...p)),[re,ie]=(0,m.useState)(()=>Sd(N,b?.text));(0,m.useEffect)(()=>{b&&x?.()},[b,x]);let P=Ql(),ae=P.remove,F=(0,m.useRef)([]),I=(0,m.useRef)(!0),L=Qu({draftKey:N,draft:re,setDraft:ie,images:P,alive:I,onUnread:()=>le(M(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:R,attaching:z}=L,B=L.release,V=(0,m.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[H,U]=(0,m.useState)(()=>Sd(`${N}:mode`)===`cadence`?`cadence`:`chat`),[W,G]=(0,m.useState)(!1),[K,q]=(0,m.useState)(``),se=`conversation:${t}`,ce=()=>{q(``),rs(se)},le=e=>ts(`error`,e,se);(0,m.useEffect)(()=>()=>rs(se),[se]);let[ue,Y]=(0,m.useState)(()=>Sd(`${N}:pending`)),[de,fe]=(0,m.useState)(()=>Sd(`${N}:model-command`)),[pe,me]=(0,m.useState)(!1),[he,_e]=(0,m.useState)(!1),[ve,ye]=(0,m.useState)(!1),[be,xe]=(0,m.useState)(0),Se=(0,m.useRef)(null),Ce=(0,m.useRef)(!1),we=(0,m.useRef)(0),Te=(0,m.useRef)(new AbortController),[Ee,De]=(0,m.useState)(!1),[Oe,ke]=(0,m.useState)(()=>{try{let e=sessionStorage.getItem(`${N}:model`);if(e)return ge(JSON.parse(e))}catch{}return b?.model??null});(0,m.useEffect)(()=>{try{Oe?sessionStorage.setItem(`${N}:model`,JSON.stringify(Oe)):sessionStorage.removeItem(`${N}:model`)}catch{}},[N,Oe]);let Ae=go(e,h&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),je=Ae.value?.kind===`conversation-context`?Ae.value.context:void 0,Me=!!je&&!Ae.error,Ne=je?.cwd??r,Pe=(0,m.useMemo)(()=>({models:(n,r)=>Ne?e.models(n,{id:t,cwd:Ne},r):Promise.resolve({kind:`error`,error:oe(`unavailable`)}),chooseModel:n=>Ne?e.chooseModel(n,{id:t,cwd:Ne}):Promise.resolve({kind:`error`,error:oe(`unavailable`)})}),[e,t,Ne]),Fe=Ee?{status:`preparing`}:v.status===`ready`&&(!h||!Me)?{status:Ae.error?`unavailable`:`connecting`}:v,Ie=(0,m.useRef)(Fe);Ie.current=Fe;let Le=fl(Pe,Fe,`${be}:${je?.revision??`unobserved`}`,y),Re=()=>{Se.current=null,_e(!1),ye(!1)},ze=(e,t)=>{e?Le.reread(!0):!e&&t!==`chosen`&&Re(),me(e)},Be=(e,t)=>{ke(t?null:e);let n=Se.current;he&&n&&(Kc(n,Ie.current)===`cancel`?(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Se.current=Gc(n,e,t),_e(!1),ce(),ye(!0)))},Ve=(0,m.useRef)(o);Ve.current=o,(0,m.useEffect)(()=>{Me&&Ne&&Ve.current?.({id:t,cwd:Ne})},[Me,t,Ne]);let[He]=(0,m.useState)(()=>typeof window<`u`&&lo()===t?fo(window.location.hash,t).leaf:i),X=ul(e,t,h,He),{turns:Ue}=X,We=X.summary!==void 0,Ge=go(e,h?{kind:`cadence-conversation`,id:t}:null,1e3),Z=Ge.value?.kind===`cadence-conversation`?Ge.value.state:void 0,Ke=Z?.enabled===!0,qe=!!Z||!!Ge.error,Je=!!Z&&!Ge.error&&!Z.notice,Ye=(0,m.useRef)(Z);Ye.current=Z;let[Xe,Ze]=(0,m.useState)(()=>Sd(`${N}:approval`,``)),Qe=(0,m.useRef)(Xe),$e=(0,m.useRef)(!1),[et,tt]=(0,m.useState)(!1),[nt,rt]=(0,m.useState)(``),[it,at]=(0,m.useState)(),ot=(0,m.useCallback)(e=>{Qe.current=e,Ze(e);try{e?sessionStorage.setItem(`${N}:approval`,e):sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]),st=_o(re,Ke?`cadence`:H),ct=c&&!(a&&!X.summary)&&Me&&We&&!X.error&&qe&&!(Ke&&(Ge.error||Z?.notice))&&!W&&!he&&!ue,lt=X.summary??void 0,ut=lt&&(lt.status===`queued`||lt.status===`running`),dt=!!lt&<.status!==`completed`&&!ut,Q=Ue.at(-1)?.header,ft=ut?Q&&[`queued`,`running`].includes(Q.status)?Q.at:0:null,{tokens:pt,provider:mt,model:ht}=X.context??{},gt=Le.catalog?.entries??Le.preview?.entries,_t=(0,m.useMemo)(()=>pt===void 0||mt===void 0||ht===void 0?void 0:xc({tokens:pt,provider:mt,model:ht},gt),[pt,mt,ht,gt]),{input:vt,read:yt,write:bt}=X.cache??{},xt=(0,m.useMemo)(()=>vt===void 0||yt===void 0||bt===void 0?void 0:{input:vt,read:yt,write:bt},[vt,yt,bt]),St=X.refresh;(0,m.useEffect)(()=>{k&&St()},[k,St]);let Ct=(0,m.useRef)(s);Ct.current=s,(0,m.useEffect)(()=>{Ct.current?.({id:t,turns:X.count,runningSince:ft,..._t?{context:_t}:{},...xt?{cache:xt}:{}})},[t,X.count,ft,_t,xt]);let wt=Ue.at(-1),Tt=!!wt&&[`queued`,`running`].includes(wt.header.status),Et=yc(e,t,X.leaf,[wt?.header.id??``,X.count,X.branches,Tt].join(),h&&!!lt),{tree:Dt}=Et,Ot=(0,m.useMemo)(()=>gc(Dt??{nodes:[],truncated:!1}),[Dt]),kt=(0,m.useMemo)(()=>{let e=_c(Dt?.nodes??[]).map(e=>({id:e.id,text:e.text}));if(!wt||!Tt||e.some(e=>e.id===wt.header.id))return e;let t=Cu(wt.steps).user[0]?.step.text??``;return[...e,{id:wt.header.id,text:wc(t)}]},[Dt,wt,Tt]),[At,jt]=(0,m.useState)(null),[Mt,Nt]=(0,m.useState)(null),[Pt,Ft]=(0,m.useState)(null),It=!!u&&c&&(!!X.error||!!Ae.error)&&X.error!==`retired-conversation`&&Ae.error!==`retired-conversation`&&!Z?.notice&&!ut&&!W&&!ue&&!he,Lt=(g||!!u)&&Me&&We&&Je&&!X.error&&!W&&!ue&&!ut,Rt=!!Oe&&J(Oe)!==J(je?.model??null),zt=!!Z?.proposal&&!!lt&&!ut&<.status!==`unknown`,Bt=Z?.proposal?pl(Z.proposal,l,Le.catalog?.version,Rt||nt===Z.proposal.id):`approve`,Vt=!!it&&!!Z&&Z.revision<it.after.revision,Ht=!!Z?.proposal&&ct&&Je&&zt&&!Xe&&!et&&!Vt&&(!!d||l)&&!!(Oe??je?.model),Ut=et?M(`Preparing execution and validating the plan; no implementation is approved.`):Vt?M(`Reading the validated plan…`):Rt?M(`Validate the plan with this model before approving it.`):lt?.status===`unknown`?M(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?Je?ut?M(`Wait for the current reply before approving this plan.`):Xe?M(`Observing plan approval…`):ct?void 0:M(`Read the current conversation context before approving this plan.`):M(`Cadence state unavailable`):M(`Read the current execution state before approving this plan.`),Wt=(0,m.useRef)(null),Gt=(0,m.useRef)(null),Kt=(0,m.useRef)(0),qt=(0,m.useRef)(!0),[Jt,Yt]=(0,m.useState)(!1),Xt=(0,m.useCallback)(()=>{xd(Gt.current,qt.current)},[]);(0,m.useLayoutEffect)(()=>{!O&&Gt.current&&!qt.current&&(Gt.current.scrollTop=Kt.current)},[O]);let Zt=(0,m.useRef)(``),Qt=(0,m.useRef)(re);(0,m.useEffect)(()=>(I.current=!0,Te.current.signal.aborted&&(Te.current=new AbortController),()=>{I.current=!1,Te.current.abort()}),[]),(0,m.useEffect)(()=>{try{sessionStorage.setItem(`${N}:mode`,H)}catch{}},[N,H]),(0,m.useEffect)(()=>{try{sessionStorage.setItem(N,re)}catch{}},[re,N]),(0,m.useEffect)(()=>{try{ue?sessionStorage.setItem(`${N}:pending`,ue):sessionStorage.removeItem(`${N}:pending`)}catch{}},[N,ue]),(0,m.useEffect)(()=>{try{ue&&de===ue?sessionStorage.setItem(`${N}:model-command`,de):sessionStorage.removeItem(`${N}:model-command`)}catch{}},[N,ue,de]),(0,m.useEffect)(()=>{T&&(ie(e=>`${e}${e?`
|
|
26
|
-
`:``}@${T}`),E(),Wt.current?.focus())},[T,E]),(0,m.useEffect)(()=>{let e=lt?`${lt.leaf}:${lt.status}`:``;e&&Zt.current!==e&&(Zt.current=e,w()),Qe.current&&Z?.runs.includes(Qe.current)&&(ot(``),q(``)),ue&&(lt?.live?.commandId===ue||X.attempt?.commandId===ue||Ue.some(e=>e.header.id===ue)||X.commands.includes(ue))&&(Y(``),qc(ue,de)&&ke(null),fe(``),ae(F.current),ie(e=>e===Qt.current?``:e),qc(ue,de)&&Cl(n,Qt.current),V.current.followAnchor(),w()),xd(Gt.current,qt.current)},[lt,Ue,ue,de,w,Z,X,ae,n,ot]);let $t=(0,m.useMemo)(()=>Ue.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[Ue]),en=Us(Gt,$t,Mt?.id??null,void 0,Xt),{earlier:tn,loadEarlier:nn}=X,rn=()=>{let e=Gt.current;e&&!O&&tn&&e.scrollTop<1200&&nn()};(0,m.useEffect)(rn);let an=(0,m.useRef)(0),on=()=>{an.current||=requestAnimationFrame(()=>{an.current=0;let e=Gt.current;if(!e)return;let t=null;if(!qt.current){let n=e.getBoundingClientRect().top+140;for(let r of e.querySelectorAll(`[data-lazy-id]`)){if(t!==null&&r.getBoundingClientRect().top>n)break;t=r.dataset.lazyId??null}}Ft(t)})};(0,m.useEffect)(()=>()=>{an.current&&cancelAnimationFrame(an.current)},[]),(0,m.useEffect)(()=>{if(!Mt)return;let e=requestAnimationFrame(()=>{let e=[...Gt.current?.querySelectorAll(`[data-lazy-id]`)??[]].find(e=>e.dataset.lazyId===Mt.id);e&&(qt.current=!1,e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),Ft(Mt.id))});return()=>cancelAnimationFrame(e)},[Mt]);let sn=Ue[0]?.ordinal,cn=(0,m.useRef)({height:0});(0,m.useLayoutEffect)(()=>{let e=Gt.current;if(!e)return;let t=cn.current;!yd&&!qt.current&&t.ordinal!==void 0&&sn!==void 0&&sn<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),cn.current={ordinal:sn,height:e.scrollHeight}}),(0,m.useEffect)(()=>{try{sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]);let ln=(0,m.useMemo)(()=>[...new Set([...X.runs,...Z?.runs??[]])],[X.runs,Z?.runs]),un=JSON.stringify(ln.slice(-4));(0,m.useEffect)(()=>{ee?.(JSON.parse(un))},[un,ee]);let[dn,fn]=(0,m.useState)({terminal:8,browser:8}),pn=(0,m.useMemo)(()=>[...new Set([...X.runs.slice(-dn.terminal),...(Z?.runs??[]).slice(-dn.browser),...Xe?[Xe]:[]])],[X.runs,Z?.runs,dn,Xe]),mn=fc(e,h?pn:[],1e3),hn=Ue.find(e=>e.header.at>0)?.header.at,gn=!tn&&Ue.length>0;(0,m.useEffect)(()=>{if(!h)return;let e=(e,t)=>ad(e,t,mn.runs,mn.unreadable,hn,gn),t=e(X.runs,dn.terminal),n=e(Z?.runs??[],dn.browser);(t!==dn.terminal||n!==dn.browser)&&fn({terminal:t,browser:n})},[h,X.runs,Z?.runs,dn,mn,hn,gn]);let _n=(0,m.useMemo)(()=>id(Ue,mn.runs.values(),tn),[Ue,mn.runs,tn]),vn=[...mn.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,m.useLayoutEffect)(()=>{vn&&xd(Gt.current,qt.current)},[vn]);let yn=t=>(0,_.jsx)(sd,{client:e,run:t,onOpen:()=>A?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{Ge.refresh(),w()}},t.id),bn=async()=>{if(!Ht||!Z?.proposal||!je||$e.current)return;let t=Oe??je.model;if(!t)return;let n=Z.proposal,r=Z,i=we.current,a=()=>I.current&&we.current===i;$e.current=!0,G(!0),tt(!0),ce();try{let o=await ml({client:e,state:r,context:je,model:t,head:X.leaf,signal:Te.current.signal,current:a,prepare:l?void 0:d});if(!I.current||we.current!==i)return;at({before:n,after:o}),rt(``),ke(e=>J(e)===J(t)?null:e)}catch(e){I.current&&we.current===i&&q(M(`Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{I.current&&we.current===i&&($e.current=!1,G(!1),tt(!1),xe(e=>e+1),Ae.refresh(),Ge.refresh(),X.refresh(),w())}},xn=async()=>{if(!Z?.proposal){le(M(`No plan is awaiting approval.`));return}if(Bt!==`approve`){await bn();return}if($e.current||Vt||Rt||!l||!Je||!ct||ut||Xe||!zt)return;let t=Z.proposal,n=Z,r=we.current;$e.current=!0,G(!0),ce();try{let i=await hl({client:e,state:n,current:()=>I.current&&we.current===r&&Ye.current?.revision===n.revision&&Ye.current?.enabled===!0,submitting:ot});if(!I.current||we.current!==r)return;i.kind===`error`?(q(i.error.code),i.error.effect===`none`&&(ot(``),i.error.code===`stale`&&rt(t.id))):ie(e=>_l(e)?``:e)}catch(e){I.current&&we.current===r&&(q(e instanceof Error?e.message:`unavailable`),!Qe.current&&e instanceof Error&&e.message===`stale`&&rt(t.id))}finally{I.current&&we.current===r&&($e.current=!1,G(!1),Ge.refresh(),X.refresh(),w())}},Sn=async(r,i)=>{let a=i?.text??r??re,o=i?.images??(r?[]:P.files),s=i?i.command.kind===`cadence-exit`:Ke&&gl(a);if(!(s?Lt:ct)&&!It||ut||z&&!i||!a.trim()&&!o.length||i&&(!ct||Kc(i,Ie.current)!==`ready`))return;if(s&&o.length){le(M(`Remove images before exiting Cadence.`));return}if(!o.length&&!i&&!r&&Ke&&_l(a)){await xn();return}let c=_o(a,H).mode===`cadence`;if(!It&&(Ke||c)&&!Je){le(M(`Cadence state unavailable. Observe the conversation before sending.`));return}if(Ce.current)return;Ce.current=!0,G(!0),ce();let l=we.current,d=()=>I.current&&we.current===l,f=!1,p=`not-dispatched`,m=(e,t)=>{let n=M(Rc(t),{code:e});t===`none`?le(n):q(n)},h=e=>{d()&&(Y(e),fe(e&&!s?e:``))},g=async e=>{u&&(De(!0),await Fc(u,Te.current.signal,e,e=>{p=e}),d()&&(De(!1),xe(e=>e+1)))};try{if(It){if(await g(je?{id:t,cwd:je.cwd}:void 0),!d())return;X.refresh(),Ae.refresh(),Ge.refresh(),w(),q(M(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let l=i??Bc({id:t,head:s?X.leaf:Ec(R,X.leaf),text:a,images:o,revision:Z?.revision??0,location:je?{id:t,cwd:je.cwd}:void 0,installModel:!!Oe,model:Oe??(Le.catalog?.selected?Vc(Le.catalog.selected):Le.catalog?.remembered??je?.model??Le.preview?.remembered??void 0),intent:s?`exit`:Ke?`message`:c?`enter`:`ordinary`});if(i){if(Kc(i,Ie.current)!==`ready`)throw Error(`stale`)}else await g(l.location);if(!d())return;if(l.command.kind===`cadence-exit`){let t=Yc(l);Qt.current=a,f=!0;let n=await zc(e,t,h);if(!d())return;n.kind===`error`?m(n.error.code,n.error.effect):(Y(``),U(`chat`),ie(e=>e===a?``:e)),Ge.refresh(),X.refresh(),w();return}let u=e=>{let t=Ie.current,n=e??(t.status===`ready`?t.epoch:void 0);n&&Kc(Wc(l,n),t)!==`cancel`?(Se.current=Wc(l,n),_e(!0)):(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))),ze(!0)},p=await e.models(void 0,l.location);if(!d())return;if(l.preparedEpoch&&p.kind===`ok`&&p.value.version.epoch!==l.preparedEpoch)throw Error(`stale`);let _=p.kind===`ok`?p.value.selected??p.value.remembered:null;if(!l.model&&_&&(l=Hc(l,_)),l.installModel&&p.kind===`ok`){if(p={kind:`ok`,value:await Jc(e,l,p.value,d)},!d())return;xe(e=>e+1)}let v=l.model??(p.kind===`ok`?p.value.remembered:null);if(p.kind===`ok`&&!p.value.selected&&v){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:p.value.version.epoch,...l.location?{location:l.location,expected:p.value.version,choice:v}:{}});if(!d())return;if(t.kind===`error`){q(t.error.code),u(p.value.version.epoch);return}if(p=await e.models(void 0,l.location),!d())return;xe(e=>e+1)}if(p.kind!==`ok`||!p.value.selected){u(p.kind===`ok`?p.value.version.epoch:void 0);return}Uc(l,p.value.selected);let y=Yc(l,p.value.version);if(l.images.length){let t=p.value.selected;if(!p.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){le(M(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(y.kind===`cadence-exit`)throw Error(`invalid`);if(y=await el(e,y,l.images,d),!d())return}F.current=l.images,Qt.current=a,f=!0;let b=await zc(e,y,h);if(!d())return;b.kind===`error`?m(b.error.code,b.error.effect):(ae(F.current),ke(null),ie(e=>e===Qt.current?``:e),Y(``),y.kind===`cadence-send`&&U(`chat`),r||Cl(n,a),Mn(null)),Ge.refresh(),X.refresh(),w()}catch(e){if(d()){let t=e instanceof Error?e.message:`unavailable`,n=Lc(e),r=M(f?Rc():Ic(p,n),{code:t});!f&&(p===`not-dispatched`||n===`none`)?le(r):q(r)}}finally{we.current===l&&(Ce.current=!1),d()&&(G(!1),De(!1))}},Cn=(0,m.useRef)(Sn);Cn.current=Sn,(0,m.useEffect)(()=>{let e=Se.current;if(!e||!ve&&!he)return;let t=Kc(e,Fe);t===`cancel`?(Se.current=null,_e(!1),ye(!1),ts(`error`,M(`The connection changed. Your model choice and draft are kept; send again when ready.`),se)):ve&&t===`ready`&&ct&&!ut&&(ye(!1),Se.current=null,Cn.current(void 0,e))},[ve,he,ct,ut,Fe,M,se]),(0,m.useEffect)(()=>{if(!ve)return;let e=setTimeout(()=>{ye(!1),Se.current=null},1e4);return()=>clearTimeout(e)},[ve]);let wn=ut?lt?.live:void 0,Tn=(0,m.useRef)(new Map),En=kc({images:P.files.length,modeChange:Ke?gl(re):st.mode===`cadence`,anchored:!!R,waiting:X.pending.length}),Dn=!!wn&&g&&!W&&!z,On=async r=>{if(!wn||!Dn||En||!re.trim())return;ce(),G(!0);let i=re,a=Ac(t,wn,r,i),o=Nc(await e.workbenchCommand(a));I.current&&(G(!1),o.kind===`accepted`?(Tn.current.set(a.commandId,i),Cl(n,i),ie(``)):o.kind===`refused`?le(M(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:S(M,o.code)})):q(o.code),X.refresh())},kn=async(n,r)=>{if(!wn||W)return;G(!0);let i=Nc(await e.workbenchCommand(jc(t,wn,n.commandId)));if(I.current){if(G(!1),i.kind===`accepted`){let e=Tn.current.get(n.commandId)??n.text;Tn.current.delete(n.commandId),r&&ie(t=>t.trim()?t:e)}else i.kind===`refused`?le(i.code===`conflict`?M(`That message has already been handed to the model and can no longer be withdrawn.`):M(`The message was not withdrawn ({reason}).`,{reason:S(M,i.code)})):q(i.code);X.refresh()}},An=e=>{ie(t=>t.trim()?`${t}\n${e}`:e),Wt.current?.focus()},jn=async()=>{let n=lt?.live;if(!n||W)return;G(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});I.current&&(r.kind===`error`&&q(r.error.code),G(!1),X.refresh())},Mn=(e,n)=>{++we.current,Te.current.abort(),Te.current=new AbortController,Se.current=null,Ce.current=!1,$e.current=!1,tt(!1),at(void 0),_e(!1),ye(!1),me(!1),G(!1),De(!1),B(),X.choose(e,n),mo(t,e)},Nn=!ut&&!W&&!ue&&!he,Pn=()=>{ce(),Wt.current?.focus()},Fn=e=>{Nn&&e.header.entry&&(e.ordinal>=X.count-1?B():L.continueAfter(e),Pn())},In=e=>{if(!Nn)return;let t=Ue.find(t=>t.ordinal===e.ordinal-1);L.edit(e,t)?Pn():le(M(`This message cannot be rewritten from here: the entry it continued is not known.`))},Ln=(e,t)=>jt({id:e,then:t});V.current={chooseBranch:Mn,followAnchor(){L.current()&&Mn(null)},show:Ln,stepVersion:(e,t)=>{let n=Ot.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(Mn(r.leaf===lt?.leaf?null:r.leaf,Ue.find(t=>t.header.id===e)?.ordinal),Ln(r.id,`show`))}};let Rn=(0,m.useCallback)(e=>V.current.show(e,`continue`),[]),zn=(0,m.useCallback)(e=>V.current.show(e,`edit`),[]),Bn=(0,m.useCallback)((e,t)=>V.current.stepVersion(e,t),[]),Vn=(0,m.useCallback)(e=>V.current.show(e,`show`),[]);(0,m.useEffect)(()=>{if(!At)return;let e=Ue.find(e=>e.header.id===At.id);if(e){jt(null),At.then===`edit`?In(e):At.then===`continue`&&Fn(e),Nt({id:e.header.id});return}let t=e=>{jt(null),le(e)};if(X.error)return jt(null);if(!We||!Ue.length&&X.count>0)return;if(!Et.current){Et.error&&!Et.loading&&t(S(M,Et.error));return}let n=Dt?.nodes.find(e=>e.id===At.id);if(n&&!n.current&&!At.switched)return Mn(n.leaf===lt?.leaf?null:n.leaf),jt({...At,switched:!0});let r=vc(kt,At.id,Ue,X.count,Tt);if(r===void 0||Ue.some(e=>e.ordinal===r))return t(M(`That message could not be found in this conversation.`));X.showFrom(r)});let Hn=W||he||!!ue||!!ut||z,Un=e=>{if(!Hn)try{P.add(e),ce()}catch(e){le(ne(e instanceof Error?e.message:`unavailable`))}},Wn=(0,m.useRef)(j);Wn.current=j;let Gn=(0,m.useMemo)(()=>({onShow:e=>V.current.show(e.id,`show`),onEdit:e=>V.current.show(e.id,`edit`),onContinue:e=>V.current.show(e.id,`continue`),onLatest:()=>V.current.chooseBranch(null)}),[]),{error:Kn,loading:qn,refresh:Jn}=Et,{pinned:Yn}=X;(0,m.useEffect)(()=>{Wn.current?.({id:t,tree:Dt,error:Kn,loading:qn,pinned:Yn,canAct:Nn,onRefresh:Jn,...Gn})},[t,Dt,Kn,qn,Yn,Nn,Jn,Gn]);let Xn=R!==null&&(Ue.some(e=>e.header.id===R.turnId)||kt.some(e=>e.id===R.turnId))?R:null,Zn=Xn?$t.find(({turn:e})=>Dc(Xn,e.ordinal))?.id:void 0,Qn=Pt===null?kt.length-1:kt.findIndex(e=>e.id===Pt),$n=R?(0,_.jsxs)(`div`,{className:`composer-anchor`,children:[R.kind===`edit`?(0,_.jsx)(la,{"aria-hidden":`true`}):(0,_.jsx)(ma,{"aria-hidden":`true`}),(0,_.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,_.jsx)(`strong`,{children:R.kind===`edit`?M(`Rewriting a message`):M(`Continuing after an earlier turn`)}),R.label&&(0,_.jsx)(`span`,{className:`composer-anchor-quote`,children:R.label}),(0,_.jsxs)(`span`,{children:[R.kind===`edit`?M(`Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.`):M(`Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.`),` `,M(`Only the conversation is rewound: files on disk stay as they are.`)]}),z&&(0,_.jsx)(`span`,{children:M(`Reading the message's images…`)}),R.media&&(0,_.jsx)(`span`,{children:M(`Attachments that were not retained are not attached again.`)})]}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,title:M(`Cancel and restore the draft that was here`),disabled:W||!!ue,onClick:()=>{B(),Wt.current?.focus()},children:M(`Cancel`)})]}):Yn&&!ut?(0,_.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,_.jsx)(`span`,{children:M(`A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.`)})})]}):void 0;return(0,_.jsxs)(`section`,{className:`chat-workspace`,hidden:O,"aria-label":M(Je?Ke?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[(0,_.jsx)(Gi,{"aria-hidden":`true`}),(0,_.jsx)(`h2`,{children:lt?.title??(a?M(`Discovered session`):X.summary===null?M(`New conversation`):M(`Conversation`))})]}),(0,_.jsxs)(`div`,{className:`conversation-branch`,children:[(0,_.jsxs)(`span`,{className:`conversation-meta`,children:[M(Je?Ke?`Cadence on`:`Ordinary`:`Cadence state unavailable`),lt&&` · ${lt.origin===`terminal`?M(`Started in the terminal`):M(`Started in the WebUI`)}`]}),lt?.archived&&(0,_.jsx)(`span`,{className:`conversation-badge`,children:M(`Archived`)}),te&&(X.branches>1||Yn)&&(0,_.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-label":M(`Branches ({count})`,{count:X.branches}),title:M(`Branches ({count})`,{count:X.branches}),onClick:te,children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),X.branches]}),Yn&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Mn(null),children:M(`Show the latest`)}),Ke&&!ut&&!dt&&!!Z?.proposal&&(0,_.jsx)(`span`,{className:`ep-state`,children:M(`Awaiting plan approval`)})]})]}),Ae.error&&!It&&(0,_.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:S(M,Ae.error)}),It&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:M(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),Ee&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:M(`Preparing execution for this Send…`)}),(0,_.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,_.jsxs)(`div`,{className:`chat-messages`,ref:Gt,onScroll:()=>{let e=Gt.current;e&&!O&&(Kt.current=e.scrollTop,qt.current=bd(e),Yt(!qt.current),rn(),on())},children:[a&&!X.summary&&(0,_.jsx)(`p`,{role:`status`,className:`panel-hint`,children:M(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!h&&(0,_.jsx)(`p`,{role:`status`,className:`panel-hint`,children:M(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),X.summary===null&&!X.error&&!a&&(0,_.jsx)(qu,{hint:M(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),h&&!X.error&&(!We||Ue.length===0&&X.count>0)&&(0,_.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:M(`Reading this conversation…`)}),Ue.length>0&&tn&&(0,_.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:X.loadingEarlier&&M(`Reading earlier messages…`)}),_n.start.map(yn),$t.map(({id:e,version:t,turn:n},r)=>{let i=Ot.get(e);return(0,_.jsxs)(m.Fragment,{children:[e===Zn&&(0,_.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),M(`From here on, the turns stay on their branch: the message being written will not have them in its context.`)]}),(0,_.jsx)(Ks,{id:e,show:!en.hidden.has(e)||e===Mt?.id,height:en.placeholder(e,t,320),containerRef:Gt,onMeasured:en.recordMeasured,lazyRef:en.register(e),children:(0,_.jsx)(Ku,{turn:n,onContinue:Nn&&n.header.entry&&n.ordinal<X.count-1?Rn:void 0,onEdit:Nn&&Tc(n,$t[r-1]?.turn)!==void 0?zn:void 0,version:i?i.findIndex(t=>t.id===e)+1:0,versions:i?.length??0,onVersion:Bn,off:Dc(Xn,n.ordinal)})}),_n.after.get(e)?.map(yn)]},n.renderId??n.header.id)}),_n.end.map(yn),X.attempt&&(0,_.jsxs)(`article`,{className:`chat-attempt`,"aria-label":M(`Message`),children:[(0,_.jsx)(`p`,{className:`chat-attempt-text`,children:X.attempt.text}),(0,_.jsxs)(`p`,{className:`inspector-note`,children:[(0,_.jsx)(`span`,{className:`ep-state ${X.attempt.status}`,children:ne(X.attempt.status)}),` `,X.attempt.notice?ne(X.attempt.notice):``]})]}),(0,_.jsx)($u,{pending:X.pending,undelivered:X.undelivered,canWithdraw:!!wn&&g&&!W,recallable:e=>Tn.current.has(e.commandId)||Mc(e.text),onWithdraw:(e,t)=>void kn(e,t),onRestore:An}),Xe&&(0,_.jsx)(`p`,{role:`status`,children:M(`Observing approval request {id}; no approval is replayed.`,{id:Xe})}),Z?.enabled&&Z.proposal&&(0,_.jsx)(cd,{proposal:Z.proposal,canApprove:!Rt&&l&&ct&&Je&&zt&&!ut&&!Xe&&!Vt&&Bt===`approve`,action:Bt,canValidate:Ht,validating:et,previous:it?.after.proposal?.id===Z.proposal.id?it.before:void 0,approvalHint:Ut,onValidate:()=>void bn(),onApprove:()=>void xn()}),Z?.enabled&&!Z.proposal&&ln.length===0&&(0,_.jsx)(`p`,{className:`inspector-note`,children:M(`Cadence stays on for this conversation until you explicitly exit.`)}),mn.failed&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`status`,children:M(`Workflow activity unavailable; retained work may still be running.`)}),Z?.notice&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:ne(Z.notice)}),[...new Set([K,X.error,Ge.error])].filter(Boolean).map(e=>(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:S(M,e??``)},e)),X.error&&X.summary!==void 0&&(0,_.jsx)(`p`,{role:`status`,className:`inspector-note`,children:M(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),ue&&(0,_.jsxs)(`p`,{className:`inspector-note`,children:[M(`Send outcome not yet observed:`),` `,(0,_.jsx)(`code`,{children:ue}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:X.refresh,children:M(`Observe current state`)})]})]}),Jt&&(0,_.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{qt.current=!0,xd(Gt.current,!0),Yt(!1)},children:[(0,_.jsx)(Oa,{"aria-hidden":`true`}),M(`Latest messages`)]}),At&&(0,_.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:M(`Reading earlier messages…`)}),kt.length>1&&(0,_.jsx)(Yu,{questions:kt,active:Qn,reading:At?.id??null,onJump:Vn})]}),(0,_.jsx)(lu,{inputRef:Wt,draft:re,onDraft:ie,locked:W||!!ue||he,images:P.files,imageKey:P.key,imagesLocked:Hn,onAddImages:Un,onRemoveImage:e=>ae([e]),anchor:$n,status:wn&&re.trim()&&En?M(En===`images`?`A message into a running reply carries no images. Remove them, or send after the reply ends.`:En===`mode`?`Cadence mode is not changed by a message into a running reply. Send this after the reply ends.`:En===`full`?`Eight messages already wait for this reply. Withdraw one, or wait.`:`A message into a running reply continues that reply, not another entry.`):ut||It||ct||Ee?void 0:M(ue?`The last Send is not yet confirmed. No message is resent.`:he?`Choose a model; your message is sent right after.`:W?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`),cadence:{active:Ke,armed:st.mode===`cadence`,known:Je,disabled:Ke?!Lt:!!ut||W||!!ue||he,onClick:()=>{Ke?Sn(`exit cadence`):st.mode===`cadence`?(U(`chat`),_o(re,`chat`).mode===`cadence`&&ie(st.text)):U(`cadence`)}},model:{client:Pe,availability:Fe,read:Le,lastModel:je?.model,draftModel:Oe,onPreviewChoice:y?e=>Be(e,!1):void 0,locked:!!ut||W||!!ue,open:pe,onOpenChange:ze,onChanged:()=>{Ae.refresh(),C()},onChosen:e=>Be(e,!0),awaitingSend:he},hint:wn&&Dn&&!En&&re.trim()?M(`Enter steers this reply · Alt+Enter queues behind it`):Ke?M(`Cadence stays on. Confirm one plan before implementation.`):st.mode===`cadence`?M(`Your next message turns on Cadence mode.`):``,running:!!ut,canStop:!W&&g,onStop:()=>void jn(),canSend:((Ke&&gl(re)?Lt:ct)||It)&&!z&&(!!re.trim()||P.files.length>0),onSend:()=>void Sn(),input:wn?{enabled:Dn&&!En&&!!re.trim(),onInput:e=>void On(e)}:void 0,historyScope:n,files:{client:e,location:h&&Me&&je?{id:t,cwd:je.cwd}:void 0},onResized:Xt})]})}function wd(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Td(e){let t=[],n=0,r=0,i=``;for(;;){let a=await e(n);if(a.kind!==`file-part`)throw Error(`invalid`);if(n===0)({size:r,version:i}=a);else if(a.size!==r||a.version!==i)throw Error(`stale`);let o=wd(a.data),s=n+o.length;if(a.next===null?s!==r:a.next!==s||o.length!==196608)throw Error(`invalid`);if(t.push(o),a.next===null)break;n=a.next}return new Blob(t,{type:`application/octet-stream`})}var Ed=/[<>:"/\\|?*\u0000-\u001f]/g,Dd=/[. ]+$/,Od=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function kd(e){let t=e.replace(Ed,`_`).replace(Dd,``);return t?Od.test(t)?`_${t}`:t:`_`}function Ad(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function jd(e,t){let n=/windows/i.test(navigator.userAgent)?kd(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return Ad(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(Ad(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Md(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
23
|
+
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function ed({label:e,children:t}){return(0,_.jsx)(`div`,{className:`msg-actions`,role:`group`,"aria-label":e,children:t})}function td({icon:e,label:t,title:n=t,showLabel:r=!1,done:i=!1,onClick:a}){return(0,_.jsxs)(`button`,{type:`button`,className:`msg-action${r?` labelled`:``}${i?` done`:``}`,title:n,"aria-label":t,onClick:a,children:[e,r&&(0,_.jsx)(`span`,{className:`msg-action-label`,children:t})]})}function nd({turn:e,parts:t}){let{t:n}=D(),{copied:r,copy:i}=es();return(0,_.jsx)(td,{icon:r?(0,_.jsx)(Fa,{"aria-hidden":`true`}):(0,_.jsx)(Da,{"aria-hidden":`true`}),label:n(`Copy message`),done:r,onClick:()=>{let r=()=>ps(`error`,n(`Copy unavailable`)),a=e=>i(e).then(e=>{e||r()}),o=$u(e,t,new AbortController().signal);typeof o==`string`?a(o):o.then(a,r)}})}var rd=(e,t)=>new Date(e).toLocaleTimeString(t===`zh`?`zh-CN`:`en-GB`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),id=(0,m.memo)(function({turn:e,onContinue:t,onEdit:n,version:r=0,versions:i=0,onVersion:a,off:o=!1}){let{t:s,tx:c,locale:l}=D(),{header:u}=e,{user:d,replies:f}=Fu(e.steps),p=f.filter(({step:e})=>e.role===`assistant`&&!e.error),h=u.status===`queued`||u.status===`running`,g=t&&u.entry&&(0,_.jsx)(td,{icon:(0,_.jsx)(Ea,{"aria-hidden":`true`}),label:s(`Continue from here`),title:s(`Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.`),showLabel:!0,onClick:()=>t(u.id)}),v=n&&!h&&(0,_.jsx)(td,{icon:(0,_.jsx)(xa,{"aria-hidden":`true`}),label:s(`Edit and resend`),title:s(`Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.`),onClick:()=>n(u.id)}),[y,b]=(0,m.useState)(!1),{thinking:x,media:S,other:C}=u.omitted,w=[x&&s(`Thinking that could not be read is not shown.`),S&&s(`Media is not retained.`),C&&s(`Other content is not retained.`)].filter(e=>e!==!1),T=u.notice.split(`
|
|
24
|
+
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:E}=u,O=h&&!f.some(({step:e})=>Nu(e)),k=u.at>0&&(0,_.jsx)(`time`,{className:`msg-time`,dateTime:new Date(u.at).toISOString(),children:rd(u.at,l)}),A=f.length>0||h||w.length>0;return(0,_.jsxs)(`section`,{className:o?`chat-turn off-branch`:`chat-turn`,"aria-label":s(o?`Conversation turn, not in the new message's context`:`Conversation turn`),children:[d.map(({step:t,index:n,key:o},c)=>{let l=t.text.trim()!==``,f=c===0&&v,p=!A&&c===d.length-1&&g;return(0,_.jsxs)(`article`,{className:`msg msg-user`,children:[(0,_.jsxs)(`div`,{className:`msg-meta`,children:[(0,_.jsx)(`span`,{className:`msg-role`,children:s(`You`)}),k,c===0&&i>1&&(0,_.jsxs)(`span`,{className:`msg-versions`,role:`group`,"aria-label":s(`Version {index} of {count}`,{index:r,count:i}),children:[(0,_.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Previous version`),title:s(`Previous version`),disabled:!a||r<=1,onClick:()=>a?.(u.id,-1),children:(0,_.jsx)(Na,{"aria-hidden":`true`})}),(0,_.jsxs)(`span`,{className:`msg-version-count`,"aria-hidden":`true`,children:[r,`/`,i]}),(0,_.jsx)(`button`,{type:`button`,className:`msg-version-step`,"aria-label":s(`Next version`),title:s(`Next version`),disabled:!a||r>=i,onClick:()=>a?.(u.id,1),children:(0,_.jsx)(Ma,{"aria-hidden":`true`})})]})]}),(0,_.jsx)(`div`,{className:`msg-body`,children:(0,_.jsx)(Hu,{turn:e,index:n,step:t,copy:!1})}),(l||f||p)&&(0,_.jsxs)(ed,{label:s(`Message actions`),children:[f,l&&(0,_.jsx)(nd,{turn:e,parts:[{step:t,index:n,key:o}]}),p]})]},o)}),A&&(0,_.jsxs)(`article`,{className:`msg msg-assistant`,children:[(0,_.jsxs)(`div`,{className:`msg-meta`,children:[(0,_.jsx)(`span`,{className:`msg-role`,children:`Cadence`}),E&&(0,_.jsx)(`button`,{type:`button`,className:`msg-model`,"aria-expanded":y,title:s(`Context fixed at admission:`),onClick:()=>b(e=>!e),children:E.model?`${E.model.provider}/${E.model.model}`:s(`No model`)}),d.length===0&&k]}),E&&y&&(0,_.jsxs)(`p`,{className:`msg-context`,children:[s(`Context fixed at admission:`),` `,(0,_.jsx)(`code`,{children:E.cwd}),` · `,E.model?`${E.model.provider}/${E.model.model} · ${E.model.thinking}`:s(`No model`)]}),(0,_.jsxs)(`div`,{className:`msg-body`,children:[f.map(({step:t,index:n,key:r})=>t.role===`tool`?(0,_.jsx)(Gu,{turn:e,index:n,step:t},r):t.role===`thinking`?(0,_.jsx)(Ku,{turn:e,index:n,step:t},r):(0,_.jsxs)(`div`,{className:`msg-part`,children:[t.error&&(0,_.jsx)(`span`,{className:`ep-state failed`,children:s(`Incomplete model response`)}),(0,_.jsx)(Hu,{turn:e,index:n,step:t,render:e=>(0,_.jsx)(Qu,{text:e,streaming:h&&t.state===`streaming`})})]},r)),O&&(0,_.jsxs)(`p`,{className:`msg-working`,role:`status`,children:[(0,_.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),u.status===`queued`?c(`queued`):s(`Working…`)]}),w.map(e=>(0,_.jsx)(`p`,{className:`msg-omitted`,children:e},e))]}),!h&&(p.length>0||g)&&(0,_.jsxs)(ed,{label:s(`Message actions`),children:[p.length>0&&(0,_.jsx)(nd,{turn:e,parts:p}),g]})]}),u.status===`running`&&u.retry&&(0,_.jsxs)(`p`,{className:`inspector-note chat-turn-retry`,role:`status`,children:[u.retry.phase===`waiting`?s(`Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts,seconds:Math.ceil(u.retry.delayMs/1e3)}):s(`Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.`,{attempt:u.retry.attempt,maxAttempts:u.retry.maxAttempts}),u.retry.reason&&` ${s(`The provider said: {reason}`,{reason:u.retry.reason})}`]}),T.length>0&&(0,_.jsx)(`p`,{className:`inspector-note chat-turn-notice`,children:T.map(e=>c(e)).join(`
|
|
25
|
+
`)}),![`completed`,`running`,`queued`].includes(u.status)&&(0,_.jsx)(`p`,{className:`ep-state ${u.status}`,children:c(u.status)})]})});function ad({hint:e,children:t}){let{t:n}=D();return(0,_.jsxs)(`div`,{className:`empty-state chat-welcome`,children:[(0,_.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h2`,{children:n(`What would you like to work on?`)}),(0,_.jsx)(`p`,{children:e}),t]})}function od({draft:e,disabled:t,onEdit:n,onSubmit:r}){let{t:i}=D(),[a,o]=(0,m.useState)(),s=a&&a.revision===e.revision+1?a:e,c=async t=>{o(nr(e,t,!1));try{await n(t)}finally{o(void 0)}},[l,u]=(0,m.useState)(``),[d,f]=(0,m.useState)(),p=s.questions.filter(e=>Xn(e,s.answers)),h=p.find(e=>e.id===l)??p[0],g=s.answers.find(e=>e.question===h.id),v=e=>c([...s.answers.filter(e=>e.question!==h.id),e]),y=d?.question===h.id?d.value:g&&`other`in g?g.other:``;return(0,_.jsxs)(`section`,{className:`workflow-plan design-card`,"aria-label":i(`Design choices`),children:[(0,_.jsx)(`h3`,{children:i(`Design choices`)}),(0,_.jsx)(`nav`,{"aria-label":i(`Questions`),children:p.map(e=>(0,_.jsxs)(`button`,{type:`button`,"aria-current":e.id===h.id?`step`:void 0,onClick:()=>u(e.id),children:[e.question,` ·`,` `,$n(e,s.answers.find(t=>t.question===e.id))??`…`]},e.id))}),(0,_.jsxs)(`fieldset`,{disabled:t,children:[(0,_.jsx)(`legend`,{children:h.question}),h.options.map(e=>(0,_.jsxs)(`label`,{children:[(0,_.jsx)(`input`,{type:`radio`,name:s.id+h.id,checked:!!g&&`option`in g&&g.option===e.id,onChange:()=>v({question:h.id,option:e.id})}),` `,e.label,e.id===h.recommended?` · ${i(`Recommended`)}`:``,(0,_.jsx)(`small`,{children:e.cost})]},e.id)),(0,_.jsx)(`p`,{children:h.reason}),(0,_.jsxs)(`p`,{children:[i(`Acceptance`),` · `,h.acceptance]}),(0,_.jsxs)(`label`,{children:[i(`Other idea`),(0,_.jsx)(`input`,{value:y,onChange:e=>f({question:h.id,value:e.target.value})})]}),(0,_.jsx)(`button`,{type:`button`,disabled:!y.trim(),onClick:()=>v({question:h.id,other:y.trim()}),children:i(`Use this answer`)})]}),(0,_.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>void c(Zn(s.questions,[],!0)),children:i(`Use all recommendations`)}),s.submitted?(0,_.jsx)(`p`,{role:`status`,children:i(`Design submitted`)}):(0,_.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>r(nr(s,s.answers,!0)),children:i(`Submit design and use recommendations for unanswered questions`)})]})}function sd(e,t,n){let r=Math.max(0,t),i=Math.floor((r+4)/7),a=Math.min(e,i),o=Array.from({length:a},(t,r)=>{let i=Math.floor(r*e/a),o=Math.floor((r+1)*e/a)-1;return n>=i&&n<=o?n:r===a-1?o:i}),s=a>1?Math.min(27,(r-a*3)/(a-1)):0;return{indices:o,gap:s,many:e>a||a>1&&s<20}}function cd({questions:e,active:t,reading:n,onJump:r}){let{t:i}=D(),a=(0,m.useRef)(null),[o,s]=(0,m.useState)(0);(0,m.useLayoutEffect)(()=>{let e=a.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>s(e.clientHeight);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[]);let{indices:c,gap:l,many:u}=(0,m.useMemo)(()=>sd(e.length,o,t),[e.length,o,t]),d=c.includes(t)?t:c.at(-1),f=e=>{let t=e.key===`ArrowDown`?1:e.key===`ArrowUp`?-1:0;if(!t&&e.key!==`Home`&&e.key!==`End`)return;let n=[...e.currentTarget.querySelectorAll(u?`.qn-list-item`:`.qn-bar`)];if(!n.length)return;e.preventDefault();let r=document.activeElement,i=u?Number(r?.dataset.question??0):n.indexOf(r);n[e.key===`Home`?0:e.key===`End`?n.length-1:Math.min(n.length-1,Math.max(0,i+t))]?.focus()},p=()=>a.current?.querySelector(`.qn-list-item.active`)?.scrollIntoView({block:`nearest`}),h=(e,t)=>{e.detail>0&&e.currentTarget.blur(),r(t)},g=t=>`${t+1}. ${e[t].text}`;return(0,_.jsxs)(`nav`,{className:`qn-rail${u?` many`:``}`,ref:a,"aria-label":i(`Questions in this conversation`),style:{"--rail-gap":`${l}px`},onKeyDown:f,onMouseEnter:p,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||p()},children:[c.map(r=>{let i=e[r];return(0,_.jsx)(`button`,{type:`button`,className:`qn-bar${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===i.id||void 0,"data-question":r,tabIndex:r===d?0:-1,onClick:e=>h(e,i.id),children:(0,_.jsx)(`span`,{className:`qn-bar-text`,children:g(r)})},i.id)}),u&&(0,_.jsx)(`div`,{className:`qn-list`,children:e.map((e,r)=>(0,_.jsxs)(`button`,{type:`button`,className:`qn-list-item${r===t?` active`:``}`,"aria-label":g(r),"aria-current":r===t?`true`:void 0,"aria-busy":n===e.id||void 0,"data-question":r,tabIndex:-1,onClick:t=>h(t,e.id),children:[(0,_.jsx)(`span`,{className:`qn-list-idx`,children:r+1}),(0,_.jsx)(`span`,{className:`qn-list-text`,children:e.text||`…`})]},e.id))})]})}var ld={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`},ud=(e,t,n)=>new File([e],`image-${n+1}.${ld[t.mimeType]??`img`}`,{type:t.mimeType});function dd({draftKey:e,draft:t,setDraft:n,images:r,alive:i,onUnread:a}){let[o,s]=(0,m.useState)(()=>{try{return Bc(sessionStorage.getItem(`${e}:anchor`))}catch{return null}}),c=(0,m.useRef)(o);c.current=o,(0,m.useEffect)(()=>{try{o?sessionStorage.setItem(`${e}:anchor`,JSON.stringify(o)):sessionStorage.removeItem(`${e}:anchor`)}catch{}},[e,o]);let l=(0,m.useRef)([]),u=(0,m.useRef)(null),[d,f]=(0,m.useState)(!1),p=()=>{u.current?.abort(),u.current=null,f(!1)},h=()=>{p();let e=c.current;e&&(c.current=null,s(null),n(e.stash),r.replace(l.current),l.current=[])},g=(e,n,i)=>{p();let a=c.current;a||(l.current=r.files);let o=Fu(e.steps).user[0],u={kind:n,entry:i,turnId:e.header.id,from:n===`edit`?e.ordinal:e.ordinal+1,label:Ic(o?.step.text??``),media:n===`edit`&&e.header.omitted.media,stash:a?a.stash:t};return c.current=u,s(u),r.replace([]),o};return{anchor:o,current:()=>c.current,attaching:d,release:h,continueAfter:e=>e.header.entry?(g(e,`continue`,e.header.entry),n(``),!0):!1,edit:(e,t)=>{let o=Lc(e,t);if(o===void 0)return!1;let s=g(e,`edit`,o);if(n(s?.step.text??``),!s)return!0;let c=s.step.text,l=s.step.images??[],d=new AbortController,p=$u(e,[s],d.signal);if(typeof p==`string`&&!l.length)return!0;u.current=d,f(!0);let{image:m}=e;return Promise.allSettled([p,...l.map((e,t)=>m?m(e,d.signal).then(n=>ud(n,e,t)):Promise.reject(Error(`unavailable`)))]).then(([e,...t])=>{if(d.signal.aborted||!i.current)return;u.current=null,f(!1),e.status===`fulfilled`&&n(t=>t===c?e.value:t);let o=t.flatMap(e=>e.status===`fulfilled`?[e.value]:[]);try{o.length&&r.add(o)}catch{o.length=0}(e.status===`rejected`||o.length<l.length)&&a()}),!0}}}function fd({pending:e,undelivered:t,canWithdraw:n,recallable:r,onWithdraw:i,onRestore:a}){let{t:o,tx:s}=D();return!e.length&&!t.length?null:(0,_.jsxs)(`section`,{className:`chat-waiting-list`,"aria-label":o(`Waiting messages`),children:[e.map(e=>(0,_.jsxs)(`article`,{className:`chat-waiting ${e.mode}`,children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(`span`,{className:`chat-waiting-tag ${e.mode}`,children:e.mode===`steer`?o(`Steering: read at the model's next step`):o(`Queued: sent when this reply ends`)}),(0,_.jsxs)(`span`,{className:`chat-waiting-actions`,children:[r(e)&&(0,_.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw and put back in the message box`),"aria-label":o(`Withdraw and put back in the message box`),onClick:()=>i(e,!0),children:(0,_.jsx)(Ta,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:!n,title:o(`Withdraw`),"aria-label":o(`Withdraw`),onClick:()=>i(e,!1),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]})]}),(0,_.jsx)(`p`,{className:`chat-attempt-text`,children:e.text})]},e.commandId)),t.map(e=>(0,_.jsxs)(`article`,{className:`chat-attempt chat-undelivered`,children:[(0,_.jsx)(`p`,{className:`chat-attempt-text`,children:e.text}),(0,_.jsxs)(`p`,{className:`inspector-note`,children:[(0,_.jsx)(`span`,{className:`ep-state ${e.status}`,children:s(e.status)}),` `,e.notice?s(e.notice):o(`Not delivered.`)]}),(0,_.jsxs)(`button`,{type:`button`,className:`ghost`,onClick:()=>a(e.text),children:[(0,_.jsx)(Ta,{"aria-hidden":`true`}),o(`Put back in the message box`)]})]},e.commandId))]})}var pd=[`queued`,`running`],md=e=>pd.includes(e.status);function hd(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function gd(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function _d(e,t,n){let r=[],i=[],a=new Map;if(!e.length)return{start:r,after:a,end:i};let o=e.filter(e=>e.header.at>0),s=e=>hd(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=hd(e),s=t===null?void 0:o.findLast(e=>e.header.at<=t);t===null||!o.length?i.push(e):s?a.set(s.header.id,[...a.get(s.header.id)??[],e]):n||r.push(e)}return{start:r,after:a,end:i}}function vd(e,t,n,r,i,a){if(t>=e.length)return t;let o=e.slice(-t);if(o.some(e=>!n.has(e)&&!r.has(e)))return t;let s=o.flatMap(e=>{let t=n.get(e),r=t?hd(t):null;return r===null?[]:[r]}),c=s.length?Math.min(...s):1/0;return a||i!==void 0&&c>=i?t+8:t}function yd(e,t){let n=e.diagnostics?.acceptedAt,r=e.diagnostics?.settledAt;if(!n||!r||r<n)return``;let i=Math.round((r-n)/1e3);return i<60?t(`{s}s`,{s:i}):i<3600?t(`{m}m {s}s`,{m:Math.floor(i/60),s:i%60}):t(`{h}h {m}m`,{h:Math.floor(i/3600),m:Math.floor(i%3600/60)})}function bd({client:e,run:t,onOpen:n,onChanged:r}){let{t:i,tx:a}=D(),o=(0,m.useId)(),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(``),d=(0,m.useRef)(!0);(0,m.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let f=md(t),p=f?gc(t):null,h=t.status===`completed`?t.deviations?.length??0:0,g=h?h===1?i(`delivered with 1 deviation`):i(`delivered with {count} deviations`,{count:h}):``,v=e=>e.filter(Boolean).join(` · `),y=v(f?[a(gd(t)),p?hc(p,i):t.steps.filter(e=>e.status===`running`).map(e=>fc(e.id)).join(`, `)]:[a(t.status)]),b=f?``:v([t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,yd(t,i)]),x=f||t.status===`completed`?``:t.notice.split(`
|
|
26
|
+
`).find(e=>e.trim())??``,C=v([y,g,b]);return(0,_.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,_.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,_.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,_.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:C,children:g?(0,_.jsxs)(_.Fragment,{children:[`${y} · `,(0,_.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,_.jsx)(Ha,{"aria-hidden":`true`}),g]}),b&&` · ${b}`]}):C})]}),f&&(0,_.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),Sd(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,_.jsx)(Wi,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,_.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:S(i,l)}):x&&(0,_.jsx)(`p`,{className:`workflow-line-reason`,title:x,children:a(x)})]})}function xd({proposal:e,canApprove:t,approvalHint:n,onApprove:r,action:i=`approve`,canValidate:a=!1,validating:o=!1,previous:s,onValidate:c}){let{t:l}=D();return(0,_.jsxs)(`section`,{className:`workflow-plan`,"aria-label":l(`Current implementation plan`),children:[(0,_.jsx)(`h3`,{children:l(`Current implementation plan`)}),e.revalidatedFrom&&(0,_.jsx)(`p`,{role:`status`,children:l(`The plan content is unchanged. Its execution context was revalidated; review it below and confirm implementation. Nothing was approved.`)}),s&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:l(`Previous execution context`)}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:s.cwd}),` · `,s.display?.model]}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:s.display?.branch}),` ·`,` `,(0,_.jsx)(`code`,{children:s.display?.baseCommit})]}),s.display?.runtime&&(0,_.jsx)(`p`,{children:s.display.runtime}),s.delivery&&(0,_.jsx)(ws,{text:jr(s.delivery)})]}),s&&s.observation!==e.observation&&(0,_.jsx)(`p`,{role:`status`,children:l(`Repository or execution-environment evidence changed. Review the current context before confirming.`)}),(0,_.jsx)(`p`,{children:l(`Tools and checks run on the service host, not in a sandbox.`)}),(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,_.jsxs)(`p`,{children:[l(`Declared write paths use the checkout root:`),` `,(0,_.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.runtime&&(0,_.jsx)(`p`,{children:e.display.runtime}),e.display?.branch&&(0,_.jsxs)(`p`,{children:[(0,_.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,_.jsx)(`code`,{children:e.display.baseCommit})]}),(0,_.jsx)(`p`,{children:l(`Approval covers this goal, its decisions, acceptance and assumptions. The service then finishes on its own: it may revise the route and write scope inside the repository, and records any deviation from the acceptance for the automatic review and the final report. No push, publication or deployment.`)}),(0,_.jsx)(ws,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:l(`Complete delivery agreement`)}),(0,_.jsxs)(`p`,{children:[l(`Plan identity`),` · `,(0,_.jsx)(`code`,{children:e.digest})]}),(0,_.jsx)(ws,{text:zr(e.plan)})]}),e.delivery&&(0,_.jsx)(ws,{text:jr(e.delivery)}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,disabled:i===`approve`?!t:!a,onClick:i===`approve`?r:c,children:l(o?`Validating plan…`:i===`restore`?`Restore execution and validate plan`:i===`validate`?`Validate plan again`:e.revalidatedFrom?`Confirm implementation`:`Implement this plan`)}),i===`approve`&&c&&(0,_.jsx)(`button`,{type:`button`,disabled:!a,onClick:c,children:l(`Validate plan again`)}),i!==`approve`&&(0,_.jsx)(`p`,{className:`inspector-note`,children:l(`Validation may start the execution service and install the displayed model choice. It sends no message and runs no implementation; confirmation comes afterward.`)}),!t&&(i===`approve`||!a)&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??l(`Plan approval is currently unavailable.`)}),(0,_.jsx)(`p`,{children:l(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function Sd(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 Cd(e){return(0,_.jsx)(wd,{...e},e.id)}function wd({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=D(),[o,s]=(0,m.useState)(1e3),[c,l]=(0,m.useState)(),u=Oo(e,{kind:`workflow`,id:t},o),d=Oo(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),f=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,p=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,h=c===void 0?p:f,[g,v]=(0,m.useState)(null),y=Oo(e,g?{kind:`workflow-detail`,id:t,stepId:g}:null),[b,x]=(0,m.useState)(!1),[S,C]=(0,m.useState)(``),w=p&&[`queued`,`running`].includes(p.status),T=(0,m.useRef)(!0);return(0,m.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]),(0,m.useEffect)(()=>{p&&![`queued`,`running`].includes(p.status)&&s(0)},[p]),(0,_.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(`strong`,{children:p?.goal??i(`Observing workflow`)}),p&&(0,_.jsxs)(`span`,{className:`ep-state ${p.status}`,children:[a(p.phase),` · `,a(p.status)]})]}),(u.error||d.error||S)&&(0,_.jsxs)(`p`,{role:`alert`,children:[S||u.error||d.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),p&&(0,_.jsx)(Dd,{run:p}),p?.execution&&(0,_.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,_.jsx)(`code`,{children:p.execution.cwd}),` ·`,` `,p.execution.model?`${p.execution.model.provider}/${p.execution.model.model} · ${p.execution.model.thinking}`:i(`No model`)]}),p?.notice&&(0,_.jsx)(`p`,{children:p.notice}),p&&h&&(0,_.jsx)(Ad,{run:p,steps:h.steps,partial:(h.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:fc(e.id)}))}),p&&((p.revision??0)>0||!!p.scope?.length)&&(0,_.jsxs)(`section`,{className:`workflow-route`,"aria-label":i(`Route revisions`),children:[(p.revision??0)>0&&(0,_.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,p.revision]}),!!p.scope?.length&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{children:i(`Paths added to the write scope after approval:`)}),(0,_.jsx)(`ul`,{className:`workflow-scope`,children:p.scope.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsx)(`code`,{children:e})},e))})]})]}),p?.delivery&&(0,_.jsx)(jd,{delivery:p.delivery}),p&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,_.jsx)(`pre`,{className:`workflow-detail`,children:Ur(p)})]}),p?.mergedCommit&&(0,_.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,_.jsx)(`code`,{children:p.mergedCommit})]}),p&&(0,_.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),p&&((h?.stepsBefore??0)>0||c!==void 0)&&(0,_.jsxs)(`nav`,{className:`workflow-actions`,children:[(h?.stepsBefore??0)>0&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(h?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),h&&(0,_.jsx)(Td,{steps:h.steps}),h?.steps.map(e=>(0,_.jsxs)(`details`,{className:`chat-tool`,children:[(0,_.jsx)(`summary`,{children:(0,_.jsx)(Ed,{run:p??h,step:e})}),e.exitCode!==null&&(0,_.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,_.jsx)(ws,{text:e.text}),e.childRunId&&r&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:fc(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,_.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>v(e.id),children:i(`Read retained step result`)}),g===e.id&&y.value?.kind===`file`&&(0,_.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),g===e.id&&y.error&&(0,_.jsx)(`p`,{role:`alert`,children:y.error})]},e.id)),w&&(0,_.jsx)(`button`,{type:`button`,className:`danger`,disabled:b,onClick:()=>{p&&(x(!0),Sd(e,p).then(e=>{T.current&&(C(e),u.refresh(),n?.())}).finally(()=>{T.current&&x(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:i(`Observe current state`)})]})}function Td({steps:e}){let{t}=D(),n=t=>e.filter(e=>e.status===t).length,r=n(`partial`),i=n(`blocked`);return!r&&!i?null:(0,_.jsxs)(`p`,{className:`inspector-note`,children:[t(`Attempts shown: {partial} partial · {blocked} blocked · {failed} failed`,{partial:r,blocked:i,failed:n(`failed`)}),` · `,t(`Partial or blocked assignments preserve work; they are not process failures or delivery approval.`)]})}function Ed({run:e,step:t}){let{t:n,tx:r}=D();return(0,_.jsxs)(_.Fragment,{children:[`${r(t.kind)} · ${fc(t.id)} · ${r(t.status)}`,bc(e,t)&&(0,_.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function Dd({run:e}){let{t}=D(),n=e.deviations??[];return n.length?(0,_.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,_.jsxs)(`h3`,{children:[(0,_.jsx)(Ha,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,_.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,_.jsx)(`ol`,{children:n.map(e=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(`dl`,{children:[(0,_.jsx)(`dt`,{children:t(`Could not be met`)}),(0,_.jsx)(`dd`,{children:e.item}),(0,_.jsx)(`dt`,{children:t(`Why`)}),(0,_.jsx)(`dd`,{children:e.reason}),(0,_.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,_.jsx)(`dd`,{children:e.delivered}),(0,_.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,_.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,_.jsx)(`code`,{children:e},e)):t(`None`)}),(0,_.jsx)(`dt`,{children:t(`Recorded at`)}),(0,_.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function Od({state:e}){return e===`running`?(0,_.jsx)(Vu,{}):e===`completed`?(0,_.jsx)(Ia,{"aria-hidden":`true`}):e===`failed`?(0,_.jsx)(Bi,{"aria-hidden":`true`}):e===`superseded`?(0,_.jsx)(Gi,{"aria-hidden":`true`}):(0,_.jsx)(ka,{"aria-hidden":`true`})}function kd(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function Ad({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=D(),o=pc(e);return o?(0,_.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,_.jsxs)(`h3`,{children:[i(`Assignments`),(0,_.jsx)(`span`,{className:`workflow-board-counts`,children:hc(o,i)})]}),n&&(0,_.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,_.jsx)(`ul`,{children:_c(e,t).map(({task:e,steps:t,artifact:n})=>(0,_.jsxs)(`li`,{className:`workflow-task`,children:[(0,_.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,_.jsx)(Od,{state:e.state}),a(e.state)]}),(0,_.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,_.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,_.jsx)(`span`,{children:e.title}),(0,_.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,_.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,_.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,_.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,_.jsx)(`span`,{className:`workflow-task-worktree`,children:kd(n,i)})]}),n?.state===`retained`&&(0,_.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,_.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,_.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,_.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function jd({delivery:e}){let{t,tx:n}=D(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${e.acceptance.waived?.length?t(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,_.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,_.jsx)(`dl`,{children:r.map(([e,t])=>(0,_.jsxs)(m.Fragment,{children:[(0,_.jsx)(`dt`,{children:e}),(0,_.jsx)(`dd`,{children:(0,_.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,_.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,_.jsx)(`p`,{children:e.cleanup.reason}),(0,_.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var Md=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function Nd(e){return e.scrollHeight-e.scrollTop-e.clientHeight<80}function Pd(e,t){t&&e&&(e.scrollTop=e.scrollHeight)}function Fd(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Id({client:e,id:t,workspaceId:n,initialCwd:r,initialLeaf:i=null,activitySelected:a=!1,onLocation:o,onActivity:s,enabled:c,actionsReady:l=c,prepareForSend:u,prepareForPlan:d,legacyWorkspaceId:f,directoryNamespaces:p=[],available:h=c,canInterrupt:g=c,modelAvailability:v,previewModels:y,initialDraft:b,onDraftApplied:x,onModelChanged:C,onChanged:w,reference:T,onReferenceUsed:E,hidden:O=!1,observe:k=0,onOpenAgent:A,onWorkflowRuns:ee,onBranches:j,onOpenBranches:te}){let{t:M,tx:ne}=D(),[N]=(0,m.useState)(()=>cl(n,t,f,...p)),[re,ie]=(0,m.useState)(()=>Fd(N,b?.text));(0,m.useEffect)(()=>{b&&x?.()},[b,x]);let P=uu(),ae=P.remove,F=(0,m.useRef)([]),I=(0,m.useRef)(!0),L=dd({draftKey:N,draft:re,setDraft:ie,images:P,alive:I,onUnread:()=>le(M(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:R,attaching:z}=L,B=L.release,V=(0,m.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[H,U]=(0,m.useState)(()=>Fd(`${N}:mode`)===`cadence`?`cadence`:`chat`),[W,G]=(0,m.useState)(!1),[K,q]=(0,m.useState)(``),se=`conversation:${t}`,ce=()=>{q(``),hs(se)},le=e=>ps(`error`,e,se);(0,m.useEffect)(()=>()=>hs(se),[se]);let[ue,Y]=(0,m.useState)(()=>Fd(`${N}:pending`)),[de,fe]=(0,m.useState)(()=>Fd(`${N}:model-command`)),[pe,me]=(0,m.useState)(!1),[he,_e]=(0,m.useState)(!1),[ve,ye]=(0,m.useState)(!1),[be,xe]=(0,m.useState)(0),Se=(0,m.useRef)(null),Ce=(0,m.useRef)(!1),we=(0,m.useRef)(0),Te=(0,m.useRef)(new AbortController),[Ee,De]=(0,m.useState)(!1),[Oe,ke]=(0,m.useState)(()=>{try{let e=sessionStorage.getItem(`${N}:model`);if(e)return ge(JSON.parse(e))}catch{}return b?.model??null});(0,m.useEffect)(()=>{try{Oe?sessionStorage.setItem(`${N}:model`,JSON.stringify(Oe)):sessionStorage.removeItem(`${N}:model`)}catch{}},[N,Oe]);let Ae=Oo(e,h&&r?{kind:`conversation-context`,location:{id:t,cwd:r}}:null,1e3),je=Ae.value?.kind===`conversation-context`?Ae.value.context:void 0,Me=!!je&&!Ae.error,Ne=je?.cwd??r,Pe=(0,m.useMemo)(()=>({models:(n,r)=>Ne?e.models(n,{id:t,cwd:Ne},r):Promise.resolve({kind:`error`,error:oe(`unavailable`)}),chooseModel:n=>Ne?e.chooseModel(n,{id:t,cwd:Ne}):Promise.resolve({kind:`error`,error:oe(`unavailable`)})}),[e,t,Ne]),Fe=Ee?{status:`preparing`}:v.status===`ready`&&(!h||!Me)?{status:Ae.error?`unavailable`:`connecting`}:v,Ie=(0,m.useRef)(Fe);Ie.current=Fe;let Le=wl(Pe,Fe,`${be}:${je?.revision??`unobserved`}`,y),Re=()=>{Se.current=null,_e(!1),ye(!1)},ze=(e,t)=>{e?Le.reread(!0):!e&&t!==`chosen`&&Re(),me(e)},Be=(e,t)=>{ke(t?null:e);let n=Se.current;he&&n&&(il(n,Ie.current)===`cancel`?(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Se.current=rl(n,e,t),_e(!1),ce(),ye(!0)))},Ve=(0,m.useRef)(o);Ve.current=o,(0,m.useEffect)(()=>{Me&&Ne&&Ve.current?.({id:t,cwd:Ne})},[Me,t,Ne]);let[He]=(0,m.useState)(()=>typeof window<`u`&&So()===t?wo(window.location.hash,t).leaf:i),X=Sl(e,t,h,He),{turns:Ue}=X,We=X.summary!==void 0,Ge=Oo(e,h?{kind:`cadence-conversation`,id:t}:null,1e3),[Ke,qe]=(0,m.useState)(),Je=Ge.value?.kind===`cadence-conversation`?Ge.value.state:void 0,Z=Je&&Ke?.id===t&&Ke.revision>Je.revision?Ke:Je,Ye=Z?.enabled===!0,Xe=!!Z||!!Ge.error,Ze=!!Z&&!Ge.error&&!Z.notice,Qe=(0,m.useRef)(Z);Qe.current=Z;let[$e,et]=(0,m.useState)(()=>Fd(`${N}:approval`,``)),tt=(0,m.useRef)($e),nt=(0,m.useRef)(!1),[rt,it]=(0,m.useState)(!1),[at,ot]=(0,m.useState)(``),[st,ct]=(0,m.useState)(),lt=(0,m.useCallback)(e=>{tt.current=e,et(e);try{e?sessionStorage.setItem(`${N}:approval`,e):sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]),ut=ko(re,Ye?`cadence`:H),dt=c&&!(a&&!X.summary)&&Me&&We&&!X.error&&Xe&&!(Ye&&(Ge.error||Z?.notice))&&!W&&!he&&!ue,Q=X.summary??void 0,ft=Q&&(Q.status===`queued`||Q.status===`running`),pt=!!Q&&Q.status!==`completed`&&!ft,mt=Ue.at(-1)?.header,ht=ft?mt&&[`queued`,`running`].includes(mt.status)?mt.at:0:null,{tokens:gt,provider:_t,model:vt}=X.context??{},yt=Le.catalog?.entries??Le.preview?.entries,bt=(0,m.useMemo)(()=>gt===void 0||_t===void 0||vt===void 0?void 0:Nc({tokens:gt,provider:_t,model:vt},yt),[gt,_t,vt,yt]),{input:xt,read:St,write:Ct}=X.cache??{},wt=(0,m.useMemo)(()=>xt===void 0||St===void 0||Ct===void 0?void 0:{input:xt,read:St,write:Ct},[xt,St,Ct]),Tt=X.refresh;(0,m.useEffect)(()=>{k&&Tt()},[k,Tt]);let Et=(0,m.useRef)(s);Et.current=s,(0,m.useEffect)(()=>{Et.current?.({id:t,turns:X.count,runningSince:ht,...bt?{context:bt}:{},...wt?{cache:wt}:{}})},[t,X.count,ht,bt,wt]);let Dt=Ue.at(-1),Ot=!!Dt&&[`queued`,`running`].includes(Dt.header.status),kt=jc(e,t,X.leaf,[Dt?.header.id??``,X.count,X.branches,Ot].join(),h&&!!Q),{tree:At}=kt,jt=(0,m.useMemo)(()=>Oc(At??{nodes:[],truncated:!1}),[At]),Mt=(0,m.useMemo)(()=>{let e=kc(At?.nodes??[]).map(e=>({id:e.id,text:e.text}));if(!Dt||!Ot||e.some(e=>e.id===Dt.header.id))return e;let t=Fu(Dt.steps).user[0]?.step.text??``;return[...e,{id:Dt.header.id,text:Ic(t)}]},[At,Dt,Ot]),[Nt,Pt]=(0,m.useState)(null),[Ft,It]=(0,m.useState)(null),[Lt,Rt]=(0,m.useState)(null),zt=!!u&&c&&(!!X.error||!!Ae.error)&&X.error!==`retired-conversation`&&Ae.error!==`retired-conversation`&&!Z?.notice&&!ft&&!W&&!ue&&!he,Bt=(g||!!u)&&Me&&We&&Ze&&!X.error&&!W&&!ue&&!ft,Vt=!!Oe&&J(Oe)!==J(je?.model??null),Ht=!!Z?.proposal&&!!Q&&!ft&&Q.status!==`unknown`,Ut=Z?.proposal?Tl(Z.proposal,l,Le.catalog?.version,Vt||at===Z.proposal.id):`approve`,Wt=!!st&&!!Z&&Z.revision<st.after.revision,Gt=!!Z?.proposal&&dt&&Ze&&Ht&&!$e&&!rt&&!Wt&&(!!d||l)&&!!(Oe??je?.model),Kt=rt?M(`Preparing execution and validating the plan; no implementation is approved.`):Wt?M(`Reading the validated plan…`):Vt?M(`Validate the plan with this model before approving it.`):Q?.status===`unknown`?M(`The latest turn's outcome is unknown. Approval waits until it is observed.`):l?Ze?ft?M(`Wait for the current reply before approving this plan.`):$e?M(`Observing plan approval…`):dt?void 0:M(`Read the current conversation context before approving this plan.`):M(`Cadence state unavailable`):M(`Read the current execution state before approving this plan.`),qt=(0,m.useRef)(null),Jt=(0,m.useRef)(null),Yt=(0,m.useRef)(0),Xt=(0,m.useRef)(!0),[Zt,Qt]=(0,m.useState)(!1),$t=(0,m.useCallback)(()=>{Pd(Jt.current,Xt.current)},[]);(0,m.useLayoutEffect)(()=>{!O&&Jt.current&&!Xt.current&&(Jt.current.scrollTop=Yt.current)},[O]);let en=(0,m.useRef)(``),tn=(0,m.useRef)(re);(0,m.useEffect)(()=>(I.current=!0,Te.current.signal.aborted&&(Te.current=new AbortController),()=>{I.current=!1,Te.current.abort()}),[]),(0,m.useEffect)(()=>{try{sessionStorage.setItem(`${N}:mode`,H)}catch{}},[N,H]),(0,m.useEffect)(()=>{try{sessionStorage.setItem(N,re)}catch{}},[re,N]),(0,m.useEffect)(()=>{try{ue?sessionStorage.setItem(`${N}:pending`,ue):sessionStorage.removeItem(`${N}:pending`)}catch{}},[N,ue]),(0,m.useEffect)(()=>{try{ue&&de===ue?sessionStorage.setItem(`${N}:model-command`,de):sessionStorage.removeItem(`${N}:model-command`)}catch{}},[N,ue,de]),(0,m.useEffect)(()=>{T&&(ie(e=>`${e}${e?`
|
|
27
|
+
`:``}@${T}`),E(),qt.current?.focus())},[T,E]),(0,m.useEffect)(()=>{let e=Q?`${Q.leaf}:${Q.status}`:``;e&&en.current!==e&&(en.current=e,w()),tt.current&&Z?.runs.includes(tt.current)&&(lt(``),q(``)),ue&&(Q?.live?.commandId===ue||X.attempt?.commandId===ue||Ue.some(e=>e.header.id===ue)||X.commands.includes(ue))&&(Y(``),al(ue,de)&&ke(null),fe(``),ae(F.current),ie(e=>e===tn.current?``:e),al(ue,de)&&Fl(n,tn.current),V.current.followAnchor(),w()),Pd(Jt.current,Xt.current)},[Q,Ue,ue,de,w,Z,X,ae,n,lt]);let nn=(0,m.useMemo)(()=>Ue.map(e=>({id:e.header.id,role:`assistant`,version:e.steps.reduce((e,t)=>e+t.text.length+1,e.header.status.length),turn:e})),[Ue]),rn=tc(Jt,nn,Ft?.id??null,void 0,$t),{earlier:an,loadEarlier:on}=X,sn=()=>{let e=Jt.current;e&&!O&&an&&e.scrollTop<1200&&on()};(0,m.useEffect)(sn);let cn=(0,m.useRef)(0),ln=()=>{cn.current||=requestAnimationFrame(()=>{cn.current=0;let e=Jt.current;if(!e)return;let t=null;if(!Xt.current){let n=e.getBoundingClientRect().top+140;for(let r of e.querySelectorAll(`[data-lazy-id]`)){if(t!==null&&r.getBoundingClientRect().top>n)break;t=r.dataset.lazyId??null}}Rt(t)})};(0,m.useEffect)(()=>()=>{cn.current&&cancelAnimationFrame(cn.current)},[]),(0,m.useEffect)(()=>{if(!Ft)return;let e=requestAnimationFrame(()=>{let e=[...Jt.current?.querySelectorAll(`[data-lazy-id]`)??[]].find(e=>e.dataset.lazyId===Ft.id);e&&(Xt.current=!1,e.scrollIntoView({block:`start`}),e.classList.remove(`msg-flash`),e.offsetWidth,e.classList.add(`msg-flash`),Rt(Ft.id))});return()=>cancelAnimationFrame(e)},[Ft]);let un=Ue[0]?.ordinal,dn=(0,m.useRef)({height:0});(0,m.useLayoutEffect)(()=>{let e=Jt.current;if(!e)return;let t=dn.current;!Md&&!Xt.current&&t.ordinal!==void 0&&un!==void 0&&un<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),dn.current={ordinal:un,height:e.scrollHeight}}),(0,m.useEffect)(()=>{try{sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]);let fn=(0,m.useMemo)(()=>[...new Set([...X.runs,...Z?.runs??[]])],[X.runs,Z?.runs]),pn=JSON.stringify(fn.slice(-4));(0,m.useEffect)(()=>{ee?.(JSON.parse(pn))},[pn,ee]);let[mn,hn]=(0,m.useState)({terminal:8,browser:8}),gn=(0,m.useMemo)(()=>[...new Set([...X.runs.slice(-mn.terminal),...(Z?.runs??[]).slice(-mn.browser),...$e?[$e]:[]])],[X.runs,Z?.runs,mn,$e]),_n=wc(e,h?gn:[],1e3),vn=Ue.find(e=>e.header.at>0)?.header.at,yn=!an&&Ue.length>0;(0,m.useEffect)(()=>{if(!h)return;let e=(e,t)=>vd(e,t,_n.runs,_n.unreadable,vn,yn),t=e(X.runs,mn.terminal),n=e(Z?.runs??[],mn.browser);(t!==mn.terminal||n!==mn.browser)&&hn({terminal:t,browser:n})},[h,X.runs,Z?.runs,mn,_n,vn,yn]);let bn=(0,m.useMemo)(()=>_d(Ue,_n.runs.values(),an),[Ue,_n.runs,an]),xn=[..._n.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,m.useLayoutEffect)(()=>{xn&&Pd(Jt.current,Xt.current)},[xn]);let Sn=t=>(0,_.jsx)(bd,{client:e,run:t,onOpen:()=>A?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{Ge.refresh(),w()}},t.id),Cn=async()=>{if(!Gt||!Z?.proposal||!je||nt.current)return;let t=Oe??je.model;if(!t)return;let n=Z.proposal,r=Z,i=we.current,a=()=>I.current&&we.current===i;nt.current=!0,G(!0),it(!0),ce();try{let o=await El({client:e,state:r,context:je,model:t,head:X.leaf,signal:Te.current.signal,current:a,prepare:l?void 0:d});if(!I.current||we.current!==i)return;ct({before:n,after:o}),ot(``),ke(e=>J(e)===J(t)?null:e)}catch(e){I.current&&we.current===i&&q(M(`Plan validation did not finish ({code}). No implementation was approved; observe the plan before trying again.`,{code:e instanceof Error?e.message:`unavailable`}))}finally{I.current&&we.current===i&&(nt.current=!1,G(!1),it(!1),xe(e=>e+1),Ae.refresh(),Ge.refresh(),X.refresh(),w())}},wn=async()=>{if(!Z?.proposal){le(M(`No plan is awaiting approval.`));return}if(Ut!==`approve`){await Cn();return}if(nt.current||Wt||Vt||!l||!Ze||!dt||ft||$e||!Ht)return;let t=Z.proposal,n=Z,r=we.current;nt.current=!0,G(!0),ce();try{let i=await Dl({client:e,state:n,current:()=>I.current&&we.current===r&&Qe.current?.revision===n.revision&&Qe.current?.enabled===!0,submitting:lt});if(!I.current||we.current!==r)return;i.kind===`error`?(q(i.error.code),i.error.effect===`none`&&(lt(``),i.error.code===`stale`&&ot(t.id))):ie(e=>kl(e)?``:e)}catch(e){I.current&&we.current===r&&(q(e instanceof Error?e.message:`unavailable`),!tt.current&&e instanceof Error&&e.message===`stale`&&ot(t.id))}finally{I.current&&we.current===r&&(nt.current=!1,G(!1),Ge.refresh(),X.refresh(),w())}},Tn=async n=>{if(!Z?.design||nt.current)return;let r=we.current;nt.current=!0,G(!0);try{let i=await e.workbenchCommand({kind:`cadence-design-edit`,commandId:crypto.randomUUID(),conversationId:t,revision:Z.revision,designId:Z.design.id,answers:n});if(!I.current||r!==we.current)return;if(i.kind!==`ok`)throw Error(i.error.code);if(i.value.kind!==`cadence-conversation`||i.value.state.id!==t)throw Error(`stale`);qe(i.value.state)}catch(e){I.current&&r===we.current&&q(e instanceof Error?e.message:`unavailable`)}finally{I.current&&r===we.current&&(nt.current=!1,G(!1),Ge.refresh())}},En=async(r,i,a=!1)=>{let o=i?.text??r??re,s=i?.images??(r?[]:P.files),c=i?i.command.kind===`cadence-exit`:Ye&&Ol(o);if(!(c?Bt:dt)&&!zt||ft||z&&!i||!o.trim()&&!s.length||i&&(!dt||il(i,Ie.current)!==`ready`))return;if(c&&s.length){le(M(`Remove images before exiting Cadence.`));return}if(!s.length&&!i&&!r&&Ye&&kl(o)){await wn();return}let l=ko(o,H).mode===`cadence`;if(!zt&&(Ye||l)&&!Ze){le(M(`Cadence state unavailable. Observe the conversation before sending.`));return}if(Ce.current)return;Ce.current=!0,G(!0),ce();let d=we.current,f=()=>I.current&&we.current===d,p=!1,m=`not-dispatched`,h=(e,t)=>{let n=M(Xc(t),{code:e});t===`none`?le(n):q(n)},g=e=>{f()&&(Y(e),fe(e&&!c?e:``))},_=async e=>{u&&(De(!0),await qc(u,Te.current.signal,e,e=>{m=e}),f()&&(De(!1),xe(e=>e+1)))};try{if(zt){if(await _(je?{id:t,cwd:je.cwd}:void 0),!f())return;X.refresh(),Ae.refresh(),Ge.refresh(),w(),q(M(`Execution was prepared, but the conversation was unreadable before Send. Review its restored context and send again; this message was not sent.`));return}let u=i??Qc({id:t,head:c?X.leaf:Rc(R,X.leaf),text:o,images:s,revision:Z?.revision??0,location:je?{id:t,cwd:je.cwd}:void 0,installModel:!!Oe,model:Oe??(Le.catalog?.selected?$c(Le.catalog.selected):Le.catalog?.remembered??je?.model??Le.preview?.remembered??void 0),intent:a?`design`:c?`exit`:Ye?`message`:l?`enter`:`ordinary`});if(i){if(il(i,Ie.current)!==`ready`)throw Error(`stale`)}else await _(u.location);if(!f())return;if(u.command.kind===`cadence-exit`){let t=sl(u);tn.current=o,p=!0;let n=await Zc(e,t,g);if(!f())return;n.kind===`error`?h(n.error.code,n.error.effect):(Y(``),U(`chat`),ie(e=>e===o?``:e)),Ge.refresh(),X.refresh(),w();return}let d=e=>{let t=Ie.current,n=e??(t.status===`ready`?t.epoch:void 0);n&&il(nl(u,n),t)!==`cancel`?(Se.current=nl(u,n),_e(!0)):(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))),ze(!0)},m=await e.models(void 0,u.location);if(!f())return;if(u.preparedEpoch&&m.kind===`ok`&&m.value.version.epoch!==u.preparedEpoch)throw Error(`stale`);let v=m.kind===`ok`?m.value.selected??m.value.remembered:null;if(!u.model&&v&&(u=el(u,v)),u.installModel&&m.kind===`ok`){if(m={kind:`ok`,value:await ol(e,u,m.value,f)},!f())return;xe(e=>e+1)}let y=u.model??(m.kind===`ok`?m.value.remembered:null);if(m.kind===`ok`&&!m.value.selected&&y){let t=await e.workbenchCommand({kind:`restore-model`,commandId:crypto.randomUUID(),epoch:m.value.version.epoch,...u.location?{location:u.location,expected:m.value.version,choice:y}:{}});if(!f())return;if(t.kind===`error`){q(t.error.code),d(m.value.version.epoch);return}if(m=await e.models(void 0,u.location),!f())return;xe(e=>e+1)}if(m.kind!==`ok`||!m.value.selected){d(m.kind===`ok`?m.value.version.epoch:void 0);return}tl(u,m.value.selected);let b=sl(u,m.value.version);if(u.images.length){let t=m.value.selected;if(!m.value.entries.some(e=>e.provider===t?.provider&&e.model===t?.model&&e.images)){le(M(`The selected model does not support images. Choose a vision model or remove the images.`));return}if(b.kind===`cadence-exit`)throw Error(`invalid`);if(b=await fl(e,b,u.images,f),!f())return}F.current=u.images,tn.current=o,p=!0;let x=await Zc(e,b,g);if(!f())return;x.kind===`error`?h(x.error.code,x.error.effect):(ae(F.current),ke(null),ie(e=>e===tn.current?``:e),Y(``),b.kind===`cadence-send`&&U(`chat`),r||Fl(n,o),In(null)),Ge.refresh(),X.refresh(),w()}catch(e){if(f()){let t=e instanceof Error?e.message:`unavailable`,n=Yc(e),r=M(p?Xc():Jc(m,n),{code:t});!p&&(m===`not-dispatched`||n===`none`)?le(r):q(r)}}finally{we.current===d&&(Ce.current=!1),f()&&(G(!1),De(!1))}},Dn=(0,m.useRef)(En);Dn.current=En,(0,m.useEffect)(()=>{let e=Se.current;if(!e||!ve&&!he)return;let t=il(e,Fe);t===`cancel`?(Se.current=null,_e(!1),ye(!1),ps(`error`,M(`The connection changed. Your model choice and draft are kept; send again when ready.`),se)):ve&&t===`ready`&&dt&&!ft&&(ye(!1),Se.current=null,Dn.current(void 0,e))},[ve,he,dt,ft,Fe,M,se]),(0,m.useEffect)(()=>{if(!ve)return;let e=setTimeout(()=>{ye(!1),Se.current=null},1e4);return()=>clearTimeout(e)},[ve]);let On=ft?Q?.live:void 0,kn=(0,m.useRef)(new Map),An=Vc({images:P.files.length,modeChange:Ye?Ol(re):ut.mode===`cadence`,anchored:!!R,waiting:X.pending.length}),jn=!!On&&g&&!W&&!z,Mn=async r=>{if(!On||!jn||An||!re.trim())return;ce(),G(!0);let i=re,a=Hc(t,On,r,i),o=Gc(await e.workbenchCommand(a));I.current&&(G(!1),o.kind===`accepted`?(kn.current.set(a.commandId,i),Fl(n,i),ie(``)):o.kind===`refused`?le(M(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:S(M,o.code)})):q(o.code),X.refresh())},Nn=async(n,r)=>{if(!On||W)return;G(!0);let i=Gc(await e.workbenchCommand(Uc(t,On,n.commandId)));if(I.current){if(G(!1),i.kind===`accepted`){let e=kn.current.get(n.commandId)??n.text;kn.current.delete(n.commandId),r&&ie(t=>t.trim()?t:e)}else i.kind===`refused`?le(i.code===`conflict`?M(`That message has already been handed to the model and can no longer be withdrawn.`):M(`The message was not withdrawn ({reason}).`,{reason:S(M,i.code)})):q(i.code);X.refresh()}},Pn=e=>{ie(t=>t.trim()?`${t}\n${e}`:e),qt.current?.focus()},Fn=async()=>{let n=Q?.live;if(!n||W)return;G(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});I.current&&(r.kind===`error`&&q(r.error.code),G(!1),X.refresh())},In=(e,n)=>{++we.current,Te.current.abort(),Te.current=new AbortController,Se.current=null,Ce.current=!1,nt.current=!1,it(!1),ct(void 0),_e(!1),ye(!1),me(!1),G(!1),De(!1),B(),X.choose(e,n),Eo(t,e)},Ln=!ft&&!W&&!ue&&!he,Rn=()=>{ce(),qt.current?.focus()},zn=e=>{Ln&&e.header.entry&&(e.ordinal>=X.count-1?B():L.continueAfter(e),Rn())},Bn=e=>{if(!Ln)return;let t=Ue.find(t=>t.ordinal===e.ordinal-1);L.edit(e,t)?Rn():le(M(`This message cannot be rewritten from here: the entry it continued is not known.`))},Vn=(e,t)=>Pt({id:e,then:t});V.current={chooseBranch:In,followAnchor(){L.current()&&In(null)},show:Vn,stepVersion:(e,t)=>{let n=jt.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(In(r.leaf===Q?.leaf?null:r.leaf,Ue.find(t=>t.header.id===e)?.ordinal),Vn(r.id,`show`))}};let Hn=(0,m.useCallback)(e=>V.current.show(e,`continue`),[]),Un=(0,m.useCallback)(e=>V.current.show(e,`edit`),[]),Wn=(0,m.useCallback)((e,t)=>V.current.stepVersion(e,t),[]),Gn=(0,m.useCallback)(e=>V.current.show(e,`show`),[]);(0,m.useEffect)(()=>{if(!Nt)return;let e=Ue.find(e=>e.header.id===Nt.id);if(e){Pt(null),Nt.then===`edit`?Bn(e):Nt.then===`continue`&&zn(e),It({id:e.header.id});return}let t=e=>{Pt(null),le(e)};if(X.error)return Pt(null);if(!We||!Ue.length&&X.count>0)return;if(!kt.current){kt.error&&!kt.loading&&t(S(M,kt.error));return}let n=At?.nodes.find(e=>e.id===Nt.id);if(n&&!n.current&&!Nt.switched)return In(n.leaf===Q?.leaf?null:n.leaf),Pt({...Nt,switched:!0});let r=Ac(Mt,Nt.id,Ue,X.count,Ot);if(r===void 0||Ue.some(e=>e.ordinal===r))return t(M(`That message could not be found in this conversation.`));X.showFrom(r)});let Kn=W||he||!!ue||!!ft||z,qn=e=>{if(!Kn)try{P.add(e),ce()}catch(e){le(ne(e instanceof Error?e.message:`unavailable`))}},Jn=(0,m.useRef)(j);Jn.current=j;let Yn=(0,m.useMemo)(()=>({onShow:e=>V.current.show(e.id,`show`),onEdit:e=>V.current.show(e.id,`edit`),onContinue:e=>V.current.show(e.id,`continue`),onLatest:()=>V.current.chooseBranch(null)}),[]),{error:Xn,loading:Zn,refresh:Qn}=kt,{pinned:$n}=X;(0,m.useEffect)(()=>{Jn.current?.({id:t,tree:At,error:Xn,loading:Zn,pinned:$n,canAct:Ln,onRefresh:Qn,...Yn})},[t,At,Xn,Zn,$n,Ln,Qn,Yn]);let er=R!==null&&(Ue.some(e=>e.header.id===R.turnId)||Mt.some(e=>e.id===R.turnId))?R:null,nr=er?nn.find(({turn:e})=>zc(er,e.ordinal))?.id:void 0,rr=Lt===null?Mt.length-1:Mt.findIndex(e=>e.id===Lt),ir=R?(0,_.jsxs)(`div`,{className:`composer-anchor`,children:[R.kind===`edit`?(0,_.jsx)(xa,{"aria-hidden":`true`}):(0,_.jsx)(Ea,{"aria-hidden":`true`}),(0,_.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,_.jsx)(`strong`,{children:R.kind===`edit`?M(`Rewriting a message`):M(`Continuing after an earlier turn`)}),R.label&&(0,_.jsx)(`span`,{className:`composer-anchor-quote`,children:R.label}),(0,_.jsxs)(`span`,{children:[R.kind===`edit`?M(`Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.`):M(`Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.`),` `,M(`Only the conversation is rewound: files on disk stay as they are.`)]}),z&&(0,_.jsx)(`span`,{children:M(`Reading the message's images…`)}),R.media&&(0,_.jsx)(`span`,{children:M(`Attachments that were not retained are not attached again.`)})]}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,title:M(`Cancel and restore the draft that was here`),disabled:W||!!ue,onClick:()=>{B(),qt.current?.focus()},children:M(`Cancel`)})]}):$n&&!ft?(0,_.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,_.jsx)(ha,{"aria-hidden":`true`}),(0,_.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,_.jsx)(`span`,{children:M(`A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.`)})})]}):void 0;return(0,_.jsxs)(`section`,{className:`chat-workspace`,hidden:O,"aria-label":M(Ze?Ye?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),(0,_.jsx)(`h2`,{children:Q?.title??(a?M(`Discovered session`):X.summary===null?M(`New conversation`):M(`Conversation`))})]}),(0,_.jsxs)(`div`,{className:`conversation-branch`,children:[(0,_.jsxs)(`span`,{className:`conversation-meta`,children:[M(Ze?Ye?`Cadence on`:`Ordinary`:`Cadence state unavailable`),Q&&` · ${Q.origin===`terminal`?M(`Started in the terminal`):M(`Started in the WebUI`)}`]}),Q?.archived&&(0,_.jsx)(`span`,{className:`conversation-badge`,children:M(`Archived`)}),te&&(X.branches>1||$n)&&(0,_.jsxs)(`button`,{type:`button`,className:`ghost`,"aria-label":M(`Branches ({count})`,{count:X.branches}),title:M(`Branches ({count})`,{count:X.branches}),onClick:te,children:[(0,_.jsx)(ha,{"aria-hidden":`true`}),X.branches]}),$n&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>In(null),children:M(`Show the latest`)}),Ye&&!ft&&!pt&&!!Z?.proposal&&(0,_.jsx)(`span`,{className:`ep-state`,children:M(`Awaiting plan approval`)})]})]}),Ae.error&&!zt&&(0,_.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:S(M,Ae.error)}),zt&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:M(`Conversation context is unavailable. Send can prepare execution, but cannot submit this draft until the context is observed.`)}),Ee&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:M(`Preparing execution for this Send…`)}),(0,_.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,_.jsxs)(`div`,{className:`chat-messages`,ref:Jt,onScroll:()=>{let e=Jt.current;e&&!O&&(Yt.current=e.scrollTop,Xt.current=Nd(e),Qt(!Xt.current),sn(),ln())},children:[a&&!X.summary&&(0,_.jsx)(`p`,{role:`status`,className:`panel-hint`,children:M(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!h&&(0,_.jsx)(`p`,{role:`status`,className:`panel-hint`,children:M(`Conversation content has not been read. You can keep a draft; nothing is sent until the context is available.`)}),X.summary===null&&!X.error&&!a&&(0,_.jsx)(ad,{hint:M(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),h&&!X.error&&(!We||Ue.length===0&&X.count>0)&&(0,_.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:M(`Reading this conversation…`)}),Ue.length>0&&an&&(0,_.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:X.loadingEarlier&&M(`Reading earlier messages…`)}),bn.start.map(Sn),nn.map(({id:e,version:t,turn:n},r)=>{let i=jt.get(e);return(0,_.jsxs)(m.Fragment,{children:[e===nr&&(0,_.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,_.jsx)(ha,{"aria-hidden":`true`}),M(`From here on, the turns stay on their branch: the message being written will not have them in its context.`)]}),(0,_.jsx)(ic,{id:e,show:!rn.hidden.has(e)||e===Ft?.id,height:rn.placeholder(e,t,320),containerRef:Jt,onMeasured:rn.recordMeasured,lazyRef:rn.register(e),children:(0,_.jsx)(id,{turn:n,onContinue:Ln&&n.header.entry&&n.ordinal<X.count-1?Hn:void 0,onEdit:Ln&&Lc(n,nn[r-1]?.turn)!==void 0?Un:void 0,version:i?i.findIndex(t=>t.id===e)+1:0,versions:i?.length??0,onVersion:Wn,off:zc(er,n.ordinal)})}),bn.after.get(e)?.map(Sn)]},n.renderId??n.header.id)}),bn.end.map(Sn),X.attempt&&(0,_.jsxs)(`article`,{className:`chat-attempt`,"aria-label":M(`Message`),children:[(0,_.jsx)(`p`,{className:`chat-attempt-text`,children:X.attempt.text}),(0,_.jsxs)(`p`,{className:`inspector-note`,children:[(0,_.jsx)(`span`,{className:`ep-state ${X.attempt.status}`,children:ne(X.attempt.status)}),` `,X.attempt.notice?ne(X.attempt.notice):``]})]}),(0,_.jsx)(fd,{pending:X.pending,undelivered:X.undelivered,canWithdraw:!!On&&g&&!W,recallable:e=>kn.current.has(e.commandId)||Wc(e.text),onWithdraw:(e,t)=>void Nn(e,t),onRestore:Pn}),$e&&(0,_.jsx)(`p`,{role:`status`,children:M(`Observing approval request {id}; no approval is replayed.`,{id:$e})}),Z?.enabled&&Z.design&&(0,_.jsx)(od,{draft:Z.design,disabled:W||ft||!dt||!Ze||!!$e,onEdit:Tn,onSubmit:e=>void En(tr(e,16384),void 0,!0)},Z.design.id),Z?.enabled&&Z.proposal&&(0,_.jsx)(xd,{proposal:Z.proposal,canApprove:!Vt&&l&&dt&&Ze&&Ht&&!ft&&!$e&&!Wt&&Ut===`approve`,action:Ut,canValidate:Gt,validating:rt,previous:st?.after.proposal?.id===Z.proposal.id?st.before:void 0,approvalHint:Kt,onValidate:()=>void Cn(),onApprove:()=>void wn()}),Z?.enabled&&!Z.proposal&&fn.length===0&&(0,_.jsx)(`p`,{className:`inspector-note`,children:M(`Cadence stays on for this conversation until you explicitly exit.`)}),_n.failed&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`status`,children:M(`Workflow activity unavailable; retained work may still be running.`)}),Z?.notice&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:ne(Z.notice)}),[...new Set([K,X.error,Ge.error])].filter(Boolean).map(e=>(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:S(M,e??``)},e)),X.error&&X.summary!==void 0&&(0,_.jsx)(`p`,{role:`status`,className:`inspector-note`,children:M(`Conversation state is not current. Previously read content may be shown; this does not mean work has stopped.`)}),ue&&(0,_.jsxs)(`p`,{className:`inspector-note`,children:[M(`Send outcome not yet observed:`),` `,(0,_.jsx)(`code`,{children:ue}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:X.refresh,children:M(`Observe current state`)})]})]}),Zt&&(0,_.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{Xt.current=!0,Pd(Jt.current,!0),Qt(!1)},children:[(0,_.jsx)(Ba,{"aria-hidden":`true`}),M(`Latest messages`)]}),Nt&&(0,_.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:M(`Reading earlier messages…`)}),Mt.length>1&&(0,_.jsx)(cd,{questions:Mt,active:rr,reading:Nt?.id??null,onJump:Gn})]}),(0,_.jsx)(xu,{inputRef:qt,draft:re,onDraft:ie,locked:W||!!ue||he,images:P.files,imageKey:P.key,imagesLocked:Kn,onAddImages:qn,onRemoveImage:e=>ae([e]),anchor:ir,status:On&&re.trim()&&An?M(An===`images`?`A message into a running reply carries no images. Remove them, or send after the reply ends.`:An===`mode`?`Cadence mode is not changed by a message into a running reply. Send this after the reply ends.`:An===`full`?`Eight messages already wait for this reply. Withdraw one, or wait.`:`A message into a running reply continues that reply, not another entry.`):ft||zt||dt||Ee?void 0:M(ue?`The last Send is not yet confirmed. No message is resent.`:he?`Choose a model; your message is sent right after.`:W?`Sending…`:`Sending is unavailable until the current context is observed. Your draft stays here.`),cadence:{active:Ye,armed:ut.mode===`cadence`,known:Ze,disabled:Ye?!Bt:!!ft||W||!!ue||he,onClick:()=>{Ye?En(`exit cadence`):ut.mode===`cadence`?(U(`chat`),ko(re,`chat`).mode===`cadence`&&ie(ut.text)):U(`cadence`)}},model:{client:Pe,availability:Fe,read:Le,lastModel:je?.model,draftModel:Oe,onPreviewChoice:y?e=>Be(e,!1):void 0,locked:!!ft||W||!!ue,open:pe,onOpenChange:ze,onChanged:()=>{Ae.refresh(),C()},onChosen:e=>Be(e,!0),awaitingSend:he},hint:On&&jn&&!An&&re.trim()?M(`Enter steers this reply · Alt+Enter queues behind it`):Ye?M(`Cadence stays on. Confirm one plan before implementation.`):ut.mode===`cadence`?M(`Your next message turns on Cadence mode.`):``,running:!!ft,canStop:!W&&g,onStop:()=>void Fn(),canSend:((Ye&&Ol(re)?Bt:dt)||zt)&&!z&&(!!re.trim()||P.files.length>0),onSend:()=>void En(),input:On?{enabled:jn&&!An&&!!re.trim(),onInput:e=>void Mn(e)}:void 0,historyScope:n,files:{client:e,location:h&&Me&&je?{id:t,cwd:je.cwd}:void 0},onResized:$t})]})}function Ld(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}async function Rd(e){let t=[],n=0,r=0,i=``;for(;;){let a=await e(n);if(a.kind!==`file-part`)throw Error(`invalid`);if(n===0)({size:r,version:i}=a);else if(a.size!==r||a.version!==i)throw Error(`stale`);let o=Ld(a.data),s=n+o.length;if(a.next===null?s!==r:a.next!==s||o.length!==196608)throw Error(`invalid`);if(t.push(o),a.next===null)break;n=a.next}return new Blob(t,{type:`application/octet-stream`})}var zd=/[<>:"/\\|?*\u0000-\u001f]/g,Bd=/[. ]+$/,Vd=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Hd(e){let t=e.replace(zd,`_`).replace(Bd,``);return t?Vd.test(t)?`_${t}`:t:`_`}function Ud(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4)}async function Wd(e,t){let n=/windows/i.test(navigator.userAgent)?Hd(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return Ud(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(Ud(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Gd(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
27
28
|
`)?``:`
|
|
28
|
-
`}${r}`}var
|
|
29
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function
|
|
30
|
-
`);return(0,m.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(p.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=
|
|
31
|
-
`):e})]}),(0,_.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,_.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,_.jsxs)(`div`,{className:`fp-toc-layout`,children:[Hd(c)&&(0,_.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,_.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,children:(0,_.jsx)(fs,{text:e})})]}):n===`diff`?(0,_.jsx)(Wd,{text:e}):(0,_.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Ud(e).map(({text:e,number:n,key:r})=>(0,_.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,_.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(f.current=n),d({start:Math.min(f.current,n),end:Math.max(f.current,n)})},children:n}),(0,_.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,_.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Kd({client:e,seed:t}){let{t:n,tx:r}=D(),i=Ro(e,t),[a,o]=(0,m.useState)(),s=i.page;return(0,_.jsxs)(`section`,{className:`scm-body`,children:[(0,_.jsx)(Cs,{pager:i}),(0,_.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,_.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,_.jsxs)(`article`,{className:`scm-file`,children:[(0,_.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,_.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(Io(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,_.jsx)(Ss,{client:e,cursor:a,render:e=>(0,_.jsx)(Gd,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var qd=[`contents`,`checks`,`changes`,`reviews`];function Jd({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(`contents`);return(0,_.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,_.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,_.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:qd.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,_.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,_.jsx)(ws,{client:e,seed:t}):(0,_.jsx)(Kd,{client:e,seed:{...t,reader:i}},i)})]})}var Yd={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.`},Xd=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Zd(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 Qd({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=D(),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(n??t),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(!0),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!1),[O,k]=(0,m.useState)(null),A=(0,m.useRef)(!0),ee=(0,m.useRef)(void 0),j=(0,m.useRef)(n??t),te=(0,m.useRef)(null),M=(0,m.useRef)(null),ne=async t=>{ee.current?.abort();let n=new AbortController;ee.current=n,x(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&A.current){if(ee.current=void 0,x(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),p(r.value.path),g(!1),y(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,m.useRef)(ne);(0,m.useEffect)(()=>(A.current=!0,N.current(j.current).then(()=>{A.current&&w(!1)}),()=>{A.current=!1,ee.current?.abort()}),[]),(0,m.useEffect)(()=>{h&&te.current?.select()},[h]),(0,m.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let re=e=>{T||ne(e)},ie=()=>{let e=f.trim();T||(Xd(e)?ne(e):k({step:`read`,code:`relative`}))},P=(h||!u)&&f.trim()||u?.path||``,ae=!T&&!b&&!!P,F=async n=>{if(T||!n||b&&n===u?.path)return;if(n!==u?.path&&!Xd(n)){k({step:`read`,code:`relative`});return}E(!0),k(null);let r=n===u?.path?u.path:(await ne(n))?.path;if(!A.current)return;if(!r){E(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),A.current&&a()}catch(e){A.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),E(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),E(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(A.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),E(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),E(!1)}},oe=u?Zd(u.path,r):void 0,I=v.trim().toLowerCase(),L=u?.entries.filter(e=>e.name.toLowerCase().includes(I))??[],R=O&&(O.step===`read`&&Yd[O.code]?l(Yd[O.code]):S(l,O.code));return(0,_.jsxs)(Os,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,_.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,_.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,_.jsx)(`h3`,{children:l(`Recent folders`)}),(0,_.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,_.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:T,onClick:()=>e.current?a():void F(e.path),children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,_.jsxs)(`div`,{className:`cwd-location`,children:[oe&&!h?(0,_.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:T,onClick:()=>re(`~`),children:[(0,_.jsx)(ea,{"aria-hidden":`true`}),oe.inside&&(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),oe.trail.map((e,t)=>(0,_.jsxs)(m.Fragment,{children:[(t>0||oe.inside)&&(0,_.jsx)(ba,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,_.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:T,onClick:()=>re(e.path),children:e.name})]},e.path))]}):C?(0,_.jsx)(`div`,{className:`cwd-crumbs`}):(0,_.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),ie()},children:(0,_.jsx)(`input`,{ref:te,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:f,disabled:T,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{p(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),g(!1),p(u.path),k(null))}})}),u&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":h,disabled:T,onClick:()=>{p(u.path),g(!h),k(null)},children:(0,_.jsx)(la,{"aria-hidden":`true`})})]}),u&&(0,_.jsxs)(`label`,{className:`cwd-filter`,children:[(0,_.jsx)(Ii,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:v,disabled:T,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,_.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":b||void 0,children:[b&&(0,_.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,_.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>re(u.parent),children:[(0,_.jsx)(Ta,{}),l(`Parent folder`)]}),L.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>re(e.path),children:[(0,_.jsx)(ia,{}),(0,_.jsx)(`span`,{children:e.name})]},e.path)),u&&!b&&L.length===0&&(0,_.jsx)(`p`,{className:`cwd-picker-note`,children:l(I?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,_.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),R&&(0,_.jsxs)(`p`,{role:`alert`,children:[R,O?.code===`registry-locked`&&(0,_.jsxs)(_.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,_.jsxs)(`footer`,{className:`cwd-footer`,children:[P&&(0,_.jsxs)(`p`,{className:`cwd-target`,children:[(0,_.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,_.jsx)(`code`,{children:P})]}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ae,onClick:()=>void F(P),children:l(T?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function $d(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var ef=[`today`,`yesterday`,`earlier`];function tf(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function nf(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=tf(t(i),n);r.set(e,[...r.get(e)??[],i])}return ef.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function rf(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function af(e,t,n=Date.now()){let r=new Date(e);return tf(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function of({onConversation:e,disabled:t=!1}){let{t:n}=D();return(0,_.jsx)(`div`,{className:`lp-new`,children:(0,_.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,_.jsx)(zi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function sf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var cf=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),lf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function uf(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var df={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},ff={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},pf={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},mf=e=>`conversation-row:${e}`;function hf(e,t){return t.kind===`refused`?{refusal:{text:ff[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function gf(e,t){let{t:n}=D(),[r,i]=(0,m.useState)(()=>new Map),a=(0,m.useRef)(!0);(0,m.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});rs(mf(c)),l({pending:o}),uf(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=hf(o,e);l(r),i&&ts(`error`,n(i.text,{code:i.code}),mf(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,cf(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,lf(e,t))}}function _f({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=D(),d=u===`zh`?`zh-CN`:`en-GB`,[f,p]=(0,m.useState)(null),h=f!==null,g=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let e=g.current;if(!h||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,p(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[h]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,_.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,_.jsx)(Ai,{"aria-hidden":`true`}):(0,_.jsx)(Gi,{"aria-hidden":`true`})}),S=()=>{if(f===null)return;let t=sf(f);t===null?ts(`error`,l(`A name can have at most {count} characters.`,{count:100}),mf(e.id)):(y.current=!0,p(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(df[a.pending]):a?.unknown?l(pf[a.unknown.action],{code:a.unknown.code}):``;return h?(0,_.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},children:[(0,_.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,_.jsx)(`input`,{ref:g,className:`session-rename-input`,value:f,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>p(e.target.value)})]}),(0,_.jsxs)(`span`,{className:`session-actions`,children:[(0,_.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,_.jsx)(Ca,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,p(null)},children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]})]}):(0,_.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,_.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,_.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:af(e.updatedAt,d)})]}),c&&(0,_.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,_.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>p(e.title),children:(0,_.jsx)(la,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,_.jsx)(Li,{"aria-hidden":`true`}):(0,_.jsx)(ka,{"aria-hidden":`true`})})]}),w&&(0,_.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function vf({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=D(),a=e.value?.entries??[];return(0,_.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,_.jsx)(Da,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,_.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,_.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,_.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,S(i,e.error)]}),e.loading&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,_.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,_.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,_.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,_.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var yf={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function bf({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,m.useState)(!0);return(0,_.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,_.jsxs)(`header`,{className:`lp-section-header`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,_.jsx)(Sa,{"aria-hidden":`true`}):(0,_.jsx)(ba,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,_.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,_.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,_.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function xf({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=D(),[o,s]=(0,m.useState)(new Set),c=$d(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,_.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,_.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,_.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,_.jsx)(ba,{"aria-hidden":`true`}):(0,_.jsx)(Sa,{"aria-hidden":`true`})}):(0,_.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,_.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,_.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,_.jsx)(fa,{"aria-hidden":`true`}):(0,_.jsx)(Gi,{"aria-hidden":`true`})}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,_.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,_.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,_.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Sf({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=D(),a=e.page;return(0,_.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(xf,{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,_.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,_.jsx)(Cs,{pager:e,compact:!0})]})}function Cf({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,canCancel:c,canceling:l,onCancel:u,onTask:d,onScope:f,chats:p=[],chatActivityKnown:h=!0,chatHistoryPartial:g=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:T=[],workflowError:E=!1,discovery:O,selectedWorkflow:k,onWorkflow:A,onCancelWorkflow:ee}){let{t:j,tx:te}=D(),[M,ne]=(0,m.useState)(``),[N,re]=(0,m.useState)(!1),ie=vo(e,N,!0),P=ie.refresh,ae=gf(e,e=>{P(),C?.(e)}),F=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,oe=Ro(e,F),I=Ro(e,r&&F&&t?{...F,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),L=oe.page&&!(`kind`in oe.page)?oe.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],R=s?.status===`complete`?s.runs:[],z=L.filter(e=>!R.some(t=>t.taskId===e.owner.taskId)),B=r&&(0,_.jsxs)(`section`,{className:`task-conversations`,"aria-label":j(`Task conversations`),children:[(0,_.jsx)(`h3`,{children:j(`Task conversations`)}),(0,_.jsx)(Sf,{pager:I,scope:i,onScope:f,exclude:R.map(e=>e.runId)},r)]}),[V,H]=(0,m.useState)(()=>new Set),U=e=>{let t=T.find(t=>t.runId===e.id)?.conversationId??null;return(0,_.jsxs)(`div`,{className:`conversation-group`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>A?.(e,t),title:e.goal,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[j(`Cadence workflow`),` · `,te(e.phase),` · `,te(e.status)]})]})]}),ee&&(0,_.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:V.has(e.id),onClick:()=>{H(t=>new Set(t).add(e.id)),ee(e).finally(()=>H(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,_.jsx)(Mi,{"aria-hidden":`true`}),j(`Cancel workflow — request stop`)]})]},e.id)},W=p.filter(e=>e.status===`running`||e.status===`queued`),G=p.filter(e=>!W.includes(e)),K=e=>w?.findLast(t=>T.some(n=>n.runId===t.id&&n.conversationId===e.id)),q=e=>{let t=e.status===`running`||e.status===`queued`,n=t||e.status===`completed`?K(e):void 0,r=n?te(rd(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,_.jsx)(_f,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:ae.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>ae.archive(e.id,t),onRename:t||e.archived?void 0:t=>ae.rename(e.id,t)},e.id)},se=G.filter(e=>rf(e.title,M)),ce=z.filter(e=>rf(e.goal,M));return(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,_.jsx)($s,{...O,represented:!n&&O.project?[...(w??[]).map(e=>Qs(O.project,`workflow`,e.id,e.epoch)),...W.flatMap(e=>e.live?[Qs(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,_.jsx)(of,{onConversation:x}),!n&&(0,_.jsxs)(bf,{title:j(`Running work`),count:s?.status===`complete`&&w&&!E&&h?String(R.length+W.length+w.length):j(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Active roster unavailable; absence is not proof of settlement.`)}),E&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),!h&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Conversation activity unavailable.`)}),W.map(q),w?.map(U),s?.status===`complete`&&R.length===0&&W.length===0&&w?.length===0&&!E&&h&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`No active runs`)}),R.map(e=>{let t=L.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,_.jsxs)(`div`,{className:`conversation-group`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:t??j(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[te(e.kind),` · `,te(e.stage)]})]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,_.jsx)(Mi,{"aria-hidden":`true`}),j(`Cancel run — request stop`)]}),r===e.taskId&&(0,_.jsx)(xf,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:f})]},e.runId)})]}),(0,_.jsxs)(bf,{title:j(N?`Archived conversations`:`Conversation history`),count:N?ie.value?`${ie.value.entries.length}${ie.value.next||ie.canPrevious?`+`:``}`:j(`Not observed`):t?oe.page&&!(`kind`in oe.page)?`${G.length+z.length}${oe.page.next||oe.canPrevious||g?`+`:``}`:j(`Not observed`):`${G.length}${g?`+`:``}`,className:`grow`,actions:(0,_.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":N,title:j(N?`Back to history`:`Show archived`),"aria-label":j(N?`Back to history`:`Show archived`),onClick:()=>re(e=>!e),children:(0,_.jsx)(ka,{"aria-hidden":`true`})}),children:[N&&(0,_.jsx)(vf,{list:ie,unavailable:S,onBack:()=>re(!1),row:q}),(0,_.jsxs)(`nav`,{"aria-label":j(`Tasks`),className:`task-list`,hidden:N,children:[(G.length>0||z.length>0)&&(0,_.jsxs)(`label`,{className:`lp-filter`,children:[(0,_.jsx)(Ii,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{type:`search`,value:M,placeholder:j(`Filter conversations…`),"aria-label":j(`Filter conversations…`),onChange:e=>ne(e.target.value)}),M&&(0,_.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:j(`Clear filter`),"aria-label":j(`Clear filter`),onClick:()=>ne(``),children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]}),S&&G.length>0&&(0,_.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),nf(se,e=>e.updatedAt).map(e=>(0,_.jsxs)(`div`,{className:`lp-time-group`,children:[(0,_.jsx)(`h3`,{className:`lp-time-label`,children:j(yf[e.key])}),e.items.map(q)]},e.key)),ce.length>0&&(0,_.jsx)(`h3`,{className:`lp-time-label`,children:j(`Tasks`)}),ce.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,_.jsx)(`span`,{className:`session-icon`,children:(0,_.jsx)(Gi,{"aria-hidden":`true`})}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,_.jsx)(`span`,{className:`session-sub`,children:j(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&B]},e.owner.taskId)),se.length===0&&ce.length===0&&(G.length>0||z.length>0)&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`No listed conversation matches. Pages not loaded are not searched.`)}),oe.page&&!(`kind`in oe.page)&&z.length===0&&G.length===0&&!g&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`No conversations yet.`)}),v,t&&(0,_.jsx)(Cs,{pager:oe,compact:!0})]}),!N&&!ce.some(e=>e.owner.taskId===r)&&B]})]})}var wf=[`queued`,`running`];function Tf(e){let t=(0,m.useRef)({client:e.client,generation:0});return t.current.client!==e.client&&(t.current={client:e.client,generation:t.current.generation+1}),(0,_.jsx)(Ef,{...e},`${t.current.generation}:${e.agent.runId}:${e.agent.stepId??``}`)}function Ef({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=D(),[s,c]=(0,m.useState)(1e3),l=go(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,f=d?wf.includes(d.status):!1;(0,m.useEffect)(()=>{u&&!wf.includes(u.status)&&c(0)},[u]);let p=go(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,f||!u?1e3:0),h=p.value?.kind===`workflow-transcript`?p.value.turn:null,g=(0,m.useMemo)(()=>h?bu(h):null,[h]),[v,y]=(0,m.useState)(!1),b=go(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null,v&&f?1e3:0),x=(0,m.useRef)(null),S=(0,m.useRef)(!0),C=(0,m.useRef)(null);return Gs(x,C,S),(0,m.useEffect)(()=>{g&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[g]),(0,_.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,_.jsx)(fa,{"aria-hidden":`true`}),(0,_.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,_.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,_.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,_.jsx)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:(0,_.jsxs)(`div`,{ref:C,children:[l.error&&(0,_.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,_.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,_.jsx)(ud,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&p.error&&(0,_.jsx)(`p`,{role:`alert`,children:p.error}),t.stepId&&(g?(0,_.jsx)(Ku,{turn:g}):(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,_.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,_.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,_.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,_.jsx)(fs,{text:d.text}):(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,_.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,"aria-expanded":v,onClick:()=>y(e=>!e),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,_.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,_.jsx)(`p`,{role:`alert`,children:b.error})]})]})})]})}function Df({path:e,disabled:t=!1,onClick:n}){let{t:r}=D(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,_.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Of({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=D(),o=r||t||n;return!e&&!o?null:(0,_.jsxs)(_.Fragment,{children:[e&&(0,_.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,_.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,_.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,_.jsxs)(`p`,{role:`status`,children:[(0,_.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,_.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,_.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,_.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,_.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function kf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=co();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:K(e)});if(n&&(a.set(`scope`,JSON.stringify(ze(n.scope))),n.snapshotSeq&&a.set(`snapshot`,se(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Af(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=K(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?ze(ue(r)):void 0,o=i?se(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=Ve(ue(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var jf=`cadence-panel-layout-v1`,Mf={left:260,right:360,navigation:!0,inspector:!1};function Nf(e,t=600){return Math.max(220,Math.min(t,e))}function Pf(e){let t={...Mf};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Nf(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Ff(e,t){let n=e<=900,r=Nf(t.left,e-560),i=Nf(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Nf(e-560-s),rightMaximum:Nf(e-560-a)}}function If({side:e,width:t,onResize:n,maximum:r}){let{t:i}=D(),a=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>a.current?.(),[]),(0,_.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Nf(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Nf(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Nf(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var Lf=[],Rf={error:ja,warning:Aa,info:Qi};function zf({toast:e}){let{t}=D(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=n||i,s=Jo(e.level);(0,m.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>ns(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Rf[e.level];return(0,_.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,_.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,_.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>ns(e.id),children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]})}function Bf(){let e=(0,m.useSyncExternalStore)(is,as,()=>Lf);return(0,_.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,_.jsx)(zf,{toast:e},e.id))})}function Vf(e,t,n,r){(0,m.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 Hf=.4,Uf=1.05;function Wf(e){return Math.min(300,e*.86)}function Gf(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Kf(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function qf(e,t){return e===`left`?t:-t}function Jf(e,t){return Math.max(-e,Math.min(0,-e+t))}function Yf(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Xf(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Yf(r*Uf,n,t)>=Hf}var Zf=new Set([`auto`,`scroll`,`overlay`]);function Qf(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Zf.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function $f(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function ep(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,m.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=Gf(r.clientX,window.innerWidth,n);i&&!Qf(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=Kf(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Wf(window.innerWidth),h=m*Uf;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=qf(r,d);let b=Jf(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Yf(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Xf({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&($f(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var tp={system:[Hi,`System`],light:[ji,`Light`],dark:[Vi,`Dark`]};function np({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:f,content:p}){let{t:h,locale:g,setLocale:v}=D(),[y,b]=(0,m.useState)(M),[x,S]=tp[y],w=h(`Theme: {current}. Switch to {next}.`,{current:h(S),next:h(tp[N(y)][1])}),{mobile:T,overlay:E,closeDrawer:O}=e,k=(0,m.useRef)(null),A=(0,m.useRef)(null),ee=()=>{A.current&&(A.current.open=!1)};return ep({enabled:T,open:E,onOpenChange:e.setDrawer,container:k}),Vf(k,E,!!E,O),(0,_.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,_.jsxs)(`header`,{className:`topbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":h(`Toggle conversation navigation`),"aria-expanded":T?E===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,_.jsx)(Ki,{"aria-hidden":`true`})}),(0,_.jsxs)(`div`,{className:`topbar-flow`,children:[(0,_.jsxs)(`span`,{className:`brand`,children:[(0,_.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,_.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,_.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,_.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,_.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(g===`zh`?`en`:`zh`),children:[(0,_.jsx)(na,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,_.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":w,"data-tip":w,onClick:()=>{let e=N(y);ne(e),b(e)},children:(0,_.jsx)(x,{"aria-hidden":`true`})}),(0,_.jsxs)(`details`,{className:`more-menu`,ref:A,onKeyDown:e=>{e.key===`Escape`&&A.current&&(A.current.open=!1,A.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,_.jsx)(`summary`,{className:`chip`,"aria-label":h(`More`),title:h(`More`),children:(0,_.jsx)(Bi,{"aria-hidden":`true`})}),(0,_.jsxs)(`div`,{className:`more-menu-items`,children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Observe current state`),onClick:()=>{ee(),u()},children:[(0,_.jsx)(Ri,{"aria-hidden":`true`}),h(`Refresh status`)]}),f&&(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Cadence service`),onClick:()=>{ee(),f()},children:[(0,_.jsx)(Fi,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`more-menu-text`,children:[h(`Cadence service`),(0,_.jsx)(`small`,{children:h(`Version, restart and upgrade.`)})]})]}),d&&(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Disconnect this page`),title:h(`Return — accepted work continues`),onClick:()=>{ee(),O(),d()},children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`more-menu-text`,children:[h(`Disconnect this page`),(0,_.jsx)(`small`,{children:h(`Started work keeps running.`)})]})]}),(0,_.jsx)(`div`,{className:`more-menu-build`,title:Ya?.buildId??h(`unbuilt source`),children:(0,_.jsx)(C,{text:h(`Local browser build: {build}.`),slots:{build:(0,_.jsx)(`code`,{children:Ya?.buildId??h(`unbuilt source`)})}})})]})]})]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":h(`Toggle workspace panels`),"aria-expanded":T?E===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,_.jsx)(Pi,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:r??h(`Files`)})]})]}),s,(0,_.jsxs)(`div`,{ref:k,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,_.jsx)(`button`,{type:`button`,"aria-label":h(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${E?` on`:``}`,onClick:O}),(0,_.jsx)(`section`,{className:`panel-drawer drawer-left${E===`left`?` open`:``}`,"aria-label":h(`Conversation navigation`),tabIndex:-1,inert:T?E!==`left`:!e.navigation||E===`right`,children:t}),(0,_.jsx)(If,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,_.jsx)(`main`,{className:`main`,inert:E!==null,children:p}),(0,_.jsx)(If,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,_.jsx)(`section`,{className:`panel-drawer drawer-right${E===`right`?` open`:``}`,"aria-label":h(`Files and history drawer`),tabIndex:-1,inert:T?E!==`right`:!e.inspector,children:(0,_.jsxs)(`div`,{className:`workbench-right`,children:[(0,_.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":h(`Workspace panels`),children:[i??(0,_.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),h(`Files`)]}),(0,_.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":h(`Collapse panel`),title:h(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,_.jsx)(ba,{"aria-hidden":`true`})})]}),n]})})]}),(0,_.jsxs)(`footer`,{className:`statusbar`,children:[(0,_.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,_.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,_.jsx)(Bf,{})]})}function rp(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function ip({cache:e}){let{t}=D(),n=e?rp(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:Sc(r.read),write:Sc(r.write),miss:Sc(r.miss),input:Sc(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,_.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,_.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,_.jsx)(da,{})}),(0,_.jsxs)(`span`,{className:`bar-item-text`,children:[(0,_.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,_.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var ap=31.42;function op({usage:e}){let{t}=D(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?Cc(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:Sc(n),window:Sc(r),percent:i}):t(`Context {used} tokens`,{used:Sc(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,_.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,_.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,_.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:ap,strokeDashoffset:+(ap*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,_.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,_.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,_.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`ctx-val`,children:Sc(n)}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,_.jsx)(`span`,{className:`ctx-max`,children:Sc(r)})]})]})})]})}function sp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,_.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,_.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,_.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,_.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function cp({dot:e,tip:t,latency:n,children:r}){let{t:i}=D(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,_.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,_.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,_.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function lp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function up({since:e,label:t}){let[n,r]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?lp(n-e):``;return(0,_.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,_.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,_.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function dp(){let[e,t]=(0,m.useState)(()=>{try{return Pf(localStorage.getItem(jf))}catch{return Pf(null)}}),[n,r]=(0,m.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,m.useState)(null);(0,m.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=Ff(n,e),s=(0,m.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(jf,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,m.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}function fp(e,t,n,r,i=`en`){let a=(e,t)=>b(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`)} · ${b(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 pp=`modulepreload`,mp=function(e){return`/`+e},hp={},gp=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=mp(t,n),t=s(t),t in hp)return;hp[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`:pp,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 _p({client:e,seed:t,onSearch:n}){let{t:r}=D(),i=Ro(e,{...t,reader:`events`}),a=i.page;return(0,_.jsxs)(`section`,{className:`timeline-view`,children:[(0,_.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,_.jsx)(Cs,{pager:i}),a&&!(`kind`in a)&&(0,_.jsx)(vp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function vp({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=D(),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(r);return d.current=r,(0,m.useEffect)(()=>{let e=!1,r;return gp(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,fp(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,_.jsxs)(_.Fragment,{children:[l&&(0,_.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,_.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,_.jsx)(ws,{client:e,seed:t})]})}var yp=[[`tools`,ki],[`context`,Zi],[`timeline`,_a],[`runs`,ra]];function bp({api:e,onOpenProject:t,homeFolder:n,projectEntries:r,notices:i,discovery:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareExecution:l,directoryNamespaces:u,previewModels:d,initialDraft:f,onDraftApplied:p}){let{t:h,tx:g}=D(),[v]=(0,m.useState)(()=>e??Xa()),[y,b]=(0,m.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,m.useState)(!1),[C]=(0,m.useState)(Af),[w,T]=(0,m.useState)(C?.taskId??null),[E,O]=(0,m.useState)(()=>C?null:lo()??crypto.randomUUID()),k=fo(y,E??``),[A,ee]=(0,m.useState)(null),[j,te]=(0,m.useState)([]),[M,ne]=(0,m.useState)(null),[N,re]=(0,m.useState)(C?`task`:`files`),[ie,P]=(0,m.useState)(),[ae,F]=(0,m.useState)(),[oe,I]=(0,m.useState)(),[L,R]=(0,m.useState)(),[z,B]=(0,m.useState)(0),[V,H]=(0,m.useState)(()=>{let e=typeof history>`u`?null:history.state,t=lo();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[U]=(0,m.useState)(()=>crypto.randomUUID()),W=(0,m.useCallback)(()=>F(void 0),[]),[G,K]=(0,m.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),q=Oo(s?.id,s?.epoch),se=!s||q.readiness===`running`,ce=!!s&&(q.readiness===`stopped`||q.readiness===`not-started`),le=(0,m.useRef)(null);se&&q.value?.epoch&&(le.current=q.value.epoch);let ue=!s||!ce&&(se||le.current!==null),Y=jo(v,w?{kind:`task`,id:w}:null,!x&&ue,le.current),de=(0,m.useRef)(!0);(Y.workspace||Y.observation||Y.error||Y.transportStatus===`stale`)&&(de.current=!1);let fe=!!(s&&(q.value||q.error)),pe=!x&&!!(Y.workspace||fe),me=(0,m.useRef)(null);(Y.workspace||q.value?.workspaceId)&&(me.current=Y.workspace?.workspaceId??q.value?.workspaceId??null);let he=e=>l?async(t,n,r)=>{let i=await l(e,t,n,r);if(t.aborted)throw Error(`stale`);q.prepared(i);let a=Y.reconnect();await Y.whenReady(i,t,a)}:void 0,ge=he(`send`),_e=he(`plan-validation`),ve=vo(v.client,pe),ye=go(v.client,Y.workspace&&!x?{kind:`conversation-active`}:null,1e3),be=ye.value?.kind===`conversation-active`?ye.value.entries:[],xe=[...be,...(ve.value?.entries??[]).filter(e=>!be.some(t=>t.id===e.id))],Se=go(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),Ce=Se.value?.kind===`workflow-active`?Se.value:void 0,we=(0,m.useMemo)(()=>[...new Set([...Ce?.runs.map(e=>e.id)??[],...j])],[Ce,j]),Te=go(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),Ee=V??s?.cwd??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0),De=oe?.id===E?oe:void 0,Oe=L?.id===E?L:void 0,ke=oo();(0,m.useEffect)(()=>{De&&lo()===De.id&&history.replaceState({...history.state,cadenceCwd:De.cwd,cadenceConversationId:De.id},``,location.href)},[De]);let Ae=E?De:Ee?{id:U,cwd:Ee}:void 0,je=De?.cwd??Ee??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0)??Y.workspace?.rootLabel,Me={state:Y.observation,transportStatus:Y.transportStatus,error:Y.error,refresh:Y.refresh},Ne=Me.state?.snapshot.scope.kind===`task`&&Me.state.snapshot.scope.id===w?Me.state.snapshot.context:void 0,Pe=dp(),{closeDrawer:Fe}=Pe,Ie=N===`branches`&&!!E,Le=!Ie&&(N!==`task`||!G),Re=()=>{re(`branches`),Pe.mobile?Pe.setDrawer(`right`):Pe.inspector||Pe.toggle(`right`)},[ze,Be]=(0,m.useState)(C?.snapshotSeq),[Ve,He]=(0,m.useState)(``),[X,Ue]=(0,m.useState)(``),We=(0,m.useRef)(null),[Ge,Z]=(0,m.useState)(`messages`),[Ke,qe]=(0,m.useState)(!1),[Je,Ye]=(0,m.useState)(!1),[Xe,Ze]=(0,m.useState)(),[Qe,$e]=(0,m.useState)(C?.cursor),[et,tt]=(0,m.useState)(``),[nt,rt]=(0,m.useState)([]),[it,at]=(0,m.useState)(new Set),ot=(0,m.useRef)(!0),st=e=>{ot.current&&rt(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?ho(t,e):t)})},ct=(0,m.useRef)(new Mo),lt=J({taskId:w,scope:G,selectedSnapshot:ze??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ct.current.select(lt),(0,m.useEffect)(()=>(ot.current=!0,()=>{ot.current=!1,ct.current.depart()}),[]);let ut=e=>{b(``);let t=e??crypto.randomUUID();e||H(je??Ee),ee(null),t!==E&&(te([]),F(void 0)),ct.current.depart(),O(t),T(null),K(null),He(``),Ue(``),Ze(void 0),$e(void 0),Be(void 0),Z(`messages`),re(e=>e===`task`?`files`:e),Fe();let n=t===E?fo(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${po(`#chat=${t}`,n)}`)};(0,m.useEffect)(()=>{E&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${E}`)},[E]);let dt=(e,t)=>{ee(null),te([]),O(null),re(`task`),He(t??``),Ue(``),Be(void 0),ct.current.depart(),T(e),K({kind:`task`,id:e}),Ze(void 0),$e(void 0),Z(`messages`),Fe(),history.replaceState(null,``,kf(e))};(0,m.useEffect)(()=>{let e=()=>{let e=Af();if(e)ee(null),te([]),O(null),re(`task`),ct.current.depart(),Be(e.snapshotSeq),He(``),Ue(``),T(e.taskId),K(e.scope??{kind:`task`,id:e.taskId}),Ze(void 0),$e(e.cursor),Z(`messages`),Fe();else{let e=lo();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&H(t),F(void 0),ee(null),te([]),O(e),T(null),K(null),re(e=>e===`task`?`files`:e),ct.current.depart(),Fe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Fe]);let Q=(e,t,n)=>{ee(null),Be(t),Ue(n??``),ct.current.depart(),K(e),Ze(void 0),$e(void 0),Z(`messages`),Fe(),w&&history.replaceState(null,``,kf(w,void 0,{scope:e,snapshotSeq:t}))},ft=ze??Me.state?.snapshot.committedSeq??Y.workspace?.committedSeq,pt=Y.workspace?.storeId,mt=G&&pt&&ft?{storeId:pt,scope:G,snapshotSeq:ft,reader:`messages`,after:null,limit:50}:null,ht=G&&pt&&ft?{storeId:pt,scope:G,snapshotSeq:ft,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,gt=Ne?Me.state?.snapshot.runs??[]:[],_t=ct.current.ticket(),vt=e=>{st(e),e.receipt&&ct.current.current(_t)&&Y.refresh()},yt=e=>{if(it.has(e)||!Y.attached||!Y.activeRuns)return;let t=crypto.randomUUID(),n=Y.activeRuns.epoch;at(t=>new Set(t).add(e)),st({commandId:t,error:h(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{vt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:h(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>st({commandId:t,error:h(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{ot.current&&at(t=>{let n=new Set(t);return n.delete(e),n})})};if(x)return(0,_.jsxs)(`main`,{className:`entry`,children:[(0,_.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h1`,{children:h(`Detached`)}),(0,_.jsx)(`p`,{children:h(`Accepted service work continues. No Cancel was requested.`)}),nt.map(e=>(0,_.jsxs)(`p`,{children:[h(`Observe command after reconnect:`),` `,(0,_.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,_.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:h(`Reconnect as a viewer`)})]});let bt=Y.activeRuns,xt=bt?.status===`complete`?bt.runs:[],St=!x&&!Y.error&&Y.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`),Ct=se&&St,wt=se&&!!Y.workspace&&Y.attached&&!Y.error&&St,Tt=de.current&&!Me.state&&!Me.error&&!q.error&&(!s||!q.value&&q.readiness===`unknown`||q.readiness===`running`),Et=ce?{status:q.readiness===`not-started`?`not-started`:`stopped`}:se&&St&&Y.attached&&Y.epoch&&(!s||q.value?.epoch===Y.epoch)?{status:`ready`,epoch:Y.epoch,attachmentVersion:Y.attachmentVersion}:{status:Tt?`connecting`:`unavailable`},Dt=x?`Viewer disconnected`:Tt?`Connecting…`:s&&q.readiness===`unknown`?`Project readiness unknown`:s&&q.readiness===`stale`?`Project observation stale`:ce?`Ready to prepare execution`:St?Y.workspace?Me.state?.connection??(w?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`,Ot=Tt?`busy`:ce?``:!Ct||!Y.workspace?`error`:Me.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`)?`ok`:`busy`;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(np,{panels:Pe,onOpenService:o,onRefresh:()=>{Y.refresh(),q.refresh()},onDisconnect:()=>{qe(!1),Ye(!1),ct.current.depart(),S(!0)},inspectorLabel:h(G&&N===`task`?`History details`:Ie?`Branches`:`Files`),toolbar:G&&(0,_.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":h(`Recorded views`),children:[(0,_.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ge===`messages`&&!Qe,onClick:()=>{$e(void 0),Ze(void 0),Z(`messages`)},children:[(0,_.jsx)(Gi,{"aria-hidden":`true`}),h(`Conversation`)]}),(0,_.jsxs)(`details`,{className:`view-menu`,ref:We,onKeyDown:e=>{e.key===`Escape`&&We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,_.jsxs)(`summary`,{className:`chip`,children:[Ge===`messages`?h(`Details`):g(Ge),(0,_.jsx)(Sa,{"aria-hidden":`true`})]}),(0,_.jsxs)(`div`,{className:`view-menu-items`,children:[yp.map(([e,t])=>(0,_.jsxs)(`button`,{type:`button`,"aria-pressed":Ge===e,onClick:()=>{$e(void 0),Ze(void 0),Z(e),We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},children:[(0,_.jsx)(t,{"aria-hidden":`true`}),g(e)]},e)),(0,_.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Export selected scope`),disabled:!mt,onClick:()=>{We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus()),Ye(!0)},children:[(0,_.jsx)(ua,{"aria-hidden":`true`}),h(`Export selected scope`)]}),(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Copy token-free link`),disabled:!w,onClick:()=>{w&&Vo(kf(w,Qe,G?{scope:G,snapshotSeq:ze}:void 0)).then(e=>e?ts(`info`,h(`Link copied.`)):ts(`error`,h(`Link copy unavailable.`)))},children:[(0,_.jsx)(Xi,{"aria-hidden":`true`}),h(`Copy token-free link`)]})]})]})]})]}),actions:G&&(0,_.jsx)(Ls,{disabled:!ht,onOpen:()=>qe(!0)}),notices:(0,_.jsxs)(_.Fragment,{children:[!Y.workspace&&xt.length>0&&(0,_.jsx)(`section`,{className:`run-strip`,"aria-label":h(`Execution and cancellation`),children:xt.map(e=>(0,_.jsxs)(`div`,{className:`run-strip-row`,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`run-strip-label`,children:[g(e.kind),` `,e.runId,` · `,g(e.stage)]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>dt(e.taskId),children:h(`Open active task`)}),(0,_.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.attached||it.has(e.runId),onClick:()=>yt(e.runId),children:[(0,_.jsx)(Mi,{"aria-hidden":`true`}),h(`Cancel run — request stop`)]})]},e.runId))}),i,(0,_.jsx)(Of,{error:et,projectObservationError:q.error,observationError:Y.error,unavailable:!Tt&&!ce&&!Ct,onRefresh:()=>{Y.refresh(),q.refresh()}})]}),navigation:(0,_.jsxs)(_.Fragment,{children:[!pe&&(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,_.jsx)($s,{...a}),(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:h(Tt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,_.jsx)(Cf,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:ce,taskId:w,scope:G,runs:gt,snapshot:Me.state?.snapshot.committedSeq,activeRuns:Y.activeRuns,canCancel:Y.attached,canceling:it,onCancel:yt,chats:xe,chatActivityKnown:ye.value?.kind===`conversation-active`&&!ye.error,chatHistoryPartial:ve.loading||ve.canPrevious||!!ve.value?.next,chatHistoryControls:(0,_.jsxs)(_.Fragment,{children:[ve.error&&(0,_.jsx)(`p`,{role:`alert`,children:ve.error}),ve.loading&&(0,_.jsx)(`p`,{className:`panel-hint`,children:h(`Reading conversation history…`)}),ve.canPrevious&&(0,_.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.previous,children:h(`Newer conversations`)}),ve.value?.next&&(0,_.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.next,children:h(`Older conversations`)}),ve.canPrevious&&(0,_.jsx)(`button`,{type:`button`,onClick:ve.first,children:h(`Latest conversations`)}),ve.error&&(0,_.jsx)(`button`,{type:`button`,onClick:ve.refresh,children:h(`Observe current state`)})]}),conversationId:E,onConversation:ut,onNewConversation:()=>ut(),actionsUnavailable:wt?``:h(ce?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{ve.refresh(),e===E&&B(e=>e+1)},workflows:Ce?.runs,workflowLinks:Ce?.links,workflowError:!!Se.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?ut(t):(ee({runId:e.id,stepId:null,label:e.goal}),Fe())},onCancelWorkflow:async e=>{tt(await ld(v.client,e)),Se.refresh()},onTask:dt,onScope:Q}),Y.workspace&&(0,_.jsx)(mc,{client:v.client,active:Y.activeRuns,taskId:w,runs:gt,snapshot:ft,workflowRuns:we,selected:A,onOpenWorkflow:e=>{ee(e),Fe()},onOpen:(e,t,n,r)=>{dt(e),K({kind:`child`,id:t}),Ue(r),Be(n),history.replaceState(null,``,kf(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,_.jsxs)(_.Fragment,{children:[E&&s&&!fe&&(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:h(`Reading this conversation…`)}),A&&(0,_.jsx)(Tf,{client:v.client,agent:A,backLabel:h(E?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>ee(null),onOpenAgent:ee},`${A.runId}:${A.stepId??``}`),E&&(!s||fe)&&(0,_.jsx)(Cd,{client:v.client,id:E,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Ee,onLocation:I,onActivity:R,hidden:!!A,onOpenAgent:ee,onWorkflowRuns:te,onBranches:P,onOpenBranches:Re,workspaceId:s?`checkout:${s.path}`:me.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?q.value?.workspaceId??void 0:void 0,prepareForSend:ge,prepareForPlan:_e,actionsReady:wt,observe:z,available:pe,canInterrupt:Y.attached,enabled:ge?pe:!!Y.workspace&&Y.attached&&!Y.error,modelAvailability:Et,previewModels:d,initialDraft:f?.conversationId===E?f:void 0,onDraftApplied:()=>p?.(E),onModelChanged:()=>{ct.current.depart(),Y.refresh(),q.refresh()},onChanged:()=>{ve.refresh(),Y.refresh()},reference:ae,onReferenceUsed:W},`${s?.id??me.current??`connecting`}:${E}:${k.leaf??``}`),G&&!A&&(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[G.kind!==`task`&&w&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>dt(w,Ve),children:h(`Back to task`)}),(0,_.jsx)(`h2`,{title:Ve||G.id,children:G.kind===`task`?Ve||h(`Task {id}`,{id:G.id.slice(0,8)}):X||h(`{kind} {id}`,{kind:g(G.kind),id:G.id.slice(0,8)})}),G.kind===`child`&&(0,_.jsx)(`span`,{className:`conversation-badge`,children:h(`Subagent`)})]}),(0,_.jsxs)(`details`,{className:`conversation-info`,children:[(0,_.jsxs)(`summary`,{children:[h(`Recorded conversation`),` ·`,` `,h(`snapshot {seq}`,{seq:ft??``})]}),(0,_.jsx)(`code`,{children:G.id}),(0,_.jsx)(`p`,{children:h(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,_.jsxs)(`div`,{className:`workspace-content`,hidden:!!E||!!A,children:[!mt&&(0,_.jsxs)(`section`,{className:`empty-state`,children:[(0,_.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h2`,{children:Y.error?h(`Recorded history could not be read.`):h(`Reading recorded history…`)}),(0,_.jsx)(`p`,{children:h(`History is readonly. Start new work in a conversation with /cadence.`)})]}),mt&&Qe?(0,_.jsxs)(`div`,{className:`tab-body`,children:[Xe&&(Xe.owner.entity.kind===`task`||Xe.owner.entity.kind===`message`||Xe.owner.entity.kind===`tool`)&&(0,_.jsx)(Ts,{client:v.client,seed:{storeId:Qe.storeId,scope:Qe.scope,snapshotSeq:Qe.snapshotSeq,kind:Xe.owner.entity.kind,id:Xe.owner.entity.id,version:Xe.owner.entity.version}},`${Xe.owner.entity.id}:${Xe.owner.entity.version}`),(0,_.jsx)(Ss,{client:v.client,cursor:Qe,highlight:Xe?.range},`${Qe.recordId}:${Qe.recordVersion}`)]}):mt&&(0,_.jsxs)(`div`,{className:Ge===`messages`||Ge===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ge===`messages`&&(0,_.jsx)(Ys,{client:v.client,seed:mt}),Ge===`tools`&&(0,_.jsx)(xp,{client:v.client,seed:mt}),Ge===`context`&&(0,_.jsx)(ws,{client:v.client,seed:mt}),Ge===`timeline`&&(0,_.jsx)(_p,{client:v.client,seed:mt,onSearch:()=>qe(!0)}),Ge===`runs`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`run-current`,children:[(0,_.jsx)(`h3`,{children:h(`Runs in the current snapshot`)}),gt.length>0?gt.map(e=>(0,_.jsx)(Ns,{run:e},e.childRunId??e.runId)):(0,_.jsx)(`p`,{className:`panel-empty`,children:Ne&&Me.state?h(`No owner run projection in this snapshot.`):h(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,_.jsx)(`h3`,{children:h(`Retained runs`)}),(0,_.jsx)(Is,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}},onScope:Q},w)]})]},`${G?.kind}:${G?.id}:${ze??`current`}`)]}),Y.workspace&&nt.length>0&&(0,_.jsx)(`div`,{className:`receipt-dock`,children:nt.map(e=>(0,_.jsx)(No,{client:v.client,value:e,onChange:st},e.commandId))})]}),inspectorTabs:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Le,onClick:()=>re(`files`),children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),h(`Files`)]}),E&&(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>re(`branches`),children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),h(`Branches`)]}),G&&(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!mt,onClick:()=>re(`task`),children:[(0,_.jsx)(Zi,{"aria-hidden":`true`}),h(`History details`)]})]}),inspector:Ie?(0,_.jsx)(bc,{view:ie?.id===E?ie:void 0,onChosen:Fe}):Le?(0,_.jsx)(Rd,{location:Ae,client:v.client,enabled:pe&&!!Ae,observed:`${q.readiness}:${q.value?.epoch??``}`,onReference:e=>{E||ut(U);let t=!E&&Ae?`${Ae.cwd.replace(/[\\/]+$/,``)}${Ae.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;F(t),Fe()}},Ae?.cwd??`owner`):mt?(0,_.jsx)(Jd,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}}},w):(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?h(`Recorded history could not be read.`):h(`Reading recorded history…`)}),status:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(cp,{tip:h(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:g(Dt)}),s&&(0,_.jsx)(sp,{tone:`faint`,icon:(0,_.jsx)(Fi,{}),children:h(`Execution service: {status}`,{status:g(q.readiness)})}),Oe&&(0,_.jsx)(op,{usage:Oe.context}),Oe&&(0,_.jsx)(ip,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,_.jsx)(sp,{icon:(0,_.jsx)(Gi,{}),tip:h(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,_.jsx)(up,{since:Oe.runningSince,label:h(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,_.jsx)(sp,{tone:`warn`,children:h(Ct?xt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:xt.length})}):!Tt&&!ce&&(0,_.jsx)(sp,{tone:`faint`,children:h(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,_.jsx)(Df,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,_.jsx)(Qd,{onOpen:t,projects:r??(Te.value?.kind===`projects`?Te.value.entries:[]),client:v.client,current:je??Y.workspace.rootLabel,initial:M||void 0,home:n,epoch:Y.workspace.epoch,onClose:()=>ne(null)}),Ke&&ht&&(0,_.jsx)(Ms,{client:v.client,seed:ht,onClose:()=>qe(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,kf(w,e.cursor,G?{scope:G,snapshotSeq:ze}:void 0))}}),Je&&ht&&(0,_.jsx)(ks,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function xp({client:e,seed:t}){let n=Ro(e,{...t,reader:`tools`}),r=n.page;return(0,_.jsxs)(`section`,{className:`tools-list`,children:[(0,_.jsx)(Cs,{pager:n}),(0,_.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,_.jsx)(Zs,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Sp=`cadence:folder-draft`,Cp=()=>({text:``,model:null});function wp(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Cp();let t=null;try{e.model!=null&&(t=ge(e.model))}catch{}return{text:e.text,model:t}}catch{return Cp()}}function Tp(e){try{e.text||e.model?sessionStorage.setItem(Sp,JSON.stringify(e)):sessionStorage.removeItem(Sp)}catch{}}function Ep(e,t,n){let r=Xc(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(Sp)}catch{}return{...n,conversationId:t}}var Dp=`cadence-last-project`;function Op(){try{let e=localStorage.getItem(Dp);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function kp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Dp,e)}catch{}}function Ap(e){let t=Op();return t?e.projects.find(e=>e.id===t):void 0}async function jp(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=Tn(await yo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Mp(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await yo(n);if(!n.ok)throw Error(bo(r));return Sn(r)}async function Np(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await yo(t);if(!t.ok)throw Error(bo(n));return An(n)}async function Pp(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await yo(s);if(!s.ok)throw xo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(bo(c));let l=wn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Fp(e,t){let n=await Np(t);return Pp(`/workbench/v1/select`,{path:e},n,t)}async function Ip(e,t,n,r,i){let a=await Np(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await Pp(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function Lp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Fp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Rp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function zp(e){let t=W(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:K(t.id),source:V(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:pn(t.sessionId),cwd:L(t.cwd,4096,!0),leaf:t.leaf===null?null:L(t.leaf,128,!0),history:V(t.history,[`shared`,`unavailable`]),phase:V(t.phase,Rp),freshness:V(t.freshness,[`current`,`stale`,`unknown`]),observedAt:z(t.observedAt,0),epoch:t.epoch===null?null:K(t.epoch),instance:t.instance===null?null:K(t.instance),executionCwd:t.executionCwd===null?null:L(t.executionCwd,4096,!0)}}function Bp(e){let t=W(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:H(t.kind,`activity-discovery`),epoch:K(t.epoch),observedAt:z(t.observedAt,0),completeness:V(t.completeness,[`complete`,`partial`]),unavailable:z(t.unavailable,0,1e4),projects:G(t.projects,128,e=>{let t=W(e,[`path`,`activities`]);return{path:L(t.path,4096,!0),activities:G(t.activities,256,zp)}})}}async function Vp(e){let t=Fa([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await yo(e);if(!e.ok)throw Error(bo(n));return Bp(n)}finally{t.dispose()}}function Hp(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function Up(e,t,n,r=Vp){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?Hp(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function Wp(e,t){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(``);return(0,m.useEffect)(()=>{if(r(void 0),a(``),e)return Up(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function Gp({ready:e,previewModels:t,draft:n=Cp(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=D(),d=dp(),[f,p]=(0,m.useState)(!1),h=fl(null,{status:`not-started`},`folder-setup`,t),g=()=>{d.closeDrawer(),a()};return(0,_.jsx)(np,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,_.jsx)(of,{disabled:!e,onConversation:g}),l&&(0,_.jsx)($s,{...l}),(0,_.jsxs)(`section`,{className:`lp-section grow`,children:[(0,_.jsx)(`header`,{className:`lp-section-header`,children:(0,_.jsx)(`span`,{className:`lp-section-title`,children:u(`Conversation history`)})}),(0,_.jsx)(`div`,{className:`lp-section-body`,children:(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,_.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,_.jsx)(`div`,{className:`chat-messages`,children:(0,_.jsxs)(qu,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,_.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:g,children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,_.jsxs)(`div`,{className:`chat-composer`,children:[(0,_.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,_.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,_.jsx)(ql,{scope:`next-conversation`,availability:{status:`not-started`},read:h,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:f,onOpenChange:e=>{e&&h.reread(),p(e)},onChanged:()=>{}}),(0,_.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,_.jsx)(Ta,{"aria-hidden":`true`})})]})]})]}),inspector:(0,_.jsx)(`aside`,{className:`panel files-panel`,children:(0,_.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,_.jsx)(sp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,_.jsx)(Df,{disabled:!e,onClick:g})})}var Kp=`cadence-recovery-dismissed`,qp={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},Jp={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function Yp(){try{let e=JSON.parse(localStorage.getItem(Kp)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Xp(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Zp({notices:e,project:t}){let{t:n}=D(),[r,i]=(0,m.useState)(Yp),[a,o]=(0,m.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(Kp,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:Xp(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,_.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,_.jsxs)(`span`,{children:[n(qp[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,_.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,_.jsxs)(`li`,{children:[(0,_.jsx)(`strong`,{children:u(e)}),` `,(0,_.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Jp[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Qp={restart:18e4,upgrade:12e5},$p=1e3,em={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},tm=e=>e instanceof Error?e.message:`unavailable`;function nm(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(em[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function rm(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function im(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function am({epoch:e,csrf:t,onClose:n}){let{t:r}=D(),[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)(!1),[C,w]=(0,m.useState)(),[T,E]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=new AbortController;return Co(e.signal).then(a,t=>{e.signal.aborted||s(tm(t))}),()=>e.abort()},[T]),(0,m.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Qp[e.action])return w(`timeout`);try{let t=await Co(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof F||e instanceof Error&&e.message===`invalid`)return w(`changed`);x(!0)}r=setTimeout(i,$p)};return r=setTimeout(i,$p),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),wo().then(l,()=>l(`failed`)).finally(()=>E(e=>e+1))},k=n=>{i&&(g(!0),s(``),To({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(tm(e)),p(!1),E(e=>e+1)}).finally(()=>g(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&rm(C),o=i?.unit;return(0,_.jsxs)(Os,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,_.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,_.jsxs)(`p`,{role:`status`,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(b?`Cadence is starting again…`:`Stopping Cadence…`):r(b?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,_.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,_.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Qp[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):nm(r,C)]}),(0,_.jsx)(`p`,{children:r(C===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,_.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,_.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,_.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,_.jsx)(`footer`,{children:a?(0,_.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,_.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,_.jsxs)(Os,{title:r(`Cadence service`),onClose:n,children:[(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,_.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,_.jsxs)(`label`,{className:`service-confirm`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,_.jsx)(`p`,{role:`alert`,children:S(r,o)}),(0,_.jsxs)(`footer`,{children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>{d(null),p(!1),s(``)},children:r(`Back`)}),(0,_.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:h||e>0&&!f,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let A=i&&c&&typeof c==`object`?Vn(c.version,i.version)>0:!1;return(0,_.jsxs)(Os,{title:r(`Cadence service`),onClose:n,children:[i?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`service-info`,children:[(0,_.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,_.jsx)(`p`,{children:im(r,i.upgrade)}),(0,_.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,_.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:nm(r,i.job)})})]}),i.unit&&(0,_.jsxs)(`section`,{className:`service-info`,children:[(0,_.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,_.jsxs)(_.Fragment,{children:[c===`failed`&&(0,_.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,_.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,_.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):A?c.deprecated?(0,_.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Rn(i.upgrade)?(0,_.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,_.jsx)(Ea,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,_.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,_.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,_.jsx)(`p`,{role:`alert`,children:S(r,o)})]}):(0,_.jsx)(`p`,{role:o?`alert`:`status`,children:o?S(r,o):r(`Reading the service…`)}),(0,_.jsx)(`footer`,{children:(0,_.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,_.jsx)(Ri,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function om(){let{t:e}=D(),[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(wp),[a,o]=(0,m.useState)(),s=(0,m.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,m.useState)(co),u=(0,m.useCallback)(e=>Mp(c??void 0,e),[c]),[d,f]=(0,m.useState)(null),[p,h]=(0,m.useState)(null),[g,v]=(0,m.useState)(``),[y,b]=(0,m.useState)(``),[x,C]=(0,m.useState)(0),[w,T]=(0,m.useState)(!1),[E,O]=(0,m.useState)(null),k=(0,m.useCallback)(()=>C(e=>e+1),[]),A=Wp(t?.epoch,k),ee=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>ee.current?.abort(),[]);let j=(0,m.useRef)(new Map),te=(0,m.useRef)(!c),M=(0,m.useRef)(null),ne=(0,m.useCallback)(()=>{M.current&&(M.current.abort(),M.current=null,O(null))},[]);(0,m.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 yo(t);t.status===400&&bo(r)===`invalid`?n(null):t.ok?(n(An(r)),b(``)):b(bo(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,m.useEffect)(()=>{let e=()=>{ee.current?.abort(),ne(),O(null),l(co())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,m.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=Ap(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),jp(e.id,n.signal).then(t=>{n.signal.aborted||(M.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),O(null),l(e.id)):O({status:`unavailable`,path:e.cwd}))})},[t,r]);let N=(0,m.useCallback)((e,n)=>{ne(),O(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&j.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=!t?.projects.some(e=>e.id===c)&&!n&&!!(r.text||r.model);s?(o(Ep(e.path,a,r)),i(Cp())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:j.current.get(e.id)??`#chat=${a}`}`),l(e.id),f(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),re=(0,m.useCallback)(async e=>{ee.current?.abort();let t=new AbortController;ee.current=t;let r=await Fp(e,t.signal);t.signal.aborted||(n(r.entry),N(r.project))},[N]),ie=t?{value:A.value,error:A.error,opening:!!p,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,r)=>{ee.current?.abort(),ne();let i=new AbortController;ee.current=i,h(r.cwd),v(``),Lp(t,r,i.signal).then(e=>{i.signal.aborted||(n(e.entry),N(e.project,r))}).catch(t=>{i.signal.aborted||v(S(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{ee.current===i&&h(null)})}}:void 0,P=async(e,r,i,a)=>{let o=t?.projects.find(e=>e.id===c);if(!o)throw Error(`unavailable`);let s=await Ip(o,e,r,i,a);if(r.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},I=(0,m.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new F(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await yo(n);if(!n.ok){let e=bo(r);return{kind:`error`,error:oe(ae.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:di(r)}}catch{return{kind:`error`,error:oe(`unavailable`)}}}}),[]),L=(0,m.useMemo)(()=>c?Xa(c):void 0,[c]),R=t?.projects.find(e=>e.id===c);if((0,m.useEffect)(()=>{R&&kp(R.id)},[R]),t===null)return(0,_.jsx)(bp,{});let z=t&&w&&(0,_.jsx)(am,{epoch:t.epoch,csrf:t.csrf,onClose:()=>T(!1)}),B=()=>T(!0),V=t&&d!==null&&(0,_.jsx)(Qd,{selectOnly:!0,client:I,current:R?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>f(null),onOpen:re});return t&&R&&L?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(bp,{api:L,project:R,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===R.path).map(e=>e.id).sort(),discovery:ie,onPrepareExecution:P,onChooseFolder:e=>{ee.current?.abort(),f(e??R.cwd)},onOpenProject:re,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,_.jsxs)(_.Fragment,{children:[g&&(0,_.jsx)(`p`,{role:`alert`,children:g}),(0,_.jsx)(Zp,{notices:t.recoveries,project:R.path}),` `]}),onOpenService:B},R.id),z,V]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Gp,{discovery:ie,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),Tp(e)},restore:E,onRefresh:()=>C(e=>e+1),onOpenService:t?B:void 0,onChooseFolder:()=>{ne(),v(``),ee.current?.abort(),f(t?.home??``)},notices:(0,_.jsxs)(_.Fragment,{children:[g&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g}),t&&(0,_.jsx)(Zp,{notices:t.recoveries}),y&&(0,_.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>C(e=>e+1),children:e(`Reload observation`)})]}),c&&!R&&t&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),V,z]})}function sm(){let{t:e}=D();return(0,_.jsxs)(`main`,{className:`entry`,children:[(0,_.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,_.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var cm=class extends m.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,_.jsx)(sm,{}):this.props.children}};te(j());var lm=document.getElementById(`root`);if(!lm)throw Error(`Application root unavailable`);(0,h.createRoot)(lm).render((0,_.jsx)(O,{children:(0,_.jsx)(cm,{children:(0,_.jsx)(om,{})})}));export{gp as t};
|
|
29
|
+
`}${r}`}var Kd=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function qd(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}function Jd(e,t){let n=e.startsWith(`/`)?`/`:`\\`;return`${e.replace(/[\\/]+$/,``)}${n}${t.split(`/`).join(n)}`}var Yd=`file-download`,Xd=(0,m.memo)(function({path:e,text:t}){return(0,_.jsx)(ws,{text:Gd(t,Cu(e))})});function Zd({client:e,enabled:t,location:n,observed:r=``,onReference:i}){let{t:a}=D(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(null),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(``),[h,g]=(0,m.useState)(!1),{copied:v,copy:y}=es(),[b,x]=(0,m.useState)(null),C=(0,m.useRef)(null),w=n?.cwd,T=n?.id;(0,m.useEffect)(()=>()=>{C.current?.abort(),C.current=null,x(null)},[e,w,T]);let E=Oo(e,t?{kind:`files`,path:o,...n?{location:n}:{}}:null),O=Oo(e,t&&c?{kind:`file`,path:c,...n?{location:n}:{}}:null),{refresh:k}=E,{refresh:A}=O,ee=(0,m.useRef)(r);(0,m.useEffect)(()=>{ee.current!==r&&(ee.current=r,k(),A())},[r,k,A]);let j=E.value?.kind===`files`?E.value:void 0,te=O.value?.kind===`file`?O.value:void 0,M=e=>{s(e),d(null)},ne=(e,t)=>{p(e),y(t).then(e=>{e||ps(`error`,a(`Copy unavailable`))})},N=t=>{let r=new AbortController;C.current=r,x(t.path),hs(Yd),Rd(async i=>{let a=await e.workbenchRead({kind:`file-part`,path:t.path,offset:i,...n?{location:n}:{}},r.signal);if(r.signal.aborted)throw Error(`unavailable`);if(a.kind===`error`)throw Error(a.error.code);return a.value}).then(e=>{if(!r.signal.aborted)return Wd(e,t.name)}).catch(e=>{if(r.signal.aborted)return;let n=e instanceof Error?e.message:String(e);ps(`error`,a(`Download of {path} failed: {error}`,{path:t.name,error:n===`oversize`?a(`the file is larger than the 64 MiB download limit`):S(a,n)}),Yd)}).finally(()=>{C.current===r&&(C.current=null,x(null))})},re=u?.trim().toLowerCase()??``,ie=j?.entries.filter(e=>!re||e.name.toLowerCase().includes(re));return(0,_.jsxs)(`div`,{className:`files-panel`,children:[(0,_.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,_.jsx)(`button`,{type:`button`,className:`crumb${o?``:` active`}`,title:n?`${a(`Conversation folder:`)} ${n.cwd}`:void 0,disabled:!n,onClick:()=>M(``),children:n?Kd(n.cwd):a(`Not observed`)}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,title:a(`Refresh files`),"aria-label":a(`Refresh files`),disabled:!t,onClick:()=>{E.refresh(),O.refresh()},children:(0,_.jsx)(Xi,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`crumb${u===null?``:` active`}`,"aria-label":a(`Filter this folder…`),title:a(`Filter this folder…`),"aria-pressed":u!==null,disabled:!j,onClick:()=>d(u===null?``:null),children:(0,_.jsx)(Ji,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`crumb${h?` active`:``}`,"aria-label":a(`About this panel`),title:a(`About this panel`),"aria-expanded":h,onClick:()=>g(e=>!e),children:(0,_.jsx)(pa,{"aria-hidden":`true`})}),qd(o).map(e=>(0,_.jsxs)(`span`,{className:`crumb-seg`,children:[(0,_.jsx)(Ma,{"aria-hidden":`true`}),(0,_.jsx)(`button`,{type:`button`,className:`crumb${e.path===o?` active`:``}`,title:e.path,onClick:()=>M(e.path),children:e.label})]},e.path))]}),h&&(0,_.jsx)(`p`,{className:`files-policy`,children:a(`Readonly preview · references send paths, not file contents · a download is the file's own bytes, unredacted`)}),u!==null&&(0,_.jsxs)(`label`,{className:`file-filter`,children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{autoFocus:!0,value:u,"aria-label":a(`Filter this folder…`),placeholder:a(`Filter this folder…`),onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Escape`&&d(null)}}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close`),onClick:()=>d(null),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]}),E.error&&(0,_.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:S(a,E.error)}),(0,_.jsxs)(`section`,{className:`file-list`,"aria-label":a(`File list`),children:[t?!j&&!E.error?(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(`Reading files…`)}):null:(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:a(n?`Files appear once this folder has been observed.`:`The conversation folder has not been observed.`)}),j&&j.parent!=null&&!re&&(0,_.jsxs)(`button`,{type:`button`,className:`file-item dir`,"aria-label":a(`Parent folder`),title:a(`Parent folder`),onClick:()=>M(j.parent??``),children:[(0,_.jsx)(ga,{className:`file-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`file-name`,children:`..`})]}),ie?.map(e=>(0,_.jsxs)(`div`,{className:`file-item ${e.directory?`dir`:`file`}${c===e.path?` selected`:``}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`file-main`,title:e.path,onClick:()=>e.directory?M(e.path):l(e.path),children:[e.directory?(0,_.jsx)(ga,{className:`file-icon`,"aria-hidden":`true`}):(0,_.jsx)(_a,{className:`file-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`file-name`,children:e.name})]}),!e.directory&&(0,_.jsx)(`button`,{type:`button`,className:`file-attach download${b===e.path?` busy`:``}`,"aria-label":a(`Download file {path}`,{path:e.name}),title:a(`Download file {path}`,{path:e.name}),"aria-busy":b===e.path,disabled:!t||!!E.error||b!==null,onClick:()=>N(e),children:(0,_.jsx)(Sa,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`file-attach ref`,"aria-label":a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),title:a(e.directory?`Link folder path {path} to the chat`:`Reference path only: {path} (the agent reads it on demand)`,{path:e.name}),disabled:!t||!!E.error,onClick:()=>i(e.path),children:(0,_.jsx)(ca,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`file-attach copy${v&&f===`name:${e.path}`?` copied`:``}`,"aria-label":a(`Copy name {path}`,{path:e.name}),title:a(`Copy name {path}`,{path:e.name}),onClick:()=>ne(`name:${e.path}`,e.name),children:v&&f===`name:${e.path}`?(0,_.jsx)(Fa,{"aria-hidden":`true`}):(0,_.jsx)(Da,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`file-attach copy${v&&f===`path:${e.path}`?` copied`:``}`,"aria-label":a(`Copy path {path}`,{path:e.name}),title:a(`Copy path {path}`,{path:e.name}),onClick:()=>ne(`path:${e.path}`,n?Jd(n.cwd,e.path):e.path),children:v&&f===`path:${e.path}`?(0,_.jsx)(Fa,{"aria-hidden":`true`}):(0,_.jsx)(Aa,{"aria-hidden":`true`})})]},e.path)),t&&!E.error&&ie?.length===0&&(re?(0,_.jsx)(`p`,{className:`panel-empty`,children:a(`No matching files`)}):(0,_.jsx)(`p`,{className:`panel-empty`,children:a(`No visible files`)})),j?.limited&&(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`Bounded listing; narrow the directory to see more.`)})]}),c&&(0,_.jsxs)(`section`,{className:`file-preview`,children:[(0,_.jsxs)(`header`,{children:[(0,_.jsx)(_a,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{title:c,children:Kd(c)}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close preview`),title:a(`Close preview`),onClick:()=>l(null),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]}),O.error&&(0,_.jsx)(`p`,{role:`alert`,children:S(a,O.error)}),te&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Xd,{path:te.path,text:te.text}),te.limited&&(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`File preview is limited; this is not the complete file.`)})]})]})]})}var Qd=`未命名章节`;function $d(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 ef(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=$d(r||Qd),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Qd}})}function tf(e){return e.length>=2}function nf(e){let t=0,n=0;return e.split(`
|
|
30
|
+
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function rf({text:e}){return(0,_.jsx)(`pre`,{className:`scm-diff-pre`,children:nf(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,_.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})}function af({text:e}){let{t}=D(),[n,r]=(0,m.useState)(`raw`),[i,a]=(0,m.useState)(!0),[o,s]=(0,m.useState)(1),[c,l]=(0,m.useState)([]),[u,d]=(0,m.useState)(null),f=(0,m.useRef)(1),p=(0,m.useRef)(null),h=e.split(`
|
|
31
|
+
`);return(0,m.useLayoutEffect)(()=>{if(n!==`markdown`)return;if(!e){l([]);return}let t=Array.from(p.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=ef(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,_.jsxs)(`div`,{className:`fp-preview`,children:[(0,_.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,_.jsxs)(`label`,{children:[t(`View`),(0,_.jsxs)(`select`,{value:n,onChange:e=>r(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,_.jsx)(`option`,{value:`raw`,children:t(`Raw text / lines`)}),(0,_.jsx)(`option`,{value:`markdown`,children:t(`Safe Markdown`)}),(0,_.jsx)(`option`,{value:`diff`,children:t(`Observed diff`)})]})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>a(e=>!e),children:t(i?`Wrap: on`:`Wrap: off`)}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.min(2,e+.1)),children:t(`Zoom +`)}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>s(e=>Math.max(.8,e-.1)),children:t(`Zoom −`)}),(0,_.jsx)(vs,{text:u?h.slice(u.start-1,u.end).join(`
|
|
32
|
+
`):e})]}),(0,_.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,_.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,_.jsxs)(`div`,{className:`fp-toc-layout`,children:[tf(c)&&(0,_.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,_.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,children:(0,_.jsx)(ws,{text:e})})]}):n===`diff`?(0,_.jsx)(rf,{text:e}):(0,_.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:nf(e).map(({text:e,number:n,key:r})=>(0,_.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,_.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(f.current=n),d({start:Math.min(f.current,n),end:Math.max(f.current,n)})},children:n}),(0,_.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,_.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function of({client:e,seed:t}){let{t:n,tx:r}=D(),i=Xo(e,t),[a,o]=(0,m.useState)(),s=i.page;return(0,_.jsxs)(`section`,{className:`scm-body`,children:[(0,_.jsx)(Fs,{pager:i}),(0,_.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,_.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,_.jsxs)(`article`,{className:`scm-file`,children:[(0,_.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,_.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,_.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(Jo(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,_.jsx)(Ps,{client:e,cursor:a,render:e=>(0,_.jsx)(af,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var sf=[`contents`,`checks`,`changes`,`reviews`];function cf({client:e,seed:t}){let{t:n,tx:r}=D(),[i,a]=(0,m.useState)(`contents`);return(0,_.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,_.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,_.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:sf.map(e=>(0,_.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,_.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,_.jsx)(Is,{client:e,seed:t}):(0,_.jsx)(of,{client:e,seed:{...t,reader:i}},i)})]})}var lf={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.`},uf=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function df(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 ff({client:e,current:t,initial:n,home:r,epoch:i,onClose:a,onOpen:o,projects:s=[],selectOnly:c=!1}){let{t:l}=D(),[u,d]=(0,m.useState)(),[f,p]=(0,m.useState)(n??t),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(``),[b,x]=(0,m.useState)(!0),[C,w]=(0,m.useState)(!0),[T,E]=(0,m.useState)(!1),[O,k]=(0,m.useState)(null),A=(0,m.useRef)(!0),ee=(0,m.useRef)(void 0),j=(0,m.useRef)(n??t),te=(0,m.useRef)(null),M=(0,m.useRef)(null),ne=async t=>{ee.current?.abort();let n=new AbortController;ee.current=n,x(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&A.current){if(ee.current=void 0,x(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),p(r.value.path),g(!1),y(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,m.useRef)(ne);(0,m.useEffect)(()=>(A.current=!0,N.current(j.current).then(()=>{A.current&&w(!1)}),()=>{A.current=!1,ee.current?.abort()}),[]),(0,m.useEffect)(()=>{h&&te.current?.select()},[h]),(0,m.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let re=e=>{T||ne(e)},ie=()=>{let e=f.trim();T||(uf(e)?ne(e):k({step:`read`,code:`relative`}))},P=(h||!u)&&f.trim()||u?.path||``,ae=!T&&!b&&!!P,F=async n=>{if(T||!n||b&&n===u?.path)return;if(n!==u?.path&&!uf(n)){k({step:`read`,code:`relative`});return}E(!0),k(null);let r=n===u?.path?u.path:(await ne(n))?.path;if(!A.current)return;if(!r){E(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),A.current&&a()}catch(e){A.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),E(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),E(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(A.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),E(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),E(!1)}},oe=u?df(u.path,r):void 0,I=v.trim().toLowerCase(),L=u?.entries.filter(e=>e.name.toLowerCase().includes(I))??[],R=O&&(O.step===`read`&&lf[O.code]?l(lf[O.code]):S(l,O.code));return(0,_.jsxs)(Bs,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,_.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,_.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,_.jsx)(`h3`,{children:l(`Recent folders`)}),(0,_.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,_.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:T,onClick:()=>e.current?a():void F(e.path),children:[(0,_.jsx)(ga,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,_.jsxs)(`div`,{className:`cwd-location`,children:[oe&&!h?(0,_.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:T,onClick:()=>re(`~`),children:[(0,_.jsx)(fa,{"aria-hidden":`true`}),oe.inside&&(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),oe.trail.map((e,t)=>(0,_.jsxs)(m.Fragment,{children:[(t>0||oe.inside)&&(0,_.jsx)(Ma,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,_.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:T,onClick:()=>re(e.path),children:e.name})]},e.path))]}):C?(0,_.jsx)(`div`,{className:`cwd-crumbs`}):(0,_.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),ie()},children:(0,_.jsx)(`input`,{ref:te,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:f,disabled:T,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{p(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),g(!1),p(u.path),k(null))}})}),u&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":h,disabled:T,onClick:()=>{p(u.path),g(!h),k(null)},children:(0,_.jsx)(xa,{"aria-hidden":`true`})})]}),u&&(0,_.jsxs)(`label`,{className:`cwd-filter`,children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:v,disabled:T,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,_.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":b||void 0,children:[b&&(0,_.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,_.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>re(u.parent),children:[(0,_.jsx)(La,{}),l(`Parent folder`)]}),L.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>re(e.path),children:[(0,_.jsx)(ga,{}),(0,_.jsx)(`span`,{children:e.name})]},e.path)),u&&!b&&L.length===0&&(0,_.jsx)(`p`,{className:`cwd-picker-note`,children:l(I?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,_.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),R&&(0,_.jsxs)(`p`,{role:`alert`,children:[R,O?.code===`registry-locked`&&(0,_.jsxs)(_.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,_.jsxs)(`footer`,{className:`cwd-footer`,children:[P&&(0,_.jsxs)(`p`,{className:`cwd-target`,children:[(0,_.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,_.jsx)(`code`,{children:P})]}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ae,onClick:()=>void F(P),children:l(T?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function pf(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}var mf=[`today`,`yesterday`,`earlier`];function hf(e,t=Date.now()){let n=new Date(t);return n.setHours(0,0,0,0),e>=n.getTime()?`today`:(n.setDate(n.getDate()-1),e>=n.getTime()?`yesterday`:`earlier`)}function gf(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=hf(t(i),n);r.set(e,[...r.get(e)??[],i])}return mf.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function _f(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function vf(e,t,n=Date.now()){let r=new Date(e);return hf(e,n)===`earlier`?r.toLocaleDateString(t,{month:`short`,day:`numeric`,...r.getFullYear()===new Date(n).getFullYear()?{}:{year:`numeric`}}):r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`,hour12:!1})}function yf({onConversation:e,disabled:t=!1}){let{t:n}=D();return(0,_.jsx)(`div`,{className:`lp-new`,children:(0,_.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,_.jsx)(Zi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function bf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var xf=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),Sf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function Cf(e,t){let n;try{n=await e.workbenchCommand(t)}catch{return{kind:`refused`,code:`invalid`}}return n.kind===`ok`?{kind:`accepted`}:{kind:n.error.effect===`none`?`refused`:`unknown`,code:n.error.code}}var wf={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},Tf={rename:`The conversation was not renamed ({code}). Its name is unchanged.`,archive:`The conversation was not archived ({code}). It stays in the history.`,unarchive:`The conversation was not unarchived ({code}). It stays archived.`},Ef={rename:`Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.`,archive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`,unarchive:`Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.`},Df=e=>`conversation-row:${e}`;function Of(e,t){return t.kind===`refused`?{refusal:{text:Tf[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function kf(e,t){let{t:n}=D(),[r,i]=(0,m.useState)(()=>new Map),a=(0,m.useRef)(!0);(0,m.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});hs(Df(c)),l({pending:o}),Cf(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=Of(o,e);l(r),i&&ps(`error`,n(i.text,{code:i.code}),Df(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,xf(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,Sf(e,t))}}function Af({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=D(),d=u===`zh`?`zh-CN`:`en-GB`,[f,p]=(0,m.useState)(null),h=f!==null,g=(0,m.useRef)(null),v=(0,m.useRef)(null),y=(0,m.useRef)(!1);(0,m.useEffect)(()=>{let e=g.current;if(!h||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,p(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[h]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,_.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,_.jsx)(Hi,{"aria-hidden":`true`}):(0,_.jsx)(ra,{"aria-hidden":`true`})}),S=()=>{if(f===null)return;let t=bf(f);t===null?ps(`error`,l(`A name can have at most {count} characters.`,{count:100}),Df(e.id)):(y.current=!0,p(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(wf[a.pending]):a?.unknown?l(Ef[a.unknown.action],{code:a.unknown.code}):``;return h?(0,_.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||p(null)},children:[(0,_.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,_.jsx)(`input`,{ref:g,className:`session-rename-input`,value:f,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>p(e.target.value)})]}),(0,_.jsxs)(`span`,{className:`session-actions`,children:[(0,_.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,_.jsx)(Fa,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,p(null)},children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]})]}):(0,_.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,_.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,_.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:vf(e.updatedAt,d)})]}),c&&(0,_.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,_.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>p(e.title),children:(0,_.jsx)(xa,{"aria-hidden":`true`})}),(0,_.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,_.jsx)(Yi,{"aria-hidden":`true`}):(0,_.jsx)(Va,{"aria-hidden":`true`})})]}),w&&(0,_.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function jf({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=D(),a=e.value?.entries??[];return(0,_.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,_.jsx)(za,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,_.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,_.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,_.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,S(i,e.error)]}),e.loading&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,_.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,_.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,_.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,_.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var Mf={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function Nf({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,m.useState)(!0);return(0,_.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,_.jsxs)(`header`,{className:`lp-section-header`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,_.jsx)(Pa,{"aria-hidden":`true`}):(0,_.jsx)(Ma,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,_.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,_.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,_.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function Pf({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=D(),[o,s]=(0,m.useState)(new Set),c=pf(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,_.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,_.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,_.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,_.jsx)(Ma,{"aria-hidden":`true`}):(0,_.jsx)(Pa,{"aria-hidden":`true`})}):(0,_.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,_.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,_.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,_.jsx)(wa,{"aria-hidden":`true`}):(0,_.jsx)(ra,{"aria-hidden":`true`})}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,_.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,_.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,_.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function Ff({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=D(),a=e.page;return(0,_.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Pf,{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,_.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,_.jsx)(Fs,{pager:e,compact:!0})]})}function If({client:e,workspace:t,executionStopped:n=!1,taskId:r,scope:i,runs:a,snapshot:o,activeRuns:s,canCancel:c,canceling:l,onCancel:u,onTask:d,onScope:f,chats:p=[],chatActivityKnown:h=!0,chatHistoryPartial:g=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:T=[],workflowError:E=!1,discovery:O,selectedWorkflow:k,onWorkflow:A,onCancelWorkflow:ee}){let{t:j,tx:te}=D(),[M,ne]=(0,m.useState)(``),[N,re]=(0,m.useState)(!1),ie=Ao(e,N,!0),P=ie.refresh,ae=kf(e,e=>{P(),C?.(e)}),F=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,oe=Xo(e,F),I=Xo(e,r&&F&&t?{...F,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),L=oe.page&&!(`kind`in oe.page)?oe.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],R=s?.status===`complete`?s.runs:[],z=L.filter(e=>!R.some(t=>t.taskId===e.owner.taskId)),B=r&&(0,_.jsxs)(`section`,{className:`task-conversations`,"aria-label":j(`Task conversations`),children:[(0,_.jsx)(`h3`,{children:j(`Task conversations`)}),(0,_.jsx)(Ff,{pager:I,scope:i,onScope:f,exclude:R.map(e=>e.runId)},r)]}),[V,H]=(0,m.useState)(()=>new Set),U=e=>{let t=T.find(t=>t.runId===e.id)?.conversationId??null;return(0,_.jsxs)(`div`,{className:`conversation-group`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>A?.(e,t),title:e.goal,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[j(`Cadence workflow`),` · `,te(e.phase),` · `,te(e.status)]})]})]}),ee&&(0,_.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:V.has(e.id),onClick:()=>{H(t=>new Set(t).add(e.id)),ee(e).finally(()=>H(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,_.jsx)(Wi,{"aria-hidden":`true`}),j(`Cancel workflow — request stop`)]})]},e.id)},W=p.filter(e=>e.status===`running`||e.status===`queued`),G=p.filter(e=>!W.includes(e)),K=e=>w?.findLast(t=>T.some(n=>n.runId===t.id&&n.conversationId===e.id)),q=e=>{let t=e.status===`running`||e.status===`queued`,n=t||e.status===`completed`?K(e):void 0,r=n?te(gd(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,_.jsx)(Af,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:ae.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>ae.archive(e.id,t),onRename:t||e.archived?void 0:t=>ae.rename(e.id,t)},e.id)},se=G.filter(e=>_f(e.title,M)),ce=z.filter(e=>_f(e.goal,M));return(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,_.jsx)(dc,{...O,represented:!n&&O.project?[...(w??[]).map(e=>uc(O.project,`workflow`,e.id,e.epoch)),...W.flatMap(e=>e.live?[uc(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,_.jsx)(yf,{onConversation:x}),!n&&(0,_.jsxs)(Nf,{title:j(`Running work`),count:s?.status===`complete`&&w&&!E&&h?String(R.length+W.length+w.length):j(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Active roster unavailable; absence is not proof of settlement.`)}),E&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),!h&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`Conversation activity unavailable.`)}),W.map(q),w?.map(U),s?.status===`complete`&&R.length===0&&W.length===0&&w?.length===0&&!E&&h&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`No active runs`)}),R.map(e=>{let t=L.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,_.jsxs)(`div`,{className:`conversation-group`,children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:t??j(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,_.jsxs)(`span`,{className:`session-sub`,children:[te(e.kind),` · `,te(e.stage)]})]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,_.jsx)(Wi,{"aria-hidden":`true`}),j(`Cancel run — request stop`)]}),r===e.taskId&&(0,_.jsx)(Pf,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:f})]},e.runId)})]}),(0,_.jsxs)(Nf,{title:j(N?`Archived conversations`:`Conversation history`),count:N?ie.value?`${ie.value.entries.length}${ie.value.next||ie.canPrevious?`+`:``}`:j(`Not observed`):t?oe.page&&!(`kind`in oe.page)?`${G.length+z.length}${oe.page.next||oe.canPrevious||g?`+`:``}`:j(`Not observed`):`${G.length}${g?`+`:``}`,className:`grow`,actions:(0,_.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-pressed":N,title:j(N?`Back to history`:`Show archived`),"aria-label":j(N?`Back to history`:`Show archived`),onClick:()=>re(e=>!e),children:(0,_.jsx)(Va,{"aria-hidden":`true`})}),children:[N&&(0,_.jsx)(jf,{list:ie,unavailable:S,onBack:()=>re(!1),row:q}),(0,_.jsxs)(`nav`,{"aria-label":j(`Tasks`),className:`task-list`,hidden:N,children:[(G.length>0||z.length>0)&&(0,_.jsxs)(`label`,{className:`lp-filter`,children:[(0,_.jsx)(Ji,{"aria-hidden":`true`}),(0,_.jsx)(`input`,{type:`search`,value:M,placeholder:j(`Filter conversations…`),"aria-label":j(`Filter conversations…`),onChange:e=>ne(e.target.value)}),M&&(0,_.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:j(`Clear filter`),"aria-label":j(`Clear filter`),onClick:()=>ne(``),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]}),S&&G.length>0&&(0,_.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),gf(se,e=>e.updatedAt).map(e=>(0,_.jsxs)(`div`,{className:`lp-time-group`,children:[(0,_.jsx)(`h3`,{className:`lp-time-label`,children:j(Mf[e.key])}),e.items.map(q)]},e.key)),ce.length>0&&(0,_.jsx)(`h3`,{className:`lp-time-label`,children:j(`Tasks`)}),ce.map(e=>(0,_.jsxs)(`div`,{children:[(0,_.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,_.jsx)(`span`,{className:`session-icon`,children:(0,_.jsx)(ra,{"aria-hidden":`true`})}),(0,_.jsxs)(`span`,{className:`session-info`,children:[(0,_.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,_.jsx)(`span`,{className:`session-sub`,children:j(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&B]},e.owner.taskId)),se.length===0&&ce.length===0&&(G.length>0||z.length>0)&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`No listed conversation matches. Pages not loaded are not searched.`)}),oe.page&&!(`kind`in oe.page)&&z.length===0&&G.length===0&&!g&&(0,_.jsx)(`p`,{className:`panel-hint`,children:j(`No conversations yet.`)}),v,t&&(0,_.jsx)(Fs,{pager:oe,compact:!0})]}),!N&&!ce.some(e=>e.owner.taskId===r)&&B]})]})}var Lf=[`queued`,`running`];function Rf(e){let t=(0,m.useRef)({client:e.client,generation:0});return t.current.client!==e.client&&(t.current={client:e.client,generation:t.current.generation+1}),(0,_.jsx)(zf,{...e},`${t.current.generation}:${e.agent.runId}:${e.agent.stepId??``}`)}function zf({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=D(),[s,c]=(0,m.useState)(1e3),l=Oo(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,f=d?Lf.includes(d.status):!1;(0,m.useEffect)(()=>{u&&!Lf.includes(u.status)&&c(0)},[u]);let p=Oo(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,f||!u?1e3:0),h=p.value?.kind===`workflow-transcript`?p.value.turn:null,g=(0,m.useMemo)(()=>h?Mu(h):null,[h]),[v,y]=(0,m.useState)(!1),b=Oo(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null,v&&f?1e3:0),x=(0,m.useRef)(null),S=(0,m.useRef)(!0),C=(0,m.useRef)(null);return rc(x,C,S),(0,m.useEffect)(()=>{g&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[g]),(0,_.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,_.jsx)(wa,{"aria-hidden":`true`}),(0,_.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,_.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,_.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,_.jsx)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:(0,_.jsxs)(`div`,{ref:C,children:[l.error&&(0,_.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,_.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,_.jsx)(Cd,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&p.error&&(0,_.jsx)(`p`,{role:`alert`,children:p.error}),t.stepId&&(g?(0,_.jsx)(id,{turn:g}):(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,_.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,_.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,_.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,_.jsx)(ws,{text:d.text}):(0,_.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,_.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,_.jsx)(`button`,{type:`button`,className:`ghost`,"aria-expanded":v,onClick:()=>y(e=>!e),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,_.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,_.jsx)(`p`,{role:`alert`,children:b.error})]})]})})]})}function Bf({path:e,disabled:t=!1,onClick:n}){let{t:r}=D(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,_.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,_.jsx)(ga,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Vf({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=D(),o=r||t||n;return!e&&!o?null:(0,_.jsxs)(_.Fragment,{children:[e&&(0,_.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,_.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,_.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,_.jsxs)(`p`,{role:`status`,children:[(0,_.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,_.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,_.jsxs)(`details`,{children:[(0,_.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,_.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,_.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,_.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function Hf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=xo();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:K(e)});if(n&&(a.set(`scope`,JSON.stringify(ze(n.scope))),n.snapshotSeq&&a.set(`snapshot`,se(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function Uf(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=K(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?ze(ue(r)):void 0,o=i?se(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=Ve(ue(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Wf=`cadence-panel-layout-v1`,Gf={left:260,right:360,navigation:!0,inspector:!1};function Kf(e,t=600){return Math.max(220,Math.min(t,e))}function qf(e){let t={...Gf};try{let n=JSON.parse(e??`null`);if(!n||typeof n!=`object`||Array.isArray(n))return t;for(let e of[`left`,`right`]){let r=n[e];typeof r==`number`&&Number.isFinite(r)&&(t[e]=Kf(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Jf(e,t){let n=e<=900,r=Kf(t.left,e-560),i=Kf(t.right),a=t.navigation?r:0,o=!n&&e-a-i<560,s=t.inspector&&!o?i:0;return{mobile:n,left:r,right:i,rightOverlay:o,leftMaximum:Kf(e-560-s),rightMaximum:Kf(e-560-a)}}function Yf({side:e,width:t,onResize:n,maximum:r}){let{t:i}=D(),a=(0,m.useRef)(void 0);return(0,m.useEffect)(()=>()=>a.current?.(),[]),(0,_.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Kf(Number(e.target.value),r)),className:`resize-handle`,tabIndex:0,"aria-orientation":`horizontal`,"aria-label":i(e===`left`?`Resize left pane`:`Resize right pane`),"aria-valuemin":220,"aria-valuemax":r,"aria-valuenow":t,onDoubleClick:()=>n(Kf(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Kf(t+(i.clientX-o)*(e===`left`?1:-1),r))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),a.current=void 0};a.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}var Xf=[],Zf={error:Ua,warning:Ha,info:ua};function Qf({toast:e}){let{t}=D(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=n||i,s=os(e.level);(0,m.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>ms(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Zf[e.level];return(0,_.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,_.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,_.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>ms(e.id),children:(0,_.jsx)(zi,{"aria-hidden":`true`})})]})}function $f(){let e=(0,m.useSyncExternalStore)(gs,_s,()=>Xf);return(0,_.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,_.jsx)(Qf,{toast:e},e.id))})}function ep(e,t,n,r){(0,m.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 tp=.4,np=1.05;function rp(e){return Math.min(300,e*.86)}function ip(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function ap(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function op(e,t){return e===`left`?t:-t}function sp(e,t){return Math.max(-e,Math.min(0,-e+t))}function cp(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function lp(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:cp(r*np,n,t)>=tp}var up=new Set([`auto`,`scroll`,`overlay`]);function dp(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&up.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function fp(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function pp(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,m.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=ip(r.clientX,window.innerWidth,n);i&&!dp(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=ap(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=rp(window.innerWidth),h=m*np;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=op(r,d);let b=sp(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(cp(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?lp({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(fp(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}var mp={system:[ea,`System`],light:[Ui,`Light`],dark:[$i,`Dark`]};function hp({panels:e,navigation:t,inspector:n,inspectorLabel:r,inspectorTabs:i,toolbar:a,actions:o,notices:s,status:c,folder:l,onRefresh:u,onDisconnect:d,onOpenService:f,content:p}){let{t:h,locale:g,setLocale:v}=D(),[y,b]=(0,m.useState)(M),[x,S]=mp[y],w=h(`Theme: {current}. Switch to {next}.`,{current:h(S),next:h(mp[N(y)][1])}),{mobile:T,overlay:E,closeDrawer:O}=e,k=(0,m.useRef)(null),A=(0,m.useRef)(null),ee=()=>{A.current&&(A.current.open=!1)};return pp({enabled:T,open:E,onOpenChange:e.setDrawer,container:k}),ep(k,E,!!E,O),(0,_.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,_.jsxs)(`header`,{className:`topbar`,children:[(0,_.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":h(`Toggle conversation navigation`),"aria-expanded":T?E===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,_.jsx)(ia,{"aria-hidden":`true`})}),(0,_.jsxs)(`div`,{className:`topbar-flow`,children:[(0,_.jsxs)(`span`,{className:`brand`,children:[(0,_.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,_.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,_.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,_.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,_.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:g===`zh`?`en`:`zh-CN`,"aria-label":g===`zh`?`Switch to English`:`切换到中文`,"data-tip":g===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(g===`zh`?`en`:`zh`),children:[(0,_.jsx)(ma,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:g===`zh`?`EN`:`中文`})]}),(0,_.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":w,"data-tip":w,onClick:()=>{let e=N(y);ne(e),b(e)},children:(0,_.jsx)(x,{"aria-hidden":`true`})}),(0,_.jsxs)(`details`,{className:`more-menu`,ref:A,onKeyDown:e=>{e.key===`Escape`&&A.current&&(A.current.open=!1,A.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,_.jsx)(`summary`,{className:`chip`,"aria-label":h(`More`),title:h(`More`),children:(0,_.jsx)(Qi,{"aria-hidden":`true`})}),(0,_.jsxs)(`div`,{className:`more-menu-items`,children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Observe current state`),onClick:()=>{ee(),u()},children:[(0,_.jsx)(Xi,{"aria-hidden":`true`}),h(`Refresh status`)]}),f&&(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Cadence service`),onClick:()=>{ee(),f()},children:[(0,_.jsx)(qi,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`more-menu-text`,children:[h(`Cadence service`),(0,_.jsx)(`small`,{children:h(`Version, restart and upgrade.`)})]})]}),d&&(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Disconnect this page`),title:h(`Return — accepted work continues`),onClick:()=>{ee(),O(),d()},children:[(0,_.jsx)(oa,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`more-menu-text`,children:[h(`Disconnect this page`),(0,_.jsx)(`small`,{children:h(`Started work keeps running.`)})]})]}),(0,_.jsx)(`div`,{className:`more-menu-build`,title:so?.buildId??h(`unbuilt source`),children:(0,_.jsx)(C,{text:h(`Local browser build: {build}.`),slots:{build:(0,_.jsx)(`code`,{children:so?.buildId??h(`unbuilt source`)})}})})]})]})]})]}),(0,_.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":h(`Toggle workspace panels`),"aria-expanded":T?E===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,_.jsx)(Ki,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:r??h(`Files`)})]})]}),s,(0,_.jsxs)(`div`,{ref:k,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,_.jsx)(`button`,{type:`button`,"aria-label":h(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${E?` on`:``}`,onClick:O}),(0,_.jsx)(`section`,{className:`panel-drawer drawer-left${E===`left`?` open`:``}`,"aria-label":h(`Conversation navigation`),tabIndex:-1,inert:T?E!==`left`:!e.navigation||E===`right`,children:t}),(0,_.jsx)(Yf,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,_.jsx)(`main`,{className:`main`,inert:E!==null,children:p}),(0,_.jsx)(Yf,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,_.jsx)(`section`,{className:`panel-drawer drawer-right${E===`right`?` open`:``}`,"aria-label":h(`Files and history drawer`),tabIndex:-1,inert:T?E!==`right`:!e.inspector,children:(0,_.jsxs)(`div`,{className:`workbench-right`,children:[(0,_.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":h(`Workspace panels`),children:[i??(0,_.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,_.jsx)(ga,{"aria-hidden":`true`}),h(`Files`)]}),(0,_.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":h(`Collapse panel`),title:h(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,_.jsx)(Ma,{"aria-hidden":`true`})})]}),n]})})]}),(0,_.jsxs)(`footer`,{className:`statusbar`,children:[(0,_.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,_.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,_.jsx)($f,{})]})}function gp(e){let t=Math.max(0,e.input),n=Math.max(0,e.read),r=Math.max(0,e.write),i=t+n+r;return{totalInput:i,miss:t,read:n,write:r,hitRate:i>0?Math.min(n/i,1):0}}function _p({cache:e}){let{t}=D(),n=e?gp(e):void 0,r=n&&n.totalInput>0?n:void 0,i=r?`${(r.hitRate*100).toFixed(1)}%`:`—`,a=r?r.hitRate>=.7?` ok`:r.hitRate>=.4?` mid`:` warn`:``,o=r?`${t(`Cache hit: {rate} · read {read} · write {write} · miss {miss} (of {input} input tokens)`,{rate:i,read:Pc(r.read),write:Pc(r.write),miss:Pc(r.miss),input:Pc(r.totalInput)})} ${t(`Summed over every usage record of this session, on every branch.`)}`:t(`Cache hit: this session's usage records state no input tokens yet.`);return(0,_.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,_.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,_.jsx)(Ca,{})}),(0,_.jsxs)(`span`,{className:`bar-item-text`,children:[(0,_.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,_.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var vp=31.42;function yp({usage:e}){let{t}=D(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?Fc(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:Pc(n),window:Pc(r),percent:i}):t(`Context {used} tokens`,{used:Pc(n)}):t(`Context size not observed yet`),o=e?[t(`Context size as of the last completed model response ({model}). Messages after that response are not counted.`,{model:`${e.provider}/${e.model}`}),n===null?t(`A compaction followed that response, so the size is unknown until the next one.`):r?``:t(`The model list states no context window for this model, so no percentage is shown.`)].filter(Boolean).join(` `):t(`No completed model response is within reach of this branch's end, so no context size is stated.`),s=(0,_.jsxs)(`svg`,{className:`ctx-ring${i===null?``:i>=80?` warn`:i>=50?` mid`:` ok`}`,viewBox:`0 0 14 14`,width:`13`,height:`13`,"aria-hidden":`true`,children:[(0,_.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,_.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:vp,strokeDashoffset:+(vp*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,_.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,_.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,_.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,_.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`ctx-val`,children:Pc(n)}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,_.jsx)(`span`,{className:`ctx-max`,children:Pc(r)})]})]})})]})}function bp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,_.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,_.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,_.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,_.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function xp({dot:e,tip:t,latency:n,children:r}){let{t:i}=D(),a=n===null?t:`${i(`Network latency: {ms}ms (the fastest request to the service in the last minute, from sending to the first byte of its reply).`,{ms:n})} ${t}`;return(0,_.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,_.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,_.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function Sp(e){let t=Math.max(0,Math.floor(e/1e3)),n=e=>String(e).padStart(2,`0`);return t<3600?`${Math.floor(t/60)}:${n(t%60)}`:`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`}function Cp({since:e,label:t}){let[n,r]=(0,m.useState)(Date.now);(0,m.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?Sp(n-e):``;return(0,_.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,_.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,_.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function wp(){let[e,t]=(0,m.useState)(()=>{try{return qf(localStorage.getItem(Wf))}catch{return qf(null)}}),[n,r]=(0,m.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,m.useState)(null);(0,m.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=Jf(n,e),s=(0,m.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Wf,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,m.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}function Tp(e,t,n,r,i=`en`){let a=(e,t)=>b(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`)} · ${b(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 Ep=`modulepreload`,Dp=function(e){return`/`+e},Op={},kp=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=Dp(t,n),t=s(t),t in Op)return;Op[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`:Ep,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 Ap({client:e,seed:t,onSearch:n}){let{t:r}=D(),i=Xo(e,{...t,reader:`events`}),a=i.page;return(0,_.jsxs)(`section`,{className:`timeline-view`,children:[(0,_.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,_.jsx)(Fs,{pager:i}),a&&!(`kind`in a)&&(0,_.jsx)(jp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function jp({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=D(),o=(0,m.useRef)(null),[s,c]=(0,m.useState)(!1),[l,u]=(0,m.useState)(!1),d=(0,m.useRef)(r);return d.current=r,(0,m.useEffect)(()=>{let e=!1,r;return kp(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,Tp(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,_.jsxs)(_.Fragment,{children:[l&&(0,_.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,_.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,_.jsx)(Is,{client:e,seed:t})]})}var Mp=[[`tools`,Vi],[`context`,la],[`timeline`,ka],[`runs`,ha]];function Np({api:e,onOpenProject:t,homeFolder:n,projectEntries:r,notices:i,discovery:a,onOpenService:o,project:s,onChooseFolder:c,onPrepareExecution:l,directoryNamespaces:u,previewModels:d,initialDraft:f,onDraftApplied:p}){let{t:h,tx:g}=D(),[v]=(0,m.useState)(()=>e??co()),[y,b]=(0,m.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,m.useState)(!1),[C]=(0,m.useState)(Uf),[w,T]=(0,m.useState)(C?.taskId??null),[E,O]=(0,m.useState)(()=>C?null:So()??crypto.randomUUID()),k=wo(y,E??``),[A,ee]=(0,m.useState)(null),[j,te]=(0,m.useState)([]),[M,ne]=(0,m.useState)(null),[N,re]=(0,m.useState)(C?`task`:`files`),[ie,P]=(0,m.useState)(),[ae,F]=(0,m.useState)(),[oe,I]=(0,m.useState)(),[L,R]=(0,m.useState)(),[z,B]=(0,m.useState)(0),[V,H]=(0,m.useState)(()=>{let e=typeof history>`u`?null:history.state,t=So();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[U]=(0,m.useState)(()=>crypto.randomUUID()),W=(0,m.useCallback)(()=>F(void 0),[]),[G,K]=(0,m.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),q=Bo(s?.id,s?.epoch),se=!s||q.readiness===`running`,ce=!!s&&(q.readiness===`stopped`||q.readiness===`not-started`),le=(0,m.useRef)(null);se&&q.value?.epoch&&(le.current=q.value.epoch);let ue=!s||!ce&&(se||le.current!==null),Y=Uo(v,w?{kind:`task`,id:w}:null,!x&&ue,le.current),de=(0,m.useRef)(!0);(Y.workspace||Y.observation||Y.error||Y.transportStatus===`stale`)&&(de.current=!1);let fe=!!(s&&(q.value||q.error)),pe=!x&&!!(Y.workspace||fe),me=(0,m.useRef)(null);(Y.workspace||q.value?.workspaceId)&&(me.current=Y.workspace?.workspaceId??q.value?.workspaceId??null);let he=e=>l?async(t,n,r)=>{let i=await l(e,t,n,r);if(t.aborted)throw Error(`stale`);q.prepared(i);let a=Y.reconnect();await Y.whenReady(i,t,a)}:void 0,ge=he(`send`),_e=he(`plan-validation`),ve=Ao(v.client,pe),ye=Oo(v.client,Y.workspace&&!x?{kind:`conversation-active`}:null,1e3),be=ye.value?.kind===`conversation-active`?ye.value.entries:[],xe=[...be,...(ve.value?.entries??[]).filter(e=>!be.some(t=>t.id===e.id))],Se=Oo(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),Ce=Se.value?.kind===`workflow-active`?Se.value:void 0,we=(0,m.useMemo)(()=>[...new Set([...Ce?.runs.map(e=>e.id)??[],...j])],[Ce,j]),Te=Oo(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),Ee=V??s?.cwd??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0),De=oe?.id===E?oe:void 0,Oe=L?.id===E?L:void 0,ke=yo();(0,m.useEffect)(()=>{De&&So()===De.id&&history.replaceState({...history.state,cadenceCwd:De.cwd,cadenceConversationId:De.id},``,location.href)},[De]);let Ae=E?De:Ee?{id:U,cwd:Ee}:void 0,je=De?.cwd??Ee??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0)??Y.workspace?.rootLabel,Me={state:Y.observation,transportStatus:Y.transportStatus,error:Y.error,refresh:Y.refresh},Ne=Me.state?.snapshot.scope.kind===`task`&&Me.state.snapshot.scope.id===w?Me.state.snapshot.context:void 0,Pe=wp(),{closeDrawer:Fe}=Pe,Ie=N===`branches`&&!!E,Le=!Ie&&(N!==`task`||!G),Re=()=>{re(`branches`),Pe.mobile?Pe.setDrawer(`right`):Pe.inspector||Pe.toggle(`right`)},[ze,Be]=(0,m.useState)(C?.snapshotSeq),[Ve,He]=(0,m.useState)(``),[X,Ue]=(0,m.useState)(``),We=(0,m.useRef)(null),[Ge,Ke]=(0,m.useState)(`messages`),[qe,Je]=(0,m.useState)(!1),[Z,Ye]=(0,m.useState)(!1),[Xe,Ze]=(0,m.useState)(),[Qe,$e]=(0,m.useState)(C?.cursor),[et,tt]=(0,m.useState)(``),[nt,rt]=(0,m.useState)([]),[it,at]=(0,m.useState)(new Set),ot=(0,m.useRef)(!0),st=e=>{ot.current&&rt(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?Do(t,e):t)})},ct=(0,m.useRef)(new Wo),lt=J({taskId:w,scope:G,selectedSnapshot:ze??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ct.current.select(lt),(0,m.useEffect)(()=>(ot.current=!0,()=>{ot.current=!1,ct.current.depart()}),[]);let ut=e=>{b(``);let t=e??crypto.randomUUID();e||H(je??Ee),ee(null),t!==E&&(te([]),F(void 0)),ct.current.depart(),O(t),T(null),K(null),He(``),Ue(``),Ze(void 0),$e(void 0),Be(void 0),Ke(`messages`),re(e=>e===`task`?`files`:e),Fe();let n=t===E?wo(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${To(`#chat=${t}`,n)}`)};(0,m.useEffect)(()=>{E&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${E}`)},[E]);let dt=(e,t)=>{ee(null),te([]),O(null),re(`task`),He(t??``),Ue(``),Be(void 0),ct.current.depart(),T(e),K({kind:`task`,id:e}),Ze(void 0),$e(void 0),Ke(`messages`),Fe(),history.replaceState(null,``,Hf(e))};(0,m.useEffect)(()=>{let e=()=>{let e=Uf();if(e)ee(null),te([]),O(null),re(`task`),ct.current.depart(),Be(e.snapshotSeq),He(``),Ue(``),T(e.taskId),K(e.scope??{kind:`task`,id:e.taskId}),Ze(void 0),$e(e.cursor),Ke(`messages`),Fe();else{let e=So();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&H(t),F(void 0),ee(null),te([]),O(e),T(null),K(null),re(e=>e===`task`?`files`:e),ct.current.depart(),Fe()}}};return window.addEventListener(`hashchange`,e),window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`hashchange`,e),window.removeEventListener(`popstate`,e)}},[Fe]);let Q=(e,t,n)=>{ee(null),Be(t),Ue(n??``),ct.current.depart(),K(e),Ze(void 0),$e(void 0),Ke(`messages`),Fe(),w&&history.replaceState(null,``,Hf(w,void 0,{scope:e,snapshotSeq:t}))},ft=ze??Me.state?.snapshot.committedSeq??Y.workspace?.committedSeq,pt=Y.workspace?.storeId,mt=G&&pt&&ft?{storeId:pt,scope:G,snapshotSeq:ft,reader:`messages`,after:null,limit:50}:null,ht=G&&pt&&ft?{storeId:pt,scope:G,snapshotSeq:ft,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,gt=Ne?Me.state?.snapshot.runs??[]:[],_t=ct.current.ticket(),vt=e=>{st(e),e.receipt&&ct.current.current(_t)&&Y.refresh()},yt=e=>{if(it.has(e)||!Y.attached||!Y.activeRuns)return;let t=crypto.randomUUID(),n=Y.activeRuns.epoch;at(t=>new Set(t).add(e)),st({commandId:t,error:h(`Stop requested; settlement is not yet confirmed.`)}),v.client.cancel({commandId:t,epoch:n,runId:e}).then(e=>{vt(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:h(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>st({commandId:t,error:h(`Cancellation effect uncertain. Observe exact receipt.`)})).finally(()=>{ot.current&&at(t=>{let n=new Set(t);return n.delete(e),n})})};if(x)return(0,_.jsxs)(`main`,{className:`entry`,children:[(0,_.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h1`,{children:h(`Detached`)}),(0,_.jsx)(`p`,{children:h(`Accepted service work continues. No Cancel was requested.`)}),nt.map(e=>(0,_.jsxs)(`p`,{children:[h(`Observe command after reconnect:`),` `,(0,_.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,_.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:h(`Reconnect as a viewer`)})]});let bt=Y.activeRuns,xt=bt?.status===`complete`?bt.runs:[],St=!x&&!Y.error&&Y.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`),Ct=se&&St,wt=se&&!!Y.workspace&&Y.attached&&!Y.error&&St,Tt=de.current&&!Me.state&&!Me.error&&!q.error&&(!s||!q.value&&q.readiness===`unknown`||q.readiness===`running`),Et=ce?{status:q.readiness===`not-started`?`not-started`:`stopped`}:se&&St&&Y.attached&&Y.epoch&&(!s||q.value?.epoch===Y.epoch)?{status:`ready`,epoch:Y.epoch,attachmentVersion:Y.attachmentVersion}:{status:Tt?`connecting`:`unavailable`},Dt=x?`Viewer disconnected`:Tt?`Connecting…`:s&&q.readiness===`unknown`?`Project readiness unknown`:s&&q.readiness===`stale`?`Project observation stale`:ce?`Ready to prepare execution`:St?Y.workspace?Me.state?.connection??(w?`Task snapshot not observed yet`:`Chat ready`):`Viewer observation unavailable`:`Viewer observation stale`,Ot=Tt?`busy`:ce?``:!Ct||!Y.workspace?`error`:Me.transportStatus===`current`&&(!Me.state||Me.state.connection===`current`)?`ok`:`busy`;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(hp,{panels:Pe,onOpenService:o,onRefresh:()=>{Y.refresh(),q.refresh()},onDisconnect:()=>{Je(!1),Ye(!1),ct.current.depart(),S(!0)},inspectorLabel:h(G&&N===`task`?`History details`:Ie?`Branches`:`Files`),toolbar:G&&(0,_.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":h(`Recorded views`),children:[(0,_.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ge===`messages`&&!Qe,onClick:()=>{$e(void 0),Ze(void 0),Ke(`messages`)},children:[(0,_.jsx)(ra,{"aria-hidden":`true`}),h(`Conversation`)]}),(0,_.jsxs)(`details`,{className:`view-menu`,ref:We,onKeyDown:e=>{e.key===`Escape`&&We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,_.jsxs)(`summary`,{className:`chip`,children:[Ge===`messages`?h(`Details`):g(Ge),(0,_.jsx)(Pa,{"aria-hidden":`true`})]}),(0,_.jsxs)(`div`,{className:`view-menu-items`,children:[Mp.map(([e,t])=>(0,_.jsxs)(`button`,{type:`button`,"aria-pressed":Ge===e,onClick:()=>{$e(void 0),Ze(void 0),Ke(e),We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus())},children:[(0,_.jsx)(t,{"aria-hidden":`true`}),g(e)]},e)),(0,_.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Export selected scope`),disabled:!mt,onClick:()=>{We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus()),Ye(!0)},children:[(0,_.jsx)(Sa,{"aria-hidden":`true`}),h(`Export selected scope`)]}),(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Copy token-free link`),disabled:!w,onClick:()=>{w&&$o(Hf(w,Qe,G?{scope:G,snapshotSeq:ze}:void 0)).then(e=>e?ps(`info`,h(`Link copied.`)):ps(`error`,h(`Link copy unavailable.`)))},children:[(0,_.jsx)(ca,{"aria-hidden":`true`}),h(`Copy token-free link`)]})]})]})]})]}),actions:G&&(0,_.jsx)(Ys,{disabled:!ht,onOpen:()=>Je(!0)}),notices:(0,_.jsxs)(_.Fragment,{children:[!Y.workspace&&xt.length>0&&(0,_.jsx)(`section`,{className:`run-strip`,"aria-label":h(`Execution and cancellation`),children:xt.map(e=>(0,_.jsxs)(`div`,{className:`run-strip-row`,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`run-strip-label`,children:[g(e.kind),` `,e.runId,` · `,g(e.stage)]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>dt(e.taskId),children:h(`Open active task`)}),(0,_.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.attached||it.has(e.runId),onClick:()=>yt(e.runId),children:[(0,_.jsx)(Wi,{"aria-hidden":`true`}),h(`Cancel run — request stop`)]})]},e.runId))}),i,(0,_.jsx)(Vf,{error:et,projectObservationError:q.error,observationError:Y.error,unavailable:!Tt&&!ce&&!Ct,onRefresh:()=>{Y.refresh(),q.refresh()}})]}),navigation:(0,_.jsxs)(_.Fragment,{children:[!pe&&(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,_.jsx)(dc,{...a}),(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:h(Tt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,_.jsx)(If,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:ce,taskId:w,scope:G,runs:gt,snapshot:Me.state?.snapshot.committedSeq,activeRuns:Y.activeRuns,canCancel:Y.attached,canceling:it,onCancel:yt,chats:xe,chatActivityKnown:ye.value?.kind===`conversation-active`&&!ye.error,chatHistoryPartial:ve.loading||ve.canPrevious||!!ve.value?.next,chatHistoryControls:(0,_.jsxs)(_.Fragment,{children:[ve.error&&(0,_.jsx)(`p`,{role:`alert`,children:ve.error}),ve.loading&&(0,_.jsx)(`p`,{className:`panel-hint`,children:h(`Reading conversation history…`)}),ve.canPrevious&&(0,_.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.previous,children:h(`Newer conversations`)}),ve.value?.next&&(0,_.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.next,children:h(`Older conversations`)}),ve.canPrevious&&(0,_.jsx)(`button`,{type:`button`,onClick:ve.first,children:h(`Latest conversations`)}),ve.error&&(0,_.jsx)(`button`,{type:`button`,onClick:ve.refresh,children:h(`Observe current state`)})]}),conversationId:E,onConversation:ut,onNewConversation:()=>ut(),actionsUnavailable:wt?``:h(ce?`Rename and archive need the execution service; it starts with your next Send.`:`Rename and archive are unavailable until the execution service is observed.`),onConversationsChanged:e=>{ve.refresh(),e===E&&B(e=>e+1)},workflows:Ce?.runs,workflowLinks:Ce?.links,workflowError:!!Se.error,selectedWorkflow:A?.runId,onWorkflow:(e,t)=>{t?ut(t):(ee({runId:e.id,stepId:null,label:e.goal}),Fe())},onCancelWorkflow:async e=>{tt(await Sd(v.client,e)),Se.refresh()},onTask:dt,onScope:Q}),Y.workspace&&(0,_.jsx)(Ec,{client:v.client,active:Y.activeRuns,taskId:w,runs:gt,snapshot:ft,workflowRuns:we,selected:A,onOpenWorkflow:e=>{ee(e),Fe()},onOpen:(e,t,n,r)=>{dt(e),K({kind:`child`,id:t}),Ue(r),Be(n),history.replaceState(null,``,Hf(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,_.jsxs)(_.Fragment,{children:[E&&s&&!fe&&(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:h(`Reading this conversation…`)}),A&&(0,_.jsx)(Rf,{client:v.client,agent:A,backLabel:h(E?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>ee(null),onOpenAgent:ee},`${A.runId}:${A.stepId??``}`),E&&(!s||fe)&&(0,_.jsx)(Id,{client:v.client,id:E,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Ee,onLocation:I,onActivity:R,hidden:!!A,onOpenAgent:ee,onWorkflowRuns:te,onBranches:P,onOpenBranches:Re,workspaceId:s?`checkout:${s.path}`:me.current??`connecting`,directoryNamespaces:u,legacyWorkspaceId:s?q.value?.workspaceId??void 0:void 0,prepareForSend:ge,prepareForPlan:_e,actionsReady:wt,observe:z,available:pe,canInterrupt:Y.attached,enabled:ge?pe:!!Y.workspace&&Y.attached&&!Y.error,modelAvailability:Et,previewModels:d,initialDraft:f?.conversationId===E?f:void 0,onDraftApplied:()=>p?.(E),onModelChanged:()=>{ct.current.depart(),Y.refresh(),q.refresh()},onChanged:()=>{ve.refresh(),Y.refresh()},reference:ae,onReferenceUsed:W},`${s?.id??me.current??`connecting`}:${E}:${k.leaf??``}`),G&&!A&&(0,_.jsxs)(`header`,{className:`conversation-header`,children:[(0,_.jsxs)(`div`,{className:`conversation-heading`,children:[G.kind!==`task`&&w&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>dt(w,Ve),children:h(`Back to task`)}),(0,_.jsx)(`h2`,{title:Ve||G.id,children:G.kind===`task`?Ve||h(`Task {id}`,{id:G.id.slice(0,8)}):X||h(`{kind} {id}`,{kind:g(G.kind),id:G.id.slice(0,8)})}),G.kind===`child`&&(0,_.jsx)(`span`,{className:`conversation-badge`,children:h(`Subagent`)})]}),(0,_.jsxs)(`details`,{className:`conversation-info`,children:[(0,_.jsxs)(`summary`,{children:[h(`Recorded conversation`),` ·`,` `,h(`snapshot {seq}`,{seq:ft??``})]}),(0,_.jsx)(`code`,{children:G.id}),(0,_.jsx)(`p`,{children:h(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,_.jsxs)(`div`,{className:`workspace-content`,hidden:!!E||!!A,children:[!mt&&(0,_.jsxs)(`section`,{className:`empty-state`,children:[(0,_.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,_.jsx)(`h2`,{children:Y.error?h(`Recorded history could not be read.`):h(`Reading recorded history…`)}),(0,_.jsx)(`p`,{children:h(`History is readonly. Start new work in a conversation with /cadence.`)})]}),mt&&Qe?(0,_.jsxs)(`div`,{className:`tab-body`,children:[Xe&&(Xe.owner.entity.kind===`task`||Xe.owner.entity.kind===`message`||Xe.owner.entity.kind===`tool`)&&(0,_.jsx)(Ls,{client:v.client,seed:{storeId:Qe.storeId,scope:Qe.scope,snapshotSeq:Qe.snapshotSeq,kind:Xe.owner.entity.kind,id:Xe.owner.entity.id,version:Xe.owner.entity.version}},`${Xe.owner.entity.id}:${Xe.owner.entity.version}`),(0,_.jsx)(Ps,{client:v.client,cursor:Qe,highlight:Xe?.range},`${Qe.recordId}:${Qe.recordVersion}`)]}):mt&&(0,_.jsxs)(`div`,{className:Ge===`messages`||Ge===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ge===`messages`&&(0,_.jsx)(sc,{client:v.client,seed:mt}),Ge===`tools`&&(0,_.jsx)(Pp,{client:v.client,seed:mt}),Ge===`context`&&(0,_.jsx)(Is,{client:v.client,seed:mt}),Ge===`timeline`&&(0,_.jsx)(Ap,{client:v.client,seed:mt,onSearch:()=>Je(!0)}),Ge===`runs`&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`run-current`,children:[(0,_.jsx)(`h3`,{children:h(`Runs in the current snapshot`)}),gt.length>0?gt.map(e=>(0,_.jsx)(Gs,{run:e},e.childRunId??e.runId)):(0,_.jsx)(`p`,{className:`panel-empty`,children:Ne&&Me.state?h(`No owner run projection in this snapshot.`):h(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,_.jsx)(`h3`,{children:h(`Retained runs`)}),(0,_.jsx)(Js,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}},onScope:Q},w)]})]},`${G?.kind}:${G?.id}:${ze??`current`}`)]}),Y.workspace&&nt.length>0&&(0,_.jsx)(`div`,{className:`receipt-dock`,children:nt.map(e=>(0,_.jsx)(Go,{client:v.client,value:e,onChange:st},e.commandId))})]}),inspectorTabs:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Le,onClick:()=>re(`files`),children:[(0,_.jsx)(ga,{"aria-hidden":`true`}),h(`Files`)]}),E&&(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>re(`branches`),children:[(0,_.jsx)(ha,{"aria-hidden":`true`}),h(`Branches`)]}),G&&(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!mt,onClick:()=>re(`task`),children:[(0,_.jsx)(la,{"aria-hidden":`true`}),h(`History details`)]})]}),inspector:Ie?(0,_.jsx)(Mc,{view:ie?.id===E?ie:void 0,onChosen:Fe}):Le?(0,_.jsx)(Zd,{location:Ae,client:v.client,enabled:pe&&!!Ae,observed:`${q.readiness}:${q.value?.epoch??``}`,onReference:e=>{E||ut(U);let t=!E&&Ae?`${Ae.cwd.replace(/[\\/]+$/,``)}${Ae.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;F(t),Fe()}},Ae?.cwd??`owner`):mt?(0,_.jsx)(cf,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}}},w):(0,_.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?h(`Recorded history could not be read.`):h(`Reading recorded history…`)}),status:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(xp,{tip:h(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:g(Dt)}),s&&(0,_.jsx)(bp,{tone:`faint`,icon:(0,_.jsx)(qi,{}),children:h(`Execution service: {status}`,{status:g(q.readiness)})}),Oe&&(0,_.jsx)(yp,{usage:Oe.context}),Oe&&(0,_.jsx)(_p,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,_.jsx)(bp,{icon:(0,_.jsx)(ra,{}),tip:h(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,_.jsx)(Cp,{since:Oe.runningSince,label:h(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,_.jsx)(bp,{tone:`warn`,children:h(Ct?xt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:xt.length})}):!Tt&&!ce&&(0,_.jsx)(bp,{tone:`faint`,children:h(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,_.jsx)(Bf,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,_.jsx)(ff,{onOpen:t,projects:r??(Te.value?.kind===`projects`?Te.value.entries:[]),client:v.client,current:je??Y.workspace.rootLabel,initial:M||void 0,home:n,epoch:Y.workspace.epoch,onClose:()=>ne(null)}),qe&&ht&&(0,_.jsx)(Ws,{client:v.client,seed:ht,onClose:()=>Je(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,Hf(w,e.cursor,G?{scope:G,snapshotSeq:ze}:void 0))}}),Z&&ht&&(0,_.jsx)(Vs,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function Pp({client:e,seed:t}){let n=Xo(e,{...t,reader:`tools`}),r=n.page;return(0,_.jsxs)(`section`,{className:`tools-list`,children:[(0,_.jsx)(Fs,{pager:n}),(0,_.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,_.jsx)(lc,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var Fp=`cadence:folder-draft`,Ip=()=>({text:``,model:null});function Lp(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Ip();let t=null;try{e.model!=null&&(t=ge(e.model))}catch{}return{text:e.text,model:t}}catch{return Ip()}}function Rp(e){try{e.text||e.model?sessionStorage.setItem(Fp,JSON.stringify(e)):sessionStorage.removeItem(Fp)}catch{}}function zp(e,t,n){let r=cl(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(Fp)}catch{}return{...n,conversationId:t}}var Bp=`cadence-last-project`;function Vp(){try{let e=localStorage.getItem(Bp);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Hp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Bp,e)}catch{}}function Up(e){let t=Vp();return t?e.projects.find(e=>e.id===t):void 0}async function Wp(e,t){try{let n=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t});if(!n.ok)return!1;let r=Tn(await jo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Gp(e,t){let n=await fetch(`/workbench/v1/models${e?`?project=${encodeURIComponent(e)}`:``}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t}),r=await jo(n);if(!n.ok)throw Error(Mo(r));return Sn(r)}async function Kp(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await jo(t);if(!t.ok)throw Error(Mo(n));return An(n)}async function qp(e,t,n,r,i){let a={method:`POST`,credentials:`same-origin`,redirect:`error`,signal:r,headers:{"Content-Type":`application/json`,"X-Cadence-CSRF":n.csrf},body:JSON.stringify({...t,epoch:n.epoch})};if(r?.aborted)throw r.reason;let o=fetch(e,a);i?.();let s=await o,c=await jo(s);if(!s.ok)throw No(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(Mo(c));let l=wn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Jp(e,t){let n=await Kp(t);return qp(`/workbench/v1/select`,{path:e},n,t)}async function Yp(e,t,n,r,i){let a=await Kp(n),o=a.projects.find(t=>t.id===e.id);if(!o||o.path!==e.path||o.cwd!==e.cwd)throw Error(`stale`);let s=await qp(t===`send`?`/workbench/v1/prepare-send`:`/workbench/v1/prepare-plan`,{projectId:e.id,commandId:crypto.randomUUID(),...r?{location:r}:{}},a,n,()=>i?.(`dispatched`));if(!s.project.epoch||s.project.id!==e.id||s.project.path!==e.path||s.project.cwd!==e.cwd)throw Error(`stale`);return i?.(`confirmed`),s}async function Xp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Jp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Zp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Qp(e){let t=W(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:K(t.id),source:V(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:pn(t.sessionId),cwd:L(t.cwd,4096,!0),leaf:t.leaf===null?null:L(t.leaf,128,!0),history:V(t.history,[`shared`,`unavailable`]),phase:V(t.phase,Zp),freshness:V(t.freshness,[`current`,`stale`,`unknown`]),observedAt:z(t.observedAt,0),epoch:t.epoch===null?null:K(t.epoch),instance:t.instance===null?null:K(t.instance),executionCwd:t.executionCwd===null?null:L(t.executionCwd,4096,!0)}}function $p(e){let t=W(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:H(t.kind,`activity-discovery`),epoch:K(t.epoch),observedAt:z(t.observedAt,0),completeness:V(t.completeness,[`complete`,`partial`]),unavailable:z(t.unavailable,0,1e4),projects:G(t.projects,128,e=>{let t=W(e,[`path`,`activities`]);return{path:L(t.path,4096,!0),activities:G(t.activities,256,Qp)}})}}async function em(e){let t=qa([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await jo(e);if(!e.ok)throw Error(Mo(n));return $p(n)}finally{t.dispose()}}function tm(e,t){return{...e,completeness:`partial`,unavailable:Math.max(1,e.unavailable),projects:e.projects.map(e=>({...e,activities:e.activities.filter(e=>t-e.observedAt<=12e4).map(e=>({...e,freshness:`unknown`}))})).filter(e=>e.activities.length)}}function nm(e,t,n,r=em){let i=new AbortController,a,o,s=async()=>{try{let a=await r(i.signal);if(i.signal.aborted)return;if(a.epoch!==e)throw n(),Error(`stale`);o=a,t(o,``)}catch(e){if(i.signal.aborted)return;o=o?tm(o,Date.now()):void 0,t(o,e instanceof Error?e.message:`unavailable`)}finally{i.signal.aborted||(a=setTimeout(s,3e3))}};return s(),()=>{i.abort(),clearTimeout(a)}}function rm(e,t){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(``);return(0,m.useEffect)(()=>{if(r(void 0),a(``),e)return nm(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function im({ready:e,previewModels:t,draft:n=Ip(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=D(),d=wp(),[f,p]=(0,m.useState)(!1),h=wl(null,{status:`not-started`},`folder-setup`,t),g=()=>{d.closeDrawer(),a()};return(0,_.jsx)(hp,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,_.jsx)(yf,{disabled:!e,onConversation:g}),l&&(0,_.jsx)(dc,{...l}),(0,_.jsxs)(`section`,{className:`lp-section grow`,children:[(0,_.jsx)(`header`,{className:`lp-section-header`,children:(0,_.jsx)(`span`,{className:`lp-section-title`,children:u(`Conversation history`)})}),(0,_.jsx)(`div`,{className:`lp-section-body`,children:(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,_.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,_.jsx)(`div`,{className:`chat-messages`,children:(0,_.jsxs)(ad,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,_.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:g,children:[(0,_.jsx)(ga,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,_.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,_.jsxs)(`div`,{className:`chat-composer`,children:[(0,_.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,_.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,_.jsx)(au,{scope:`next-conversation`,availability:{status:`not-started`},read:h,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:f,onOpenChange:e=>{e&&h.reread(),p(e)},onChanged:()=>{}}),(0,_.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,_.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,_.jsx)(La,{"aria-hidden":`true`})})]})]})]}),inspector:(0,_.jsx)(`aside`,{className:`panel files-panel`,children:(0,_.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,_.jsx)(bp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,_.jsx)(Bf,{disabled:!e,onClick:g})})}var am=`cadence-recovery-dismissed`,om={reboot:`The machine restarted while Cadence was running. Cadence recovered automatically.`,crash:`Cadence ended unexpectedly last time. It recovered automatically.`,restart:`Cadence ran into a problem and restarted itself.`,storage:`Cadence repaired some incomplete files automatically.`},sm={"released-locks":`Released the previous run's locks.`,"stopped-workers":`Stopped {count} leftover worker processes.`,"stopped-owner":`Stopped the unresponsive previous process.`,"continued-history":`History continues after the last complete entry.`,"archived-history":`Unreadable history was archived and a new one was started.`,"archived-state":`Damaged state was archived; it started afresh.`,"rebuilt-registry":`Rebuilt the project registry.`,"removed-temporaries":`Set aside interrupted temporary files.`};function cm(){try{let e=JSON.parse(localStorage.getItem(am)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function lm(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function um({notices:e,project:t}){let{t:n}=D(),[r,i]=(0,m.useState)(cm),[a,o]=(0,m.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(am,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:lm(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,_.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,_.jsxs)(`span`,{children:[n(om[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,_.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,_.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,_.jsxs)(`li`,{children:[(0,_.jsx)(`strong`,{children:u(e)}),` `,(0,_.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(sm[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var dm={restart:18e4,upgrade:12e5},fm=1e3,pm={"fetch-failed":`The release could not be downloaded; the service kept running.`,"stop-unconfirmed":`The running service did not confirm its orderly stop.`,"install-failed":`The package manager could not install the release.`,"not-ready":`The new service did not become ready.`,refused:`The service manager refused the operation.`,interrupted:`The job ended without reporting.`},mm=e=>e instanceof Error?e.message:`unavailable`;function hm(e,t){if(t.state===`ready`)return t.action===`restart`?e(`Cadence restarted.`):t.version===t.from?e(`Cadence {version} was already installed.`,{version:t.from}):e(`Cadence {version} is running.`,{version:t.version??``});if(t.state===`rolled-back`)return e(`Cadence {to} did not become ready; {version} was reinstalled.`,{to:t.to??``,version:t.version??t.from});if(t.state===`running`)return e(`In progress…`);let n=e(pm[t.reason??`refused`]);return t.action===`restart`?e(`The restart did not finish: {reason}`,{reason:n}):e(`The upgrade did not finish: {reason}`,{reason:n})}function gm(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function _m(e,t){switch(t){case`npm`:return e(`Installation: npm global.`);case`bun`:return e(`Installation: Bun global.`);case`npm-local`:return e(`Installation: npm local.`);case`bun-local`:return e(`Installation: Bun local.`);case`pi-npm`:return e(`Installation: Pi-managed (npm).`);case`pi-bun`:return e(`Installation: Pi-managed (Bun).`);case`pinned`:return e(`Pi pins this package version; change its package declaration explicitly before upgrading.`);case`not-writable`:return e(`This account cannot write the installation; update it in a terminal.`);case`unsupported-install`:return e(`The installation method could not be safely identified; update it using its original installation method.`)}}function vm({epoch:e,csrf:t,onClose:n}){let{t:r}=D(),[i,a]=(0,m.useState)(),[o,s]=(0,m.useState)(``),[c,l]=(0,m.useState)(),[u,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(!1),[h,g]=(0,m.useState)(!1),[v,y]=(0,m.useState)(null),[b,x]=(0,m.useState)(!1),[C,w]=(0,m.useState)(),[T,E]=(0,m.useState)(0);(0,m.useEffect)(()=>{let e=new AbortController;return Fo(e.signal).then(a,t=>{e.signal.aborted||s(mm(t))}),()=>e.abort()},[T]),(0,m.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>dm[e.action])return w(`timeout`);try{let t=await Fo(n.signal);if(t.job?.id===e.id&&t.job.state!==`running`)return w(t.job)}catch(e){if(n.signal.aborted)return;if(e instanceof F||e instanceof Error&&e.message===`invalid`)return w(`changed`);x(!0)}r=setTimeout(i,fm)};return r=setTimeout(i,fm),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Io().then(l,()=>l(`failed`)).finally(()=>E(e=>e+1))},k=n=>{i&&(g(!0),s(``),Lo({action:n.action,from:i.version,to:n.to,work:i.work,epoch:e},t).then(e=>y({job:e,since:Date.now()})).catch(e=>{s(mm(e)),p(!1),E(e=>e+1)}).finally(()=>g(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&gm(C),o=i?.unit;return(0,_.jsxs)(Bs,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,_.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,_.jsxs)(`p`,{role:`status`,children:[(0,_.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(b?`Cadence is starting again…`:`Stopping Cadence…`):r(b?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,_.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,_.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:dm[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):hm(r,C)]}),(0,_.jsx)(`p`,{children:r(C===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,_.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,_.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,_.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,_.jsx)(`footer`,{children:a?(0,_.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,_.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,_.jsxs)(Bs,{title:r(`Cadence service`),onClose:n,children:[(0,_.jsxs)(`section`,{children:[(0,_.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,_.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,_.jsxs)(`label`,{className:`service-confirm`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>p(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,_.jsx)(`p`,{role:`alert`,children:S(r,o)}),(0,_.jsxs)(`footer`,{children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>{d(null),p(!1),s(``)},children:r(`Back`)}),(0,_.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:h||e>0&&!f,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let A=i&&c&&typeof c==`object`?Vn(c.version,i.version)>0:!1;return(0,_.jsxs)(Bs,{title:r(`Cadence service`),onClose:n,children:[i?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`service-info`,children:[(0,_.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,_.jsx)(`p`,{children:_m(r,i.upgrade)}),(0,_.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,_.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:hm(r,i.job)})})]}),i.unit&&(0,_.jsxs)(`section`,{className:`service-info`,children:[(0,_.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,_.jsxs)(_.Fragment,{children:[c===`failed`&&(0,_.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,_.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,_.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):A?c.deprecated?(0,_.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):Rn(i.upgrade)?(0,_.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,_.jsx)(Ra,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,_.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,_.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,_.jsx)(`p`,{role:`alert`,children:S(r,o)})]}):(0,_.jsx)(`p`,{role:o?`alert`:`status`,children:o?S(r,o):r(`Reading the service…`)}),(0,_.jsx)(`footer`,{children:(0,_.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,_.jsx)(Xi,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function ym(){let{t:e}=D(),[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(Lp),[a,o]=(0,m.useState)(),s=(0,m.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,m.useState)(xo),u=(0,m.useCallback)(e=>Gp(c??void 0,e),[c]),[d,f]=(0,m.useState)(null),[p,h]=(0,m.useState)(null),[g,v]=(0,m.useState)(``),[y,b]=(0,m.useState)(``),[x,C]=(0,m.useState)(0),[w,T]=(0,m.useState)(!1),[E,O]=(0,m.useState)(null),k=(0,m.useCallback)(()=>C(e=>e+1),[]),A=rm(t?.epoch,k),ee=(0,m.useRef)(null);(0,m.useEffect)(()=>()=>ee.current?.abort(),[]);let j=(0,m.useRef)(new Map),te=(0,m.useRef)(!c),M=(0,m.useRef)(null),ne=(0,m.useCallback)(()=>{M.current&&(M.current.abort(),M.current=null,O(null))},[]);(0,m.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 jo(t);t.status===400&&Mo(r)===`invalid`?n(null):t.ok?(n(An(r)),b(``)):b(Mo(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,m.useEffect)(()=>{let e=()=>{ee.current?.abort(),ne(),O(null),l(xo())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,m.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=Up(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),Wp(e.id,n.signal).then(t=>{n.signal.aborted||(M.current=null,t?(history.replaceState(null,``,`/app?project=${e.id}`),O(null),l(e.id)):O({status:`unavailable`,path:e.cwd}))})},[t,r]);let N=(0,m.useCallback)((e,n)=>{ne(),O(null),c&&history.state?.cadenceCwd===t?.projects.find(e=>e.id===c)?.cwd&&j.current.set(c,window.location.hash);let a=crypto.randomUUID(),s=!t?.projects.some(e=>e.id===c)&&!n&&!!(r.text||r.model);s?(o(zp(e.path,a,r)),i(Ip())):o(void 0),history.pushState({cadenceCwd:n?.cwd??e.cwd,cadenceConversationId:n?.sessionId},``,`/app?project=${e.id}${n?.sessionId?`#chat=${encodeURIComponent(n.sessionId)}&activity=1${n.leaf?`&leaf=${encodeURIComponent(n.leaf)}`:``}`:s?`#chat=${a}`:j.current.get(e.id)??`#chat=${a}`}`),l(e.id),f(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),re=(0,m.useCallback)(async e=>{ee.current?.abort();let t=new AbortController;ee.current=t;let r=await Jp(e,t.signal);t.signal.aborted||(n(r.entry),N(r.project))},[N]),ie=t?{value:A.value,error:A.error,opening:!!p,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,r)=>{ee.current?.abort(),ne();let i=new AbortController;ee.current=i,h(r.cwd),v(``),Xp(t,r,i.signal).then(e=>{i.signal.aborted||(n(e.entry),N(e.project,r))}).catch(t=>{i.signal.aborted||v(S(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{ee.current===i&&h(null)})}}:void 0,P=async(e,r,i,a)=>{let o=t?.projects.find(e=>e.id===c);if(!o)throw Error(`unavailable`);let s=await Yp(o,e,r,i,a);if(r.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},I=(0,m.useMemo)(()=>({async workbenchRead(e,t){try{if(e.kind!==`directories`)throw new F(`invalid`);let n=await fetch(`/workbench/v1/directories?path=${encodeURIComponent(e.path)}`,{credentials:`same-origin`,redirect:`error`,signal:t}),r=await jo(n);if(!n.ok){let e=Mo(r);return{kind:`error`,error:oe(ae.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:Ci(r)}}catch{return{kind:`error`,error:oe(`unavailable`)}}}}),[]),L=(0,m.useMemo)(()=>c?co(c):void 0,[c]),R=t?.projects.find(e=>e.id===c);if((0,m.useEffect)(()=>{R&&Hp(R.id)},[R]),t===null)return(0,_.jsx)(Np,{});let z=t&&w&&(0,_.jsx)(vm,{epoch:t.epoch,csrf:t.csrf,onClose:()=>T(!1)}),B=()=>T(!0),V=t&&d!==null&&(0,_.jsx)(ff,{selectOnly:!0,client:I,current:R?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>f(null),onOpen:re});return t&&R&&L?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Np,{api:L,project:R,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===R.path).map(e=>e.id).sort(),discovery:ie,onPrepareExecution:P,onChooseFolder:e=>{ee.current?.abort(),f(e??R.cwd)},onOpenProject:re,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,_.jsxs)(_.Fragment,{children:[g&&(0,_.jsx)(`p`,{role:`alert`,children:g}),(0,_.jsx)(um,{notices:t.recoveries,project:R.path}),` `]}),onOpenService:B},R.id),z,V]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(im,{discovery:ie,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),Rp(e)},restore:E,onRefresh:()=>C(e=>e+1),onOpenService:t?B:void 0,onChooseFolder:()=>{ne(),v(``),ee.current?.abort(),f(t?.home??``)},notices:(0,_.jsxs)(_.Fragment,{children:[g&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:g}),t&&(0,_.jsx)(um,{notices:t.recoveries}),y&&(0,_.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,_.jsx)(`button`,{type:`button`,onClick:()=>C(e=>e+1),children:e(`Reload observation`)})]}),c&&!R&&t&&(0,_.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),V,z]})}function bm(){let{t:e}=D();return(0,_.jsxs)(`main`,{className:`entry`,children:[(0,_.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,_.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var xm=class extends m.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,_.jsx)(bm,{}):this.props.children}};te(j());var Sm=document.getElementById(`root`);if(!Sm)throw Error(`Application root unavailable`);(0,h.createRoot)(Sm).render((0,_.jsx)(O,{children:(0,_.jsx)(xm,{children:(0,_.jsx)(ym,{})})}));export{kp as t};
|