@abelxiaoxing/cadence 2.1.10 → 2.1.11
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/THIRD_PARTY_NOTICES.md +9 -0
- package/docs/conversation-mode.md +11 -3
- package/docs/reuse-and-distribution.md +8 -0
- package/package.json +1 -1
- package/src/cadence-instructions.ts +1 -1
- package/src/model-preview.mjs +9 -0
- package/src/native-build.ts +1 -1
- package/src/sdk-worker.mjs +6 -1
- package/src/service/contracts/workbench.ts +101 -7
- package/src/service/contracts/workflow.ts +3 -3
- package/src/service-cli.mjs +9 -0
- package/src/service-host.mjs +619 -179
- package/src/worker-capture.mjs +157 -9
- package/src/worker-public.mjs +9 -0
- package/web/dist/assets/cadence.css +1 -1
- package/web/dist/assets/cadence.js +26 -29
- package/web/dist/assets/markdown.js +1 -1
- package/web/dist/manifest.json +9 -9
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{n as t,r as n,t as r}from"./react.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"./markdown.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var f=e(n(),1),p=t(),m={"Incomplete model response":`未完成的模型响应`,"Upstream interrupted. Retry {attempt}/{maxAttempts} is scheduled after {seconds}s; completed tool results are kept.":`上游响应中断,第 {attempt}/{maxAttempts} 次重试安排在 {seconds} 秒后;已完成的工具结果已保留。`,"Retrying the model request ({attempt}/{maxAttempts}); completed tool results are kept.":`正在重试模型请求({attempt}/{maxAttempts});已完成的工具结果已保留。`,"The 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":`发现的会话`,"Owner work already listed below is not duplicated here.":`下方已经列出的 owner 工作不在此重复显示。`,"Active Pi work":`Pi 活动工作`,"{projects} projects · {sessions} sessions":`{projects} 个项目 · {sessions} 个会话`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Discovering active work…":`正在发现活动工作…`,"No active work observed. Idle terminals and owners are not listed.":`未观察到活动工作。空闲终端和 owner 不列入此处。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution 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; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"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 restart the service.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重启服务。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`包管理器会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade now":`立即升级`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},h=r(),g=`cadence-locale`,_=new Map(Object.entries(m));function v(e,t,n){let r=e===`zh`?_.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}var y={unavailable:`The service is unavailable right now ({code}).`,conflict:`Another operation is still in progress ({code}). Try again when it finishes.`,stale:`The context changed ({code}). Read the current state before trying this action again.`,"auth-unavailable":`Model credentials are unavailable ({code}). Check auth.json or the provider's API key.`,"corrupt-selected":`A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.`,"retired-conversation":`This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).`,"unsupported-context":`This is not supported here ({code}).`,capacity:`A limit was reached ({code}).`};function b(e,t){let n=Object.hasOwn(y,t)?y[t]:void 0;return n?e(n,{code:t}):t}function x({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function S(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function C(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var w=(0,f.createContext)(C(`en`,()=>{}));function T(){return(0,f.useContext)(w)}function E({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??S()),i=(0,f.useMemo)(()=>C(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(w.Provider,{value:i,children:t})}var D=`cadence-theme`,O=[`system`,`light`,`dark`],k=e=>e===`light`||e===`dark`;function ee(){try{let e=localStorage.getItem(D);if(k(e))return e}catch{}return`system`}function A(e){typeof document<`u`&&(e===`system`?delete document.documentElement.dataset.theme:document.documentElement.dataset.theme=e)}function j(){let e=typeof document>`u`?void 0:document.documentElement.dataset.theme;return k(e)?e:`system`}function te(e){try{e===`system`?localStorage.removeItem(D):localStorage.setItem(D,e)}catch{}A(e)}var M=e=>O[(O.indexOf(e)+1)%O.length],ne=`cadence-graph/2`,N=`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}),re=[`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 ie(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(),ae(e)>t)throw new F(`oversize`);return e}function ae(e){return new TextEncoder().encode(e).length}function R(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&I(),e}function z(e){return typeof e!=`boolean`&&I(),e}function B(e,t){return(typeof e!=`string`||!t.includes(e))&&I(),e}function V(e,t){return e!==t&&I(),t}function H(e,t){return e===null?null:t(e)}function U(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 W(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 G(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 K(e){let t=L(e,64);return/^[0-9a-f]{64}$/.test(t)||I(),t}function oe(e){let t=L(e,P.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||I(),t}function q(e,t){return oe(e),oe(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function se(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-=ae(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=W(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=U(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 ce(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 le(e){let t=U(e,[`code`,`effect`,`recovery`]);return{code:B(t.code,re),effect:B(t.effect,[`none`,`accepted`,`uncertain`]),recovery:B(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ue=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],Y=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],de=[`not-launched`,`direct-child-closed`,`unconfirmed`],fe=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],pe=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function me(e){let t=U(e,[`provider`,`model`,`api`,`thinking`]);return{provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:B(t.api,fe),thinking:B(t.thinking,pe)}}function he(e){let{sourceSelectionId:t,...n}=U(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:G(t),...me(n)}}function ge(e){let t=U(e,[`role`,`sha256`]);return{role:B(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:K(t.sha256)}}function _e(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function ve(e){let t=U(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:G(t.recordId),version:R(t.version,1),field:B(t.field,ue),bytes:R(t.bytes,0,P.detailBytes),sha256:K(t.sha256)}}function ye(e){let t=U(e,[`start`,`end`]),n=R(t.start);return{start:n,end:R(t.end,n+1,P.detailBytes)}}function be(e){let t=U(e,[`source`,`range`,`requireCompleteObservation`]),n=xe(t.source),r;if(n===`current`)r={kind:n,assignmentId:se(U(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=U(t.source,[`kind`,`runId`,`childRunId`,`result`]);V(n,`historical`);let i=ve(e.result);V(i.field,`final-text`),r={kind:`historical`,runId:G(e.runId),childRunId:G(e.childRunId),result:i}}let i=H(t.range,ye);return r.kind===`historical`&&i&&i.end>r.result.bytes&&I(),{source:r,range:i,requireCompleteObservation:z(t.requireCompleteObservation)}}function xe(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 Se(e){J(e,P.graphBytes);let t=U(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=ve(t.plan);V(n.field,`plan`);let r=R(t.planRevision,1);n.version!==r&&I();let i={schema:V(t.schema,ne),taskId:G(t.taskId),taskKind:B(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:R(t.taskRevision,1),revision:R(t.revision,1),planRevision:r,plan:n,assignments:W(t.assignments,P.assignments,e=>{let t=U(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:se(t.id),purpose:B(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:L(t.instructions,P.instructionsBytes,!0),expectedOutput:L(t.expectedOutput,P.expectedOutputBytes,!0),role:ge(t.role),model:he(t.model),dependencies:W(t.dependencies,P.assignments,be)}})};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!==_e(e.purpose))throw new F(`forbidden`);c(e)}return i}function Ce(e){let t=U(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=H(t.graphRevision,e=>R(e,1)),r=H(t.graphIdentity,K);return n===null!=(r===null)&&I(),{id:G(t.id),kind:B(t.kind,[`code`,`research`,`diagnosis`]),revision:R(t.revision,1),identity:K(t.identity),graphRevision:n,graphIdentity:r}}function we(e){let t=U(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=U(t.observation,[`identity`,`complete`]);return{epoch:G(t.epoch),accessGeneration:R(t.accessGeneration,1),configRev:R(t.configRev,1),controlRev:R(t.controlRev,1),workspaceId:G(t.workspaceId),cwdId:G(t.cwdId),model:he(t.model),checkEnvGeneration:R(t.checkEnvGeneration,1),checkoutGeneration:R(t.checkoutGeneration),observation:{identity:K(n.identity),complete:z(n.complete)},task:H(t.task,Ce)}}function Te(e){let t=U(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:B(t.kind,[`configured`,`manual`]),name:L(t.name,128,!0),command:L(t.command,4096,!0),timeoutMs:R(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 Ee(e){switch(J(e),xe(e)){case`create`:{let t=U(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:B(t.taskKind,[`code`,`research`,`diagnosis`]),goal:L(t.goal,8192,!0)}}case`save-plan`:{let t=U(e,[`kind`,`taskId`,`plan`,`graph`]),n=Se(t.graph),r=G(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:xe(e),taskId:G(U(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=U(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:G(t.taskId),check:Te(t.check)}}case`review`:{let t=U(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:G(t.taskId),runId:G(t.runId),changesIdentity:K(t.changesIdentity),checksRevision:R(t.checksRevision),acceptIssues:z(t.acceptIssues)}}default:return I()}}function De(e){J(e);let t=U(e,[`expected`,`action`]);return{expected:we(t.expected),action:Ee(t.action)}}function Oe(e){J(e);let t=U(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:G(t.commandId),grant:G(t.grant),expected:we(t.expected),action:Ee(t.action)}}function ke(e){if(J(e),xe(e)===`action`){let t=U(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:we(t.expected),action:Ee(t.action)}}let t=U(e,[`kind`,`epoch`,`runId`]);return V(t.kind,`cancel`),{kind:`cancel`,epoch:G(t.epoch),runId:G(t.runId)}}function Ae(e){let t=U(e,[`commandId`,`epoch`,`runId`]);return{commandId:G(t.commandId),epoch:G(t.epoch),runId:G(t.runId)}}function je(e){J(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=U(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=W(n.configuredChecks,32,Te);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&I(),{...t?{checkEnvironmentPolicy:V(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:R(n.checksRevision),reviewRunId:H(n.reviewRunId,G),version:we(n.version),action:Ee(n.action),rootLabel:L(n.rootLabel,4096,!0),cwdLabel:L(n.cwdLabel,4096,!0),readablePlan:L(n.readablePlan,32768),graph:H(n.graph,Se),activeRunId:H(n.activeRunId,G),issues:W(n.issues,7,e=>B(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Me(e){J(e);let t=U(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:G(t.grant),expiresAt:n,preview:je(t.preview)}}function Ne(e){let t=U(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:B(t.observed,[`complete`,`incomplete`]),source:B(t.source,[`complete`,`limited`,`unavailable`]),redacted:z(t.redacted),omissions:W(t.omissions,6,e=>B(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 Pe(e){let t=U(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:R(t.graphRevision,1),inputs:W(t.inputs,P.assignments,e=>{let t=U(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=ve(t.result);V(i.field,`final-text`);let a=H(t.range,ye);a&&a.end>i.bytes&&I();let o=L(t.text,P.predecessorBytes);if(n+=ae(o),n>P.handoffBytes)throw new F(`oversize`);let s=R(t.dependencyIndex,0,P.assignments-1);return r.has(s)&&I(),r.add(s),ae(o)!==(a?a.end-a.start:i.bytes)&&I(),{assignmentId:se(t.assignmentId),dependencyIndex:s,runId:G(t.runId),childRunId:G(t.childRunId),result:i,range:a,text:o,coverage:Ne(t.coverage)}})}}function Fe(e){let t=U(e,[`source`,`reason`,`target`]);return{source:B(t.source,[`user`,`service`,`owner`,`command`,`worker`,`coordinator`,`unknown`]),reason:L(t.reason,128,!0),target:L(t.target,128,!0)}}function Ie(e){let t=U(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={...t.stop===void 0?{}:{stop:Fe(t.stop)},outcome:B(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:B(t.closure,de),exitCode:H(t.exitCode,e=>R(e,-2147483648,4294967295)),signal:H(t.signal,e=>L(e,32,!0)),durationMs:R(t.durationMs),stdin:B(t.stdin,[`delivered`,`failed`,`not-required`]),final:B(t.final,[`valid`,`missing`,`invalid`]),cleanup:B(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:Ne(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 Le(e){let t=U(e,[`kind`,`id`]);return{kind:B(t.kind,[`task`,`run`,`child`]),id:G(t.id)}}function Re(e){let t=L(e,P.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||I(),t}function ze(e){J(e);let t=U(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:G(t.storeId),scope:Le(t.scope),query:H(t.query,e=>{let t=L(e,P.queryBytes);return t.length||I(),t}),snapshotSeq:oe(t.snapshotSeq),recordId:H(t.recordId,G),recordVersion:H(t.recordVersion,e=>R(e,1)),field:H(t.field,e=>B(e,ue)),offset:R(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&I(),n}function Be(e){let t=U(e,[`disposition`,`value`]),n=B(t.disposition,[`observed`,`unavailable`,`redacted`]),r=We(t.value);return n===`observed`!=(r!==null)&&I(),{disposition:n,value:r}}function Ve(e){let t=U(e,[`messageId`,`blockId`]);return{messageId:G(t.messageId),blockId:G(t.blockId)}}function He(e){let t=xe(e);if(t===`message-final`)return{kind:t,messageId:G(U(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:B(U(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=U(e,[`kind`,`dependencyIndex`,`source`]),r=ve(n.source);return V(r.field,`final-text`),{kind:t,dependencyIndex:R(n.dependencyIndex,0,P.assignments-1),source:r}}if(t===`message`){let n=U(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:G(n.messageId),blockId:G(n.blockId),index:R(n.index,0,P.dataFrames),stage:B(n.stage,[`stream`,`final`])}}let n=U(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return V(t,`tool`),{kind:`tool`,callId:G(n.callId),blockId:G(n.blockId),index:R(n.index,0,P.dataFrames),stage:B(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function X(e){let t=U(e,[`owner`,`field`,`encoding`]),n=He(t.owner),r=B(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=B(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 Ue(e){let t=U(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=B(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=B(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=H(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:He(t.owner),sourceType:n,mimeType:i,reason:r}}function We(e){if(e===null)return null;let t=L(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||I(),t}function Ge(e){let t=U(e,[`phase`,`attempt`,`maxAttempts`,`delayMs`,...Object.hasOwn(e??{},`reason`)?[`reason`]:[]]),n=R(t.maxAttempts,1),r={phase:B(t.phase,[`waiting`,`requesting`]),attempt:R(t.attempt,1,n),maxAttempts:n,delayMs:R(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 Z(e){let t=xe(e);switch(t){case`ready`:{let n=U(e,[`kind`,`requestProtocol`,...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[]]);return{kind:t,requestProtocol:V(n.requestProtocol,2),...n.runtime===void 0?{}:{runtime:(()=>{let e=U(n.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:K(e.workerHash)}})()}}}case`message-start`:{let n=U(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=B(n.role,[`user`,`assistant`,`tool-result`]),i=H(n.resultCallId,G);return r!==`tool-result`&&i!==null&&I(),{kind:t,messageId:G(n.messageId),role:r,source:Be(n.source),resultCallId:i}}case`message-text`:{let n=U(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...Ve({messageId:n.messageId,blockId:n.blockId}),detailId:G(n.detailId)}}case`message-end`:{let n=U(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:G(n.messageId),finalDetailId:H(n.finalDetailId,G),finalBlockCount:R(n.finalBlockCount,0,P.dataFrames),stopReason:B(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=U(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:G(n.callId),declaration:Ve(n.declaration),index:R(n.index,0,P.dataFrames),source:Be(n.source),name:L(n.name,128,!0),argsDetailId:H(n.argsDetailId,G),stage:B(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=U(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:G(n.callId),declaration:H(n.declaration,Ve),source:Be(n.source),name:L(n.name,128,!0),argsDetailId:H(n.argsDetailId,G)}}case`tool-update`:{let n=U(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:G(n.callId),detailId:G(n.detailId),semantics:V(n.semantics,`snapshot`)}}case`tool-end`:{let n=U(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=B(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=H(n.declaration,Ve),a=z(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&I(),{kind:t,callId:G(n.callId),declaration:i,source:Be(n.source),name:L(n.name,128,!0),resultDetailId:G(n.resultDetailId),isError:z(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Ue(U(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=U(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:G(n.detailId),descriptor:X(n.descriptor)}}case`detail-chunk`:{let n=U(e,[`kind`,`detailId`,`offset`,`text`]),r=L(n.text,P.chunkBytes),i=R(n.offset,0,P.detailBytes);return i+ae(r)>P.detailBytes&&I(),{kind:t,detailId:G(n.detailId),offset:i,text:r}}case`detail-end`:{let n=U(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:G(n.detailId),bytes:R(n.bytes,0,P.detailBytes),sha256:K(n.sha256),coverage:Ne(n.coverage)}}case`model-retry`:return{kind:t,progress:H(U(e,[`kind`,`progress`]).progress,Ge)};case`capture-status`:return{kind:t,coverage:Ne(U(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:B(U(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=U(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:G(n.messageId),detailId:G(n.detailId),stopReason:V(n.stopReason,`stop`)}}default:return I()}}function Ke(e){let t=U(e,[...Object.hasOwn(e??{},`stop`)?[`stop`]:[],`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={...t.stop===void 0?{}:{stop:Fe(t.stop)},outcome:B(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:B(t.closure,de),exitCode:H(t.exitCode,e=>R(e,-2147483648,4294967295)),signal:H(t.signal,e=>L(e,32,!0)),durationMs:R(t.durationMs),stdin:V(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 qe(e){let t=U(e,[`messageId`,`detailId`]);return{messageId:G(t.messageId),detailId:G(t.detailId)}}function Je(e){let t=U(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=oe(t.committedSeq);return n===`0`&&I(),{childRunId:G(t.childRunId),detailId:G(t.detailId),content:ve(t.content),committedSeq:n}}function Ye(e){let t=xe(e,`status`);if(t===`committed`){let n=U(e,[`status`,`selected`,`detail`]),r=qe(n.selected),i=Je(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&I(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=U(e,[`status`,`selected`,`error`]);return{status:t,selected:H(n.selected,qe),error:le(n.error)}}let n=U(e,[`status`,`selected`]);return{status:B(t,[`pending`,`uncertain`]),selected:H(n.selected,qe)}}function Xe(e,t){let n=H(e,oe);return(n===`0`||n!==null&&t.status===`committed`&&q(n,t.detail.committedSeq)<0)&&I(),n}function Ze(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Qe(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Ze(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function $e(e){let t=xe(e);if(t===`sdk`){let n=U(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Ye(n.recording),i=Xe(n.settlementSeq,r);return{kind:t,native:Ie(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=U(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=H(n.settlementSeq,oe);return r===`0`&&I(),{kind:t,native:Ke(n.native),capture:Ne(n.capture),settlementSeq:r}}let n=U(e,[`kind`,`outcome`,`required`]);V(t,`parent`);let r=W(n.required,P.assignments,e=>{let t=U(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=G(t.childRunId),r=Ye(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&I(),{assignmentId:se(t.assignmentId),childRunId:n,native:H(t.native,Ie),recording:r,settlementSeq:Xe(t.settlementSeq,r)}}),i=B(n.outcome,Y);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(Ze))&&I(),{kind:`parent`,outcome:i,required:r}}function et(e){let t=U(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=R(t.first,1,2**53-1),r=R(t.last,n,2**53-1),i=R(t.firstObservedMs),a=R(t.lastObservedMs,i);return n===r&&i!==a&&I(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function tt(e){let t=U(e,[`source`,`event`]),n=et(t.source),r=xe(t.event);if(r===`stored-chunk`){let e=U(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:G(e.detailId),text:L(e.text,P.chunkBytes)}}}if(r===`stored-end`){let e=U(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:G(e.detailId),coverage:Ne(e.coverage)}}}let i=Z(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&I(),{source:n,event:i}}function nt(e){let t=U(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:G(t.epoch),taskId:G(t.taskId),runId:G(t.runId),childRunId:G(t.childRunId)}}function rt(e){J({kind:`ok`,value:e},P.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=U(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:G(n.storeId),workspaceId:G(n.workspaceId),epoch:G(n.epoch)};if(!t)return V(n.status,`unavailable`),{...r,status:`unavailable`,error:it(n.error)};let i=W(n.runs,P.episodes,e=>{let t=U(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:G(t.taskId),runId:G(t.runId),operationId:G(t.operationId),epoch:G(t.epoch),kind:B(t.kind,[`start`,`generate-plan`,`check`]),stage:B(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 it(e){let t=le(e);return V(t.effect,`none`),t}function at(e){let t=U(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:K(t.sourceHash),contractHash:K(t.contractHash),buildId:K(t.buildId)}}function ot(e){let t=B(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=U(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:K(n.contractHash)}:{kind:t,...at({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function st(e){let t=U(e,[`contractHash`,`assets`]);return{contractHash:K(t.contractHash),assets:at(t.assets)}}function ct(e){J(e);let t=U(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:G(t.commandId),operationId:G(t.operationId),runId:H(t.runId,G),admission:B(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:oe(t.committedSeq),execution:H(t.execution,e=>B(e,Y)),settlement:H(t.settlement,$e),created:H(t.created,e=>{let t=U(e,[`kind`,`taskId`,`state`]);return{kind:V(t.kind,`task`),taskId:G(t.taskId),state:B(t.state,[`reserved`,`published`])}}),publication:B(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&&Qe(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&I(),n}function lt(e){J(e);let t=U(e,[`identity`,`receipt`]),n=ke(t.identity),r=ct(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(xe(e)===`ok`)return{kind:`ok`,value:t(U(e,[`kind`,`value`]).value)};let n=U(e,[`kind`,`error`]);return V(n.kind,`error`),{kind:`error`,error:le(n.error)}}function ut(e){switch(J(e),xe(e,`status`)){case`found`:return{status:`found`,receipt:ct(U(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:oe(U(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:le(U(e,[`status`,`error`]).error)};default:return I()}}function dt(e){let t=U(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:G(t.runId),taskId:G(t.taskId),childRunId:H(t.childRunId,G),assignmentId:H(t.assignmentId,se),admission:xt(t.admission),lifecycle:B(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:H(t.outcome,e=>B(e,Y)),settlement:H(t.settlement,$e),reason:H(t.reason,e=>B(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:B(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:Ne(t.coverage),result:H(t.result,ve)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&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&&Qe(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Qe(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&I(),n}function ft(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function pt(e,t,n){return ft(e,t)&&e.taskId===wt(n)&&e.admission.context.workspaceId===Ct(n)}function mt(e){J(e,P.pageBytes);let t=U(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:V(t.protocol,1),storeId:G(t.storeId),epoch:G(t.epoch),scope:Le(t.scope),committedSeq:oe(t.committedSeq),context:St(t.context),runs:W(t.runs,P.maxPageEntries,dt),horizon:It(t.horizon)};return(!Tt(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=>!pt(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&I(),n}function ht(e){J(e,P.pageBytes);let t=xe(e),n=U(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:G(n.storeId),epoch:G(n.epoch),scope:Le(n.scope),committedSeq:oe(n.committedSeq)};if(t===`update`){let e=oe(n.previousSeq);q(r.committedSeq,e)<=0&&I();let i=St(n.context);Tt(i,r.epoch,r.scope)||I();let a=W(n.runs,P.maxPageEntries,dt),o=W(n.removed,P.maxPageEntries,G),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!pt(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 V(t,`heartbeat`),{kind:`heartbeat`,...r}}function gt(e){let{navigation:t,...n}=e;return n}function _t(e,t){(!t.navigation||t.navigation===e.navigation||J(gt(e))!==J(gt(t)))&&I()}function vt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return yt(e);J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`kind`,`cursor`,`next`,`coverage`]),n=ze(t.cursor),r=ze(t.next);return _t(n,r),{kind:`progress`,cursor:n,next:r,coverage:Ne(t.coverage)}}function yt(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ze(t.cursor),content:ve(t.content),range:H(t.range,ye),text:L(t.text,P.detailPageBytes),next:H(t.next,ze),coverage:Ne(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==ae(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(gt({...n.next,offset:n.cursor.offset}))!==J(gt(n.cursor)))&&I(),n}function bt(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`cursor`,`hits`,`next`,`coverage`]),n=ze(t.cursor);n.query||I();let r=ae(n.query),i=W(t.hits,P.maxPageEntries,e=>{let t=U(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=ve(t.content),a=Ot(t.owner);kt(a,n.scope)||I();let o=ye(t.range),s=ze(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||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=H(t.next,ze);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:Ne(t.coverage)}}function xt(e){let t=U(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=we(t.context),r=H(t.graph,e=>{let t=U(e,[`recordId`,`revision`,`sha256`]);return{recordId:G(t.recordId),revision:R(t.revision,1),sha256:K(t.sha256)}}),i=B(t.kind,[`start`,`generate-plan`,`check`]),a=W(t.assignments,P.assignments,e=>{let t=U(e,[`assignmentId`,`childRunId`]);return{assignmentId:se(t.assignmentId),childRunId:G(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:G(t.operationId),commandId:G(t.commandId),kind:i,context:n,assignments:a,graph:r}}function St(e){if(xe(e,`status`)===`available`)return{status:`available`,version:we(U(e,[`status`,`version`]).version)};let t=U(e,[`status`,`workspaceId`,`taskId`,`error`]);V(t.status,`unavailable`);let n=le(t.error);return V(n.effect,`none`),{status:`unavailable`,workspaceId:G(t.workspaceId),taskId:H(t.taskId,G),error:n}}function Ct(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function wt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Tt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||wt(e)===n.id)}function Et(e){let t=U(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=U(t.capabilities,[`actions`,`manualChecks`,`history`]),r=B(t.authority,[`browser`,`local`]),i=H(t.csrf,G),a={actions:z(n.actions),manualChecks:z(n.manualChecks),history:z(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&I(),{...t.build===void 0?{}:{build:st(t.build)},protocol:V(t.protocol,1),storeId:G(t.storeId),epoch:G(t.epoch),accessGeneration:R(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function Dt(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:rt(t.activeRuns)},workspaceId:G(t.workspaceId),storeId:G(t.storeId),epoch:G(t.epoch),committedSeq:oe(t.committedSeq),rootLabel:L(t.rootLabel,4096,!0),context:St(t.context),models:W(t.models,P.maxPageEntries,he)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&I(),(Ct(n.context)!==n.workspaceId||wt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&I(),n}function Ot(e){let t=U(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=U(t.entity,[`kind`,`id`,`version`]),r={taskId:G(t.taskId),runId:H(t.runId,G),childRunId:H(t.childRunId,G),entity:{kind:B(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:G(n.id),version:R(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 kt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function At(e){let t=U(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:K(t.identity),complete:z(t.complete),checkoutGeneration:R(t.checkoutGeneration)}}function jt(e){J(e,P.controlBytes);let t=xe(e);switch(t){case`assignment-state`:{let n=U(e,[`kind`,`childRunId`,`state`,`reason`]),r=B(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=H(n.reason,e=>B(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:G(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:B(U(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=U(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:G(n.runId),identity:xt(n.identity)}}case`parent-settled`:{let n=U(e,[`kind`,`runId`,`settlement`]),r=$e(n.settlement);return r.kind!==`parent`&&I(),{kind:t,runId:G(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=U(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:G(r.reservationId)}:{},lane:B(r.lane,[`reader`,`writer`,`check`]),state:B(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:R(r.checkoutGeneration)}}case`handoff`:{let n=U(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:G(n.childRunId),handoff:Pe(n.handoff),observation:At(n.observation)}}case`changes`:{let n=U(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=ve(n.content);return V(r.field,`changes`),{kind:t,observationId:G(n.observationId),stage:B(n.stage,[`before`,`after`,`review`]),observation:At(n.observation),content:r}}case`check-start`:{let n=U(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:G(n.checkId),selection:Te(n.selection),cwdId:G(n.cwdId),cwdLabel:L(n.cwdLabel,4096,!0),checkEnvGeneration:R(n.checkEnvGeneration,1),before:At(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=U(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=U(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:G(e.operationId),reservationId:G(e.reservationId),from:R(e.from),to:R(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&I()}let a=Ke(r.native),o=B(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=At(r.before),c=At(r.after),l=H(r.output,ve),u=Ne(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:G(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=U(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=z(n.acceptIssues),i=B(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=ve(n.content);return V(a.field,`review`),i===`reviewed-with-issues`&&!r&&I(),{kind:t,reviewId:G(n.reviewId),runId:G(n.runId),checksRevision:R(n.checksRevision),changesIdentity:K(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=U(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=R(n.expectedRevision),i=H(n.expectedIdentity,K),a=R(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&I(),{kind:t,publicationId:G(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:K(n.nextIdentity)}}case`publication-settled`:{let n=U(e,[`kind`,`publicationId`,`status`,`observed`]),r=B(n.status,[`published`,`conflict`,`uncertain`]),i=H(n.observed,e=>{let t=U(e,[`revision`,`identity`]);return{revision:R(t.revision,1),identity:K(t.identity)}});return r===`published`&&i===null&&I(),{kind:t,publicationId:G(n.publicationId),status:r,observed:i}}default:return I()}}function Mt(e){let t=U(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:G(t.epoch),operationId:G(t.operationId),taskId:G(t.taskId),runId:H(t.runId,G)}}function Nt(e){J(e,P.ownerQueueBytes);let t=U(e,[`observedMs`,`link`,`events`]),n=Mt(t.link),r=W(t.events,P.ownerQueueFrames,e=>{let t=xe(e);if(t===`fact`){let r=jt(U(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=U(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=Ot(r.owner),a=B(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:G(r.detailId),owner:i,field:a,encoding:V(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=U(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:G(n.detailId),text:L(n.text,P.chunkBytes)}}let r=U(e,[`kind`,`detailId`,`coverage`]);return V(t,`content-end`),{kind:`content-end`,detailId:G(r.detailId),coverage:Ne(r.coverage)}});return{observedMs:R(t.observedMs),link:n,events:r}}var Pt=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Ft(e){let t=U(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=B(t.reader,Pt),r=U(t.scope,[`kind`,`id`]),i={kind:B(r.kind,[`workspace`,`task`,`run`,`child`]),id:G(r.id)},a=H(t.snapshotSeq,oe),o=H(t.after,e=>{let t=U(e,[`recordId`,`version`,`offset`]);return{recordId:G(t.recordId),version:R(t.version,1),offset:R(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&I(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:G(t.storeId),scope:i,snapshotSeq:a,after:o,limit:R(t.limit,1,P.maxPageEntries)}}function It(e){let t=U(e,[`policy`,`historicalRuns`]),n=Ft(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&I(),{policy:V(t.policy,`active-and-recent`),historicalRuns:n}}function Lt(e){let t=xe(e);if(t===`run`)return{kind:t,projection:dt(U(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=U(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=oe(n.committedSeq);return r===`0`&&I(),{kind:t,recordId:G(n.recordId),committedSeq:r,link:nt(n.link),capture:tt(n.capture)}}if(t===`owner-fact`){let n=U(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=Nt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&I();let a=oe(n.committedSeq);return a===`0`&&I(),{kind:t,recordId:G(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=U(e,[...n,...r]),a=Ot(i.owner),o=R(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&I(),t===`task`){let e=H(i.plan,ve);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=B(i.role,[`user`,`assistant`,`tool-result`]),n=B(i.state,[`partial`,`final`]),r=H(i.finalBlockCount,e=>R(e,0,P.dataFrames)),s=H(i.finalText,ve),c=H(i.resultCallId,G);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:Be(i.source)}}if(t===`tool`){let e=H(i.declaration,Ve),n=H(i.declarationStage,e=>B(e,[`partial`,`final`])),r=z(i.startObserved),s=H(i.result,e=>{let t=Z(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:Be(i.source),name:L(i.name,128,!0)}}if(t===`content`){let e=X(i.descriptor),n=ve(i.content);return(e.field!==n.field||!Rt(e.owner,a))&&I(),{kind:t,owner:a,version:o,detailId:G(i.detailId),descriptor:e,content:n,coverage:Ne(i.coverage)}}V(t,`omitted`);let s=Ue(i.block);return Rt(s.owner,a)||I(),{kind:`omitted`,owner:a,version:o,block:s}}function Rt(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 zt(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 Bt(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`request`,`records`,`next`,`coverage`]),n=Ft(t.request);n.snapshotSeq===null&&I();let r=W(t.records,n.limit,Lt),i=H(t.next,Ft);return(r.some(e=>!zt(e,n))||i&&(i.after===null||J(gt({...i,after:n.after}))!==J(gt(n))||J(i.after)===J(n.after)))&&I(),{request:n,records:r,next:i,coverage:Ne(t.coverage)}}function Vt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||J(gt({...r,snapshotSeq:null}))!==J(gt(n)))&&I(),{kind:`snapshot`,request:n,next:r,coverage:Ne(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Bt(e);J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`kind`,`request`,`next`,`coverage`]),n=Ft(t.request),r=Ft(t.next);return _t(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}function Ht(e,t){return J({...t.request,snapshotSeq:e.snapshotSeq})===J(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Ut(e){let t=U(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=U(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:G(t.storeId),scope:Le(t.scope),snapshotSeq:oe(t.snapshotSeq),graph:{recordId:G(n.recordId),revision:R(n.revision,1),sha256:K(n.sha256)}}}function Wt(e){J({kind:`ok`,value:e});let t=U(e,[`request`,`graph`]),n=Ut(t.request),r=Se(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&I(),{request:n,graph:r}}function Gt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Wt(e);J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`kind`,`request`,`next`,`coverage`]),n=Ut(t.request),r=Ut(t.next);return _t(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}function Kt(e){let t=U(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:G(t.storeId),scope:Le(t.scope),snapshotSeq:oe(t.snapshotSeq),format:B(t.format,[`ndjson`,`markdown`])}}function qt(e){J(e,P.controlBytes);let t=U(e,[`exportId`,`ordinal`,`event`]),n=xe(t.event),r;switch(n){case`manifest`:{let e=U(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=U(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:K(i.exporterBuildSha256),capturePolicy:V(i.capturePolicy,`public-text-tools/2`)},schema:V(e.schema,N),request:Kt(e.request),coverage:Ne(e.coverage),serviceProtocol:V(e.serviceProtocol,1),workerProtocol:V(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Lt(U(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Wt(U(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=U(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=ve(e.content),a=H(e.range,ye),o=L(e.text,P.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==ae(o):i.bytes!==0||o!==``)&&I(),r={kind:n,owner:Ot(e.owner),content:i,range:a,text:o,coverage:Ne(e.coverage)};break}case`markdown`:r={kind:n,text:L(U(t.event,[`kind`,`text`]).text,P.detailPageBytes)};break;case`trailer`:{let e=U(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=Ne(e.coverage),a=z(e.complete);a&&i.observed!==`complete`&&I(),r={kind:n,complete:a,frames:R(e.frames,1),encodedBytes:R(e.encodedBytes),sha256:K(e.sha256),committedSeq:oe(e.committedSeq),coverage:i};break}default:return I()}return{exportId:G(t.exportId),ordinal:R(t.ordinal,1),event:r}}function Jt(e,t){let n=qt(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 Yt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=Kt(e)}receive(e){let t=qt(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`&&!kt(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`&&!Xt(n.record,this.request.scope)&&I(),this.bytes+=ae(Jt(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 Xt(e,t){return e.kind===`run`?ft(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:kt(e.owner,t)}function Zt(e){let t=U(e,[`taskId`,`revision`,`definitions`]),n=W(t.definitions,32,e=>{let t=U(e,[`selection`,`status`,`checkId`]),n=Te(t.selection),r=B(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=H(t.checkId,G);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:G(t.taskId),revision:R(t.revision),definitions:n}}function Qt(e){let t=U(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Re(t.navigation)}:{},storeId:G(t.storeId),scope:Le(t.scope),snapshotSeq:oe(t.snapshotSeq),kind:B(t.kind,[`task`,`message`,`tool`]),id:G(t.id),version:R(t.version,1)}}function $t(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`request`,`record`]),n=Qt(t.request),r=Lt(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||!kt(r.owner,n.scope))&&I(),{request:n,record:r}}function en(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return $t(e);J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`kind`,`request`,`next`,`coverage`]),n=Qt(t.request),r=Qt(t.next);return _t(n,r),{kind:`progress`,request:n,next:r,coverage:Ne(t.coverage)}}var tn=e=>{let t=le(e);return V(t.effect,`none`),t};function nn(e){let t=U(e,[`storeId`,`taskId`]);return{storeId:G(t.storeId),taskId:H(t.taskId,G)}}function rn(e){let t=nn(e);return t.taskId===null&&I(),t}function an(e){let t=U(e,[`id`,`kind`,`revision`,`identity`]);return{id:G(t.id),kind:B(t.kind,[`code`,`research`,`diagnosis`]),revision:R(t.revision,1),identity:K(t.identity)}}function on(e){let t=W(e,3,ge);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&I(),t}function sn(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return U(e,[`status`]),{status:t};if(t===`saved`){let n=U(e,[`status`,`request`,`planRevision`]);return{status:t,request:Ut(n.request),planRevision:R(n.planRevision,1)}}let n=U(e,[`status`,`error`]);return V(n.status,`unavailable`),{status:`unavailable`,error:tn(n.error)}}function cn(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||Ct(e.context)!==e.workspaceId||wt(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 ln(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:nn(t.request),workspaceId:G(t.workspaceId),epoch:G(t.epoch),committedSeq:oe(t.committedSeq),context:St(t.context),task:H(t.task,an),roles:on(t.roles),savedGraph:sn(t.savedGraph),readablePlan:H(t.readablePlan,e=>{let t=U(e,[`source`,`text`,`editable`,`coverage`]),n=Ne(t.coverage),r=z(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&I(),{source:V(t.source,`current-v1`),text:L(t.text,32768),editable:r,coverage:n}})};cn(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 un(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=U(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:rn(t.request),workspaceId:G(t.workspaceId),epoch:G(t.epoch),committedSeq:oe(t.committedSeq),context:St(t.context),task:an(t.task),observation:{identity:K(n.identity),complete:z(n.complete),checkoutGeneration:R(n.checkoutGeneration,0)},text:L(t.text,131072),git:z(t.git),coverage:Ne(t.coverage)};if(cn(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 dn(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 fn(e){let t=U(e,[`id`,`cwd`]);return{id:dn(t.id),cwd:L(t.cwd,4096,!0)}}function pn(e){let t=U(e,[`id`,`cwd`,`revision`,`model`]);return{id:dn(t.id),cwd:L(t.cwd,4096,!0),revision:R(t.revision,0,2**53-1-1),model:H(t.model,me)}}function mn(e){let t=U(e,[`cwd`,`checkoutRoot`,`version`,`model`]);return{cwd:L(t.cwd,4096,!0),checkoutRoot:L(t.checkoutRoot,4096,!0),version:hn(t.version),model:H(t.model,he)}}function hn(e){let t=U(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`,...Object.hasOwn(e??{},`conversation`)?[`conversation`]:[]]);return{...t.conversation===void 0?{}:{conversation:fn(t.conversation)},epoch:G(t.epoch),accessGeneration:R(t.accessGeneration,1),configRev:R(t.configRev,1),catalogId:G(t.catalogId)}}function gn(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`version`,`selected`]);return{version:hn(t.version),selected:H(t.selected,he)}}function _n(e){J(e);let t=U(e,[`expected`,`choice`]);return{expected:hn(t.expected),choice:me(t.choice)}}function vn(e){let t=U(e,[`provider`,`model`,`api`,`thinking`,`eligibility`,...Object.hasOwn(e??{},`images`)?[`images`]:[],...Object.hasOwn(e??{},`contextWindow`)?[`contextWindow`]:[]]),n={...t.images===void 0?{}:{images:z(t.images)},...t.contextWindow===void 0?{}:{contextWindow:R(t.contextWindow,1)},provider:L(t.provider,128,!0),model:L(t.model,256,!0),api:H(t.api,e=>B(e,fe)),thinking:W(t.thinking,7,e=>{let t=U(e,[`level`,`selectable`]);return{level:B(t.level,pe),selectable:z(t.selectable)}}),eligibility:B(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 yn(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 bn(e){J({kind:`ok`,value:e},P.pageBytes);let t=U(e,[`status`,`entries`,`withheld`,`remembered`]),n=W(t.entries,P.maxPageEntries,vn),r=H(t.remembered,me),i=B(t.status,[`complete`,`capacity`]),a=R(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&&!yn(n,r))&&I(),{status:i,entries:n,withheld:a,remembered:r}}function xn(e){let{version:t,selected:n,...r}=U(e,[`version`,`selected`,`status`,`entries`,`withheld`,`remembered`]);return J({kind:`ok`,value:e},P.pageBytes),{...bn(r),version:hn(t),selected:H(n,he)}}function Sn(e){let t=U(e,[`id`,`path`,`cwd`,`epoch`]);return{id:K(t.id),path:L(t.path,4096,!0),cwd:L(t.cwd,4096,!0),epoch:t.epoch===null?null:G(t.epoch)}}function Cn(e){let t=U(e,[`kind`,`status`,`epoch`,`workspaceId`]);return{kind:V(t.kind,`project-observation`),status:B(t.status,[`running`,`stopped`,`not-started`,`unavailable`]),epoch:t.epoch===null?null:G(t.epoch),workspaceId:t.workspaceId===null?null:G(t.workspaceId)}}var wn=[`registry`,`workbench`,`project`],Tn=[`reboot`,`crash`,`restart`,`storage`],En=[`released-locks`,`stopped-workers`,`stopped-owner`,`continued-history`,`archived-history`,`archived-state`,`rebuilt-registry`,`removed-temporaries`];function Dn(e){let t=U(e,[`id`,`at`,`scope`,`path`,`cause`,`actions`,`workers`,`archived`]);return{id:G(t.id),at:R(t.at,0),scope:B(t.scope,wn),path:t.path===null?null:L(t.path,4096,!0),cause:B(t.cause,Tn),actions:W(t.actions,En.length,e=>B(e,En)),workers:R(t.workers,0,1e6),archived:z(t.archived)}}function On(e){let t=U(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`recoveries`,`build`]);return{kind:V(t.kind,`workbench`),epoch:G(t.epoch),csrf:G(t.csrf),home:L(t.home,4096,!0),projects:W(t.projects,128,Sn),recoveries:W(t.recoveries,20,Dn),build:st(t.build)}}var kn=[`restart`,`upgrade`],An=[`running`,`ready`,`failed`,`rolled-back`],jn=[`fetch-failed`,`stop-unconfirmed`,`install-failed`,`not-ready`,`refused`,`interrupted`],Mn=/^(?: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 Nn(e){let t=L(e,96,!0);if(!Mn.test(t))throw new F(`invalid`);return t}function Pn(e){let t=U(e,[`id`,`action`,`from`,`to`,`state`,`reason`,`version`,`at`,`endedAt`]);return{id:G(t.id),action:B(t.action,kn),from:Nn(t.from),to:t.to===null?null:Nn(t.to),state:B(t.state,An),reason:t.reason===null?null:B(t.reason,jn),version:t.version===null?null:Nn(t.version),at:R(t.at,0),endedAt:t.endedAt===null?null:R(t.endedAt,0)}}var Fn=[`npm`,`bun`,`pi-npm`,`pi-bun`,`npm-local`,`bun-local`,`unsupported-install`,`pinned`,`not-writable`];function In(e){return e===`npm`||e===`bun`||e===`pi-npm`||e===`pi-bun`||e===`npm-local`||e===`bun-local`}function Ln(e){let t=U(e,[`kind`,`version`,`unit`,`upgrade`,`work`,`job`]),n=null;if(t.unit!==null){let e=U(t.unit,[`name`,`scope`]);n={name:L(e.name,96,!0),scope:B(e.scope,[`user`,`system`])}}return{kind:V(t.kind,`service`),version:Nn(t.version),unit:n,upgrade:B(t.upgrade,Fn),work:R(t.work,0,1e6),job:t.job===null?null:Pn(t.job)}}function Rn(e){let t=U(e,[`kind`,`version`,`deprecated`]);return{kind:V(t.kind,`release`),version:Nn(t.version),deprecated:z(t.deprecated)}}function zn(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 Bn=Object.freeze({chunkChars:262144,idleMs:6e5}),Vn=Object.freeze([`image/png`,`image/jpeg`,`image/webp`]);function Hn(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 Un(e,t){if(!Vn.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={"Runtime observation":`运行观察`,"Reply queued":`回复排队中`,"Reply running":`回复进行中`,"Reply ended":`回复已结束`,"Reply failed":`回复失败`,"Reply canceled":`回复已取消`,"Reply timed out":`回复超时`,"Reply outcome unknown":`回复结果未知`,"Waiting · no new progress observed":`等待中 · 暂未观察到新进展`,"Thinking activity observed":`已观察到思考活动`,"Thinking activity ended":`思考活动已结束`,"Thinking content unavailable":`思考内容不可用`,"Thinking content is not streamed. Readable recorded thinking can be opened after it is saved.":`不传输思考正文;可读取的思考内容落盘后可展开查看。`,"Reply output observed":`已观察到回复输出`,"Tool running":`工具执行中`,"Tool result observed":`已观察到工具结果`,"Tool failure observed":`已观察到工具失败`,"Tool cancellation observed":`已观察到工具取消`,"Tool outcome unknown":`工具结果未知`,"Awaiting workflow observation":`等待工作流状态`,"Last observed":`上次观察状态`,"Observing current state":`正在观察当前状态`,"Waiting for current observations":`等待当前状态读取`,"Observation unavailable · waiting for current state":`观察不可用 · 等待当前状态`,"Observation paused":`观察已暂停`,"Observation delayed · showing last known state":`观察滞后 · 显示上次已知状态`,"Observation paused · showing last known state":`观察已暂停 · 显示上次已知状态`,"History readable · live execution not connected":`历史可读 · 未连接实时执行服务`,"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":`发现的会话`,"Owner work already listed below is not duplicated here.":`下方已经列出的 owner 工作不在此重复显示。`,"Active Pi work":`Pi 活动工作`,"{projects} projects · {sessions} sessions":`{projects} 个项目 · {sessions} 个会话`,"Activity observation is partial. Missing work is not known to have finished.":`活动观察不完整。未显示的工作不代表已经结束。`,"Discovering active work…":`正在发现活动工作…`,"No active work observed. Idle terminals and owners are not listed.":`未观察到活动工作。空闲终端和 owner 不列入此处。`,"Unattributed work":`无法归属的工作`,"Terminal turn (observe only)":`终端回合(只读观察)`,"Owner turn":`Owner 回合`,"Owner workflow":`Owner 工作流`,"Current observation":`当前观察`,"Stale observation":`观察已过期`,"Unknown activity":`活动状态未知`,"Activity was discovered; session history is not yet readable. No transcript was created.":`已发现活动;会话历史暂不可读。未创建或伪造对话记录。`,turn:`回合中`,settling:`收尾中`,"Complete delivery agreement":`完整交付约定`,"Implementation route updates":`实现路线调整次数`,"Earlier workflow steps":`更早的执行步骤`,"Latest workflow steps":`最新执行步骤`,recovering:`自动诊断与恢复`,learning:`沉淀项目知识`,knowledge:`项目知识`,"Not recorded":`未记录`,"Task branch":`任务分支`,"Task worktree":`任务工作区`,"Delivery target":`交付目标`,"Worktree preparation":`工作区准备`,"Candidate commit":`候选提交`,"Candidate acceptance":`候选验收`,"Checks and automatic Agent review passed":`检查和自动 Agent review 已通过`,"Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed":`已验收:{total} 项检查中有 {count} 项被已记录的偏离搁置,其余检查和自动 Agent review 已通过`,"set aside by a recorded deviation":`已被记录的偏离搁置`,Assignments:`子任务`,"Assignment: {state}":`子任务:{state}`,"{count} running":`{count} 个运行中`,"{count} queued":`{count} 个排队中`,"{count} done":`{count} 个已完成`,"{count} failed":`{count} 个失败`,"{count} superseded":`{count} 个已被取代`,"dropped by route revision {revision}":`在第 {revision} 次路线修订中取消`,"added or rewritten by route revision {revision}":`由第 {revision} 次路线修订新增或改写`,"after {ids}":`在 {ids} 之后`,"own worktree":`独立工作区`,integrated:`已合回`,"kept for inspection":`保留待查看`,"Only the steps on this page are grouped below; other pages hold more.":`下面只归类了本页的步骤,其他分页还有更多步骤。`,"Route revisions":`路线修订`,"Paths added to the write scope after approval:":`批准之后加入写入范围的路径:`,"delivered with 1 deviation":`交付时有 1 处偏离`,"delivered with {count} deviations":`交付时有 {count} 处偏离`,"Deviations from the agreement":`与约定的偏离`,"Deviations from the agreement: {count}":`与约定的偏离:{count} 处`,"Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.":`每一处都是无法按原文满足的验收项或决定,以及实际交付的替代结果。自动 Agent review 会被要求逐条确认;这不是人工审阅。`,"Could not be met":`无法满足`,Why:`原因`,"Delivered instead":`实际交付`,"Checks set aside":`搁置的检查`,None:`无`,"Recorded at":`记录于`,"route revision {revision}":`第 {revision} 次路线修订`,"Local integration":`本地合回`,"Post-merge checks":`合回后检查`,"Worktree cleanup":`工作区清理`,"Task branch delivery":`任务分支交付`,"Policy: keep the task branch; no push or deployment.":`策略:保留任务分支;不推送或部署。`,retained:`已保留`,removed:`已移除`,applied:`已合回`,applying:`合回中`,"Invalid image.":`图片格式无效。`,"Add images":`添加图片`,"Remove image: {name}":`移除图片:{name}`,"Attached image":`附加图片`,"Open image":`打开图片`,"Image unavailable.":`图片暂不可用。`,"Loading image…":`正在加载图片…`,"Remove images before exiting Cadence.":`请先移除图片,再退出 Cadence。`,"The selected model does not support images. Choose a vision model or remove the images.":`当前模型不支持图片。请选择视觉模型或移除图片。`,"Use PNG, JPEG or WebP images.":`请选择 PNG、JPEG 或 WebP 图片。`,"Image is empty.":`图片为空。`,"Context fixed at admission:":`接纳时固定的上下文:`,"Declared write paths use the checkout root:":`声明的写入路径以此 checkout 根目录为基准:`,"No model":`未使用模型`,"The message was not sent ({code}). Its draft is kept.":`消息尚未发送({code})。草稿已保留。`,"Execution 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; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.":`{count} 个模型未列出:其提供方或模型 ID 包含某个凭据值(例如与提供方名称相同的 apiKey)或控制字符。请让每个凭据值都不与任何提供方或模型 ID 重合;修改 models.json 后需重启服务。`,"Model catalog unavailable ({code}); no model is selectable. No automatic retry.":`模型目录不可用({code});无法选择任何模型。不会自动重试。`,"Choice response unconfirmed; observe catalog before another explicit choice.":`选择的响应未确认;请先观察目录再进行下一次显式选择。`,"Confirm owner model choice":`确认所有者模型选择`,"Command receipt":`命令回执`,Admission:`准入`,Execution:`执行`,"not settled":`未结束`,Publication:`发布`,Run:`运行`,"metadata action":`元数据操作`,"{status}. This observation does not authorize replay.":`{status}。此观察不授权重放。`,"Observe exact receipt":`观察确切回执`,"Conflicting receipt observation refused; prior committed facts preserved.":`冲突的回执观察已被拒绝;之前提交的事实已保留。`,"Retained content fields":`保留的内容字段`,"Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.":`仅显示本页中实体 {entity} 的匹配项。继续翻页可查看其他字段/版本。`,"Omitted source block:":`已省略的源块:`,"{bytes} retained bytes":`保留 {bytes} 字节`,"Inspect complete retained field":`查看完整的保留字段`,"Recording: {observed}; source: {source};":`记录:{observed};来源:{source};`,redacted:`已脱敏`,"no reported redaction":`未报告脱敏`,"; omitted: {omissions}":`;已省略:{omissions}`,". Not a guarantee of complete original source or universal secret detection.":`。不保证原始来源完整,也不保证能检测出所有机密。`,"Reading all retained field pages…":`正在读取所有保留字段页…`,"Copied all retained field bytes (source omissions still apply).":`已复制全部保留字段字节(来源省略仍然适用)。`,"Copied retained field bytes; recording is incomplete. No complete-source claim.":`已复制保留字段字节;记录不完整。不声称来源完整。`,"Clipboard unavailable.":`剪贴板不可用。`,"Full-field copy refused/incomplete.":`完整字段复制被拒绝/不完整。`,"Retained field":`保留字段`,"snapshot {seq}":`快照 {seq}`,"Exact hit bytes [{start}, {end}); only this immutable field is highlighted.":`确切命中字节 [{start}, {end});仅高亮这个不可变字段。`,"Markdown page":`Markdown 页`,"Raw page":`原始页`,"Copy full retained field":`复制完整保留字段`,"Copy canceled; execution unchanged.":`复制已取消;执行不受影响。`,"Cancel copy":`取消复制`,"Detail refused: {error}":`详情被拒绝:{error}`,"Reading…":`读取中…`,"Validation in progress. The retained field is not empty.":`正在验证。该保留字段并非为空。`,"Bytes {start}–{end} of {total}.":`第 {start}–{end} 字节,共 {total} 字节。`,"More retained data available.":`还有更多保留数据。`,"End of field.":`字段结束。`,Previous:`上一页`,"Continue validation":`继续验证`,"Next field page":`下一字段页`,"Read unavailable.":`读取不可用。`,"Exact entity metadata":`确切的实体元数据`,"Reading exact entity version…":`正在读取确切的实体版本…`,"Entity refused: {error}":`实体被拒绝:{error}`,"Entity validation in progress, not missing.":`实体正在验证,并非缺失。`,"Continue exact entity validation":`继续确切的实体验证`,"Exact stored owner and associations":`确切存储的所有者与关联`,"Export retained history":`导出保留历史`,"Selected {kind}: {id} · snapshot {seq}":`已选{kind}:{id} · 快照 {seq}`,Format:`格式`,"NDJSON public archive":`NDJSON 公开归档`,"Readable Markdown with footer metadata":`带页脚元数据的可读 Markdown`,"Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.":`包括已加载页之外的保留上下文、消息/工具、任务图、生命周期、变更、检查、人工审阅和覆盖范围。脱敏和来源省略仍然保留。`,"A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.":`浏览器原生下载请求无法证明下载完成。请检查下载文件中的原始 EOF 以及完成尾部/计数/摘要;缺少页脚即表示不完整。访问被撤销时可能在没有尾部的情况下终止。`,"Download requested — completion not verified by this browser UI.":`已请求下载——此浏览器界面未验证是否完成。`,"Download unavailable; no archive claimed complete.":`下载不可用;不声称任何归档完整。`,"Request selected-scope download":`请求下载所选范围`,"Search retained history":`搜索保留历史`,"Case-sensitive literal query":`区分大小写的字面查询`,"Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.":`区分大小写的 UTF-8 字面搜索。范围:{kind} {id};快照 {seq}。不使用正则,不请求提供方,也不修复历史。`,"Searching bounded retained range…":`正在搜索限定的保留范围…`,"Search refused: {error}":`搜索被拒绝:{error}`,"Enter a query to search this selected scope.":`输入查询以搜索所选范围。`,"Matches on this page: {count}":`本页匹配:{count}`,"bytes {start}–{end}":`字节 {start}–{end}`,"Continue same snapshot search":`在同一快照中继续搜索`,"↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.":`↑↓ 移动 · Enter 打开确切命中 · Escape 关闭。重新打开不会恢复执行。`,"Search unavailable or invalid; no automatic retry.":`搜索不可用或无效;不会自动重试。`,"Query must be 1–1024 UTF-8 bytes; it was not clipped.":`查询必须为 1–1024 个 UTF-8 字节;未做截断。`,"No hits in this bounded window; search is not finished.":`此限定窗口中没有命中;搜索尚未完成。`,"No hits in the final retained window. Coverage limits above still apply.":`最后的保留窗口中没有命中。上方的覆盖范围限制仍然适用。`,"Immutable admitted graph":`不可变的已准入任务图`,"Graph refused: {error}":`任务图被拒绝:{error}`,"Reading graph…":`正在读取任务图…`,"Graph validation in progress; not an empty graph.":`任务图正在验证;并非空图。`,"Continue graph validation":`继续验证任务图`,"Find on displayed field page":`在当前字段页中查找`," (first 1000 visual highlights)":`(前 1000 处可视高亮)`,"; not whole-history search":`;不是全历史搜索`,"Previous match":`上一个匹配`,"Next match":`下一个匹配`,"Read refused: {error}. Retained state has not been repaired.":`读取被拒绝:{error}。保留状态未被修复。`,"Reading bounded history page…":`正在读取限定的历史页…`,"Snapshot selected":`已选择快照`,"Validating retained history":`正在验证保留历史`,"; continue this exact read. No data page yet.":`;请继续这次确切读取。尚无数据页。`,"Previous page":`上一页`,"Next page":`下一页`,"Observe a new snapshot":`观察新快照`,"End of this retained snapshot (incomplete).":`此保留快照已结束(不完整)。`,"End of this retained snapshot.":`此保留快照已结束。`,"Open retained episode/child details":`打开保留的执行轮次/子运行详情`,"Inspect admitted graph and plan":`查看已准入的任务图与计划`,"Search all retained pages in selected scope":`搜索所选范围内的所有保留页`,"Select a task to inspect plans, checks, changes and review.":`选择一个任务以查看计划、检查、变更和审阅。`,Inspector:`检查器`,plan:`计划`,checks:`检查`,changes:`变更`,review:`审阅`,"Owner metadata is stale.":`所有者元数据已过期。`,"Owner metadata unavailable.":`所有者元数据不可用。`,"Plan proposal unavailable.":`计划提案不可用。`,"Saved graph proof in progress.":`已保存任务图的证明正在进行。`,"Continue saved graph read":`继续读取已保存的任务图`,"Load observed saved plan into local draft":`将观察到的已保存计划载入本地草稿`,"Current control context unavailable. Historical data is not action authority.":`当前控制上下文不可用。历史数据不能作为操作依据。`,"Captured historical observations":`已捕获的历史观察`,"Human review":`人工审阅`,"Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.":`“完成”记录的是人工确认,而非执行成功或认证。它不能重新启动被阻塞的执行轮次。`,"Episode to review":`要审阅的执行轮次`,"Select an observed episode":`选择一个已观察的执行轮次`,"I acknowledge current unresolved issues if present; original results will not be rewritten.":`我确认当前存在的未解决问题;原始结果不会被改写。`,"Preview human review / Done":`预览人工审阅 / 完成`,"Observe current obligations in Checks before requesting review.":`请求审阅前,请先在“检查”中观察当前检查项。`,readonly:`只读`,Edit:`编辑`,Purpose:`用途`,Instructions:`指令`,View:`视图`,"Raw text / lines":`原始文本 / 行`,"Safe Markdown":`安全 Markdown`,"Observed diff":`观察到的 diff`,"Wrap: on":`换行:开`,"Wrap: off":`换行:关`,"Zoom +":`放大 +`,"Zoom −":`缩小 −`,"Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.":`仅为捕获的页面,不是对当前文件系统的读取。行号仅在本页内有效。上方提供完整的保留分页和复制。`,"Page headings":`页面标题`,"Select page line {line}":`选择页内第 {line} 行`,"Selected page lines {start}–{end}":`已选页内第 {start}–{end} 行`,"Clear selection":`清除选择`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"Copy message":`复制消息`,"Message actions":`消息操作`,"No path recorded":`未记录路径`,"{added} lines added, {removed} removed":`新增 {added} 行,删除 {removed} 行`,"Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.":`根据这次调用记录下来的参数生成,没有与文件比对,因此不能证明文件现在的内容。`,"Error recorded: requested, not applied":`记录到错误:仅为请求内容,未应用`,"Requested content":`请求写入的内容`,"Requested change":`请求的修改`,"No lines recorded.":`没有记录任何行。`,"Replacement {index} of {count}: {removed} lines for {added}":`第 {index} 处替换(共 {count} 处):{removed} 行换成 {added} 行`,"Showing the first {shown} of {total} lines.":`仅显示前 {shown} 行,共 {total} 行。`,"Show all lines":`显示全部行`,"Open image: {name}":`放大查看图片:{name}`,"Zoom out":`缩小`,"Zoom in":`放大`,"Actual size":`原始大小`,"Fit to window":`适应窗口`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"Filter conversations…":`筛选对话…`,"Clear filter":`清除筛选`,"No listed conversation matches. Pages not loaded are not searched.":`已列出的对话中没有匹配项。尚未加载的分页不在筛选范围内。`,Today:`今天`,Yesterday:`昨天`,Earlier:`更早`,Rename:`重命名`,"Rename {title}":`重命名“{title}”`,Archive:`归档`,"Archive {title}":`归档“{title}”`,Unarchive:`取消归档`,"Unarchive {title}":`取消归档“{title}”`,"Conversation name":`对话名称`,"Empty: titled by its first message":`留空则以第一条消息作标题`,"Save name":`保存名称`,"Keep the current name":`保留现有名称`,"A name can have at most {count} characters.":`名称最多 {count} 个字符。`,"Renaming…":`正在重命名…`,"Archiving…":`正在归档…`,"Unarchiving…":`正在取消归档…`,"The conversation was not renamed ({code}). Its name is unchanged.":`对话没有重命名({code}),名称保持不变。`,"The conversation was not archived ({code}). It stays in the history.":`对话没有归档({code}),仍在历史对话中。`,"The conversation was not unarchived ({code}). It stays archived.":`对话没有取消归档({code}),仍处于归档状态。`,"Rename outcome is unknown ({code}). The list shows the recorded name when it is read again; nothing is retried.":`重命名的结果未知({code})。重新读取列表后会显示已记录的名称;不会自动重试。`,"Archive outcome is unknown ({code}). The lists show the recorded state when they are read again; nothing is retried.":`归档操作的结果未知({code})。重新读取列表后会显示已记录的状态;不会自动重试。`,"Rename and archive need the execution service; it starts with your next Send.":`重命名和归档需要执行服务在运行;下次发送消息时会启动它。`,"Rename and archive are unavailable until the execution service is observed.":`读取到执行服务的状态后,才能重命名和归档。`,"Archived conversations":`已归档的对话`,"Show archived":`查看已归档的对话`,"Back to history":`返回历史对话`,"Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.":`归档只是不再把对话列在历史对话里,会话文件不会被移动或删除。`,"Archived conversations could not be read. This is not an empty list.":`无法读取已归档的对话,这不代表列表为空。`,"Reading archived conversations…":`正在读取已归档的对话…`,"No archived conversations.":`没有已归档的对话。`,Archived:`已归档`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,"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 restart the service.":`还没有配置模型。请在 Pi 的 models.json 或 auth.json 中添加提供方,然后重启服务。`,"Thinking level: {level}":`思考级别:{level}`,Thinking:`思考`,"The model list could not be read ({code}).":`无法读取模型列表({code})。`,"Read again":`重新读取`,"The model was not changed ({code}).":`模型未切换({code})。`,"Switching model…":`正在切换模型…`,"This model is used for future messages in this conversation. Work already started keeps its original model.":`此模型用于当前会话后续发送的消息,已开始的工作仍使用原模型。`,"Type a message below. Turn on Cadence mode to agree on a plan before implementation.":`在下方输入消息开始对话。打开 Cadence 模式可以先商定计划再实施。`,"Cadence mode":`Cadence 模式`,"Cadence mode is on. Click to exit it.":`Cadence 模式已开启,点击退出。`,"Your next message turns on Cadence mode. Click to cancel.":`发送下一条消息时将开启 Cadence 模式,点击取消。`,"Turn on Cadence mode: agree on a plan before implementation.":`开启 Cadence 模式:先商定计划,再开始实施。`,"Your next message turns on Cadence mode.":`发送下一条消息时将开启 Cadence 模式。`,"The service is unavailable right now ({code}).":`服务暂时不可用({code})。`,"Another operation is still in progress ({code}). Try again when it finishes.":`另一项操作仍在进行({code}),结束后再试。`,"Model credentials are unavailable ({code}). Check auth.json or the provider's API key.":`模型凭据不可用({code}),请检查 auth.json 或提供方的 API key。`,"A selected file was refused ({code}); nothing was changed. Run cadence doctor to see which file and field.":`所选文件被拒绝({code}),未做任何修改。运行 cadence doctor 查看是哪个文件和字段。`,"This is not supported here ({code}).":`此处不支持该操作({code})。`,"A limit was reached ({code}).":`已达到上限({code})。`,More:`更多`,"Refresh status":`刷新状态`,"Disconnect this page":`断开此页面`,"Started work keeps running.":`已开始的工作会继续运行。`,"No conversations yet.":`还没有对话。`,"Conversations are kept with each project. Click a project to open it.":`对话按项目保存,点击项目即可打开。`,"Opening…":`正在打开…`,"Open a working folder to start. Each project keeps its own conversations.":`打开一个工作文件夹即可开始,每个项目保存各自的对话。`,"Open a folder…":`打开文件夹…`,"Open a working folder to start chatting.":`打开工作文件夹后即可开始对话。`,"{path} could not be opened ({code}).":`无法打开 {path}({code})。`,"Cadence service":`Cadence 服务`,"Version, restart and upgrade.":`版本、重启和升级。`,"Reading the service…":`正在读取服务状态…`,"Runs as {unit} ({scope} systemd service).":`以 {unit} 运行({scope} 级 systemd 服务)。`,"This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.":`此 Cadence 实例不是由 systemd 服务启动的,页面无法重启或升级它。请在终端中运行 cadence server restart。`,"Last request ({time}): {outcome}":`上次请求({time}):{outcome}`,"Installation: npm global.":`安装方式:npm 全局安装。`,"Installation: npm local.":`安装方式:npm 本地安装。`,"Installation: Bun local.":`安装方式:Bun 本地安装。`,"Installation: Bun global.":`安装方式:Bun 全局安装。`,"Installation: Pi-managed (npm).":`安装方式:Pi 管理(npm)。`,"Installation: Pi-managed (Bun).":`安装方式:Pi 管理(Bun)。`,"Pi pins this package version; change its package declaration explicitly before upgrading.":`Pi 固定了此包的版本;请先明确修改包声明,再升级。`,"This account cannot write the installation; update it in a terminal.":`当前账户无法写入安装目录;请在终端中更新。`,"The installation method could not be safely identified; update it using its original installation method.":`无法可靠识别安装方式;请按原安装方式更新。`,Updates:`更新`,"Update information is unavailable for this installation.":`无法获取此安装的更新信息。`,"Check for updates":`检查更新`,"Asking the package registry for the latest version…":`正在向软件包仓库查询最新版本…`,"Cadence {version} is the latest version.":`Cadence {version} 已是最新版本。`,"{version} is deprecated on npm and is not offered.":`{version} 在 npm 上已弃用,不提供升级。`,"{version} is available, but this account cannot write the installation; upgrade it in a terminal.":`{version} 可用,但当前账户无法写入安装目录;请在终端中升级。`,"{version} is available, but this installation requires a manual update using its original installation method.":`{version} 可用,但当前安装需要按原安装方式手动更新。`,"Upgrade to {version}":`升级到 {version}`,"Restart service":`重启服务`,"Restart Cadence?":`重启 Cadence?`,"Upgrade Cadence {from} to {to}?":`将 Cadence 从 {from} 升级到 {to}?`,"The service stops in order and starts again; this page waits and then reloads.":`服务会按顺序停止并重新启动;此页面会等待完成后重新加载。`,"The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.":`包管理器会在 Cadence 继续运行时下载 {to};然后服务停止、安装 {to} 并重新启动。如果 {to} 未能就绪,会重新安装 {from}。`,"{count} running workflows or conversations will be stopped.":`{count} 个正在运行的工作流或会话将被停止。`,"Stop them and continue":`停止它们并继续`,"Restart now":`立即重启`,"Upgrade now":`立即升级`,"Stopping Cadence…":`正在停止 Cadence…`,"Cadence is starting again…":`Cadence 正在重新启动…`,"Downloading {to}, then stopping Cadence…":`正在下载 {to},随后停止 Cadence…`,"Installing {to} and starting Cadence…":`正在安装 {to} 并启动 Cadence…`,"This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.":`此操作在服务之外运行:关闭或刷新页面不会中断它,运行中的工作会按顺序停止。`,"Reload the page to reconnect to the new service.":`重新加载页面以连接新的服务。`,"Details in a terminal:":`在终端中查看详情:`,"Reload page":`重新加载页面`,"Cadence did not report back within {minutes} minutes.":`Cadence 在 {minutes} 分钟内没有返回结果。`,"Cadence answered with a different version.":`Cadence 以另一个版本响应。`,"Cadence restarted.":`Cadence 已重启。`,"Cadence {version} was already installed.":`Cadence {version} 已经安装。`,"Cadence {version} is running.":`Cadence {version} 正在运行。`,"Cadence {to} did not become ready; {version} was reinstalled.":`Cadence {to} 未能就绪,已重新安装 {version}。`,"In progress…":`进行中…`,"The restart did not finish: {reason}":`重启未完成:{reason}`,"The upgrade did not finish: {reason}":`升级未完成:{reason}`,"The release could not be downloaded; the service kept running.":`无法下载该版本;服务保持运行。`,"The running service did not confirm its orderly stop.":`正在运行的服务没有确认有序停止。`,"The package manager could not install the release.":`包管理器无法安装该版本。`,"The new service did not become ready.":`新服务未能就绪。`,"The service manager refused the operation.":`服务管理器拒绝了此操作。`,"The job ended without reporting.":`任务在报告结果前结束。`,"The service was not changed; this page stays connected.":`服务没有改动;此页面保持连接。`,Close:`关闭`,"Conversation branches":`对话分支`,"Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).":`每行是一条消息,缩进的是分支。选择一行即可查看那条分支。终端里看到的是同一棵树(Pi 中的 /tree)。`,"Only the newest messages are listed.":`只列出了最新的消息。`,"Started in the terminal":`在终端中开始`,"Started in the WebUI":`在 WebUI 中开始`,"Branches ({count})":`分支({count})`,Branches:`分支`,"Show the latest":`查看最新`,"Filter messages…":`筛选消息…`,"Refresh branches":`刷新分支`,"A chosen branch is shown, not the latest.":`当前显示的是你选中的分支,不是最新的。`,"No messages yet.":`还没有消息。`,"No matching messages":`没有匹配的消息`,"Edit and resend: {text}":`编辑并重新发送:{text}`,"Continue from here: {text}":`从这里继续:{text}`,"Send the next message from the end of this turn. It starts a new branch there; the later turns stay on theirs and nothing is deleted.":`下一条消息接在这一轮结束的位置发送,并从那里开始一个新分支;后面的轮次留在原来的分支上,不会删除任何内容。`,"Continue from here":`从这里继续`,"Edit and resend":`编辑并重新发送`,"Put this message back in the composer. Sending it starts a new branch beside this one; nothing is deleted.":`把这条消息放回输入框。发送后会在它旁边开始一个新分支,不会删除任何内容。`,"Conversation turn, not in the new message's context":`对话轮次,不会进入新消息的上下文`,"Version {index} of {count}":`第 {index} 个版本,共 {count} 个`,"Previous version":`上一个版本`,"Next version":`下一个版本`,"This message cannot be rewritten from here: the entry it continued is not known.":`无法从这里重写这条消息:不知道它接在哪一条记录之后。`,"Part of the message could not be read back. Check the text and images before sending.":`这条消息有一部分没能读回来。发送前请检查文字和图片。`,"That message could not be found in this conversation.":`在这段对话里找不到那条消息。`,"Rewriting a message":`正在重写一条消息`,"Continuing after an earlier turn":`接在较早的一轮之后继续`,"Send starts a new branch beside it; that message and the turns after it stay on their branch and are not in the new context.":`发送后会在它旁边开始一个新分支;那条消息和之后的轮次留在原来的分支上,不会进入新的上下文。`,"Send starts a new branch after that turn; the turns after it stay on their branch and are not in the new context.":`发送后会在那一轮之后开始一个新分支;再往后的轮次留在原来的分支上,不会进入新的上下文。`,"Only the conversation is rewound: files on disk stay as they are.":`回退的只是对话,磁盘上的文件不会变。`,"Reading the message's images…":`正在读取这条消息的图片…`,"Attachments that were not retained are not attached again.":`没有保留下来的附件不会重新附上。`,"Cancel and restore the draft that was here":`取消,并恢复原来的草稿`,Cancel:`取消`,"A chosen branch is shown, not the latest. A message sent now continues from the end of what is shown; the rest stays in the session.":`当前显示的是你选中的分支,不是最新的。现在发送的消息会接在所显示内容的末尾,其余内容仍保留在会话中。`,"From here on, the turns stay on their branch: the message being written will not have them in its context.":`从这里往下的轮次留在原来的分支上:正在写的这条消息的上下文里不会有它们。`,"Questions in this conversation":`这段对话里的提问`,"Message box height: automatic. Drag or use the arrow keys to set it.":`输入框高度:自动。拖动或用方向键可以调整。`,"Message box height: fixed. Double-click or press Home for automatic.":`输入框高度:固定。双击或按 Home 键恢复自动。`,Automatic:`自动`,"{pixels} pixels":`{pixels} 像素`,"Files to reference":`可引用的文件`,"Files in the conversation folder":`对话文件夹里的文件`,"Enter inserts the path · Esc closes":`回车插入路径 · Esc 关闭`,"This Cadence conversation format is no longer supported. Start a new conversation; existing files are kept ({code}).":`此版本不再支持这类旧 Cadence 会话。请新建会话;原有文件会保留({code})。`},_=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
|
|
2
2
|
|
|
3
|
-
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var
|
|
4
|
-
`&&e!==` `||e.charCodeAt(0)===127||/[--]/u.test(e))&&qn(e,`contains an invisible control character (only newline and tab are accepted)`);return f}function lr(e){return e.documents??e.knowledge??[]}function ur(e){return[...new Set([...e.tasks.flatMap(e=>e.writes),...lr(e)])]}function dr(e,t,n){return Zn(n,e,16,(e,n)=>{if(Object.hasOwn(e??{},`research`)){let t=Qn(n,e,[`research`,`reason`]),r=typeof t.research==`string`?er(t.research):null;return r===null&&qn(`${n}.research`,`${typeof t.research==`string`?`${Jn(t.research)} `:``}is not an investigation; give the "investigation" value of a completed research step`),{research:r,reason:Xn(`${n}.reason`,t.reason,Wn.reason,!0)}}let r=Qn(n,e,[`path`,`reason`],[`section`]);return{path:Yn(`${n}.path`,()=>rr(r.path,t)),...r.section===void 0?{}:{section:Xn(`${n}.section`,r.section,256,!0)},reason:Xn(`${n}.reason`,r.reason,Wn.reason,!0)}})}var fr=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 pr(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 mr(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 hr(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 gr(e){let t=U(e,[`policy`,`target`]),n=U(t.target,[`checkoutRoot`,`repository`,`repositoryIdentity`,`branch`,`head`]);return{policy:B(t.policy,[`task-branch-v1`]),target:{checkoutRoot:hr(n.checkoutRoot),repository:hr(n.repository),repositoryIdentity:K(n.repositoryIdentity),branch:mr(n.branch),head:pr(n.head)}}}function _r(e){let t=U(e,[`binding`,`taskBranch`,`worktreeRoot`,...Object.hasOwn(e??{},`artifacts`)?[`artifacts`]:[],`preparation`,`workspace`,`candidate`,`acceptance`,`integration`,`postChecks`,`cleanup`]),n=U(t.integration,[`status`,`before`,`after`,`reason`]),r=U(t.cleanup,[`status`,`reason`]),i=e=>L(e,160,!0),a=H(t.acceptance,e=>{let t=U(e,[`candidate`,`tree`,`planDigest`,`contextDigest`,`checks`,`review`,...Object.hasOwn(e??{},`waived`)?[`waived`]:[]]),n=W(t.checks,Wn.checks,i);if(!n.length||new Set(n).size!==n.length)throw Error(`Invalid acceptance checks`);return{candidate:pr(t.candidate),tree:pr(t.tree),planDigest:K(t.planDigest),contextDigest:K(t.contextDigest),checks:n,review:i(t.review),...t.waived===void 0?{}:{waived:W(t.waived,Wn.checks,i).filter(e=>n.includes(e))}}}),o=H(t.candidate,pr);if(a&&a.candidate!==o)throw Error(`Stale candidate acceptance`);let s=H(t.workspace,e=>{let t=U(e,[`head`,`state`]);return{head:pr(t.head),state:B(t.state,[`preparing`,`ready`,`removed`,`retained`])}}),c=gr(t.binding),l=mr(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:hr(t.worktreeRoot),...t.artifacts===void 0?{}:{artifacts:W(t.artifacts,256,e=>{let t=U(e,[`id`,`path`,`base`,`head`,`applied`,`state`]);return{id:ir(t.id),path:hr(t.path),base:pr(t.base),head:pr(t.head),applied:H(t.applied,pr),state:B(t.state,[`preparing`,`ready`,`removed`,`retained`])}})},preparation:B(t.preparation,[`pending`,`ready`,`unknown`]),workspace:s,candidate:o,acceptance:a,integration:{status:B(n.status,[`pending`,`blocked`,`applying`,`applied`,`unknown`]),before:pr(n.before),after:H(n.after,pr),reason:L(n.reason,2048)},postChecks:B(t.postChecks,[`not-run`,`passed`,`failed`,`unknown`]),cleanup:{status:B(r.status,[`pending`,`removed`,`retained`]),reason:L(r.reason,2048)}}}function vr(e){if(!e)return``;let t=e.target;return`Target: ${t.branch} @ ${t.head}\nTarget checkout: ${t.checkoutRoot}\nExecution: new cadence/<goal>-<run-id> branch and one stable isolated worktree after approval. Assignments that can run side by side each work in a temporary worktree of their own beside it; the service commits that work and picks it onto the candidate.\nAcceptance: checks and automatic Agent review of the exact candidate.\nDelivery: fast-forward only into the bound target, unchanged since approval or this run's last confirmed merge. Keep the task branch; remove only owned worktrees without any residue, including ignored files. No source/profile/dependency copying, push or deployment.`}function yr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`display`),n=U(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:G(n.revalidatedFrom)},...n.delivery===void 0?{}:{delivery:gr(n.delivery)},id:G(n.id),epoch:G(n.epoch),digest:K(n.digest),observation:K(n.observation),model:hn(n.model),plan:cr(n.plan),cwd:L(n.cwd,4096,!0),...n.checkoutRoot===void 0?{}:{checkoutRoot:L(n.checkoutRoot,4096,!0)},...t?{display:(()=>{let e=U(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 br(e){let t=Object.getOwnPropertyDescriptor(e??{},`action`)?.value;if(t===`research`){let n=U(e,[`action`,`goal`,`questions`,`model`,...Object.hasOwn(e??{},`roots`)?[`roots`]:[]]),r=W(n.questions,Wn.questions,e=>L(e,8192,!0));if(!r.length)throw Error(`Research needs a question`);let i=n.roots===void 0?void 0:W(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:hn(n.model)}}if(t===`propose`){let n=U(e,[`action`,`plan`,`model`]);return{action:t,plan:cr(n.plan),model:hn(n.model)}}if(t===`prepare`||t===`execute`){let n=U(e,t===`execute`?[`action`,`proposalId`,`digest`,`grant`]:[`action`,`proposalId`,`digest`]),r={proposalId:G(n.proposalId),digest:K(n.digest)};return t===`prepare`?{action:t,...r}:{action:t,...r,grant:G(n.grant)}}let n=U(e,[`action`,`runId`]);return{action:B(n.action,[`cancel`]),runId:G(n.runId)}}function xr(e){let t=U(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=>B(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=U(t.verification,[`id`,`source`,`steps`]);return{id:G(e.id),source:K(e.source),steps:W(e.steps,32,e=>L(e,160,!0))}})()},...t.stepsBefore===void 0?{}:{stepsBefore:R(t.stepsBefore,0)},...t.revision===void 0?{}:{revision:R(t.revision,0)},...t.scope===void 0?{}:{scope:W(t.scope,1024,e=>rr(e))},...t.deviations===void 0?{}:{deviations:W(t.deviations,16,e=>{let t=U(e,[`revision`,`item`,`reason`,`delivered`,`waives`]);return{revision:R(t.revision,0),item:L(t.item,2048,!0),reason:L(t.reason,4096,!0),delivered:L(t.delivered,4096,!0),waives:W(t.waives,16,e=>L(e,128,!0))}})},...t.tasks===void 0?{}:{tasks:W(t.tasks,Wn.route,e=>{let t=U(e,[`id`,`title`,`after`,`state`,...Object.hasOwn(e??{},`revision`)?[`revision`]:[]]);return{id:ir(t.id),title:L(t.title,256,!0),after:W(t.after,Wn.tasks,e=>ir(e)),state:B(t.state,Gn),...t.revision===void 0?{}:{revision:R(t.revision,1,1e6)}}})},...t.delivery===void 0?{}:{delivery:_r(t.delivery)},...t.execution===void 0?{}:{execution:mn(t.execution)},...t.diagnostics===void 0?{}:{diagnostics:kr(t.diagnostics)},id:G(t.id),epoch:G(t.epoch),goal:L(t.goal,8192),status:t.status===`queued`?`queued`:n(t.status),phase:B(t.phase,[`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`finished`]),notice:L(t.notice,2048),mergedCommit:H(t.mergedCommit,e=>L(e,64,!0)),humanReviewed:!1,steps:W(t.steps,256,e=>{let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`childRunId`),r=U(e,[`id`,`kind`,`status`,`text`,`exitCode`,`truncated`,...Object.hasOwn(e??{},`timing`)?[`timing`]:[],...Object.hasOwn(e??{},`runtime`)?[`runtime`]:[],...t?[`childRunId`]:[]]);return{...r.timing===void 0?{}:{timing:Or(r.timing)},...r.runtime===void 0?{}:{runtime:(()=>{let e=U(r.runtime,[`sdkVersion`,`workerHash`]);return{sdkVersion:L(e.sdkVersion,128,!0),workerHash:K(e.workerHash)}})()},id:L(r.id,160,!0),...t?{childRunId:G(r.childRunId)}:{},kind:B(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)?B(r.status,[`partial`,`blocked`]):n(r.status),text:L(r.text,65536),exitCode:H(r.exitCode,e=>R(e,-2147483648,2147483647)),truncated:z(r.truncated)}})}}function Sr(e){let t=Object.getOwnPropertyDescriptor(e??{},`type`)?.value;if(t===`run`)return{type:t,run:xr(U(e,[`type`,`run`]).run)};if(t===`proposal`)return{type:t,proposal:yr(U(e,[`type`,`proposal`]).proposal)};let n=U(e,[`type`,`proposal`,`grant`,`expiresAt`]);return{type:B(n.type,[`grant`]),proposal:yr(n.proposal),grant:G(n.grant),expiresAt:R(n.expiresAt,0)}}var Cr=e=>`${e.name}: ${e.command} (${e.timeoutMs===void 0?`no timeout`:`${e.timeoutMs}ms`})`,wr=e=>`research`in e?`investigation ${e.research} — ${e.reason}`:`${e.path}${e.section?` § ${e.section}`:``} — ${e.reason}`;function Tr(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 Er(e){let t=lr(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${or(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(wr).join(`; `)}`:``}\n${e.instructions}`).join(`
|
|
3
|
+
`)&&n.getUint32(8)===13&&r(12,`IHDR`))i=n.getUint32(16),a=n.getUint32(20);else if(t===`image/jpeg`&&e[0]===255&&e[1]===216)for(let t=2;t+3<e.length&&e[t++]===255;){for(;e[t]===255;)t++;let r=e[t++];if(r===217||r===218)break;if(r===1||r>=208&&r<=215)continue;if(t+2>e.length)break;let o=n.getUint16(t);if(o<2||t+o>e.length)break;if([192,193,194,195,197,198,199,201,202,203,205,206,207].includes(r)&&o>=8){a=n.getUint16(t+3),i=n.getUint16(t+5);break}t+=o}else if(t===`image/webp`&&e.length>=30&&r(0,`RIFF`)&&r(8,`WEBP`)&&n.getUint32(4,!0)+8===e.length){if(r(12,`VP8X`))i=1+e[24]+(e[25]<<8)+(e[26]<<16),a=1+e[27]+(e[28]<<8)+(e[29]<<16);else if(r(12,`VP8 `)&&e[23]===157&&e[24]===1&&e[25]===42)i=n.getUint16(26,!0)&16383,a=n.getUint16(28,!0)&16383;else if(r(12,`VP8L`)&&e[20]===47){let e=n.getUint32(21,!0);i=1+(e&16383),a=1+(e>>>14&16383)}}if(!i||!a)throw Error(`Invalid image dimensions or header`);return{width:i,height:a}}var Kn={tasks:16,route:48,questions:32,checks:16,bytes:262144,context:32768,reason:1024,historyScanEntries:200,historyPage:20,historyScans:16,historyIdleMs:12e4},qn=[`queued`,`running`,`completed`,`failed`,`superseded`],Jn=class extends Error{};function Yn(e,t){throw new Jn(`${e}: ${t}`)}var Xn=e=>JSON.stringify(rr(e,80));function Zn(e,t){try{return t()}catch(t){if(t instanceof Jn)throw t;return Yn(e,t instanceof F?t.code===`oversize`?`is too long`:`is not valid`:t instanceof Error?t.message:`is not valid`)}}function Qn(e,t,n,r=!1){if(t===void 0)return Yn(e,`is missing`);if(typeof t!=`string`)return Yn(e,`must be text`);if(r&&!t.trim())return Yn(e,`must not be empty`);let i=R(t);return i>n?Yn(e,`is ${i} bytes; at most ${n}`):Zn(e,()=>L(t,n,r))}function $n(e,t,n,r){return t===void 0?Yn(e,`is missing`):Array.isArray(t)?t.length>n?Yn(e,`has ${t.length} entries; at most ${n}`):Zn(e,()=>G(t,n,e=>e)).map((t,n)=>r(t,`${e}[${n}]`)):Yn(e,`must be a list`)}function er(e,t,n,r=[]){if(t===void 0)return Yn(e,`is missing`);if(typeof t!=`object`||!t||Array.isArray(t))return Yn(e,`must be an object`);let i=Object.keys(t),a=[...n,...r],o=i.filter(e=>!a.includes(e));if(o.length)return Yn(e,`has no field ${o.map(Xn).join(`, `)}; its fields are ${a.join(`, `)}`);let s=n.filter(e=>!i.includes(e));return s.length?Yn(e,`is missing ${s.join(`, `)}`):Zn(e,()=>W(t,a.filter(e=>i.includes(e))))}var tr=/^(?: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 nr(e){return tr.exec(e)?.[1]??null}function rr(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 ir(e,t){return e.some(e=>t===e||t.startsWith(`${e}/`))}function ar(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 or=(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 sr(e,t=`check`){let n=er(t,e,[`name`,`command`],[`timeoutMs`]);return{name:Qn(`${t}.name`,n.name,128,!0),command:Qn(`${t}.command`,n.command,4096,!0),...n.timeoutMs===void 0?{}:{timeoutMs:Zn(`${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 cr(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 lr(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 cr(e),r(t),cr(e).filter(e=>n.has(e.id))}function ur(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,Kn.bytes)}catch(e){Yn(`plan`,e instanceof F&&e.code===`oversize`?`is larger than ${Kn.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=er(`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)=>$n(t,e,16,(e,t)=>Zn(t,()=>{let t=ar(e,n);if(!t.endsWith(`.md`))throw Error(`must be a Markdown file (.md)`);return t})),c=$n(`tasks`,o.tasks,Kn.tasks,(e,t)=>{let r=er(t,e,[`id`,`title`,`instructions`,`writes`,`after`,...a?[`reads`]:[]]);return{id:Zn(`${t}.id`,()=>or(r.id,n)),title:Qn(`${t}.title`,r.title,256,!0),instructions:Qn(`${t}.instructions`,r.instructions,8192,!0),writes:$n(`${t}.writes`,r.writes,128,(e,t)=>Zn(t,()=>ar(e,n))),after:$n(`${t}.after`,r.after,Kn.tasks,(e,t)=>Zn(t,()=>or(e,n))),...a?{reads:pr(r.reads,n,`${t}.reads`)}:{}}});c.length||Yn(`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&&Yn(`${n}.id`,`${Xn(t.id)} is already the id of tasks[${l.indexOf(t.id)}]`),t.writes.length||Yn(`${n}.writes`,`needs at least one path this assignment writes`),new Set(t.writes).size!==t.writes.length&&Yn(`${n}.writes`,`lists a path twice`),new Set(t.after).size!==t.after.length&&Yn(`${n}.after`,`lists an assignment twice`);let r=t.after.find(e=>!l.includes(e));r!==void 0&&Yn(`${n}.after`,`names ${Xn(r)}, which is not the id of an assignment in tasks`)}Zn(`tasks`,()=>cr(c));for(let e of r?[]:c)for(let t of c)if(!(e.id>=t.id||lr(c,e.id).some(e=>e.id===t.id)||lr(c,t.id).some(t=>t.id===e.id))&&(e.writes.some(e=>ir(t.writes,e))||t.writes.some(t=>ir(e.writes,t))))throw Error(`Independent tasks share write paths; assign an owner and dependency`);let u=(e,t,n)=>$n(t,e,n,sr),d=u(o.checks,`checks`,Kn.checks);d.length||Yn(`checks`,`needs at least one real verification command`);let f={goal:Qn(`goal`,o.goal,8192,!0),design:Qn(`design`,o.design,32768,!0),decisions:Qn(`decisions`,o.decisions,16384),acceptance:Qn(`acceptance`,o.acceptance,16384,!0),...a?{version:3,assumptions:Qn(`assumptions`,o.assumptions,16384),documents:s(o.documents,`documents`),reviewReads:pr(o.reviewReads,n,`reviewReads`),policy:{installs:Zn(`policy.installs`,()=>{try{return B(er(`policy`,o.policy,[`installs`]).installs)}catch(e){throw e instanceof Jn?e:Error(`must be true or false`)}})}}:r?{version:2,knowledge:s(o.knowledge,`knowledge`)}:{projectContext:Qn(`projectContext`,o.projectContext,16384),repairAttempts:Zn(`repairAttempts`,()=>z(o.repairAttempts,0,2))},tasks:c,checks:d,setup:$n(`setup`,o.setup,4,(e,t)=>{let{placement:r,...i}=er(t,e,[`name`,`command`,...n?[`placement`]:[]],[`timeoutMs`,...n?[]:[`placement`]]);return{...sr(i,t),...r===void 0?{}:{placement:Zn(`${t}.placement`,()=>V(r,[`target`,`candidate`,`worktree`]))}}}),baselineChecks:u(o.baselineChecks,`baselineChecks`,Kn.checks),delivery:Zn(`delivery`,()=>{try{return V(o.delivery,[`local-merge`,`working-copy`])}catch{throw Error(`is local-merge or working-copy`)}})},p=R(mr(f));p>Kn.context&&Yn(`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 ${Kn.context}`);let m=R(fr(f).join(`, `));m>16384&&Yn(`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!==`
|
|
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(`
|
|
5
5
|
|
|
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 Br(e,t,n=!1){let r=e.role===`tool`,i=r||e.role===`thinking`,a=i?``:Rr(e.text,Ir);return{id:e.id,role:e.role,text:a,...e.images?.length?{images:e.images}:{},clipped:!i&&(n||a!==e.text),name:e.name,target:r?Rr(zr(e.args),Lr):``,error:e.error,parts:t}}function Vr(e){let t=U(e,[`id`,`updatedAt`]);return{id:dn(t.id),updatedAt:R(t.updatedAt,0)}}var Hr=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function Ur(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversation-context`:case`conversation-models`:return{kind:t,location:fn(U(e,[`kind`,`location`]).location)};case`conversation-turn`:{let n=U(e,[`kind`,`id`,`leaf`,`ordinal`,`before`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),ordinal:R(n.ordinal,0),before:H(n.before,e=>R(e,0))}}case`conversation-image`:{let n=U(e,[`kind`,`id`,`leaf`,`entry`,`index`,`offset`,...Object.hasOwn(e??{},`live`)?[`live`]:[]]),r=R(n.offset,0);if(r%Bn.chunkChars||n.live!==void 0&&n.live!==!0)throw new F(`invalid`);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),...n.live===void 0?{}:{live:!0},entry:Mr(n.entry),index:R(n.index,0),offset:r}}case`conversation-step`:{let n=U(e,[`kind`,`id`,`leaf`,`turnId`,`step`,`part`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),turnId:Mr(n.turnId),step:R(n.step,0),part:R(n.part,0)}}case`cadence-conversation`:return{kind:t,id:dn(U(e,[`kind`,`id`]).id)};case`conversation-tree`:{let n=U(e,[`kind`,`id`,`leaf`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr)}}case`workflow-history`:{let n=Object.hasOwn(e,`scan`),r=U(e,[`kind`,`after`,...n?[`scan`]:[]]);return{kind:t,after:H(r.after,G),...n?{scan:G(r.scan)}:{}}}case`workflow-active`:return U(e,[`kind`]),{kind:t};case`workflow-transcript`:case`workflow-detail`:{let n=U(e,[`kind`,`id`,`stepId`]);return{kind:t,id:G(n.id),stepId:L(n.stepId,160,!0)}}case`workflow`:{let n=U(e,[`kind`,`id`,...Object.hasOwn(e??{},`before`)?[`before`]:[]]);return{kind:t,id:G(n.id),...n.before===void 0?{}:{before:R(n.before,1)}}}case`conversations`:{let n=Object.hasOwn(e,`after`),r=Object.hasOwn(e,`archived`),i=U(e,[`kind`,...n?[`after`]:[],...r?[`archived`]:[]]);if(r&&i.archived!==!0)throw new F(`invalid`);return{kind:t,...n?{after:H(i.after,Vr)}:{},...r?{archived:!0}:{}}}case`conversation-active`:case`projects`:return U(e,[`kind`]),{kind:t};case`conversation`:{let n=U(e,[`kind`,`id`,`leaf`,`known`]);return{kind:t,id:dn(n.id),leaf:H(n.leaf,Mr),known:H(n.known,Mr)}}case`file-part`:{let n=Object.hasOwn(e??{},`location`),r=U(e,[`kind`,`path`,`offset`,...n?[`location`]:[]]),i=R(r.offset,0);if(i%196608||i>=67108864)throw new F(`invalid`);return{kind:t,path:L(r.path,4096),offset:i,...n?{location:fn(r.location)}:{}}}default:{let n=(t===`file`||t===`files`)&&Object.hasOwn(e??{},`location`),r=U(e,[`kind`,`path`,...n?[`location`]:[]]);return{kind:B(r.kind,[`files`,`file`,`directories`]),path:L(r.path,4096),...n?{location:fn(r.location)}:{}}}}}function Wr(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 Gr(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`conversation-model`){let n=U(e,[`kind`,`commandId`,`location`,`expected`,`choice`]);return{kind:t,commandId:G(n.commandId),location:fn(n.location),expected:hn(n.expected),choice:me(n.choice)}}if(t===`restore-model`||t===`workflow-cancel`){let n=U(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:G(n.commandId),epoch:G(n.epoch)};return t===`restore-model`?{kind:t,...i,...n.location===void 0?{}:{location:fn(n.location)},...r?{expected:hn(n.expected),choice:me(n.choice)}:{}}:{kind:t,...i,runId:G(n.runId)}}if(t===`cadence-exit`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`revision`,...Object.hasOwn(e??{},`location`)?[`location`]:[]]);return{kind:t,...n.location===void 0?{}:{location:fn(n.location)},commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),revision:R(n.revision,0)}}if(t===`image-upload`){let n=U(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=Gr(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:G(n.commandId),imageId:G(n.imageId),send:r,mimeType:B(n.mimeType,Vn),size:R(n.size,1),offset:R(n.offset,0),data:L(n.data,Bn.chunkChars,!0)}}if(t===`cadence-send`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`,`revision`,`intent`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),text:L(n.text,Pr),...n.images===void 0?{}:{images:W(n.images,2**53-1,G)},model:hn(n.model),revision:R(n.revision,0),intent:B(n.intent,[`message`,`enter`,`exit`])}}if(t===`cadence-revalidate`){let n=U(e,[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`,`head`,`context`,`expected`,`model`]),r=dn(n.conversationId),i=pn(n.context);if(i.id!==r)throw new F(`invalid`);return{kind:t,commandId:G(n.commandId),conversationId:r,revision:R(n.revision,0),proposalId:G(n.proposalId),digest:K(n.digest),head:H(n.head,Mr),context:i,expected:hn(n.expected),model:me(n.model)}}if(t===`cadence-prepare`||t===`cadence-approve`){let n=[`kind`,`commandId`,`conversationId`,`revision`,`proposalId`,`digest`],r=U(e,t===`cadence-approve`?[...n,`grant`]:n),i={commandId:G(r.commandId),conversationId:dn(r.conversationId),revision:R(r.revision,0),proposalId:G(r.proposalId),digest:K(r.digest)};return t===`cadence-prepare`?{kind:t,...i}:{kind:t,...i,grant:G(r.grant)}}if(t===`workflow`){let n=U(e,[`kind`,`commandId`,`epoch`,`request`]);return{kind:t,commandId:G(n.commandId),epoch:G(n.epoch),request:br(n.request)}}if(t===`send`){let n=U(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`model`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),head:H(n.head,Mr),text:L(n.text,Pr),...n.images===void 0?{}:{images:W(n.images,2**53-1,G)},model:hn(n.model)}}if(t===`interrupt`||t===`conversation-input`||t===`conversation-input-cancel`){let n=U(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`,...t===`conversation-input`?[`mode`,`text`]:t===`conversation-input-cancel`?[`inputId`]:[]]),r={commandId:G(n.commandId),conversationId:dn(n.conversationId),turnId:G(n.turnId),epoch:G(n.epoch)};return t===`conversation-input`?{kind:t,...r,mode:B(n.mode,[`steer`,`queue`]),text:L(n.text,Pr,!0)}:t===`interrupt`?{kind:t,...r}:{kind:t,...r,inputId:G(n.inputId)}}if(t===`conversation-rename`){let n=U(e,[`kind`,`commandId`,`conversationId`,`name`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),name:Wr(n.name)}}if(t===`conversation-archive`){let n=U(e,[`kind`,`commandId`,`conversationId`,`archived`]);return{kind:t,commandId:G(n.commandId),conversationId:dn(n.conversationId),archived:z(n.archived)}}let n=U(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:B(n.kind,[`open-project`]),commandId:G(n.commandId),path:L(n.path,4096,!0),epoch:G(n.epoch)}}function Kr(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=U(e,[...t,...n?[`omitted`]:[],...r?[`transcript`]:[],...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[]]),a=r?U(i.transcript,[`pages`]):null,o=n?U(i.omitted,[`thinking`,`media`,`other`]):null;return{...i.execution===void 0?{}:{execution:mn(i.execution)},...i.retry===void 0?{}:{retry:Ge(i.retry)},id:G(i.id),epoch:G(i.epoch),status:B(i.status,Hr),notice:L(i.notice,1024),...a?{transcript:{pages:R(a.pages,0)}}:{},omitted:{thinking:o?z(o.thinking):!1,media:o?z(o.media):!1,other:o?z(o.other):!1},items:W(i.items,256,Yr)}}var qr=[`user`,`assistant`,`tool`,`thinking`];function Jr(e){return W(e,2**53-1,e=>{let t=U(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:Mr(t.entry),index:R(t.index,0),mimeType:B(t.mimeType,Vn)}})}function Yr(e){let t=U(e,[`id`,`role`,`text`,`name`,`args`,`error`,...Object.hasOwn(e??{},`images`)?[`images`]:[]]);return{...t.images===void 0?{}:{images:Jr(t.images)},id:L(t.id,160,!0),role:B(t.role,qr),text:L(t.text,262144),name:L(t.name,128),args:L(t.args,65536),error:z(t.error)}}function Xr(e){let t=U(e,[`id`,`role`,`text`,`clipped`,...Object.hasOwn(e??{},`images`)?[`images`]:[],`name`,`target`,`error`,`parts`]),n={...t.images===void 0?{}:{images:Jr(t.images)},id:L(t.id,160,!0),role:B(t.role,qr),text:L(t.text,Ir),clipped:z(t.clipped),name:L(t.name,128),target:L(t.target,Lr),error:z(t.error),parts:R(t.parts,0)};if((n.role===`tool`||n.role===`thinking`)&&(n.text||n.clipped)||n.role===`thinking`&&!n.parts)throw new F(`invalid`);return n}function Zr(e){let t=U(e,[`id`,`status`,`notice`,`omitted`,`steps`,`stable`,...Object.hasOwn(e??{},`execution`)?[`execution`]:[],...Object.hasOwn(e??{},`retry`)?[`retry`]:[],`entry`,...Object.hasOwn(e??{},`parent`)?[`parent`]:[],`at`]),n=U(t.omitted,[`thinking`,`media`,`other`]),r=R(t.steps,0);return{...t.execution===void 0?{}:{execution:mn(t.execution)},...t.retry===void 0?{}:{retry:Ge(t.retry)},id:Mr(t.id),entry:H(t.entry,Mr),...t.parent===void 0?{}:{parent:H(t.parent,Mr)},at:R(t.at,0),status:B(t.status,Hr),notice:L(t.notice,1024),omitted:{thinking:z(n.thinking),media:z(n.media),other:z(n.other)},steps:r,stable:R(t.stable,0,r)}}function Qr(e){let t=t=>typeof e==`object`&&!!e&&Object.hasOwn(e,t),n=U(e,[`id`,`title`,`leaf`,`status`,`updatedAt`,`origin`,...t(`cadence`)?[`cadence`]:[],...t(`live`)?[`live`]:[],...t(`archived`)?[`archived`]:[]]),r=t(`live`)?U(n.live,[`commandId`,`epoch`]):null;if(t(`archived`)&&n.archived!==!0)throw new F(`invalid`);return{id:dn(n.id),title:L(n.title,512,!0),leaf:H(n.leaf,Mr),status:B(n.status,Hr),updatedAt:R(n.updatedAt,0),origin:B(n.origin,[`terminal`,`webui`]),...t(`cadence`)?{cadence:z(n.cadence)}:{},...r?{live:{commandId:G(r.commandId),epoch:G(r.epoch)}}:{},...t(`archived`)?{archived:!0}:{}}}function $r(e){let t=U(e,[`commandId`,`text`,`status`,`notice`]);return{commandId:G(t.commandId),text:L(t.text,16384),status:B(t.status,Hr),notice:L(t.notice,1024)}}function ei(e){let t=U(e,[`commandId`,`mode`,`text`]);return{commandId:G(t.commandId),mode:B(t.mode,[`steer`,`queue`]),text:L(t.text,256)}}function ti(e){let t=U(e,[`tokens`,`provider`,`model`]);return{tokens:H(t.tokens,e=>R(e,1)),provider:L(t.provider,128),model:L(t.model,256)}}function ni(e){let t=U(e,[`input`,`read`,`write`]);return{input:R(t.input,0),read:R(t.read,0),write:R(t.write,0)}}function ri(e){let t=U(e,[`id`,`parent`,`text`,`at`,`leaf`,`current`]);return{id:Mr(t.id),parent:H(t.parent,Mr),text:L(t.text,1024),at:R(t.at,0),leaf:Mr(t.leaf),current:z(t.current)}}function ii(e){J(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`image-upload`){let n=U(e,[`kind`,`commandId`,`imageId`,`offset`]);return{kind:t,commandId:G(n.commandId),imageId:G(n.imageId),offset:R(n.offset,0)}}if(t===`conversation-image`){let n=U(e,[`kind`,`mimeType`,`data`,`next`]);return{kind:t,mimeType:B(n.mimeType,Vn),data:L(n.data,Bn.chunkChars,!0),next:H(n.next,e=>R(e,0))}}if(t===`conversation-context`)return{kind:t,context:pn(U(e,[`kind`,`context`]).context)};if(t===`conversation-models`)return{kind:t,catalog:xn(U(e,[`kind`,`catalog`]).catalog)};if(t===`conversation-model`){let n=U(e,[`kind`,`commandId`,`choice`]);return{kind:t,commandId:G(n.commandId),choice:gn(n.choice)}}if(t===`workflow-transcript`){let n=U(e,[`kind`,`runId`,`stepId`,`turn`]);return{kind:t,runId:G(n.runId),stepId:L(n.stepId,160,!0),turn:H(n.turn,Kr)}}if(t===`cadence-conversation`)return{kind:t,state:jr(U(e,[`kind`,`state`]).state)};if(t===`workflow-history-progress`){let n=U(e,[`kind`,`after`,`scan`]);return{kind:t,after:H(n.after,G),scan:G(n.scan)}}if(t===`workflow-history`){let n=U(e,[`kind`,`entries`,`next`]),r=W(n.entries,Wn.historyPage,e=>{let t=U(e,[`id`,`run`]),n=G(t.id),r=H(t.run,xr);if(r&&r.id!==n)throw new F(`invalid`);return{id:n,run:r}}),i=H(n.next,G);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=U(e,[`kind`,`runs`,...n?[`links`]:[]]),i=W(r.runs,4,xr),a=n?W(r.links,4,e=>{let t=U(e,[`runId`,`conversationId`]);return{runId:G(t.runId),conversationId:dn(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=U(e,[`kind`,`commandId`,`state`]);return{kind:t,commandId:G(n.commandId),state:jr(n.state)}}if(t===`cadence-grant`){let n=U(e,[`kind`,`commandId`,`grant`,`expiresAt`,`revision`,`proposal`]);return{kind:t,commandId:G(n.commandId),grant:G(n.grant),expiresAt:R(n.expiresAt,0),revision:R(n.revision,0),proposal:yr(n.proposal)}}let n=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(n===`workflow`){let t=U(e,[`kind`,`commandId`,`response`]);return{kind:n,commandId:H(t.commandId,G),response:Sr(t.response)}}if(n===`conversation-active`)return{kind:n,entries:W(U(e,[`kind`,`entries`]).entries,8,Qr)};if(n===`conversations`){let t=U(e,[`kind`,`entries`,`next`]);return{kind:n,entries:W(t.entries,200,Qr),next:H(t.next,Vr)}}if(n===`conversation`){let t=U(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=H(t.summary,Qr),i=R(t.turns,0);if(!r&&i)throw new F(`invalid`);return{kind:n,...t.commands===void 0?{}:{commands:W(t.commands,64,G)},...t.context===void 0?{}:{context:ti(t.context)},...t.cache===void 0?{}:{cache:ni(t.cache)},...t.pending===void 0?{}:{pending:W(t.pending,8,ei)},...t.undelivered===void 0?{}:{undelivered:W(t.undelivered,8,$r)},summary:r,leaf:H(t.leaf,Mr),continues:z(t.continues),turns:i,branches:R(t.branches,0),runs:W(t.runs,200,G),attempt:H(t.attempt,$r)}}if(n===`conversation-tree`){let t=U(e,[`kind`,`conversationId`,`nodes`,`truncated`]);return{kind:n,conversationId:dn(t.conversationId),nodes:W(t.nodes,Fr,ri),truncated:z(t.truncated)}}if(n===`conversation-turn`){let t=U(e,[`kind`,`conversationId`,`leaf`,`ordinal`,`turn`,`start`,`steps`]),r=Zr(t.turn),i=R(t.start,0),a=W(t.steps,24,Xr);if(i+a.length>r.steps)throw new F(`invalid`);return{kind:n,conversationId:dn(t.conversationId),leaf:H(t.leaf,Mr),ordinal:R(t.ordinal,0),turn:r,start:i,steps:a}}if(n===`conversation-step`){let t=U(e,[`kind`,`conversationId`,`leaf`,`turnId`,`step`,`part`,`item`]);return{kind:n,conversationId:dn(t.conversationId),leaf:H(t.leaf,Mr),turnId:Mr(t.turnId),step:R(t.step,0),part:R(t.part,0),item:Yr(t.item)}}if(n===`files`||n===`directories`){let t=U(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:n,path:L(t.path,4096),parent:H(t.parent,e=>L(e,4096)),limited:z(t.limited),entries:W(t.entries,200,e=>{let t=U(e,[`name`,`path`,`directory`]);return{name:L(t.name,1024,!0),path:L(t.path,4096,!0),directory:z(t.directory)}})}}if(n===`file`){let t=U(e,[`kind`,`path`,`text`,`limited`]);return{kind:n,path:L(t.path,4096),text:L(t.text,262144),limited:z(t.limited)}}if(n===`file-part`){let t=U(e,[`kind`,`path`,`size`,`version`,`data`,`next`]),r=R(t.size,0),i=L(t.data,Nr/3*4),a=H(t.next,e=>R(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:W(U(e,[`kind`,`entries`]).entries,128,e=>{let t=U(e,[`path`,`current`]);return{path:L(t.path,4096,!0),current:z(t.current)}})};if(n===`accepted`)return{kind:n,commandId:G(U(e,[`kind`,`commandId`]).commandId)};let r=U(e,[`kind`,`commandId`,`path`,`link`]);return{kind:B(r.kind,[`project`]),commandId:G(r.commandId),path:L(r.path,4096,!0),link:L(r.link,8192,!0)}}var ai={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},oi=f.createContext&&f.createContext(ai),si=[`attr`,`size`,`title`];function ci(e,t){if(e==null)return{};var n,r,i=li(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 li(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 ui(){return ui=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},ui.apply(null,arguments)}function di(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 fi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?di(Object(n),!0).forEach(function(t){pi(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):di(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function pi(e,t,n){return(t=mi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function mi(e){var t=hi(e,`string`);return typeof t==`symbol`?t:t+``}function hi(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 gi(e){return e&&e.map((e,t)=>f.createElement(e.tag,fi({key:t},e.attr),gi(e.child)))}function $(e){return t=>f.createElement(_i,ui({attr:fi({},e.attr)},t),gi(e.child))}function _i(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=ci(e,si),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,ui({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:fi(fi({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&f.createElement(`title`,null,i),e.children)};return oi===void 0?t(ai):f.createElement(oi.Consumer,null,e=>t(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:`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 yi(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 bi(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 xi(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 Si(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 Ci(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 wi(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 Ti(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 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:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`4.93`,y1:`4.93`,x2:`19.07`,y2:`19.07`},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:`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 Oi(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 ki(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 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:`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 ji(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 Mi(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 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:`1`},child:[]},{tag:`circle`,attr:{cx:`19`,cy:`12`,r:`1`},child:[]},{tag:`circle`,attr:{cx:`5`,cy:`12`,r:`1`},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:`path`,attr:{d:`M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z`},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:`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 Ii(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 Li(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 Ri(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 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:`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 Bi(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 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:`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 Hi(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 Ui(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 Wi(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 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:`12`,y1:`16`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`},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:`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 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:`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 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:`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 Yi(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 Xi(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 Zi(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 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:`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 $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:`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 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:`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 ta(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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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 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 ia(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 aa(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 oa(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 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:`15 10 20 15 15 20`},child:[]},{tag:`path`,attr:{d:`M4 4v7a4 4 0 0 0 4 4h12`},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:`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 la(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 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:`polyline`,attr:{points:`12 6 12 12 16 14`},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:`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 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:`18 15 12 9 6 15`},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 18 15 12 9 6`},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 18 9 12 15 6`},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:`polyline`,attr:{points:`6 9 12 15 18 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:`polyline`,attr:{points:`20 6 9 17 4 12`},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:`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 va(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 ya(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 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:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},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:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 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:`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 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.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 wa(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 Ta=e=>({kind:`error`,error:ie(`unavailable`,e?`uncertain`:`none`)}),Ea=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Ur(e);try{if(!this.transport.workbenchRead)return Ta(!1);let e=Q(await this.transport.workbenchRead(n,t),ii);return e.kind===`ok`&&n.kind===`conversation-context`&&(e.value.kind!==n.kind||e.value.context.id!==n.location.id)?Ta(!1):e}catch{return Ta(!1)}}async workbenchCommand(e){let t=Gr(e);try{if(!this.transport.workbenchCommand)return Ta(!0);let e=Q(await this.transport.workbenchCommand(t),ii);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Ta(!0):e}catch{return Ta(!0)}}async current(e,t){let n=nn(e);try{if(!this.transport.current)return Ta(!1);let e=Q(await this.transport.current(n,t),ln);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async currentChanges(e,t){let n=rn(e);try{if(!this.transport.currentChanges)return Ta(!1);let e=Q(await this.transport.currentChanges(n,t),un);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),rt):Ta(!1)}catch{return Ta(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:Ta(!1)}return this.transport.models?Q(await this.transport.models(e),xn):Ta(!1)}catch{return Ta(!1)}}async chooseModel(e,t){let n=_n(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}:Ta(!0)}else{if(!this.transport.chooseModel)return Ta(!1);e=Q(await this.transport.chooseModel(n),gn)}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 Ta(!0)}return e}catch{return Ta(!0)}}async checkObligations(e,t){G(e);try{let n=Q(await this.transport.checkObligations(e,t),Zt);return n.kind===`ok`&&n.value.taskId!==e?Ta(!1):n}catch{return Ta(!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=Qt({...t,kind:e});try{let e=Q(await this.transport.entity(r,n),en);return e.kind===`ok`&&J(e.value.request)!==J(r)?Ta(!1):e}catch{return Ta(!1)}}async session(e){try{return Q(await this.transport.session(e),Et)}catch{return Ta(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),Dt)}catch{return Ta(!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=Ft({...t,reader:e});try{let t=Q(await this.transport[e](r,n),Vt);return t.kind===`ok`&&!Ht(r,t.value)?Ta(!1):t}catch{return Ta(!1)}}async graph(e,t){let n=Ut(e);try{let e=Q(await this.transport.graph(n,t),Gt);return e.kind===`ok`&&J(e.value.request)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async*export(e,t){let n=Kt(e),r=new Yt(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=De({expected:e,action:t});try{let e=Q(await this.transport.preflight(n),Me);return e.kind===`ok`&&(J(e.value.preview.version)!==J(n.expected)||J(e.value.preview.action)!==J(n.action))?Ta(!1):e}catch{return Ta(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=Oe(t);if(n.action.kind!==e)return{kind:`error`,error:ie(`invalid`)};try{let e=Q(await this.transport.command(n),ct);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Ta(!0);lt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Ta(!0)}}async cancel(e){let t=Ae(e);try{let e=Q(await this.transport.cancel(t),ct);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Ta(!0);lt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Ta(!0)}}async receipt(e,t){G(e);try{let n=ut(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:ie(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=Le(e);try{let e=Q(await this.transport.snapshot(n,t),mt);return e.kind===`ok`&&J(e.value.scope)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async detail(e,t){let n=ze(e);try{let e=Q(await this.transport.detail(n,t),vt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}async search(e,t){let n=ze(e);try{let e=Q(await this.transport.search(n,t),bt);return e.kind===`ok`&&J(e.value.cursor)!==J(n)?Ta(!1):e}catch{return Ta(!1)}}},Da=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=mt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&J(i.scope)===J(r.scope)&&q(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=ht(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=q(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||Ct(i.context)!==Ct(a.context)||wt(i.context)!==wt(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{mt(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 Oa(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 ka={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`},Aa=`/api/v1/events`,ja=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Ma(e,t){if(ja.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 Na(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Pa(e,t){switch(e){case`workbenchRead`:return Ur(t);case`workbenchCommand`:return Gr(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=Ft(t);if(n.reader!==e)throw new F(`invalid`);return n}case`current`:return nn(t);case`currentChanges`:return rn(t);case`checkObligations`:case`receipt`:return G(t);case`entity`:return Qt(t);case`graph`:return Ut(t);case`snapshot`:return Le(t);case`detail`:case`search`:return ze(t);case`export`:case`download`:return Kt(t);case`chooseModel`:return _n(t);case`preflight`:return De(t);case`command`:return Oe(t);case`cancel`:return Ae(t)}}function Fa(e,t){if(ja.includes(e))return Q(t,Vt);switch(e){case`workbenchRead`:case`workbenchCommand`:return Q(t,ii);case`current`:return Q(t,ln);case`currentChanges`:return Q(t,un);case`activeRuns`:return Q(t,rt);case`models`:return Q(t,xn);case`chooseModel`:return Q(t,gn);case`session`:return Q(t,Et);case`workspace`:return Q(t,Dt);case`checkObligations`:return Q(t,Zt);case`entity`:return Q(t,en);case`graph`:return Q(t,Gt);case`snapshot`:return Q(t,mt);case`detail`:return Q(t,vt);case`search`:return Q(t,bt);case`preflight`:return Q(t,Me);case`command`:case`cancel`:return Q(t,ct);case`receipt`:return ut(t);case`detach`:return Q(t,e=>{if(e!==null)throw new F(`invalid`);return null});default:throw new F(`invalid`)}}function Ia(e){return[...ja,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function La(e,t){let n=ka[e];return t===null||Na(e)?n:`${n}?request=${encodeURIComponent(J(t))}`}function Ra(e,t){let n=Pa(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?ka[e]:La(e,n);return Na(e)||Ia(e)&&(r||ae(i)>P.headerBytes/4)?{path:ka[e],method:`POST`,body:J(n)}:{path:i,method:`GET`}}function za(e){J(e,P.viewerBytes);let t=B(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:mt(U(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:ht(U(e,[`kind`,`event`]).event)}:(U(e,[`kind`]),{kind:t})}var Ba=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&&=ot(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=Ra(e,Pa(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:Oa([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=G(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 Va(t,Ma(e)),s=ce(a);if(ae(a)>Ma(e,s))throw new F(`oversize`);let c=Fa(e,s);if(e===`session`){let e=Q(c,Et);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new F(`forbidden`);this.attachment=n??G(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`,_n(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,G(e),t)}entity(e,t){return this.request(`entity`,Qt(e),t)}tasks(e,t){return this.request(`tasks`,Ft(e),t)}runs(e,t){return this.request(`runs`,Ft(e),t)}messages(e,t){return this.request(`messages`,Ft(e),t)}tools(e,t){return this.request(`tools`,Ft(e),t)}contents(e,t){return this.request(`contents`,Ft(e),t)}events(e,t){return this.request(`events`,Ft(e),t)}checks(e,t){return this.request(`checks`,Ft(e),t)}changes(e,t){return this.request(`changes`,Ft(e),t)}reviews(e,t){return this.request(`reviews`,Ft(e),t)}graph(e,t){return this.request(`graph`,Ut(e),t)}preflight(e){return this.request(`preflight`,De(e))}command(e){return this.request(`command`,Oe(e))}cancel(e){return this.request(`cancel`,Ae(e))}receipt(e,t){return this.request(`receipt`,G(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(),Et);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=Ra(`export`,Kt(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
|
-
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield
|
|
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=Le(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}`:``}${Aa}?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=za(ce(e.data,P.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function Va(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 Ha={sourceHash:`ad0828373f8d69b3564dc8baf81604cbc64d5c7358a5c88fed3fd63512569528`,contractHash:`d70dd3e63843be7df42ff10943fcdc78bcd27b881b0ac8222526e8dad7b0e6e2`,buildId:`cdb10ead66d8e5131f34d0cf0afca06dd616e3b987b802e68d1b326bec64b5e0`};function Ua(e){let t=new Ba({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...Ha?{build:{kind:`browser`,...Ha}}:{},socket:e=>new WebSocket(e)});return{client:new Ea(t),transport:t}}function Wa(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 Ga(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 Ka=[],qa=null,Ja,Ya,Xa=new Set;function Za(){let e=Ga(Ka,performance.now());if(e!==qa){qa=e;for(let e of Xa)e()}}function Qa(e){if(Xa.add(e),Xa.size===1&&typeof PerformanceObserver<`u`)try{Ja=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=Wa(t,location.origin);e&&(Ka=[...Ka.slice(-19),e])}Za()}),Ja.observe({type:`resource`,buffered:!0}),Ya=setInterval(Za,5e3)}catch{Ja=void 0}return()=>{Xa.delete(e),!Xa.size&&(Ja?.disconnect(),Ja=void 0,clearInterval(Ya),Ka=[],qa=null)}}function $a(){return(0,f.useSyncExternalStore)(Qa,()=>qa,()=>null)}function eo(e,t){let n=new URLSearchParams(e).get(`project`),r=new URLSearchParams(t.replace(/^#/,``)).get(`chat`),i=null;try{i=r?dn(r):null}catch{}return{project:n&&/^[a-f0-9]{64}$/.test(n)?n:null,chat:i}}function to(e=typeof window>`u`?``:window.location.search){return eo(e,``).project}function no(e=typeof window>`u`?``:window.location.hash){return eo(``,e).chat}function ro(){let e=to();return e?`/projects/${e}`:``}function io(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&eo(``,e).chat!==t)return{selected:!1,leaf:null};try{return{selected:n.get(`activity`)===`1`,leaf:n.has(`leaf`)?Mr(n.get(`leaf`)):null}}catch{return{selected:!1,leaf:null}}}function ao(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Mr(t)),`#${n}`}function oo(e,t){if(typeof window>`u`||no()!==e)return;let n=ao(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function so(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&&q(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||q(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 co(e,t,n=0){let r=JSON.stringify(t),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)({key:r,revision:-1});(0,f.useEffect)(()=>{if(r===`null`)return;let t=new AbortController,a,o=async()=>{let c=await e.workbenchRead(Ur(JSON.parse(r)),t.signal);t.signal.aborted||(s(e=>c.kind===`ok`?{key:r,revision:i,value:c.value}:{key:r,revision:i,value:e.key===r?e.value:void 0,error:c.error.code}),n&&(a=setTimeout(()=>void o(),n)))};return o(),()=>{t.abort(),clearTimeout(a)}},[e,r,i,n]);let c=(0,f.useCallback)(()=>a(e=>e+1),[]);return{...o.key===r?o:{},loading:r!==`null`&&(o.key!==r||o.revision!==i),refresh:c}}function lo(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 uo(e,t,n=!1){let[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)([]),s=co(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 fo(e){return ce(await Va(e,1048576),1048576)}function po(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 mo(e){let t=Error(po(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 ho(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await fo(r);if(!r.ok)throw Error(po(i));return t(i)}function go(e){return ho(`/workbench/v1/service`,Ln,e)}function _o(e){return ho(`/workbench/v1/service/release`,Rn,e)}async function vo(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 fo(n);if(!n.ok)throw Error(po(r));let i=U(r,[`kind`,`job`]);return V(i.kind,`service-job`),Pn(i.job)}function yo(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function bo(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function xo(e,t){let[n,r]=(0,f.useState)(0),i=(0,f.useRef)(0),a=(0,f.useRef)(0),[o,s]=(0,f.useState)({});(0,f.useEffect)(()=>{if(!e)return;let r=++a.current,i=new AbortController,o=()=>!i.signal.aborted&&a.current===r,c,l=async()=>{if(o()){try{let r=await fetch(`/workbench/v1/projects/${e}`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:i.signal}),a=await fo(r);if(!r.ok)throw Error(po(a));let c=Cn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...bo(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...bo(i.id===e?i.value:void 0,void 0,r instanceof Error?r.message:`unavailable`)}))}o()&&(c=setTimeout(()=>void l(),5e3))}};return l(),()=>{i.abort(),clearTimeout(c)}},[e,n,t]);let c=(0,f.useCallback)(()=>{++a.current;let e=++i.current;return r(e),e},[]),l=t=>{let n=c();s(r=>({id:e,revision:n,selectedEpoch:t,value:{kind:`project-observation`,status:`running`,epoch:t,workspaceId:r.id===e?r.value?.workspaceId??null:null}}))},u=o.id===e?o:{};return{...u,readiness:yo(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var So=e=>e===`unauthenticated`||e===`forbidden`,Co=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 Da,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,So(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(So(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,So(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,So(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 Da,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(So(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Da,_={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 wo(e,t,n,r){let i=(0,f.useMemo)(()=>new Co(e),[e]),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)({actions:!1,attached:!1,transportStatus:`closed`,attachmentVersion:0}),l=t?.kind,u=t?.id;return(0,f.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 To=class{generation=0;identity=``;select(e){e!==this.identity&&(this.identity=e,this.depart())}depart(){this.generation++}ticket(){return this.generation}current(e){return e===this.generation}};function Eo({client:e,value:t,onChange:n}){let{t:r,tx:i}=T(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function Do(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 Oo(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 ko(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 Ao(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=Do(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 jo(e,t){let n=t?J({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),Oo(e,l,n.signal).then(e=>{t===m.current&&(o(!1),e.kind===`error`?c(e.error.code):i(e.value))}).catch(()=>{t===m.current&&(c(`Read unavailable.`),o(!1))}),()=>{n.abort(),m.current++}},[e,l]),{page:r,busy:a,error:s,more:()=>{!a&&r?.next&&(l&&p(e=>[...e,l]),u(r.next))},previous:()=>{!a&&d.length&&(u(d[d.length-1]),p(e=>e.slice(0,-1)))},canPrevious:d.length>0,refresh:()=>{i(void 0),p([]),u(t?{...t}:null)}}}function Mo({value:e,compact:t=!1}){let{t:n,tx:r}=T();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(Mo,{value:e})]}):(0,h.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[n(`Recording: {observed}; source: {source};`,{observed:r(e.observed),source:r(e.source)}),` `,e.redacted?n(`redacted`):n(`no reported redaction`),e.omissions.length>0&&n(`; omitted: {omissions}`,{omissions:e.omissions.map(r).join(`, `)}),n(`. Not a guarantee of complete original source or universal secret detection.`)]})}function No(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 Po(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return No(e)}return No(e)}function Fo(e={}){let{duration:t=2e3,onSuccess:n,onError:r}=e,i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(!1),s=(0,f.useRef)(null),c=(0,f.useCallback)(()=>{s.current!==null&&(clearTimeout(s.current),s.current=null)},[]),l=(0,f.useCallback)(()=>{c(),o(!1)},[c]);return(0,f.useEffect)(()=>(i.current=!0,()=>{i.current=!1,c()}),[c]),{copied:a,copy:(0,f.useCallback)(async e=>{let a=!1;try{a=await Po(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 Io(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
16
|
-
`).map(e=>e===``?[]:[e])}if(Array.isArray(e)){let n=[];for(let r of e){let e=t(r);if(n.length===0)n=e;else{let t=e[0]??[];n[n.length-1].push(...t),n.push(...e.slice(1))}}return n}if(e&&typeof e==`object`&&`props`in e){let n=e,r=n.props?.children,i={...n.props,children:void 0},a=r==null?[]:t(r);return a.length===0?[[(0,f.createElement)(n.type,i)]]:a.map(e=>[(0,f.createElement)(n.type,i,...e)])}return[[e]]},n=t(e);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}var Lo=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Ro(!0)},text:{92:Ro(!1)}});let t={enter:{backslashMathInline:zo,backslashMathDisplay:zo,backslashMathBlock:zo},exit:{backslashMathInline:Bo,backslashMathDisplay:Bo,backslashMathBlock:Bo}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Ro(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 zo=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)},Bo=function(e){this.exit(e)};function Vo(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var Ho=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function Uo(e,t,n=3){let r=[...e.filter(e=>!Ho(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 Wo=[],Go=1,Ko=new Set;function qo(e){if(!(e.length===Wo.length&&e.every((e,t)=>e===Wo[t]))){Wo=e;for(let e of Ko)e()}}function Jo(e,t,n){let r=Go++;return qo(Uo(Wo,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function Yo(e){qo(Wo.filter(t=>t.id!==e))}function Xo(e){qo(Wo.filter(t=>t.key!==e))}function Zo(e){return Ko.add(e),()=>{Ko.delete(e)}}var Qo=()=>Wo,$o=(0,f.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=T(),{copied:r,copy:i}=Fo();return(0,h.jsx)(`button`,{type:`button`,className:r?`${t} copied`:t,title:n(`Copy displayed text`),"aria-label":n(`Copy displayed text`),onClick:()=>{i(e).then(e=>{e||Jo(`error`,n(`Copy unavailable`))})},children:r?(0,h.jsx)(ga,{}):(0,h.jsx)(ca,{})})}),es=[s,d,Lo],ts=[s,l,d,Lo],ns=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function rs(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 is({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?ts:es,rehypePlugins:t?[i,o,...ns]:ns,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:ss,a:os,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var as=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(is,{...e})})});function os({href:e,children:t}){let n=e&&rs(e);return n?(0,h.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,h.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function ss({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Io(r).map(e=>{let t=`code-offset:${i}`;return i+=cs(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,h.jsxs)(`div`,{className:`codeblock`,children:[(0,h.jsx)($o,{text:cs(e)}),(0,h.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,h.jsxs)(`div`,{className:`code-line`,children:[o&&(0,h.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,h.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function cs(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(cs).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return cs(t?.children)}return``}function ls(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 us=new Map;function ds(e,t){t.length?us.set(e,t):us.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...us].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 fs(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 ps(e,t){let n=t.startContainer.parentElement;for(let r of fs(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 ms({container:e,version:t}){let{t:n}=T(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(0),l=(0,f.useRef)([]),u=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?ls(n,r):[];return l.current=i,c(i.length),o(0),ds(u,i),()=>ds(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(ps(e.current,l.current[n]),ds(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>ds(`${u}-active`,[]),[u]),(0,h.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,h.jsxs)(`label`,{children:[n(`Find on displayed field page`),(0,h.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d(e.shiftKey?-1:1))}})]}),(0,h.jsxs)(`span`,{children:[s?a+1:0,`/`,s,s>=1e3?n(` (first 1000 visual highlights)`):``,n(`; not whole-history search`)]}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(-1),children:n(`Previous match`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!s,onClick:()=>d(1),children:n(`Next match`)})]})}function hs({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=T(),s=J(t),c=(0,f.useMemo)(()=>ze(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[C,w]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,w(a(`Reading all retained field pages…`));try{let r=await Ao(e,t,n.signal);if(n.signal.aborted)return;let i=await Po(r.text);if(n.signal.aborted)return;w(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||w(a(`Full-field copy refused/incomplete.`))}finally{E.current===n&&(E.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,h.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,h.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,h.jsx)(`summary`,{children:a(`Field details`)}),(0,h.jsxs)(`div`,{className:`detail-identity`,children:[(0,h.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,h.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!!E.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!E.current&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{E.current?.abort(),E.current=null,w(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),C&&(0,h.jsx)(`p`,{role:`status`,children:C}),y&&(0,h.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),_&&(0,h.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,h.jsx)(Mo,{value:d.coverage,compact:i}),d&&`kind`in d&&(0,h.jsx)(`p`,{children:a(`Validation in progress. The retained field is not empty.`)}),k&&(0,h.jsxs)(h.Fragment,{children:[(!i||k.next)&&(0,h.jsxs)(`p`,{children:[a(`Bytes {start}–{end} of {total}.`,{start:k.range?.start??0,end:k.range?.end??0,total:k.content.bytes}),` `,k.next?a(`More retained data available.`):a(`End of field.`)]}),!i&&(0,h.jsx)(ms,{container:D,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,h.jsx)(as,{text:k.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!k||!n||!k.range)return k?.text;let e=Math.max(n.start,k.range.start)-k.range.start,t=Math.min(n.end,k.range.end)-k.range.start;if(t<=e)return k.text;let r=new TextEncoder().encode(k.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,h.jsxs)(h.Fragment,{children:[i(0,e),(0,h.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||m.length>0||d?.next)&&(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.length,onClick:()=>{u(m[m.length-1]),g(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!d?.next,onClick:()=>{d?.next&&(g(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function gs({pager:e,compact:t=!1}){let{t:n,tx:r}=T(),{page:i,busy:a,error:o}=e;return(0,h.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,h.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,h.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&!(t&&i.coverage.observed===`complete`&&i.coverage.source===`complete`&&!i.coverage.redacted&&i.coverage.omissions.length===0)&&(0,h.jsx)(Mo,{value:i.coverage,compact:t}),(!t||e.canPrevious)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!e.canPrevious,onClick:e.previous,children:n(`Previous page`)}),(!t||i?.next)&&(0,h.jsx)(`button`,{type:`button`,disabled:a||!i?.next,onClick:e.more,children:i&&`kind`in i?n(`Continue validation`):n(`Next page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:a,onClick:e.refresh,"aria-label":n(`Observe a new snapshot`),title:n(`Observe a new snapshot`),children:t?(0,h.jsx)(ji,{"aria-hidden":`true`}):n(`Observe a new snapshot`)}),!t&&i&&!(`kind`in i)&&!i.next&&(0,h.jsx)(`span`,{className:`page-end`,children:i.coverage.observed===`incomplete`?n(`End of this retained snapshot (incomplete).`):n(`End of this retained snapshot.`)})]})}function _s({client:e,seed:t,entityId:n}){let{t:r,tx:i}=T(),a=jo(e,{...t,reader:`contents`}),[o,s]=(0,f.useState)(),c=a.page;return(0,h.jsxs)(`section`,{"aria-label":r(`Retained content fields`),children:[(0,h.jsx)(gs,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(x,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,h.jsx)(`code`,{children:n})}})}),c&&!(`kind`in c)&&c.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,h.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,h.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,h.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,h.jsx)(Mo,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(ko(c.request.storeId,c.request.scope,c.request.snapshotSeq,e.content))},children:r(`Inspect complete retained field`)})]},`${e.content.recordId}:${e.content.version}`)),o&&(0,h.jsx)(hs,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function vs({client:e,seed:t}){return(0,h.jsx)(ys,{client:e,seed:t},J(t))}function ys({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(i.kind===`message`?e.message(i,n.signal):i.kind===`tool`?e.tool(i,n.signal):e.task(i,n.signal)).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,h.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,h.jsx)(Mo,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Entity validation in progress, not missing.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue exact entity validation`)})]}):(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Exact stored owner and associations`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(o.record,null,2)})]}))]})}function bs(e){let t=Ra(`download`,Kt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=ro()+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 xs({title:e,children:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current?.()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),n&&(0,h.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),t]})}function Ss({request:e,onClose:t}){let{t:n,tx:r}=T(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(xs,{title:n(`Export retained history`),onClose:t,children:[(0,h.jsx)(`p`,{children:n(`Selected {kind}: {id} · snapshot {seq}`,{kind:r(i.scope.kind),id:i.scope.id,seq:i.snapshotSeq})}),(0,h.jsxs)(`label`,{children:[n(`Format`),(0,h.jsxs)(`select`,{value:a,onChange:e=>o(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,h.jsx)(`option`,{value:`ndjson`,children:n(`NDJSON public archive`)}),(0,h.jsx)(`option`,{value:`markdown`,children:n(`Readable Markdown with footer metadata`)})]})]}),(0,h.jsx)(`p`,{children:n(`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`)}),(0,h.jsx)(`p`,{children:n(`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{try{bs({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,h.jsx)(`p`,{role:`status`,children:s})]})}function Cs(e,t){if(!t||ae(t)>P.queryBytes)throw Error(`Query must be 1–${P.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ze({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ws(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 Ts({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=T(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=Cs(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(xs,{title:i(`Search retained history`),onClose:n,children:(0,h.jsxs)(`div`,{className:`gs-modal`,children:[(0,h.jsxs)(`div`,{className:`gs-input-row`,children:[(0,h.jsx)(ki,{}),(0,h.jsx)(`input`,{ref:s,"aria-label":i(`Case-sensitive literal query`),value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),p(e=>Math.max(0,Math.min(e+1,(m?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),p(e=>Math.max(e-1,0))),e.key===`Enter`&&m?.hits[d]&&(e.preventDefault(),r(m.hits[d]),n())}})]}),(0,h.jsx)(`p`,{children:i(`Case-sensitive literal UTF-8 search. Scope {kind} {id}; snapshot {seq}. No regex, provider request or history repair.`,{kind:a(o.scope.kind),id:o.scope.id,seq:o.snapshotSeq})}),(0,h.jsxs)(`div`,{className:`gs-results`,children:[_&&(0,h.jsx)(`p`,{role:`status`,children:i(`Searching bounded retained range…`)}),y&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Search refused: {error}`,{error:a(y)})}),!l&&(0,h.jsx)(`p`,{children:i(`Enter a query to search this selected scope.`)}),m&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Mo,{value:m.coverage}),(0,h.jsxs)(`div`,{className:`gs-section`,children:[(0,h.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:m.hits.length})}),m.hits.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>p(t),onClick:()=>{r(e),n()},children:[(0,h.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,h.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,h.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` /`,` `,i(`bytes {start}–{end}`,{start:e.range.start,end:e.range.end})]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),m.hits.length===0&&(0,h.jsx)(`p`,{children:a(ws(m))})]}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.next,onClick:()=>{m.next&&S(m.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,h.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Es({run:e,historical:t=!1}){let{t:n,tx:r}=T();return(0,h.jsxs)(`article`,{className:`run-summary`,children:[(0,h.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,h.jsx)(`p`,{children:(0,h.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,h.jsx)(`dd`,{children:r(e.lifecycle)}),(0,h.jsx)(`dt`,{children:n(`Execution`)}),(0,h.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,h.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,h.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,h.jsx)(`dt`,{children:n(`Summary publication`)}),(0,h.jsx)(`dd`,{children:r(e.publication)})]}),(0,h.jsx)(Mo,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Ds({client:e,seed:t}){return(0,h.jsx)(Os,{client:e,seed:t},J(t))}function Os({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),e.graph(i,n.signal).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,h.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,h.jsx)(Mo,{value:o.coverage}),o&&(`kind`in o?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:n(`Graph validation in progress; not an empty graph.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>a(o.next),children:n(`Continue graph validation`)})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(hs,{client:e,cursor:ko(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,h.jsx)(as,{text:e.instructions}),(0,h.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function ks({client:e,seed:t,onScope:n}){let{t:r}=T(),i=jo(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(gs,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Es,{run:e.projection,historical:!0}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,h.jsx)(Ds,{client:e,seed:o},o.graph.recordId)]})}function As({onOpen:e,disabled:t}){let{t:n}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,h.jsx)(ki,{"aria-hidden":`true`})})}function js(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 Ms(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 Ns(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)??Ps(n.role,n.customType)}return r}function Ps(e,t){switch(e){case`user`:return 72;case`assistant`:return 280;case`tool-result`:return 120;case`custom`:return t===`file`?96:72;default:return 60}}function Fs(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Is(e,t,n=null,r=1800){let[i,a]=(0,f.useState)(()=>new Set),o=(0,f.useRef)(i);o.current=i;let s=(0,f.useRef)(new Map),c=(0,f.useRef)(new Map),l=(0,f.useRef)(new Map),u=(0,f.useRef)(0),d=(0,f.useRef)(new Map);d.current=new Map(t.map(e=>[e.id,e.version]));let p=(0,f.useRef)(new Set);p.current=Ns(t,s.current,r),n!==null&&p.current.add(n);let m=(0,f.useCallback)((e,t)=>{let n=d.current.get(e);n!==void 0&&(c.current.set(e,{h:t,len:n}),s.current.set(e,t))},[]),h=(0,f.useCallback)(()=>{let t=e.current;if(!t)return;let n=t.getBoundingClientRect(),r=[];for(let[e,t]of l.current){let n=t.getBoundingClientRect();r.push({id:e,top:n.top,bottom:n.bottom}),o.current.has(e)||m(e,n.height)}let i=js(r,{top:n.top-1200,bottom:n.bottom+1200},p.current,o.current,{top:n.top-2400,bottom:n.bottom+2400});for(let e of i.hide){let t=l.current.get(e);t&&m(e,t.offsetHeight)}a(e=>Ms(e,i))},[m,e]),g=(0,f.useCallback)(()=>{u.current||=requestAnimationFrame(()=>{u.current=0,h()})},[h]);return(0,f.useLayoutEffect)(()=>{t.length?h():a(new Set)},[h,t,n]),(0,f.useEffect)(()=>{let t=new ResizeObserver(g);return e.current&&t.observe(e.current),()=>{t.disconnect(),cancelAnimationFrame(u.current)}},[g,e]),{hidden:i,scheduleSweep:g,recordMeasured:m,register:(0,f.useCallback)(e=>t=>{t?l.current.set(e,t):l.current.delete(e)},[]),placeholder:(0,f.useCallback)((e,t,n)=>Fs(e,t,c.current,n),[])}}var Ls=(0,f.memo)(function({id:e,show:t,height:n,containerRef:r,onMeasured:i,lazyRef:a,children:o}){let s=(0,f.useRef)(null);return(0,f.useLayoutEffect)(()=>{if(!t)return;let n=s.current;if(!n)return;let r=n.offsetHeight;r>0&&i?.(e,r)},[t,e,i]),t?(0,h.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,h.jsx)(`div`,{ref:s,children:o})}):(0,h.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),Rs=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(fa,{"aria-hidden":`true`}):(0,h.jsx)(ea,{"aria-hidden":`true`}),r(a?`Collapse`:`Inspect message`)]})]}),(0,h.jsxs)(`div`,{className:`msg-body`,children:[e.role===`tool-result`&&(0,h.jsx)(`p`,{className:`msg-note`,children:r(`Result call: {call}. Kept visible independently of the tool card.`,{call:e.resultCallId??r(`unassociated / orphan`)})}),(0,h.jsx)(`div`,{className:`msg-text`,children:(0,h.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,h.jsx)(hs,{compact:!0,client:t,cursor:ko(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,h.jsx)(`p`,{children:r(`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`)}),a&&(0,h.jsxs)(`div`,{className:`message-inspection`,children:[(0,h.jsx)(`p`,{className:`msg-ident`,children:r(`Child {child} · message {message} · version {version}`,{child:e.owner.childRunId??``,message:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`p`,{className:`msg-note`,children:r(`{state} message record, not execution outcome`,{state:i(e.state)})}),(0,h.jsxs)(`details`,{open:!0,children:[(0,h.jsx)(`summary`,{children:r(`All message blocks, source limits and tool associations`)}),(0,h.jsx)(_s,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function zs({messages:e,client:t,seed:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),o=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,version:e.version,message:e})),[e]),s=Is(i,o);return(0,h.jsxs)(`div`,{className:`messages-wrap`,children:[(0,h.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,s.scheduleSweep()},children:o.map(({id:e,role:r,message:a})=>(0,h.jsx)(Ls,{id:e,show:!s.hidden.has(e),height:s.placeholder(e,a.version,r===`user`?100:280),containerRef:i,onMeasured:s.recordMeasured,lazyRef:s.register(e),children:(0,h.jsx)(Rs,{message:a,client:t,seed:n})},e))}),(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight,a.current=!0)},children:[(0,h.jsx)(xa,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Bs({client:e,seed:t}){let{t:n}=T(),r=jo(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(gs,{pager:r,compact:!0}),i&&!(`kind`in i)&&t.snapshotSeq!==null&&i.request.snapshotSeq!==t.snapshotSeq&&(0,h.jsx)(`button`,{type:`button`,className:`conversation-update`,disabled:r.busy,onClick:r.refresh,children:n(`New activity — update conversation`)}),i&&!(`kind`in i)&&(0,h.jsxs)(h.Fragment,{children:[i.records.length===0&&(0,h.jsx)(`p`,{className:`empty-note panel-empty`,children:i.next?n(`No message records on this page; more history remains.`):n(`No message records on this page.`)}),(0,h.jsx)(zs,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Vs({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,h.jsxs)(`div`,{className:`chead ${n}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,h.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,h.jsx)(ha,{}):(0,h.jsx)(pa,{})}):c,(0,h.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,h.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var Hs=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=T(),[a,o]=(0,f.useState)(!1),s=e.result?e.result.isError?r(`SDK tool error observed`):r(`SDK tool end observed`):e.startObserved?r(`Start observed; end not observed in this snapshot`):r(`No start observed`),c=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,h.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,h.jsx)(Vs,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Si,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-path`,children:r(`Child {child} · call {call} · v{version}`,{child:e.owner.childRunId??``,call:e.owner.entity.id,version:e.version})}),(0,h.jsx)(`span`,{className:`toolcall-badge ${c}`,children:s})]}),children:e.name}),a&&(0,h.jsxs)(`div`,{className:`toolcall-body`,children:[(0,h.jsx)(`p`,{children:r(`SDK tool observations are not native process launch/close or passing parent checks.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Source ID`)}),(0,h.jsxs)(`dd`,{children:[i(e.source.disposition),`:`,` `,e.source.value??r(`unavailable`)]}),(0,h.jsx)(`dt`,{children:r(`Declaration`)}),(0,h.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${i(String(e.declarationStage))})`:r(`No declaration recorded; orphan result remains accessible`)})]}),(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(`Recorded tool end (not parsed from output)`)}),(0,h.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):r(`No end fact in this snapshot.`)})]}),(0,h.jsx)(`div`,{className:`toolcall-args`,children:(0,h.jsx)(_s,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),Us=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function Ws({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=T(),s=new Set(e?.projects.flatMap(e=>e.activities.filter(e=>e.sessionId).map(t=>`${e.path}\0${t.sessionId}`))),c=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(Us(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length);return(0,h.jsxs)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:a(`Active Pi work`)})}),(0,h.jsxs)(`div`,{className:`lp-section-body`,children:[e&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`{projects} projects · {sessions} sessions`,{projects:e.projects.length,sessions:s.size})}),(t||e?.completeness===`partial`)&&(0,h.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),i.length>0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Owner work already listed below is not duplicated here.`)}),!e&&!t&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`Discovering active work…`)}),e?.completeness===`complete`&&!t&&!e.projects.length&&(0,h.jsx)(`p`,{className:`panel-hint`,children:a(`No active work observed. Idle terminals and owners are not listed.`)}),c?.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`p`,{className:`panel-hint`,children:e.path}),e.activities.map(t=>(0,h.jsx)(`button`,{type:`button`,className:`session-item`,disabled:n||!t.sessionId||t.history!==`shared`,onClick:()=>r(e.path,t),children:(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t.sessionId??a(`Unattributed work`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.source===`terminal`?a(`Terminal turn (observe only)`):t.source===`turn`?a(`Owner turn`):a(`Owner workflow`),` `,`· `,o(t.phase),` ·`,` `,t.freshness===`current`?a(`Current observation`):t.freshness===`stale`?a(`Stale observation`):a(`Unknown activity`)]}),t.history===`unavailable`&&(0,h.jsx)(`span`,{className:`session-sub`,children:a(`History configuration differs. Activity remains observe-only.`)}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[t.cwd,t.executionCwd?` → ${t.executionCwd}`:``]})]})},`${t.epoch??t.instance}:${t.source}:${t.id}`))]},e.path))]})]})}function Gs(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 Ks(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 qs=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function Js(e,t){return qs.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function Ys(e){let t=Ks(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function Xs(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=>Gs(e.id)===n.id),...r?{artifact:r}:{}}})}var Zs=[`queued`,`running`];function Qs(e,t){let n=e=>Number(!Zs.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 $s(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(Gs(t.id))):!1}var ec=[`queued`,`running`],tc=4,nc=1e4;function rc(e,t,n=2e3){let[r,i]=(0,f.useState)(()=>({runs:new Map,failed:!1,unreadable:new Set})),a=(0,f.useRef)({client:e,runs:new Map}),o=JSON.stringify([...new Set(t)]);return(0,f.useEffect)(()=>{let t=new AbortController,r;a.current.client!==e&&(a.current={client:e,runs:new Map});let s=JSON.parse(o),c=new Set(s);for(let e of a.current.runs.keys())c.has(e)||a.current.runs.delete(e);let l=new Map(a.current.runs),u=new Map,d=e=>{let t=new Map;for(let e of s){let n=l.get(e);n&&t.set(e,n)}return i({runs:t,failed:e,unreadable:new Set(u.keys())}),t},f=async n=>{let r=await e.workbenchRead({kind:`workflow`,id:n},t.signal);if(t.signal.aborted)return!1;if(r.kind===`ok`&&r.value.kind===`workflow`&&r.value.response.type===`run`){let e=r.value.response.run;return l.set(n,e),u.delete(n),a.current.runs.set(n,e),!1}return l.has(n)?!0:(u.set(n,Date.now()),!1)},p=async()=>{let e=!1,i=Date.now(),a=s.filter(e=>{let t=l.get(e);return t?ec.includes(t.status):i-(u.get(e)??0)>=nc}).reverse();for(let n=0;n<a.length;n+=tc){let r=await Promise.all(a.slice(n,n+tc).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+tc<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>ec.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),nc))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function ic({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=T(),o=Ks(e),s=n?.runId===e.id?n.stepId:void 0;return(0,h.jsxs)(`section`,{className:`agent-dock-run`,"aria-label":e.goal,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-run-head${s===null?` active`:``}`,title:e.goal,onClick:()=>r?.({runId:e.id,stepId:null,label:e.goal}),children:[(0,h.jsx)(`span`,{className:`agent-dock-run-goal`,children:e.goal}),o&&(0,h.jsx)(`span`,{className:`agent-dock-run-state`,children:Js(o,i)})]}),t.map(t=>{let n=Gs(t.id),o=e.tasks?.find(e=>e.id===n);return(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row${s===t.id?` active`:``}`,title:o?`${o.title} · ${e.goal}`:e.goal,onClick:()=>r?.({runId:e.id,stepId:t.id,label:n}),children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:`${a(t.kind)} · ${n}`}),o&&(0,h.jsx)(`small`,{children:i(`Assignment: {state}`,{state:a(o.state)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${t.status}`,children:a(t.status)})]},t.childRunId)})]})}function ac({client:e,active:t,taskId:n,runs:r,snapshot:i,workflowRuns:a=[],selected:o,onOpen:s,onOpenWorkflow:c}){let{t:l,tx:u}=T(),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),y=rc(e,a),b=JSON.stringify(t?.status===`complete`?[...new Set(t.runs.map(e=>e.taskId))]:[]);(0,f.useEffect)(()=>{let t=new AbortController,n,r=async()=>{let i=[],a=!1;for(let n of JSON.parse(b)){let r=await e.snapshot({kind:`task`,id:n},t.signal);if(t.signal.aborted)return;if(r.kind===`ok`)for(let e of r.value.runs)e.childRunId&&i.push({taskId:n,run:e,snapshot:r.value.committedSeq});else a=!0}t.signal.aborted||(g(i),v(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,b]);let x=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],S=[...m,...x.filter(e=>!m.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`)),C=Qs(a,y.runs),w=C.flatMap(e=>e.steps),E=S.length+w.length,D=w.filter(e=>ec.includes(e.status)).length+S.filter(e=>e.run.lifecycle!==`settled`).length,O=d??(E>0||!!_);return(0,h.jsxs)(`section`,{className:`agent-dock${O?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":O,onClick:()=>p(!O),children:[(0,h.jsx)(ha,{}),(0,h.jsx)(aa,{}),(0,h.jsx)(`span`,{children:l(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count${D?` live`:``}`,children:D?l(`{active} active · {total} total`,{active:D,total:E}):E})]}),O&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(_||t?.status!==`complete`||y.failed)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Subagent roster unavailable`)}),E===0&&!_&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:l(`Cadence research, implementation and review agents appear here.`)}),C.map(({run:e,steps:t})=>(0,h.jsx)(ic,{run:e,steps:t,selected:o,onOpen:c},e.id)),S.map(e=>(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>s(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??l(`Subagent`)),children:[(0,h.jsx)(`span`,{className:`agent-dot ${e.run.outcome??e.run.lifecycle}`}),(0,h.jsxs)(`span`,{className:`agent-dock-label`,children:[(0,h.jsx)(`strong`,{children:e.run.assignmentId??l(`Subagent`)}),(0,h.jsx)(`small`,{children:l(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:u(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}function oc(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 sc(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 cc=e=>e.filter(e=>e.current);function lc(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 uc(e,t,n,r,i){let[a,o]=(0,f.useState)();(0,f.useEffect)(()=>{i&&o(e=>e?.shape===r?e:{shape:r,leaf:n})},[i,r,n]);let s=co(e,a?{kind:`conversation-tree`,id:t,leaf:a.leaf}:null),{value:c,refresh:l}=s,u=(0,f.useMemo)(()=>a&&c?.kind===`conversation-tree`?{leaf:a.leaf,nodes:c.nodes,truncated:c.truncated}:void 0,[c,a]),[d,p]=(0,f.useState)();return(0,f.useEffect)(()=>{u&&p(u)},[u]),{tree:u??d,current:!!u&&a?.shape===r,error:s.error,loading:s.loading,refresh:l}}function dc({view:e,onChosen:t}){let{t:n,locale:r}=T(),[i,a]=(0,f.useState)(``),o=e=>new Date(e).toLocaleString(r===`zh`?`zh-CN`:`en-GB`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}),s=e?.tree,c=(0,f.useMemo)(()=>oc(s?.nodes??[]),[s]),l=i.trim().toLowerCase(),u=l?c.filter(({node:e})=>e.text.toLowerCase().includes(l)):c,d=(e,n)=>{e(n),t?.()};return(0,h.jsxs)(`section`,{className:`branches-panel`,"aria-label":n(`Conversation branches`),children:[(0,h.jsxs)(`header`,{className:`panel-crumbs`,children:[(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:i,placeholder:n(`Filter messages…`),"aria-label":n(`Filter messages…`),disabled:!c.length,onChange:e=>a(e.target.value)}),i&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:n(`Clear filter`),"aria-label":n(`Clear filter`),onClick:()=>a(``),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),(0,h.jsx)(`button`,{type:`button`,className:`crumb`,title:n(`Refresh branches`),"aria-label":n(`Refresh branches`),disabled:!e,onClick:()=>e?.onRefresh(),children:(0,h.jsx)(ji,{"aria-hidden":`true`})})]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:n(`Each line is a message; indented lines are branches. Choose one to read that branch. The terminal shares this tree (/tree in Pi).`)}),e?.pinned&&(0,h.jsxs)(`p`,{className:`branches-pinned`,children:[(0,h.jsx)(`span`,{children:n(`A chosen branch is shown, not the latest.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{e.onLatest(),t?.()},children:n(`Show the latest`)})]}),e?.error&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`alert`,children:b(n,e.error)}),s?.truncated&&(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`Only the newest messages are listed.`)}),!s&&!e?.error?(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:n(`Reading…`)}):s&&c.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No messages yet.`)}):s&&u.length===0?(0,h.jsx)(`p`,{className:`panel-empty`,children:n(`No matching messages`)}):null,(0,h.jsx)(`ol`,{className:`branch-rows`,"aria-busy":e?.loading||void 0,children:u.map(({node:t,depth:r})=>(0,h.jsxs)(`li`,{className:`branch-item${t.current?` current`:``}`,children:[Array.from({length:r},(e,t)=>(0,h.jsx)(`span`,{className:`branch-rail`,"aria-hidden":`true`},t)),(0,h.jsxs)(`button`,{type:`button`,className:`branch-row`,"aria-current":t.current?`true`:void 0,title:t.text,onClick:()=>e&&d(e.onShow,t),children:[(0,h.jsx)(`span`,{className:`branch-dot`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`branch-text`,children:t.text||`…`}),t.at>0&&(0,h.jsx)(`time`,{dateTime:new Date(t.at).toISOString(),children:o(t.at)})]}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Edit and resend: {text}`,{text:t.text||`…`}),title:n(`Edit and resend`),disabled:!e?.canAct,onClick:()=>e&&d(e.onEdit,t),children:(0,h.jsx)(na,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`branch-act`,"aria-label":n(`Continue from here: {text}`,{text:t.text||`…`}),title:n(`Continue from here`),disabled:!e?.canAct,onClick:()=>e&&d(e.onContinue,t),children:(0,h.jsx)(sa,{"aria-hidden":`true`})})]},t.id))})]})}function fc(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 mc(e,t){return Math.round(e/t*100)}var hc=e=>e.trim().split(`
|
|
17
|
-
`,1)[0].slice(0,200);function gc(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var _c=(e,t)=>e?e.entry:t,vc=(e,t)=>e!==null&&t>=e.from;function yc(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:Mr(t.entry),turnId:t.turnId,from:t.from,label:t.label,media:t.media===!0,stash:t.stash}}catch{return null}}function bc(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function xc(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 Sc(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function Cc(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function wc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var Tc=2e4;async function Ec(e,t,n,r){let i=Oa([t],Tc);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Dc(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 Oc(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function kc(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 Ac(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function jc(e){let t={commandId:crypto.randomUUID(),conversationId:dn(e.id),head:e.head===null?null:Mr(e.head)},n=e.location?fn(e.location):void 0;if(n&&n.id!==t.conversationId)throw new F(`stale`);let r=L(e.text,Pr,!e.images?.length),i=e.intent===`exit`?{kind:`cadence-exit`,...n?{location:n}:{},...t,revision:R(e.revision,0)}:e.intent===`ordinary`?{kind:`send`,...t,text:r}:{kind:`cadence-send`,...t,text:r,intent:e.intent,revision:R(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(Mc(e.model))}:{}})}function Mc(e){return me({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Nc(e,t){return Object.freeze({...e,model:Object.freeze(Mc(t))})}function Pc(e,t){if(e.model&&J(e.model)!==J(Mc(t)))throw new F(`stale`)}function Fc(e,t){return Object.freeze({...e,preparedEpoch:G(t)})}function Ic(e,t,n){return Object.freeze({...Nc(e,t),installModel:!n})}function Lc(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function Rc(e,t){return!!e&&e===t}async function zc(e,t,n,r){if(!r())throw new F(`stale`);if(!t.installModel||!t.model)return n;if(!yn(n.entries,t.model))throw new F(`unsupported-context`);if(n.selected&&J(Mc(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 Pc(t,a.value.selected),a.value}function Bc(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=Gr(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 Vc(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 Hc(e){for(let t of e){if(!Vn.includes(t.type))throw Error(`Use PNG, JPEG or WebP images.`);if(!t.size)throw Error(`Image is empty.`)}}async function Uc(e){Hc([e]);let t=new Uint8Array(await e.arrayBuffer());return Un(t,e.type),t}var Wc=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 Gc(e,t,n,r){Hc(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await Uc(a);if(!r())throw Error(`stale`);let o=Wc(n),s=crypto.randomUUID();for(let i=0;i<o.length;i+=Bn.chunkChars){if(!r())throw Error(`stale`);let c=o.slice(i,i+Bn.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 Kc(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>Bn.chunkChars)throw Error(`invalid`);if(n.push(i.data),r+=i.data.length,i.next===null)break;if(i.next!==r||i.data.length!==Bn.chunkChars)throw Error(`invalid`)}let i=Hn(n.join(``));return Un(i,e.mimeType),new Blob([new Uint8Array(i)],{type:e.mimeType})}var qc=1e3,Jc=1e4,Yc=4,Xc=e=>e===`queued`||e===`running`,Zc=class extends Error{},Qc=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;details=new Map;error=``;loadingEarlier=!1;running=!1;again=!1;closed=!1;active=!1;timer;abort=new AbortController;reads=0;queue=[];snapshot;constructor(e,t,n){this.client=e,this.id=t,this.notify=n,this.snapshot=this.compose()}view(){return this.snapshot}setActive(e){this.active!==e&&(this.active=e,e?this.tick():clearTimeout(this.timer))}close(){this.closed=!0,this.abort.abort(),clearTimeout(this.timer)}refresh=()=>{this.tick()};choose=(e,t)=>{this.closed||(this.pinned===e?t!==void 0&&this.showFrom(t):(this.abort.abort(),this.abort=new AbortController,this.pinned=e,this.summary=void 0,this.context=void 0,this.pending=[],this.undelivered=[],this.error=``,this.forget(),this.opening=t===void 0?null:Math.max(0,t),this.publish(),this.tick()))};forget(){this.turns.clear(),this.details.clear(),this.imageReaders.clear(),this.first=null,this.count=0}loadEarlier=()=>{this.closed||this.loadingEarlier||!this.first||(this.first=Math.max(0,this.first-3),this.loadingEarlier=!0,this.publish(),this.tick())};showFrom=e=>{this.closed||(this.first===null?this.opening=Math.max(0,e):e>=this.first||(this.first=Math.max(0,e),this.loadingEarlier=!0,this.publish(),this.tick()))};publish(){this.closed||(this.snapshot=this.compose(),this.notify())}compose(){let e=[],t=this.count-1;for(;t>=0&&!this.turns.has(t);)t--;for(;t>=(this.first??this.count);t--){let n=this.turns.get(t);if(!n)break;e.unshift(n)}return{summary:this.summary,leaf:this.leaf,pinned:this.pinned!==null,branches:this.branches,runs:this.runs,attempt:this.attempt,pending:this.pending,undelivered:this.undelivered,commands:this.commands,...this.context?{context:this.context}:{},...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 Zc?e.message:`unavailable`)}finally{this.running=!1}if(e&&!this.again&&(this.loadingEarlier=!1),this.publish(),this.again){this.again=!1,this.tick();return}if(!this.active)return;let n=Xc(this.summary?.status)||[...this.turns.values()].some(e=>Xc(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?qc:Jc)}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 Zc(`invalid`);(!n.continues||n.turns<this.count)&&this.forget();let r=n.leaf===this.leaf?this.count:this.count-1;this.leaf=n.leaf,this.branches=n.branches,this.runs=n.runs,this.attempt=n.attempt,this.pending=n.pending??[],this.undelivered=n.undelivered??[],this.commands=n.commands??[],this.context=n.context,this.cache=n.cache,this.summary=n.summary,this.count=n.turns;let i=Math.max(0,n.turns-2);this.first=Math.min(this.first??this.opening??i,i),this.opening=null,this.publish();let a=[];for(let e=this.first;e<this.count;e++){let t=this.turns.get(e);(!t||e>=r||t.header.stable<t.header.steps||Xc(t.header.status))&&a.push(e)}await Promise.all(a.map(t=>this.load(t,n.leaf,e)))}async load(e,t,n){let r=this.turns.get(e),i=await this.turnRead(e,null,t,n),a=i.turn,o=Array.from({length:a.steps}),s=r?.header.id===a.id?Math.min(r.header.stable,i.start):0;for(let e=0;e<s;e++)o[e]=r?.steps[e];i.steps.forEach((e,t)=>{o[i.start+t]=e});let c=[];for(let e=i.start;e>s;e-=24)c.push(e);for(let r of await Promise.all(c.map(r=>this.turnRead(e,r,t,n))))r.steps.forEach((e,t)=>{let n=r.start+t;n>=s&&n<i.start&&(o[n]=e)});if(!n.aborted){if(o.some(e=>!e))throw new Zc(`stale`);this.turns.set(e,{ordinal:e,header:a,steps:o,detail:this.detail(t,a.id,n),image:this.imageReader(t,n)})}}async turnRead(e,t,n,r){let i=await this.read({kind:`conversation-turn`,id:this.id,leaf:n,ordinal:e,before:t},r);if(i.kind!==`conversation-turn`||i.ordinal!==e||i.leaf!==n)throw new Zc(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=Oa([t,r]);try{return await Kc(n,t=>this.read({kind:`conversation-image`,id:this.id,leaf:e,...n.live?{live:!0}:{},entry:n.entry,index:n.index,offset:t},i.signal))}finally{i.dispose()}},this.imageReaders.set(n,r)),r}detail(e,t,n){let r=`${e??``}:${t}`,i=this.details.get(r);return i||(i=async(r,i,a)=>{let o=await Promise.all(Array.from({length:i},async(i,o)=>{let s=Oa([n,a]);try{let n=await this.read({kind:`conversation-step`,id:this.id,leaf:e,turnId:t,step:r,part:o},s.signal);if(n.kind!==`conversation-step`||n.part!==o)throw new Zc(`invalid`);return n.item}finally{s.dispose()}}));return{text:o.map(e=>e.text).join(``),args:o.map(e=>e.args).join(``)}},this.details.set(r,i)),i}async read(e,t=this.abort.signal){this.reads>=Yc&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new Zc(`stale`);let n=await this.client.workbenchRead(e,t);if(n.kind===`error`)throw new Zc(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function $c(e,t,n,r=null){let[i,a]=(0,f.useState)(null),[o,s]=(0,f.useState)(null);return(0,f.useEffect)(()=>{let n=new Qc(e,t,()=>s(n.view()));return n.choose(r),a(n),s(n.view()),()=>n.close()},[e,t,r]),(0,f.useEffect)(()=>{i?.setActive(n)},[i,n]),{...o??{summary:void 0,leaf:null,pinned:!1,branches:0,runs:[],attempt:null,pending:[],undelivered:[],commands:[],count:0,turns:[],earlier:!1,loadingEarlier:!1,error:``},refresh:i?.refresh??el,loadEarlier:i?.loadEarlier??el,showFrom:i?.showFrom??el,choose:i?.choose??el}}function el(){}function tl(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,f.useState)(0),l=(0,f.useRef)(0),u=(0,f.useMemo)(()=>({client:e,epoch:i,attachment:a,refresh:n,revision:s,preview:o}),[e,i,a,n,s,o]),d=(0,f.useRef)(u);d.current=u;let p=(0,f.useRef)(!0);(0,f.useEffect)(()=>(p.current=!0,()=>{p.current=!1}),[]);let m=(0,f.useCallback)(()=>p.current&&(u.epoch!==null||!!u.preview)&&d.current===u&&l.current===u.revision,[u]),[h,g]=(0,f.useState)();(0,f.useEffect)(()=>{if(u.epoch===null&&!u.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&m();return u.preview?(u.preview(t.signal).then(e=>{n()&&g({scope:u,preview:e})}).catch(e=>{n()&&g({scope:u,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal).then(e=>{n()&&(e.kind===`error`?g({scope:u,error:e.error.code}):e.value.version.epoch===u.epoch?g({scope:u,catalog:e.value}):g({scope:u,error:`stale`}))}).catch(()=>{n()&&g({scope:u,error:`unavailable`})}),()=>t.abort())},[e,u,m]);let _=h?.scope===u&&m()?h:void 0;return{catalog:_?.catalog,preview:_?.preview,error:_?.error,loading:(i!==null||!!o)&&!_,isCurrent:m,reread(){m()&&c(++l.current)},accept(e){return!m()||e.version.epoch!==u.epoch?!1:(g({scope:u,catalog:e}),!0)}}}function nl(e,t,n,r=!1){return t?r||!n||J(n)!==J(e.model)?`validate`:`approve`:`restore`}async function rl(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 Ec(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 il(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 al(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function ol(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var sl=e=>`cadence:prompt-history:${e}`;function cl(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 ll(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 ul(e){try{let t=sessionStorage.getItem(sl(e));return t?cl(JSON.parse(t)):[]}catch{return[]}}function dl(e,t){let n=t;for(;n;)try{sessionStorage.setItem(sl(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=ul(e),r=ll(n,t);r!==n&&dl(e,r)}var pl={index:-1,draft:``};function ml(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:pl,text:t.draft}}function hl(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function gl(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||!hl(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 _l(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 yl(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 bl(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 xl(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Sl=``;function Cl(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function wl(e,t){return{first:!e.slice(0,t).includes(`
|
|
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`}] ${Tr(e)}`).join(`
|
|
7
|
+
`)||`None; no dependency installation or copying.`}\n\n## Baseline verification\n${e.baselineChecks.map(Tr).join(`
|
|
8
|
+
`)||`No separate baseline checks declared.`}\n\n## Verification\n${e.checks.map(Tr).join(`
|
|
9
|
+
`)}${e.reviewReads?.length?`\n\n## Review reads first\n${e.reviewReads.map(Er).join(`
|
|
10
|
+
`)}`:``}\n\n## Automation boundary\n${Dr(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(`
|
|
11
|
+
`)||`No existing document is named for update; project knowledge is still read.`}\n`}var kr=e=>z(e,0,864e13);function Ar(e){let t=W(e,[`createdAt`,`preparedAt`,`startedAt`,`stopRequestedAt`,`closedAt`,`settledAt`,...Object.hasOwn(e??{},`timeoutMs`)?[`timeoutMs`]:[],`stopReason`]);return{createdAt:kr(t.createdAt),preparedAt:U(t.preparedAt,kr),startedAt:U(t.startedAt,kr),stopRequestedAt:U(t.stopRequestedAt,kr),closedAt:U(t.closedAt,kr),settledAt:U(t.settledAt,kr),...t.timeoutMs===void 0?{}:{timeoutMs:z(t.timeoutMs,100,2147483647)},stopReason:U(t.stopReason,e=>L(e,320,!0))}}function jr(e){let t=W(e,[`acceptedAt`,`acquiredAt`,`settledAt`,`owner`]),n=W(t.owner,[`version`,`build`,`entry`,`pid`,`node`,`platform`,`startedAt`]);return{acceptedAt:kr(t.acceptedAt),acquiredAt:U(t.acquiredAt,kr),settledAt:U(t.settledAt,kr),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:kr(n.startedAt)}}}function Mr(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(`
|
|
12
|
+
`)}function Nr(e){let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`notice`),n=W(e,[`id`,`revision`,`enabled`,`head`,`proposal`,`runs`,...t?[`notice`]:[]]);return{id:pn(n.id),revision:z(n.revision,0),enabled:B(n.enabled),head:U(n.head,K),proposal:U(n.proposal,xr),runs:G(n.runs,200,K),...t?{notice:L(n.notice,1024,!0)}:{}}}function Pr(e){let t=L(e,64,!0);if(!/^[A-Za-z0-9_-]+$/.test(t))throw new F(`invalid`);return t}var Fr=196608,Ir=16384,Lr=1e3,Rr=16384,zr=1024;function Br(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 Vr(e){let t;try{t=JSON.parse(e)}catch{return``}if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=e=>{let n=Object.hasOwn(t,e)?t[e]:void 0;return typeof n==`string`?n.trim():``},r=n(`command`);return r?r.split(`
|
|
13
|
+
`,1)[0]:[n(`pattern`),n(`path`)].filter(Boolean).join(` `)}function 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`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:`circle`,attr:{cx:`12`,cy:`12`,r:`2`},child:[]},{tag:`path`,attr:{d:`M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14`},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:`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 Vi(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 Hi(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 Ui(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 Wi(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 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:`M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3`},child:[]}]})(e)}function Ki(e){return $({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 qi(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 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:`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 Yi(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 Xi(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 Zi(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 Qi(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 $i(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 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:`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 ta(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 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:`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 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:`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 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:`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 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:`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 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:`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 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:`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 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:`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 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:`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 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:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},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:`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 fa(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 pa(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 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 14 4 9 9 4`},child:[]},{tag:`path`,attr:{d:`M20 20v-7a4 4 0 0 0-4-4H4`},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:`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 ga(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 _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:`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 va(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 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:`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 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:`18 15 12 9 6 15`},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:`9 18 15 12 9 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:`15 18 9 12 15 6`},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:`6 9 12 15 18 9`},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:`polyline`,attr:{points:`20 6 9 17 4 12`},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:`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 Ea(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 Da(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 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:`19`,y1:`12`,x2:`5`,y2:`12`},child:[]},{tag:`polyline`,attr:{points:`12 19 5 12 12 5`},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:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 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:`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 ja(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 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:`12`,y1:`8`,x2:`12`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`},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:`22 12 18 12 15 21 9 3 6 12 2 12`},child:[]}]})(e)}var Pa=e=>({kind:`error`,error:oe(`unavailable`,e?`uncertain`:`none`)}),Fa=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=Gr(e);try{if(!this.transport.workbenchRead)return Pa(!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)?Pa(!1):e}catch{return Pa(!1)}}async workbenchCommand(e){let t=qr(e);try{if(!this.transport.workbenchCommand)return Pa(!0);let e=Q(await this.transport.workbenchCommand(t),di);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?Pa(!0):e}catch{return Pa(!0)}}async current(e,t){let n=an(e);try{if(!this.transport.current)return Pa(!1);let e=Q(await this.transport.current(n,t),dn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Pa(!1):e}catch{return Pa(!1)}}async currentChanges(e,t){let n=on(e);try{if(!this.transport.currentChanges)return Pa(!1);let e=Q(await this.transport.currentChanges(n,t),fn);return e.kind===`ok`&&J(e.value.request)!==J(n)?Pa(!1):e}catch{return Pa(!1)}}async activeRuns(e){try{return this.transport.activeRuns?Q(await this.transport.activeRuns(e),at):Pa(!1)}catch{return Pa(!1)}}async models(e,t){try{if(t){let n=await this.workbenchRead({kind:`conversation-models`,location:t},e);return n.kind===`error`?n:n.value.kind===`conversation-models`&&n.value.catalog.version.conversation?.id===t.id?{kind:`ok`,value:n.value.catalog}:Pa(!1)}return this.transport.models?Q(await this.transport.models(e),Cn):Pa(!1)}catch{return Pa(!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}:Pa(!0)}else{if(!this.transport.chooseModel)return Pa(!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 Pa(!0)}return e}catch{return Pa(!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?Pa(!1):n}catch{return Pa(!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)?Pa(!1):e}catch{return Pa(!1)}}async session(e){try{return Q(await this.transport.session(e),Ot)}catch{return Pa(!1)}}async workspace(e){try{return Q(await this.transport.workspace(e),kt)}catch{return Pa(!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)?Pa(!1):t}catch{return Pa(!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)?Pa(!1):e}catch{return Pa(!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))?Pa(!1):e}catch{return Pa(!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 Pa(!0);dt({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Pa(!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 Pa(!0);dt({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Pa(!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)?Pa(!1):e}catch{return Pa(!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)?Pa(!1):e}catch{return Pa(!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)?Pa(!1):e}catch{return Pa(!1)}}},Ia=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 La(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 Ra={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`},za=`/api/v1/events`,Ba=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Va(e,t){if(Ba.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 Ha(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function Ua(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 Wa(e,t){if(Ba.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 Ga(e){return[...Ba,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Ka(e,t){let n=Ra[e];return t===null||Ha(e)?n:`${n}?request=${encodeURIComponent(J(t))}`}function qa(e,t){let n=Ua(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Ra[e]:Ka(e,n);return Ha(e)||Ga(e)&&(r||R(i)>P.headerBytes/4)?{path:Ra[e],method:`POST`,body:J(n)}:{path:i,method:`GET`}}function Ja(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 Ya=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=qa(e,Ua(e,t)),i=r.method===`POST`,a=this.options.requestTimeoutMs===void 0?void 0:La([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 Xa(t,Va(e)),s=ue(a);if(R(a)>Va(e,s))throw new F(`oversize`);let c=Wa(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=qa(`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
|
+
`);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}`:``}${za}?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=Ja(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 Xa(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 Za={sourceHash:`c9b7cb2124ceef78efb739fad6f2618a9d459278aa98deb41fff304cdb834475`,contractHash:`8801198e182c2457f2ff8feb9331db22d449f2b483c0befd08ce493b4db6fb4a`,buildId:`dbed70697fb1eed6fba159518d2240db0569ca1a38e376d3c28e968dda1d0b0a`};function Qa(e){let t=new Ya({origin:window.location.origin,requestTimeoutMs:1e4,...e?{project:e}:{},...Za?{build:{kind:`browser`,...Za}}:{},socket:e=>new WebSocket(e)});return{client:new Fa(t),transport:t}}function $a(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 eo(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 to=[],no=null,ro,io,ao=new Set;function oo(){let e=eo(to,performance.now());if(e!==no){no=e;for(let e of ao)e()}}function so(e){if(ao.add(e),ao.size===1&&typeof PerformanceObserver<`u`)try{ro=new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=$a(t,location.origin);e&&(to=[...to.slice(-19),e])}oo()}),ro.observe({type:`resource`,buffered:!0}),io=setInterval(oo,5e3)}catch{ro=void 0}return()=>{ao.delete(e),!ao.size&&(ro?.disconnect(),ro=void 0,clearInterval(io),to=[],no=null)}}function co(){return(0,m.useSyncExternalStore)(so,()=>no,()=>null)}function lo(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 uo(e=typeof window>`u`?``:window.location.search){return lo(e,``).project}function fo(e=typeof window>`u`?``:window.location.hash){return lo(``,e).chat}function po(){let e=uo();return e?`/projects/${e}`:``}function mo(e=typeof window>`u`?``:window.location.hash,t){let n=new URLSearchParams(e.replace(/^#/,``));if(t!==void 0&&lo(``,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 ho(e,t){let n=new URLSearchParams(e.replace(/^#/,``));return t===null?n.delete(`leaf`):n.set(`leaf`,Pr(t)),`#${n}`}function go(e,t){if(typeof window>`u`||fo()!==e)return;let n=ho(window.location.hash,t);n!==window.location.hash&&history.replaceState(history.state,``,`${location.pathname}${location.search}${n}`)}function _o(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 vo(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 yo(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 bo(e,t,n=!1){let[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)([]),s=vo(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 xo(e){return ue(await Xa(e,1048576),1048576)}function So(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 Co(e){let t=Error(So(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 wo(e,t,n){let r=await fetch(e,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:n}),i=await xo(r);if(!r.ok)throw Error(So(i));return t(i)}function To(e){return wo(`/workbench/v1/service`,zn,e)}function Eo(e){return wo(`/workbench/v1/service/release`,Bn,e)}async function Do(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 xo(n);if(!n.ok)throw Error(So(r));let i=W(r,[`kind`,`job`]);return H(i.kind,`service-job`),In(i.job)}function Oo(e,t,n=!0){return!e||e.status===`unavailable`?`unknown`:t||!n?`stale`:e.status}function ko(e,t,n){return!t||t.status===`unavailable`?{value:e??t,error:n??`unavailable`}:{value:t,error:void 0}}function Ao(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 xo(r);if(!r.ok)throw Error(So(a));let c=Tn(a);o()&&s(r=>({id:e,revision:n,selectedEpoch:t,...ko(r.id===e?r.value:void 0,c)}))}catch(r){o()&&s(i=>({id:e,revision:n,selectedEpoch:t,...ko(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:Oo(u.value,u.error,u.revision===n&&u.selectedEpoch===t),refresh:c,prepared:l}}var jo=e=>e===`unauthenticated`||e===`forbidden`,Mo=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 Ia,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,jo(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(jo(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,jo(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,jo(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 Ia,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(jo(t.error.code)){E();return}throw Error(t.error.code)}if(s=new AbortController,c=new Ia,_={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 No(e,t,n,r){let i=(0,m.useMemo)(()=>new Mo(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 Po=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 Fo({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 Io(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 Lo(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 Ro(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 zo(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=Io(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 Bo(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),Lo(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 Vo({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)(Vo,{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 Ho(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function Uo(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return Ho(e)}return Ho(e)}function Wo(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 Uo(e)}catch(e){a=!1,r&&r(e)}return i.current&&(a?(o(!0),c(),s.current=setTimeout(()=>{o(!1),s.current=null},t),n?.(e)):r&&!a&&r(Error(`Copy failed`))),a},[t,n,r,c]),reset:l}}function Go(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 Ko=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:qo(!0)},text:{92:qo(!1)}});let t={enter:{backslashMathInline:Jo,backslashMathDisplay:Jo,backslashMathBlock:Jo},exit:{backslashMathInline:Yo,backslashMathDisplay:Yo,backslashMathBlock:Yo}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function qo(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 Jo=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)},Yo=function(e){this.exit(e)};function Xo(e){switch(e){case`error`:return null;case`warning`:return 4200;default:return 2400}}var Zo=(e,t)=>e.key!==void 0&&e.key===t.key||e.level===t.level&&e.text.trim()===t.text.trim();function Qo(e,t,n=3){let r=[...e.filter(e=>!Zo(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 $o=[],es=1,ts=new Set;function ns(e){if(!(e.length===$o.length&&e.every((e,t)=>e===$o[t]))){$o=e;for(let e of ts)e()}}function rs(e,t,n){let r=es++;return ns(Qo($o,{id:r,level:e,text:t,...n?{key:n}:{}})),r}function is(e){ns($o.filter(t=>t.id!==e))}function as(e){ns($o.filter(t=>t.key!==e))}function os(e){return ts.add(e),()=>{ts.delete(e)}}var ss=()=>$o,cs=(0,m.memo)(function({text:e,className:t=`copy-btn`}){let{t:n}=D(),{copied:r,copy:i}=Wo();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||rs(`error`,n(`Copy unavailable`))})},children:r?(0,_.jsx)(wa,{}):(0,_.jsx)(ga,{})})}),ls=[c,f,Ko],us=[c,u,f,Ko],ds=[[l,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[d,{detect:!1,ignoreMissing:!0}]];function fs(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 ps({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,_.jsx)(a,{remarkPlugins:n?us:ls,rehypePlugins:t?[i,o,...ds]:ds,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:gs,a:hs,img:({alt:e})=>(0,_.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ms=(0,m.memo)(function(e){return(0,_.jsx)(`div`,{className:`md`,children:(0,_.jsx)(ps,{...e})})});function hs({href:e,children:t}){let n=e&&fs(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 gs({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Go(r).map(e=>{let t=`code-offset:${i}`;return i+=_s(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)(cs,{text:_s(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 _s(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(_s).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return _s(t?.children)}return``}function vs(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 ys=new Map;function bs(e,t){t.length?ys.set(e,t):ys.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...ys].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 xs(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 Ss(e,t){let n=t.startContainer.parentElement;for(let r of xs(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 Cs({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?vs(n,r):[];return l.current=i,c(i.length),o(0),bs(u,i),()=>bs(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(Ss(e.current,l.current[n]),bs(`${u}-active`,[l.current[n]]))};return(0,m.useEffect)(()=>()=>bs(`${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 ws({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 zo(e,t,n.signal);if(n.signal.aborted)return;let i=await Uo(r.text);if(n.signal.aborted)return;w(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||w(a(`Full-field copy refused/incomplete.`))}finally{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)(Vo,{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)(Cs,{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)(ms,{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 Ts({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)(Vo,{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 Es({client:e,seed:t,entityId:n}){let{t:r,tx:i}=D(),a=Bo(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)(Ts,{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)(Vo,{value:e.coverage}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(Ro(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)(ws,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Ds({client:e,seed:t}){return(0,_.jsx)(Os,{client:e,seed:t},J(t))}function Os({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)(Vo,{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 ks(e){let t=qa(`download`,Jt(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=po()+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 As({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 js({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)(As,{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{ks({...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 Ms(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 Ns(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 Ps({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=Ms(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)(As,{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)(Vo,{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(Ns(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 Fs({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)(Vo,{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 Is({client:e,seed:t}){return(0,_.jsx)(Ls,{client:e,seed:t},J(t))}function Ls({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)(Vo,{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)(ws,{client:e,cursor:Ro(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)(ms,{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 Rs({client:e,seed:t,onScope:n}){let{t:r}=D(),i=Bo(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,m.useState)();return(0,_.jsxs)(`section`,{children:[(0,_.jsx)(Ts,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,_.jsxs)(`article`,{children:[(0,_.jsx)(Fs,{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)(Is,{client:e,seed:o},o.graph.recordId)]})}function zs({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 Bs(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 Vs(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 Hs(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)??Us(n.role,n.customType)}return r}function Us(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 Ws(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}function Gs(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=Hs(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=Bs(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=>Vs(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)=>Ws(e,t,d.current,n),[])}}function Ks(e,t){e&&t&&(e.scrollTop=e.scrollHeight)}function qs(e,t,n){(0,m.useEffect)(()=>{let r=new ResizeObserver(()=>Ks(e.current,n.current));return t.current&&r.observe(t.current),()=>r.disconnect()},[e,t,n])}var Js=(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`})}),Ys=(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)(ba,{"aria-hidden":`true`}):(0,_.jsx)(ca,{"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)(ws,{compact:!0,client:t,cursor:Ro(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)(Es,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function Xs({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=Gs(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)(Js,{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)(Ys,{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)(ka,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function Zs({client:e,seed:t}){let{t:n}=D(),r=Bo(e,{...t,reader:`messages`}),i=r.page;return(0,_.jsxs)(`section`,{className:`transcript`,children:[(0,_.jsx)(Ts,{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)(Xs,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function Qs({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)(Ca,{}):(0,_.jsx)(xa,{})}):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 $s=(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)(Qs,{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)(Es,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})}),ec=(e,t,n,r)=>JSON.stringify([e,t,n,r]);function tc({value:e,error:t,opening:n,onOpen:r,represented:i=[]}){let{t:a,tx:o}=D(),s=new Set(e?.projects.flatMap(e=>e.activities.filter(e=>e.sessionId).map(t=>`${e.path}\0${t.sessionId}`))),c=e?.projects.map(e=>({...e,activities:e.activities.filter(t=>!i.includes(ec(e.path,t.source,t.id,t.epoch)))})).filter(e=>e.activities.length);return(0,_.jsxs)(`section`,{className:`lp-section`,"aria-label":a(`Active Pi work`),children:[(0,_.jsx)(`header`,{className:`lp-section-header`,children:(0,_.jsx)(`span`,{className:`lp-section-title`,children:a(`Active Pi work`)})}),(0,_.jsxs)(`div`,{className:`lp-section-body`,children:[e&&(0,_.jsx)(`p`,{className:`panel-hint`,children:a(`{projects} projects · {sessions} sessions`,{projects:e.projects.length,sessions:s.size})}),(t||e?.completeness===`partial`)&&(0,_.jsxs)(`p`,{role:`status`,className:`panel-hint`,children:[a(`Activity observation is partial. Missing work is not known to have finished.`),t?` (${t})`:``]}),i.length>0&&(0,_.jsx)(`p`,{className:`panel-hint`,children:a(`Owner work already listed below is not duplicated here.`)}),!e&&!t&&(0,_.jsx)(`p`,{className:`panel-hint`,children:a(`Discovering active work…`)}),e?.completeness===`complete`&&!t&&!e.projects.length&&(0,_.jsx)(`p`,{className:`panel-hint`,children:a(`No active work observed. Idle terminals and owners are not listed.`)}),c?.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 nc(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 rc(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 ic=[[`running`,`{count} running`],[`queued`,`{count} queued`],[`completed`,`{count} done`],[`failed`,`{count} failed`],[`superseded`,`{count} superseded`]];function ac(e,t){return ic.filter(([t])=>e[t]>0).map(([n,r])=>t(r,{count:e[n]})).join(` · `)}function oc(e){let t=rc(e);return!t||t.queued+t.running===0?null:t.running>1||(e.delivery?.artifacts?.length??0)>0?t:null}function sc(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=>nc(e.id)===n.id),...r?{artifact:r}:{}}})}var cc=[`queued`,`running`];function lc(e,t){let n=e=>Number(!cc.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 uc(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(nc(t.id))):!1}var dc=[`queued`,`running`],fc=4,pc=1e4;function mc(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?dc.includes(t.status):i-(u.get(e)??0)>=pc}).reverse();for(let n=0;n<a.length;n+=fc){let r=await Promise.all(a.slice(n,n+fc).map(f));if(t.signal.aborted)return;e||=r.includes(!0),n+fc<a.length&&d(e)}let o=d(e);e||[...o.values()].some(e=>dc.includes(e.status))?r=setTimeout(()=>void p(),n):u.size&&(r=setTimeout(()=>void p(),pc))};return p(),()=>{t.abort(),clearTimeout(r)}},[e,o,n]),r}function hc({run:e,steps:t,selected:n,onOpen:r}){let{t:i,tx:a}=D(),o=rc(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:ac(o,i)})]}),t.map(t=>{let n=nc(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 gc({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=mc(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=lc(a,y.runs),w=C.flatMap(e=>e.steps),T=S.length+w.length,E=w.filter(e=>dc.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)(Ca,{}),(0,_.jsx)(pa,{}),(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)(hc,{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 _c(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 vc(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 yc=e=>e.filter(e=>e.current);function bc(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 xc(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=vo(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 Sc({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)(()=>_c(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)(ua,{"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)(ha,{"aria-hidden":`true`})})]},t.id))})]})}function Cc(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 wc(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 Tc(e,t){return Math.round(e/t*100)}var Ec=e=>e.trim().split(`
|
|
17
|
+
`,1)[0].slice(0,200);function Dc(e,t){return e.header.parent===void 0?t?.ordinal===e.ordinal-1?t.header.entry??void 0:void 0:e.header.parent}var Oc=(e,t)=>e?e.entry:t,kc=(e,t)=>e!==null&&t>=e.from;function Ac(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 jc(e){return e.images>0?`images`:e.modeChange?`mode`:e.anchored?`anchor`:e.waiting>=8?`full`:null}function Mc(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 Nc(e,t,n,r=crypto.randomUUID()){return{kind:`conversation-input-cancel`,commandId:r,conversationId:e,turnId:t.commandId,epoch:t.epoch,inputId:n}}function Pc(e){return new TextEncoder().encode(JSON.stringify(e)).length<=248}function Fc(e){return e.kind===`ok`?{kind:`accepted`}:e.error.effect===`none`?{kind:`refused`,code:e.error.code}:{kind:`unknown`,code:e.error.code}}var Ic=2e4;async function Lc(e,t,n,r){let i=La([t],Ic);try{if(i.signal.aborted)throw i.signal.reason;await e(i.signal,n,r)}finally{i.dispose()}}function Rc(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 zc(e){if(e&&typeof e==`object`&&`effect`in e)return[`none`,`accepted`,`uncertain`].includes(String(e.effect))?String(e.effect):void 0}function Bc(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 Vc(e,t,n){n(t.commandId);let r=await e.workbenchCommand(t);return(r.kind===`ok`||r.error.effect===`none`)&&n(``),r}function Hc(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(Uc(e.model))}:{}})}function Uc(e){return ge({provider:e.provider,model:e.model,api:e.api,thinking:e.thinking})}function Wc(e,t){return Object.freeze({...e,model:Object.freeze(Uc(t))})}function Gc(e,t){if(e.model&&J(e.model)!==J(Uc(t)))throw new F(`stale`)}function Kc(e,t){return Object.freeze({...e,preparedEpoch:K(t)})}function qc(e,t,n){return Object.freeze({...Wc(e,t),installModel:!n})}function Jc(e,t){return e.preparedEpoch?t.status===`ready`?t.epoch===e.preparedEpoch?`ready`:`cancel`:[`stopped`,`not-started`].includes(t.status)?`cancel`:`wait`:`cancel`}function Yc(e,t){return!!e&&e===t}async function Xc(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(Uc(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 Gc(t,a.value.selected),a.value}function Zc(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 Qc(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 $c(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 el(e){$c([e]);let t=new Uint8Array(await e.arrayBuffer());return Gn(t,e.type),t}var tl=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 nl(e,t,n,r){$c(n);let i=[];for(let a of n){if(!r())throw Error(`stale`);let n=await el(a);if(!r())throw Error(`stale`);let o=tl(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 rl(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 il=e=>e.renderId??`legacy:${e.id}`;function al(e,t){let n=new Map(e.map(e=>[il(e),e])),r=new Set;return t.map(e=>{let t=il(e);if(r.has(t))throw new ul(`stale`);r.add(t);let i=n.get(t);return i&&JSON.stringify(i)===JSON.stringify(e)?i:e})}var ol=1e3,sl=1e4,cl=4,ll=e=>e===`queued`||e===`running`,ul=class extends Error{},dl=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 ul?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`||ll(this.summary?.status)||[...this.turns.values()].some(e=>ll(e.header.status));this.timer=setTimeout(()=>void this.tick(),n?ol:sl)}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 ul(`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||ll(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)&&il(r.steps[n])!==il(e))throw new ul(`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 ul(`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 ul(`stale`);let l=al(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 ul(`invalid`);return i}imageReader(e,t){let n=e??``,r=this.imageReaders.get(n);return r||(r=async(n,r)=>{let i=La([t,r]);try{return await rl(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 ul(`stale`);let c=await Promise.all(Array.from({length:a},async(n,a)=>{let c=La([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 ul(`invalid`);if(s.renderId&&n.item.renderId!==s.renderId||s.version&&n.item.version!==s.version)throw new ul(`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>=cl&&await new Promise(e=>this.queue.push(e)),this.reads++;try{if(this.closed||t.aborted)throw new ul(`stale`);let n=await this.client.workbenchRead(e,t);if(this.closed||t.aborted)throw new ul(`stale`);if(n.kind===`error`)throw new ul(n.error.code);return n.value}finally{this.reads--,this.queue.shift()?.()}}};function fl(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 dl(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??pl,loadEarlier:l?.loadEarlier??pl,showFrom:l?.showFrom??pl,choose:l?.choose??pl}}function pl(){}function ml(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,revision:s,preview:o}),[e,i,a,n,s,o]),d=(0,m.useRef)(u);d.current=u;let f=(0,m.useRef)(!0);(0,m.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]);let p=(0,m.useCallback)(()=>f.current&&(u.epoch!==null||!!u.preview)&&d.current===u&&l.current===u.revision,[u]),[h,g]=(0,m.useState)();(0,m.useEffect)(()=>{if(u.epoch===null&&!u.preview)return;let t=new AbortController,n=()=>!t.signal.aborted&&p();return u.preview?(u.preview(t.signal).then(e=>{n()&&g({scope:u,preview:e})}).catch(e=>{n()&&g({scope:u,error:e instanceof Error?e.message:`unavailable`})}),()=>t.abort()):(e&&e.models(t.signal).then(e=>{n()&&(e.kind===`error`?g({scope:u,error:e.error.code}):e.value.version.epoch===u.epoch?g({scope:u,catalog:e.value}):g({scope:u,error:`stale`}))}).catch(()=>{n()&&g({scope:u,error:`unavailable`})}),()=>t.abort())},[e,u,p]);let _=h?.scope===u&&p()?h:void 0;return{catalog:_?.catalog,preview:_?.preview,error:_?.error,loading:(i!==null||!!o)&&!_,isCurrent:p,reread(){p()&&c(++l.current)},accept(e){return!p()||e.version.epoch!==u.epoch?!1:(g({scope:u,catalog:e}),!0)}}}function hl(e,t,n,r=!1){return t?r||!n||J(n)!==J(e.model)?`validate`:`approve`:`restore`}async function gl(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 Lc(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 _l(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 vl(e){return/^(?:退出\s*cadence|关闭\s*cadence(?:模式)?|exit cadence)$/iu.test(e.trim())}function yl(e){return/^(?:按(?:这个|本)?计划(?:开始)?(?:执行|实施)|确认(?:计划并)?(?:执行|实施)|approve and execute)[。.!!]?$/iu.test(e.trim())}var bl=e=>`cadence:prompt-history:${e}`;function xl(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 Sl(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 Cl(e){try{let t=sessionStorage.getItem(bl(e));return t?xl(JSON.parse(t)):[]}catch{return[]}}function wl(e,t){let n=t;for(;n;)try{sessionStorage.setItem(bl(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 Tl(e,t){let n=Cl(e),r=Sl(n,t);r!==n&&wl(e,r)}var El={index:-1,draft:``};function Dl(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:El,text:t.draft}}function Ol(e){return e===void 0||!(e===`@`||/[A-Za-z0-9_]/.test(e))}function kl(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||!Ol(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 Al(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 jl=e=>e.length<=1024&&!/[\0\uD800-\uDFFF]/u.test(e);function Ml(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 Nl(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 Pl(e){let t=Number.parseFloat(getComputedStyle(e).lineHeight)||0;return t>0?Math.max(2,t/2):2}var Fl=``;function Il(e,t,n=1){return{first:e<=n,last:Math.abs(t-e)<=n}}function Ll(e,t){return{first:!e.slice(0,t).includes(`
|
|
18
18
|
`),last:!e.slice(t).includes(`
|
|
19
|
-
`)}}var Tl=null;function El(){if(Tl?.isConnected)return Tl;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),Tl=e,e}function Dl(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 Ol(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Sl,e.appendChild(n),n.offsetTop}function kl(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=wl(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=El();if(Dl(e,i)<=0)return r;let a=Ol(i,t.slice(0,n)),o=Ol(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Cl(a,o,xl(e))}var Al={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},jl={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.`},Ml=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Nl=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function Pl(e,t){let n=e.thinking.filter(e=>e.selectable).map(e=>e.level);if(n.includes(t))return t;let r=e=>pe.indexOf(e);return n.reduce((e,n)=>Math.abs(r(n)-r(t))<Math.abs(r(e)-r(t))?n:e)}function Fl(){let{t:e}=T();return(0,f.useCallback)(t=>`${t.model} · ${e(Al[t.thinking])}`,[e])}function Il({client:e,availability:t,read:n,lastModel:r,draftModel:i,onPreviewChoice:a,locked:o,open:s,onOpenChange:c,onChanged:l,onChosen:u,awaitingSend:d=!1,scope:p=`conversation`}){let{t:m}=T(),g=Fl(),_=t.status===`ready`,v=n.preview,y=_||!!v||n.loading&&t.status!==`preparing`,b=_?t.epoch:null,x=_?t.attachmentVersion:null,{error:S,loading:C,reread:w}=n,E=_?n.catalog:void 0,D=E??v,[O,k]=(0,f.useState)(``),[ee,A]=(0,f.useState)(!1),[j,te]=(0,f.useState)(``),M=(0,f.useRef)(null),ne=(0,f.useRef)(null),N=(0,f.useRef)(null),P=(0,f.useRef)(null),re=(0,f.useRef)(c);re.current=c,(0,f.useEffect)(()=>{k(``)},[e,b,x]);let F=(0,f.useCallback)((e=!0,t)=>{t?re.current(!1,t):re.current(!1),te(``),k(``),e&&ne.current?.focus({preventScroll:!0})},[]);(0,f.useEffect)(()=>{if(!s)return;y&&N.current?.focus({preventScroll:!0});let e=e=>{M.current?.contains(e.target)||F(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[s,F,y]);let ie=E?.selected??null,I=i??ie??(v?r:null)??D?.remembered??null,L=(0,f.useMemo)(()=>{let e=j.trim().toLowerCase(),t=new Map;for(let n of D?.entries??[])(!e||`${n.provider}/${n.model}`.toLowerCase().includes(e))&&t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t]},[D,j]),ae=D?.entries.find(e=>Nl(e,I)),R=(_||!!v)&&!!D&&!C&&!S&&n.isCurrent(),z=async(t,r)=>{if(!R||!n.isCurrent()||!D||!t.api||ee||o)return;let i=me({provider:t.provider,model:t.model,api:t.api,thinking:r});if(v&&a)a(i),F(!0,`chosen`);else if(E&&e){if(ie&&Ml(ie,i))F(!0,`chosen`),u?.(i);else{A(!0),k(``);try{let t=await e.chooseModel({expected:E.version,choice:i});if(!n.isCurrent())return;if(t.kind===`error`){k(t.error.code),w();return}let r={...E,version:t.value.version,selected:t.value.selected};if(!n.accept(r))return;l(),F(!0,`chosen`),u?.(i)}catch{n.isCurrent()&&(k(`uncertain`),w())}finally{A(!1)}}}},B=()=>[...P.current?.querySelectorAll(`button[role=option]:not(:disabled)`)??[]],V=e=>{if(e.key!==`ArrowDown`&&e.key!==`ArrowUp`)return;e.preventDefault();let t=B(),n=t.indexOf(document.activeElement)+(e.key===`ArrowDown`?1:-1);n<0?N.current?.focus():t[Math.min(n,t.length-1)]?.focus()},H=t.status===`stopped`||t.status===`not-started`,U=D?null:r,W=n.preview||n.loading&&a||S&&a?m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`):H?m(`Choose a model`):t.status===`preparing`?m(`Preparing execution…`):t.status===`connecting`?m(`Checking execution state…`):t.status===`unavailable`?m(`Execution state unavailable`):m(C?`Reading models…`:S?`Model list unavailable`:`Choose a model`),G=I?g(I):H&&U?m(`Last used: {model}`,{model:g(U)}):W;return(0,h.jsxs)(`div`,{className:`model-picker`,ref:M,children:[(0,h.jsxs)(`button`,{ref:ne,type:`button`,className:`model-trigger${I&&!ie||U?` remembered`:``}${D&&!I?` empty`:``}`,"aria-label":m(`Model: {model}`,{model:G}),"aria-haspopup":`dialog`,"aria-expanded":s,title:o?m(`Switch models after the current reply finishes.`):i?m(`Choose now; the model is verified when you send.`):U?m(`Last used model; availability is checked when you send.`):I&&!ie?m(`Last used model; it is used again when you send.`):I?`${I.provider}/${I.model} · ${I.api}`:W,onClick:()=>{s?F():(k(``),c(!0))},children:[(0,h.jsx)(aa,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`model-trigger-text`,children:G}),(0,h.jsx)(ha,{"aria-hidden":`true`})]}),s&&(0,h.jsxs)(`div`,{className:`model-popover`,role:`dialog`,"aria-label":m(`Choose a model`),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),F())},children:[d&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose a model; your message is sent right after.`)}),v&&(0,h.jsx)(`p`,{className:`model-popover-lead`,children:m(`Choose now; the model is verified when you send.`)}),!y&&!S&&(0,h.jsx)(`p`,{className:`model-popover-lead`,role:`status`,children:t.status===`preparing`?m(`Execution is being prepared for your Send. Models will load when it is ready.`):m(`Model selection is unavailable until the current conversation and execution state are observed.`)}),U&&(0,h.jsxs)(`p`,{className:`model-popover-lead`,children:[m(`Last used: {model}`,{model:g(U)}),(0,h.jsx)(`br`,{}),m(`Last used model; availability is checked when you send.`)]}),y&&(0,h.jsxs)(`label`,{className:`model-search`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{ref:N,type:`search`,"aria-label":m(`Search models`),placeholder:m(`Search models…`),value:j,onChange:e=>te(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`?(e.preventDefault(),B()[0]?.focus()):e.key===`Enter`&&(e.preventDefault(),B()[0]?.click())}})]}),y&&(0,h.jsxs)(`div`,{className:`model-list`,role:`listbox`,"aria-label":m(`Models`),ref:P,onKeyDown:V,children:[C&&(0,h.jsx)(`p`,{className:`model-empty`,role:`status`,children:m(`Reading models…`)}),L.map(([e,t])=>(0,h.jsxs)(`fieldset`,{className:`model-group`,children:[(0,h.jsx)(`legend`,{className:`model-group-label`,children:e}),t.map(e=>{let t=e.eligibility===`candidate`,n=Nl(e,I);return(0,h.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":n,className:`model-option`,disabled:!R||!t||ee||o,title:`${e.provider}/${e.model}${e.api?` · ${e.api}`:``}`,onClick:()=>void z(e,Pl(e,I?.thinking??`medium`)),children:[(0,h.jsx)(`span`,{className:`model-option-name`,children:e.model}),!t&&(0,h.jsx)(`span`,{className:`model-option-note`,children:e.eligibility===`auth-unavailable`?m(`Credentials unavailable`):m(`Not supported`)}),n&&(!ie||!!i)&&(0,h.jsx)(`span`,{className:`model-option-note`,children:m(`Used when you send`)}),n&&(0,h.jsx)(ga,{className:`model-option-check`,"aria-hidden":`true`})]},`${e.provider}/${e.model}`)})]},e)),D?.status===`complete`&&L.length===0&&(0,h.jsx)(`p`,{className:`model-empty`,children:j.trim()?m(`No matching models.`):m(v?`No models are configured. Add a provider to Pi's models.json or auth.json, then read the list again.`:`No models are configured. Add a provider to Pi's models.json or auth.json, then restart the service.`)})]}),y&&ae&&ae.thinking.length>1&&(0,h.jsxs)(`div`,{className:`model-thinking`,children:[(0,h.jsx)(`span`,{className:`model-thinking-label`,children:m(`Thinking`)}),ae.thinking.map(e=>(0,h.jsx)(`button`,{type:`button`,"aria-label":m(`Thinking level: {level}`,{level:m(Al[e.level])}),"aria-pressed":I?.thinking===e.level,disabled:!R||!e.selectable||ee||o,onClick:()=>void z(ae,e.level),children:m(Al[e.level])},e.level))]}),(0,h.jsxs)(`div`,{className:`model-popover-notes`,children:[v&&!S&&(0,h.jsx)(`button`,{type:`button`,className:`link`,disabled:C||ee,onClick:w,children:m(`Refresh models`)}),o&&(0,h.jsx)(`p`,{children:m(`Switch models after the current reply finishes.`)}),D?.status===`capacity`&&(0,h.jsx)(`p`,{role:`alert`,children:m(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!D?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:m(D.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:D.withheld})}),(_||!!a)&&S&&(0,h.jsxs)(`p`,{role:`alert`,children:[m(`The model list could not be read ({code}).`,{code:S}),` `,(0,h.jsx)(`button`,{type:`button`,className:`link`,onClick:w,children:m(`Read again`)})]}),O&&(0,h.jsx)(`p`,{role:`alert`,children:jl[O]?m(jl[O]):m(`The model was not changed ({code}).`,{code:O})}),R&&(0,h.jsx)(`p`,{className:`model-popover-scope`,children:m(ee?`Switching model…`:p===`next-conversation`?`Used for your next new conversation after choosing a folder.`:`This model is used for future messages in this conversation. Work already started keeps its original model.`)})]})]})]})}function Ll({active:e,armed:t,known:n,disabled:r,onClick:i}){let{t:a}=T(),o=n?e?`on`:t?`armed`:`off`:`unknown`,s=a(n?e?`Cadence on`:t?`Cadence on next Send`:`Cadence off`:`Cadence state unavailable`);return(0,h.jsxs)(`button`,{type:`button`,className:`mode-toggle ${o}`,"aria-label":s,disabled:r||!n,title:a(e?`Cadence mode is on. Click to exit it.`:t?`Your next message turns on Cadence mode. Click to cancel.`:`Turn on Cadence mode: agree on a plan before implementation.`),onClick:i,children:[(0,h.jsx)(`span`,{className:`mode-switch`,"aria-hidden":`true`}),s]})}var Rl=.1,zl=(e,t)=>Math.max(Rl,Math.min(4,e*t));function Bl({blob:e,label:t,onClose:n}){let{t:r}=T(),i=(0,f.useRef)(null),a=(0,f.useRef)(null),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)({width:0,height:0}),[u,d]=(0,f.useState)(!1),[p,m]=(0,f.useState)(null);(0,f.useEffect)(()=>{let t=URL.createObjectURL(e);return s(t),()=>URL.revokeObjectURL(t)},[e]),(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]);let g=e=>{if(!c.width)return;let t=(a.current?.clientWidth||c.width)/c.width;m(n=>zl(n??t,e))},_=(e,t,n,r=!1)=>(0,h.jsx)(`button`,{type:`button`,className:`img-lightbox-btn`,title:e,"aria-label":e,disabled:r,onClick:n,children:t});return(0,h.jsx)(`dialog`,{ref:i,className:`img-lightbox`,"aria-label":t,onCancel:e=>{e.preventDefault(),n()},onClick:e=>{e.target===e.currentTarget&&n()},onKeyDown:e=>{e.key===`Escape`&&e.stopPropagation()},children:(0,h.jsxs)(`div`,{className:`img-lightbox-panel`,children:[(0,h.jsxs)(`div`,{className:`img-lightbox-toolbar`,children:[(0,h.jsx)(`span`,{className:`img-lightbox-name`,children:t}),_(r(`Close`),(0,h.jsx)(bi,{"aria-hidden":`true`}),n)]}),(0,h.jsxs)(`div`,{className:`img-lightbox-image${p===null?``:` img-lightbox-image-zoomed`}`,"data-pending":c.width>0||u?void 0:`true`,children:[o&&!u&&(0,h.jsx)(`img`,{ref:a,src:o,alt:t,style:p===null||!c.width?void 0:{width:c.width*p,height:c.height*p},onLoad:e=>l({width:e.currentTarget.naturalWidth,height:e.currentTarget.naturalHeight}),onError:()=>d(!0)}),u&&(0,h.jsx)(`p`,{role:`alert`,children:r(`Image unavailable.`)})]}),(0,h.jsxs)(`div`,{className:`img-lightbox-view-controls`,children:[c.width>0&&(0,h.jsxs)(`span`,{className:`img-lightbox-dims`,children:[c.width,` × `,c.height]}),_(r(`Zoom out`),(0,h.jsx)(vi,{"aria-hidden":`true`}),()=>g(1/1.25),!c.width||p!==null&&p<=.1),_(r(`Actual size`),(0,h.jsx)(Bi,{"aria-hidden":`true`}),()=>m(1),!c.width||p===1),p!==null&&(0,h.jsxs)(`span`,{className:`img-lightbox-zoom`,role:`status`,children:[Math.round(p*100),`%`]}),_(r(`Zoom in`),(0,h.jsx)(yi,{"aria-hidden":`true`}),()=>g(1.25),!c.width||p!==null&&p>=4),_(r(`Fit to window`),(0,h.jsx)(Li,{"aria-hidden":`true`}),()=>m(null),p===null)]})]})})}function Vl(){let[e,t]=(0,f.useState)([]),n=(0,f.useRef)(e),r=(0,f.useRef)(new WeakMap);return{files:e,add:e=>{let i=[...new Set([...n.current,...e])];Hc(i);for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=i,t(i)},remove:(0,f.useCallback)(e=>{n.current=n.current.filter(t=>!e.includes(t)),t(n.current)},[]),replace:(0,f.useCallback)(e=>{for(let t of e)r.current.has(t)||r.current.set(t,crypto.randomUUID());n.current=[...e],t(n.current)},[]),key:e=>r.current.get(e)}}function Hl(e){let[t,n]=(0,f.useState)(null);return{open:n,lightbox:t&&(0,h.jsx)(Bl,{blob:t,label:e,onClose:()=>n(null)})}}function Ul({url:e,alt:t,onOpen:n,onError:r}){let{t:i}=T();return(0,h.jsx)(`button`,{type:`button`,className:`chat-image-open`,"aria-label":i(`Open image: {name}`,{name:t}),title:i(`Open image`),onClick:n,children:(0,h.jsx)(`img`,{src:e,alt:t,loading:`lazy`,onError:r})})}function Wl({file:e,disabled:t,remove:n}){let{t:r}=T(),[i,a]=(0,f.useState)(``),[o,s]=(0,f.useState)(!1),{open:c,lightbox:l}=Hl(e.name);return(0,f.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),Uc(e).then(()=>{t&&(n=URL.createObjectURL(e),a(n))}).catch(()=>{t&&s(!0)}),()=>{t=!1,n&&URL.revokeObjectURL(n)}},[e]),(0,h.jsxs)(`div`,{className:`chat-image-draft`,children:[i&&(0,h.jsx)(Ul,{url:i,alt:e.name,onOpen:()=>c(e)}),o&&(0,h.jsx)(`span`,{className:`banner-notice`,children:r(`Invalid image.`)}),(0,h.jsx)(`span`,{title:e.name,children:e.name}),(0,h.jsx)(`button`,{type:`button`,className:`chat-image-remove`,disabled:t,"aria-label":r(`Remove image: {name}`,{name:e.name}),onClick:n,children:`×`}),l]})}function Gl({image:e,read:t}){let{t:n}=T(),[r,i]=(0,f.useState)(null),[a,o]=(0,f.useState)(!1),{open:s,lightbox:c}=Hl(n(`Attached image`)),{entry:l,index:u,mimeType:d,live:p}=e;return(0,f.useEffect)(()=>{let e=new AbortController,n=``;if(i(null),o(!1),!t)o(!0);else return t({entry:l,index:u,mimeType:d,...p?{live:p}:{}},e.signal).then(t=>{e.signal.aborted||(n=URL.createObjectURL(t),i({url:n,blob:t}))}).catch(()=>{e.signal.aborted||o(!0)}),()=>{e.abort(),n&&URL.revokeObjectURL(n)}},[t,l,u,d,p]),(0,h.jsxs)(h.Fragment,{children:[a?(0,h.jsx)(`span`,{className:`banner-notice`,children:n(`Image unavailable.`)}):r?(0,h.jsx)(Ul,{url:r.url,alt:n(`Attached image`),onOpen:()=>s(r.blob),onError:()=>o(!0)}):(0,h.jsx)(`span`,{className:`inspector-note`,children:n(`Loading image…`)}),c]})}function Kl({images:e,turn:t}){return(0,h.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,h.jsx)(Gl,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var ql=`cadence:composer-height`,Jl=16;function Yl(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var Xl=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,Zl=()=>Xl(typeof window>`u`?0:window.innerHeight);function Ql({inputRef:e,draft:t,onDraft:n,locked:r,images:i,imageKey:a,imagesLocked:o,onAddImages:s,onRemoveImage:c,anchor:l,status:u,cadence:d,model:p,hint:m,running:g,canStop:_,onStop:v,canSend:y,onSend:x,input:S,historyScope:C,files:w,onResized:E}){let{t:D}=T(),O=(0,f.useRef)(null),k=(0,f.useRef)(null),ee=(0,f.useId)(),[A,j]=(0,f.useState)(()=>{try{return Yl(localStorage.getItem(ql))}catch{return null}}),[te,M]=(0,f.useState)(64),[ne,N]=(0,f.useState)(``);(0,f.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Zl();t.style.height=`auto`;let r=t.scrollHeight,i=Math.min(A===null?Math.max(r,64):A,n);t.style.height=`${i}px`,t.style.overflowY=r>i?`auto`:`hidden`,M(i)},[t,A,ne,e]);let P=(0,f.useRef)(E);P.current=E,(0,f.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,P.current?.())},r=new ResizeObserver(n);return r.observe(e),window.addEventListener(`resize`,n),()=>{r.disconnect(),window.removeEventListener(`resize`,n)}},[]);let re=(e,t)=>{let n=e===null||e<=68?null:Math.min(Math.round(e),320);if(j(n),t)try{n===null?localStorage.removeItem(ql):localStorage.setItem(ql,String(n))}catch{}},F=(0,f.useRef)(void 0);(0,f.useEffect)(()=>()=>F.current?.(),[]);let ie=(0,f.useRef)(pl),I=(0,f.useRef)(null);(0,f.useEffect)(()=>{t!==I.current&&(ie.current=pl)},[t]);let L=(0,f.useRef)(null),[ae,R]=(0,f.useState)(-1);(0,f.useLayoutEffect)(()=>{let t=e.current;t&&L.current!==null&&(t.setSelectionRange(L.current,L.current),R(L.current),L.current=null)},[t,e]);let z=e=>{I.current=e,L.current=e.length,n(e)},[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(-1),[W,G]=(0,f.useState)(null),{location:K}=w,oe=K&&B&&!r&&W===t?gl(t,ae):null,q=_l(oe?.query??``),se=oe!==null&&oe.start!==H&&vl(q.folder),J=co(w.client,se&&K?{kind:`files`,path:q.folder,location:K}:null),ce=J.value?.kind===`files`?J.value:void 0,le=ce?yl(ce.entries,q.name):[],[ue,Y]=(0,f.useState)(0),de=oe?`${oe.start}:${oe.query}`:``;(0,f.useEffect)(()=>{Y(0),de||U(-1)},[de]);let fe=Math.min(ue,le.length-1),pe=le[fe],me=pe?`${ee}-${fe}`:void 0;(0,f.useEffect)(()=>{me&&document.getElementById(me)?.scrollIntoView({block:`nearest`})},[me]);let he=e=>{if(!oe)return;let r=bl(t,oe,ae,e);L.current=r.cursor,G(r.text),n(r.text)},ge=e=>{if(!e.nativeEvent.isComposing){if(se){if(e.key===`Escape`){e.preventDefault(),U(oe.start);return}if(pe){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let t=e.key===`ArrowDown`?1:-1;Y((fe+t+le.length)%le.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&&ie.current.index===-1)return;let r=kl(e.currentTarget);if(n?!r.first:!r.last)return;let i=ml(ul(C),ie.current,n?`older`:`newer`,t);if(!i)return;e.preventDefault(),ie.current=i.cursor,z(i.text)}else if(e.key===`Escape`&&ie.current.index!==-1){e.preventDefault();let t=ie.current.draft;ie.current=pl,z(t)}else e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),g&&S?S.enabled&&S.onInput(e.altKey?`queue`:`steer`):x())}},_e=D(A===null?`Message box height: automatic. Drag or use the arrow keys to set it.`:`Message box height: fixed. Double-click or press Home for automatic.`);return(0,h.jsxs)(`form`,{ref:O,className:`chat-composer`,onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),s(Array.from(e.dataTransfer.files)))},onSubmit:e=>{e.preventDefault(),g||x()},children:[(0,h.jsx)(`input`,{type:`range`,className:`composer-resize${A===null?``:` is-manual`}`,min:64,max:320,step:Jl,value:Math.round(te),"aria-label":_e,title:_e,"aria-orientation":`vertical`,"aria-valuetext":A===null?D(`Automatic`):D(`{pixels} pixels`,{pixels:Math.round(te)}),onChange:e=>re(Number(e.target.value),!0),onKeyDown:e=>{e.key===`Home`&&(e.preventDefault(),re(null,!0))},onDoubleClick:()=>re(null,!0),onPointerDown:t=>{t.preventDefault(),t.currentTarget.focus(),F.current?.();let n=t.clientY,r=e.current?.getBoundingClientRect().height??te,i=null,a=e=>{i=Math.min(Zl(),Math.max(64,r+(n-e.clientY))),re(i,!1)},o=()=>{window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),F.current=void 0,i!==null&&re(i,!0)};F.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})}}),(0,h.jsx)(`input`,{ref:k,type:`file`,accept:Vn.join(`,`),multiple:!0,hidden:!0,disabled:o,"aria-label":D(`Add images`),onChange:e=>{s(Array.from(e.currentTarget.files??[])),e.currentTarget.value=``}}),l,i.length>0&&(0,h.jsx)(`div`,{className:`chat-images`,children:i.map(e=>(0,h.jsx)(Wl,{file:e,disabled:o,remove:()=>c(e)},a(e)))}),u&&(0,h.jsx)(`p`,{className:`composer-status`,role:`status`,children:u}),se&&(0,h.jsxs)(`div`,{className:`mention-menu`,id:ee,role:`listbox`,"aria-label":D(`Files to reference`),onMouseDown:e=>e.preventDefault(),children:[(0,h.jsxs)(`div`,{className:`mention-menu-hint`,children:[(0,h.jsx)(`span`,{className:`mention-menu-folder`,children:q.folder?`@${q.folder}`:D(`Files in the conversation folder`)}),(0,h.jsx)(`span`,{children:D(`Enter inserts the path · Esc closes`)})]}),J.error?(0,h.jsx)(`p`,{className:`mention-menu-note`,role:`alert`,children:b(D,J.error)}):ce?le.length===0?(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`No matching files`)}):null:(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`Reading files…`)}),le.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,role:`option`,id:`${ee}-${t}`,className:`mention-item${e===pe?` active`:``}`,"aria-selected":e===pe,tabIndex:-1,title:e.path,onMouseEnter:()=>Y(t),onClick:()=>he(e),children:[e.directory?(0,h.jsx)(Zi,{"aria-hidden":`true`}):(0,h.jsx)(Qi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`mention-name`,children:e.name}),e.path!==e.name&&(0,h.jsx)(`span`,{className:`mention-path`,children:e.path})]},e.path)),ce?.limited&&(0,h.jsx)(`p`,{className:`mention-menu-note`,children:D(`Bounded listing; narrow the directory to see more.`)})]}),(0,h.jsx)(`textarea`,{ref:e,disabled:r,"aria-label":D(`Message`),"aria-autocomplete":K?`list`:void 0,"aria-controls":se?ee:void 0,"aria-activedescendant":se?me:void 0,value:t,placeholder:D(`Message, or /cadence to enter continuous Cadence mode…`),rows:2,onChange:e=>{R(e.target.selectionStart),G(e.target.value),n(e.target.value)},onSelect:e=>{let{selectionStart:t,selectionEnd:n}=e.currentTarget;R(t===n?t:-1)},onFocus:()=>V(!0),onBlur:()=>V(!1),onPaste:e=>{let t=Array.from(e.clipboardData.files).filter(e=>e.type.startsWith(`image/`));t.length&&(e.preventDefault(),s(t))},onKeyDown:ge}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost icon`,disabled:o,"aria-label":D(`Add images`),title:D(`Add images`),onClick:()=>k.current?.click(),children:(0,h.jsx)(Ki,{"aria-hidden":`true`})}),(0,h.jsx)(Ll,{...d}),(0,h.jsx)(Il,{...p}),(0,h.jsx)(`span`,{className:`composer-hint`,children:m}),g&&S?.enabled&&(0,h.jsxs)(`span`,{className:`composer-split`,children:[(0,h.jsx)(`button`,{type:`button`,className:`composer-queue`,"aria-label":D(`Queue behind this reply`),title:D(`Queue: sent when this reply ends (Alt+Enter)`),onClick:()=>S.onInput(`queue`),children:(0,h.jsx)(Hi,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`composer-steer`,"aria-label":D(`Steer this reply`),title:D(`Steer: read at the model's next step (Enter)`),onClick:()=>S.onInput(`steer`),children:(0,h.jsx)(va,{"aria-hidden":`true`})})]}),g?(0,h.jsx)(`button`,{type:`button`,className:`danger`,"aria-label":D(`Stop response`),title:D(`Stop response`),disabled:!_,onClick:v,children:(0,h.jsx)(Ti,{"aria-hidden":`true`})}):(0,h.jsx)(`button`,{"aria-label":D(`Send`),title:D(`Send`),type:`submit`,className:`primary`,disabled:!y,children:(0,h.jsx)(va,{"aria-hidden":`true`})})]})]})}function $l(e){let t=e.items.map(e=>({...Br(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 eu(e,t,n,r){let i=`${e.header.id}:${t}:${n.id}:${n.parts}`,[a,o]=(0,f.useState)({key:``}),{detail:s}=e,c=n.parts;return(0,f.useEffect)(()=>{if(!r||c===0)return;let e=new AbortController;return s(t,c,e.signal).then(e=>o({key:i,value:e}),t=>{e.signal.aborted||o({key:i,error:t instanceof Error?t.message:`unavailable`})}),()=>e.abort()},[s,t,c,r,i]),a.key===i?a:{}}var tu={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 nu(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(tu,n)&&tu[n]||`plaintext`}var ru=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function iu(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(ru)||[e],i=t.match(ru)||[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 au(e){if(!e)return[];let t=e.split(`
|
|
20
|
-
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function ou(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=au(r),o=au(i);n+=a.length,t+=o.length;let s=[];if(a.length===1&&o.length===1){let{oldTokens:e,newTokens:t}=iu(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 su=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function cu(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!su(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:nu(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=au(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(su):[],...typeof n.oldText==`string`||typeof n.newText==`string`?[{oldText:n.oldText,newText:n.newText}]:[]];return a.length===0?null:{...i,isWrite:!1,...ou(a)}}function lu({line:e}){return(0,h.jsxs)(`div`,{className:`diff-line-row ${e.type}`,children:[(0,h.jsx)(`span`,{className:`diff-gutter-sym`,children:e.type===`add`?`+`:`-`}),(0,h.jsx)(`span`,{className:`diff-line-content`,children:e.tokens?.length?e.tokens.map((e,t)=>(0,h.jsx)(`span`,{className:e.type===`same`?void 0:`char-${e.type}`,children:e.text},t)):e.content||` `})]})}function uu({data:e,failed:t=!1}){let{t:n}=T(),[r,i]=(0,f.useState)(!1),a=e.additions+e.deletions,o=r?1/0:400,s=e.hunks.flatMap((e,t)=>{let n=e.lines.slice(0,Math.max(o,0));return o-=n.length,n.length>0?[{hunk:e,index:t,lines:n}]:[]});return(0,h.jsxs)(`div`,{className:`file-diff-card${t?` is-err`:``}`,children:[(0,h.jsxs)(`div`,{className:`file-diff-toolbar`,children:[(0,h.jsxs)(`div`,{className:`file-diff-info`,children:[(0,h.jsx)($i,{className:`file-diff-file-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`file-diff-path`,title:e.filePath,children:e.filePath||n(`No path recorded`)}),e.language!==`plaintext`&&(0,h.jsx)(`span`,{className:`file-diff-lang`,children:e.language}),(0,h.jsxs)(`span`,{className:`file-diff-stat-badge`,title:n(`{added} lines added, {removed} removed`,{added:e.additions,removed:e.deletions}),children:[(0,h.jsxs)(`span`,{className:`add`,children:[`+`,e.additions]}),!e.isWrite&&(0,h.jsxs)(`span`,{className:`del`,children:[`-`,e.deletions]})]})]}),(0,h.jsxs)(`span`,{className:`file-diff-claim`,title:n(`Built from the call's recorded arguments. It is not compared with the file, so it is not proof of what the file holds.`),children:[t&&(0,h.jsx)(wa,{"aria-hidden":`true`}),t?n(`Error recorded: requested, not applied`):e.isWrite?n(`Requested content`):n(`Requested change`)]})]}),(0,h.jsx)(`div`,{className:`file-diff-body`,children:a===0?(0,h.jsx)(`div`,{className:`diff-empty-tip`,children:n(`No lines recorded.`)}):(0,h.jsx)(`div`,{className:`diff-unified-view`,children:s.map(({hunk:t,index:r,lines:i})=>(0,h.jsxs)(`div`,{className:`diff-hunk-section`,children:[e.hunks.length>1&&(0,h.jsx)(`div`,{className:`diff-hunk-header`,children:(0,h.jsx)(`span`,{className:`diff-hunk-text`,children:n(`Replacement {index} of {count}: {removed} lines for {added}`,{index:r+1,count:e.hunks.length,removed:t.removed,added:t.added})})}),i.map((e,t)=>(0,h.jsx)(lu,{line:e},t))]},r))})}),!r&&a>400&&(0,h.jsxs)(`p`,{className:`file-diff-more`,children:[n(`Showing the first {shown} of {total} lines.`,{shown:400,total:a}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>i(!0),children:n(`Show all lines`)})]})]})}function du(e){let t=e.map((e,t)=>({step:e,index:t}));return{user:t.filter(({step:e})=>e.role===`user`),replies:t.filter(({step:e})=>e.role===`tool`||e.role===`thinking`||e.role===`assistant`&&e.text.trim()!==``)}}var fu={bash:[Ci,`exec`],powershell:[Ci,`exec`],read:[$i,`read`],ls:[Zi,`read`],write:[ta,`edit`],edit:[na,`edit`],grep:[ki,`search`],find:[la,`search`]},pu=[Si,`default`],mu=e=>Object.hasOwn(fu,e)?fu[e]:pu;function hu(e,t){let{header:n,steps:r}=e;if(r[t]?.error)return`err`;let i=n.status===`queued`||n.status===`running`;return i&&t>=n.stable?`run`:n.status===`completed`||i||r.slice(t+1).some(e=>e.role===`assistant`)?`ok`:`idle`}var gu={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function _u(){return(0,h.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,width:`1em`,height:`1em`,className:`half-ring-spin`,"aria-hidden":`true`,children:(0,h.jsx)(`path`,{d:`M 12 2 A 10 10 0 0 1 12 22`})})}function vu({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,h.jsx)(as,{text:e})}){let{t:a}=T(),o=t<e.header.stable,s=eu(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,h.jsxs)(h.Fragment,{children:[n.images?.length?(0,h.jsx)(Kl,{images:n.images,turn:e}):null,c.trim()!==``&&(0,h.jsxs)(`div`,{className:`msg-text single`,children:[(0,h.jsx)(`div`,{className:`msg-text-main`,children:i(c)}),r&&(0,h.jsx)($o,{text:c,className:`msg-text-copy`})]}),n.clipped&&o&&!s.value&&(0,h.jsx)(`p`,{className:s.error?`banner-notice`:`inspector-note`,children:s.error?b(a,s.error):a(`Reading the rest of this message…`)})]})}function yu(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 bu(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function xu({turn:e,index:t,step:n}){let{t:r}=T(),[i,a]=(0,f.useState)(!1),o=eu(e,t,n,i),[s,c]=mu(n.name),l=hu(e,t),u=r(gu[l]),d=o.value?.args,p=d?yu(d):void 0,m=(0,f.useMemo)(()=>d?cu(n.name,d):null,[n.name,d]);return(0,h.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,h.jsx)(Vs,{open:i,onToggle:()=>a(e=>!e),headClassName:`toolcall-head`,titleText:r(i?`Collapse`:`Show arguments and output`),icon:(0,h.jsx)(s,{"aria-hidden":`true`}),iconClassName:`toolcall-icon tc-tone-${c}`,titleClassName:`toolcall-name`,after:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`toolcall-status`,role:`img`,title:u,"aria-label":u,children:l===`err`?(0,h.jsx)(bi,{"aria-hidden":`true`}):l===`ok`?(0,h.jsx)(ga,{"aria-hidden":`true`}):l===`run`?(0,h.jsx)(_u,{}):(0,h.jsx)(Ii,{"aria-hidden":`true`})}),n.target&&(0,h.jsxs)(`span`,{className:`toolcall-path`,title:n.target,children:[c===`exec`&&`$ `,n.target]}),(0,h.jsx)(`span`,{className:`toolcall-spacer`}),n.target&&(0,h.jsx)($o,{text:n.target,className:`chead-copy`})]}),children:n.name||r(`Tool`)}),i&&(0,h.jsx)(`div`,{className:`toolcall-body`,children:n.parts===0?(0,h.jsx)(`p`,{className:`inspector-note`,children:r(`Nothing more is recorded for this call.`)}):o.value?(0,h.jsxs)(h.Fragment,{children:[o.value.args&&(0,h.jsx)(`div`,{className:`toolcall-args`,children:m?(0,h.jsx)(uu,{data:m,failed:l===`err`}):p?(0,h.jsxs)(`div`,{className:`termline`,children:[(0,h.jsx)(Ci,{className:`termline-icon`,"aria-hidden":`true`}),(0,h.jsx)(`code`,{children:p})]}):(0,h.jsx)(`pre`,{children:bu(o.value.args)})}),o.value.text&&(0,h.jsxs)(`div`,{className:`toolcall-output`,children:[(0,h.jsx)(`div`,{className:`toolcall-output-label`,children:r(n.error?`Error output`:`Output`)}),(0,h.jsx)(`pre`,{children:o.value.text})]})]}):(0,h.jsx)(`p`,{className:o.error?`banner-notice`:`inspector-note`,children:o.error?b(r,o.error):r(`Reading…`)})})]})}var Su=/^\s{0,3}(`{3,}|~{3,})/,Cu=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function wu(e){return e.trim()===``}function Tu(e){let t=Su.exec(e);return t?t[1]:null}function Eu(e){let t=e.split(`
|
|
21
|
-
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=Tu(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=Tu(a);if(o&&!wu(a))i=o,r.push(a);else if(wu(a)){let i=e;for(;i<t.length&&wu(t[i]);)i++;if(!(i<t.length&&Cu.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
22
|
-
`)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
|
|
23
|
-
`),inFence:i!==null}}function Du(e,t,n=!1){let r=e.length;if(t>=r)return r;t<0&&(t=0);let i=r-t,a;a=n?i<=16?Math.max(2,Math.ceil(i/6)):Math.ceil(i/8):i<=32?1:i<=90?2:Math.ceil(i<=240?i/28:i/18);let o=Math.min(r,t+a);if(o<r){let t=e.charCodeAt(o-1);t>=55296&&t<=56319&&(o=Math.min(r,o+1))}return o}var Ou=(0,f.memo)(function({text:e}){return(0,h.jsx)(is,{text:e})}),ku=22,Au=14,ju=()=>typeof document<`u`&&document.hidden;function Mu(e,t=!0,n=!1,r){let[i,a]=(0,f.useState)(()=>!t||ju()||e.length>1500?e.length:0),o=(0,f.useRef)(e);o.current=e;let s=(0,f.useRef)(i);s.current=i;let c=(0,f.useRef)(n);c.current=n;let l=(0,f.useRef)(r);return l.current=r,(0,f.useEffect)(()=>{if(typeof document>`u`)return;let e=()=>{document.hidden,s.current=o.current.length,a(o.current.length),(c.current||!t)&&l.current?.()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[t]),(0,f.useEffect)(()=>{if(!t){s.current!==e.length&&(s.current=e.length,a(e.length));return}if(ju()){s.current!==e.length&&(s.current=e.length,a(e.length)),(n||s.current>=e.length)&&l.current?.();return}if(e.length<s.current){s.current=e.length,a(e.length);return}if(s.current>=e.length){l.current?.();return}let r=0,i=0,u=e=>{let t=c.current?Au:ku;if(i>0&&e-i<t){r=requestAnimationFrame(u);return}i=e;let n=o.current,d=Du(n,s.current,c.current);d!==s.current&&(s.current=d,a(d)),d<n.length?r=requestAnimationFrame(u):l.current?.()};return r=requestAnimationFrame(u),()=>cancelAnimationFrame(r)},[e,t,n]),!t||i>=e.length?e:e.slice(0,i)}var Nu=600,Pu=32;function Fu({text:e,inFence:t}){let n=!t&&e.length>=Nu,[r,i]=(0,f.useState)(e),a=(0,f.useRef)(0),o=(0,f.useRef)(null);return(0,f.useEffect)(()=>{if(!n)return;let t=Date.now()-a.current,r=()=>{a.current=Date.now(),i(e)};if(t>=Pu)r();else return o.current=setTimeout(r,Pu-t),()=>{o.current&&clearTimeout(o.current)}},[e,n]),t?(0,h.jsx)(`div`,{className:`codeblock`,children:(0,h.jsx)(`pre`,{children:(0,h.jsx)(`code`,{children:e})})}):(0,h.jsx)(is,{text:n?r:e})}var Iu=(0,f.memo)(function({text:e,finishing:t=!1,onSettled:n}){let r=Mu(e,!0,t,n),{frozen:i,active:a,inFence:o}=(0,f.useMemo)(()=>Eu(r),[r]),s=0,c=i.map(e=>{let t=`stream-offset:${s}`;return s+=e.length,{key:t,text:e}});return(0,h.jsxs)(`div`,{className:`md`,children:[c.map(({text:e,key:t})=>(0,h.jsx)(Ou,{text:e},t)),a.length>0&&(0,h.jsx)(Fu,{text:a,inFence:o},i.length)]})});function Lu(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
19
|
+
`)}}var Rl=null;function zl(){if(Rl?.isConnected)return Rl;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),Rl=e,e}function Bl(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 Vl(e,t){e.textContent=t;let n=document.createElement(`span`);return n.textContent=Fl,e.appendChild(n),n.offsetTop}function Hl(e){let t=e.value,n=e.selectionStart;if(n!==e.selectionEnd)return{first:!1,last:!1};let r=Ll(t,n);if(!r.first&&!r.last||typeof document>`u`||typeof getComputedStyle!=`function`)return r;let i=zl();if(Bl(e,i)<=0)return r;let a=Vl(i,t.slice(0,n)),o=Vl(i,t),s=i.offsetHeight>0;return i.textContent=``,!s&&t!==``?r:Il(a,o,Pl(e))}var Ul={off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Max`},Wl={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.`},Gl=(e,t)=>e.provider===t.provider&&e.model===t.model&&e.api===t.api&&e.thinking===t.thinking,Kl=(e,t)=>!!t&&e.provider===t.provider&&e.model===t.model&&e.api===t.api;function ql(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 Jl(){let{t:e}=D();return(0,m.useCallback)(t=>`${t.model} · ${e(Ul[t.thinking])}`,[e])}function Yl({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=Jl(),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=>Kl(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&&Gl(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)(pa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`model-trigger-text`,children:W}),(0,_.jsx)(Ca,{"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=Kl(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,ql(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)(wa,{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 restart the service.`)})]}),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(Ul[e.level])}),"aria-pressed":F?.thinking===e.level,disabled:!L||!e.selectable||A||o,onClick:()=>void R(I,e.level),children:p(Ul[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,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; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count: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,children:p(`Read again`)})]}),O&&(0,_.jsx)(`p`,{role:`alert`,children:Wl[O]?p(Wl[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 Xl({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 Zl=.1,Ql=(e,t)=>Math.max(Zl,Math.min(4,e*t));function $l({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=>Ql(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)(Ji,{"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)(Gi,{"aria-hidden":`true`}),()=>p(null),f===null)]})]})})}function eu(){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])];$c(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 tu(e){let[t,n]=(0,m.useState)(null);return{open:n,lightbox:t&&(0,_.jsx)($l,{blob:t,label:e,onClose:()=>n(null)})}}function nu({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 ru({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}=tu(e.name);return(0,m.useEffect)(()=>{let t=!0,n=``;return a(``),s(!1),el(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)(nu,{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 iu({image:e,read:t}){let{t:n}=D(),[r,i]=(0,m.useState)(null),[a,o]=(0,m.useState)(!1),{open:s,lightbox:c}=tu(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)(nu,{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 au({images:e,turn:t}){return(0,_.jsx)(`div`,{className:`chat-images`,children:e.map(e=>(0,_.jsx)(iu,{image:e,read:t.image},`${e.live?`live`:`session`}:${e.entry}:${e.index}`))})}var ou=`cadence:composer-height`,su=16;function cu(e){let t=Number(e);return e!==null&&Number.isFinite(t)&&t>68?Math.min(Math.round(t),320):null}var lu=e=>e>0?Math.max(160,Math.min(320,Math.floor(e*.42))):320,uu=()=>lu(typeof window>`u`?0:window.innerHeight);function du({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 cu(localStorage.getItem(ou))}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=uu();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(ou):localStorage.setItem(ou,String(n))}catch{}},P=(0,m.useRef)(void 0);(0,m.useEffect)(()=>()=>P.current?.(),[]);let ae=(0,m.useRef)(El),F=(0,m.useRef)(null);(0,m.useEffect)(()=>{t!==F.current&&(ae.current=El)},[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?kl(t,I):null,q=Al(K?.query??``),se=K!==null&&K.start!==V&&jl(q.folder),ce=vo(w.client,se&&G?{kind:`files`,path:q.folder,location:G}:null),le=ce.value?.kind===`files`?ce.value:void 0,J=le?Ml(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=Nl(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=Hl(e.currentTarget);if(n?!r.first:!r.last)return;let i=Dl(Cl(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=El,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:su,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(uu(),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)(ru,{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)(aa,{"aria-hidden":`true`}):(0,_.jsx)(oa,{"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)(ea,{"aria-hidden":`true`})}),(0,_.jsx)(Xl,{...d}),(0,_.jsx)(Yl,{...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)(Xi,{"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)(Ea,{"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)(Ea,{"aria-hidden":`true`})})]})]})}var fu={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 pu(e){let t=e?.split(/[\\/]/).pop()??``;if(t===`Makefile`)return`makefile`;let n=t.includes(`.`)?t.split(`.`).pop()?.toLowerCase():``;return n&&Object.hasOwn(fu,n)&&fu[n]||`plaintext`}var mu=/\s+|[a-zA-Z0-9_$]+|[^\s\w]/g;function hu(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(mu)||[e],i=t.match(mu)||[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 gu(e){if(!e)return[];let t=e.split(`
|
|
20
|
+
`);return t.length>1&&t.at(-1)===``&&t.pop(),t}function _u(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=gu(r),o=gu(i);n+=a.length,t+=o.length;let s=[];if(a.length===1&&o.length===1){let{oldTokens:e,newTokens:t}=hu(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 vu=e=>!!e&&typeof e==`object`&&!Array.isArray(e);function yu(e,t){if(e!==`edit`&&e!==`write`)return null;let n;try{n=JSON.parse(t)}catch{return null}if(!vu(n))return null;let r=typeof n.path==`string`?n.path:typeof n.file_path==`string`?n.file_path:``,i={filePath:r,language:pu(r)};if(e===`write`){if(typeof n.content!=`string`)return null;let e=gu(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(vu):[],...typeof n.oldText==`string`||typeof n.newText==`string`?[{oldText:n.oldText,newText:n.newText}]:[]];return a.length===0?null:{...i,isWrite:!1,..._u(a)}}function bu({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 xu({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)(sa,{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)(Ma,{"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)(bu,{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 Su(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 Cu(e){return e.state===`pending`||e.state===`streaming`||e.state===`running`}function wu(e,t,n,r){let i=`${e.renderId??e.header.id}:${il(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 Tu(e){let t=e.map((e,t)=>({step:e,index:t,key:il(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 Eu={bash:[Ai,`exec`],powershell:[Ai,`exec`],read:[sa,`read`],ls:[aa,`read`],write:[la,`edit`],edit:[ua,`edit`],grep:[Ii,`search`],find:[_a,`search`]},Du=[ki,`default`],Ou=e=>Object.hasOwn(Eu,e)?Eu[e]:Du;function ku(e,t){let n=e.steps[t];return n?.error||n?.state===`failed`?`err`:n?.state===`completed`?`ok`:n&&Cu(n)&&(e.header.status===`queued`||e.header.status===`running`)?`run`:`idle`}var Au={run:`Tool call in progress`,ok:`Tool result recorded`,err:`Tool error recorded`,idle:`No tool result observed`};function ju(){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 Mu({turn:e,index:t,step:n,copy:r=!0,render:i=e=>(0,_.jsx)(ms,{text:e})}){let{t:a}=D(),o=t<e.header.stable,s=wu(e,t,n,n.clipped&&o),c=s.value?.text??n.text;return(0,_.jsxs)(_.Fragment,{children:[n.images?.length?(0,_.jsx)(au,{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)(cs,{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 Nu(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 Pu(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Fu({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=wu(e,t,n,i),[s,c]=Ou(n.name),l=ku(e,t),u=r(Au[l]),d=o.value?.args,f=d?Nu(d):void 0,p=(0,m.useMemo)(()=>d?yu(n.name,d):null,[n.name,d]);return(0,_.jsxs)(`div`,{className:`toolcall ${l}`,children:[(0,_.jsx)(Qs,{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)(wa,{"aria-hidden":`true`}):l===`run`?(0,_.jsx)(ju,{}):(0,_.jsx)(Wi,{"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)(cs,{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)(xu,{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:Pu(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 Iu({turn:e,index:t,step:n}){let{t:r}=D(),[i,a]=(0,m.useState)(!1),o=wu(e,t,n,i&&n.parts>0),s=Cu(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)(pa,{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)(ju,{})]})});let c=o.value?.text.trim()??``;return(0,_.jsxs)(`div`,{className:`thinking${i?` open`:``}`,children:[(0,_.jsx)(Qs,{open:i,onToggle:()=>a(e=>!e),headClassName:`thinking-head`,titleText:r(i?`Collapse`:`Show thinking`),icon:(0,_.jsx)(pa,{"aria-hidden":`true`}),iconClassName:`thinking-icon`,titleClassName:`thinking-label`,after:(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`toolcall-spacer`}),c&&(0,_.jsx)(cs,{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 Lu=s().use(p).use(c).use(f).use(Ko);function Ru(e){return e.type===`definition`||e.type===`linkReference`||e.type===`imageReference`||e.type===`footnoteDefinition`||e.type===`footnoteReference`||(e.children?.some(Ru)??!1)}function zu(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 Bu(e){let{children:t}=Lu.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)),Ru(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&&zu(a,e.slice(a?.position?.start.offset));return{segments:r,frozen:r.slice(0,-1).map(e=>e.text),active:i,inFence:o}}var Vu=(0,m.memo)(function({text:e}){return(0,_.jsx)(ps,{text:e})}),Hu=(0,m.memo)(function({text:e}){let{segments:t}=(0,m.useMemo)(()=>Bu(e),[e]);return(0,_.jsx)(`div`,{className:`md`,children:t.map(e=>(0,_.jsx)(Vu,{text:e.text},`stream-offset:${e.start}`))})});function Uu(e,t,n){let r=e=>e.filter(e=>e.trim()!==``).join(`
|
|
24
21
|
|
|
25
|
-
`),i=({step:t,index:n})=>t.clipped&&n<e.header.stable;return t.some(i)?Promise.all(t.map(t=>i(t)?e.detail(t.index,t.step.parts,n).then(e=>e.text):t.step.text)).then(r):r(t.map(({step:e})=>e.text))}function
|
|
26
|
-
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:
|
|
27
|
-
`)}),![`completed`,`running`,`queued`].includes(u.status)&&(0,
|
|
28
|
-
`).find(e=>e.trim())??``,C=v([y,_,x]);return(0,h.jsxs)(`article`,{className:`workflow-line ${t.status}`,"aria-labelledby":o,children:[(0,h.jsxs)(`button`,{type:`button`,className:`workflow-line-open`,title:i(`Open workflow details`),onClick:n,children:[(0,h.jsx)(`span`,{className:`agent-dot ${t.status}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`workflow-line-goal`,id:o,children:t.goal}),(0,h.jsx)(`span`,{className:`workflow-line-meta ep-state ${t.status}`,title:C,children:_?(0,h.jsxs)(h.Fragment,{children:[`${y} · `,(0,h.jsxs)(`span`,{className:`workflow-line-deviation`,children:[(0,h.jsx)(Ca,{"aria-hidden":`true`}),_]}),x&&` · ${x}`]}):C})]}),p&&(0,h.jsxs)(`button`,{type:`button`,className:`ghost workflow-line-stop`,"aria-label":i(`Cancel workflow — request stop`),title:i(`Cancel workflow — request stop`),disabled:s,onClick:()=>{c(!0),u(``),od(e,t).then(e=>{d.current&&(u(e),r?.())}).finally(()=>{d.current&&c(!1)})},children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),i(`Stop`)]}),l?(0,h.jsx)(`p`,{className:`workflow-line-reason`,role:`alert`,children:b(i,l)}):S&&(0,h.jsx)(`p`,{className:`workflow-line-reason`,title:S,children:a(S)})]})}function ad({proposal:e,canApprove:t,approvalHint:n,onApprove:r,action:i=`approve`,canValidate:a=!1,validating:o=!1,previous:s,onValidate:c}){let{t:l}=T();return(0,h.jsxs)(`section`,{className:`workflow-plan`,"aria-label":l(`Current implementation plan`),children:[(0,h.jsx)(`h3`,{children:l(`Current implementation plan`)}),e.revalidatedFrom&&(0,h.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,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:l(`Previous execution context`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:s.cwd}),` · `,s.display?.model]}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:s.display?.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:s.display?.baseCommit})]}),s.display?.runtime&&(0,h.jsx)(`p`,{children:s.display.runtime}),s.delivery&&(0,h.jsx)(as,{text:vr(s.delivery)})]}),s&&s.observation!==e.observation&&(0,h.jsx)(`p`,{role:`status`,children:l(`Repository or execution-environment evidence changed. Review the current context before confirming.`)}),(0,h.jsx)(`p`,{children:l(`Tools and checks run on the service host, not in a sandbox.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.cwd}),` · `,e.display?.model]}),(0,h.jsxs)(`p`,{children:[l(`Declared write paths use the checkout root:`),` `,(0,h.jsx)(`code`,{children:e.checkoutRoot??e.cwd})]}),e.display?.runtime&&(0,h.jsx)(`p`,{children:e.display.runtime}),e.display?.branch&&(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:e.display.branch}),` ·`,` `,(0,h.jsx)(`code`,{children:e.display.baseCommit})]}),(0,h.jsx)(`p`,{children: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,h.jsx)(as,{text:`## ${e.plan.goal}\n\n${e.plan.acceptance}\n\n${e.plan.decisions}`}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:l(`Complete delivery agreement`)}),(0,h.jsx)(as,{text:Er(e.plan)})]}),e.delivery&&(0,h.jsx)(as,{text:vr(e.delivery)}),(0,h.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,h.jsx)(`button`,{type:`button`,disabled:!a,onClick:c,children:l(`Validate plan again`)}),i!==`approve`&&(0,h.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,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:n??l(`Plan approval is currently unavailable.`)}),(0,h.jsx)(`p`,{children:l(`To change the plan, continue the conversation. A changed plan requires fresh approval.`)})]})}async function od(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 sd(e){return(0,h.jsx)(cd,{...e},e.id)}function cd({client:e,id:t,onChanged:n,onOpenAgent:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(1e3),[c,l]=(0,f.useState)(),u=co(e,{kind:`workflow`,id:t},o),d=co(e,c===void 0?null:{kind:`workflow`,id:t,before:c}),p=d.value?.kind===`workflow`&&d.value.response.type===`run`?d.value.response.run:null,m=u.value?.kind===`workflow`&&u.value.response.type===`run`?u.value.response.run:null,g=c===void 0?m:p,[_,v]=(0,f.useState)(null),y=co(e,_?{kind:`workflow-detail`,id:t,stepId:_}:null),[b,x]=(0,f.useState)(!1),[S,C]=(0,f.useState)(``),w=m&&[`queued`,`running`].includes(m.status),E=(0,f.useRef)(!0);return(0,f.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]),(0,f.useEffect)(()=>{m&&![`queued`,`running`].includes(m.status)&&s(0)},[m]),(0,h.jsxs)(`article`,{className:`workflow-card chat-tool`,"aria-label":i(`Workflow progress`),children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`strong`,{children:m?.goal??i(`Observing workflow`)}),m&&(0,h.jsxs)(`span`,{className:`ep-state ${m.status}`,children:[a(m.phase),` · `,a(m.status)]})]}),(u.error||d.error||S)&&(0,h.jsxs)(`p`,{role:`alert`,children:[S||u.error||d.error,` ·`,` `,i(`State unavailable is not completion. No automatic resubmission.`)]}),m&&(0,h.jsx)(dd,{run:m}),m?.execution&&(0,h.jsxs)(`p`,{className:`inspector-note`,children:[i(`Context fixed at admission:`),` `,(0,h.jsx)(`code`,{children:m.execution.cwd}),` ·`,` `,m.execution.model?`${m.execution.model.provider}/${m.execution.model.model} · ${m.execution.model.thinking}`:i(`No model`)]}),m?.notice&&(0,h.jsx)(`p`,{children:m.notice}),m&&g&&(0,h.jsx)(md,{run:m,steps:g.steps,partial:(g.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:Gs(e.id)}))}),m&&((m.revision??0)>0||!!m.scope?.length)&&(0,h.jsxs)(`section`,{className:`workflow-route`,"aria-label":i(`Route revisions`),children:[(m.revision??0)>0&&(0,h.jsxs)(`p`,{children:[i(`Implementation route updates`),`: `,m.revision]}),!!m.scope?.length&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{children:i(`Paths added to the write scope after approval:`)}),(0,h.jsx)(`ul`,{className:`workflow-scope`,children:m.scope.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsx)(`code`,{children:e})},e))})]})]}),m?.delivery&&(0,h.jsx)(hd,{delivery:m.delivery}),m&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:`Owner timing and runtime`}),(0,h.jsx)(`pre`,{className:`workflow-detail`,children:Ar(m)})]}),m?.mergedCommit&&(0,h.jsxs)(`p`,{children:[i(`Actual local merge commit:`),` `,(0,h.jsx)(`code`,{children:m.mergedCommit})]}),m&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Agent review is not human review. Worktrees and retained results are preserved.`)}),m&&((g?.stepsBefore??0)>0||c!==void 0)&&(0,h.jsxs)(`nav`,{className:`workflow-actions`,children:[(g?.stepsBefore??0)>0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>l(g?.stepsBefore),children:i(`Earlier workflow steps`)}),c!==void 0&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{l(void 0),s(1e3)},children:i(`Latest workflow steps`)})]}),g&&(0,h.jsx)(ld,{steps:g.steps}),g?.steps.map(e=>(0,h.jsxs)(`details`,{className:`chat-tool`,children:[(0,h.jsx)(`summary`,{children:(0,h.jsx)(ud,{run:m??g,step:e})}),e.exitCode!==null&&(0,h.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,h.jsx)(as,{text:e.text}),e.childRunId&&r&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:Gs(e.id)}),children:i(`Open subagent context`)}),e.truncated&&(0,h.jsx)(`p`,{children:i(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>v(e.id),children:i(`Read retained step result`)}),_===e.id&&y.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:y.value.text}),_===e.id&&y.error&&(0,h.jsx)(`p`,{role:`alert`,children:y.error})]},e.id)),w&&(0,h.jsx)(`button`,{type:`button`,className:`danger`,disabled:b,onClick:()=>{m&&(x(!0),od(e,m).then(e=>{E.current&&(C(e),u.refresh(),n?.())}).finally(()=>{E.current&&x(!1)}))},children:i(`Cancel workflow — request stop`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>{u.refresh(),c!==void 0&&d.refresh()},children:i(`Observe current state`)})]})}function ld({steps:e}){let{t}=T(),n=t=>e.filter(e=>e.status===t).length,r=n(`partial`),i=n(`blocked`);return!r&&!i?null:(0,h.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 ud({run:e,step:t}){let{t:n,tx:r}=T();return(0,h.jsxs)(h.Fragment,{children:[`${r(t.kind)} · ${Gs(t.id)} · ${r(t.status)}`,$s(e,t)&&(0,h.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function dd({run:e}){let{t}=T(),n=e.deviations??[];return n.length?(0,h.jsxs)(`section`,{className:`workflow-deviations`,"aria-label":t(`Deviations from the agreement`),children:[(0,h.jsxs)(`h3`,{children:[(0,h.jsx)(Ca,{"aria-hidden":`true`}),t(`Deviations from the agreement: {count}`,{count:n.length})]}),(0,h.jsx)(`p`,{className:`workflow-deviations-note`,children:t(`Each is an acceptance item or decision that could not be met as written, with what was delivered instead. The automatic Agent review is asked to confirm each one; it is not human review.`)}),(0,h.jsx)(`ol`,{children:n.map(e=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:t(`Could not be met`)}),(0,h.jsx)(`dd`,{children:e.item}),(0,h.jsx)(`dt`,{children:t(`Why`)}),(0,h.jsx)(`dd`,{children:e.reason}),(0,h.jsx)(`dt`,{children:t(`Delivered instead`)}),(0,h.jsx)(`dd`,{children:e.delivered}),(0,h.jsx)(`dt`,{children:t(`Checks set aside`)}),(0,h.jsx)(`dd`,{children:e.waives.length?e.waives.map(e=>(0,h.jsx)(`code`,{children:e},e)):t(`None`)}),(0,h.jsx)(`dt`,{children:t(`Recorded at`)}),(0,h.jsx)(`dd`,{children:t(`route revision {revision}`,{revision:e.revision})})]})},`${e.revision}:${e.item}`))})]}):null}function fd({state:e}){return e===`running`?(0,h.jsx)(_u,{}):e===`completed`?(0,h.jsx)(_a,{"aria-hidden":`true`}):e===`failed`?(0,h.jsx)(xi,{"aria-hidden":`true`}):e===`superseded`?(0,h.jsx)(Ei,{"aria-hidden":`true`}):(0,h.jsx)(ua,{"aria-hidden":`true`})}function pd(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function md({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=T(),o=Ks(e);return o?(0,h.jsxs)(`section`,{className:`workflow-board`,"aria-label":i(`Assignments`),children:[(0,h.jsxs)(`h3`,{children:[i(`Assignments`),(0,h.jsx)(`span`,{className:`workflow-board-counts`,children:Js(o,i)})]}),n&&(0,h.jsx)(`p`,{className:`inspector-note`,children:i(`Only the steps on this page are grouped below; other pages hold more.`)}),(0,h.jsx)(`ul`,{children:Xs(e,t).map(({task:e,steps:t,artifact:n})=>(0,h.jsxs)(`li`,{className:`workflow-task`,children:[(0,h.jsxs)(`span`,{className:`workflow-task-state ${e.state}`,children:[(0,h.jsx)(fd,{state:e.state}),a(e.state)]}),(0,h.jsxs)(`div`,{className:`workflow-task-body`,children:[(0,h.jsxs)(`div`,{className:`workflow-task-title`,children:[(0,h.jsx)(`span`,{children:e.title}),(0,h.jsx)(`code`,{children:e.id})]}),(e.after.length>0||n||e.revision!==void 0)&&(0,h.jsxs)(`div`,{className:`workflow-task-meta`,children:[e.revision!==void 0&&(0,h.jsx)(`span`,{className:`workflow-task-revised`,children:i(e.state===`superseded`?`dropped by route revision {revision}`:`added or rewritten by route revision {revision}`,{revision:e.revision})}),e.after.length>0&&(0,h.jsx)(`span`,{children:i(`after {ids}`,{ids:e.after.join(`, `)})}),n&&(0,h.jsx)(`span`,{className:`workflow-task-worktree`,children:pd(n,i)})]}),n?.state===`retained`&&(0,h.jsx)(`code`,{className:`workflow-task-path`,children:n.path}),t.length>0&&(0,h.jsx)(`div`,{className:`workflow-task-steps`,children:t.map(e=>e.childRunId&&r?(0,h.jsx)(`button`,{type:`button`,className:`ghost`,title:i(`Open subagent context`),onClick:()=>r(e),children:`${a(e.kind)} · ${a(e.status)}`},e.id):(0,h.jsx)(`span`,{children:`${a(e.kind)} · ${a(e.status)}`},e.id))})]})]},e.id))})]}):null}function hd({delivery:e}){let{t,tx:n}=T(),r=[[t(`Task branch`),e.taskBranch],[t(`Task worktree`),e.worktreeRoot],[t(`Delivery target`),`${e.binding.target.branch} @ ${e.binding.target.head}`],[t(`Worktree preparation`),n(e.preparation)],[t(`Candidate commit`),e.candidate??t(`Not recorded`)],[t(`Candidate acceptance`),e.acceptance?`${e.acceptance.waived?.length?t(`Accepted with {count} of {total} checks set aside by a recorded deviation; the others and the automatic Agent review passed`,{count:e.acceptance.waived.length,total:e.acceptance.checks.length}):t(`Checks and automatic Agent review passed`)} · ${e.acceptance.candidate}`:t(`Not recorded`)],[t(`Local integration`),`${n(e.integration.status)}${e.integration.after?` · ${e.integration.after}`:``}`],[t(`Post-merge checks`),n(e.postChecks)],[t(`Worktree cleanup`),n(e.cleanup.status)]];return(0,h.jsxs)(`section`,{className:`workflow-delivery`,"aria-label":t(`Task branch delivery`),children:[(0,h.jsx)(`dl`,{children:r.map(([e,t])=>(0,h.jsxs)(f.Fragment,{children:[(0,h.jsx)(`dt`,{children:e}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(`code`,{children:t})})]},e))}),e.integration.reason&&(0,h.jsx)(`p`,{children:e.integration.reason}),e.cleanup.reason&&(0,h.jsx)(`p`,{children:e.cleanup.reason}),(0,h.jsx)(`p`,{children:t(`Policy: keep the task branch; no push or deployment.`)})]})}var gd=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function _d(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function vd({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:p,directoryNamespaces:m=[],available:g=c,canInterrupt:_=c,modelAvailability:v,previewModels:y,initialDraft:x,onDraftApplied:S,onModelChanged:C,onChanged:w,reference:E,onReferenceUsed:D,hidden:O=!1,observe:k=0,onOpenAgent:ee,onWorkflowRuns:A,onBranches:j,onOpenBranches:te}){let{t:M,tx:ne}=T(),[N]=(0,f.useState)(()=>Vc(n,t,p,...m)),[P,re]=(0,f.useState)(()=>_d(N,x?.text));(0,f.useEffect)(()=>{x&&S?.()},[x,S]);let F=Vl(),I=F.remove,L=(0,f.useRef)([]),ae=(0,f.useRef)(!0),R=Yu({draftKey:N,draft:P,setDraft:re,images:F,alive:ae,onUnread:()=>le(M(`Part of the message could not be read back. Check the text and images before sending.`))}),{anchor:z,attaching:B}=R,V=R.release,H=(0,f.useRef)({chooseBranch(e,t){},followAnchor(){},show(e,t){},stepVersion(e,t){}}),[U,W]=(0,f.useState)(()=>_d(`${N}:mode`)===`cadence`?`cadence`:`chat`),[G,K]=(0,f.useState)(!1),[oe,q]=(0,f.useState)(``),se=`conversation:${t}`,ce=()=>{q(``),Xo(se)},le=e=>Jo(`error`,e,se);(0,f.useEffect)(()=>()=>Xo(se),[se]);let[ue,Y]=(0,f.useState)(()=>_d(`${N}:pending`)),[de,fe]=(0,f.useState)(()=>_d(`${N}:model-command`)),[pe,he]=(0,f.useState)(!1),[ge,_e]=(0,f.useState)(!1),[ve,ye]=(0,f.useState)(!1),[be,xe]=(0,f.useState)(0),Se=(0,f.useRef)(null),Ce=(0,f.useRef)(!1),we=(0,f.useRef)(0),Te=(0,f.useRef)(new AbortController),[Ee,De]=(0,f.useState)(!1),[Oe,ke]=(0,f.useState)(()=>{try{let e=sessionStorage.getItem(`${N}:model`);if(e)return me(JSON.parse(e))}catch{}return x?.model??null});(0,f.useEffect)(()=>{try{Oe?sessionStorage.setItem(`${N}:model`,JSON.stringify(Oe)):sessionStorage.removeItem(`${N}:model`)}catch{}},[N,Oe]);let Ae=co(e,g&&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,f.useMemo)(()=>({models:n=>Ne?e.models(n,{id:t,cwd:Ne}):Promise.resolve({kind:`error`,error:ie(`unavailable`)}),chooseModel:n=>Ne?e.chooseModel(n,{id:t,cwd:Ne}):Promise.resolve({kind:`error`,error:ie(`unavailable`)})}),[e,t,Ne]),Fe=Ee?{status:`preparing`}:v.status===`ready`&&(!g||!Me)?{status:Ae.error?`unavailable`:`connecting`}:v,Ie=(0,f.useRef)(Fe);Ie.current=Fe;let Le=tl(Pe,Fe,`${be}:${je?.revision??`unobserved`}`,y),Re=()=>{Se.current=null,_e(!1),ye(!1)},ze=(e,t)=>{e&&!Le.preview&&!Le.loading?Le.reread():!e&&t!==`chosen`&&Re(),he(e)},Be=(e,t)=>{ke(t?null:e);let n=Se.current;ge&&n&&(Lc(n,Ie.current)===`cancel`?(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Se.current=Ic(n,e,t),_e(!1),ce(),ye(!0)))},Ve=(0,f.useRef)(o);Ve.current=o,(0,f.useEffect)(()=>{Me&&Ne&&Ve.current?.({id:t,cwd:Ne})},[Me,t,Ne]);let[He]=(0,f.useState)(()=>typeof window<`u`&&no()===t?io(window.location.hash,t).leaf:i),X=$c(e,t,g,He),{turns:Ue}=X,We=X.summary!==void 0,Ge=co(e,g?{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,f.useRef)(Z);Ye.current=Z;let[Xe,Ze]=(0,f.useState)(()=>_d(`${N}:approval`,``)),Qe=(0,f.useRef)(Xe),$e=(0,f.useRef)(!1),[et,tt]=(0,f.useState)(!1),[nt,rt]=(0,f.useState)(``),[it,at]=(0,f.useState)(),ot=(0,f.useCallback)(e=>{Qe.current=e,Ze(e);try{e?sessionStorage.setItem(`${N}:approval`,e):sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]),st=lo(P,Ke?`cadence`:U),ct=c&&!(a&&!X.summary)&&Me&&We&&!X.error&&qe&&!(Ke&&(Ge.error||Z?.notice))&&!G&&!ge&&!ue,lt=X.summary??void 0,Q=lt&&(lt.status===`queued`||lt.status===`running`),ut=!!lt&<.status!==`completed`&&!Q,dt=Ue.at(-1)?.header,ft=Q?dt&&[`queued`,`running`].includes(dt.status)?dt.at:0:null,{tokens:pt,provider:mt,model:ht}=X.context??{},gt=Le.catalog?.entries??Le.preview?.entries,_t=(0,f.useMemo)(()=>pt===void 0||mt===void 0||ht===void 0?void 0:fc({tokens:pt,provider:mt,model:ht},gt),[pt,mt,ht,gt]),{input:vt,read:yt,write:bt}=X.cache??{},xt=(0,f.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,f.useEffect)(()=>{k&&St()},[k,St]);let Ct=(0,f.useRef)(s);Ct.current=s,(0,f.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=uc(e,t,X.leaf,[wt?.header.id??``,X.count,X.branches,Tt].join(),g&&!!lt),{tree:Dt}=Et,Ot=(0,f.useMemo)(()=>sc(Dt??{nodes:[],truncated:!1}),[Dt]),kt=(0,f.useMemo)(()=>{let e=cc(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=du(wt.steps).user[0]?.step.text??``;return[...e,{id:wt.header.id,text:hc(t)}]},[Dt,wt,Tt]),[At,jt]=(0,f.useState)(null),[Mt,Nt]=(0,f.useState)(null),[Pt,Ft]=(0,f.useState)(null),It=!!u&&c&&(!!X.error||!!Ae.error)&&X.error!==`retired-conversation`&&Ae.error!==`retired-conversation`&&!Z?.notice&&!Q&&!G&&!ue&&!ge,Lt=(_||!!u)&&Me&&We&&Je&&!X.error&&!G&&!ue&&!Q,Rt=!!Oe&&J(Oe)!==J(je?.model??null),zt=!!Z?.proposal&&!!lt&&!Q&<.status!==`unknown`,Bt=Z?.proposal?nl(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?Q?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,f.useRef)(null),Gt=(0,f.useRef)(null),Kt=(0,f.useRef)(0),qt=(0,f.useRef)(!0),[Jt,Yt]=(0,f.useState)(!1);(0,f.useLayoutEffect)(()=>{!O&&Gt.current&&!qt.current&&(Gt.current.scrollTop=Kt.current)},[O]);let Xt=(0,f.useRef)(``),Zt=(0,f.useRef)(P);(0,f.useEffect)(()=>(ae.current=!0,Te.current.signal.aborted&&(Te.current=new AbortController),()=>{ae.current=!1,Te.current.abort()}),[]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(`${N}:mode`,U)}catch{}},[N,U]),(0,f.useEffect)(()=>{try{sessionStorage.setItem(N,P)}catch{}},[P,N]),(0,f.useEffect)(()=>{try{ue?sessionStorage.setItem(`${N}:pending`,ue):sessionStorage.removeItem(`${N}:pending`)}catch{}},[N,ue]),(0,f.useEffect)(()=>{try{ue&&de===ue?sessionStorage.setItem(`${N}:model-command`,de):sessionStorage.removeItem(`${N}:model-command`)}catch{}},[N,ue,de]),(0,f.useEffect)(()=>{E&&(re(e=>`${e}${e?`
|
|
29
|
-
`:``}@${E}`),D(),Wt.current?.focus())},[E,D]),(0,f.useEffect)(()=>{let e=lt?`${lt.leaf}:${lt.status}`:``;e&&Xt.current!==e&&(Xt.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(``),Rc(ue,de)&&ke(null),fe(``),I(L.current),re(e=>e===Zt.current?``:e),Rc(ue,de)&&fl(n,Zt.current),H.current.followAnchor(),w()),qt.current&&Gt.current&&(Gt.current.scrollTop=Gt.current.scrollHeight)},[lt,Ue,ue,de,w,Z,X,I,n,ot]);let Qt=(0,f.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]),$t=Is(Gt,Qt,Mt?.id??null),{earlier:en,loadEarlier:tn}=X,nn=()=>{let e=Gt.current;e&&!O&&en&&e.scrollTop<1200&&tn()};(0,f.useEffect)(nn);let rn=(0,f.useRef)(0),an=()=>{rn.current||=requestAnimationFrame(()=>{rn.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,f.useEffect)(()=>()=>{rn.current&&cancelAnimationFrame(rn.current)},[]),(0,f.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 on=Ue[0]?.ordinal,sn=(0,f.useRef)({height:0});(0,f.useLayoutEffect)(()=>{let e=Gt.current;if(!e)return;let t=sn.current;!gd&&!qt.current&&t.ordinal!==void 0&&on!==void 0&&on<t.ordinal&&(e.scrollTop+=e.scrollHeight-t.height),sn.current={ordinal:on,height:e.scrollHeight}}),(0,f.useEffect)(()=>{try{sessionStorage.removeItem(`${N}:approval`)}catch{}},[N]);let cn=(0,f.useMemo)(()=>[...new Set([...X.runs,...Z?.runs??[]])],[X.runs,Z?.runs]),ln=JSON.stringify(cn.slice(-4));(0,f.useEffect)(()=>{A?.(JSON.parse(ln))},[ln,A]);let[un,dn]=(0,f.useState)({terminal:8,browser:8}),fn=(0,f.useMemo)(()=>[...new Set([...X.runs.slice(-un.terminal),...(Z?.runs??[]).slice(-un.browser),...Xe?[Xe]:[]])],[X.runs,Z?.runs,un,Xe]),pn=rc(e,g?fn:[],1e3),mn=Ue.find(e=>e.header.at>0)?.header.at,hn=!en&&Ue.length>0;(0,f.useEffect)(()=>{if(!g)return;let e=(e,t)=>nd(e,t,pn.runs,pn.unreadable,mn,hn),t=e(X.runs,un.terminal),n=e(Z?.runs??[],un.browser);(t!==un.terminal||n!==un.browser)&&dn({terminal:t,browser:n})},[g,X.runs,Z?.runs,un,pn,mn,hn]);let gn=(0,f.useMemo)(()=>td(Ue,pn.runs.values(),en),[Ue,pn.runs,en]),_n=[...pn.runs.values()].filter(Qu).at(-1),vn=[...pn.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,f.useLayoutEffect)(()=>{vn&&qt.current&&Gt.current&&(Gt.current.scrollTop=Gt.current.scrollHeight)},[vn]);let yn=t=>(0,h.jsx)(id,{client:e,run:t,onOpen:()=>ee?.({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=()=>ae.current&&we.current===i;$e.current=!0,K(!0),tt(!0),ce();try{let o=await rl({client:e,state:r,context:je,model:t,head:X.leaf,signal:Te.current.signal,current:a,prepare:l?void 0:d});if(!ae.current||we.current!==i)return;at({before:n,after:o}),rt(``),ke(e=>J(e)===J(t)?null:e)}catch(e){ae.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{ae.current&&we.current===i&&($e.current=!1,K(!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||Q||Xe||!zt)return;let t=Z.proposal,n=Z,r=we.current;$e.current=!0,K(!0),ce();try{let i=await il({client:e,state:n,current:()=>ae.current&&we.current===r&&Ye.current?.revision===n.revision&&Ye.current?.enabled===!0,submitting:ot});if(!ae.current||we.current!==r)return;i.kind===`error`?(q(i.error.code),i.error.effect===`none`&&(ot(``),i.error.code===`stale`&&rt(t.id))):re(e=>ol(e)?``:e)}catch(e){ae.current&&we.current===r&&(q(e instanceof Error?e.message:`unavailable`),!Qe.current&&e instanceof Error&&e.message===`stale`&&rt(t.id))}finally{ae.current&&we.current===r&&($e.current=!1,K(!1),Ge.refresh(),X.refresh(),w())}},Sn=async(r,i)=>{let a=i?.text??r??P,o=i?.images??(r?[]:F.files),s=i?i.command.kind===`cadence-exit`:Ke&&al(a);if(!(s?Lt:ct)&&!It||Q||B&&!i||!a.trim()&&!o.length||i&&(!ct||Lc(i,Ie.current)!==`ready`))return;if(s&&o.length){le(M(`Remove images before exiting Cadence.`));return}if(!o.length&&!i&&!r&&Ke&&ol(a)){await xn();return}let c=lo(a,U).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,K(!0),ce();let l=we.current,d=()=>ae.current&&we.current===l,f=!1,p=`not-dispatched`,m=(e,t)=>{let n=M(kc(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 Ec(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??jc({id:t,head:s?X.leaf:_c(z,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?Mc(Le.catalog.selected):Le.catalog?.remembered??je?.model??Le.preview?.remembered??void 0),intent:s?`exit`:Ke?`message`:c?`enter`:`ordinary`});if(i){if(Lc(i,Ie.current)!==`ready`)throw Error(`stale`)}else await g(l.location);if(!d())return;if(l.command.kind===`cadence-exit`){let t=Bc(l);Zt.current=a,f=!0;let n=await Ac(e,t,h);if(!d())return;n.kind===`error`?m(n.error.code,n.error.effect):(Y(``),W(`chat`),re(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&&Lc(Fc(l,n),t)!==`cancel`?(Se.current=Fc(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=Nc(l,_)),l.installModel&&p.kind===`ok`){if(p={kind:`ok`,value:await zc(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}Pc(l,p.value.selected);let y=Bc(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 Gc(e,y,l.images,d),!d())return}L.current=l.images,Zt.current=a,f=!0;let b=await Ac(e,y,h);if(!d())return;b.kind===`error`?m(b.error.code,b.error.effect):(I(L.current),ke(null),re(e=>e===Zt.current?``:e),Y(``),y.kind===`cadence-send`&&W(`chat`),r||fl(n,a),Mn(null)),Ge.refresh(),X.refresh(),w()}catch(e){if(d()){let t=e instanceof Error?e.message:`unavailable`,n=Oc(e),r=M(f?kc():Dc(p,n),{code:t});!f&&(p===`not-dispatched`||n===`none`)?le(r):q(r)}}finally{we.current===l&&(Ce.current=!1),d()&&(K(!1),De(!1))}},Cn=(0,f.useRef)(Sn);Cn.current=Sn,(0,f.useEffect)(()=>{let e=Se.current;if(!e||!ve&&!ge)return;let t=Lc(e,Fe);t===`cancel`?(Se.current=null,_e(!1),ye(!1),Jo(`error`,M(`The connection changed. Your model choice and draft are kept; send again when ready.`),se)):ve&&t===`ready`&&ct&&!Q&&(ye(!1),Se.current=null,Cn.current(void 0,e))},[ve,ge,ct,Q,Fe,M,se]),(0,f.useEffect)(()=>{if(!ve)return;let e=setTimeout(()=>{ye(!1),Se.current=null},1e4);return()=>clearTimeout(e)},[ve]);let wn=Q?lt?.live:void 0,Tn=(0,f.useRef)(new Map),En=bc({images:F.files.length,modeChange:Ke?al(P):st.mode===`cadence`,anchored:!!z,waiting:X.pending.length}),Dn=!!wn&&_&&!G&&!B,On=async r=>{if(!wn||!Dn||En||!P.trim())return;ce(),K(!0);let i=P,a=xc(t,wn,r,i),o=wc(await e.workbenchCommand(a));ae.current&&(K(!1),o.kind===`accepted`?(Tn.current.set(a.commandId,i),fl(n,i),re(``)):o.kind===`refused`?le(M(`The running reply did not take the message ({reason}). Your text stays here.`,{reason:b(M,o.code)})):q(o.code),X.refresh())},kn=async(n,r)=>{if(!wn||G)return;K(!0);let i=wc(await e.workbenchCommand(Sc(t,wn,n.commandId)));if(ae.current){if(K(!1),i.kind===`accepted`){let e=Tn.current.get(n.commandId)??n.text;Tn.current.delete(n.commandId),r&&re(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:b(M,i.code)})):q(i.code);X.refresh()}},An=e=>{re(t=>t.trim()?`${t}\n${e}`:e),Wt.current?.focus()},jn=async()=>{let n=lt?.live;if(!n||G)return;K(!0);let r=await e.workbenchCommand({kind:`interrupt`,commandId:crypto.randomUUID(),conversationId:t,turnId:n.commandId,epoch:n.epoch});ae.current&&(r.kind===`error`&&q(r.error.code),K(!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),he(!1),K(!1),De(!1),V(),X.choose(e,n),oo(t,e)},Nn=!Q&&!G&&!ue&&!ge,Pn=()=>{ce(),Wt.current?.focus()},Fn=e=>{Nn&&e.header.entry&&(e.ordinal>=X.count-1?V():R.continueAfter(e),Pn())},In=e=>{if(!Nn)return;let t=Ue.find(t=>t.ordinal===e.ordinal-1);R.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});H.current={chooseBranch:Mn,followAnchor(){R.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,f.useCallback)(e=>H.current.show(e,`continue`),[]),zn=(0,f.useCallback)(e=>H.current.show(e,`edit`),[]),Bn=(0,f.useCallback)((e,t)=>H.current.stepVersion(e,t),[]),Vn=(0,f.useCallback)(e=>H.current.show(e,`show`),[]);(0,f.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(b(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=lc(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=lt?Ke?Q?M(`Discussing`):ut?ne(lt.status):Z?.proposal?M(`Awaiting plan approval`):``:lt.status===`completed`?``:ne(lt.status):``,Un=G||ge||!!ue||!!Q||B,Wn=e=>{if(!Un)try{F.add(e),ce()}catch(e){le(ne(e instanceof Error?e.message:`unavailable`))}},Gn=(0,f.useRef)(j);Gn.current=j;let Kn=(0,f.useMemo)(()=>({onShow:e=>H.current.show(e.id,`show`),onEdit:e=>H.current.show(e.id,`edit`),onContinue:e=>H.current.show(e.id,`continue`),onLatest:()=>H.current.chooseBranch(null)}),[]),{error:qn,loading:Jn,refresh:Yn}=Et,{pinned:Xn}=X;(0,f.useEffect)(()=>{Gn.current?.({id:t,tree:Dt,error:qn,loading:Jn,pinned:Xn,canAct:Nn,onRefresh:Yn,...Kn})},[t,Dt,qn,Jn,Xn,Nn,Yn,Kn]);let Zn=z!==null&&(Ue.some(e=>e.header.id===z.turnId)||kt.some(e=>e.id===z.turnId))?z:null,Qn=Zn?Qt.find(({turn:e})=>vc(Zn,e.ordinal))?.id:void 0,$n=Pt===null?kt.length-1:kt.findIndex(e=>e.id===Pt),er=(0,f.useCallback)(()=>{qt.current&&Gt.current&&(Gt.current.scrollTop=Gt.current.scrollHeight)},[]),tr=z?(0,h.jsxs)(`div`,{className:`composer-anchor`,children:[z.kind===`edit`?(0,h.jsx)(na,{"aria-hidden":`true`}):(0,h.jsx)(sa,{"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`composer-anchor-text`,role:`status`,children:[(0,h.jsx)(`strong`,{children:z.kind===`edit`?M(`Rewriting a message`):M(`Continuing after an earlier turn`)}),z.label&&(0,h.jsx)(`span`,{className:`composer-anchor-quote`,children:z.label}),(0,h.jsxs)(`span`,{children:[z.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.`)]}),B&&(0,h.jsx)(`span`,{children:M(`Reading the message's images…`)}),z.media&&(0,h.jsx)(`span`,{children:M(`Attachments that were not retained are not attached again.`)})]}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,title:M(`Cancel and restore the draft that was here`),disabled:G||!!ue,onClick:()=>{V(),Wt.current?.focus()},children:M(`Cancel`)})]}):Xn&&!Q?(0,h.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,h.jsx)(Xi,{"aria-hidden":`true`}),(0,h.jsx)(`div`,{className:`composer-anchor-text`,role:`status`,children:(0,h.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,h.jsxs)(`section`,{className:`chat-workspace`,hidden:O,"aria-label":M(Je?Ke?`Cadence conversation`:`Ordinary conversation`:`Conversation`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(Ri,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{children:lt?.title??(a?M(`Discovered session`):X.summary===null?M(`New conversation`):M(`Conversation`))})]}),(0,h.jsxs)(`div`,{className:`conversation-branch`,children:[(0,h.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,h.jsx)(`span`,{className:`conversation-badge`,children:M(`Archived`)}),te&&(X.branches>1||Xn)&&(0,h.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,h.jsx)(Xi,{"aria-hidden":`true`}),X.branches]}),Xn&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>Mn(null),children:M(`Show the latest`)}),_n&&(0,h.jsx)(`span`,{className:`ep-state running`,role:`status`,children:ne(ed(_n))}),lt&&Hn&&(!_n||ut||Ke&&!Q&&!!Z?.proposal)&&(0,h.jsx)(`span`,{className:`ep-state ${lt.status}`,children:Hn})]})]}),Ae.error&&!It&&(0,h.jsx)(`p`,{role:`alert`,className:`inspector-note`,children:b(M,Ae.error)}),It&&(0,h.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,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:M(`Preparing execution for this Send…`)}),(0,h.jsxs)(`div`,{className:`chat-messages-wrap`,children:[(0,h.jsxs)(`div`,{className:`chat-messages`,ref:Gt,onScroll:()=>{let e=Gt.current;e&&!O&&(Kt.current=e.scrollTop,qt.current=e.scrollHeight-e.scrollTop-e.clientHeight<80,Yt(!qt.current),nn(),an())},children:[a&&!X.summary&&(0,h.jsx)(`p`,{role:`status`,className:`panel-hint`,children:M(`Activity was discovered; session history is not yet readable. No transcript was created.`)}),!g&&(0,h.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,h.jsx)(Wu,{hint:M(`Type a message below. Turn on Cadence mode to agree on a plan before implementation.`)}),g&&!X.error&&(!We||Ue.length===0&&X.count>0)&&(0,h.jsx)(`p`,{className:`inspector-note chat-reading`,role:`status`,children:M(`Reading this conversation…`)}),Ue.length>0&&en&&(0,h.jsx)(`div`,{className:`chat-earlier`,role:`status`,children:X.loadingEarlier&&M(`Reading earlier messages…`)}),gn.start.map(yn),Qt.map(({id:e,version:t,turn:n},r)=>{let i=Ot.get(e);return(0,h.jsxs)(f.Fragment,{children:[e===Qn&&(0,h.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,h.jsx)(Xi,{"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,h.jsx)(Ls,{id:e,show:!$t.hidden.has(e)||e===Mt?.id,height:$t.placeholder(e,t,320),containerRef:Gt,onMeasured:$t.recordMeasured,lazyRef:$t.register(e),children:(0,h.jsx)(Uu,{turn:n,onContinue:Nn&&n.header.entry&&n.ordinal<X.count-1?Rn:void 0,onEdit:Nn&&gc(n,Qt[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:vc(Zn,n.ordinal)})}),gn.after.get(e)?.map(yn)]},e)}),gn.end.map(yn),X.attempt&&(0,h.jsxs)(`article`,{className:`chat-attempt`,"aria-label":M(`Message`),children:[(0,h.jsx)(`p`,{className:`chat-attempt-text`,children:X.attempt.text}),(0,h.jsxs)(`p`,{className:`inspector-note`,children:[(0,h.jsx)(`span`,{className:`ep-state ${X.attempt.status}`,children:ne(X.attempt.status)}),` `,X.attempt.notice?ne(X.attempt.notice):``]})]}),(0,h.jsx)(Xu,{pending:X.pending,undelivered:X.undelivered,canWithdraw:!!wn&&_&&!G,recallable:e=>Tn.current.has(e.commandId)||Cc(e.text),onWithdraw:(e,t)=>void kn(e,t),onRestore:An}),Xe&&(0,h.jsx)(`p`,{role:`status`,children:M(`Observing approval request {id}; no approval is replayed.`,{id:Xe})}),Z?.enabled&&Z.proposal&&(0,h.jsx)(ad,{proposal:Z.proposal,canApprove:!Rt&&l&&ct&&Je&&zt&&!Q&&!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&&cn.length===0&&(0,h.jsx)(`p`,{className:`inspector-note`,children:M(`Cadence stays on for this conversation until you explicitly exit.`)}),pn.failed&&(0,h.jsx)(`p`,{className:`inspector-note`,role:`status`,children:M(`Workflow activity unavailable; retained work may still be running.`)}),Z?.notice&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:ne(Z.notice)}),[...new Set([oe,X.error,Ge.error])].filter(Boolean).map(e=>(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:b(M,e??``)},e)),X.error&&X.summary!==void 0&&(0,h.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,h.jsxs)(`p`,{className:`inspector-note`,children:[M(`Send outcome not yet observed:`),` `,(0,h.jsx)(`code`,{children:ue}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:X.refresh,children:M(`Observe current state`)})]})]}),Jt&&(0,h.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{Gt.current&&(Gt.current.scrollTop=Gt.current.scrollHeight),qt.current=!0},children:[(0,h.jsx)(xa,{"aria-hidden":`true`}),M(`Latest messages`)]}),At&&(0,h.jsx)(`p`,{className:`chat-jump-status`,role:`status`,children:M(`Reading earlier messages…`)}),kt.length>1&&(0,h.jsx)(Ku,{questions:kt,active:$n,reading:At?.id??null,onJump:Vn})]}),(0,h.jsx)(Ql,{inputRef:Wt,draft:P,onDraft:re,locked:G||!!ue||ge,images:F.files,imageKey:F.key,imagesLocked:Un,onAddImages:Wn,onRemoveImage:e=>I([e]),anchor:tr,status:wn&&P.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.`):Q||It||ct||Ee?void 0:M(ue?`The last Send is not yet confirmed. No message is resent.`:ge?`Choose a model; your message is sent right after.`:G?`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:!!Q||G||!!ue||ge,onClick:()=>{Ke?Sn(`exit cadence`):st.mode===`cadence`?(W(`chat`),lo(P,`chat`).mode===`cadence`&&re(st.text)):W(`cadence`)}},model:{client:Pe,availability:Fe,read:Le,lastModel:je?.model,draftModel:Oe,onPreviewChoice:y?e=>Be(e,!1):void 0,locked:!!Q||G||!!ue,open:pe,onOpenChange:ze,onChanged:()=>{Ae.refresh(),C()},onChosen:e=>Be(e,!0),awaitingSend:ge},hint:wn&&Dn&&!En&&P.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:!!Q,canStop:!G&&_,onStop:()=>void jn(),canSend:((Ke&&al(P)?Lt:ct)||It)&&!B&&(!!P.trim()||F.files.length>0),onSend:()=>void Sn(),input:wn?{enabled:Dn&&!En&&!!P.trim(),onInput:e=>void On(e)}:void 0,historyScope:n,files:{client:e,location:g&&Me&&je?{id:t,cwd:je.cwd}:void 0},onResized:er})]})}function yd(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 bd(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=yd(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 xd=/[<>:"/\\|?*\u0000-\u001f]/g,Sd=/[. ]+$/,Cd=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function wd(e){let t=e.replace(xd,`_`).replace(Sd,``);return t?Cd.test(t)?`_${t}`:t:`_`}function Td(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 Ed(e,t){let n=/windows/i.test(navigator.userAgent)?wd(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return Td(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(Td(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Dd(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(`
|
|
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 Wu({label:e,children:t}){return(0,_.jsx)(`div`,{className:`msg-actions`,role:`group`,"aria-label":e,children:t})}function Gu({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 Ku({turn:e,parts:t}){let{t:n}=D(),{copied:r,copy:i}=Wo();return(0,_.jsx)(Gu,{icon:r?(0,_.jsx)(wa,{"aria-hidden":`true`}):(0,_.jsx)(ga,{"aria-hidden":`true`}),label:n(`Copy message`),done:r,onClick:()=>{let r=()=>rs(`error`,n(`Copy unavailable`)),a=e=>i(e).then(e=>{e||r()}),o=Uu(e,t,new AbortController().signal);typeof o==`string`?a(o):o.then(a,r)}})}var qu=(e,t)=>new Date(e).toLocaleTimeString(t===`zh`?`zh-CN`:`en-GB`,{hour:`2-digit`,minute:`2-digit`,hour12:!1}),Ju=(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}=Tu(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)(Gu,{icon:(0,_.jsx)(ha,{"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)(Gu,{icon:(0,_.jsx)(ua,{"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(`
|
|
23
|
+
`).filter(e=>e&&e!==`Hidden thinking, signatures and media are not retained.`),{execution:E}=u,O=h&&!f.some(({step:e})=>Cu(e)),k=u.at>0&&(0,_.jsx)(`time`,{className:`msg-time`,dateTime:new Date(u.at).toISOString(),children:qu(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)(Sa,{"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)(xa,{"aria-hidden":`true`})})]})]}),(0,_.jsx)(`div`,{className:`msg-body`,children:(0,_.jsx)(Mu,{turn:e,index:n,step:t,copy:!1})}),(l||f||p)&&(0,_.jsxs)(Wu,{label:s(`Message actions`),children:[f,l&&(0,_.jsx)(Ku,{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)(Fu,{turn:e,index:n,step:t},r):t.role===`thinking`?(0,_.jsx)(Iu,{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)(Mu,{turn:e,index:n,step:t,render:e=>(0,_.jsx)(Hu,{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)(Wu,{label:s(`Message actions`),children:[p.length>0&&(0,_.jsx)(Ku,{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(`
|
|
24
|
+
`)}),![`completed`,`running`,`queued`].includes(u.status)&&(0,_.jsx)(`p`,{className:`ep-state ${u.status}`,children:c(u.status)})]})});function Yu({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 Xu(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 Zu({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)(()=>Xu(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 Qu=[`queued`,`running`],$u=e=>Qu.includes(e.status);function ed(e){return e.diagnostics?.acceptedAt??e.steps.find(e=>e.timing)?.timing?.createdAt??null}function td(e){return e.status===`queued`?`queued`:e.phase===`research`?`researching`:e.phase}function nd(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=>ed(e)??2**53-1;for(let e of[...t].sort((e,t)=>s(e)-s(t))){let t=ed(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 rd(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?ed(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 id(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 ad({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=$u(t),p=f?oc(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(td(t)),p?ac(p,i):t.steps.filter(e=>e.status===`running`).map(e=>nc(e.id)).join(`, `)]:[a(t.status)]),b=f?``:v([t.mergedCommit?i(`merged {commit}`,{commit:t.mergedCommit.slice(0,7)}):``,id(t,i)]),x=f||t.status===`completed`?``:t.notice.split(`
|
|
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)(ja,{"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)(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 od({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)(ms,{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)(ms,{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)(ms,{text:Or(e.plan)})]}),e.delivery&&(0,_.jsx)(ms,{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 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)(ld,{...e},e.id)}function ld({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=vo(e,{kind:`workflow`,id:t},o),d=vo(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=vo(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)(fd,{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)(hd,{run:p,steps:h.steps,partial:(h.stepsBefore??0)>0||c!==void 0,onOpen:r&&(e=>r({runId:t,stepId:e.id,label:nc(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)(gd,{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)(ud,{steps:h.steps}),h?.steps.map(e=>(0,_.jsxs)(`details`,{className:`chat-tool`,children:[(0,_.jsx)(`summary`,{children:(0,_.jsx)(dd,{run:p??h,step:e})}),e.exitCode!==null&&(0,_.jsxs)(`p`,{children:[i(`Exit code`),`: `,e.exitCode]}),(0,_.jsx)(ms,{text:e.text}),e.childRunId&&r&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>r({runId:t,stepId:e.id,label:nc(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 ud({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 dd({run:e,step:t}){let{t:n,tx:r}=D();return(0,_.jsxs)(_.Fragment,{children:[`${r(t.kind)} · ${nc(t.id)} · ${r(t.status)}`,uc(e,t)&&(0,_.jsx)(`span`,{className:`workflow-set-aside`,children:n(`set aside by a recorded deviation`)})]})}function fd({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)(ja,{"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 pd({state:e}){return e===`running`?(0,_.jsx)(ju,{}):e===`completed`?(0,_.jsx)(Ta,{"aria-hidden":`true`}):e===`failed`?(0,_.jsx)(Oi,{"aria-hidden":`true`}):e===`superseded`?(0,_.jsx)(Ni,{"aria-hidden":`true`}):(0,_.jsx)(va,{"aria-hidden":`true`})}function md(e,t){return[t(`own worktree`),e.applied?t(`integrated`):``,e.state===`retained`?t(`kept for inspection`):``].filter(Boolean).join(` · `)}function hd({run:e,steps:t,partial:n=!1,onOpen:r}){let{t:i,tx:a}=D(),o=rc(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:ac(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:sc(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)(pd,{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:md(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 gd({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.`)})]})}function _d(e){if(e?.status!==`running`)return{kind:`waiting`};let t=e.activity;switch(t?.kind){case`thinking`:return{kind:`thinking`,state:`active`};case`text`:return{kind:`output`};case`tool`:return{kind:`tool`,name:t.name??``,state:`running`};default:return{kind:`waiting`}}}function vd({available:e,status:t,observed:n,readFailed:r}){return e?r||t===`unavailable`?`stale`:!n||t===`connecting`||t===`preparing`?`connecting`:t===`stopped`||t===`not-started`?`history`:`observing`:`paused`}function yd(e,t,n){let r=e.map(e=>t.get(e)).findLast(e=>e&&$u(e));if(r)return r;if(n&&e.includes(n.id)&&$u(n))return t.get(n.id)??n;let i=e.at(-1);return t.get(i??``)??(n?.id===i?n:void 0)}var bd={queued:`Reply queued`,running:`Reply running`,completed:`Reply ended`,failed:`Reply failed`,canceled:`Reply canceled`,timeout:`Reply timed out`,unknown:`Reply outcome unknown`},xd={observing:`Observing current state`,connecting:`Waiting for current observations`,stale:`Observation delayed · showing last known state`,paused:`Observation paused · showing last known state`,history:`History readable · live execution not connected`},Sd={running:`Tool running`,completed:`Tool result observed`,failed:`Tool failure observed`,canceled:`Tool cancellation observed`,unknown:`Tool outcome unknown`};function Cd({reply:e,workflow:t,connection:n,replyStale:r=!1,workflowStale:i=!1,activity:a}){let{t:o,tx:s}=D(),c=e===`running`,l=n!==`observing`,u=n===`stale`||n===`paused`,d=!!e||!!t,f=!d&&n===`stale`?`Observation unavailable · waiting for current state`:!d&&n===`paused`?`Observation paused`:xd[n],p=!a||a.kind===`waiting`?`Waiting · no new progress observed`:a.kind===`thinking`?a.state===`active`?`Thinking activity observed`:a.state===`ended`?`Thinking activity ended`:`Thinking content unavailable`:a.kind===`output`?`Reply output observed`:Sd[a.state];return(0,_.jsxs)(`div`,{className:`runtime-observation`,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"aria-label":o(`Runtime observation`),children:[e&&(0,_.jsxs)(`div`,{className:`runtime-observation-item`,"data-runtime":`reply`,children:[(0,_.jsx)(Na,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`runtime-observation-text`,children:[(0,_.jsx)(`span`,{children:o(bd[e])}),(r||l)&&(0,_.jsxs)(`span`,{className:`runtime-observation-stale`,children:[` `,`· `,o(`Last observed`)]}),c&&(0,_.jsxs)(`span`,{className:`runtime-observation-activity`,children:[(0,_.jsx)(`span`,{children:o(p)}),a?.kind===`tool`&&a.name&&(0,_.jsx)(`span`,{className:`runtime-observation-name`,title:a.name,children:a.name})]})]})]}),t!==void 0&&(0,_.jsxs)(`div`,{className:`runtime-observation-item`,"data-runtime":`workflow`,children:[(0,_.jsx)(ia,{"aria-hidden":`true`}),(0,_.jsxs)(`span`,{className:`runtime-observation-text`,children:[o(`Workflow`),`: `,t?s($u(t)&&t.phase!==`finished`?td(t):t.status):o(`Awaiting workflow observation`),t&&(i||l)&&(0,_.jsxs)(`span`,{className:`runtime-observation-stale`,children:[` `,`· `,o(`Last observed`)]})]})]}),(0,_.jsxs)(`div`,{className:`runtime-observation-item runtime-observation-connection${u?` runtime-observation-stale`:``}`,"data-runtime":`connection`,children:[(0,_.jsx)(zi,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{className:`runtime-observation-text`,children:o(f)})]})]})}var wd={"image/png":`png`,"image/jpeg":`jpg`,"image/webp":`webp`},Td=(e,t,n)=>new File([e],`image-${n+1}.${wd[t.mimeType]??`img`}`,{type:t.mimeType});function Ed({draftKey:e,draft:t,setDraft:n,images:r,alive:i,onUnread:a}){let[o,s]=(0,m.useState)(()=>{try{return Ac(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=Tu(e.steps).user[0],u={kind:n,entry:i,turnId:e.header.id,from:n===`edit`?e.ordinal:e.ordinal+1,label:Ec(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=Dc(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=Uu(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=>Td(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 Dd({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)(ma,{"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)(Di,{"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)(ma,{"aria-hidden":`true`}),o(`Put back in the message box`)]})]},e.commandId))]})}var Od=typeof CSS<`u`&&CSS.supports(`overflow-anchor`,`auto`);function kd(e){return e.scrollHeight-e.scrollTop-e.clientHeight<80}function Ad(e,t){t&&e&&(e.scrollTop=e.scrollHeight)}function jd(e,t=``){try{return sessionStorage.getItem(e)??t}catch{return t}}function Md({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)(()=>Qc(n,t,f,...p)),[re,ie]=(0,m.useState)(()=>jd(N,b?.text));(0,m.useEffect)(()=>{b&&x?.()},[b,x]);let P=eu(),ae=P.remove,F=(0,m.useRef)([]),I=(0,m.useRef)(!0),L=Ed({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)(()=>jd(`${N}:mode`)===`cadence`?`cadence`:`chat`),[W,G]=(0,m.useState)(!1),[K,q]=(0,m.useState)(``),se=`conversation:${t}`,ce=()=>{q(``),as(se)},le=e=>rs(`error`,e,se);(0,m.useEffect)(()=>()=>as(se),[se]);let[ue,Y]=(0,m.useState)(()=>jd(`${N}:pending`)),[de,fe]=(0,m.useState)(()=>jd(`${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=vo(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=>Ne?e.models(n,{id:t,cwd:Ne}):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=ml(Pe,Fe,`${be}:${je?.revision??`unobserved`}`,y),Re=()=>{Se.current=null,_e(!1),ye(!1)},ze=(e,t)=>{e&&!Le.preview&&!Le.loading?Le.reread():!e&&t!==`chosen`&&Re(),me(e)},Be=(e,t)=>{ke(t?null:e);let n=Se.current;he&&n&&(Jc(n,Ie.current)===`cancel`?(Re(),le(M(`The connection changed. Your model choice and draft are kept; send again when ready.`))):(Se.current=qc(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`&&fo()===t?mo(window.location.hash,t).leaf:i),X=fl(e,t,h,He),{turns:Ue}=X,We=X.summary!==void 0,Ge=vo(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)(()=>jd(`${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=yo(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:Cc({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=xc(e,t,X.leaf,[wt?.header.id??``,X.count,X.branches,Tt].join(),h&&!!lt),{tree:Dt}=Et,Ot=(0,m.useMemo)(()=>vc(Dt??{nodes:[],truncated:!1}),[Dt]),kt=(0,m.useMemo)(()=>{let e=yc(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=Tu(wt.steps).user[0]?.step.text??``;return[...e,{id:wt.header.id,text:Ec(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?hl(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)(()=>{Ad(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(``),Yc(ue,de)&&ke(null),fe(``),ae(F.current),ie(e=>e===Qt.current?``:e),Yc(ue,de)&&Tl(n,Qt.current),V.current.followAnchor(),w()),Ad(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=Gs(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;!Od&&!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=mc(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)=>rd(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)(()=>nd(Ue,mn.runs.values(),tn),[Ue,mn.runs,tn]),vn=(0,m.useRef)({client:e,id:t});(vn.current.client!==e||vn.current.id!==t)&&(vn.current={client:e,id:t});let yn=yd(pn,mn.runs,vn.current.run),bn=!!yn&&mn.runs.get(yn.id)!==yn;vn.current.run=yn;let xn=vd({available:h,status:v.status,observed:We,readFailed:!!X.error||!!Ge.error||mn.failed||mn.unreadable.size>0}),Sn=[...mn.runs.values()].map(e=>`${e.id}:${e.status}`).join();(0,m.useLayoutEffect)(()=>{Sn&&Ad(Gt.current,qt.current)},[Sn]);let Cn=t=>(0,_.jsx)(ad,{client:e,run:t,onOpen:()=>A?.({runId:t.id,stepId:null,label:t.goal}),onChanged:()=>{Ge.refresh(),w()}},t.id),wn=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 gl({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())}},Tn=async()=>{if(!Z?.proposal){le(M(`No plan is awaiting approval.`));return}if(Bt!==`approve`){await wn();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 _l({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=>yl(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())}},En=async(r,i)=>{let a=i?.text??r??re,o=i?.images??(r?[]:P.files),s=i?i.command.kind===`cadence-exit`:Ke&&vl(a);if(!(s?Lt:ct)&&!It||ut||z&&!i||!a.trim()&&!o.length||i&&(!ct||Jc(i,Ie.current)!==`ready`))return;if(s&&o.length){le(M(`Remove images before exiting Cadence.`));return}if(!o.length&&!i&&!r&&Ke&&yl(a)){await Tn();return}let c=yo(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(Bc(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 Lc(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??Hc({id:t,head:s?X.leaf:Oc(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?Uc(Le.catalog.selected):Le.catalog?.remembered??je?.model??Le.preview?.remembered??void 0),intent:s?`exit`:Ke?`message`:c?`enter`:`ordinary`});if(i){if(Jc(i,Ie.current)!==`ready`)throw Error(`stale`)}else await g(l.location);if(!d())return;if(l.command.kind===`cadence-exit`){let t=Zc(l);Qt.current=a,f=!0;let n=await Vc(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&&Jc(Kc(l,n),t)!==`cancel`?(Se.current=Kc(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=Wc(l,_)),l.installModel&&p.kind===`ok`){if(p={kind:`ok`,value:await Xc(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}Gc(l,p.value.selected);let y=Zc(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 nl(e,y,l.images,d),!d())return}F.current=l.images,Qt.current=a,f=!0;let b=await Vc(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||Tl(n,a),In(null)),Ge.refresh(),X.refresh(),w()}catch(e){if(d()){let t=e instanceof Error?e.message:`unavailable`,n=zc(e),r=M(f?Bc():Rc(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))}},Dn=(0,m.useRef)(En);Dn.current=En,(0,m.useEffect)(()=>{let e=Se.current;if(!e||!ve&&!he)return;let t=Jc(e,Fe);t===`cancel`?(Se.current=null,_e(!1),ye(!1),rs(`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,Dn.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 On=ut?lt?.live:void 0,kn=(0,m.useRef)(new Map),An=jc({images:P.files.length,modeChange:Ke?vl(re):st.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=Mc(t,On,r,i),o=Fc(await e.workbenchCommand(a));I.current&&(G(!1),o.kind===`accepted`?(kn.current.set(a.commandId,i),Tl(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=Fc(await e.workbenchCommand(Nc(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),Wt.current?.focus()},Fn=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())},In=(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),go(t,e)},Ln=!ut&&!W&&!ue&&!he,Rn=()=>{ce(),Wt.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)=>jt({id:e,then:t});V.current={chooseBranch:In,followAnchor(){L.current()&&In(null)},show:Vn,stepVersion:(e,t)=>{let n=Ot.get(e)??[],r=n[n.findIndex(t=>t.id===e)+t];r&&(In(r.leaf===lt?.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(!At)return;let e=Ue.find(e=>e.header.id===At.id);if(e){jt(null),At.then===`edit`?Bn(e):At.then===`continue`&&zn(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 In(n.leaf===lt?.leaf?null:n.leaf),jt({...At,switched:!0});let r=bc(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 Kn=W||he||!!ue||!!ut||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}=Et,{pinned:$n}=X;(0,m.useEffect)(()=>{Jn.current?.({id:t,tree:Dt,error:Xn,loading:Zn,pinned:$n,canAct:Ln,onRefresh:Qn,...Yn})},[t,Dt,Xn,Zn,$n,Ln,Qn,Yn]);let er=R!==null&&(Ue.some(e=>e.header.id===R.turnId)||kt.some(e=>e.id===R.turnId))?R:null,tr=er?$t.find(({turn:e})=>kc(er,e.ordinal))?.id:void 0,nr=Pt===null?kt.length-1:kt.findIndex(e=>e.id===Pt),rr=R?(0,_.jsxs)(`div`,{className:`composer-anchor`,children:[R.kind===`edit`?(0,_.jsx)(ua,{"aria-hidden":`true`}):(0,_.jsx)(ha,{"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`)})]}):$n&&!ut?(0,_.jsxs)(`div`,{className:`composer-anchor quiet`,children:[(0,_.jsx)(ia,{"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)(Ki,{"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||$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)(ia,{"aria-hidden":`true`}),X.branches]}),$n&&(0,_.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>In(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=kd(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)(Yu,{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(Cn),$t.map(({id:e,version:t,turn:n},r)=>{let i=Ot.get(e);return(0,_.jsxs)(m.Fragment,{children:[e===tr&&(0,_.jsxs)(`p`,{className:`chat-anchor-divider`,children:[(0,_.jsx)(ia,{"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)(Js,{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)(Ju,{turn:n,onContinue:Ln&&n.header.entry&&n.ordinal<X.count-1?Hn:void 0,onEdit:Ln&&Dc(n,$t[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:kc(er,n.ordinal)})}),_n.after.get(e)?.map(Cn)]},n.renderId??n.header.id)}),_n.end.map(Cn),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)(Dd,{pending:X.pending,undelivered:X.undelivered,canWithdraw:!!On&&g&&!W,recallable:e=>kn.current.has(e.commandId)||Pc(e.text),onWithdraw:(e,t)=>void Nn(e,t),onRestore:Pn}),Xe&&(0,_.jsx)(`p`,{role:`status`,children:M(`Observing approval request {id}; no approval is replayed.`,{id:Xe})}),Z?.enabled&&Z.proposal&&(0,_.jsx)(od,{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 wn(),onApprove:()=>void Tn()}),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,Ad(Gt.current,!0),Yt(!1)},children:[(0,_.jsx)(ka,{"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)(Zu,{questions:kt,active:nr,reading:At?.id??null,onJump:Gn})]}),(0,_.jsx)(Cd,{reply:lt?.status??X.attempt?.status,activity:_d(Q),workflow:pn.length?yn??null:void 0,connection:xn,replyStale:!!X.error,workflowStale:mn.failed||!!Ge.error||bn}),(0,_.jsx)(du,{inputRef:Wt,draft:re,onDraft:ie,locked:W||!!ue||he,images:P.files,imageKey:P.key,imagesLocked:Kn,onAddImages:qn,onRemoveImage:e=>ae([e]),anchor:rr,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.`):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?En(`exit cadence`):st.mode===`cadence`?(U(`chat`),yo(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:On&&jn&&!An&&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 Fn(),canSend:((Ke&&vl(re)?Lt:ct)||It)&&!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:Xt})]})}function Nd(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 Pd(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=Nd(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 Fd=/[<>:"/\\|?*\u0000-\u001f]/g,Id=/[. ]+$/,Ld=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Rd(e){let t=e.replace(Fd,`_`).replace(Id,``);return t?Ld.test(t)?`_${t}`:t:`_`}function zd(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 Bd(e,t){let n=/windows/i.test(navigator.userAgent)?Rd(t):t,r=window.showSaveFilePicker;if(!r||!window.isSecureContext)return zd(e,n),`handed`;let i;try{i=await r.call(window,{suggestedName:n})}catch(t){return t instanceof DOMException&&t.name===`AbortError`?`cancelled`:(zd(e,n),`handed`)}let a=await i.createWritable();return await a.write(e),await a.close(),`handed`}function Vd(e,t=`plaintext`){let n=0;for(let t of e.matchAll(/`+/g))n=Math.max(n,t[0].length);let r="`".repeat(Math.max(3,n+1));return`${r}${/^[a-z0-9+#-]+$/.test(t)&&t!==`plaintext`?t:``}\n${e}${e.endsWith(`
|
|
30
27
|
`)?``:`
|
|
31
|
-
`}${r}`}var
|
|
32
|
-
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function
|
|
33
|
-
`);return(0,
|
|
34
|
-
`):e})]}),(0,h.jsx)(`p`,{className:`fp-notice`,children:t(`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`)}),(0,h.jsx)(`div`,{style:{fontSize:`${o}em`},children:n===`markdown`?(0,h.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ld(c)&&(0,h.jsx)(`nav`,{className:`fp-toc`,"aria-label":t(`Page headings`),children:c.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>m.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,h.jsx)(`div`,{className:`fp-markdown-zoom`,ref:m,children:(0,h.jsx)(as,{text:e})})]}):n===`diff`?(0,h.jsx)(zd,{text:e}):(0,h.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Rd(e).map(({text:e,number:n,key:r})=>(0,h.jsxs)(`div`,{className:`fp-line ${u&&n>=u.start&&n<=u.end?`sel`:``}`,children:[(0,h.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":t(`Select page line {line}`,{line:n}),onClick:e=>{e.shiftKey||(p.current=n),d({start:Math.min(p.current,n),end:Math.max(p.current,n)})},children:n}),(0,h.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},r))})}),u&&(0,h.jsxs)(`footer`,{className:`fp-foot`,children:[t(`Selected page lines {start}–{end}`,{start:u.start,end:u.end}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>d(null),children:t(`Clear selection`)})]})]})}function Vd({client:e,seed:t}){let{t:n,tx:r}=T(),i=jo(e,t),[a,o]=(0,f.useState)(),s=i.page;return(0,h.jsxs)(`section`,{className:`scm-body`,children:[(0,h.jsx)(gs,{pager:i}),(0,h.jsx)(`p`,{children:n(`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`)}),(0,h.jsx)(`div`,{className:`scm-files-list`,children:s&&!(`kind`in s)&&s.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,i=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,h.jsxs)(`article`,{className:`scm-file`,children:[(0,h.jsxs)(`h3`,{children:[t.kind,` · `,n(`committed #{seq}`,{seq:e.committedSeq})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{s.request.scope.kind!==`workspace`&&s.request.snapshotSeq!==null&&o(ko(s.request.storeId,s.request.scope,s.request.snapshotSeq,i))},children:n(`Inspect full retained {field}`,{field:r(i.field)})})]},e.recordId)})}),a&&(0,h.jsx)(hs,{client:e,cursor:a,render:e=>(0,h.jsx)(Bd,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var Hd=[`contents`,`checks`,`changes`,`reviews`];function Ud({client:e,seed:t}){let{t:n,tx:r}=T(),[i,a]=(0,f.useState)(`contents`);return(0,h.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,h.jsx)(`p`,{className:`inspector-note`,children:n(`History is readonly. Start new work in a conversation with /cadence.`)}),(0,h.jsx)(`nav`,{className:`rp-tabs`,"aria-label":n(`Inspector`),children:Hd.map(e=>(0,h.jsx)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":i===e,onClick:()=>a(e),children:r(e)},e))}),(0,h.jsx)(`div`,{className:`inspector-body`,children:i===`contents`?(0,h.jsx)(_s,{client:e,seed:t}):(0,h.jsx)(Vd,{client:e,seed:{...t,reader:i}},i)})]})}var Wd={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.`},Gd=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function Kd(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}=T(),[u,d]=(0,f.useState)(),[p,m]=(0,f.useState)(n??t),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[x,S]=(0,f.useState)(!0),[C,w]=(0,f.useState)(!0),[E,D]=(0,f.useState)(!1),[O,k]=(0,f.useState)(null),ee=(0,f.useRef)(!0),A=(0,f.useRef)(void 0),j=(0,f.useRef)(n??t),te=(0,f.useRef)(null),M=(0,f.useRef)(null),ne=async t=>{A.current?.abort();let n=new AbortController;A.current=n,S(!0),k(null);let r=await e.workbenchRead({kind:`directories`,path:t},n.signal).catch(()=>void 0);if(!n.signal.aborted&&ee.current){if(A.current=void 0,S(!1),r?.kind===`ok`&&r.value.kind===`directories`)return d(r.value),m(r.value.path),_(!1),y(``),r.value;k({step:`read`,code:r?.kind===`error`?r.error.code:`unavailable`})}},N=(0,f.useRef)(ne);(0,f.useEffect)(()=>(ee.current=!0,N.current(j.current).then(()=>{ee.current&&w(!1)}),()=>{ee.current=!1,A.current?.abort()}),[]),(0,f.useEffect)(()=>{g&&te.current?.select()},[g]),(0,f.useEffect)(()=>{M.current&&(M.current.scrollLeft=M.current.scrollWidth)});let P=e=>{E||ne(e)},re=()=>{let e=p.trim();E||(Gd(e)?ne(e):k({step:`read`,code:`relative`}))},F=(g||!u)&&p.trim()||u?.path||``,ie=!E&&!x&&!!F,I=async n=>{if(E||!n||x&&n===u?.path)return;if(n!==u?.path&&!Gd(n)){k({step:`read`,code:`relative`});return}D(!0),k(null);let r=n===u?.path?u.path:(await ne(n))?.path;if(!ee.current)return;if(!r){D(!1);return}if(!o&&r===t){a();return}if(o){try{await o(r),ee.current&&a()}catch(e){ee.current&&(k({step:`open`,code:e instanceof Error?e.message:`unavailable`}),D(!1))}return}if(!e.workbenchCommand){k({step:`open`,code:`unavailable`}),D(!1);return}let s=await e.workbenchCommand({kind:`open-project`,commandId:crypto.randomUUID(),path:r,epoch:i});if(ee.current){if(s.kind===`ok`&&s.value.kind===`project`){let e=new URL(s.value.link);e.protocol===`http:`&&[`127.0.0.1`,`[::1]`].includes(e.hostname)||e.protocol===`https:`?window.location.assign(e.href):(k({step:`open`,code:`unsupported-context`}),D(!1))}else k({step:`open`,code:s.kind===`error`?s.error.code:`unavailable`}),D(!1)}},L=u?Kd(u.path,r):void 0,ae=v.trim().toLowerCase(),R=u?.entries.filter(e=>e.name.toLowerCase().includes(ae))??[],z=O&&(O.step===`read`&&Wd[O.code]?l(Wd[O.code]):b(l,O.code));return(0,h.jsxs)(xs,{title:l(c?`Choose working folder`:`Open working folder`),onClose:a,children:[(0,h.jsx)(`p`,{children:l(c?`Choose a folder on the service host. Conversations stay with their folder and running work continues. Nothing starts until you send.`:`Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.`)}),s.length>0&&(0,h.jsxs)(`section`,{className:`cwd-recent`,"aria-label":l(`Recent folders`),children:[(0,h.jsx)(`h3`,{children:l(`Recent folders`)}),(0,h.jsx)(`div`,{className:`cwd-recent-list`,children:s.map(e=>(0,h.jsxs)(`button`,{type:`button`,title:l(`Open {path}`,{path:e.path}),"aria-current":e.current?`true`:void 0,disabled:E,onClick:()=>e.current?a():void I(e.path),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:e.path})]},e.path))})]}),(0,h.jsxs)(`div`,{className:`cwd-location`,children:[L&&!g?(0,h.jsxs)(`nav`,{ref:M,className:`cwd-crumbs`,"aria-label":l(`Current location`),children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":l(`Home folder`),title:l(`Home folder (~)`),"aria-current":r&&u?.path===r?`location`:void 0,disabled:E,onClick:()=>P(`~`),children:[(0,h.jsx)(qi,{"aria-hidden":`true`}),L.inside&&(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`~`})]}),L.trail.map((e,t)=>(0,h.jsxs)(f.Fragment,{children:[(t>0||L.inside)&&(0,h.jsx)(pa,{"aria-hidden":`true`,className:`cwd-crumb-sep`}),(0,h.jsx)(`button`,{type:`button`,"aria-current":e.path===u?.path?`location`:void 0,disabled:E,onClick:()=>P(e.path),children:e.name})]},e.path))]}):C?(0,h.jsx)(`div`,{className:`cwd-crumbs`}):(0,h.jsx)(`form`,{className:`cwd-input`,onSubmit:e=>{e.preventDefault(),re()},children:(0,h.jsx)(`input`,{ref:te,"aria-label":l(`Folder path`),placeholder:l(`Type or paste a path, then press Enter`),value:p,disabled:E,spellCheck:!1,autoComplete:`off`,enterKeyHint:`go`,onChange:e=>{m(e.target.value),O?.step===`read`&&k(null)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),_(!1),m(u.path),k(null))}})}),u&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,"aria-label":l(`Edit path`),title:l(`Edit path`),"aria-pressed":g,disabled:E,onClick:()=>{m(u.path),_(!g),k(null)},children:(0,h.jsx)(na,{"aria-hidden":`true`})})]}),u&&(0,h.jsxs)(`label`,{className:`cwd-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{"aria-label":l(`Filter folders`),placeholder:l(`Filter this folder…`),value:v,disabled:E,spellCheck:!1,autoComplete:`off`,onChange:e=>y(e.target.value)})]}),(0,h.jsxs)(`div`,{className:`cwd-picker-list`,"aria-busy":x||void 0,children:[x&&(0,h.jsx)(`p`,{role:`status`,className:`cwd-picker-note`,children:l(`Reading folder…`)}),u?.parent&&(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(u.parent),children:[(0,h.jsx)(va,{}),l(`Parent folder`)]}),R.map(e=>(0,h.jsxs)(`button`,{type:`button`,disabled:E,onClick:()=>P(e.path),children:[(0,h.jsx)(Zi,{}),(0,h.jsx)(`span`,{children:e.name})]},e.path)),u&&!x&&R.length===0&&(0,h.jsx)(`p`,{className:`cwd-picker-note`,children:l(ae?`No matching folders.`:`No subfolders.`)})]}),u?.limited&&(0,h.jsx)(`p`,{className:`inspector-note`,children:l(`Bounded listing; narrow the directory to see more.`)}),z&&(0,h.jsxs)(`p`,{role:`alert`,children:[z,O?.code===`registry-locked`&&(0,h.jsxs)(h.Fragment,{children:[` `,`—`,` `,l(`Another Cadence process is updating the project registry. Try again in a moment; if this persists, run cadence doctor on the service host.`)]})]}),(0,h.jsxs)(`footer`,{className:`cwd-footer`,children:[F&&(0,h.jsxs)(`p`,{className:`cwd-target`,children:[(0,h.jsx)(`span`,{children:l(`Will open:`)}),` `,(0,h.jsx)(`code`,{children:F})]}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:!ie,onClick:()=>void I(F),children:l(E?c?`Selecting folder…`:`Opening folder…`:c?`Use this folder`:`Open this folder`)})]})]})}function Jd(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 Yd=[`today`,`yesterday`,`earlier`];function Xd(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 Zd(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=Xd(t(i),n);r.set(e,[...r.get(e)??[],i])}return Yd.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function Qd(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function $d(e,t,n=Date.now()){let r=new Date(e);return Xd(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 ef({onConversation:e,disabled:t=!1}){let{t:n}=T();return(0,h.jsx)(`div`,{className:`lp-new`,children:(0,h.jsxs)(`button`,{type:`button`,className:`new-conversation`,disabled:t||!e,onClick:e,children:[(0,h.jsx)(Mi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function tf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var nf=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),rf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function af(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 of={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},sf={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.`},cf={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.`},lf=e=>`conversation-row:${e}`;function uf(e,t){return t.kind===`refused`?{refusal:{text:sf[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function df(e,t){let{t:n}=T(),[r,i]=(0,f.useState)(()=>new Map),a=(0,f.useRef)(!0);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let o=(o,s)=>{let c=s.conversationId;if(r.get(c)?.pending)return;let l=e=>i(t=>{let n=new Map(t);return e?n.set(c,e):n.delete(c),n});Xo(lf(c)),l({pending:o}),af(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=uf(o,e);l(r),i&&Jo(`error`,n(i.text,{code:i.code}),lf(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,nf(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,rf(e,t))}}function ff({chat:e,selected:t,state:n=``,tone:r=``,onOpen:i,row:a,unavailable:o=``,onRename:s,onArchive:c}){let{t:l,locale:u}=T(),d=u===`zh`?`zh-CN`:`en-GB`,[p,m]=(0,f.useState)(null),g=p!==null,_=(0,f.useRef)(null),v=(0,f.useRef)(null),y=(0,f.useRef)(!1);(0,f.useEffect)(()=>{let e=_.current;if(!g||!e){y.current&&v.current?.focus({preventScroll:!0}),y.current=!1;return}e.focus({preventScroll:!0}),e.select();let t=e=>{e.key===`Escape`&&(e.stopPropagation(),y.current=!0,m(null))};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[g]);let b=e.origin===`terminal`?l(`Started in the terminal`):l(`Started in the WebUI`),x=(0,h.jsx)(`span`,{className:`session-icon`,role:`img`,"aria-label":b,title:b,children:e.origin===`terminal`?(0,h.jsx)(Ci,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),S=()=>{if(p===null)return;let t=tf(p);t===null?Jo(`error`,l(`A name can have at most {count} characters.`,{count:100}),lf(e.id)):(y.current=!0,m(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(of[a.pending]):a?.unknown?l(cf[a.unknown.action],{code:a.unknown.code}):``;return g?(0,h.jsxs)(`form`,{className:`conversation-row renaming`,onSubmit:e=>{e.preventDefault(),S()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||m(null)},children:[(0,h.jsxs)(`div`,{className:`session-item renaming${t?` active`:``}`,children:[x,(0,h.jsx)(`input`,{ref:_,className:`session-rename-input`,value:p,"aria-label":l(`Conversation name`),placeholder:l(`Empty: titled by its first message`),onChange:e=>m(e.target.value)})]}),(0,h.jsxs)(`span`,{className:`session-actions`,children:[(0,h.jsx)(`button`,{type:`submit`,className:`session-action`,title:l(`Save name`),"aria-label":l(`Save name`),onMouseDown:e=>e.preventDefault(),children:(0,h.jsx)(ga,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,title:l(`Keep the current name`),"aria-label":l(`Keep the current name`),onMouseDown:e=>e.preventDefault(),onClick:()=>{y.current=!0,m(null)},children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})]}):(0,h.jsxs)(`div`,{className:`conversation-row${c?` has-actions`:``}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${t?` active`:``}`,"aria-current":t?`true`:void 0,onClick:i,title:e.title,children:[x,(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.title}),n&&(0,h.jsx)(`span`,{className:`session-sub session-state ${r}`,children:n})]}),e.updatedAt>0&&(0,h.jsx)(`time`,{className:`session-time`,dateTime:new Date(e.updatedAt).toISOString(),title:new Date(e.updatedAt).toLocaleString(d),children:$d(e.updatedAt,d)})]}),c&&(0,h.jsxs)(`span`,{className:`session-actions`,children:[s&&(0,h.jsx)(`button`,{ref:v,type:`button`,className:`session-action`,disabled:C,title:o||l(`Rename`),"aria-label":l(`Rename {title}`,{title:e.title}),onClick:()=>m(e.title),children:(0,h.jsx)(na,{"aria-hidden":`true`})}),(0,h.jsx)(`button`,{type:`button`,className:`session-action`,disabled:C,title:o||l(e.archived?`Unarchive`:`Archive`),"aria-label":l(e.archived?`Unarchive {title}`:`Archive {title}`,{title:e.title}),onClick:()=>c(!e.archived),children:e.archived?(0,h.jsx)(Ai,{"aria-hidden":`true`}):(0,h.jsx)(Sa,{"aria-hidden":`true`})})]}),w&&(0,h.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function pf({list:e,unavailable:t,onBack:n,row:r}){let{t:i}=T(),a=e.value?.entries??[];return(0,h.jsxs)(`nav`,{"aria-label":i(`Archived conversations`),className:`task-list`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`ghost lp-back`,onClick:n,children:[(0,h.jsx)(ba,{"aria-hidden":`true`}),i(`Back to history`)]}),(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`Archiving only leaves a conversation out of the history. Its session file is not moved or deleted.`)}),t&&a.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:t}),e.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`panel-hint`,children:[i(`Archived conversations could not be read. This is not an empty list.`),` `,b(i,e.error)]}),e.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i(`Reading archived conversations…`)}),a.map(r),e.value&&!e.error&&a.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No archived conversations.`)}),e.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:e.previous,children:i(`Newer conversations`)}),e.value?.next&&(0,h.jsx)(`button`,{type:`button`,onClick:e.next,children:i(`Older conversations`)}),e.error&&(0,h.jsx)(`button`,{type:`button`,onClick:e.refresh,children:i(`Observe current state`)})]})}var mf={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function hf({title:e,children:t,className:n=``,count:r,actions:i}){let[a,o]=(0,f.useState)(!0);return(0,h.jsxs)(`section`,{className:`lp-section ${n}${a?``:` collapsed`}`,children:[(0,h.jsxs)(`header`,{className:`lp-section-header`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`lp-section-heading`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(ha,{"aria-hidden":`true`}):(0,h.jsx)(pa,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`lp-section-title`,children:e}),r&&(0,h.jsx)(`span`,{className:`lp-count`,children:r})]}),i&&(0,h.jsx)(`span`,{className:`lp-section-actions`,children:i})]}),(0,h.jsx)(`div`,{className:`lp-section-body`,hidden:!a,children:t})]})}function gf({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=T(),[o,s]=(0,f.useState)(new Set),c=Jd(e.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.childRunId?e.assignmentId??i(`Subagent`):a(e.admission.kind),active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),o);return(0,h.jsx)(`nav`,{className:`conversation-tree`,"aria-label":i(`Runs and assignments`),children:c.map(o=>{let c=e.find(e=>(e.childRunId??e.runId)===o.c.id),l=c?.childRunId?`child`:`run`,u=c?.outcome??c?.lifecycle??`unknown`,d=t?.kind===l&&t.id===o.c.id;return(0,h.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${o.depth*14}px`},children:[o.hasKids?(0,h.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":i(`Toggle assignments`),"aria-expanded":!o.isCollapsed,onClick:()=>s(e=>{let t=new Set(e);return t.has(o.c.id)?t.delete(o.c.id):t.add(o.c.id),t}),children:o.isCollapsed?(0,h.jsx)(pa,{"aria-hidden":`true`}):(0,h.jsx)(ha,{"aria-hidden":`true`})}):(0,h.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`button`,{type:`button`,className:`session-item${d?` active`:``}`,"aria-current":d?`true`:void 0,title:`${o.c.label} · ${o.c.id}`,onClick:()=>r({kind:l,id:o.c.id},n,o.c.label),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:l===`child`?(0,h.jsx)(aa,{"aria-hidden":`true`}):(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:o.c.label}),l===`child`&&(0,h.jsx)(`span`,{className:`session-sub`,children:i(`Subagent`)}),o.isCollapsed&&(0,h.jsx)(`span`,{className:`session-sub session-outcome`,children:`${i(`{count} descendants`,{count:o.descendantCount})}${o.hasFailure?i(` / failed child`):``}${o.hasUnknown?i(` / unknown child`):``}`})]}),(0,h.jsx)(`span`,{className:`ep-state ${u}`,children:a(u)})]})]},o.c.id)})})}function _f({pager:e,scope:t,onScope:n,exclude:r}){let{t:i}=T(),a=e.page;return(0,h.jsxs)(`div`,{className:`retained-conversations`,children:[a&&!(`kind`in a)&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(gf,{runs:a.records.flatMap(e=>e.kind===`run`&&!r.includes(e.projection.runId)?[e.projection]:[]),scope:t,snapshot:a.request.snapshotSeq??void 0,onScope:n}),a.records.length===0&&(0,h.jsx)(`p`,{className:`panel-hint`,children:i(`No retained conversations on this page.`)})]}),(0,h.jsx)(gs,{pager:e,compact:!0})]})}function vf({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:p,chats:m=[],chatActivityKnown:g=!0,chatHistoryPartial:_=!1,chatHistoryControls:v,conversationId:y,onConversation:b,onNewConversation:x,actionsUnavailable:S=``,onConversationsChanged:C,workflows:w,workflowLinks:E=[],workflowError:D=!1,discovery:O,selectedWorkflow:k,onWorkflow:ee,onCancelWorkflow:A}){let{t:j,tx:te}=T(),[M,ne]=(0,f.useState)(``),[N,P]=(0,f.useState)(!1),re=uo(e,N,!0),F=re.refresh,ie=df(e,e=>{F(),C?.(e)}),I=t?{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}:null,L=jo(e,I),ae=jo(e,r&&I&&t?{...I,reader:`runs`,scope:{kind:`task`,id:r},snapshotSeq:o??t.committedSeq}:null),R=L.page&&!(`kind`in L.page)?L.page.records.flatMap(e=>e.kind===`task`?[e]:[]):[],z=s?.status===`complete`?s.runs:[],B=R.filter(e=>!z.some(t=>t.taskId===e.owner.taskId)),V=r&&(0,h.jsxs)(`section`,{className:`task-conversations`,"aria-label":j(`Task conversations`),children:[(0,h.jsx)(`h3`,{children:j(`Task conversations`)}),(0,h.jsx)(_f,{pager:ae,scope:i,onScope:p,exclude:z.map(e=>e.runId)},r)]}),[H,U]=(0,f.useState)(()=>new Set),W=e=>{let t=E.find(t=>t.runId===e.id)?.conversationId??null;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${k===e.id||t&&t===y?` active`:``}`,onClick:()=>ee?.(e,t),title:e.goal,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[j(`Cadence workflow`),` · `,te(e.phase),` · `,te(e.status)]})]})]}),A&&(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:H.has(e.id),onClick:()=>{U(t=>new Set(t).add(e.id)),A(e).finally(()=>U(t=>{let n=new Set(t);return n.delete(e.id),n}))},children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel workflow — request stop`)]})]},e.id)},G=m.filter(e=>e.status===`running`||e.status===`queued`),K=m.filter(e=>!G.includes(e)),oe=e=>w?.findLast(t=>E.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`?oe(e):void 0,r=n?te(ed(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,h.jsx)(ff,{chat:e,selected:e.id===y,state:r,tone:n?`running`:e.status,onOpen:()=>b?.(e.id),row:ie.states.get(e.id),unavailable:S,onArchive:t?void 0:t=>ie.archive(e.id,t),onRename:t||e.archived?void 0:t=>ie.rename(e.id,t)},e.id)},se=K.filter(e=>Qd(e.title,M)),J=B.filter(e=>Qd(e.goal,M));return(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,h.jsx)(Ws,{...O,represented:!n&&O.project?[...(w??[]).map(e=>Us(O.project,`workflow`,e.id,e.epoch)),...G.flatMap(e=>e.live?[Us(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,h.jsx)(ef,{onConversation:x}),!n&&(0,h.jsxs)(hf,{title:j(`Running work`),count:s?.status===`complete`&&w&&!D&&g?String(z.length+G.length+w.length):j(`Not observed`),className:`running-conversations`,children:[s?.status!==`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Active roster unavailable; absence is not proof of settlement.`)}),D&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Workflow activity unavailable; retained work may still be running.`)}),!g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`Conversation activity unavailable.`)}),G.map(q),w?.map(W),s?.status===`complete`&&z.length===0&&G.length===0&&w?.length===0&&!D&&g&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No active runs`)}),z.map(e=>{let t=R.find(t=>t.owner.taskId===e.taskId)?.goal;return(0,h.jsxs)(`div`,{className:`conversation-group`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${r===e.taskId&&i?.kind===`task`?` active`:``}`,onClick:()=>d(e.taskId,t),title:e.runId,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:t??j(`Task {id}`,{id:e.taskId.slice(0,8)})}),(0,h.jsxs)(`span`,{className:`session-sub`,children:[te(e.kind),` · `,te(e.stage)]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`conversation-stop`,disabled:!c||l.has(e.runId),onClick:()=>u(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),j(`Cancel run — request stop`)]}),r===e.taskId&&(0,h.jsx)(gf,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:p})]},e.runId)})]}),(0,h.jsxs)(hf,{title:j(N?`Archived conversations`:`Conversation history`),count:N?re.value?`${re.value.entries.length}${re.value.next||re.canPrevious?`+`:``}`:j(`Not observed`):t?L.page&&!(`kind`in L.page)?`${K.length+B.length}${L.page.next||L.canPrevious||_?`+`:``}`:j(`Not observed`):`${K.length}${_?`+`:``}`,className:`grow`,actions:(0,h.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:()=>P(e=>!e),children:(0,h.jsx)(Sa,{"aria-hidden":`true`})}),children:[N&&(0,h.jsx)(pf,{list:re,unavailable:S,onBack:()=>P(!1),row:q}),(0,h.jsxs)(`nav`,{"aria-label":j(`Tasks`),className:`task-list`,hidden:N,children:[(K.length>0||B.length>0)&&(0,h.jsxs)(`label`,{className:`lp-filter`,children:[(0,h.jsx)(ki,{"aria-hidden":`true`}),(0,h.jsx)(`input`,{type:`search`,value:M,placeholder:j(`Filter conversations…`),"aria-label":j(`Filter conversations…`),onChange:e=>ne(e.target.value)}),M&&(0,h.jsx)(`button`,{type:`button`,className:`lp-filter-clear`,title:j(`Clear filter`),"aria-label":j(`Clear filter`),onClick:()=>ne(``),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]}),S&&K.length>0&&(0,h.jsx)(`p`,{className:`panel-hint lp-actions-hint`,children:S}),Zd(se,e=>e.updatedAt).map(e=>(0,h.jsxs)(`div`,{className:`lp-time-group`,children:[(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(mf[e.key])}),e.items.map(q)]},e.key)),J.length>0&&(0,h.jsx)(`h3`,{className:`lp-time-label`,children:j(`Tasks`)}),J.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===r&&i?.kind===`task`?` active`:``}`,"aria-current":e.owner.taskId===r&&i?.kind===`task`?`true`:void 0,title:e.goal,onClick:()=>d(e.owner.taskId,e.goal),children:[(0,h.jsx)(`span`,{className:`session-icon`,children:(0,h.jsx)(Ri,{"aria-hidden":`true`})}),(0,h.jsxs)(`span`,{className:`session-info`,children:[(0,h.jsx)(`span`,{className:`session-title`,children:e.goal}),(0,h.jsx)(`span`,{className:`session-sub`,children:j(`Task {id}`,{id:e.owner.taskId.slice(0,8)})})]})]}),e.owner.taskId===r&&V]},e.owner.taskId)),se.length===0&&J.length===0&&(K.length>0||B.length>0)&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:j(`No listed conversation matches. Pages not loaded are not searched.`)}),L.page&&!(`kind`in L.page)&&B.length===0&&K.length===0&&!_&&(0,h.jsx)(`p`,{className:`panel-hint`,children:j(`No conversations yet.`)}),v,t&&(0,h.jsx)(gs,{pager:L,compact:!0})]}),!N&&!J.some(e=>e.owner.taskId===r)&&V]})]})}var yf=[`queued`,`running`];function bf({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=T(),[s,c]=(0,f.useState)(1e3),l=co(e,{kind:`workflow`,id:t.runId},s),u=l.value?.kind===`workflow`&&l.value.response.type===`run`?l.value.response.run:null,d=t.stepId?u?.steps.find(e=>e.id===t.stepId):void 0,p=d?yf.includes(d.status):!1;(0,f.useEffect)(()=>{u&&!yf.includes(u.status)&&c(0)},[u]);let m=co(e,t.stepId&&(!u||d?.childRunId)?{kind:`workflow-transcript`,id:t.runId,stepId:t.stepId}:null,p||!u?1e3:0),g=m.value?.kind===`workflow-transcript`?m.value.turn:null,_=(0,f.useMemo)(()=>g?$l(g):null,[g]),[v,y]=(0,f.useState)(!1),b=co(e,v&&t.stepId?{kind:`workflow-detail`,id:t.runId,stepId:t.stepId}:null),x=(0,f.useRef)(null),S=(0,f.useRef)(!0),C=_?.steps.length??0;return(0,f.useEffect)(()=>{C&&S.current&&x.current&&(x.current.scrollTop=x.current.scrollHeight)},[C]),(0,h.jsxs)(`section`,{className:`chat-workspace workflow-agent`,"aria-label":a(`Subagent context`),children:[(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:r,children:n}),(0,h.jsx)(aa,{"aria-hidden":`true`}),(0,h.jsx)(`h2`,{title:t.stepId??t.runId,children:d?`${o(d.kind)} · ${t.label}`:t.label}),(0,h.jsx)(`span`,{className:`conversation-badge`,children:t.stepId?a(`Subagent`):a(`Workflow`)})]}),(d??u)&&(0,h.jsx)(`span`,{className:`ep-state ${(d??u)?.status}`,children:o((d??u)?.status??``)})]}),(0,h.jsxs)(`div`,{className:`chat-messages`,ref:x,onScroll:e=>{let t=e.currentTarget;S.current=t.scrollHeight-t.scrollTop-t.clientHeight<80},children:[l.error&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[l.error,` ·`,` `,a(`State unavailable is not completion. No automatic resubmission.`)]}),u&&t.stepId&&(0,h.jsxs)(`p`,{className:`inspector-note workflow-agent-goal`,children:[a(`Workflow`),`: `,u.goal,` · `,o(u.phase),` · `,o(u.status)]}),!t.stepId&&(0,h.jsx)(sd,{client:e,id:t.runId,onOpenAgent:i}),t.stepId&&m.error&&(0,h.jsx)(`p`,{role:`alert`,children:m.error}),t.stepId&&(_?(0,h.jsx)(Uu,{turn:_}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No retained transcript observed yet; absence is not proof of no activity.`)})),d&&(0,h.jsxs)(`section`,{className:`workflow-agent-result`,"aria-label":a(`Step result`),children:[(0,h.jsx)(`h3`,{children:a(`Step result`)}),d.exitCode!==null&&(0,h.jsxs)(`p`,{children:[a(`Exit code`),`: `,d.exitCode]}),d.text?(0,h.jsx)(as,{text:d.text}):(0,h.jsx)(`p`,{className:`inspector-note`,children:a(`No result yet.`)}),d.truncated&&(0,h.jsx)(`p`,{children:a(`Preview is truncated.`)}),(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>y(!0),children:a(`Read retained step result`)}),v&&b.value?.kind===`file`&&(0,h.jsx)(`pre`,{className:`workflow-detail`,children:b.value.text}),v&&b.error&&(0,h.jsx)(`p`,{role:`alert`,children:b.error})]})]})]})}function xf({path:e,disabled:t=!1,onClick:n}){let{t:r}=T(),i=e?.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;return(0,h.jsxs)(`button`,{type:`button`,className:`status-cwd`,title:e||r(`Choose working folder`),"aria-label":r(`Switch working folder`),disabled:t,onClick:n,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Sf({error:e,observationError:t,projectObservationError:n,unavailable:r=!1,onRefresh:i}){let{t:a}=T(),o=r||t||n;return!e&&!o?null:(0,h.jsxs)(h.Fragment,{children:[e&&(0,h.jsx)(`p`,{className:`banner-notice`,role:`alert`,children:e}),o&&(0,h.jsxs)(`section`,{className:`workspace-notice`,"aria-label":a(`Observation status`),children:[(0,h.jsxs)(`div`,{className:`workspace-notice-summary`,children:[(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`strong`,{children:a(`Latest state unavailable.`)}),` `,a(`Started work may still be running. No message is resent.`)]}),i&&(0,h.jsx)(`button`,{type:`button`,onClick:i,children:a(`Observe current state`)})]}),(t||n)&&(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:a(`Diagnostic details`)}),n&&(0,h.jsx)(`p`,{children:a(`Project observation: {code}.`,{code:n})}),t&&(0,h.jsx)(`p`,{children:a(`Viewer observation: {code}.`,{code:t})}),(t===`stale`||n===`stale`)&&(0,h.jsx)(`p`,{children:a(`Context changed. Read the current state before confirming a plan.`)})]})]})]})}function Cf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=to();i&&r.searchParams.set(`project`,i);let a=new URLSearchParams({task:G(e)});if(n&&(a.set(`scope`,JSON.stringify(Le(n.scope))),n.snapshotSeq&&a.set(`snapshot`,oe(n.snapshotSeq))),t){let{navigation:e,...n}=t;a.set(`detail`,JSON.stringify(n))}return r.hash=a.toString(),r.href}function wf(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=G(e.get(`task`)),n=e.get(`detail`),r=e.get(`scope`),i=e.get(`snapshot`),a=r?Le(ce(r)):void 0,o=i?oe(i):void 0;if(a?.kind===`task`&&a.id!==t||o&&!a)return null;if(!n)return{taskId:t,scope:a,snapshotSeq:o};let s=ze(ce(n));return s.navigation?null:{taskId:t,cursor:s,scope:a,snapshotSeq:o}}catch{return null}}var Tf=`cadence-panel-layout-v1`,Ef={left:260,right:360,navigation:!0,inspector:!1};function Df(e,t=600){return Math.max(220,Math.min(t,e))}function Of(e){let t={...Ef};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]=Df(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function kf(e,t){let n=e<=900,r=Df(t.left,e-560),i=Df(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:Df(e-560-s),rightMaximum:Df(e-560-a)}}function Af({side:e,width:t,onResize:n,maximum:r}){let{t:i}=T(),a=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>a.current?.(),[]),(0,h.jsx)(`input`,{type:`range`,min:220,max:r,step:1,value:t,onChange:e=>n(Df(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(Df(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Df(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 jf=[],Mf={error:wa,warning:Ca,info:Gi};function Nf({toast:e}){let{t}=T(),[n,r]=(0,f.useState)(!1),[i,a]=(0,f.useState)(!1),o=n||i,s=Vo(e.level);(0,f.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>Yo(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=Mf[e.level];return(0,h.jsxs)(`div`,{className:`notice notice-${e.level}${o?` paused`:``}`,role:e.level===`error`?`alert`:`status`,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1),children:[(0,h.jsx)(c,{className:`notice-icon`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`notice-text`,children:e.text}),(0,h.jsx)(`button`,{type:`button`,className:`notice-close`,title:t(`Dismiss notification`),"aria-label":t(`Dismiss notification`),onClick:()=>Yo(e.id),children:(0,h.jsx)(bi,{"aria-hidden":`true`})})]})}function Pf(){let e=(0,f.useSyncExternalStore)(Zo,Qo,()=>jf);return(0,h.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,h.jsx)(Nf,{toast:e},e.id))})}function Ff(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus({preventScroll:!0});let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus({preventScroll:!0})):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus({preventScroll:!0}))}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus({preventScroll:!0})}},[e,t,n,r])}var If=.4,Lf=1.05;function Rf(e){return Math.min(300,e*.86)}function zf(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function Bf(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Vf(e,t){return e===`left`?t:-t}function Hf(e,t){return Math.max(-e,Math.min(0,-e+t))}function Uf(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Wf(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Uf(r*Lf,n,t)>=If}var Gf=new Set([`auto`,`scroll`,`overlay`]);function Kf(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Gf.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function qf(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function Jf(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=zf(r.clientX,window.innerWidth,n);i&&!Kf(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=Bf(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Rf(window.innerWidth),h=m*Lf;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=Vf(r,d);let b=Hf(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Uf(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Wf({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(qf(),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 Yf={system:[Fi,`System`],light:[wi,`Light`],dark:[Pi,`Dark`]};function Xf({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:p,content:m}){let{t:g,locale:_,setLocale:v}=T(),[y,b]=(0,f.useState)(j),[S,C]=Yf[y],w=g(`Theme: {current}. Switch to {next}.`,{current:g(C),next:g(Yf[M(y)][1])}),{mobile:E,overlay:D,closeDrawer:O}=e,k=(0,f.useRef)(null),ee=(0,f.useRef)(null),A=()=>{ee.current&&(ee.current.open=!1)};return Jf({enabled:E,open:D,onOpenChange:e.setDrawer,container:k}),Ff(k,D,!!D,O),(0,h.jsxs)(`div`,{className:`app${e.className} antialiased`,children:[(0,h.jsxs)(`header`,{className:`topbar`,children:[(0,h.jsx)(`button`,{type:`button`,className:`panel-toggle navigation-toggle`,"aria-label":g(`Toggle conversation navigation`),"aria-expanded":E?D===`left`:e.navigation,onClick:()=>e.toggle(`left`),children:(0,h.jsx)(zi,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`topbar-flow`,children:[(0,h.jsxs)(`span`,{className:`brand`,children:[(0,h.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),a,(0,h.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,h.jsxs)(`div`,{className:`tb-actions`,children:[o,(0,h.jsxs)(`button`,{type:`button`,className:`chip chip-lang`,lang:_===`zh`?`en`:`zh-CN`,"aria-label":_===`zh`?`Switch to English`:`切换到中文`,"data-tip":_===`zh`?`Switch to English`:`切换到中文`,onClick:()=>v(_===`zh`?`en`:`zh`),children:[(0,h.jsx)(Yi,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:_===`zh`?`EN`:`中文`})]}),(0,h.jsx)(`button`,{type:`button`,className:`chip chip-theme`,"aria-label":w,"data-tip":w,onClick:()=>{let e=M(y);te(e),b(e)},children:(0,h.jsx)(S,{"aria-hidden":`true`})}),(0,h.jsxs)(`details`,{className:`more-menu`,ref:ee,onKeyDown:e=>{e.key===`Escape`&&ee.current&&(ee.current.open=!1,ee.current.querySelector(`summary`)?.focus())},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||(e.currentTarget.open=!1)},children:[(0,h.jsx)(`summary`,{className:`chip`,"aria-label":g(`More`),title:g(`More`),children:(0,h.jsx)(Ni,{"aria-hidden":`true`})}),(0,h.jsxs)(`div`,{className:`more-menu-items`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Observe current state`),onClick:()=>{A(),u()},children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),g(`Refresh status`)]}),p&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Cadence service`),onClick:()=>{A(),p()},children:[(0,h.jsx)(Oi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Cadence service`),(0,h.jsx)(`small`,{children:g(`Version, restart and upgrade.`)})]})]}),d&&(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Disconnect this page`),title:g(`Return — accepted work continues`),onClick:()=>{A(),O(),d()},children:[(0,h.jsx)(Vi,{"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`more-menu-text`,children:[g(`Disconnect this page`),(0,h.jsx)(`small`,{children:g(`Started work keeps running.`)})]})]}),(0,h.jsx)(`div`,{className:`more-menu-build`,title:Ha?.buildId??g(`unbuilt source`),children:(0,h.jsx)(x,{text:g(`Local browser build: {build}.`),slots:{build:(0,h.jsx)(`code`,{children:Ha?.buildId??g(`unbuilt source`)})}})})]})]})]})]}),(0,h.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label inspector-toggle`,"aria-label":g(`Toggle workspace panels`),"aria-expanded":E?D===`right`:e.inspector,onClick:()=>e.toggle(`right`),children:[(0,h.jsx)(Di,{"aria-hidden":`true`}),(0,h.jsx)(`span`,{children:r??g(`Files`)})]})]}),s,(0,h.jsxs)(`div`,{ref:k,className:`layout`,style:{"--left-w":`${e.left}px`,"--right-w":`${e.right}px`},children:[(0,h.jsx)(`button`,{type:`button`,"aria-label":g(`Close drawer`),tabIndex:-1,className:`drawer-backdrop persistent${D?` on`:``}`,onClick:O}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-left${D===`left`?` open`:``}`,"aria-label":g(`Conversation navigation`),tabIndex:-1,inert:E?D!==`left`:!e.navigation||D===`right`,children:t}),(0,h.jsx)(Af,{side:`left`,width:e.left,maximum:e.leftMaximum,onResize:t=>e.resize(`left`,t)}),(0,h.jsx)(`main`,{className:`main`,inert:D!==null,children:m}),(0,h.jsx)(Af,{side:`right`,width:e.right,maximum:e.rightMaximum,onResize:t=>e.resize(`right`,t)}),(0,h.jsx)(`section`,{className:`panel-drawer drawer-right${D===`right`?` open`:``}`,"aria-label":g(`Files and history drawer`),tabIndex:-1,inert:E?D!==`right`:!e.inspector,children:(0,h.jsxs)(`div`,{className:`workbench-right`,children:[(0,h.jsxs)(`nav`,{className:`rp-tabs`,"aria-label":g(`Workspace panels`),children:[i??(0,h.jsxs)(`span`,{className:`rp-tab`,"aria-current":`true`,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),(0,h.jsx)(`button`,{type:`button`,className:`panel-collapse-btn`,"aria-label":g(`Collapse panel`),title:g(`Collapse panel`),onClick:()=>e.toggle(`right`),children:(0,h.jsx)(pa,{"aria-hidden":`true`})})]}),n]})})]}),(0,h.jsxs)(`footer`,{className:`statusbar`,children:[(0,h.jsx)(`div`,{className:`statusbar-left`,children:c}),(0,h.jsx)(`div`,{className:`statusbar-right`,children:l})]}),(0,h.jsx)(Pf,{})]})}function Zf(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 Qf({cache:e}){let{t}=T(),n=e?Zf(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,h.jsxs)(`span`,{className:`status-item status-cache${r?``:` is-zero`}`,title:o,children:[(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:(0,h.jsx)(ia,{})}),(0,h.jsxs)(`span`,{className:`bar-item-text`,children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[t(`Cache hit`),` `]}),(0,h.jsx)(`b`,{className:`cache-pct${a}`,children:i})]})]})}var $f=31.42;function ep({usage:e}){let{t}=T(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?mc(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,h.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,h.jsx)(`circle`,{className:`ctx-ring-bg`,cx:`7`,cy:`7`,r:`5`}),i!==null&&i>0&&(0,h.jsx)(`circle`,{className:`ctx-ring-fill`,cx:`7`,cy:`7`,r:`5`,strokeDasharray:$f,strokeDashoffset:+($f*(1-Math.min(i,100)/100)).toFixed(2)})]});return(0,h.jsxs)(`span`,{className:`status-item status-ctx${n===null?` is-zero`:``}`,title:`${a}. ${o}`,children:[n!==null&&r?(0,h.jsx)(`span`,{className:`ctx-meter`,role:`meter`,"aria-label":t(`Context window in use`),"aria-valuemin":0,"aria-valuemax":r,"aria-valuenow":Math.min(n,r),"aria-valuetext":a,children:s}):s,(0,h.jsx)(`span`,{className:`bar-item-text`,children:n===null?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`span`,{className:`visually-hidden`,children:[a,` `]}),(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`—`})]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`ctx-val`,children:pc(n)}),r&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,h.jsx)(`span`,{className:`ctx-max`,children:pc(r)})]})]})})]})}function tp({icon:e,dot:t,tone:n,tip:r,role:i,children:a}){return(0,h.jsxs)(`span`,{className:`status-item${n?` ${n}`:``}`,title:r,role:i,children:[t!==void 0&&(0,h.jsx)(`span`,{className:`status-dot ${t}`,"aria-hidden":`true`}),e&&(0,h.jsx)(`span`,{className:`bar-item-icon`,"aria-hidden":`true`,children:e}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:a})]})}function np({dot:e,tip:t,latency:n,children:r}){let{t:i}=T(),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,h.jsxs)(`span`,{className:`status-item status-conn`,title:a,children:[(0,h.jsx)(`span`,{className:`status-dot ${e}`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,role:`status`,children:r}),n!==null&&(0,h.jsxs)(`span`,{className:`status-latency ${n<100?`ok`:n<300?`mid`:`warn`}`,children:[n,`ms`]})]})}function rp(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 ip({since:e,label:t}){let[n,r]=(0,f.useState)(Date.now);(0,f.useEffect)(()=>{if(!e)return;r(Date.now());let t=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(t)},[e]);let i=e?rp(n-e):``;return(0,h.jsxs)(`span`,{className:`status-item working`,title:i?`${t} · ${i}`:t,children:[(0,h.jsx)(`span`,{className:`working-spin`,"aria-hidden":`true`}),(0,h.jsx)(`span`,{className:`bar-item-text`,children:t}),i&&(0,h.jsx)(`span`,{className:`bar-item-duration`,children:i})]})}function ap(){let[e,t]=(0,f.useState)(()=>{try{return Of(localStorage.getItem(Tf))}catch{return Of(null)}}),[n,r]=(0,f.useState)(()=>typeof window>`u`?1440:window.innerWidth??1440),[i,a]=(0,f.useState)(null);(0,f.useEffect)(()=>{let e=()=>r(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let o=kf(n,e),s=(0,f.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Tf,JSON.stringify(r))}catch{}},[e]),c=o.mobile?i:o.rightOverlay&&e.inspector?`right`:null,l=(0,f.useCallback)(()=>{a(null),!o.mobile&&o.rightOverlay&&s({inspector:!1})},[o.mobile,o.rightOverlay,s]);return{...o,overlay:c,closeDrawer:l,setDrawer:a,navigation:e.navigation,inspector:e.inspector,className:`${e.navigation?``:` navigation-hidden`}${e.inspector?``:` inspector-hidden`}${o.rightOverlay?` inspector-overlay`:``}`,toggle(t){o.mobile?a(e=>e===t?null:t):s(t===`left`?{navigation:!e.navigation}:{inspector:!e.inspector})},resize(e,t){s({[e]:t})}}}function op(e,t,n,r,i=`en`){let a=(e,t)=>v(i,e,t),o=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),s=o.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,o=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:o,group:`${r??`owner`}:${o}`,groupLabel:`${r??a(`Owner`)} · ${v(i,o)}`,kind:o===`tools`?`tool`:o===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:a(`Committed #{seq}; {who}`,{seq:e.committedSeq,who:r??a(`owner`)}),status:a(`recorded fact`),clock:e.kind===`capture-fact`?a(`Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.`,{child:e.link.childRunId,first:e.capture.source.firstObservedMs,last:e.capture.source.lastObservedMs}):a(`Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.`,{epoch:e.link.epoch,ms:e.observedMs}),...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),c;return{lang:i,onData(e){return c=e,()=>{c=void 0}},readState(){c?.({kind:`state`,conversations:[{id:e,title:a(`{scope} — loaded committed page`,{scope:e}),isStreaming:!1,segCount:s.length}],activeId:e})},readSegments(t){t===e&&c?.({kind:`segs`,convId:t,segs:s,reset:!0})},readSegment(t,n){let r=s.findIndex(e=>e.key===n);t!==e||r<0||c?.({kind:`seg_detail`,convId:t,key:n,seg:s[r],detail:JSON.stringify(o[r],null,2),analysis:{position:a(`Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.`,{seq:o[r].committedSeq,ordinal:r+1})}})},openDetail(t,r){let i=o.find(e=>e.recordId===r);t===e&&i&&n(i)},searchHistory:r}}var sp=`modulepreload`,cp=function(e){return`/`+e},lp={},up=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=cp(t,n),t=s(t),t in lp)return;lp[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`:sp,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 dp({client:e,seed:t,onSearch:n}){let{t:r}=T(),i=jo(e,{...t,reader:`events`}),a=i.page;return(0,h.jsxs)(`section`,{className:`timeline-view`,children:[(0,h.jsx)(`p`,{children:r(`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`)}),(0,h.jsx)(gs,{pager:i}),a&&!(`kind`in a)&&(0,h.jsx)(fp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function fp({client:e,seed:t,records:n,onSearch:r}){let{t:i,locale:a}=T(),o=(0,f.useRef)(null),[s,c]=(0,f.useState)(!1),[l,u]=(0,f.useState)(!1),d=(0,f.useRef)(r);return d.current=r,(0,f.useEffect)(()=>{let e=!1,r;return up(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,op(t.scope.id,n,()=>c(!0),()=>d.current(),a)))}),[]).catch(()=>{e||u(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id,a]),(0,h.jsxs)(h.Fragment,{children:[l&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`)}),(0,h.jsx)(`div`,{className:`timeline-mount`,ref:o}),s&&(0,h.jsx)(_s,{client:e,seed:t})]})}var pp=[[`tools`,Si],[`context`,Wi],[`timeline`,ua],[`runs`,Xi]];function mp({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:p,onDraftApplied:m}){let{t:g,tx:_}=T(),[v]=(0,f.useState)(()=>e??Ua()),[y,b]=(0,f.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,f.useState)(!1),[C]=(0,f.useState)(wf),[w,E]=(0,f.useState)(C?.taskId??null),[D,O]=(0,f.useState)(()=>C?null:no()??crypto.randomUUID()),k=io(y,D??``),[ee,A]=(0,f.useState)(null),[j,te]=(0,f.useState)([]),[M,ne]=(0,f.useState)(null),[N,P]=(0,f.useState)(C?`task`:`files`),[re,F]=(0,f.useState)(),[ie,I]=(0,f.useState)(),[L,ae]=(0,f.useState)(),[R,z]=(0,f.useState)(),[B,V]=(0,f.useState)(0),[H,U]=(0,f.useState)(()=>{let e=typeof history>`u`?null:history.state,t=no();return t&&e?.cadenceConversationId===t&&typeof e?.cadenceCwd==`string`?e.cadenceCwd:void 0}),[W]=(0,f.useState)(()=>crypto.randomUUID()),G=(0,f.useCallback)(()=>I(void 0),[]),[K,oe]=(0,f.useState)(C?C.scope??{kind:`task`,id:C.taskId}:null),q=xo(s?.id,s?.epoch),se=!s||q.readiness===`running`,ce=!!s&&(q.readiness===`stopped`||q.readiness===`not-started`),le=(0,f.useRef)(null);se&&q.value?.epoch&&(le.current=q.value.epoch);let ue=!s||!ce&&(se||le.current!==null),Y=wo(v,w?{kind:`task`,id:w}:null,!x&&ue,le.current),de=(0,f.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,f.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=uo(v.client,pe),ye=co(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=co(v.client,Y.workspace&&!x?{kind:`workflow-active`}:null,2e3),Ce=Se.value?.kind===`workflow-active`?Se.value:void 0,we=(0,f.useMemo)(()=>[...new Set([...Ce?.runs.map(e=>e.id)??[],...j])],[Ce,j]),Te=co(v.client,!s&&Y.workspace&&!x?{kind:`projects`}:null),Ee=H??s?.cwd??(Te.value?.kind===`projects`?Te.value.entries.find(e=>e.current)?.path:void 0),De=L?.id===D?L:void 0,Oe=R?.id===D?R:void 0,ke=$a();(0,f.useEffect)(()=>{De&&no()===De.id&&history.replaceState({...history.state,cadenceCwd:De.cwd,cadenceConversationId:De.id},``,location.href)},[De]);let Ae=D?De:Ee?{id:W,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=ap(),{closeDrawer:Fe}=Pe,Ie=N===`branches`&&!!D,Le=!Ie&&(N!==`task`||!K),Re=()=>{P(`branches`),Pe.mobile?Pe.setDrawer(`right`):Pe.inspector||Pe.toggle(`right`)},[ze,Be]=(0,f.useState)(C?.snapshotSeq),[Ve,He]=(0,f.useState)(``),[X,Ue]=(0,f.useState)(``),We=(0,f.useRef)(null),[Ge,Z]=(0,f.useState)(`messages`),[Ke,qe]=(0,f.useState)(!1),[Je,Ye]=(0,f.useState)(!1),[Xe,Ze]=(0,f.useState)(),[Qe,$e]=(0,f.useState)(C?.cursor),[et,tt]=(0,f.useState)(``),[nt,rt]=(0,f.useState)([]),[it,at]=(0,f.useState)(new Set),ot=(0,f.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?so(t,e):t)})},ct=(0,f.useRef)(new To),lt=J({taskId:w,scope:K,selectedSnapshot:ze??null,detached:x,attachment:Y.attachmentVersion,workspaceContext:Y.workspace?.context??null,observationError:Y.error??null});ct.current.select(lt),(0,f.useEffect)(()=>(ot.current=!0,()=>{ot.current=!1,ct.current.depart()}),[]);let Q=e=>{b(``);let t=e??crypto.randomUUID();e||U(je??Ee),A(null),t!==D&&(te([]),I(void 0)),ct.current.depart(),O(t),E(null),oe(null),He(``),Ue(``),Ze(void 0),$e(void 0),Be(void 0),Z(`messages`),P(e=>e===`task`?`files`:e),Fe();let n=t===D?io(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${ao(`#chat=${t}`,n)}`)};(0,f.useEffect)(()=>{D&&!window.location.hash&&history.replaceState(null,``,`${location.pathname}${location.search}#chat=${D}`)},[D]);let ut=(e,t)=>{A(null),te([]),O(null),P(`task`),He(t??``),Ue(``),Be(void 0),ct.current.depart(),E(e),oe({kind:`task`,id:e}),Ze(void 0),$e(void 0),Z(`messages`),Fe(),history.replaceState(null,``,Cf(e))};(0,f.useEffect)(()=>{let e=()=>{let e=wf();if(e)A(null),te([]),O(null),P(`task`),ct.current.depart(),Be(e.snapshotSeq),He(``),Ue(``),E(e.taskId),oe(e.scope??{kind:`task`,id:e.taskId}),Ze(void 0),$e(e.cursor),Z(`messages`),Fe();else{let e=no();if(e){b(window.location.hash);let t=history.state?.cadenceCwd;typeof t==`string`&&U(t),I(void 0),A(null),te([]),O(e),E(null),oe(null),P(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 dt=(e,t,n)=>{A(null),Be(t),Ue(n??``),ct.current.depart(),oe(e),Ze(void 0),$e(void 0),Z(`messages`),Fe(),w&&history.replaceState(null,``,Cf(w,void 0,{scope:e,snapshotSeq:t}))},ft=ze??Me.state?.snapshot.committedSeq??Y.workspace?.committedSeq,pt=Y.workspace?.storeId,mt=K&&pt&&ft?{storeId:pt,scope:K,snapshotSeq:ft,reader:`messages`,after:null,limit:50}:null,ht=K&&pt&&ft?{storeId:pt,scope:K,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:g(`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:g(`{code}; cancellation effect {effect}. Observe exact receipt.`,{code:e.error.code,effect:e.error.effect})})}).catch(()=>st({commandId:t,error:g(`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,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h1`,{children:g(`Detached`)}),(0,h.jsx)(`p`,{children:g(`Accepted service work continues. No Cancel was requested.`)}),nt.map(e=>(0,h.jsxs)(`p`,{children:[g(`Observe command after reconnect:`),` `,(0,h.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>S(!1),children:g(`Reconnect as a viewer`)})]});let 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,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(Xf,{panels:Pe,onOpenService:o,onRefresh:()=>{Y.refresh(),q.refresh()},onDisconnect:()=>{qe(!1),Ye(!1),ct.current.depart(),S(!0)},inspectorLabel:g(K&&N===`task`?`History details`:Ie?`Branches`:`Files`),toolbar:K&&(0,h.jsxs)(`nav`,{className:`tb-tabs`,"aria-label":g(`Recorded views`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-pressed":Ge===`messages`&&!Qe,onClick:()=>{$e(void 0),Ze(void 0),Z(`messages`)},children:[(0,h.jsx)(Ri,{"aria-hidden":`true`}),g(`Conversation`)]}),(0,h.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,h.jsxs)(`summary`,{className:`chip`,children:[Ge===`messages`?g(`Details`):_(Ge),(0,h.jsx)(ha,{"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`view-menu-items`,children:[pp.map(([e,t])=>(0,h.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,h.jsx)(t,{"aria-hidden":`true`}),_(e)]},e)),(0,h.jsxs)(`div`,{className:`view-menu-actions`,children:[(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Export selected scope`),disabled:!mt,onClick:()=>{We.current&&(We.current.open=!1,We.current.querySelector(`summary`)?.focus()),Ye(!0)},children:[(0,h.jsx)(ra,{"aria-hidden":`true`}),g(`Export selected scope`)]}),(0,h.jsxs)(`button`,{type:`button`,"aria-label":g(`Copy token-free link`),disabled:!w,onClick:()=>{w&&Po(Cf(w,Qe,K?{scope:K,snapshotSeq:ze}:void 0)).then(e=>e?Jo(`info`,g(`Link copied.`)):Jo(`error`,g(`Link copy unavailable.`)))},children:[(0,h.jsx)(Ui,{"aria-hidden":`true`}),g(`Copy token-free link`)]})]})]})]})]}),actions:K&&(0,h.jsx)(As,{disabled:!ht,onOpen:()=>qe(!0)}),notices:(0,h.jsxs)(h.Fragment,{children:[!Y.workspace&&xt.length>0&&(0,h.jsx)(`section`,{className:`run-strip`,"aria-label":g(`Execution and cancellation`),children:xt.map(e=>(0,h.jsxs)(`div`,{className:`run-strip-row`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,h.jsxs)(`span`,{className:`run-strip-label`,children:[_(e.kind),` `,e.runId,` · `,_(e.stage)]}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>ut(e.taskId),children:g(`Open active task`)}),(0,h.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!Y.attached||it.has(e.runId),onClick:()=>yt(e.runId),children:[(0,h.jsx)(Ti,{"aria-hidden":`true`}),g(`Cancel run — request stop`)]})]},e.runId))}),i,(0,h.jsx)(Sf,{error:et,projectObservationError:q.error,observationError:Y.error,unavailable:!Tt&&!ce&&!Ct,onRefresh:()=>{Y.refresh(),q.refresh()}})]}),navigation:(0,h.jsxs)(h.Fragment,{children:[!pe&&(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[a&&(0,h.jsx)(Ws,{...a}),(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(Tt?`Reading conversation history…`:`Conversation history could not be read. This is not an empty history.`)})]}),pe&&(0,h.jsx)(vf,{discovery:a,client:v.client,workspace:Y.workspace,executionStopped:ce,taskId:w,scope:K,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,h.jsxs)(h.Fragment,{children:[ve.error&&(0,h.jsx)(`p`,{role:`alert`,children:ve.error}),ve.loading&&(0,h.jsx)(`p`,{className:`panel-hint`,children:g(`Reading conversation history…`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.previous,children:g(`Newer conversations`)}),ve.value?.next&&(0,h.jsx)(`button`,{type:`button`,disabled:ve.loading,onClick:ve.next,children:g(`Older conversations`)}),ve.canPrevious&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.first,children:g(`Latest conversations`)}),ve.error&&(0,h.jsx)(`button`,{type:`button`,onClick:ve.refresh,children:g(`Observe current state`)})]}),conversationId:D,onConversation:Q,onNewConversation:()=>Q(),actionsUnavailable:wt?``:g(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===D&&V(e=>e+1)},workflows:Ce?.runs,workflowLinks:Ce?.links,workflowError:!!Se.error,selectedWorkflow:ee?.runId,onWorkflow:(e,t)=>{t?Q(t):(A({runId:e.id,stepId:null,label:e.goal}),Fe())},onCancelWorkflow:async e=>{tt(await od(v.client,e)),Se.refresh()},onTask:ut,onScope:dt}),Y.workspace&&(0,h.jsx)(ac,{client:v.client,active:Y.activeRuns,taskId:w,runs:gt,snapshot:ft,workflowRuns:we,selected:ee,onOpenWorkflow:e=>{A(e),Fe()},onOpen:(e,t,n,r)=>{ut(e),oe({kind:`child`,id:t}),Ue(r),Be(n),history.replaceState(null,``,Cf(e,void 0,{scope:{kind:`child`,id:t},snapshotSeq:n}))}})]}),content:(0,h.jsxs)(h.Fragment,{children:[D&&s&&!fe&&(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:g(`Reading this conversation…`)}),ee&&(0,h.jsx)(bf,{client:v.client,agent:ee,backLabel:g(D?`Back to conversation`:w?`Back to task`:`Back`),onBack:()=>A(null),onOpenAgent:A},`${ee.runId}:${ee.stepId??``}`),D&&(!s||fe)&&(0,h.jsx)(vd,{client:v.client,id:D,activitySelected:k.selected,initialLeaf:k.leaf,initialCwd:Ee,onLocation:ae,onActivity:z,hidden:!!ee,onOpenAgent:A,onWorkflowRuns:te,onBranches:F,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:B,available:pe,canInterrupt:Y.attached,enabled:ge?pe:!!Y.workspace&&Y.attached&&!Y.error,modelAvailability:Et,previewModels:d,initialDraft:p?.conversationId===D?p:void 0,onDraftApplied:()=>m?.(D),onModelChanged:()=>{ct.current.depart(),Y.refresh(),q.refresh()},onChanged:()=>{ve.refresh(),Y.refresh()},reference:ie,onReferenceUsed:G},`${s?.id??me.current??`connecting`}:${D}:${k.leaf??``}`),K&&!ee&&(0,h.jsxs)(`header`,{className:`conversation-header`,children:[(0,h.jsxs)(`div`,{className:`conversation-heading`,children:[K.kind!==`task`&&w&&(0,h.jsx)(`button`,{type:`button`,className:`ghost`,onClick:()=>ut(w,Ve),children:g(`Back to task`)}),(0,h.jsx)(`h2`,{title:Ve||K.id,children:K.kind===`task`?Ve||g(`Task {id}`,{id:K.id.slice(0,8)}):X||g(`{kind} {id}`,{kind:_(K.kind),id:K.id.slice(0,8)})}),K.kind===`child`&&(0,h.jsx)(`span`,{className:`conversation-badge`,children:g(`Subagent`)})]}),(0,h.jsxs)(`details`,{className:`conversation-info`,children:[(0,h.jsxs)(`summary`,{children:[g(`Recorded conversation`),` ·`,` `,g(`snapshot {seq}`,{seq:ft??``})]}),(0,h.jsx)(`code`,{children:K.id}),(0,h.jsx)(`p`,{children:g(`Pages and old outcomes are historical observations, not renewed consent.`)})]})]}),(0,h.jsxs)(`div`,{className:`workspace-content`,hidden:!!D||!!ee,children:[!mt&&(0,h.jsxs)(`section`,{className:`empty-state`,children:[(0,h.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,h.jsx)(`h2`,{children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),(0,h.jsx)(`p`,{children:g(`History is readonly. Start new work in a conversation with /cadence.`)})]}),mt&&Qe?(0,h.jsxs)(`div`,{className:`tab-body`,children:[Xe&&(Xe.owner.entity.kind===`task`||Xe.owner.entity.kind===`message`||Xe.owner.entity.kind===`tool`)&&(0,h.jsx)(vs,{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,h.jsx)(hs,{client:v.client,cursor:Qe,highlight:Xe?.range},`${Qe.recordId}:${Qe.recordVersion}`)]}):mt&&(0,h.jsxs)(`div`,{className:Ge===`messages`||Ge===`tools`?`tab-body transcript-body`:`tab-body`,children:[Ge===`messages`&&(0,h.jsx)(Bs,{client:v.client,seed:mt}),Ge===`tools`&&(0,h.jsx)(hp,{client:v.client,seed:mt}),Ge===`context`&&(0,h.jsx)(_s,{client:v.client,seed:mt}),Ge===`timeline`&&(0,h.jsx)(dp,{client:v.client,seed:mt,onSearch:()=>qe(!0)}),Ge===`runs`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`run-current`,children:[(0,h.jsx)(`h3`,{children:g(`Runs in the current snapshot`)}),gt.length>0?gt.map(e=>(0,h.jsx)(Es,{run:e},e.childRunId??e.runId)):(0,h.jsx)(`p`,{className:`panel-empty`,children:Ne&&Me.state?g(`No owner run projection in this snapshot.`):g(`No snapshot observed yet; absence is not proof of settlement.`)})]}),(0,h.jsx)(`h3`,{children:g(`Retained runs`)}),(0,h.jsx)(ks,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}},onScope:dt},w)]})]},`${K?.kind}:${K?.id}:${ze??`current`}`)]}),Y.workspace&&nt.length>0&&(0,h.jsx)(`div`,{className:`receipt-dock`,children:nt.map(e=>(0,h.jsx)(Eo,{client:v.client,value:e,onChange:st},e.commandId))})]}),inspectorTabs:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Le,onClick:()=>P(`files`),children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),g(`Files`)]}),D&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>P(`branches`),children:[(0,h.jsx)(Xi,{"aria-hidden":`true`}),g(`Branches`)]}),K&&(0,h.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":N===`task`,disabled:!mt,onClick:()=>P(`task`),children:[(0,h.jsx)(Wi,{"aria-hidden":`true`}),g(`History details`)]})]}),inspector:Ie?(0,h.jsx)(dc,{view:re?.id===D?re:void 0,onChosen:Fe}):Le?(0,h.jsx)(Nd,{location:Ae,client:v.client,enabled:pe&&!!Ae,observed:`${q.readiness}:${q.value?.epoch??``}`,onReference:e=>{D||Q(W);let t=!D&&Ae?`${Ae.cwd.replace(/[\\/]+$/,``)}${Ae.cwd.startsWith(`/`)?`/`:`\\`}${e}`:e;I(t),Fe()}},Ae?.cwd??`owner`):mt?(0,h.jsx)(Ud,{client:v.client,seed:{...mt,scope:{kind:`task`,id:w??mt.scope.id}}},w):(0,h.jsx)(`p`,{className:`panel-empty`,role:`status`,children:Y.error?g(`Recorded history could not be read.`):g(`Reading recorded history…`)}),status:(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(np,{tip:g(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:_(Dt)}),s&&(0,h.jsx)(tp,{tone:`faint`,icon:(0,h.jsx)(Oi,{}),children:g(`Execution service: {status}`,{status:_(q.readiness)})}),Oe&&(0,h.jsx)(ep,{usage:Oe.context}),Oe&&(0,h.jsx)(Qf,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,h.jsx)(tp,{icon:(0,h.jsx)(Ri,{}),tip:g(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,h.jsx)(ip,{since:Oe.runningSince,label:g(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,h.jsx)(tp,{tone:`warn`,children:g(Ct?xt.length===1?`{count} active run`:`{count} active runs`:`Last observed: {count} active runs`,{count:xt.length})}):!Tt&&!ce&&(0,h.jsx)(tp,{tone:`faint`,children:g(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,h.jsx)(xf,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,h.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,h.jsx)(Ts,{client:v.client,seed:ht,onClose:()=>qe(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,Cf(w,e.cursor,K?{scope:K,snapshotSeq:ze}:void 0))}}),Je&&ht&&(0,h.jsx)(Ss,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function hp({client:e,seed:t}){let n=jo(e,{...t,reader:`tools`}),r=n.page;return(0,h.jsxs)(`section`,{className:`tools-list`,children:[(0,h.jsx)(gs,{pager:n}),(0,h.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,h.jsx)(Hs,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var gp=`cadence:folder-draft`,_p=()=>({text:``,model:null});function vp(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return _p();let t=null;try{e.model!=null&&(t=me(e.model))}catch{}return{text:e.text,model:t}}catch{return _p()}}function yp(e){try{e.text||e.model?sessionStorage.setItem(gp,JSON.stringify(e)):sessionStorage.removeItem(gp)}catch{}}function bp(e,t,n){let r=Vc(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(gp)}catch{}return{...n,conversationId:t}}var xp=`cadence-last-project`;function Sp(){try{let e=localStorage.getItem(xp);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Cp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(xp,e)}catch{}}function wp(e){let t=Sp();return t?e.projects.find(e=>e.id===t):void 0}async function Tp(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=Cn(await fo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Ep(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 fo(n);if(!n.ok)throw Error(po(r));return bn(r)}async function Dp(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await fo(t);if(!t.ok)throw Error(po(n));return On(n)}async function Op(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 fo(s);if(!s.ok)throw mo(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(po(c));let l=Sn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function kp(e,t){let n=await Dp(t);return Op(`/workbench/v1/select`,{path:e},n,t)}async function Ap(e,t,n,r,i){let a=await Dp(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 Op(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 jp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await kp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var Mp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Np(e){let t=U(e,[`id`,`source`,`sessionId`,`cwd`,`leaf`,`history`,`phase`,`freshness`,`observedAt`,`epoch`,`instance`,`executionCwd`]);return{id:G(t.id),source:B(t.source,[`terminal`,`turn`,`workflow`]),sessionId:t.sessionId===null?null:dn(t.sessionId),cwd:L(t.cwd,4096,!0),leaf:t.leaf===null?null:L(t.leaf,128,!0),history:B(t.history,[`shared`,`unavailable`]),phase:B(t.phase,Mp),freshness:B(t.freshness,[`current`,`stale`,`unknown`]),observedAt:R(t.observedAt,0),epoch:t.epoch===null?null:G(t.epoch),instance:t.instance===null?null:G(t.instance),executionCwd:t.executionCwd===null?null:L(t.executionCwd,4096,!0)}}function Pp(e){let t=U(e,[`kind`,`epoch`,`observedAt`,`completeness`,`unavailable`,`projects`]);return{kind:V(t.kind,`activity-discovery`),epoch:G(t.epoch),observedAt:R(t.observedAt,0),completeness:B(t.completeness,[`complete`,`partial`]),unavailable:R(t.unavailable,0,1e4),projects:W(t.projects,128,e=>{let t=U(e,[`path`,`activities`]);return{path:L(t.path,4096,!0),activities:W(t.activities,256,Np)}})}}async function Fp(e){let t=Oa([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await fo(e);if(!e.ok)throw Error(po(n));return Pp(n)}finally{t.dispose()}}function Ip(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 Lp(e,t,n,r=Fp){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?Ip(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 Rp(e,t){let[n,r]=(0,f.useState)(),[i,a]=(0,f.useState)(``);return(0,f.useEffect)(()=>{if(r(void 0),a(``),e)return Lp(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function zp({ready:e,previewModels:t,draft:n=_p(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=T(),d=ap(),[p,m]=(0,f.useState)(!1),g=tl(null,{status:`not-started`},`folder-setup`,t),_=()=>{d.closeDrawer(),a()};return(0,h.jsx)(Xf,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,h.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,h.jsx)(ef,{disabled:!e,onConversation:_}),l&&(0,h.jsx)(Ws,{...l}),(0,h.jsxs)(`section`,{className:`lp-section grow`,children:[(0,h.jsx)(`header`,{className:`lp-section-header`,children:(0,h.jsx)(`span`,{className:`lp-section-title`,children:u(`Conversation history`)})}),(0,h.jsx)(`div`,{className:`lp-section-body`,children:(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:u(`Choose a working folder to see its conversation history.`)})})]})]}),content:(0,h.jsxs)(`section`,{className:`chat-workspace`,"aria-label":u(`Ordinary conversation`),children:[(0,h.jsx)(`div`,{className:`chat-messages`,children:(0,h.jsxs)(Wu,{hint:u(`Choose a working folder to start. You can write a draft below.`),children:[(0,h.jsxs)(`button`,{type:`button`,className:`primary welcome-action`,disabled:!e,onClick:_,children:[(0,h.jsx)(Zi,{"aria-hidden":`true`}),u(`Choose a folder…`)]}),i&&(0,h.jsx)(`p`,{className:`panel-hint`,role:`status`,children:i.status===`checking`?u(`Returning to your last folder {path}…`,{path:i.path}):u(`Could not restore {path}. Choose a folder to continue; nothing was started.`,{path:i.path})})]})}),(0,h.jsxs)(`div`,{className:`chat-composer`,children:[(0,h.jsx)(`textarea`,{"aria-label":u(`Message`),rows:3,value:n.text,onChange:e=>r?.({...n,text:e.target.value}),placeholder:u(`Write a message. Choose a folder before sending…`)}),(0,h.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,h.jsx)(Il,{scope:`next-conversation`,availability:{status:`not-started`},read:g,draftModel:n.model,onPreviewChoice:r?e=>r({...n,model:e}):void 0,locked:!e,open:p,onOpenChange:e=>{e&&!g.preview&&!g.loading&&g.reread(),m(e)},onChanged:()=>{}}),(0,h.jsx)(`span`,{className:`composer-hint`,children:u(`Choose a folder before sending.`)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,"aria-label":u(`Send`),title:u(`Send`),disabled:!0,children:(0,h.jsx)(va,{"aria-hidden":`true`})})]})]})]}),inspector:(0,h.jsx)(`aside`,{className:`panel files-panel`,children:(0,h.jsx)(`p`,{className:`panel-hint`,children:u(`Files appear here after you open a working folder.`)})}),status:(0,h.jsx)(tp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,h.jsx)(xf,{disabled:!e,onClick:_})})}var Bp=`cadence-recovery-dismissed`,Vp={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.`},Hp={"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 Up(){try{let e=JSON.parse(localStorage.getItem(Bp)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Wp(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function Gp({notices:e,project:t}){let{t:n}=T(),[r,i]=(0,f.useState)(Up),[a,o]=(0,f.useState)(!1),s=e.filter(e=>!r.includes(e.id)&&(t===void 0||e.scope!==`project`||e.path===t));if(!s.length)return null;let c=s[0],l=()=>{let e=[...r,...s.map(e=>e.id)].slice(-50);try{localStorage.setItem(Bp,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:Wp(e.path)}):e.scope===`workbench`?n(`Cadence service`):n(`Project registry`);return(0,h.jsxs)(`div`,{className:`banner-notice recovery-notice`,role:`status`,children:[(0,h.jsxs)(`span`,{children:[n(Vp[c.cause]),` `,c.cause!==`storage`&&n(`Work that was running is marked as interrupted; start it again when you are ready.`)]}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),children:n(a?`Hide details`:`Details`)}),` `,(0,h.jsx)(`button`,{type:`button`,onClick:l,children:n(`Dismiss`)}),a&&(0,h.jsx)(`ul`,{className:`recovery-details`,children:s.map(e=>(0,h.jsxs)(`li`,{children:[(0,h.jsx)(`strong`,{children:u(e)}),` `,(0,h.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()}),`: `,e.actions.map(t=>n(Hp[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var Kp={restart:18e4,upgrade:12e5},qp=1e3,Jp={"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.`},Yp=e=>e instanceof Error?e.message:`unavailable`;function Xp(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(Jp[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 Zp(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function Qp(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 $p({epoch:e,csrf:t,onClose:n}){let{t:r}=T(),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(null),[p,m]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(null),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(),[E,D]=(0,f.useState)(0);(0,f.useEffect)(()=>{let e=new AbortController;return go(e.signal).then(a,t=>{e.signal.aborted||s(Yp(t))}),()=>e.abort()},[E]),(0,f.useEffect)(()=>{if(!v)return;let{job:e,since:t}=v,n=new AbortController,r,i=async()=>{if(Date.now()-t>Kp[e.action])return w(`timeout`);try{let t=await go(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`);S(!0)}r=setTimeout(i,qp)};return r=setTimeout(i,qp),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),_o().then(l,()=>l(`failed`)).finally(()=>D(e=>e+1))},k=n=>{i&&(_(!0),s(``),vo({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(Yp(e)),m(!1),D(e=>e+1)}).finally(()=>_(!1)))};if(v){let{job:e}=v,t=C!==void 0&&(typeof C==`string`||C.state!==`ready`),a=typeof C==`object`&&Zp(C),o=i?.unit;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:C?n:void 0,children:[(0,h.jsxs)(`section`,{className:`service-progress`,children:[C===void 0?(0,h.jsxs)(`p`,{role:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),e.action===`restart`?r(x?`Cadence is starting again…`:`Stopping Cadence…`):r(x?`Installing {to} and starting Cadence…`:`Downloading {to}, then stopping Cadence…`,{to:e.to??``})]}):(0,h.jsxs)(`p`,{role:t?`alert`:`status`,children:[(0,h.jsx)(`span`,{className:`status-dot ${t?`error`:`ok`}`,"aria-hidden":`true`}),C===`timeout`?r(`Cadence did not report back within {minutes} minutes.`,{minutes:Kp[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):Xp(r,C)]}),(0,h.jsx)(`p`,{children:r(C===void 0?`This runs outside the service: closing or reloading the page does not stop it, and running work is stopped in order.`:a?`The service was not changed; this page stays connected.`:`Reload the page to reconnect to the new service.`)}),t&&o&&(0,h.jsxs)(`p`,{className:`service-commands`,children:[r(`Details in a terminal:`),` `,(0,h.jsxs)(`code`,{children:[`cadence server status`,o.scope===`system`?` --system`:``]}),` `,(0,h.jsxs)(`code`,{children:[`journalctl `,o.scope===`system`?``:`--user `,`-u`,` `,o.name.replace(/\.service$/,`.maintenance.service`)]})]})]}),C!==void 0&&(0,h.jsx)(`footer`,{children:a?(0,h.jsx)(`button`,{type:`button`,onClick:n,children:r(`Close`)}):(0,h.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>window.location.reload(),children:r(`Reload page`)})})]})}if(u&&i){let e=i.work;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:u.action===`restart`?r(`Restart Cadence?`):r(`Upgrade Cadence {from} to {to}?`,{from:i.version,to:u.to})}),(0,h.jsx)(`p`,{children:u.action===`restart`?r(`The service stops in order and starts again; this page waits and then reloads.`):r(`The package manager downloads {to} while Cadence keeps running; then the service stops, {to} is installed and the service starts again. If {to} does not become ready, {from} is reinstalled.`,{to:u.to,from:i.version})}),e>0&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`p`,{role:`alert`,children:r(`{count} running workflows or conversations will be stopped.`,{count:e})}),(0,h.jsxs)(`label`,{className:`service-confirm`,children:[(0,h.jsx)(`input`,{type:`checkbox`,checked:p,onChange:e=>m(e.target.checked)}),` `,r(`Stop them and continue`)]})]})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>{d(null),m(!1),s(``)},children:r(`Back`)}),(0,h.jsx)(`button`,{type:`button`,className:e>0?`danger`:`primary`,disabled:g||e>0&&!p,onClick:()=>k(u),children:u.action===`restart`?r(`Restart now`):r(`Upgrade now`)})]})]})}let ee=i&&c&&typeof c==`object`?zn(c.version,i.version)>0:!1;return(0,h.jsxs)(xs,{title:r(`Cadence service`),onClose:n,children:[i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsxs)(`h3`,{children:[`Cadence `,i.version]}),(0,h.jsx)(`p`,{children:Qp(r,i.upgrade)}),(0,h.jsx)(`p`,{children:i.unit?r(`Runs as {unit} ({scope} systemd service).`,{unit:i.unit.name,scope:i.unit.scope}):r(`This Cadence instance was not started by its systemd service, so the page cannot restart or upgrade it. Use cadence server restart in a terminal.`)}),i.job&&(0,h.jsx)(`p`,{children:r(`Last request ({time}): {outcome}`,{time:new Date(i.job.at).toLocaleString(),outcome:Xp(r,i.job)})})]}),i.unit&&(0,h.jsxs)(`section`,{className:`service-info`,children:[(0,h.jsx)(`h3`,{children:r(`Updates`)}),c===void 0||c===`failed`?(0,h.jsxs)(h.Fragment,{children:[c===`failed`&&(0,h.jsx)(`p`,{role:`alert`,children:r(`Update information is unavailable for this installation.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:O,children:r(`Check for updates`)})]}):c===`checking`?(0,h.jsx)(`p`,{role:`status`,children:r(`Asking the package registry for the latest version…`)}):ee?c.deprecated?(0,h.jsx)(`p`,{children:r(`{version} is deprecated on npm and is not offered.`,{version:c.version})}):In(i.upgrade)?(0,h.jsxs)(`button`,{type:`button`,className:`primary`,onClick:()=>d({action:`upgrade`,to:c.version}),children:[(0,h.jsx)(ya,{"aria-hidden":`true`}),r(`Upgrade to {version}`,{version:c.version})]}):(0,h.jsx)(`p`,{children:i.upgrade===`not-writable`?r(`{version} is available, but this account cannot write the installation; upgrade it in a terminal.`,{version:c.version}):r(`{version} is available, but this installation requires a manual update using its original installation method.`,{version:c.version})}):(0,h.jsx)(`p`,{children:r(`Cadence {version} is the latest version.`,{version:i.version})})]}),o&&(0,h.jsx)(`p`,{role:`alert`,children:b(r,o)})]}):(0,h.jsx)(`p`,{role:o?`alert`:`status`,children:o?b(r,o):r(`Reading the service…`)}),(0,h.jsx)(`footer`,{children:(0,h.jsxs)(`button`,{type:`button`,disabled:!i?.unit,onClick:()=>d({action:`restart`,to:null}),children:[(0,h.jsx)(ji,{"aria-hidden":`true`}),r(`Restart service`)]})})]})}function em(){let{t:e}=T(),[t,n]=(0,f.useState)(),[r,i]=(0,f.useState)(vp),[a,o]=(0,f.useState)(),s=(0,f.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,f.useState)(to),u=(0,f.useCallback)(e=>Ep(c??void 0,e),[c]),[d,p]=(0,f.useState)(null),[m,g]=(0,f.useState)(null),[_,v]=(0,f.useState)(``),[y,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(0),[w,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useCallback)(()=>C(e=>e+1),[]),ee=Rp(t?.epoch,k),A=(0,f.useRef)(null);(0,f.useEffect)(()=>()=>A.current?.abort(),[]);let j=(0,f.useRef)(new Map),te=(0,f.useRef)(!c),M=(0,f.useRef)(null),ne=(0,f.useCallback)(()=>{M.current&&(M.current.abort(),M.current=null,O(null))},[]);(0,f.useEffect)(()=>{let e=new AbortController;return(async()=>{try{let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e.signal}),r=await fo(t);t.status===400&&po(r)===`invalid`?n(null):t.ok?(n(On(r)),x(``)):x(po(r))}catch{e.signal.aborted||x(`unavailable`)}})(),()=>e.abort()},[S]),(0,f.useEffect)(()=>{let e=()=>{A.current?.abort(),ne(),O(null),l(to())};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[ne]),(0,f.useEffect)(()=>{if(!t||!te.current||(te.current=!1,r.text||r.model))return;let e=wp(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),Tp(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,f.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(bp(e.path,a,r)),i(_p())):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),p(null),window.dispatchEvent(new PopStateEvent(`popstate`))},[c,ne,t,r]),P=(0,f.useCallback)(async e=>{A.current?.abort();let t=new AbortController;A.current=t;let r=await kp(e,t.signal);t.signal.aborted||(n(r.entry),N(r.project))},[N]),I=t?{value:ee.value,error:ee.error,opening:!!m,project:t.projects.find(e=>e.id===c)?.path,onOpen:(t,r)=>{A.current?.abort(),ne();let i=new AbortController;A.current=i,g(r.cwd),v(``),jp(t,r,i.signal).then(e=>{i.signal.aborted||(n(e.entry),N(e.project,r))}).catch(t=>{i.signal.aborted||v(b(e,t instanceof Error?t.message:`unavailable`))}).finally(()=>{A.current===i&&g(null)})}}:void 0,L=async(e,r,i,a)=>{let o=t?.projects.find(e=>e.id===c);if(!o)throw Error(`unavailable`);let s=await Ap(o,e,r,i,a);if(r.aborted)throw Error(`stale`);return n(s.entry),s.project.epoch},ae=(0,f.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 fo(n);if(!n.ok){let e=po(r);return{kind:`error`,error:ie(re.find(t=>t===e)??`unavailable`)}}return{kind:`ok`,value:ii(r)}}catch{return{kind:`error`,error:ie(`unavailable`)}}}}),[]),R=(0,f.useMemo)(()=>c?Ua(c):void 0,[c]),z=t?.projects.find(e=>e.id===c);if((0,f.useEffect)(()=>{z&&Cp(z.id)},[z]),t===null)return(0,h.jsx)(mp,{});let B=t&&w&&(0,h.jsx)($p,{epoch:t.epoch,csrf:t.csrf,onClose:()=>E(!1)}),V=()=>E(!0),H=t&&d!==null&&(0,h.jsx)(qd,{selectOnly:!0,client:ae,current:z?.cwd??``,projects:t.projects.map(e=>({path:e.cwd,current:e.id===c})),initial:d,home:t.home,epoch:t.epoch,onClose:()=>p(null),onOpen:P});return t&&z&&R?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(mp,{api:R,project:z,previewModels:u,initialDraft:a,onDraftApplied:s,directoryNamespaces:t?.projects.filter(e=>e.path===z.path).map(e=>e.id).sort(),discovery:I,onPrepareExecution:L,onChooseFolder:e=>{A.current?.abort(),p(e??z.cwd)},onOpenProject:P,homeFolder:t.home,projectEntries:t.projects.map(e=>({path:e.cwd,current:e.id===c})),notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,children:_}),(0,h.jsx)(Gp,{notices:t.recoveries,project:z.path}),` `]}),onOpenService:V},z.id),B,H]}):(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(zp,{discovery:I,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),yp(e)},restore:D,onRefresh:()=>C(e=>e+1),onOpenService:t?V:void 0,onChooseFolder:()=>{ne(),v(``),A.current?.abort(),p(t?.home??``)},notices:(0,h.jsxs)(h.Fragment,{children:[_&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:_}),t&&(0,h.jsx)(Gp,{notices:t.recoveries}),y&&(0,h.jsxs)(`p`,{role:`alert`,className:`banner-notice`,children:[y,` `,(0,h.jsx)(`button`,{type:`button`,onClick:()=>C(e=>e+1),children:e(`Reload observation`)})]}),c&&!z&&t&&(0,h.jsx)(`p`,{role:`alert`,className:`banner-notice`,children:e(`This folder is unavailable. Choose another folder; nothing was moved or recreated.`)})]})}),H,B]})}function tm(){let{t:e}=T();return(0,h.jsxs)(`main`,{className:`entry`,children:[(0,h.jsx)(`h1`,{children:e(`Presentation unavailable`)}),(0,h.jsx)(`p`,{children:e(`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`)}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:e(`Reload observation`)})]})}var nm=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,h.jsx)(tm,{}):this.props.children}};A(ee());var rm=document.getElementById(`root`);if(!rm)throw Error(`Application root unavailable`);(0,p.createRoot)(rm).render((0,h.jsx)(E,{children:(0,h.jsx)(nm,{children:(0,h.jsx)(em,{})})}));export{up as t};
|
|
28
|
+
`}${r}`}var Hd=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function Ud(e){return[...e.matchAll(/[^\\/]+/g)].map(t=>({label:t[0],path:e.slice(0,t.index+t[0].length)}))}function Wd(e,t){let n=e.startsWith(`/`)?`/`:`\\`;return`${e.replace(/[\\/]+$/,``)}${n}${t.split(`/`).join(n)}`}var Gd=`file-download`,Kd=(0,m.memo)(function({path:e,text:t}){return(0,_.jsx)(ms,{text:Vd(t,pu(e))})});function qd({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}=Wo(),[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=vo(e,t?{kind:`files`,path:o,...n?{location:n}:{}}:null),O=vo(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||rs(`error`,a(`Copy unavailable`))})},N=t=>{let r=new AbortController;C.current=r,x(t.path),as(Gd),Pd(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 Bd(e,t.name)}).catch(e=>{if(r.signal.aborted)return;let n=e instanceof Error?e.message:String(e);rs(`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)}),Gd)}).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?Hd(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)(Ri,{"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)(Ii,{"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)(na,{"aria-hidden":`true`})}),Ud(o).map(e=>(0,_.jsxs)(`span`,{className:`crumb-seg`,children:[(0,_.jsx)(xa,{"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)(Ii,{"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)(Di,{"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)(aa,{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)(aa,{className:`file-icon`,"aria-hidden":`true`}):(0,_.jsx)(oa,{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)(da,{"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)(Zi,{"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)(wa,{"aria-hidden":`true`}):(0,_.jsx)(ga,{"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?Wd(n.cwd,e.path):e.path),children:v&&f===`path:${e.path}`?(0,_.jsx)(wa,{"aria-hidden":`true`}):(0,_.jsx)(ya,{"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)(oa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{title:c,children:Hd(c)}),(0,_.jsx)(`button`,{type:`button`,className:`crumb`,"aria-label":a(`Close preview`),title:a(`Close preview`),onClick:()=>l(null),children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]}),O.error&&(0,_.jsx)(`p`,{role:`alert`,children:S(a,O.error)}),te&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(Kd,{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 Jd=`未命名章节`;function Yd(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 Xd(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=Yd(r||Jd),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Jd}})}function Zd(e){return e.length>=2}function Qd(e){let t=0,n=0;return e.split(`
|
|
29
|
+
`).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function $d({text:e}){return(0,_.jsx)(`pre`,{className:`scm-diff-pre`,children:Qd(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 ef({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(`
|
|
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=Xd(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)(cs,{text:u?h.slice(u.start-1,u.end).join(`
|
|
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:[Zd(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)(ms,{text:e})})]}):n===`diff`?(0,_.jsx)($d,{text:e}):(0,_.jsx)(`div`,{className:`fp-code ${i?``:`no-wrap`}`,children:Qd(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 tf({client:e,seed:t}){let{t:n,tx:r}=D(),i=Bo(e,t),[a,o]=(0,m.useState)(),s=i.page;return(0,_.jsxs)(`section`,{className:`scm-body`,children:[(0,_.jsx)(Ts,{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(Ro(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)(ws,{client:e,cursor:a,render:e=>(0,_.jsx)(ef,{text:e})},`${a.recordId}:${a.recordVersion}`)]})}var nf=[`contents`,`checks`,`changes`,`reviews`];function rf({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:nf.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)(Es,{client:e,seed:t}):(0,_.jsx)(tf,{client:e,seed:{...t,reader:i}},i)})]})}var af={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.`},of=e=>/^(?:~(?:[\\/]|$)|[\\/]|[A-Za-z]:[\\/])/.test(e);function sf(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 cf({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||(of(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&&!of(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?sf(u.path,r):void 0,I=v.trim().toLowerCase(),L=u?.entries.filter(e=>e.name.toLowerCase().includes(I))??[],R=O&&(O.step===`read`&&af[O.code]?l(af[O.code]):S(l,O.code));return(0,_.jsxs)(As,{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)(aa,{"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)(ta,{"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)(xa,{"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)(ua,{"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)(Ea,{}),l(`Parent folder`)]}),L.map(e=>(0,_.jsxs)(`button`,{type:`button`,disabled:T,onClick:()=>re(e.path),children:[(0,_.jsx)(aa,{}),(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 lf(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 uf=[`today`,`yesterday`,`earlier`];function df(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 ff(e,t,n=Date.now()){let r=new Map;for(let i of e){let e=df(t(i),n);r.set(e,[...r.get(e)??[],i])}return uf.flatMap(e=>{let t=r.get(e);return t?[{key:e,items:t}]:[]})}function pf(e,t){let n=t.trim().toLowerCase();return!n||e.toLowerCase().includes(n)}function mf(e,t,n=Date.now()){let r=new Date(e);return df(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 hf({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)(Bi,{"aria-hidden":`true`}),n(`New conversation`)]})})}function gf(e){let t=e.replace(/\p{Cc}+/gu,` `).trim();return[...t].length>100?null:t}var _f=(e,t)=>({kind:`conversation-rename`,commandId:crypto.randomUUID(),conversationId:e,name:t}),vf=(e,t)=>({kind:`conversation-archive`,commandId:crypto.randomUUID(),conversationId:e,archived:t});async function yf(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 bf={rename:`Renaming…`,archive:`Archiving…`,unarchive:`Unarchiving…`},xf={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.`},Sf={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.`},Cf=e=>`conversation-row:${e}`;function wf(e,t){return t.kind===`refused`?{refusal:{text:xf[e],code:t.code},reread:!1}:{...t.kind===`unknown`?{row:{unknown:{action:e,code:t.code}}}:{},reread:!0}}function Tf(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});as(Cf(c)),l({pending:o}),yf(e,s).then(e=>{if(!a.current)return;let{row:r,refusal:i,reread:s}=wf(o,e);l(r),i&&rs(`error`,n(i.text,{code:i.code}),Cf(c)),s&&t(c)})};return{states:r,rename:(e,t)=>o(`rename`,_f(e,t)),archive:(e,t)=>o(t?`archive`:`unarchive`,vf(e,t))}}function Ef({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)(Ki,{"aria-hidden":`true`})}),S=()=>{if(f===null)return;let t=gf(f);t===null?rs(`error`,l(`A name can have at most {count} characters.`,{count:100}),Cf(e.id)):(y.current=!0,p(null),t!==e.title&&s?.(t))},C=!!o||!!a?.pending,w=a?.pending?l(bf[a.pending]):a?.unknown?l(Sf[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)(wa,{"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:mf(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)(ua,{"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)(Aa,{"aria-hidden":`true`})})]}),w&&(0,_.jsx)(`p`,{className:`session-note`,role:a?.pending?`status`:`alert`,children:w})]})}function Df({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)(Oa,{"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 Of={today:`Today`,yesterday:`Yesterday`,earlier:`Earlier`};function kf({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)(Ca,{"aria-hidden":`true`}):(0,_.jsx)(xa,{"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 Af({runs:e,scope:t,snapshot:n,onScope:r}){let{t:i,tx:a}=D(),[o,s]=(0,m.useState)(new Set),c=lf(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)(xa,{"aria-hidden":`true`}):(0,_.jsx)(Ca,{"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)(pa,{"aria-hidden":`true`}):(0,_.jsx)(Ki,{"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 jf({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)(Af,{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)(Ts,{pager:e,compact:!0})]})}function Mf({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=bo(e,N,!0),P=ie.refresh,ae=Tf(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=Bo(e,F),I=Bo(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)(jf,{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(td(n)):e.cadence&&t?j(`Discussing`):e.status===`completed`?``:te(e.status);return(0,_.jsx)(Ef,{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=>pf(e.title,M)),ce=z.filter(e=>pf(e.goal,M));return(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[O&&(0,_.jsx)(tc,{...O,represented:!n&&O.project?[...(w??[]).map(e=>ec(O.project,`workflow`,e.id,e.epoch)),...W.flatMap(e=>e.live?[ec(O.project,`turn`,e.live.commandId,e.live.epoch)]:[])]:[]}),(0,_.jsx)(hf,{onConversation:x}),!n&&(0,_.jsxs)(kf,{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)(Af,{runs:a.filter(t=>t.runId===e.runId),scope:i,onScope:f})]},e.runId)})]}),(0,_.jsxs)(kf,{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)(Aa,{"aria-hidden":`true`})}),children:[N&&(0,_.jsx)(Df,{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}),ff(se,e=>e.updatedAt).map(e=>(0,_.jsxs)(`div`,{className:`lp-time-group`,children:[(0,_.jsx)(`h3`,{className:`lp-time-label`,children:j(Of[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)(Ki,{"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)(Ts,{pager:oe,compact:!0})]}),!N&&!ce.some(e=>e.owner.taskId===r)&&B]})]})}var Nf=[`queued`,`running`];function Pf(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)(Ff,{...e},`${t.current.generation}:${e.agent.runId}:${e.agent.stepId??``}`)}function Ff({client:e,agent:t,backLabel:n,onBack:r,onOpenAgent:i}){let{t:a,tx:o}=D(),[s,c]=(0,m.useState)(1e3),l=vo(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?Nf.includes(d.status):!1;(0,m.useEffect)(()=>{u&&!Nf.includes(u.status)&&c(0)},[u]);let p=vo(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?Su(h):null,[h]),[v,y]=(0,m.useState)(!1),b=vo(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 qs(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)(pa,{"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)(Ju,{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)(ms,{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 If({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)(aa,{"aria-hidden":`true`}),(0,_.jsx)(`span`,{children:i||r(`Choose working folder`)})]})}function Lf({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 Rf(e,t,n){let r=new URL(window.location.origin+window.location.pathname),i=uo();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 zf(){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 Bf=`cadence-panel-layout-v1`,Vf={left:260,right:360,navigation:!0,inspector:!1};function Hf(e,t=600){return Math.max(220,Math.min(t,e))}function Uf(e){let t={...Vf};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]=Hf(r))}for(let e of[`navigation`,`inspector`]){let r=n[e];typeof r==`boolean`&&(t[e]=r)}}catch{}return t}function Wf(e,t){let n=e<=900,r=Hf(t.left,e-560),i=Hf(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:Hf(e-560-s),rightMaximum:Hf(e-560-a)}}function Gf({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(Hf(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(Hf(e===`left`?260:360,r)),onPointerDown:i=>{i.preventDefault(),a.current?.();let o=i.clientX,s=i=>{n(Hf(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 Kf=[],qf={error:Ma,warning:ja,info:$i};function Jf({toast:e}){let{t}=D(),[n,r]=(0,m.useState)(!1),[i,a]=(0,m.useState)(!1),o=n||i,s=Xo(e.level);(0,m.useEffect)(()=>{if(o||s===null)return;let t=setTimeout(()=>is(e.id),s);return()=>clearTimeout(t)},[o,s,e.id]);let c=qf[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:()=>is(e.id),children:(0,_.jsx)(Di,{"aria-hidden":`true`})})]})}function Yf(){let e=(0,m.useSyncExternalStore)(os,ss,()=>Kf);return(0,_.jsx)(`div`,{className:`notices`,children:e.map(e=>(0,_.jsx)(Jf,{toast:e},e.id))})}function Xf(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 Zf=.4,Qf=1.05;function $f(e){return Math.min(300,e*.86)}function ep(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function tp(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function np(e,t){return e===`left`?t:-t}function rp(e,t){return Math.max(-e,Math.min(0,-e+t))}function ip(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function ap(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:ip(r*Qf,n,t)>=Zf}var op=new Set([`auto`,`scroll`,`overlay`]);function sp(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&op.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function cp(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function lp(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=ep(r.clientX,window.innerWidth,n);i&&!sp(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=tp(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=$f(window.innerWidth),h=m*Qf;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=np(r,d);let b=rp(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(ip(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?ap({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(cp(),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 up={system:[Ui,`System`],light:[ji,`Light`],dark:[Hi,`Dark`]};function dp({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]=up[y],w=h(`Theme: {current}. Switch to {next}.`,{current:h(S),next:h(up[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 lp({enabled:T,open:E,onOpenChange:e.setDrawer,container:k}),Xf(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)(qi,{"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)(ra,{"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)(Vi,{"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)(Yi,{"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:Za?.buildId??h(`unbuilt source`),children:(0,_.jsx)(C,{text:h(`Local browser build: {build}.`),slots:{build:(0,_.jsx)(`code`,{children:Za?.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)(Gf,{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)(Gf,{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)(aa,{"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)(xa,{"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)(Yf,{})]})}function fp(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 pp({cache:e}){let{t}=D(),n=e?fp(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:wc(r.read),write:wc(r.write),miss:wc(r.miss),input:wc(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)(fa,{})}),(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 mp=31.42;function hp({usage:e}){let{t}=D(),n=e?.tokens??null,r=e?.window??null,i=n!==null&&r?Tc(n,r):null,a=e?n===null?t(`Context unknown after compaction`):r&&i!==null?t(`Context {used} / {window} · {percent}%`,{used:wc(n),window:wc(r),percent:i}):t(`Context {used} tokens`,{used:wc(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:mp,strokeDashoffset:+(mp*(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:wc(n)}),r&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(`span`,{className:`status-sep`,children:`/`}),(0,_.jsx)(`span`,{className:`ctx-max`,children:wc(r)})]})]})})]})}function gp({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 _p({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 vp(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 yp({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?vp(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 bp(){let[e,t]=(0,m.useState)(()=>{try{return Uf(localStorage.getItem(Bf))}catch{return Uf(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=Wf(n,e),s=(0,m.useCallback)(n=>{let r={...e,...n};t(r);try{localStorage.setItem(Bf,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 xp(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 Sp=`modulepreload`,Cp=function(e){return`/`+e},wp={},Tp=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=Cp(t,n),t=s(t),t in wp)return;wp[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`:Sp,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 Ep({client:e,seed:t,onSearch:n}){let{t:r}=D(),i=Bo(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)(Ts,{pager:i}),a&&!(`kind`in a)&&(0,_.jsx)(Dp,{client:e,seed:a.request,records:a.records,onSearch:n},`${a.request.snapshotSeq}:${a.request.after?.recordId??`first`}`)]})}function Dp({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 Tp(()=>import(`./timeline-client.js`).then(i=>{!e&&o.current&&(r=i.default.mount(o.current,xp(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)(Es,{client:e,seed:t})]})}var Op=[[`tools`,ki],[`context`,Qi],[`timeline`,va],[`runs`,ia]];function kp({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??Qa()),[y,b]=(0,m.useState)(()=>typeof window>`u`?``:window.location.hash),[x,S]=(0,m.useState)(!1),[C]=(0,m.useState)(zf),[w,T]=(0,m.useState)(C?.taskId??null),[E,O]=(0,m.useState)(()=>C?null:fo()??crypto.randomUUID()),k=mo(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=fo();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=Ao(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=No(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=bo(v.client,pe),ye=vo(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=vo(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=vo(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=co();(0,m.useEffect)(()=>{De&&fo()===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=bp(),{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?_o(t,e):t)})},ct=(0,m.useRef)(new Po),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?mo(location.hash,t).leaf:null;history.replaceState({cadenceCwd:je??Ee,cadenceConversationId:t},``,`${location.pathname}${location.search}${ho(`#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,``,Rf(e))};(0,m.useEffect)(()=>{let e=()=>{let e=zf();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=fo();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,``,Rf(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)(dp,{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)(Ki,{"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)(Ca,{"aria-hidden":`true`})]}),(0,_.jsxs)(`div`,{className:`view-menu-items`,children:[Op.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)(da,{"aria-hidden":`true`}),h(`Export selected scope`)]}),(0,_.jsxs)(`button`,{type:`button`,"aria-label":h(`Copy token-free link`),disabled:!w,onClick:()=>{w&&Uo(Rf(w,Qe,G?{scope:G,snapshotSeq:ze}:void 0)).then(e=>e?rs(`info`,h(`Link copied.`)):rs(`error`,h(`Link copy unavailable.`)))},children:[(0,_.jsx)(Zi,{"aria-hidden":`true`}),h(`Copy token-free link`)]})]})]})]})]}),actions:G&&(0,_.jsx)(zs,{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)(Lf,{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)(tc,{...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)(Mf,{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)(gc,{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,``,Rf(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)(Pf,{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)(Md,{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)(Ds,{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)(ws,{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)(Zs,{client:v.client,seed:mt}),Ge===`tools`&&(0,_.jsx)(Ap,{client:v.client,seed:mt}),Ge===`context`&&(0,_.jsx)(Es,{client:v.client,seed:mt}),Ge===`timeline`&&(0,_.jsx)(Ep,{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)(Fs,{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)(Rs,{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)(Fo,{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)(aa,{"aria-hidden":`true`}),h(`Files`)]}),E&&(0,_.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-pressed":Ie,onClick:()=>re(`branches`),children:[(0,_.jsx)(ia,{"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)(Qi,{"aria-hidden":`true`}),h(`History details`)]})]}),inspector:Ie?(0,_.jsx)(Sc,{view:ie?.id===E?ie:void 0,onChosen:Fe}):Le?(0,_.jsx)(qd,{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)(rf,{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)(_p,{tip:h(`Connection freshness is not execution outcome.`),dot:Ot,latency:Ot===`ok`||Ot===``?ke:null,children:g(Dt)}),s&&(0,_.jsx)(gp,{tone:`faint`,icon:(0,_.jsx)(Fi,{}),children:h(`Execution service: {status}`,{status:g(q.readiness)})}),Oe&&(0,_.jsx)(hp,{usage:Oe.context}),Oe&&(0,_.jsx)(pp,{cache:Oe.cache}),Oe&&Oe.turns>0&&(0,_.jsx)(gp,{icon:(0,_.jsx)(Ki,{}),tip:h(`Turns in this conversation: {count}`,{count:Oe.turns}),children:Oe.turns}),Oe&&Oe.runningSince!==null&&(0,_.jsx)(yp,{since:Oe.runningSince,label:h(`Working`)}),bt?.status===`complete`?xt.length>0&&(0,_.jsx)(gp,{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)(gp,{tone:`faint`,children:h(`Active roster unavailable; absence is not proof of settlement.`)})]}),folder:(Y.workspace||s)&&(0,_.jsx)(If,{path:je,onClick:()=>c?c(je):ne(``)})}),M!==null&&Y.workspace&&(0,_.jsx)(cf,{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)(Ps,{client:v.client,seed:ht,onClose:()=>qe(!1),onHit:e=>{Ze(e),$e(e.cursor),w&&history.replaceState(null,``,Rf(w,e.cursor,G?{scope:G,snapshotSeq:ze}:void 0))}}),Je&&ht&&(0,_.jsx)(js,{request:{storeId:ht.storeId,scope:ht.scope,snapshotSeq:ht.snapshotSeq,format:`ndjson`},onClose:()=>Ye(!1)})]})}function Ap({client:e,seed:t}){let n=Bo(e,{...t,reader:`tools`}),r=n.page;return(0,_.jsxs)(`section`,{className:`tools-list`,children:[(0,_.jsx)(Ts,{pager:n}),(0,_.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,_.jsx)($s,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var jp=`cadence:folder-draft`,Mp=()=>({text:``,model:null});function Np(){try{let e=JSON.parse(sessionStorage.getItem(`cadence:folder-draft`)??`null`);if(!e||typeof e.text!=`string`)return Mp();let t=null;try{e.model!=null&&(t=ge(e.model))}catch{}return{text:e.text,model:t}}catch{return Mp()}}function Pp(e){try{e.text||e.model?sessionStorage.setItem(jp,JSON.stringify(e)):sessionStorage.removeItem(jp)}catch{}}function Fp(e,t,n){let r=Qc(`checkout:${e}`,t);try{sessionStorage.setItem(r,n.text),n.model&&sessionStorage.setItem(`${r}:model`,JSON.stringify(n.model)),sessionStorage.removeItem(jp)}catch{}return{...n,conversationId:t}}var Ip=`cadence-last-project`;function Lp(){try{let e=localStorage.getItem(Ip);return e&&/^[a-f0-9]{64}$/.test(e)?e:null}catch{return null}}function Rp(e){try{localStorage.getItem(`cadence-last-project`)!==e&&localStorage.setItem(Ip,e)}catch{}}function zp(e){let t=Lp();return t?e.projects.find(e=>e.id===t):void 0}async function Bp(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 xo(n));return(r.workspaceId!==null||r.status===`not-started`)&&!t.aborted}catch{return!1}}async function Vp(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 xo(n);if(!n.ok)throw Error(So(r));return Sn(r)}async function Hp(e){let t=await fetch(`/workbench/v1`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:e}),n=await xo(t);if(!t.ok)throw Error(So(n));return An(n)}async function Up(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 xo(s);if(!s.ok)throw Co(c);if(!c||typeof c!=`object`||!(`kind`in c)||c.kind!==`project`||!(`project`in c))throw Error(So(c));let l=wn(c.project);return{project:l,entry:{...n,projects:[...n.projects.filter(e=>e.id!==l.id),l]}}}async function Wp(e,t){let n=await Hp(t);return Up(`/workbench/v1/select`,{path:e},n,t)}async function Gp(e,t,n,r,i){let a=await Hp(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 Up(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 Kp(e,t,n){if(!t.sessionId||t.history!==`shared`)throw Error(`unavailable`);let r=await Wp(t.cwd,n);if(n.aborted||r.project.path!==e||r.project.cwd!==t.cwd)throw Error(`stale`);return r}var qp=[`turn`,`queued`,`running`,`research`,`implementing`,`verifying`,`reviewing`,`recovering`,`learning`,`integrating`,`stopping`,`settling`];function Jp(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,qp),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 Yp(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,Jp)}})}}async function Xp(e){let t=La([e],12e3);try{let e=await fetch(`/workbench/v1/activity`,{credentials:`same-origin`,redirect:`error`,cache:`no-store`,signal:t.signal}),n=await xo(e);if(!e.ok)throw Error(So(n));return Yp(n)}finally{t.dispose()}}function Zp(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 Qp(e,t,n,r=Xp){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?Zp(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 $p(e,t){let[n,r]=(0,m.useState)(),[i,a]=(0,m.useState)(``);return(0,m.useEffect)(()=>{if(r(void 0),a(``),e)return Qp(e,(e,t)=>{r(e),a(t)},t)},[e,t]),{value:n,error:i}}function em({ready:e,previewModels:t,draft:n=Mp(),onDraftChange:r,restore:i,onChooseFolder:a,onRefresh:o,onOpenService:s,notices:c,discovery:l}){let{t:u}=D(),d=bp(),[f,p]=(0,m.useState)(!1),h=ml(null,{status:`not-started`},`folder-setup`,t),g=()=>{d.closeDrawer(),a()};return(0,_.jsx)(dp,{panels:d,onRefresh:o,onOpenService:s,notices:c,navigation:(0,_.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,_.jsx)(hf,{disabled:!e,onConversation:g}),l&&(0,_.jsx)(tc,{...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)(Yu,{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)(aa,{"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)(Yl,{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.preview&&!h.loading&&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)(Ea,{"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)(gp,{tone:`faint`,children:u(`Choose a working folder`)}),folder:(0,_.jsx)(If,{disabled:!e,onClick:g})})}var tm=`cadence-recovery-dismissed`,nm={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.`},rm={"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 im(){try{let e=JSON.parse(localStorage.getItem(tm)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function am(e){return e.split(/[\\/]/).filter(Boolean).at(-1)??e}function om({notices:e,project:t}){let{t:n}=D(),[r,i]=(0,m.useState)(im),[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(tm,JSON.stringify(e))}catch{}i(e)},u=e=>e.scope===`project`&&e.path?n(`Folder {name}`,{name:am(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(nm[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(rm[t],{count:e.workers})).join(` `),e.archived&&` ${n(`Archived files are kept for 30 days; cadence doctor shows where.`)}`]},e.id))})]})}var sm={restart:18e4,upgrade:12e5},cm=1e3,lm={"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.`},um=e=>e instanceof Error?e.message:`unavailable`;function dm(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(lm[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 fm(e){return e.state===`failed`?e.reason===`fetch-failed`||e.reason===`refused`:e.state===`ready`&&e.action===`upgrade`&&e.version===e.from}function pm(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 mm({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 To(e.signal).then(a,t=>{e.signal.aborted||s(um(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>sm[e.action])return w(`timeout`);try{let t=await To(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,cm)};return r=setTimeout(i,cm),()=>{n.abort(),clearTimeout(r)}},[v]);let O=()=>{l(`checking`),Eo().then(l,()=>l(`failed`)).finally(()=>E(e=>e+1))},k=n=>{i&&(g(!0),s(``),Do({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(um(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`&&fm(C),o=i?.unit;return(0,_.jsxs)(As,{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:sm[e.action]/6e4}):C===`changed`?r(`Cadence answered with a different version.`):dm(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)(As,{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)(As,{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:pm(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:dm(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)(Da,{"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 hm(){let{t:e}=D(),[t,n]=(0,m.useState)(),[r,i]=(0,m.useState)(Np),[a,o]=(0,m.useState)(),s=(0,m.useCallback)(e=>{o(t=>t?.conversationId===e?void 0:t)},[]),[c,l]=(0,m.useState)(uo),u=(0,m.useCallback)(e=>Vp(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=$p(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 xo(t);t.status===400&&So(r)===`invalid`?n(null):t.ok?(n(An(r)),b(``)):b(So(r))}catch{e.signal.aborted||b(`unavailable`)}})(),()=>e.abort()},[x]),(0,m.useEffect)(()=>{let e=()=>{ee.current?.abort(),ne(),O(null),l(uo())};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=zp(t);if(!e)return;let n=new AbortController;M.current=n,O({status:`checking`,path:e.cwd}),Bp(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(Fp(e.path,a,r)),i(Mp())):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 Wp(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(``),Kp(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 Gp(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 xo(n);if(!n.ok){let e=So(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?Qa(c):void 0,[c]),R=t?.projects.find(e=>e.id===c);if((0,m.useEffect)(()=>{R&&Rp(R.id)},[R]),t===null)return(0,_.jsx)(kp,{});let z=t&&w&&(0,_.jsx)(mm,{epoch:t.epoch,csrf:t.csrf,onClose:()=>T(!1)}),B=()=>T(!0),V=t&&d!==null&&(0,_.jsx)(cf,{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)(kp,{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)(om,{notices:t.recoveries,project:R.path}),` `]}),onOpenService:B},R.id),z,V]}):(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(em,{discovery:ie,ready:!!t,previewModels:t?u:void 0,draft:r,onDraftChange:e=>{ne(),i(e),Pp(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)(om,{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 gm(){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 _m=class extends m.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,_.jsx)(gm,{}):this.props.children}};te(j());var vm=document.getElementById(`root`);if(!vm)throw Error(`Application root unavailable`);(0,h.createRoot)(vm).render((0,_.jsx)(O,{children:(0,_.jsx)(_m,{children:(0,_.jsx)(hm,{})})}));export{Tp as t};
|