@abelxiaoxing/cadence 2.0.18 → 2.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/conversation-context.mjs +22 -9
- package/src/service-host.mjs +22 -13
- package/web/dist/assets/cadence.js +1 -1
- package/web/dist/manifest.json +3 -3
package/package.json
CHANGED
|
@@ -21,6 +21,26 @@ function argumentsData(value, secrets) {
|
|
|
21
21
|
if (sanitizer.limited) throw new Error("Unsupported context arguments");
|
|
22
22
|
return parseWireJson(source, 64 * 1024);
|
|
23
23
|
}
|
|
24
|
+
function own(value, key) {
|
|
25
|
+
const d =
|
|
26
|
+
value && typeof value === "object"
|
|
27
|
+
? Object.getOwnPropertyDescriptor(value, key)
|
|
28
|
+
: undefined;
|
|
29
|
+
if (!d || !("value" in d)) throw new Error("Invalid usage");
|
|
30
|
+
return d.value;
|
|
31
|
+
}
|
|
32
|
+
// Pi adds optional usage breakdowns per provider and release (reasoning, cacheWrite1h);
|
|
33
|
+
// retain only the counts every assistant message carries, read as own data properties.
|
|
34
|
+
function counts(value, keys) {
|
|
35
|
+
const out = Object.create(null);
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
const n = own(value, key);
|
|
38
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < 0)
|
|
39
|
+
throw new Error("Invalid usage");
|
|
40
|
+
out[key] = n;
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
24
44
|
/** Deliberately retain text and tool exchanges, not just last assistant prose. */
|
|
25
45
|
export function conversationMessages(messages, secrets = []) {
|
|
26
46
|
return list(messages, 4096, (message) => {
|
|
@@ -54,27 +74,20 @@ export function conversationMessages(messages, secrets = []) {
|
|
|
54
74
|
toolName: clean(message.toolName, secrets, 128),
|
|
55
75
|
isError: message.isError === true,
|
|
56
76
|
};
|
|
57
|
-
const usage =
|
|
77
|
+
const usage = counts(message.usage, [
|
|
58
78
|
"input",
|
|
59
79
|
"output",
|
|
60
80
|
"cacheRead",
|
|
61
81
|
"cacheWrite",
|
|
62
82
|
"totalTokens",
|
|
63
|
-
"cost",
|
|
64
83
|
]);
|
|
65
|
-
|
|
84
|
+
usage.cost = counts(own(message.usage, "cost"), [
|
|
66
85
|
"input",
|
|
67
86
|
"output",
|
|
68
87
|
"cacheRead",
|
|
69
88
|
"cacheWrite",
|
|
70
89
|
"total",
|
|
71
90
|
]);
|
|
72
|
-
for (const value of [
|
|
73
|
-
...Object.values(usage).filter((v) => typeof v !== "object"),
|
|
74
|
-
...Object.values(cost),
|
|
75
|
-
])
|
|
76
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
77
|
-
throw new Error("Invalid usage");
|
|
78
91
|
return {
|
|
79
92
|
role,
|
|
80
93
|
timestamp,
|
package/src/service-host.mjs
CHANGED
|
@@ -21944,6 +21944,22 @@ function argumentsData(value, secrets) {
|
|
|
21944
21944
|
throw new Error("Unsupported context arguments");
|
|
21945
21945
|
return parseWireJson(source, 64 * 1024);
|
|
21946
21946
|
}
|
|
21947
|
+
function own(value, key2) {
|
|
21948
|
+
const d = value && typeof value === "object" ? Object.getOwnPropertyDescriptor(value, key2) : undefined;
|
|
21949
|
+
if (!d || !("value" in d))
|
|
21950
|
+
throw new Error("Invalid usage");
|
|
21951
|
+
return d.value;
|
|
21952
|
+
}
|
|
21953
|
+
function counts(value, keys3) {
|
|
21954
|
+
const out = Object.create(null);
|
|
21955
|
+
for (const key2 of keys3) {
|
|
21956
|
+
const n = own(value, key2);
|
|
21957
|
+
if (typeof n !== "number" || !Number.isFinite(n) || n < 0)
|
|
21958
|
+
throw new Error("Invalid usage");
|
|
21959
|
+
out[key2] = n;
|
|
21960
|
+
}
|
|
21961
|
+
return out;
|
|
21962
|
+
}
|
|
21947
21963
|
function conversationMessages(messages, secrets = []) {
|
|
21948
21964
|
return list(messages, 4096, (message) => {
|
|
21949
21965
|
if (!message || typeof message !== "object")
|
|
@@ -21973,27 +21989,20 @@ function conversationMessages(messages, secrets = []) {
|
|
|
21973
21989
|
toolName: clean(message.toolName, secrets, 128),
|
|
21974
21990
|
isError: message.isError === true
|
|
21975
21991
|
};
|
|
21976
|
-
const usage =
|
|
21992
|
+
const usage = counts(message.usage, [
|
|
21977
21993
|
"input",
|
|
21978
21994
|
"output",
|
|
21979
21995
|
"cacheRead",
|
|
21980
21996
|
"cacheWrite",
|
|
21981
|
-
"totalTokens"
|
|
21982
|
-
"cost"
|
|
21997
|
+
"totalTokens"
|
|
21983
21998
|
]);
|
|
21984
|
-
|
|
21999
|
+
usage.cost = counts(own(message.usage, "cost"), [
|
|
21985
22000
|
"input",
|
|
21986
22001
|
"output",
|
|
21987
22002
|
"cacheRead",
|
|
21988
22003
|
"cacheWrite",
|
|
21989
22004
|
"total"
|
|
21990
22005
|
]);
|
|
21991
|
-
for (const value of [
|
|
21992
|
-
...Object.values(usage).filter((v) => typeof v !== "object"),
|
|
21993
|
-
...Object.values(cost)
|
|
21994
|
-
])
|
|
21995
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0)
|
|
21996
|
-
throw new Error("Invalid usage");
|
|
21997
22006
|
return {
|
|
21998
22007
|
role: role2,
|
|
21999
22008
|
timestamp,
|
|
@@ -24852,7 +24861,7 @@ class TaskActions {
|
|
|
24852
24861
|
const graph = action.kind === "start" ? plan?.graph ?? this.defaultGraph(selected2.record, selected2.identity, expected.model) : null;
|
|
24853
24862
|
if (graph && hash2(canonicalJson(graph)) !== expected.task.graphIdentity)
|
|
24854
24863
|
throw new ContractError("stale");
|
|
24855
|
-
let
|
|
24864
|
+
let own3 = {
|
|
24856
24865
|
revision: selected2.record.revision,
|
|
24857
24866
|
identity: selected2.identity
|
|
24858
24867
|
};
|
|
@@ -24882,7 +24891,7 @@ class TaskActions {
|
|
|
24882
24891
|
try {
|
|
24883
24892
|
this.assertChoice(expected);
|
|
24884
24893
|
const latest = h.coordination.store.loadSnapshot(action.taskId);
|
|
24885
|
-
return latest?.identity ===
|
|
24894
|
+
return latest?.identity === own3.identity && latest.record.revision === own3.revision && this.sources.current();
|
|
24886
24895
|
} catch {
|
|
24887
24896
|
return false;
|
|
24888
24897
|
}
|
|
@@ -24910,7 +24919,7 @@ class TaskActions {
|
|
|
24910
24919
|
});
|
|
24911
24920
|
if (publication.status !== "published" || !publication.observed)
|
|
24912
24921
|
throw new ContractError("conflict");
|
|
24913
|
-
|
|
24922
|
+
own3 = publication.observed;
|
|
24914
24923
|
}
|
|
24915
24924
|
});
|
|
24916
24925
|
accepted2.activate(work);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
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={"The shared registry lock is blocking projects. On the service host, run cadence recover inspect --workspace <project> with the same --state-home, then use recover resolve in a local terminal if eligible. Do not delete lock files manually.":`共享注册表锁正在阻止项目打开。请在服务所在主机运行 cadence recover inspect --workspace <project>,使用相同的 --state-home;符合恢复条件时,在本机终端运行 recover resolve。请勿手动删除锁文件。`,"Start a conversation from the sidebar.":`从左侧开启一段新对话。`,"Conversations are kept with each project. Open a working folder to see its history.":`历史对话按项目保存。打开工作文件夹后,即可查看它的历史对话。`,"Conversations are kept with each project. Choose a project below and open it to see its history.":`历史对话按项目保存。在下方选择项目并打开,即可查看它的历史对话。`,"Returning to your last project {name}…":`正在回到上次的项目 {name}…`,"Your last project {name} is not running. Choose it below and open it again to see its conversations.":`上次的项目 {name} 当前未运行。在下方选择它并重新打开,即可查看它的对话。`,"Choose a working folder at the bottom right to start chatting.":`在右下角选择工作文件夹,即可开始对话。`,"Files appear here after you open a working folder.":`打开工作文件夹后,在这里浏览文件。`,"No working folder selected":`未选择工作文件夹`,"Task created, but its conversation link was not confirmed.":`任务已创建,但与普通对话的关联尚未确认。`,"Workbench projects":`工作台项目`,"Your workbench, your projects":`你的工作台,你的项目`,"No default workspace is created. Open an existing folder to use ordinary conversations and Cadence tasks.":`不会创建默认工作区。打开已有文件夹,即可使用普通对话和 Cadence 任务。`,"Opening a project never starts a task. Switching projects keeps admitted work running in its original directory.":`打开项目不会启动任务。切换项目后,已接纳的工作仍在原目录中继续。`,"Selected project is unavailable. Choose a project explicitly; no directory was reconstructed.":`所选项目不可用,请明确选择项目;未重建任何目录。`,"No projects associated yet.":`尚未关联任何项目。`,"Chat ready":`可以开始对话`,"Conversation capture limit exceeded.":`对话记录已达到容量上限。`,"Start a new conversation; incomplete context is not replayed.":`请新建对话;不会重放不完整的上下文。`,"Current metadata unavailable; showing the active turn only. No state was reconstructed.":`当前对话元数据不可用,仅显示仍在运行的轮次,未重建任何状态。`,"Send unavailable. Check the message limit (16 KiB); observe any pending command before sending again.":`暂时无法发送。请检查消息是否超过 16 KiB;如有待确认的命令,请先观察其结果,不要重复发送。`,Files:`文件`,"File list":`文件列表`,"Workspace panels":`工作区面板`,"Task details":`任务详情`,"Switch working folder":`切换工作文件夹`,"Open working folder":`打开工作文件夹`,"Open this folder":`打开此文件夹`,"Opening folder…":`正在打开文件夹…`,"Will open:":`将打开:`,"Open {path}":`打开 {path}`,"Folder path":`文件夹路径`,"Type or paste a path, then press Enter":`输入或粘贴路径,按回车前往`,"Edit path":`输入路径`,"Current location":`当前位置`,"Home folder":`主目录`,"Home folder (~)":`主目录(~)`,"Filter folders":`筛选文件夹`,"Filter this folder…":`筛选当前文件夹…`,"Reading folder…":`正在读取文件夹…`,"No matching folders.":`没有匹配的文件夹。`,"No subfolders.":`没有子文件夹。`,"Enter a full path, for example ~/project.":`请输入完整路径,例如 ~/project。`,"This folder does not exist. Check the path.":`找不到这个文件夹,请检查路径。`,"This location cannot be browsed: it belongs to another account, is protected, or is not a plain folder (for example a link).":`无法浏览这个位置:它属于其他账户、受保护,或不是普通文件夹(例如符号链接)。`,"This folder could not be read right now; it may lack read permission. Try again.":`暂时无法读取这个文件夹,可能没有读取权限,请重试。`,"Parent folder":`上级文件夹`,"Choose a folder on the service host. Opening reuses or starts that project's independent service; current work keeps running.":`选择服务所在主机上的文件夹。打开时将复用或启动该项目的独立服务,当前工作会继续运行。`,"New conversation":`新对话`,Ordinary:`普通对话`,"Ordinary conversation":`普通对话`,"Cadence task":`Cadence 任务`,"Conversation mode":`对话模式`,"Back to ordinary conversation":`返回普通对话`,"What would you like to work on?":`今天想做些什么?`,"Chat normally, or start with /cadence to prepare a task. Nothing starts until you send.":`直接聊天,或以 /cadence 开头准备任务。发送前不会启动任何工作。`,"Message, or /cadence followed by a task…":`输入消息,或使用 /cadence 描述任务…`,Message:`消息`,Send:`发送`,"Stop response":`停止回复`,"Prepare task":`准备任务`,"Analyzing task…":`正在分析任务…`,"Send to begin analysis. You will confirm the plan before any edits.":`发送后开始分析,修改代码前会请你确认计划。`,"Task preparation unavailable. Observe the original receipt before sending again.":`任务准备不可用,请先查看原始请求结果,不要重复发送。`,"Task preparation stopped: {reason}. Observe the original receipt; no automatic retry.":`任务准备已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Plan approval":`计划确认`,"Plan metadata read in progress. Try again after observation completes.":`计划信息仍在读取,请等状态更新后再试。`,"This task already has a plan. Review it in Task details instead.":`此任务已有计划,请在任务详情中查看,避免覆盖现有计划。`,"Analysis complete. Review the plan before making changes.":`分析完成,请在修改代码前确认计划。`,"Analysis and progress appear below. No edits start before plan approval.":`分析过程与进度显示在下方,确认计划前不会修改代码。`,"Review implementation plan":`查看实施计划`,"Confirm plan and execute":`确认计划并执行`,"Approving saves this exact plan and starts it. No separate Start confirmation is needed.":`确认后将保存并执行当前计划,无需再次点击启动。`,"Context changed. Close and review the plan again.":`任务上下文已变化,请关闭后重新查看计划。`,"Plan confirmation expired. Review the plan again.":`计划确认已过期,请重新查看计划。`,"Plan execution stopped: {reason}. Observe the original receipt; no automatic retry.":`计划执行流程已停止:{reason}。请查看原始请求结果,不会自动重试。`,"Prepare a plan first; Start requires confirmation.":`先准备计划,执行需另行确认 Start。`,"Direct host tools · no Cadence task":`直接使用主机工具 · 不创建 Cadence 任务`,"Conversation turn":`对话轮次`,You:`你`,Tool:`工具`,"Earlier messages":`较早的消息`,"Latest messages":`最新消息`,"Send outcome not yet observed:":`尚未观察到此次发送的结果:`,"Observe this send before sending again. No automatic retry.":`请先观察此次发送的结果,不会自动重试。`,"This turn has no complete continuation context. Start a new conversation; retained messages are preserved.":`此轮没有完整的续聊上下文。请新建对话,已记录的消息会保留。`,Subagents:`子代理`,"Subagent roster unavailable":`暂时无法观察子代理列表`,"Cadence subagents appear here when a task runs.":`Cadence 任务运行时,子代理会显示在这里。`,"Refresh files":`刷新文件`,"Reference {path}":`引用 {path}`,"Copy path {path}":`复制路径 {path}`,"No visible files":`没有可显示的文件`,"Close preview":`关闭预览`,"Bounded listing; narrow the directory to see more.":`列表已达到显示上限,请进入更具体的目录查看。`,"File preview is limited; this is not the complete file.":`文件预览已截断,并非完整内容。`,"Readonly preview · references send paths, not file contents":`只读预览 · 引用只发送路径,不自动注入文件内容`,"Hidden thinking, signatures and media are not retained.":`隐藏思考、签名和媒体内容不予保留。`,"Cadence task workspace":`Cadence 任务工作区`,"Presentation unavailable":`界面无法显示`,"No execution result is inferred. Reconnect to observe the owner; accepted work continues.":`不会推断任何执行结果。重新连接以观察所有者服务;已接受的工作会继续进行。`,"Reload observation":`重新加载观察`,"Build information":`构建信息`,Conversation:`对话`,Details:`详情`,"Back to task":`返回任务`,"Task {id}":`任务 {id}`,"{kind} {id}":`{kind} {id}`,Subagent:`子代理`,"Recorded conversation":`已记录对话`,"Recording details":`记录信息`,"Field details":`原文与复制`,"New activity — update conversation":`有新动态 · 更新对话`,"No retained conversations on this page.":`本页没有已保留的对话。`,"Recent projects":`最近项目`,"This service exposes one project. Opening it never starts work.":`当前服务连接一个项目,打开项目不会启动执行。`,"Running conversations":`运行的对话`,"Conversation history":`历史对话`,"Task conversations":`任务对话与子代理`,Tasks:`任务`,"Recorded views":`已记录视图`,messages:`消息`,tools:`工具`,context:`上下文`,timeline:`时间线`,runs:`运行`,"Export selected scope":`导出所选范围`,"Copy token-free link":`复制不含令牌的链接`,"Link copy unavailable.":`无法复制链接。`,"Observe current state":`重新观察当前状态`,"Choose owner model":`选择所有者模型`,Model:`模型`,"Return — work continues":`返回——工作继续`,"Return — accepted work continues":`返回——已接受的工作会继续`,Return:`返回`,"Plan / review":`计划 / 审阅`,Plan:`计划`,"Execution and cancellation":`执行与取消`,"Open active task":`打开活动任务`,"Cancel run — request stop":`取消运行——请求停止`,"{message}.":`{message}。`,"Context changed. Observe again and request a fresh confirmation.":`上下文已变化。请重新观察并请求新的确认。`,"Explicit service guidance: {status} / {start}. No service is started by this page.":`显式服务操作:{status} / {start}。本页面不会启动任何服务。`,"Close drawer":`关闭抽屉`,"Task navigation drawer":`任务导航抽屉`,"Plan and review drawer":`计划与审阅抽屉`,"Selected {kind}:":`已选{kind}:`,"· snapshot {seq}.":`· 快照 {seq}。`,"Pages and old outcomes are historical observations, not renewed consent.":`分页内容和旧结果是历史观察,不代表重新授权。`,"Open a task or create one explicitly":`打开一个任务,或显式创建一个`,"Plans, children, checks and human review share one service owner. No chat or discovery activates execution.":`计划、子运行、检查和人工审阅共用一个服务所有者。聊天或浏览不会触发执行。`,"Create task":`创建任务`,"Runs in the current snapshot":`当前快照中的运行`,"Retained runs":`已保留的运行记录`,"No owner run projection in this snapshot.":`此快照中没有所有者运行视图。`,"No snapshot observed yet; absence is not proof of settlement.":`尚未观察到快照;没有记录不代表已结束。`,"Connection freshness is not execution outcome.":`连接是否最新不代表执行结果。`," · transport {status}":` · 传输:{status}`,"{count} active run":`{count} 个活动运行`,"{count} active runs":`{count} 个活动运行`,"No active runs":`没有活动运行`,"Active roster unavailable; absence is not proof of settlement.":`活动运行列表不可用;没有记录不代表已结束。`,"unbuilt source":`未构建的源码`,"Local browser build: {build}.":`本地浏览器构建:{build}。`,"Shared compatibility: {state}.":`共享兼容性:{state}。`,compatible:`兼容`,"unavailable / mismatch — reload built assets; normal actions disabled":`不可用 / 不匹配——请重新加载构建产物;常规操作已禁用`,"Service unavailable":`服务不可用`,"Task snapshot not observed yet":`尚未观察到任务快照`,"No task selected":`未选择任务`,"Resize left pane":`调整左侧面板宽度`,"Resize right pane":`调整右侧面板宽度`,Detached:`已断开`,"Accepted service work continues. No Cancel was requested.":`已接受的服务工作会继续进行。没有请求取消。`,"Observe command after reconnect:":`重新连接后观察命令:`,"Reconnect as a viewer":`以查看者身份重新连接`,"Current action context unavailable; observe again.":`当前操作上下文不可用;请重新观察。`,"Preflight refused: {code}":`预检被拒绝:{code}`,"Preflight unavailable. No automatic retry.":`预检不可用。不会自动重试。`,"Stop requested; settlement is not yet confirmed.":`已请求停止;尚未确认结束。`,"{code}; cancellation effect {effect}. Observe exact receipt.":`{code};取消效果 {effect}。请观察确切回执。`,"Cancellation effect uncertain. Observe exact receipt.":`取消效果不确定。请观察确切回执。`,"Observation unavailable or detach unconfirmed; explicit re-entry required.":`观察不可用或断开未确认;需要显式重新进入。`,"Observation unavailable.":`观察不可用。`,"Access revoked; explicit token re-entry required.":`访问已被撤销;需要显式重新输入令牌。`,Kind:`类型`,Code:`代码`,"Readonly research":`只读调研`,"Readonly diagnosis":`只读诊断`,Goal:`目标`,"Preview Create (does not Start)":`预览创建(不会启动)`,"Close dialog — no cancellation of accepted work":`关闭对话框——不会取消已接受的工作`,"Close — accepted work is not cancelled":`关闭——不会取消已接受的工作`,"Admission pending/unknown — observe this exact receipt.":`准入待定/未知——请观察这个确切回执。`,"{code}; effect {effect}":`{code};效果 {effect}`,"Uncertain; do not repeat the action.":`结果不确定;请勿重复此操作。`,"Confirm {action}":`确认{action}`,"Access is not consent. This confirmation applies only to the displayed context, once.":`访问权限不等于同意。此确认仅对所显示的上下文生效一次。`,Checkout:`工作副本`,"Working directory":`工作目录`,"Model / API / thinking":`模型 / API / 思考`,"Check environment":`检查环境`,"Service launch environment policy, generation {generation}; no browser environment overlays.":`服务启动环境策略,第 {generation} 代;不叠加浏览器环境。`,Observation:`观察`,"Complete within bounded scope":`在限定范围内完整`,"Incomplete bounded coverage":`限定范围覆盖不完整`,Expires:`过期时间`,"Exact parent check":`确切的父级检查`,"{name}; timeout {timeout} ms; cwd above.":`{name};超时 {timeout} 毫秒;工作目录见上。`,"Readonly proposal only. It will not save itself or dispatch editing.":`仅为只读提案。它不会自行保存,也不会分派编辑。`,"Issues: {issues}":`问题:{issues}`,"Context changed or confirmation expired. Close, observe again and request a new preview.":`上下文已变化或确认已过期。请关闭、重新观察并请求新的预览。`,"Back — no new effect":`返回——不产生新效果`,"Create {kind} task":`创建{kind}任务`,"No Start is included.":`不包含启动。`,"Expected: {output}":`预期产出:{output}`,"Exact proposed graph and identities (not yet committed)":`确切的提议任务图与标识(尚未提交)`,"Exact human review targets":`确切的人工审阅对象`,"Human review only; failures, native exit, stale and not-run checks remain unchanged. Issues acknowledgment: {accepted}.":`仅为人工审阅;失败、原生退出、过期和未运行的检查保持不变。问题确认:{accepted}。`,"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.":`计划提案不可用。`,"Current plan metadata unavailable. Observe again; historical text is not action authority.":`当前计划元数据不可用。请重新观察;历史文本不能作为操作依据。`,"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.":`请求审阅前,请先在“检查”中观察当前检查项。`,"Readable plan & decomposition":`可读计划与分解`,"{count} required assignments":`{count} 个必需子任务`,"Preview readonly Generate proposal":`预览只读生成提案`,"Preview Save plan":`预览保存计划`,"Preview Start saved graph":`预览启动已保存的任务图`,"Draft changes never execute. Start uses the saved graph shown in its fresh preview, not unsaved text. Generated proposals never save or start themselves.":`草稿修改永远不会执行。启动使用其最新预览中显示的已保存任务图,而不是未保存的文本。生成的提案不会自行保存或启动。`,"Saved assignments name an old model selection. Reading does not rebind them.":`已保存的子任务指定了旧的模型选择。读取不会重新绑定它们。`,"Explicitly rebind draft to current model (requires new Save)":`将草稿显式重新绑定到当前模型(需要重新保存)`,"Readable plan":`可读计划`,"Read rendered plan":`阅读渲染后的计划`,"checkout writer":`工作副本写入者`,readonly:`只读`,Edit:`编辑`,"Remove draft assignment":`移除草稿子任务`,Purpose:`用途`,Instructions:`指令`,"Expected output":`预期产出`,"Current-episode dependencies (whole final text by default)":`本轮依赖(默认使用完整最终文本)`,"Require complete observation":`要求完整观察`,"Selection: {range}":`选择范围:{range}`,"reviewed UTF-8 bytes {start}–{end}":`已审阅的 UTF-8 字节 {start}–{end}`,"whole final text; no silent clipping":`完整最终文本;不会静默截断`,"Reviewed edge JSON (range/null and exact historical identity)":`已审阅的依赖边 JSON(范围/null 与确切历史标识)`,"Remove edge":`移除依赖边`,"Explicit historical/advisory edge JSON":`显式的历史/参考依赖边 JSON`,"Exact committed run/child/result/version plus range and coverage requirement":`确切的已提交运行/子运行/结果/版本,以及范围和覆盖要求`,"Add reviewed historical edge":`添加已审阅的历史依赖边`,"Discard inline edits":`放弃行内编辑`,"Apply to local draft":`应用到本地草稿`,"Role {role}":`角色 {role}`,"Add assignment":`添加子任务`,"Remove dependent edges explicitly before deleting this assignment.":`删除此子任务前,请先显式移除依赖它的边。`,"Invalid dependency. Original edge retained; review before Save.":`依赖无效。已保留原依赖边;请在保存前审阅。`,"Historical edge requires actual committed identity; no guessed result reference.":`历史依赖边需要真实的已提交标识;不接受猜测的结果引用。`,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":`清除选择`,"Current configured obligations":`当前已配置的检查项`,"Observe obligations":`观察检查项`,"Obligations unavailable: {error}":`检查项不可用:{error}`,"Obligations unavailable.":`检查项不可用。`,"No configured obligations. This is not passing check coverage.":`没有已配置的检查项。这不代表检查已通过。`,"Timeout {timeout} ms. Native outcome and freshness remain separate.":`超时 {timeout} 毫秒。原生结果与是否最新分别记录。`,"Preview exact configured check":`预览确切的已配置检查`,"Browser checks are configured selections only. Native-local manual commands are not a browser shell endpoint.":`浏览器中只能运行已配置的检查。本地原生手动命令不是浏览器 shell 端点。`,"Current checkout changes":`当前工作副本变更`,"Current checkout changes (not a captured historical diff)":`当前工作副本变更(不是捕获的历史 diff)`,"Observe current changes":`观察当前变更`,"Current observation unavailable":`当前观察不可用`,"Fingerprint {identity} · {coverage} · includes pre-existing dirt; not attribution.":`指纹 {identity} · {coverage} · 包含既有的未提交修改;不代表归属。`,"complete within bounded scope":`在限定范围内完整`,"incomplete coverage":`覆盖不完整`,"Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.":`捕获的观察包含既有的未提交修改。它们不会把每处变更都归于 Cadence;限定指纹不是文件系统快照。`,"committed #{seq}":`已提交 #{seq}`,"Inspect full retained {field}":`查看完整保留的{field}`,"Copy displayed text":`复制显示的文本`,"Copy unavailable":`无法复制`,"{state} message record, not execution outcome":`{state}消息记录,不代表执行结果`,Collapse:`收起`,"Inspect message":`查看消息`,"Child {child} · message {message} · version {version}":`子运行 {child} · 消息 {message} · 版本 {version}`,"Result call: {call}. Kept visible independently of the tool card.":`结果对应调用:{call}。独立于工具卡片保持可见。`,"unassociated / orphan":`未关联 / 孤立`,"No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.":`此快照中没有最终文本字段。请在下方查看保留的部分/最终块以及省略元数据。`,"All message blocks, source limits and tool associations":`全部消息块、来源限制与工具关联`,"Latest on loaded page":`跳到已加载页的最新处`,"No message records on this page; more history remains.":`本页没有消息记录;还有更多历史。`,"No message records on this page.":`本页没有消息记录。`,"SDK tool error observed":`观察到 SDK 工具错误`,"SDK tool end observed":`观察到 SDK 工具结束`,"Start observed; end not observed in this snapshot":`已观察到开始;此快照中未观察到结束`,"No start observed":`未观察到开始`,"Inspect recorded tool call":`查看已记录的工具调用`,"Child {child} · call {call} · v{version}":`子运行 {child} · 调用 {call} · v{version}`,"SDK tool observations are not native process launch/close or passing parent checks.":`SDK 工具观察不代表原生进程的启动/关闭,也不代表父级检查已通过。`,"Source ID":`来源 ID`,unavailable:`不可用`,Declaration:`声明`,"No declaration recorded; orphan result remains accessible":`未记录声明;孤立结果仍可访问`,"Recorded tool end (not parsed from output)":`已记录的工具结束(非从输出解析)`,"No end fact in this snapshot.":`此快照中没有结束事实。`,"historical projection":`历史视图`,"owner projection":`所有者视图`,Lifecycle:`生命周期`,unsettled:`未结束`,"Wait/block reason":`等待/阻塞原因`,"none reported":`未报告`,"Summary publication":`摘要发布`,"Native / recording / parent settlement facts (independent of human review)":`原生 / 记录 / 父级结束事实(独立于人工审阅)`,"No settlement recorded":`未记录结束信息`,"New task":`新建任务`,"No retained task on this page.":`本页没有保留的任务。`,"One checkout owner. Open/history never executes.":`每个工作副本一个所有者。打开或查看历史永远不会执行。`,"Active and recent episodes":`活动与近期执行轮次`,"Runs and assignments":`运行与子任务`,"Toggle assignments":`展开/收起子任务`,"{count} descendants":`{count} 个后代`," / failed child":` / 有失败的子运行`," / unknown child":` / 有未知的子运行`,"No active or recent episode observed.":`未观察到活动或近期的执行轮次。`,"All retained episodes for task":`此任务的全部保留执行轮次`,"Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.":`按提交顺序排列,而非真实时间。回放只推进可视化。原始观察保留时钟/序号来源;未知的时间不会被重建。`,"Bundled timeline unavailable; retained events remain accessible, no CDN fallback.":`内置时间线不可用;保留的事件仍可访问,不会回退到 CDN。`,Owner:`所有者`,owner:`所有者`,input:`输入`,model:`模型`,"Committed #{seq}; {who}":`已提交 #{seq};{who}`,"recorded fact":`已记录事实`,"Worker-local monotonic observations ({child}): {first}–{last} ms; not aligned to other workers.":`工作进程本地单调时钟观察({child}):{first}–{last} 毫秒;未与其他工作进程对齐。`,"Owner observation ({epoch}): {ms} ms; clock origin not established by this reader.":`所有者观察({epoch}):{ms} 毫秒;此读取器未确定时钟起点。`,"{scope} — loaded committed page":`{scope}——已加载的提交页`,"Committed sequence {seq}; page ordinal {ordinal}. Timing shown in raw facts only; clocks may not be comparable.":`提交序号 {seq};页内序数 {ordinal}。时间只在原始事实中显示;各时钟可能无法比较。`,task:`任务`,run:`运行`,child:`子运行`,workspace:`工作区`,message:`消息`,tool:`工具`,"final-text":`最终文本`,"tool-args":`工具参数`,"tool-update":`工具更新`,"tool-result":`工具结果`,check:`检查`,user:`用户`,assistant:`助手`,partial:`部分`,final:`最终`,observed:`已观察`,create:`创建`,"generate-plan":`生成计划`,"save-plan":`保存计划`,start:`启动`,research:`调研`,diagnosis:`诊断`,edit:`编辑`,current:`最新`,stale:`已过期`,resync:`重新同步中`,closed:`已关闭`,"accepted-unallocated":`已接受未分配`,active:`活动中`,draining:`排空中`,queued:`排队中`,preparing:`准备中`,running:`运行中`,closing:`收尾中`,settled:`已结束`,completed:`已完成`,failed:`失败`,canceled:`已取消`,timeout:`超时`,unknown:`未知`,blocked:`已阻塞`,pending:`待定`,published:`已发布`,conflict:`冲突`,uncertain:`不确定`,accepted:`已接受`,refused:`已拒绝`,absent:`不存在`,inconclusive:`无定论`,"not-run":`未运行`,passed:`已通过`,complete:`完整`,incomplete:`不完整`,limited:`受限`,binary:`二进制`,"hidden-thinking":`隐藏的思考`,"source-limit":`来源限制`,"capture-limit":`捕获限制`,gap:`缺口`,unsupported:`不支持`,capacity:`容量`,dependency:`依赖`,writer:`写入者`,"parent-stopped":`父级已停止`,"wait-expired":`等待超时`,"handoff-overflow":`交接溢出`,"stale-dependency":`依赖已过期`,quarantine:`隔离`,"incomplete-observation":`观察不完整`,"unrun-checks":`有未运行的检查`,"stale-checks":`有过期的检查`,"failed-checks":`有失败的检查`,"partial-results":`结果不完整`,"recording-incomplete":`记录不完整`,"legacy-context":`旧版上下文`},h=r(),g=`cadence-locale`,_=new Map(Object.entries(m));function v(e,t,n){let r=e===`zh`?_.get(t)??t:t;return n?r.replace(/\{(\w+)\}/g,(e,t)=>Object.hasOwn(n,t)?String(n[t]):e):r}function y({text:e,slots:t}){return e.split(/\{(\w+)\}/).map((e,n)=>n%2==0?e:(0,h.jsx)(f.Fragment,{children:Object.hasOwn(t,e)?t[e]:`{${e}}`},e))}function b(){try{let e=localStorage.getItem(g);if(e===`en`||e===`zh`)return e}catch{}return(typeof navigator>`u`?void 0:navigator.languages?.[0]??navigator.language)?.toLowerCase().startsWith(`zh`)?`zh`:`en`}function x(e,t){return{locale:e,t:(t,n)=>v(e,t,n),tx:t=>v(e,t),setLocale:t}}var S=(0,f.createContext)(x(`en`,()=>{}));function C(){return(0,f.useContext)(S)}function w({initial:e,children:t}){let[n,r]=(0,f.useState)(()=>e??b()),i=(0,f.useMemo)(()=>x(n,e=>{try{localStorage.setItem(g,e)}catch{}r(e)}),[n]);return(0,f.useEffect)(()=>{document.documentElement.lang=n===`zh`?`zh-CN`:`en`,document.title=v(n,`Cadence task workspace`)},[n]),(0,h.jsx)(S.Provider,{value:i,children:t})}var T=`cadence-graph/2`,E=`cadence-public-export/2`,D=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),O=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`quarantine`,`capacity`,`unavailable`,`registry-locked`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],k=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function A(e,t=`none`){return{code:e,effect:t,recovery:t!==`none`||e===`receipt-inconclusive`?`observe`:[`stale`,`expired-grant`,`consumed-grant`].includes(e)?`fresh-confirmation`:`operator`}}function j(){throw new k}function M(e,t,n=!1){if((typeof e!=`string`||e.includes(`\0`)||/[\uD800-\uDFFF]/u.test(e)||n&&!e.trim())&&j(),N(e)>t)throw new k(`oversize`);return e}function N(e){return new TextEncoder().encode(e).length}function P(e,t=0,n=2**53-1){return(typeof e!=`number`||!Number.isSafeInteger(e)||e<t||e>n)&&j(),e}function F(e){return typeof e!=`boolean`&&j(),e}function I(e,t){return(typeof e!=`string`||!t.includes(e))&&j(),e}function L(e,t){return e!==t&&j(),t}function R(e,t){return e===null?null:t(e)}function z(e,t){(typeof e!=`object`||!e||Array.isArray(e)||![null,Object.prototype].includes(Object.getPrototypeOf(e)))&&j();let n=Reflect.ownKeys(e);(n.length!==t.length||n.some(e=>typeof e!=`string`||!t.includes(e)))&&j();let r=Object.create(null);for(let n of t){let t=Object.getOwnPropertyDescriptor(e,n);(!t||!(`value`in t)||!t.enumerable)&&j(),r[n]=t.value}return r}function B(e,t,n){(!Array.isArray(e)||e.length>t||Reflect.ownKeys(e).length!==e.length+1)&&j();let r=[];for(let t=0;t<e.length;t++){let i=Object.getOwnPropertyDescriptor(e,String(t));(!i||!(`value`in i))&&j(),r.push(n(i.value))}return r}function V(e){let t=M(e,36);return/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/.test(t)||j(),t}function H(e){let t=M(e,64);return/^[0-9a-f]{64}$/.test(t)||j(),t}function U(e){let t=M(e,D.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function ee(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function te(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function W(e,t=D.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new k(`oversize`);return e};function i(e,n){if(n>64&&j(),e===null||typeof e==`boolean`)return r(String(e));if(typeof e==`string`)return M(e,t),r(JSON.stringify(e));if(typeof e==`number`)return Number.isFinite(e)||j(),r(JSON.stringify(e));if(Array.isArray(e)){let a=B(e,t,e=>e);return r(`[]${`,`.repeat(Math.max(0,a.length-1))}`),`[${a.map(e=>i(e,n+1)).join(`,`)}]`}if(e&&typeof e==`object`){let t=Reflect.ownKeys(e);t.some(e=>typeof e!=`string`)&&j();let a=t.sort(),o=z(e,a);return r(`{}${`,`.repeat(Math.max(0,a.length-1))}`),`{${a.map(e=>`${r(`${JSON.stringify(e)}:`)}${i(o[e],n+1)}`).join(`,`)}}`}return j()}return i(e,0)}function ne(e,t=D.controlBytes){M(e,t);let n=0,r=()=>{for(;/[\x20\t\r\n]/.test(e[n]??`!`);)n++};function i(){let r=n++,i=!1;for(;n<e.length;){let a=e[n++];if(!i&&a===`"`)try{return M(JSON.parse(e.slice(r,n)),t)}catch{return j()}i=!i&&a===`\\`}return j()}function a(t){if(t>64&&j(),r(),e[n]===`"`)return i();if(e[n]===`{`||e[n]===`[`){let o=e[n++]===`{`,s=o?`}`:`]`,c=Object.create(null),l=[],u=new Set;if(r(),e[n]===s)return n++,o?c:l;for(;;){r();let d=``;o&&(e[n]!==`"`&&j(),d=i(),u.has(d)&&j(),u.add(d),r(),e[n++]!==`:`&&j());let f=a(t+1);o?c[d]=f:l.push(f),r();let p=e[n++];if(p===s)break;p!==`,`&&j()}return o?c:l}let o=/^(?:true|false|null|-?(?:0|[1-9][0-9]*)(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)/.exec(e.slice(n))?.[0];o||j(),n+=o.length;let s=JSON.parse(o);return typeof s==`number`&&!Number.isFinite(s)&&j(),s}let o=a(0);return r(),n!==e.length&&j(),o}function re(e){let t=z(e,[`code`,`effect`,`recovery`]);return{code:I(t.code,O),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ie=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],ae=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],oe=[`not-launched`,`direct-child-closed`,`unconfirmed`],se=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],ce=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function le(e){let t=z(e,[`provider`,`model`,`api`,`thinking`]);return{provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:I(t.api,se),thinking:I(t.thinking,ce)}}function ue(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...le(n)}}function de(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function fe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function G(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ie),bytes:P(t.bytes,0,D.detailBytes),sha256:H(t.sha256)}}function pe(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,D.detailBytes)}}function me(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=K(t.source),r;if(n===`current`)r={kind:n,assignmentId:te(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=G(e.result);L(i.field,`final-text`),r={kind:`historical`,runId:V(e.runId),childRunId:V(e.childRunId),result:i}}let i=R(t.range,pe);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function K(e,t=`kind`){(typeof e!=`object`||!e)&&j();let n=Object.getOwnPropertyDescriptor(e,t);return(!n||!(`value`in n))&&j(),M(n.value,64,!0)}function he(e){W(e,D.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=G(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,T),taskId:V(t.taskId),taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),taskRevision:P(t.taskRevision,1),revision:P(t.revision,1),planRevision:r,plan:n,assignments:B(t.assignments,D.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:te(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,D.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,D.expectedOutputBytes,!0),role:de(t.role),model:ue(t.model),dependencies:B(t.dependencies,D.assignments,me)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=W(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==fe(e.purpose))throw new k(`forbidden`);c(e)}return i}function ge(e){let t=z(e,[`id`,`kind`,`revision`,`identity`,`graphRevision`,`graphIdentity`]),n=R(t.graphRevision,e=>P(e,1)),r=R(t.graphIdentity,H);return n===null!=(r===null)&&j(),{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity),graphRevision:n,graphIdentity:r}}function _e(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`controlRev`,`workspaceId`,`cwdId`,`model`,`checkEnvGeneration`,`checkoutGeneration`,`observation`,`task`]),n=z(t.observation,[`identity`,`complete`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),controlRev:P(t.controlRev,1),workspaceId:V(t.workspaceId),cwdId:V(t.cwdId),model:ue(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,ge)}}function ve(e){let t=z(e,[`kind`,`name`,`command`,`timeoutMs`]),n={kind:I(t.kind,[`configured`,`manual`]),name:M(t.name,128,!0),command:M(t.command,4096,!0),timeoutMs:P(t.timeoutMs,100,D.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function ye(e){switch(W(e),K(e)){case`create`:{let t=z(e,[`kind`,`taskKind`,`goal`]);return{kind:`create`,taskKind:I(t.taskKind,[`code`,`research`,`diagnosis`]),goal:M(t.goal,8192,!0)}}case`save-plan`:{let t=z(e,[`kind`,`taskId`,`plan`,`graph`]),n=he(t.graph),r=V(t.taskId);return n.taskId!==r&&j(),{kind:`save-plan`,taskId:r,plan:M(t.plan,32768),graph:n}}case`generate-plan`:case`start`:return{kind:K(e),taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`check`:{let t=z(e,[`kind`,`taskId`,`check`]);return{kind:`check`,taskId:V(t.taskId),check:ve(t.check)}}case`review`:{let t=z(e,[`kind`,`taskId`,`runId`,`changesIdentity`,`checksRevision`,`acceptIssues`]);return{kind:`review`,taskId:V(t.taskId),runId:V(t.runId),changesIdentity:H(t.changesIdentity),checksRevision:P(t.checksRevision),acceptIssues:F(t.acceptIssues)}}default:return j()}}function be(e){W(e);let t=z(e,[`expected`,`action`]);return{expected:_e(t.expected),action:ye(t.action)}}function xe(e){W(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:_e(t.expected),action:ye(t.action)}}function Se(e){if(W(e),K(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:_e(t.expected),action:ye(t.action)}}let t=z(e,[`kind`,`epoch`,`runId`]);return L(t.kind,`cancel`),{kind:`cancel`,epoch:V(t.epoch),runId:V(t.runId)}}function Ce(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function we(e){W(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,ve);return(r.some(e=>e.kind!==`configured`)||new Set(r.map(e=>e.name)).size!==r.length)&&j(),{...t?{checkEnvironmentPolicy:L(n.checkEnvironmentPolicy,`service-launch-ordinary/1`)}:{},configuredChecks:r,checksRevision:P(n.checksRevision),reviewRunId:R(n.reviewRunId,V),version:_e(n.version),action:ye(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,he),activeRunId:R(n.activeRunId,V),issues:B(n.issues,7,e=>I(e,[`incomplete-observation`,`unrun-checks`,`stale-checks`,`failed-checks`,`partial-results`,`recording-incomplete`,`legacy-context`]))}}function Te(e){W(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:we(t.preview)}}function q(e){let t=z(e,[`observed`,`source`,`redacted`,`omissions`]),n={observed:I(t.observed,[`complete`,`incomplete`]),source:I(t.source,[`complete`,`limited`,`unavailable`]),redacted:F(t.redacted),omissions:B(t.omissions,6,e=>I(e,[`binary`,`hidden-thinking`,`source-limit`,`capture-limit`,`gap`,`unsupported`]))};return(new Set(n.omissions).size!==n.omissions.length||n.observed===`complete`&&n.omissions.some(e=>e===`capture-limit`||e===`gap`))&&j(),n}function Ee(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,D.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=G(t.result);L(i.field,`final-text`);let a=R(t.range,pe);a&&a.end>i.bytes&&j();let o=M(t.text,D.predecessorBytes);if(n+=N(o),n>D.handoffBytes)throw new k(`oversize`);let s=P(t.dependencyIndex,0,D.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:te(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:q(t.coverage)}})}}function De(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`,`final`,`cleanup`,`capture`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,oe),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:I(t.stdin,[`delivered`,`failed`,`not-required`]),final:I(t.final,[`valid`,`missing`,`invalid`]),cleanup:I(t.cleanup,[`settled`,`failed`,`unconfirmed`]),capture:q(t.capture)};return n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)&&j(),n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null||n.stdin!==`delivered`||n.final!==`valid`||n.cleanup!==`settled`||n.capture.observed!==`complete`)&&j(),n}function J(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function Oe(e){let t=M(e,D.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function ke(e){W(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:J(t.scope),query:R(t.query,e=>{let t=M(e,D.queryBytes);return t.length||j(),t}),snapshotSeq:U(t.snapshotSeq),recordId:R(t.recordId,V),recordVersion:R(t.recordVersion,e=>P(e,1)),field:R(t.field,e=>I(e,ie)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function Ae(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=Fe(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function je(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function Me(e){let t=K(e);if(t===`message-final`)return{kind:t,messageId:V(z(e,[`kind`,`messageId`]).messageId)};if(t===`context`)return{kind:t,component:I(z(e,[`kind`,`component`]).component,[`request-context`,`request-prompt`,`request-instructions`,`role`,`effective-system`])};if(t===`handoff`){let n=z(e,[`kind`,`dependencyIndex`,`source`]),r=G(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,D.assignments-1),source:r}}if(t===`message`){let n=z(e,[`kind`,`messageId`,`blockId`,`index`,`stage`]);return{kind:t,messageId:V(n.messageId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`stream`,`final`])}}let n=z(e,[`kind`,`callId`,`blockId`,`index`,`stage`]);return L(t,`tool`),{kind:`tool`,callId:V(n.callId),blockId:V(n.blockId),index:P(n.index,0,D.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function Ne(e){let t=z(e,[`owner`,`field`,`encoding`]),n=Me(t.owner),r=I(t.field,[`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`]),i=I(t.encoding,[`utf8`,`canonical-json`]);return(r!==(n.kind===`context`||n.kind===`handoff`?`context`:n.kind===`message-final`?`final-text`:n.kind===`message`?`message`:n.stage===`result`?`tool-result`:n.stage===`update-snapshot`?`tool-update`:`tool-args`)||n.kind!==`tool`&&i!==`utf8`||r===`tool-args`&&i!==`canonical-json`&&(n.kind!==`tool`||n.stage!==`arguments-partial`))&&j(),{owner:n,field:r,encoding:i}}function Pe(e){let t=z(e,[`owner`,`sourceType`,`mimeType`,`reason`]),n=I(t.sourceType,[`image`,`audio`,`binary`,`hidden-thinking`,`unsupported`]),r=I(t.reason,[`binary`,`hidden-thinking`,`unsupported`]),i=R(t.mimeType,e=>M(e,128,!0));return(r!==(n===`hidden-thinking`?`hidden-thinking`:n===`unsupported`?`unsupported`:`binary`)||i!==null&&(n===`hidden-thinking`||!/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/i.test(i)))&&j(),{owner:Me(t.owner),sourceType:n,mimeType:i,reason:r}}function Fe(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function Ie(e){let t=K(e);switch(t){case`ready`:return{kind:t,requestProtocol:L(z(e,[`kind`,`requestProtocol`]).requestProtocol,2)};case`message-start`:{let n=z(e,[`kind`,`messageId`,`role`,`source`,`resultCallId`]),r=I(n.role,[`user`,`assistant`,`tool-result`]),i=R(n.resultCallId,V);return r!==`tool-result`&&i!==null&&j(),{kind:t,messageId:V(n.messageId),role:r,source:Ae(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...je({messageId:n.messageId,blockId:n.blockId}),detailId:V(n.detailId)}}case`message-end`:{let n=z(e,[`kind`,`messageId`,`finalDetailId`,`finalBlockCount`,`stopReason`]);return{kind:t,messageId:V(n.messageId),finalDetailId:R(n.finalDetailId,V),finalBlockCount:P(n.finalBlockCount,0,D.dataFrames),stopReason:I(n.stopReason,[`stop`,`length`,`toolUse`,`error`,`aborted`,`unknown`])}}case`call-declaration`:{let n=z(e,[`kind`,`callId`,`declaration`,`index`,`source`,`name`,`argsDetailId`,`stage`]);return{kind:t,callId:V(n.callId),declaration:je(n.declaration),index:P(n.index,0,D.dataFrames),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V),stage:I(n.stage,[`partial`,`final`])}}case`tool-start`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`argsDetailId`]);return{kind:t,callId:V(n.callId),declaration:R(n.declaration,je),source:Ae(n.source),name:M(n.name,128,!0),argsDetailId:R(n.argsDetailId,V)}}case`tool-update`:{let n=z(e,[`kind`,`callId`,`detailId`,`semantics`]);return{kind:t,callId:V(n.callId),detailId:V(n.detailId),semantics:L(n.semantics,`snapshot`)}}case`tool-end`:{let n=z(e,[`kind`,`callId`,`declaration`,`source`,`name`,`resultDetailId`,`isError`,`association`,`startObserved`]),r=I(n.association,[`declared`,`execution-only`,`orphan`,`ambiguous`]),i=R(n.declaration,je),a=F(n.startObserved);return(r===`declared`!=(i!==null)||r===`execution-only`&&!a||(r===`orphan`||r===`ambiguous`)&&a)&&j(),{kind:t,callId:V(n.callId),declaration:i,source:Ae(n.source),name:M(n.name,128,!0),resultDetailId:V(n.resultDetailId),isError:F(n.isError),association:r,startObserved:a}}case`omitted-block`:return{kind:t,block:Pe(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:Ne(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,D.chunkBytes),i=P(n.offset,0,D.detailBytes);return i+N(r)>D.detailBytes&&j(),{kind:t,detailId:V(n.detailId),offset:i,text:r}}case`detail-end`:{let n=z(e,[`kind`,`detailId`,`bytes`,`sha256`,`coverage`]);return{kind:t,detailId:V(n.detailId),bytes:P(n.bytes,0,D.detailBytes),sha256:H(n.sha256),coverage:q(n.coverage)}}case`capture-status`:return{kind:t,coverage:q(z(e,[`kind`,`coverage`]).coverage)};case`worker-failure`:return{kind:t,code:I(z(e,[`kind`,`code`]).code,[`protocol`,`capture`,`model`,`auth`,`network`,`cleanup`,`prompt`])};case`final`:{let n=z(e,[`kind`,`messageId`,`detailId`,`stopReason`]);return{kind:t,messageId:V(n.messageId),detailId:V(n.detailId),stopReason:L(n.stopReason,`stop`)}}default:return j()}}function Le(e){let t=z(e,[`outcome`,`closure`,`exitCode`,`signal`,`durationMs`,`stdin`]),n={outcome:I(t.outcome,[`completed`,`failed`,`canceled`,`timeout`,`unknown`]),closure:I(t.closure,oe),exitCode:R(t.exitCode,e=>P(e,-2147483648,4294967295)),signal:R(t.signal,e=>M(e,32,!0)),durationMs:P(t.durationMs),stdin:L(t.stdin,`not-required`)};return(n.closure===`not-launched`&&(n.exitCode!==null||n.signal!==null)||n.outcome===`completed`&&(n.closure!==`direct-child-closed`||n.exitCode!==0||n.signal!==null))&&j(),n}function Re(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function ze(e){let t=z(e,[`childRunId`,`detailId`,`content`,`committedSeq`]),n=U(t.committedSeq);return n===`0`&&j(),{childRunId:V(t.childRunId),detailId:V(t.detailId),content:G(t.content),committedSeq:n}}function Be(e){let t=K(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=Re(n.selected),i=ze(n.detail);return(r.detailId!==i.detailId||i.content.field!==`final-text`)&&j(),{status:t,selected:r,detail:i}}if(t===`refused`){let n=z(e,[`status`,`selected`,`error`]);return{status:t,selected:R(n.selected,Re),error:re(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,Re)}}function Ve(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&ee(n,t.detail.committedSeq)<0)&&j(),n}function He(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function Ue(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?He(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function We(e){let t=K(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=Be(n.recording),i=Ve(n.settlementSeq,r);return{kind:t,native:De(n.native),recording:r,settlementSeq:i}}if(t===`check`){let n=z(e,[`kind`,`native`,`capture`,`settlementSeq`]),r=R(n.settlementSeq,U);return r===`0`&&j(),{kind:t,native:Le(n.native),capture:q(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=Be(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:te(t.assignmentId),childRunId:n,native:R(t.native,De),recording:r,settlementSeq:Ve(t.settlementSeq,r)}}),i=I(n.outcome,ae);return(!r.length||new Set(r.map(e=>e.assignmentId)).size!==r.length||new Set(r.map(e=>e.childRunId)).size!==r.length||i===`completed`&&!r.every(He))&&j(),{kind:`parent`,outcome:i,required:r}}function Y(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,D.dataFrames+D.controlFrames),r=P(t.last,n,D.dataFrames+D.controlFrames),i=P(t.firstObservedMs),a=P(t.lastObservedMs,i);return n===r&&i!==a&&j(),{first:n,last:r,firstObservedMs:i,lastObservedMs:a}}function Ge(e){let t=z(e,[`source`,`event`]),n=Y(t.source),r=K(t.event);if(r===`stored-chunk`){let e=z(t.event,[`kind`,`detailId`,`text`]);return{source:n,event:{kind:r,detailId:V(e.detailId),text:M(e.text,D.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:q(e.coverage)}}}let i=Ie(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ke(e){let t=z(e,[`epoch`,`taskId`,`runId`,`childRunId`]);return{epoch:V(t.epoch),taskId:V(t.taskId),runId:V(t.runId),childRunId:V(t.childRunId)}}function qe(e){W({kind:`ok`,value:e},D.pageBytes);let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value===`complete`,n=z(e,[`storeId`,`workspaceId`,`epoch`,`status`,t?`runs`:`error`]),r={storeId:V(n.storeId),workspaceId:V(n.workspaceId),epoch:V(n.epoch)};if(!t)return L(n.status,`unavailable`),{...r,status:`unavailable`,error:Je(n.error)};let i=B(n.runs,D.episodes,e=>{let t=z(e,[`taskId`,`runId`,`operationId`,`epoch`,`kind`,`stage`]);return{taskId:V(t.taskId),runId:V(t.runId),operationId:V(t.operationId),epoch:V(t.epoch),kind:I(t.kind,[`start`,`generate-plan`,`check`]),stage:I(t.stage,[`accepted-unallocated`,`active`,`draining`])}});return(i.some(e=>e.epoch!==r.epoch)||new Set(i.map(e=>e.runId)).size!==i.length||new Set(i.map(e=>e.taskId)).size!==i.length||new Set(i.map(e=>e.operationId)).size!==i.length)&&j(),{...r,status:`complete`,runs:i}}function Je(e){let t=re(e);return L(t.effect,`none`),t}function Ye(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Xe(e){let t=I(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value,[`native`,`browser`]),n=z(e,t===`native`?[`kind`,`contractHash`]:[`kind`,`contractHash`,`sourceHash`,`buildId`]);return t===`native`?{kind:t,contractHash:H(n.contractHash)}:{kind:t,...Ye({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Ze(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:Ye(t.assets)}}function Qe(e,t,n=!1){return!!e&&!!t&&t.contractHash===e.contractHash&&(n||e.assets.contractHash===e.contractHash&&(t.kind===`native`||t.buildId===e.assets.buildId&&t.sourceHash===e.assets.sourceHash))}function $e(e){W(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,ae)),settlement:R(t.settlement,We),created:R(t.created,e=>{let t=z(e,[`kind`,`taskId`,`state`]);return{kind:L(t.kind,`task`),taskId:V(t.taskId),state:I(t.state,[`reserved`,`published`])}}),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`])};return(n.committedSeq===`0`||n.settlement?.kind===`sdk`||n.execution===`completed`&&!n.settlement||n.execution!==null&&n.settlement!==null&&Ue(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function et(e){W(e);let t=z(e,[`identity`,`receipt`]),n=Se(t.identity),r=$e(t.receipt);n.kind===`cancel`&&r.runId!==n.runId&&j();let i=n.kind===`action`&&n.action.kind===`create`;if((!i&&r.created!==null||i&&r.admission===`accepted`&&r.created===null)&&j(),n.kind===`action`){let e=[`start`,`generate-plan`,`check`].includes(n.action.kind);(r.admission===`accepted`&&e!==(r.runId!==null)||!e&&(r.execution!==null||r.settlement!==null)||r.settlement!==null&&r.settlement.kind!==(n.action.kind===`check`?`check`:`parent`))&&j()}return{identity:n,receipt:r}}function X(e,t){if(K(e)===`ok`)return{kind:`ok`,value:t(z(e,[`kind`,`value`]).value)};let n=z(e,[`kind`,`error`]);return L(n.kind,`error`),{kind:`error`,error:re(n.error)}}function tt(e){switch(W(e),K(e,`status`)){case`found`:return{status:`found`,receipt:$e(z(e,[`status`,`receipt`]).receipt)};case`absent`:return{status:`absent`,committedSeq:U(z(e,[`status`,`committedSeq`]).committedSeq)};case`inconclusive`:return{status:`inconclusive`,error:re(z(e,[`status`,`error`]).error)};default:return j()}}function nt(e){let t=z(e,[`runId`,`taskId`,`childRunId`,`assignmentId`,`admission`,`lifecycle`,`outcome`,`settlement`,`reason`,`publication`,`coverage`,`result`]),n={runId:V(t.runId),taskId:V(t.taskId),childRunId:R(t.childRunId,V),assignmentId:R(t.assignmentId,te),admission:ft(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,ae)),settlement:R(t.settlement,We),reason:R(t.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])),publication:I(t.publication,[`pending`,`published`,`conflict`,`uncertain`]),coverage:q(t.coverage),result:R(t.result,G)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&W(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==W(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&W(n.result)!==W(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&Ue(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||Ue(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function rt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function it(e,t,n){return rt(e,t)&&e.taskId===ht(n)&&e.admission.context.workspaceId===mt(n)}function at(e){W(e,D.pageBytes);let t=z(e,[`protocol`,`storeId`,`epoch`,`scope`,`committedSeq`,`context`,`runs`,`horizon`]),n={protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),scope:J(t.scope),committedSeq:U(t.committedSeq),context:pt(t.context),runs:B(t.runs,D.maxPageEntries,nt),horizon:Et(t.horizon)};return(!gt(n.context,n.epoch,n.scope)||W(n.horizon.historicalRuns.scope)!==W(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!it(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function ot(e){W(e,D.pageBytes);let t=K(e),n=z(e,t===`update`?[`kind`,`storeId`,`epoch`,`scope`,`previousSeq`,`committedSeq`,`runs`,`removed`,`context`]:[`kind`,`storeId`,`epoch`,`scope`,`committedSeq`]),r={storeId:V(n.storeId),epoch:V(n.epoch),scope:J(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);ee(r.committedSeq,e)<=0&&j();let i=pt(n.context);gt(i,r.epoch,r.scope)||j();let a=B(n.runs,D.maxPageEntries,nt),o=B(n.removed,D.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!it(e,r.scope,i))||new Set(s).size!==s.length||new Set(o).size!==o.length||o.some(e=>s.includes(e)))&&j(),{kind:t,...r,previousSeq:e,runs:a,removed:o,context:i}}return L(t,`heartbeat`),{kind:`heartbeat`,...r}}function st(e){let{navigation:t,...n}=e;return n}function ct(e,t){(!t.navigation||t.navigation===e.navigation||W(st(e))!==W(st(t)))&&j()}function lt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return ut(e);W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=ke(t.cursor),r=ke(t.next);return ct(n,r),{kind:`progress`,cursor:n,next:r,coverage:q(t.coverage)}}function ut(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:ke(t.cursor),content:G(t.content),range:R(t.range,pe),text:M(t.text,D.detailPageBytes),next:R(t.next,ke),coverage:q(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||W(st({...n.next,offset:n.cursor.offset}))!==W(st(n.cursor)))&&j(),n}function dt(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=ke(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,D.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=G(t.content),a=yt(t.owner);bt(a,n.scope)||j();let o=pe(t.range),s=ke(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||W(s.scope)!==W(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,D.previewBytes),cursor:s}}),a=R(t.next,ke);return a&&(a.storeId!==n.storeId||W(a.scope)!==W(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&j(),{cursor:n,hits:i,next:a,coverage:q(t.coverage)}}function ft(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=_e(t.context),r=R(t.graph,e=>{let t=z(e,[`recordId`,`revision`,`sha256`]);return{recordId:V(t.recordId),revision:P(t.revision,1),sha256:H(t.sha256)}}),i=I(t.kind,[`start`,`generate-plan`,`check`]),a=B(t.assignments,D.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:te(t.assignmentId),childRunId:V(t.childRunId)}});return(i===`check`!=(a.length===0)||new Set(a.map(e=>e.assignmentId)).size!==a.length||new Set(a.map(e=>e.childRunId)).size!==a.length)&&j(),(!n.task||i===`start`&&(!r||r.revision!==n.task.graphRevision||r.sha256!==n.task.graphIdentity)||i!==`start`&&r!==null)&&j(),{operationId:V(t.operationId),commandId:V(t.commandId),kind:i,context:n,assignments:a,graph:r}}function pt(e){if(K(e,`status`)===`available`)return{status:`available`,version:_e(z(e,[`status`,`version`]).version)};let t=z(e,[`status`,`workspaceId`,`taskId`,`error`]);L(t.status,`unavailable`);let n=re(t.error);return L(n.effect,`none`),{status:`unavailable`,workspaceId:V(t.workspaceId),taskId:R(t.taskId,V),error:n}}function mt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function ht(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function gt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||ht(e)===n.id)}function _t(e){let t=z(e,[`protocol`,`storeId`,`epoch`,`accessGeneration`,`authority`,`csrf`,`capabilities`,...Object.getOwnPropertyDescriptor(e??{},`build`)?[`build`]:[]]),n=z(t.capabilities,[`actions`,`manualChecks`,`history`]),r=I(t.authority,[`browser`,`local`]),i=R(t.csrf,V),a={actions:F(n.actions),manualChecks:F(n.manualChecks),history:F(n.history)};return(r===`browser`&&(i===null||a.manualChecks)||r===`local`&&i!==null)&&j(),{...t.build===void 0?{}:{build:Ze(t.build)},protocol:L(t.protocol,1),storeId:V(t.storeId),epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),authority:r,csrf:i,capabilities:a}}function vt(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:qe(t.activeRuns)},workspaceId:V(t.workspaceId),storeId:V(t.storeId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),rootLabel:M(t.rootLabel,4096,!0),context:pt(t.context),models:B(t.models,D.maxPageEntries,ue)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(mt(n.context)!==n.workspaceId||ht(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function yt(e){let t=z(e,[`taskId`,`runId`,`childRunId`,`entity`]),n=z(t.entity,[`kind`,`id`,`version`]),r={taskId:V(t.taskId),runId:R(t.runId,V),childRunId:R(t.childRunId,V),entity:{kind:I(n.kind,[`task`,`run`,`child`,`message`,`tool`,`check`,`changes`,`review`]),id:V(n.id),version:P(n.version,1)}};return(r.childRunId!==null&&r.runId===null||r.entity.kind===`task`&&(r.entity.id!==r.taskId||r.runId!==null)||r.entity.kind===`run`&&(r.entity.id!==r.runId||r.childRunId!==null)||r.entity.kind===`child`&&r.entity.id!==r.childRunId||[`message`,`tool`].includes(r.entity.kind)&&r.childRunId===null||[`check`,`changes`,`review`].includes(r.entity.kind)&&r.childRunId!==null)&&j(),r}function bt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function xt(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function St(e){W(e,D.controlBytes);let t=K(e);switch(t){case`assignment-state`:{let n=z(e,[`kind`,`childRunId`,`state`,`reason`]),r=I(n.state,[`waiting`,`ready`,`preparing`,`closing`,`unstarted`]),i=R(n.reason,e=>I(e,[`capacity`,`dependency`,`writer`,`parent-stopped`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`]));return(r===`waiting`||r===`unstarted`)&&i===null&&j(),(r===`ready`||r===`preparing`)&&i!==null&&j(),{kind:t,childRunId:V(n.childRunId),state:r,reason:i}}case`admission-closed`:return{kind:t,reason:I(z(e,[`kind`,`reason`]).reason,[`failed`,`canceled`,`timeout`,`wait-expired`,`handoff-overflow`,`stale-dependency`,`quarantine`])};case`parent-admitted`:{let n=z(e,[`kind`,`runId`,`identity`]);return{kind:t,runId:V(n.runId),identity:ft(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=We(n.settlement);return r.kind!==`parent`&&j(),{kind:t,runId:V(n.runId),settlement:r}}case`gate`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`reservationId`),r=z(e,[`kind`,`lane`,`state`,`checkoutGeneration`,...n?[`reservationId`]:[]]);return{kind:t,...n?{reservationId:V(r.reservationId)}:{},lane:I(r.lane,[`reader`,`writer`,`check`]),state:I(r.state,[`waiting`,`held`,`released`,`unknown`]),checkoutGeneration:P(r.checkoutGeneration)}}case`handoff`:{let n=z(e,[`kind`,`childRunId`,`handoff`,`observation`]);return{kind:t,childRunId:V(n.childRunId),handoff:Ee(n.handoff),observation:xt(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=G(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:xt(n.observation),content:r}}case`check-start`:{let n=z(e,[`kind`,`checkId`,`selection`,`cwdId`,`cwdLabel`,`checkEnvGeneration`,`before`]);return{kind:t,checkId:V(n.checkId),selection:ve(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:xt(n.before)}}case`check-settled`:{let n=typeof e==`object`&&!!e&&Object.hasOwn(e,`ownAdvance`),r=z(e,[`kind`,`checkId`,`native`,`status`,`before`,`after`,`output`,`coverage`,...n?[`ownAdvance`]:[]]),i;if(n){let e=z(r.ownAdvance,[`operationId`,`reservationId`,`from`,`to`]);i={operationId:V(e.operationId),reservationId:V(e.reservationId),from:P(e.from),to:P(e.to)},(i.to!==i.from+1||i.reservationId!==r.checkId)&&j()}let a=Le(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=xt(r.before),c=xt(r.after),l=R(r.output,G),u=q(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||W({...s,checkoutGeneration:c.checkoutGeneration})!==W(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=G(n.content);return L(a.field,`review`),i===`reviewed-with-issues`&&!r&&j(),{kind:t,reviewId:V(n.reviewId),runId:V(n.runId),checksRevision:P(n.checksRevision),changesIdentity:H(n.changesIdentity),acceptIssues:r,outcome:i,content:a}}case`publication-intent`:{let n=z(e,[`kind`,`publicationId`,`expectedRevision`,`expectedIdentity`,`nextRevision`,`nextIdentity`]),r=P(n.expectedRevision),i=R(n.expectedIdentity,H),a=P(n.nextRevision,1);return(r===0!=(i===null)||a!==r+1)&&j(),{kind:t,publicationId:V(n.publicationId),expectedRevision:r,expectedIdentity:i,nextRevision:a,nextIdentity:H(n.nextIdentity)}}case`publication-settled`:{let n=z(e,[`kind`,`publicationId`,`status`,`observed`]),r=I(n.status,[`published`,`conflict`,`uncertain`]),i=R(n.observed,e=>{let t=z(e,[`revision`,`identity`]);return{revision:P(t.revision,1),identity:H(t.identity)}});return r===`published`&&i===null&&j(),{kind:t,publicationId:V(n.publicationId),status:r,observed:i}}default:return j()}}function Ct(e){let t=z(e,[`epoch`,`operationId`,`taskId`,`runId`]);return{epoch:V(t.epoch),operationId:V(t.operationId),taskId:V(t.taskId),runId:R(t.runId,V)}}function wt(e){W(e,D.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=Ct(t.link),r=B(t.events,D.ownerQueueFrames,e=>{let t=K(e);if(t===`fact`){let r=St(z(e,[`kind`,`fact`]).fact);return(`runId`in r&&r.runId!==n.runId||r.kind===`parent-admitted`&&(r.identity.context.task?.id!==n.taskId||r.identity.operationId!==n.operationId)||[`gate`,`assignment-state`,`admission-closed`,`handoff`,`check-start`,`check-settled`].includes(r.kind)&&n.runId===null)&&j(),{kind:t,fact:r}}if(t===`content-begin`){let r=z(e,[`kind`,`detailId`,`owner`,`field`,`encoding`]),i=yt(r.owner),a=I(r.field,[`plan`,`check`,`changes`,`review`]);return(i.taskId!==n.taskId||i.runId!==n.runId||i.childRunId!==null||i.entity.kind!==(a===`plan`?`task`:a))&&j(),{kind:t,detailId:V(r.detailId),owner:i,field:a,encoding:L(r.encoding,`utf8`)}}if(t===`content-chunk`){let n=z(e,[`kind`,`detailId`,`text`]);return{kind:t,detailId:V(n.detailId),text:M(n.text,D.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:q(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var Tt=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Z(e){let t=z(e,[`reader`,`storeId`,`scope`,`snapshotSeq`,`after`,`limit`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=I(t.reader,Tt),r=z(t.scope,[`kind`,`id`]),i={kind:I(r.kind,[`workspace`,`task`,`run`,`child`]),id:V(r.id)},a=R(t.snapshotSeq,U),o=R(t.after,e=>{let t=z(e,[`recordId`,`version`,`offset`]);return{recordId:V(t.recordId),version:P(t.version,1),offset:P(t.offset)}});return(o&&a===null||n===`tasks`!=(i.kind===`workspace`))&&j(),{reader:n,...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,D.maxPageEntries)}}function Et(e){let t=z(e,[`policy`,`historicalRuns`]),n=Z(t.historicalRuns);return(n.reader!==`runs`||n.after!==null||n.snapshotSeq===null)&&j(),{policy:L(t.policy,`active-and-recent`),historicalRuns:n}}function Dt(e){let t=K(e);if(t===`run`)return{kind:t,projection:nt(z(e,[`kind`,`projection`]).projection)};if(t===`capture-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`link`,`capture`]),r=U(n.committedSeq);return r===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:r,link:Ke(n.link),capture:Ge(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=wt({observedMs:n.observedMs,link:n.link,events:[{kind:`fact`,fact:n.fact}]}),i=r.events[0];i.kind!==`fact`&&j();let a=U(n.committedSeq);return a===`0`&&j(),{kind:t,recordId:V(n.recordId),committedSeq:a,link:r.link,observedMs:r.observedMs,fact:i.fact}}let n=[`kind`,`owner`,`version`],r=t===`task`?[`goal`,`plan`]:t===`message`?[`role`,`source`,`resultCallId`,`state`,`finalBlockCount`,`finalText`]:t===`tool`?[`source`,`name`,`declaration`,`declarationStage`,`startObserved`,`result`]:t===`content`?[`detailId`,`descriptor`,`content`,`coverage`]:[`block`],i=z(e,[...n,...r]),a=yt(i.owner),o=P(i.version,1);if([`task`,`message`,`tool`].includes(t)&&(a.entity.kind!==t||a.entity.version!==o)&&j(),t===`task`){let e=R(i.plan,G);return e&&e.field!==`plan`&&j(),{kind:t,owner:a,version:o,goal:M(i.goal,8192,!0),plan:e}}if(t===`message`){let e=I(i.role,[`user`,`assistant`,`tool-result`]),n=I(i.state,[`partial`,`final`]),r=R(i.finalBlockCount,e=>P(e,0,D.dataFrames)),s=R(i.finalText,G),c=R(i.resultCallId,V);return(n===`final`!=(r!==null)||n===`partial`&&s!==null||s&&s.field!==`final-text`||e!==`tool-result`&&c!==null)&&j(),{kind:t,owner:a,version:o,role:e,state:n,finalBlockCount:r,finalText:s,resultCallId:c,source:Ae(i.source)}}if(t===`tool`){let e=R(i.declaration,je),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=Ie(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||W(s.declaration)!==W(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:Ae(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=Ne(i.descriptor),n=G(i.content);return(e.field!==n.field||!Ot(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:q(i.coverage)}}L(t,`omitted`);let s=Pe(i.block);return Ot(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function Ot(e,t){return e.kind===`message`||e.kind===`message-final`?t.entity.kind===`message`&&e.messageId===t.entity.id:e.kind===`tool`?t.entity.kind===`tool`&&e.callId===t.entity.id:t.entity.kind===`child`}function kt(e,t){let{scope:n,reader:r}=t,i=e.kind===`run`?{taskId:e.projection.taskId,runId:e.projection.runId,childRunId:e.projection.childRunId}:e.kind===`owner-fact`?{...e.link,childRunId:null}:e.kind===`capture-fact`?e.link:e.owner;return n.kind!==`workspace`&&!(n.kind===`task`?i.taskId===n.id:n.kind===`run`?i.runId===n.id:i.childRunId===n.id)?!1:r===`tasks`?e.kind===`task`:r===`runs`?e.kind===`run`:r===`messages`?e.kind===`message`:r===`tools`?e.kind===`tool`:r===`contents`?e.kind===`content`||e.kind===`omitted`:e.kind===`capture-fact`?r===`events`:e.kind===`owner-fact`?r===`events`||r===`checks`&&[`check-start`,`check-settled`].includes(e.fact.kind)||r===`changes`&&e.fact.kind===`changes`||r===`reviews`&&e.fact.kind===`review`:!1}function At(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Z(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,Dt),i=R(t.next,Z);return(r.some(e=>!kt(e,n))||i&&(i.after===null||W(st({...i,after:n.after}))!==W(st(n))||W(i.after)===W(n.after)))&&j(),{request:n,records:r,next:i,coverage:q(t.coverage)}}function jt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Z(t.request),r=Z(t.next);return(n.snapshotSeq!==null||n.after!==null||r.snapshotSeq===null||!r.navigation||W(st({...r,snapshotSeq:null}))!==W(st(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:q(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return At(e);W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Z(t.request),r=Z(t.next);return ct(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}function Mt(e,t){return W({...t.request,snapshotSeq:e.snapshotSeq})===W(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function Nt(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`graph`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n=z(t.graph,[`recordId`,`revision`,`sha256`]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:J(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function Pt(e){W({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=Nt(t.request),r=he(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function Ft(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Pt(e);W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Nt(t.request),r=Nt(t.next);return ct(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}function It(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:J(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function Lt(e){W(e,D.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=K(t.event),r;switch(n){case`manifest`:{let e=z(t.event,[`kind`,`schema`,`request`,`coverage`,`serviceProtocol`,`workerProtocol`,`provenance`]),i=z(e.provenance,[`exporterBuildSha256`,`capturePolicy`]);r={kind:n,provenance:{exporterBuildSha256:H(i.exporterBuildSha256),capturePolicy:L(i.capturePolicy,`public-text-tools/2`)},schema:L(e.schema,E),request:It(e.request),coverage:q(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:Dt(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:Pt(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=G(e.content),a=R(e.range,pe),o=M(e.text,D.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:yt(e.owner),content:i,range:a,text:o,coverage:q(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,D.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=q(e.coverage),a=F(e.complete);a&&i.observed!==`complete`&&j(),r={kind:n,complete:a,frames:P(e.frames,1),encodedBytes:P(e.encodedBytes),sha256:H(e.sha256),committedSeq:U(e.committedSeq),coverage:i};break}default:return j()}return{exportId:V(t.exportId),ordinal:P(t.ordinal,1),event:r}}function Rt(e,t){let n=Lt(e);return t===`ndjson`?`${W(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${W(n)}\n\`\`\`\n`)}var zt=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=It(e)}receive(e){let t=Lt(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||W(n.request)!==W(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!bt(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(W(n.graph.request.scope)!==W(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Bt(n.record,this.request.scope)&&j(),this.bytes+=N(Rt(t,this.request.format))),this.exportId=t.exportId,this.ordinal=t.ordinal,t}get completion(){return this.ended?this.complete?`complete-unverified-digest`:`incomplete`:`missing-trailer`}};function Bt(e,t){return e.kind===`run`?rt(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:bt(e.owner,t)}function Vt(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=ve(t.selection),r=I(t.status,[`not-run`,`passed`,`failed`,`canceled`,`stale`]),i=R(t.checkId,V);return(n.kind!==`configured`||r===`not-run`!=(i===null))&&j(),{selection:n,status:r,checkId:i}});return new Set(n.map(e=>e.selection.name)).size!==n.length&&j(),{taskId:V(t.taskId),revision:P(t.revision),definitions:n}}function Ht(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:Oe(t.navigation)}:{},storeId:V(t.storeId),scope:J(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function Ut(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`record`]),n=Ht(t.request),r=Dt(t.record);return(r.kind!==`task`&&r.kind!==`message`&&r.kind!==`tool`||r.kind!==n.kind||r.owner.entity.id!==n.id||r.version!==n.version||!bt(r.owner,n.scope))&&j(),{request:n,record:r}}function Wt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Ut(e);W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Ht(t.request),r=Ht(t.next);return ct(n,r),{kind:`progress`,request:n,next:r,coverage:q(t.coverage)}}var Gt=e=>{let t=re(e);return L(t.effect,`none`),t};function Kt(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function qt(e){let t=Kt(e);return t.taskId===null&&j(),t}function Jt(e){let t=z(e,[`id`,`kind`,`revision`,`identity`]);return{id:V(t.id),kind:I(t.kind,[`code`,`research`,`diagnosis`]),revision:P(t.revision,1),identity:H(t.identity)}}function Yt(e){let t=B(e,3,de);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Xt(e){let t=Object.getOwnPropertyDescriptor(e??{},`status`)?.value;if(t===`none`)return z(e,[`status`]),{status:t};if(t===`saved`){let n=z(e,[`status`,`request`,`planRevision`]);return{status:t,request:Nt(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:Gt(n.error)}}function Zt(e){if((!(e.task?e.task.id===e.request.taskId:e.request.taskId===null||e.context.status===`unavailable`)||mt(e.context)!==e.workspaceId||ht(e.context)!==e.request.taskId)&&j(),e.context.status===`available`){let t=e.context.version;(t.epoch!==e.epoch||!!t.task!=!!e.task||e.task&&(t.task?.revision!==e.task.revision||t.task.identity!==e.task.identity||t.task.kind!==e.task.kind))&&j()}}function Qt(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:Kt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:pt(t.context),task:R(t.task,Jt),roles:Yt(t.roles),savedGraph:Xt(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=q(t.coverage),r=F(t.editable);return r&&(n.redacted||n.observed!==`complete`||n.source!==`complete`||n.omissions.length)&&j(),{source:L(t.source,`current-v1`),text:M(t.text,32768),editable:r,coverage:n}})};Zt(n),!!n.task!=!!n.readablePlan&&j();let r=n.savedGraph;return r.status===`saved`&&(r.request.storeId!==n.request.storeId||r.request.scope.kind!==`task`||r.request.scope.id!==n.task?.id||r.request.snapshotSeq!==n.committedSeq||n.context.status===`available`&&(r.request.graph.sha256!==n.context.version.task?.graphIdentity||r.request.graph.revision!==n.context.version.task?.graphRevision))&&j(),r.status===`unavailable`&&n.context.status===`available`&&j(),n}function $t(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:qt(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:pt(t.context),task:Jt(t.task),observation:{identity:H(n.identity),complete:F(n.complete),checkoutGeneration:P(n.checkoutGeneration,0)},text:M(t.text,131072),git:F(t.git),coverage:q(t.coverage)};if(Zt(r),r.context.status===`available`){let e=r.context.version;(e.observation.identity!==r.observation.identity||e.observation.complete!==r.observation.complete||e.checkoutGeneration!==r.observation.checkoutGeneration)&&j()}return r}function en(e){let t=z(e,[`epoch`,`accessGeneration`,`configRev`,`catalogId`]);return{epoch:V(t.epoch),accessGeneration:P(t.accessGeneration,1),configRev:P(t.configRev,1),catalogId:V(t.catalogId)}}function tn(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`]);return{version:en(t.version),selected:R(t.selected,ue)}}function nn(e){W(e);let t=z(e,[`expected`,`choice`]);return{expected:en(t.expected),choice:le(t.choice)}}function rn(e){let t=z(e,[`provider`,`model`,`api`,`thinking`,`eligibility`]),n={provider:M(t.provider,128,!0),model:M(t.model,256,!0),api:R(t.api,e=>I(e,se)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,ce),selectable:F(t.selectable)}}),eligibility:I(t.eligibility,[`candidate`,`unsupported`,`auth-unavailable`])};return(new Set(n.thinking.map(e=>e.level)).size!==n.thinking.length||n.thinking.some(e=>e.selectable&&(n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function an(e){W({kind:`ok`,value:e},D.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`,`withheld`]),n=B(t.entries,D.maxPageEntries,rn),r=I(t.status,[`complete`,`capacity`]),i=P(t.withheld,0,D.maxPageEntries);return(r===`capacity`&&(n.length||i)||n.length+i>D.maxPageEntries||new Set(n.map(e=>W([e.provider,e.model]))).size!==n.length)&&j(),{version:en(t.version),selected:R(t.selected,ue),status:r,entries:n,withheld:i}}function on(e){let t=z(e,[`id`,`path`,`cwd`,`epoch`]);return{id:H(t.id),path:M(t.path,4096,!0),cwd:M(t.cwd,4096,!0),epoch:V(t.epoch)}}function sn(e){let t=z(e,[`kind`,`epoch`,`csrf`,`home`,`projects`,`build`]);return{kind:L(t.kind,`workbench`),epoch:V(t.epoch),csrf:V(t.csrf),home:M(t.home,4096,!0),projects:B(t.projects,128,on),build:Ze(t.build)}}var cn=[`queued`,`running`,`completed`,`failed`,`canceled`,`timeout`,`unknown`];function ln(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;switch(t){case`conversations`:case`projects`:return z(e,[`kind`]),{kind:t};case`task-origin`:return{kind:t,taskId:V(z(e,[`kind`,`taskId`]).taskId)};case`conversation`:{let n=z(e,[`kind`,`id`,`before`]);return{kind:t,id:V(n.id),before:R(n.before,V)}}default:{let t=z(e,[`kind`,`path`]);return{kind:I(t.kind,[`files`,`file`,`directories`]),path:M(t.path,4096)}}}}function un(e){let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`link-task`){let n=z(e,[`kind`,`commandId`,`epoch`,`taskId`,`conversationId`]);return{kind:t,commandId:V(n.commandId),epoch:V(n.epoch),taskId:V(n.taskId),conversationId:V(n.conversationId)}}if(t===`send`){let n=z(e,[`kind`,`commandId`,`conversationId`,`head`,`text`,`model`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),head:R(n.head,V),text:M(n.text,16384,!0),model:en(n.model)}}if(t===`interrupt`){let n=z(e,[`kind`,`commandId`,`conversationId`,`turnId`,`epoch`]);return{kind:t,commandId:V(n.commandId),conversationId:V(n.conversationId),turnId:V(n.turnId),epoch:V(n.epoch)}}let n=z(e,[`kind`,`commandId`,`path`,`epoch`]);return{kind:I(n.kind,[`open-project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),epoch:V(n.epoch)}}function dn(e){let t=z(e,[`id`,`epoch`,`status`,`items`,`notice`]);return{id:V(t.id),epoch:V(t.epoch),status:I(t.status,cn),notice:M(t.notice,1024),items:B(t.items,256,e=>{let t=z(e,[`id`,`role`,`text`,`name`,`args`,`error`]);return{id:M(t.id,160,!0),role:I(t.role,[`user`,`assistant`,`tool`]),text:M(t.text,262144),name:M(t.name,128),args:M(t.args,65536),error:F(t.error)}})}}function fn(e){let t=z(e,[`id`,`title`,`head`,`status`,`updatedAt`]);return{id:V(t.id),title:M(t.title,512,!0),head:V(t.head),status:I(t.status,cn),updatedAt:P(t.updatedAt,0)}}function pn(e){W(e,524288);let t=Object.getOwnPropertyDescriptor(e??{},`kind`)?.value;if(t===`task-origin`){let n=z(e,[`kind`,`taskId`,`conversationId`]);return{kind:t,taskId:V(n.taskId),conversationId:R(n.conversationId,V)}}if(t===`conversations`)return{kind:t,entries:B(z(e,[`kind`,`entries`]).entries,200,fn)};if(t===`conversation`){let n=z(e,[`kind`,`summary`,`turns`,`before`]);return{kind:t,summary:R(n.summary,fn),turns:B(n.turns,20,dn),before:R(n.before,V)}}if(t===`files`||t===`directories`){let n=z(e,[`kind`,`path`,`parent`,`entries`,`limited`]);return{kind:t,path:M(n.path,4096),parent:R(n.parent,e=>M(e,4096)),limited:F(n.limited),entries:B(n.entries,200,e=>{let t=z(e,[`name`,`path`,`directory`]);return{name:M(t.name,1024,!0),path:M(t.path,4096,!0),directory:F(t.directory)}})}}if(t===`file`){let n=z(e,[`kind`,`path`,`text`,`limited`]);return{kind:t,path:M(n.path,4096),text:M(n.text,262144),limited:F(n.limited)}}if(t===`projects`)return{kind:t,entries:B(z(e,[`kind`,`entries`]).entries,128,e=>{let t=z(e,[`path`,`current`]);return{path:M(t.path,4096,!0),current:F(t.current)}})};if(t===`accepted`)return{kind:t,commandId:V(z(e,[`kind`,`commandId`]).commandId)};let n=z(e,[`kind`,`commandId`,`path`,`link`]);return{kind:I(n.kind,[`project`]),commandId:V(n.commandId),path:M(n.path,4096,!0),link:M(n.link,8192,!0)}}var mn={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`},hn=`/api/v1/events`,gn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function _n(e,t){if(gn.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`||e===`workbenchRead`||e===`workbenchCommand`)return D.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return D.pageBytes}return D.controlBytes}function vn(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`,`workbenchCommand`].includes(e)}function yn(e,t){switch(e){case`workbenchRead`:return ln(t);case`workbenchCommand`:return un(t);case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new k(`invalid`);return null;case`tasks`:case`runs`:case`messages`:case`tools`:case`contents`:case`events`:case`checks`:case`changes`:case`reviews`:{let n=Z(t);if(n.reader!==e)throw new k(`invalid`);return n}case`current`:return Kt(t);case`currentChanges`:return qt(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Ht(t);case`graph`:return Nt(t);case`snapshot`:return J(t);case`detail`:case`search`:return ke(t);case`export`:case`download`:return It(t);case`chooseModel`:return nn(t);case`preflight`:return be(t);case`command`:return xe(t);case`cancel`:return Ce(t)}}function bn(e,t){if(gn.includes(e))return X(t,jt);switch(e){case`workbenchRead`:case`workbenchCommand`:return X(t,pn);case`current`:return X(t,Qt);case`currentChanges`:return X(t,$t);case`activeRuns`:return X(t,qe);case`models`:return X(t,an);case`chooseModel`:return X(t,tn);case`session`:return X(t,_t);case`workspace`:return X(t,vt);case`checkObligations`:return X(t,Vt);case`entity`:return X(t,Wt);case`graph`:return X(t,Ft);case`snapshot`:return X(t,at);case`detail`:return X(t,lt);case`search`:return X(t,dt);case`preflight`:return X(t,Te);case`command`:case`cancel`:return X(t,$e);case`receipt`:return tt(t);case`detach`:return X(t,e=>{if(e!==null)throw new k(`invalid`);return null});default:throw new k(`invalid`)}}function xn(e){return[...gn,`workbenchRead`,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function Sn(e,t){let n=mn[e];return t===null||vn(e)?n:`${n}?request=${encodeURIComponent(W(t))}`}function Cn(e,t){let n=yn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?mn[e]:Sn(e,n);return vn(e)||xn(e)&&(r||N(i)>D.headerBytes/4)?{path:mn[e],method:`POST`,body:W(n)}:{path:i,method:`GET`}}function wn(e){W(e,D.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:at(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:ot(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var Tn=class{options;attachment;csrf=null;fetcher;origin;constructor(e){this.options=e;let t=new URL(e.origin);if(t.origin!==e.origin||t.protocol!==`https:`&&!/^http:\/\/(?:127\.0\.0\.1|\[::1\]):[1-9][0-9]*$/.test(e.origin)||e.project!==void 0&&!/^[a-f0-9]{64}$/.test(e.project))throw new k(`invalid`);this.origin=e.origin,e.build&&=Xe(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}workbenchRead(e,t){return this.request(`workbenchRead`,e,t)}workbenchCommand(e){return this.request(`workbenchCommand`,e)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=W(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new k(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=Cn(e,yn(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${r.path}`,{method:r.method,headers:this.headers(i),credentials:`same-origin`,redirect:`error`,signal:this.options.requestTimeoutMs===void 0?n:AbortSignal.any([...n?[n]:[],AbortSignal.timeout(this.options.requestTimeoutMs)]),...i?{body:r.body}:{}}),o;try{e===`session`&&a.ok&&(o=V(a.headers.get(`x-cadence-attachment`)),this.attachment=o)}catch(e){throw await a.body?.cancel().catch(()=>{}),e}let s=await En(a,_n(e)),c=ne(s);if(N(s)>_n(e,c))throw new k(`oversize`);let l=bn(e,c);if(e===`session`){let e=X(l,_t);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new k(`forbidden`);this.attachment=o??V(a.headers.get(`x-cadence-attachment`)),this.csrf=e.value.csrf}}return l}session(e){return this.request(`session`,null,e)}current(e,t){return this.request(`current`,e,t)}currentChanges(e,t){return this.request(`currentChanges`,e,t)}activeRuns(e){return this.request(`activeRuns`,null,e)}models(e){return this.request(`models`,null,e)}chooseModel(e){return this.request(`chooseModel`,nn(e))}workspace(e){return this.request(`workspace`,null,e)}checkObligations(e,t){return this.request(`checkObligations`,V(e),t)}entity(e,t){return this.request(`entity`,Ht(e),t)}tasks(e,t){return this.request(`tasks`,Z(e),t)}runs(e,t){return this.request(`runs`,Z(e),t)}messages(e,t){return this.request(`messages`,Z(e),t)}tools(e,t){return this.request(`tools`,Z(e),t)}contents(e,t){return this.request(`contents`,Z(e),t)}events(e,t){return this.request(`events`,Z(e),t)}checks(e,t){return this.request(`checks`,Z(e),t)}changes(e,t){return this.request(`changes`,Z(e),t)}reviews(e,t){return this.request(`reviews`,Z(e),t)}graph(e,t){return this.request(`graph`,Nt(e),t)}preflight(e){return this.request(`preflight`,be(e))}command(e){return this.request(`command`,xe(e))}cancel(e){return this.request(`cancel`,Ce(e))}receipt(e,t){return this.request(`receipt`,V(e),t)}snapshot(e,t){return this.request(`snapshot`,e,t)}detail(e,t){return this.request(`detail`,e,t)}search(e,t){return this.request(`search`,e,t)}async detach(){let e=this.attachment;if(!e)return;let t=X(await this.request(`detach`,null),e=>{if(e!==null)throw new k(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new k(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=Cn(`export`,It(e)),r=await this.fetcher(`${this.origin}${this.options.project?`/projects/${this.options.project}`:``}${n.path}`,{method:n.method,headers:this.headers(n.method===`POST`),...n.body===void 0?{}:{body:n.body},credentials:`same-origin`,redirect:`error`,signal:t});if(!r.ok||!r.body)throw await r.body?.cancel(),new k(`unavailable`);let i=r.body.getReader(),a=new TextDecoder(`utf-8`,{fatal:!0}),o=``;try{for(;;){let{value:e,done:n}=await i.read();if(t.aborted)throw new k(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=D.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+D.chunkBytes),{stream:!0});let r=o.indexOf(`
|
|
2
2
|
`);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield Lt(ne(e,D.controlBytes)),r=o.indexOf(`
|
|
3
|
-
`)}if(new TextEncoder().encode(o).length>D.controlBytes)throw new k(`oversize`)}if(n){if(o)throw new k(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=J(e);if(!this.attachment||!this.options.socket)throw new k(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${hn}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=D.staleMs&&u(`stale`);try{Date.now()-c>=D.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},D.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new k(`invalid`);let n=wn(ne(e.data,D.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function En(e,t){if(!e.body)throw new k(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new k(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Dn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},On=f.createContext&&f.createContext(Dn),kn=[`attr`,`size`,`title`];function An(e,t){if(e==null)return{};var n,r,i=jn(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 jn(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 Mn(){return Mn=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},Mn.apply(null,arguments)}function Nn(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 Pn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Nn(Object(n),!0).forEach(function(t){Fn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fn(e,t,n){return(t=In(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function In(e){var t=Ln(e,`string`);return typeof t==`symbol`?t:t+``}function Ln(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 Rn(e){return e&&e.map((e,t)=>f.createElement(e.tag,Pn({key:t},e.attr),Rn(e.child)))}function Q(e){return t=>f.createElement(zn,Mn({attr:Pn({},e.attr)},t),Rn(e.child))}function zn(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=An(e,kn),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Mn({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Pn(Pn({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 On===void 0?t(Dn):f.createElement(On.Consumer,null,e=>t(e))}function Bn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Vn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`7`,r:`4`},child:[]},{tag:`polyline`,attr:{points:`17 11 19 13 23 9`},child:[]}]})(e)}function Hn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`3 6 5 6 21 6`},child:[]},{tag:`path`,attr:{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`11`,x2:`10`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`14`,y1:`11`,x2:`14`,y2:`17`},child:[]}]})(e)}function Un(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Wn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Gn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Kn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function qn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Jn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Yn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Xn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Zn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function Qn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 $n(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function er(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function tr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function nr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function rr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`18`,cy:`18`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`6`,r:`3`},child:[]},{tag:`path`,attr:{d:`M13 6h3a2 2 0 0 1 2 2v7`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`9`,x2:`6`,y2:`21`},child:[]}]})(e)}function ir(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 ar(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function or(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function sr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 cr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 lr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function ur(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 dr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function fr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function pr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function mr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function _r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function vr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 11 12 14 22 4`},child:[]},{tag:`path`,attr:{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`},child:[]}]})(e)}function yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}async function xr(e,t,n){let r=await e.preflight(t,n);return r.kind===`error`?r:{kind:`ok`,value:{preflight:r.value,commandId:crypto.randomUUID(),submitted:!1}}}function Sr(e,t){if(t.submitted)throw Error(`Already submitted; observe the same receipt.`);t.submitted=!0;let n=t.preflight,r={commandId:t.commandId,expected:n.preview.version,grant:n.grant},i=n.preview.action;switch(i.kind){case`create`:return e.create({...r,action:i});case`save-plan`:return e.savePlan({...r,action:i});case`generate-plan`:return e.generatePlan({...r,action:i});case`start`:return e.start({...r,action:i});case`check`:return e.check({...r,action:i});case`review`:return e.review({...r,action:i})}}var $=e=>({kind:`error`,error:A(`unavailable`,e?`uncertain`:`none`)}),Cr=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=ln(e);try{return this.transport.workbenchRead?X(await this.transport.workbenchRead(n,t),pn):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=un(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=X(await this.transport.workbenchCommand(t),pn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Kt(e);try{if(!this.transport.current)return $(!1);let e=X(await this.transport.current(n,t),Qt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=qt(e);try{if(!this.transport.currentChanges)return $(!1);let e=X(await this.transport.currentChanges(n,t),$t);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?X(await this.transport.activeRuns(e),qe):$(!1)}catch{return $(!1)}}async models(e){try{return this.transport.models?X(await this.transport.models(e),an):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=nn(e);try{if(!this.transport.chooseModel)return $(!1);let e=X(await this.transport.chooseModel(t),tn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(W(r)!==W(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){V(e);try{let n=X(await this.transport.checkObligations(e,t),Vt);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Ht({...t,kind:e});try{let e=X(await this.transport.entity(r,n),Wt);return e.kind===`ok`&&W(e.value.request)!==W(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return X(await this.transport.session(e),_t)}catch{return $(!1)}}async workspace(e){try{return X(await this.transport.workspace(e),vt)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Z({...t,reader:e});try{let t=X(await this.transport[e](r,n),jt);return t.kind===`ok`&&!Mt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Nt(e);try{let e=X(await this.transport.graph(n,t),Ft);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=It(e),r=new zt(n),i;try{if(t.aborted)throw new k(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new k(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new k(`unavailable`);yield i}catch{throw new k(`unavailable`)}}async preflight(e,t){let n=be({expected:e,action:t});try{let e=X(await this.transport.preflight(n),Te);return e.kind===`ok`&&(W(e.value.preview.version)!==W(n.expected)||W(e.value.preview.action)!==W(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=xe(t);if(n.action.kind!==e)return{kind:`error`,error:A(`invalid`)};try{let e=X(await this.transport.command(n),$e);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);et({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Ce(e);try{let e=X(await this.transport.cancel(t),$e);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);et({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=tt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:A(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=J(e);try{let e=X(await this.transport.snapshot(n,t),at);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=X(await this.transport.detail(n,t),lt);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=X(await this.transport.search(n,t),dt);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},wr=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=at(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ee(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=D.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=D.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=ot(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ee(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||mt(i.context)!==mt(a.context)||ht(i.context)!==ht(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>D.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{at(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`}},Tr={sourceHash:`52d16d2ceac7b5776440936aa91d397374c969aed4b746d256f3913309fab99e`,contractHash:`944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a`,buildId:`a66f48d170b7ce48b756b25f449e71c69db43eebb821058f6c7403a153f1282b`};function Er(e){let t=new Tn({origin:window.location.origin,...e?{project:e}:{},...Tr?{build:{kind:`browser`,...Tr}}:{},socket:e=>new WebSocket(e)});return{client:new Cr(t),transport:t}}async function Dr(e,t,n,r){let i=Qt(e);if(i.context.status!==`available`||!i.context.version.task||!i.readablePlan?.editable||i.savedGraph.status===`unavailable`)throw new k(`unavailable`);let a=i.context.version,o=a.task;if(!o)throw new k(`stale`);let s=M(t,32768),c=ye({kind:`save-plan`,taskId:o.id,plan:s,graph:{schema:`cadence-graph/2`,taskId:o.id,taskKind:o.kind,taskRevision:o.revision+1,revision:(o.graphRevision??0)+1,planRevision:i.savedGraph.status===`saved`?i.savedGraph.planRevision+1:1,plan:{recordId:r.uuid(),version:i.savedGraph.status===`saved`?i.savedGraph.planRevision+1:1,field:`plan`,bytes:N(s),sha256:`0`.repeat(64)},assignments:n}});if(c.kind!==`save-plan`)throw new k(`invalid`);for(let e of c.graph.assignments){let t=i.roles.find(t=>t.role===fe(e.purpose));if(!t||W(t)!==W(e.role)||W(a.model)!==W(e.model))throw new k(`stale`)}c.graph.plan.sha256=await r.sha256(new TextEncoder().encode(s));let l=ye(c);if(l.kind!==`save-plan`)throw new k(`invalid`);return l}var Or=`Current plan metadata unavailable. Observe again; historical text is not action authority.`;function kr(e,t){let n=async n=>{let r=await e.current({storeId:t,taskId:n.task?.id??null});if(r.kind===`error`)throw new k(r.error.code);if(r.value.context.status!==`available`||W(r.value.context.version)!==W(n))throw new k(`stale`);return r.value},r=e=>({kind:`error`,error:A(e instanceof k?e.code:`unavailable`)});return{async read(t,i){try{let r=await n(t);if(!r.readablePlan||r.savedGraph.status===`unavailable`)throw new k(`unavailable`);let a=null;if(r.savedGraph.status===`saved`){let o=r.savedGraph.request;if(i&&(i.storeId!==o.storeId||W(i.graph)!==W(o.graph)||W(i.scope)!==W(o.scope)))throw new k(`stale`);let s=await e.graph(i??o);if(s.kind===`error`)return s;if(await n(t),`kind`in s.value)return{kind:`ok`,value:{...s.value,context:t}};a=s.value.graph}else if(i)throw new k(`stale`);return{kind:`ok`,value:{context:t,roles:r.roles,savedGraph:a,readablePlan:r.readablePlan.text,editable:r.readablePlan.editable}}}catch(e){return r(e)}},async saveAction(e,t){let i=structuredClone(t);try{let t=await Dr(await n(e),i.readablePlan,i.assignments,{uuid:()=>crypto.randomUUID(),sha256:async e=>Array.from(new Uint8Array(await crypto.subtle.digest(`SHA-256`,Uint8Array.from(e))),e=>e.toString(16).padStart(2,`0`)).join(``)});return await n(e),{kind:`ok`,value:t}}catch(e){return r(e)}}}}function Ar(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ee(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ee(t.committedSeq,r.committedSeq)>0||W(r)===W(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function jr(e){if(e.aborted)throw Error(`canceled`)}function Mr(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>W(e[n]??null)!==W(t[n]??null))}function Nr(e){return Error(e.length?`stale: ${e.join(`, `)}`:`stale`)}function Pr(e,t,n){let r=Mr(e,t).filter(e=>!n.includes(e));if(r.length)throw Nr(r)}var Fr=(e,t)=>Pr(e,t,[`task`,`controlRev`]),Ir=(e,t)=>Pr(e,t,[`task`,`controlRev`,`observation`,`checkoutGeneration`]);async function Lr(e){jr(e.signal);let t=await e.client.workspace(e.signal);if(jr(e.signal),t.kind===`error`)throw Error(t.error.code);if(t.value.context.status!==`available`)throw Error(`unavailable`);return t.value.context.version}async function Rr(e,t,n){if(n!==`stale`)return Error(n);try{return Nr(Mr(t,t.task?await Vr(e,t.task.id):await Lr(e)))}catch{return Error(`stale`)}}async function zr(e,t){if(jr(e.signal),Date.now()>=Date.parse(t.preflight.expiresAt))throw Error(`expired`);e.observe({commandId:t.commandId,error:`Admission pending/unknown — observe this exact receipt.`});let n=await Sr(e.client,t);if(n.kind===`error`)throw e.observe({commandId:t.commandId,error:`${n.error.code}; effect ${n.error.effect}`}),await Rr(e,t.preflight.preview.version,n.error.code);if(e.observe({commandId:t.commandId,receipt:n.value}),jr(e.signal),n.value.admission!==`accepted`)throw Error(n.value.admission);return n.value}async function Br(e,t){let n=t,r=Date.now()+3e4;for(;n.publication===`pending`&&Date.now()<r;){jr(e.signal),await new Promise(e=>setTimeout(e,250)),jr(e.signal);let t=await e.client.receipt(n.commandId,e.signal);if(jr(e.signal),e.observe({commandId:n.commandId,lookup:t}),t.status===`absent`)throw Error(`receipt-inconclusive`);t.status===`found`&&(n=t.receipt)}if(n.admission!==`accepted`||n.publication!==`published`)throw Error(`Publication unconfirmed. Observe the original receipt; do not repeat the action.`);return n}async function Vr(e,t){jr(e.signal);let n=await e.client.current({storeId:e.storeId,taskId:t},e.signal);if(jr(e.signal),n.kind===`error`)throw Error(n.error.code);if(n.value.context.status!==`available`)throw Error(`unavailable`);let r=n.value.context.version;if(r.task?.id!==t)throw Error(`stale`);return r}async function Hr(e){let t=await Lr(e);Ir(e.context,t);let n=await xr(e.client,t,{kind:`create`,taskKind:`code`,goal:e.goal});if(n.kind===`error`)throw await Rr(e,t,n.error.code);let r=await Br(e,await zr(e,n.value));if(r.created?.state!==`published`)throw Error(`receipt-inconclusive`);let i=r.created.taskId,a=await Vr(e,i);Ir(t,a);let o=await xr(e.client,a,{kind:`generate-plan`,taskId:i});if(o.kind===`error`)throw await Rr(e,a,o.error.code);return await zr(e,o.value),i}async function Ur(e){let{prepared:t}=e,n=t.preflight.preview;if(n.action.kind!==`save-plan`)throw Error(`invalid`);await Br(e,await zr(e,t));let r=await Vr(e,n.action.taskId);if(Fr(n.version,r),r.task?.kind!==n.version.task?.kind||r.task?.revision!==(n.version.task?.revision??0)+1)throw Error(`stale`);let i=await xr(e.client,r,{kind:`start`,taskId:n.action.taskId});if(i.kind===`error`)throw await Rr(e,r,i.error.code);if(i.value.preflight.preview.readablePlan!==n.action.plan||W(i.value.preflight.preview.graph)!==W(n.action.graph))throw Error(`stale`);await zr(e,i.value)}function Wr(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(ln(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 Gr(e,t){let n=/^(?:\/cadence|cadence)(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}var Kr=e=>e===`unauthenticated`||e===`forbidden`,qr=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new wr,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0},v=()=>!r&&n===this.version,y=()=>{v()&&t({..._,observation:c.state})},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new wr,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,Kr(e.error.code)&&w(),!1):(T(e.value),!0)};if(t&&!await i())return;e||(_.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(a.kind===`ok`)_.activeRuns=a.value;else if(Kr(a.error.code)){w();return}else _.activeRuns=void 0;y();let o=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(o.kind===`error`){_.error=o.error.code,Kr(o.error.code)&&w();return}if(!t&&W(_.workspace?.models??[])!==W(o.value.models)&&!await i())return;if(_.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,Kr(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new wr,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Tr?{kind:`browser`,...Tr}:null;_.compatible=Qe(e.build,t),_.cancelCompatible=Qe(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new wr,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new wr,_={actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function Jr(e,t,n){let r=(0,f.useMemo)(()=>new qr(e),[e]),[i,a]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),o=t?.kind,s=t?.id;return(0,f.useEffect)(()=>{if(a({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return r.observe(o&&s?{kind:o,id:s}:null,a)},[r,o,s,n]),{...i,refresh:(e=!1)=>r.refresh(e)}}var Yr=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 Xr(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
3
|
+
`)}if(new TextEncoder().encode(o).length>D.controlBytes)throw new k(`oversize`)}if(n){if(o)throw new k(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=J(e);if(!this.attachment||!this.options.socket)throw new k(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${this.options.project?`/projects/${this.options.project}`:``}${hn}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=D.staleMs&&u(`stale`);try{Date.now()-c>=D.reconcileMs?(i.send(W({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},D.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(W({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new k(`invalid`);let n=wn(ne(e.data,D.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function En(e,t){if(!e.body)throw new k(`invalid`);let n=e.body.getReader(),r=new TextDecoder(`utf-8`,{fatal:!0}),i=0,a=``;try{for(;;){let{value:e,done:o}=await n.read();if(o)return a+r.decode();if(i+=e.byteLength,i>t)throw new k(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var Dn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},On=f.createContext&&f.createContext(Dn),kn=[`attr`,`size`,`title`];function An(e,t){if(e==null)return{};var n,r,i=jn(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 jn(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 Mn(){return Mn=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},Mn.apply(null,arguments)}function Nn(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 Pn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Nn(Object(n),!0).forEach(function(t){Fn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Nn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fn(e,t,n){return(t=In(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function In(e){var t=Ln(e,`string`);return typeof t==`symbol`?t:t+``}function Ln(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 Rn(e){return e&&e.map((e,t)=>f.createElement(e.tag,Pn({key:t},e.attr),Rn(e.child)))}function Q(e){return t=>f.createElement(zn,Mn({attr:Pn({},e.attr)},t),Rn(e.child))}function zn(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=An(e,kn),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,Mn({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:Pn(Pn({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 On===void 0?t(Dn):f.createElement(On.Consumer,null,e=>t(e))}function Bn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`18`,y1:`6`,x2:`6`,y2:`18`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`6`,x2:`18`,y2:`18`},child:[]}]})(e)}function Vn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2`},child:[]},{tag:`circle`,attr:{cx:`8.5`,cy:`7`,r:`4`},child:[]},{tag:`polyline`,attr:{points:`17 11 19 13 23 9`},child:[]}]})(e)}function Hn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`3 6 5 6 21 6`},child:[]},{tag:`path`,attr:{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`},child:[]},{tag:`line`,attr:{x1:`10`,y1:`11`,x2:`10`,y2:`17`},child:[]},{tag:`line`,attr:{x1:`14`,y1:`11`,x2:`14`,y2:`17`},child:[]}]})(e)}function Un(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z`},child:[]}]})(e)}function Wn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]}]})(e)}function Gn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`3`,x2:`9`,y2:`21`},child:[]}]})(e)}function Kn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`11`,cy:`11`,r:`8`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`},child:[]}]})(e)}function qn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`23 4 23 10 17 10`},child:[]},{tag:`polyline`,attr:{points:`1 20 1 14 7 14`},child:[]},{tag:`path`,attr:{d:`M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15`},child:[]}]})(e)}function Jn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`line`,attr:{x1:`5`,y1:`12`,x2:`19`,y2:`12`},child:[]}]})(e)}function Yn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`},child:[]}]})(e)}function Xn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`3`,y1:`12`,x2:`21`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`6`,x2:`21`,y2:`6`},child:[]},{tag:`line`,attr:{x1:`3`,y1:`18`,x2:`21`,y2:`18`},child:[]}]})(e)}function Zn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`},child:[]},{tag:`polyline`,attr:{points:`16 17 21 12 16 7`},child:[]},{tag:`line`,attr:{x1:`21`,y1:`12`,x2:`9`,y2:`12`},child:[]}]})(e)}function Qn(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`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 $n(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`},child:[]},{tag:`path`,attr:{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`},child:[]}]})(e)}function er(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polygon`,attr:{points:`12 2 2 7 12 12 22 7 12 2`},child:[]},{tag:`polyline`,attr:{points:`2 17 12 22 22 17`},child:[]},{tag:`polyline`,attr:{points:`2 12 12 17 22 12`},child:[]}]})(e)}function tr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`},child:[]},{tag:`polyline`,attr:{points:`9 22 9 12 15 12 15 22`},child:[]}]})(e)}function nr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`line`,attr:{x1:`2`,y1:`12`,x2:`22`,y2:`12`},child:[]},{tag:`path`,attr:{d:`M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z`},child:[]}]})(e)}function rr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`18`,cy:`18`,r:`3`},child:[]},{tag:`circle`,attr:{cx:`6`,cy:`6`,r:`3`},child:[]},{tag:`path`,attr:{d:`M13 6h3a2 2 0 0 1 2 2v7`},child:[]},{tag:`line`,attr:{x1:`6`,y1:`9`,x2:`6`,y2:`21`},child:[]}]})(e)}function ir(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`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 ar(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z`},child:[]}]})(e)}function or(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z`},child:[]},{tag:`polyline`,attr:{points:`13 2 13 9 20 9`},child:[]}]})(e)}function sr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 cr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 lr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z`},child:[]}]})(e)}function ur(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`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 dr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,ry:`2`},child:[]},{tag:`rect`,attr:{x:`9`,y:`9`,width:`6`,height:`6`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`1`,x2:`9`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`1`,x2:`15`,y2:`4`},child:[]},{tag:`line`,attr:{x1:`9`,y1:`20`,x2:`9`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`15`,y1:`20`,x2:`15`,y2:`23`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`9`,x2:`23`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`20`,y1:`14`,x2:`23`,y2:`14`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`9`,x2:`4`,y2:`9`},child:[]},{tag:`line`,attr:{x1:`1`,y1:`14`,x2:`4`,y2:`14`},child:[]}]})(e)}function fr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`rect`,attr:{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`,ry:`2`},child:[]},{tag:`path`,attr:{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`},child:[]}]})(e)}function pr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`circle`,attr:{cx:`12`,cy:`12`,r:`10`},child:[]},{tag:`polyline`,attr:{points:`12 6 12 12 16 14`},child:[]}]})(e)}function mr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`18 15 12 9 6 15`},child:[]}]})(e)}function hr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 18 15 12 9 6`},child:[]}]})(e)}function gr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`6 9 12 15 18 9`},child:[]}]})(e)}function _r(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`20 6 9 17 4 12`},child:[]}]})(e)}function vr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`polyline`,attr:{points:`9 11 12 14 22 4`},child:[]},{tag:`path`,attr:{d:`M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11`},child:[]}]})(e)}function yr(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`19`,x2:`12`,y2:`5`},child:[]},{tag:`polyline`,attr:{points:`5 12 12 5 19 12`},child:[]}]})(e)}function br(e){return Q({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}async function xr(e,t,n){let r=await e.preflight(t,n);return r.kind===`error`?r:{kind:`ok`,value:{preflight:r.value,commandId:crypto.randomUUID(),submitted:!1}}}function Sr(e,t){if(t.submitted)throw Error(`Already submitted; observe the same receipt.`);t.submitted=!0;let n=t.preflight,r={commandId:t.commandId,expected:n.preview.version,grant:n.grant},i=n.preview.action;switch(i.kind){case`create`:return e.create({...r,action:i});case`save-plan`:return e.savePlan({...r,action:i});case`generate-plan`:return e.generatePlan({...r,action:i});case`start`:return e.start({...r,action:i});case`check`:return e.check({...r,action:i});case`review`:return e.review({...r,action:i})}}var $=e=>({kind:`error`,error:A(`unavailable`,e?`uncertain`:`none`)}),Cr=class{transport;constructor(e){this.transport=e}async workbenchRead(e,t){let n=ln(e);try{return this.transport.workbenchRead?X(await this.transport.workbenchRead(n,t),pn):$(!1)}catch{return $(!1)}}async workbenchCommand(e){let t=un(e);try{if(!this.transport.workbenchCommand)return $(!0);let e=X(await this.transport.workbenchCommand(t),pn);return e.kind===`ok`&&(!(`commandId`in e.value)||e.value.commandId!==t.commandId)?$(!0):e}catch{return $(!0)}}async current(e,t){let n=Kt(e);try{if(!this.transport.current)return $(!1);let e=X(await this.transport.current(n,t),Qt);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async currentChanges(e,t){let n=qt(e);try{if(!this.transport.currentChanges)return $(!1);let e=X(await this.transport.currentChanges(n,t),$t);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async activeRuns(e){try{return this.transport.activeRuns?X(await this.transport.activeRuns(e),qe):$(!1)}catch{return $(!1)}}async models(e){try{return this.transport.models?X(await this.transport.models(e),an):$(!1)}catch{return $(!1)}}async chooseModel(e){let t=nn(e);try{if(!this.transport.chooseModel)return $(!1);let e=X(await this.transport.chooseModel(t),tn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(W(r)!==W(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return $(!0)}return e}catch{return $(!0)}}async checkObligations(e,t){V(e);try{let n=X(await this.transport.checkObligations(e,t),Vt);return n.kind===`ok`&&n.value.taskId!==e?$(!1):n}catch{return $(!1)}}task(e,t){return this.entity(`task`,e,t)}message(e,t){return this.entity(`message`,e,t)}tool(e,t){return this.entity(`tool`,e,t)}async entity(e,t,n){let r=Ht({...t,kind:e});try{let e=X(await this.transport.entity(r,n),Wt);return e.kind===`ok`&&W(e.value.request)!==W(r)?$(!1):e}catch{return $(!1)}}async session(e){try{return X(await this.transport.session(e),_t)}catch{return $(!1)}}async workspace(e){try{return X(await this.transport.workspace(e),vt)}catch{return $(!1)}}tasks(e,t){return this.page(`tasks`,e,t)}runs(e,t){return this.page(`runs`,e,t)}messages(e,t){return this.page(`messages`,e,t)}tools(e,t){return this.page(`tools`,e,t)}contents(e,t){return this.page(`contents`,e,t)}events(e,t){return this.page(`events`,e,t)}checks(e,t){return this.page(`checks`,e,t)}changes(e,t){return this.page(`changes`,e,t)}reviews(e,t){return this.page(`reviews`,e,t)}async page(e,t,n){let r=Z({...t,reader:e});try{let t=X(await this.transport[e](r,n),jt);return t.kind===`ok`&&!Mt(r,t.value)?$(!1):t}catch{return $(!1)}}async graph(e,t){let n=Nt(e);try{let e=X(await this.transport.graph(n,t),Ft);return e.kind===`ok`&&W(e.value.request)!==W(n)?$(!1):e}catch{return $(!1)}}async*export(e,t){let n=It(e),r=new zt(n),i;try{if(t.aborted)throw new k(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new k(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new k(`unavailable`);yield i}catch{throw new k(`unavailable`)}}async preflight(e,t){let n=be({expected:e,action:t});try{let e=X(await this.transport.preflight(n),Te);return e.kind===`ok`&&(W(e.value.preview.version)!==W(n.expected)||W(e.value.preview.action)!==W(n.action))?$(!1):e}catch{return $(!1)}}create(e){return this.execute(`create`,e)}savePlan(e){return this.execute(`save-plan`,e)}generatePlan(e){return this.execute(`generate-plan`,e)}start(e){return this.execute(`start`,e)}check(e){return this.execute(`check`,e)}review(e){return this.execute(`review`,e)}async execute(e,t){let n=xe(t);if(n.action.kind!==e)return{kind:`error`,error:A(`invalid`)};try{let e=X(await this.transport.command(n),$e);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return $(!0);et({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return $(!0)}}async cancel(e){let t=Ce(e);try{let e=X(await this.transport.cancel(t),$e);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return $(!0);et({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return $(!0)}}async receipt(e,t){V(e);try{let n=tt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:A(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=J(e);try{let e=X(await this.transport.snapshot(n,t),at);return e.kind===`ok`&&W(e.value.scope)!==W(n)?$(!1):e}catch{return $(!1)}}async detail(e,t){let n=ke(e);try{let e=X(await this.transport.detail(n,t),lt);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}async search(e,t){let n=ke(e);try{let e=X(await this.transport.search(n,t),dt);return e.kind===`ok`&&W(e.value.cursor)!==W(n)?$(!1):e}catch{return $(!1)}}},wr=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=at(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&W(i.scope)===W(r.scope)&&ee(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=D.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=D.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=ot(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||W(i.scope)!==W(a.scope))return this.resync();let o=ee(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||mt(i.context)!==mt(a.context)||ht(i.context)!==ht(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||W(t.admission)!==W(e.admission))return this.resync();s[n]=e}}if(s.length>D.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{at(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`}},Tr={sourceHash:`c77e313ffb7d7026a27190ad6ce4ce5365601f0ad411f0f902add702d2afb337`,contractHash:`944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a`,buildId:`fc61e56158d0ae6106cb9f0000d593b05c0c8902e0f27e0df5e805d658a90d78`};function Er(e){let t=new Tn({origin:window.location.origin,...e?{project:e}:{},...Tr?{build:{kind:`browser`,...Tr}}:{},socket:e=>new WebSocket(e)});return{client:new Cr(t),transport:t}}async function Dr(e,t,n,r){let i=Qt(e);if(i.context.status!==`available`||!i.context.version.task||!i.readablePlan?.editable||i.savedGraph.status===`unavailable`)throw new k(`unavailable`);let a=i.context.version,o=a.task;if(!o)throw new k(`stale`);let s=M(t,32768),c=ye({kind:`save-plan`,taskId:o.id,plan:s,graph:{schema:`cadence-graph/2`,taskId:o.id,taskKind:o.kind,taskRevision:o.revision+1,revision:(o.graphRevision??0)+1,planRevision:i.savedGraph.status===`saved`?i.savedGraph.planRevision+1:1,plan:{recordId:r.uuid(),version:i.savedGraph.status===`saved`?i.savedGraph.planRevision+1:1,field:`plan`,bytes:N(s),sha256:`0`.repeat(64)},assignments:n}});if(c.kind!==`save-plan`)throw new k(`invalid`);for(let e of c.graph.assignments){let t=i.roles.find(t=>t.role===fe(e.purpose));if(!t||W(t)!==W(e.role)||W(a.model)!==W(e.model))throw new k(`stale`)}c.graph.plan.sha256=await r.sha256(new TextEncoder().encode(s));let l=ye(c);if(l.kind!==`save-plan`)throw new k(`invalid`);return l}var Or=`Current plan metadata unavailable. Observe again; historical text is not action authority.`;function kr(e,t){let n=async n=>{let r=await e.current({storeId:t,taskId:n.task?.id??null});if(r.kind===`error`)throw new k(r.error.code);if(r.value.context.status!==`available`||W(r.value.context.version)!==W(n))throw new k(`stale`);return r.value},r=e=>({kind:`error`,error:A(e instanceof k?e.code:`unavailable`)});return{async read(t,i){try{let r=await n(t);if(!r.readablePlan||r.savedGraph.status===`unavailable`)throw new k(`unavailable`);let a=null;if(r.savedGraph.status===`saved`){let o=r.savedGraph.request;if(i&&(i.storeId!==o.storeId||W(i.graph)!==W(o.graph)||W(i.scope)!==W(o.scope)))throw new k(`stale`);let s=await e.graph(i??o);if(s.kind===`error`)return s;if(await n(t),`kind`in s.value)return{kind:`ok`,value:{...s.value,context:t}};a=s.value.graph}else if(i)throw new k(`stale`);return{kind:`ok`,value:{context:t,roles:r.roles,savedGraph:a,readablePlan:r.readablePlan.text,editable:r.readablePlan.editable}}}catch(e){return r(e)}},async saveAction(e,t){let i=structuredClone(t);try{let t=await Dr(await n(e),i.readablePlan,i.assignments,{uuid:()=>crypto.randomUUID(),sha256:async e=>Array.from(new Uint8Array(await crypto.subtle.digest(`SHA-256`,Uint8Array.from(e))),e=>e.toString(16).padStart(2,`0`)).join(``)});return await n(e),{kind:`ok`,value:t}}catch(e){return r(e)}}}}function Ar(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&ee(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&W(t.settlement)!==W(r.settlement))?i=!0:(!r||ee(t.committedSeq,r.committedSeq)>0||W(r)===W(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}function jr(e){if(e.aborted)throw Error(`canceled`)}function Mr(e,t){return[...new Set([...Object.keys(e),...Object.keys(t)])].filter(n=>W(e[n]??null)!==W(t[n]??null))}function Nr(e){return Error(e.length?`stale: ${e.join(`, `)}`:`stale`)}function Pr(e,t,n){let r=Mr(e,t).filter(e=>!n.includes(e));if(r.length)throw Nr(r)}var Fr=(e,t)=>Pr(e,t,[`task`,`controlRev`]),Ir=(e,t)=>Pr(e,t,[`task`,`controlRev`,`observation`,`checkoutGeneration`]);async function Lr(e){jr(e.signal);let t=await e.client.workspace(e.signal);if(jr(e.signal),t.kind===`error`)throw Error(t.error.code);if(t.value.context.status!==`available`)throw Error(`unavailable`);return t.value.context.version}async function Rr(e,t,n){if(n!==`stale`)return Error(n);try{return Nr(Mr(t,t.task?await Vr(e,t.task.id):await Lr(e)))}catch{return Error(`stale`)}}async function zr(e,t){if(jr(e.signal),Date.now()>=Date.parse(t.preflight.expiresAt))throw Error(`expired`);e.observe({commandId:t.commandId,error:`Admission pending/unknown — observe this exact receipt.`});let n=await Sr(e.client,t);if(n.kind===`error`)throw e.observe({commandId:t.commandId,error:`${n.error.code}; effect ${n.error.effect}`}),await Rr(e,t.preflight.preview.version,n.error.code);if(e.observe({commandId:t.commandId,receipt:n.value}),jr(e.signal),n.value.admission!==`accepted`)throw Error(n.value.admission);return n.value}async function Br(e,t){let n=t,r=Date.now()+3e4;for(;n.publication===`pending`&&Date.now()<r;){jr(e.signal),await new Promise(e=>setTimeout(e,250)),jr(e.signal);let t=await e.client.receipt(n.commandId,e.signal);if(jr(e.signal),e.observe({commandId:n.commandId,lookup:t}),t.status===`absent`)throw Error(`receipt-inconclusive`);t.status===`found`&&(n=t.receipt)}if(n.admission!==`accepted`||n.publication!==`published`)throw Error(`Publication unconfirmed. Observe the original receipt; do not repeat the action.`);return n}async function Vr(e,t){jr(e.signal);let n=await e.client.current({storeId:e.storeId,taskId:t},e.signal);if(jr(e.signal),n.kind===`error`)throw Error(n.error.code);if(n.value.context.status!==`available`)throw Error(`unavailable`);let r=n.value.context.version;if(r.task?.id!==t)throw Error(`stale`);return r}async function Hr(e){let t=await Lr(e);Ir(e.context,t);let n=await xr(e.client,t,{kind:`create`,taskKind:`code`,goal:e.goal});if(n.kind===`error`)throw await Rr(e,t,n.error.code);let r=await Br(e,await zr(e,n.value));if(r.created?.state!==`published`)throw Error(`receipt-inconclusive`);let i=r.created.taskId,a=await Vr(e,i);Ir(t,a);let o=await xr(e.client,a,{kind:`generate-plan`,taskId:i});if(o.kind===`error`)throw await Rr(e,a,o.error.code);return await zr(e,o.value),i}async function Ur(e){let{prepared:t}=e,n=t.preflight.preview;if(n.action.kind!==`save-plan`)throw Error(`invalid`);await Br(e,await zr(e,t));let r=await Vr(e,n.action.taskId);if(Fr(n.version,r),r.task?.kind!==n.version.task?.kind||r.task?.revision!==(n.version.task?.revision??0)+1)throw Error(`stale`);let i=await xr(e.client,r,{kind:`start`,taskId:n.action.taskId});if(i.kind===`error`)throw await Rr(e,r,i.error.code);if(i.value.preflight.preview.readablePlan!==n.action.plan||W(i.value.preflight.preview.graph)!==W(n.action.graph))throw Error(`stale`);await zr(e,i.value)}function Wr(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(ln(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 Gr(e,t){let n=/^(?:\/cadence|cadence)(?:\s+|$)/.exec(e.trimStart());return n?{mode:`cadence`,text:e.trimStart().slice(n[0].length)}:{mode:t,text:e}}var Kr=e=>e===`unauthenticated`||e===`forbidden`,qr=class{api;serial=Promise.resolve();version=0;stopCurrent;pollCurrent;constructor(e){this.api=e}refresh(e=!1){this.pollCurrent?.(e)}observe(e,t){this.stopCurrent?.();let n=++this.version,r=!1,i,a,o,s=new AbortController,c=new wr,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g=!1,_={actions:!1,transportStatus:`closed`,attachmentVersion:0},v=()=>!r&&n===this.version,y=()=>{v()&&t({..._,observation:c.state})},b=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=b;let x=e=>{this.serial=this.serial.then(e).catch(()=>{v()&&(h=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),_.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,_.actions=!1,_.transportStatus=`closed`,_.workspace=void 0,c=new wr,y())})},S=async()=>{await this.api.transport.detach()},C=async(t=!1)=>{if(!v()||!f||d||h)return;d=!0,_.actions=!1;let n=!1;y(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!v()||r.aborted?!1:e.kind===`error`?(_.actions=!1,_.error=e.error.code,Kr(e.error.code)&&w(),!1):(T(e.value),!0)};if(t&&!await i())return;e||(_.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!v()||r.aborted)return;if(a.kind===`ok`)_.activeRuns=a.value;else if(Kr(a.error.code)){w();return}else _.activeRuns=void 0;y();let o=await this.api.client.workspace(r);if(!v()||r.aborted)return;if(o.kind===`error`){_.error=o.error.code,Kr(o.error.code)&&w();return}if(!t&&W(_.workspace?.models??[])!==W(o.value.models)&&!await i())return;if(_.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!v()||r.aborted)return;if(i.kind===`error`)_.error=i.error.code,Kr(i.error.code)&&w();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),_.error=void 0,n=!0}}else _.error=void 0,n=!0}catch{v()&&(_.error=`Observation unavailable.`,_.actions=!1,_.transportStatus=`stale`)}finally{d=!1,m=!n,_.actions=n&&g,y()}},w=()=>{h=!0,_.actions=!1,_.transportStatus=`closed`,_.error=`Access revoked; explicit token re-entry required.`,_.workspace=void 0,_.activeRuns=void 0,c=new wr,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),x(S),y()},T=e=>{let t=Tr?{kind:`browser`,...Tr}:null;_.compatible=Qe(e.build,t),_.cancelCompatible=Qe(e.build,t,!0),g=e.capabilities.actions&&_.compatible},E=async()=>{if(f=!1,await S(),!v()||h)return;let t=await this.api.client.session();if(!v()||h){await S();return}if(t.kind===`error`){h=!0,_.error=`${t.error.code}; explicit re-entry required.`,_.workspace=void 0,c=new wr,_.actions=!1,y();return}if(f=!0,s=new AbortController,c=new wr,_={actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:_.attachmentVersion+1},T(t.value),y(),await C(),!v()||h||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(v()&&!h&&n===u){if(e.kind===`snapshot`){let t=c.install(e.snapshot,Date.now(),c.beginSnapshot());t!==void 0&&(l=t)}else e.kind===`event`?c.receive(e.event,l,Date.now())===`resync`&&C():C();y()}},e=>{v()&&!h&&n===u&&(_.transportStatus=e,e===`closed`&&(f=!1,_.actions=!1,_.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>x(E),1e3)),y())})};return x(E),this.pollCurrent=e=>{C(e)},a=setInterval(()=>{v()&&!h&&(c.tick(Date.now()),y(),(Date.now()-p>=(m?2e3:3e4)||e&&c.needsPoll(Date.now()))&&C())},1e3),()=>{v()&&(b(),x(S))}}};function Jr(e,t,n){let r=(0,f.useMemo)(()=>new qr(e),[e]),[i,a]=(0,f.useState)({actions:!1,transportStatus:`closed`,attachmentVersion:0}),o=t?.kind,s=t?.id;return(0,f.useEffect)(()=>{if(a({actions:!1,transportStatus:`closed`,attachmentVersion:0}),n)return r.observe(o&&s?{kind:o,id:s}:null,a)},[r,o,s,n]),{...i,refresh:(e=!1)=>r.refresh(e)}}var Yr=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 Xr(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
|
|
4
4
|
`).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 Zr=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:Qr(!0)},text:{92:Qr(!1)}});let t={enter:{backslashMathInline:$r,backslashMathDisplay:$r,backslashMathBlock:$r},exit:{backslashMathInline:ei,backslashMathDisplay:ei,backslashMathBlock:ei}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function Qr(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 $r=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)},ei=function(e){this.exit(e)};function ti(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 ni(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return ti(e)}return ti(e)}function ri(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 ni(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}}var ii=(0,f.memo)(function({text:e}){let{t}=C(),[n,r]=(0,f.useState)(!1),{copied:i,copy:a}=ri();return(0,h.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:t(`Copy displayed text`),"aria-label":t(`Copy displayed text`),onClick:()=>{r(!1),a(e).then(e=>r(!e))},children:[i?(0,h.jsx)(_r,{}):(0,h.jsx)(fr,{}),n&&t(`Copy unavailable`)]})}),ai=[s,d,Zr],oi=[s,l,d,Zr],si=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function ci(e){if(e.startsWith(`#`)&&![...e].some(e=>e.charCodeAt(0)<=32))return e;try{let t=new URL(e);return![`https:`,`http:`].includes(t.protocol)||t.username||t.password||t.searchParams.has(`token`)?void 0:e}catch{return}}function li({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,h.jsx)(a,{remarkPlugins:n?oi:ai,rehypePlugins:t?[i,o,...si]:si,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:fi,a:di,img:({alt:e})=>(0,h.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var ui=(0,f.memo)(function(e){return(0,h.jsx)(`div`,{className:`md`,children:(0,h.jsx)(li,{...e})})});function di({href:e,children:t}){let n=e&&ci(e);return n?(0,h.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,h.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function fi({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=Xr(r).map(e=>{let t=`code-offset:${i}`;return i+=pi(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,h.jsxs)(`div`,{className:`codeblock`,children:[(0,h.jsx)(ii,{text:pi(e)}),(0,h.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,h.jsxs)(`div`,{className:`code-line`,children:[o&&(0,h.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,h.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function pi(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(pi).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return pi(t?.children)}return``}function mi({title:e,children:t,onClose:n}){let{t:r}=C(),i=(0,f.useRef)(null),a=(0,f.useId)(),o=(0,f.useRef)(n);return o.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=i.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[]),(0,h.jsxs)(`dialog`,{ref:i,className:`action-dialog`,"aria-labelledby":a,onCancel:e=>{e.preventDefault(),o.current()},children:[(0,h.jsxs)(`header`,{children:[(0,h.jsx)(`h2`,{id:a,children:e}),(0,h.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":r(`Close dialog — no cancellation of accepted work`),title:r(`Close — accepted work is not cancelled`),onClick:n,children:(0,h.jsx)(Bn,{"aria-hidden":`true`})})]}),t]})}function hi({prepared:e,client:t,current:n,onClose:r,onResult:i,attachmentVersion:a}){let{t:o,tx:s}=C(),[c,l]=(0,f.useState)(Date.now()),[u,d]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),1e3);return()=>clearInterval(e)},[]);let p=e.preflight,m=p.preview,g=(0,f.useRef)(a),_=(0,f.useRef)(!1);(!n||W(n)!==W(m.version)||c>=Date.parse(p.expiresAt)||g.current!==a)&&(_.current=!0);let v=_.current,y=async()=>{if(!(v||e.submitted)){d(!0),i({commandId:e.commandId,error:o(`Admission pending/unknown — observe this exact receipt.`)});try{let n=await Sr(t,e);i(n.kind===`ok`?{commandId:e.commandId,receipt:n.value}:{commandId:e.commandId,error:o(`{code}; effect {effect}`,{code:n.error.code,effect:n.error.effect})})}catch{i({commandId:e.commandId,error:o(`Uncertain; do not repeat the action.`)})}r()}};return(0,h.jsxs)(mi,{title:o(`Confirm {action}`,{action:s(m.action.kind)}),onClose:r,children:[(0,h.jsx)(`p`,{children:o(`Access is not consent. This confirmation applies only to the displayed context, once.`)}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:o(`Checkout`)}),(0,h.jsx)(`dd`,{children:m.rootLabel}),(0,h.jsx)(`dt`,{children:o(`Working directory`)}),(0,h.jsx)(`dd`,{children:(0,h.jsx)(`code`,{children:m.cwdLabel})}),(0,h.jsx)(`dt`,{children:o(`Model / API / thinking`)}),(0,h.jsxs)(`dd`,{children:[m.version.model.provider,` / `,m.version.model.model,` /`,` `,m.version.model.api,` / `,m.version.model.thinking]}),(0,h.jsx)(`dt`,{children:o(`Check environment`)}),(0,h.jsx)(`dd`,{children:o(`Service launch environment policy, generation {generation}; no browser environment overlays.`,{generation:m.version.checkEnvGeneration})}),(0,h.jsx)(`dt`,{children:o(`Observation`)}),(0,h.jsx)(`dd`,{children:m.version.observation.complete?o(`Complete within bounded scope`):o(`Incomplete bounded coverage`)}),(0,h.jsx)(`dt`,{children:o(`Expires`)}),(0,h.jsx)(`dd`,{children:p.expiresAt})]}),(0,h.jsx)(gi,{preview:m}),m.action.kind===`check`&&(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:o(`Exact parent check`)}),(0,h.jsx)(`pre`,{children:m.action.check.command}),(0,h.jsx)(`p`,{children:o(`{name}; timeout {timeout} ms; cwd above.`,{name:m.action.check.name,timeout:m.action.check.timeoutMs})})]}),m.action.kind===`generate-plan`&&(0,h.jsx)(`p`,{children:o(`Readonly proposal only. It will not save itself or dispatch editing.`)}),m.issues.length>0&&(0,h.jsx)(`p`,{role:`alert`,children:o(`Issues: {issues}`,{issues:m.issues.map(s).join(`, `)})}),v&&(0,h.jsx)(`p`,{role:`alert`,children:o(`Context changed or confirmation expired. Close, observe again and request a new preview.`)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,onClick:r,children:o(`Back — no new effect`)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:v||u||e.submitted,onClick:()=>void y(),children:o(`Confirm {action}`,{action:s(m.action.kind)})})]})]})}function gi({preview:e}){let{t,tx:n}=C(),r=e.action,i=r.kind===`save-plan`?r.graph:e.graph;return(0,h.jsxs)(h.Fragment,{children:[r.kind===`create`&&(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:t(`Create {kind} task`,{kind:n(r.taskKind)})}),(0,h.jsx)(`pre`,{children:r.goal}),(0,h.jsx)(`p`,{children:t(`No Start is included.`)})]}),r.kind!==`create`&&(0,h.jsx)(ui,{text:r.kind===`save-plan`?r.plan:e.readablePlan}),i?.assignments.map(e=>(0,h.jsxs)(`section`,{children:[(0,h.jsxs)(`h3`,{children:[e.id,` · `,e.purpose]}),(0,h.jsxs)(`p`,{children:[e.role.role,` / `,e.role.sha256]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.model,null,2)}),(0,h.jsx)(ui,{text:e.instructions}),(0,h.jsx)(`p`,{children:t(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.dependencies,null,2)})]},e.id)),r.kind===`save-plan`&&(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`h3`,{children:t(`Exact proposed graph and identities (not yet committed)`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(r.graph,null,2)})]}),r.kind===`review`&&(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:t(`Exact human review targets`)}),(0,h.jsx)(`pre`,{children:JSON.stringify(r,null,2)}),(0,h.jsx)(`p`,{children:t(`Human review only; failures, native exit, stale and not-run checks remain unchanged. Issues acknowledgment: {accepted}.`,{accepted:String(r.acceptIssues)})})]})]})}function _i({client:e,compatible:t,onClose:n,onChanged:r}){let{t:i,tx:a}=C(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(``),[u,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(``),[g,_]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=new AbortController;return e.models(t.signal).then(e=>{t.signal.aborted||(e.kind===`ok`?s(e.value):d(e.error.code))}).catch(()=>{t.signal.aborted||d(`unavailable`)}),()=>t.abort()},[e]),(0,h.jsxs)(mi,{title:i(`Choose owner model`),onClose:n,children:[(0,h.jsx)(`p`,{children:i(`Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.`)}),(0,h.jsx)(`p`,{children:i(`Current: {model}`,{model:o?.selected?`${o.selected.provider}/${o.selected.model} · ${o.selected.thinking}`:i(`No model selected`)})}),(0,h.jsxs)(`label`,{children:[i(`Exact model / API / thinking`),(0,h.jsxs)(`select`,{value:c,disabled:!o,onChange:e=>l(e.target.value),children:[(0,h.jsx)(`option`,{value:``,children:i(`Select explicitly`)}),o?.entries.flatMap(e=>e.thinking.filter(e=>e.selectable).map(t=>{let n=JSON.stringify({provider:e.provider,model:e.model,api:e.api,thinking:t.level});return(0,h.jsxs)(`option`,{value:n,children:[e.provider,`/`,e.model,` · `,e.api,` · `,t.level]},n)}))]})]}),o?.status===`capacity`&&(0,h.jsx)(`p`,{children:i(`Catalog capacity exceeded; no partial model list is selectable.`)}),!!o?.withheld&&(0,h.jsx)(`p`,{role:`alert`,children:i(o.withheld===1?`{count} model withheld: its provider or model ID contains a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`:`{count} models withheld: their provider or model IDs contain a credential value (such as an apiKey equal to the provider name) or control characters. Give each credential a value that matches no provider or model ID; restart the service after editing models.json.`,{count:o.withheld})}),u&&(0,h.jsx)(`p`,{role:`alert`,children:i(`Model catalog unavailable ({code}); no model is selectable. No automatic retry.`,{code:a(u)})}),p&&(0,h.jsx)(`p`,{role:`alert`,children:i(`{error}. No automatic replacement or retry.`,{error:a(p)})}),(0,h.jsx)(`button`,{type:`button`,disabled:!t||!o||!c||g,onClick:()=>{o&&(_(!0),e.chooseModel({expected:o.version,choice:le(JSON.parse(c))}).then(e=>{e.kind===`error`?m(e.error.code):(r(),n())}).catch(()=>m(`Choice response unconfirmed; observe catalog before another explicit choice.`)).finally(()=>_(!1)))},children:i(`Confirm owner model choice`)})]})}function vi({client:e,value:t,onChange:n}){let{t:r,tx:i}=C(),a=(0,f.useRef)(!0),o=(0,f.useRef)(null);(0,f.useEffect)(()=>(a.current=!0,()=>{a.current=!1,o.current?.abort()}),[]);let[s,c]=(0,f.useState)(!1),l=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,h.jsxs)(`section`,{className:`receipt`,"aria-label":r(`Command receipt`),children:[(0,h.jsx)(`h3`,{children:r(`Command receipt`)}),(0,h.jsx)(`code`,{children:t.commandId}),t.error&&(0,h.jsx)(`p`,{role:`alert`,children:i(t.error)}),l&&(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:r(`Admission`)}),(0,h.jsx)(`dd`,{children:i(l.admission)}),(0,h.jsx)(`dt`,{children:r(`Execution`)}),(0,h.jsx)(`dd`,{children:l.execution?i(l.execution):r(`not settled`)}),(0,h.jsx)(`dt`,{children:r(`Publication`)}),(0,h.jsx)(`dd`,{children:i(l.publication)}),(0,h.jsx)(`dt`,{children:r(`Run`)}),(0,h.jsx)(`dd`,{children:l.runId??r(`metadata action`)})]}),t.lookup&&t.lookup.status!==`found`&&(0,h.jsx)(`p`,{children:r(`{status}. This observation does not authorize replay.`,{status:i(t.lookup.status)})}),(0,h.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>{c(!0),o.current=new AbortController,e.receipt(t.commandId,o.current.signal).then(e=>{a.current&&(n({commandId:t.commandId,lookup:e}),c(!1))})},children:r(`Observe exact receipt`)})]})}function yi(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 bi(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 xi(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 Si(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=yi(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 Ci(e,t){let n=t?W({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),bi(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 wi({value:e,compact:t=!1}){let{t:n,tx:r}=C();return t&&e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?(0,h.jsxs)(`details`,{className:`coverage-details`,children:[(0,h.jsx)(`summary`,{children:n(`Recording details`)}),(0,h.jsx)(wi,{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 Ti(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 Ei=new Map;function Di(e,t){t.length?Ei.set(e,t):Ei.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Ei].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 Oi(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 ki(e,t){let n=t.startContainer.parentElement;for(let r of Oi(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 Ai({container:e,version:t}){let{t:n}=C(),[r,i]=(0,f.useState)(``),[a,o]=(0,f.useState)(0),[s,c]=(0,f.useState)(0),l=(0,f.useRef)([]),u=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let n=e.current,i=n&&r?Ti(n,r):[];return l.current=i,c(i.length),o(0),Di(u,i),()=>Di(u,[])},[r,e,t,u]);let d=t=>{let n=s?(a+t+s)%s:0;o(n),e.current&&l.current[n]&&(ki(e.current,l.current[n]),Di(`${u}-active`,[l.current[n]]))};return(0,f.useEffect)(()=>()=>Di(`${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 ji({client:e,cursor:t,highlight:n,render:r,compact:i=!1}){let{t:a,tx:o}=C(),s=W(t),c=(0,f.useMemo)(()=>ke(JSON.parse(s)),[s]),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)(),[m,g]=(0,f.useState)([]),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),[x,S]=(0,f.useState)(i?`markdown`:`raw`),[w,T]=(0,f.useState)(``),E=(0,f.useRef)(null),D=(0,f.useRef)(null);(0,f.useEffect)(()=>(u(c),g([]),p(void 0),b(void 0),()=>E.current?.abort()),[c]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return v(!0),b(void 0),e.detail(l,n.signal).then(e=>{t&&(v(!1),e.kind===`error`?b(e.error.code):p(e.value))}).catch(()=>{t&&(b(`Read unavailable.`),v(!1))}),()=>{t=!1,n.abort()}},[e,l]);let O=async()=>{if(E.current)return;let n=new AbortController;E.current=n,T(a(`Reading all retained field pages…`));try{let r=await Si(e,t,n.signal);if(n.signal.aborted)return;let i=await ni(r.text);if(n.signal.aborted)return;T(i?r.recordingComplete?a(`Copied all retained field bytes (source omissions still apply).`):a(`Copied retained field bytes; recording is incomplete. No complete-source claim.`):a(`Clipboard unavailable.`))}catch{n.signal.aborted||T(a(`Full-field copy refused/incomplete.`))}finally{E.current===n&&(E.current=null)}},k=d&&!(`kind`in d)?d:void 0;return(0,h.jsxs)(`section`,{className:`detail-pane${i?` message-field`:``}`,"aria-label":a(`Retained field`),children:[(0,h.jsxs)(`details`,{className:`field-details`,open:!i||void 0,children:[(0,h.jsx)(`summary`,{children:a(`Field details`)}),(0,h.jsxs)(`div`,{className:`detail-identity`,children:[(0,h.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` /`,` `,t.field&&o(t.field),` /`,` `,a(`snapshot {seq}`,{seq:t.snapshotSeq})]}),n&&(0,h.jsx)(`p`,{children:a(`Exact hit bytes [{start}, {end}); only this immutable field is highlighted.`,{start:n.start,end:n.end})}),(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,onClick:()=>S(e=>e===`raw`?`markdown`:`raw`),children:a(x===`raw`?`Markdown page`:`Raw page`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!!E.current,onClick:()=>void O(),children:a(`Copy full retained field`)}),!!E.current&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{E.current?.abort(),E.current=null,T(a(`Copy canceled; execution unchanged.`))},children:a(`Cancel copy`)})]})]}),w&&(0,h.jsx)(`p`,{role:`status`,children:w}),y&&(0,h.jsx)(`p`,{role:`alert`,children:a(`Detail refused: {error}`,{error:o(y)})}),_&&(0,h.jsx)(`p`,{role:`status`,children:a(`Reading…`)}),d&&(0,h.jsx)(wi,{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)(Ai,{container:D,version:`${k.content.recordId}:${k.content.version}:${k.range?.start??0}:${x}`}),(0,h.jsx)(`div`,{ref:D,"data-retained-field":!0,children:r?r(k.text):x===`markdown`?(0,h.jsx)(ui,{text:k.text}):(0,h.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!k||!n||!k.range)return k?.text;let e=Math.max(n.start,k.range.start)-k.range.start,t=Math.min(n.end,k.range.end)-k.range.start;if(t<=e)return k.text;let r=new TextEncoder().encode(k.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,h.jsxs)(h.Fragment,{children:[i(0,e),(0,h.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(!i||m.length>0||d?.next)&&(0,h.jsxs)(`div`,{className:`toolbar`,children:[(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.length,onClick:()=>{u(m[m.length-1]),g(e=>e.slice(0,-1))},children:a(`Previous`)}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!d?.next,onClick:()=>{d?.next&&(g(e=>[...e,l]),u(d.next))},children:d&&`kind`in d?a(`Continue validation`):a(`Next field page`)})]})]})}function Mi({pager:e,compact:t=!1}){let{t:n,tx:r}=C(),{page:i,busy:a,error:o}=e;return(0,h.jsxs)(`div`,{className:`page-controls${t?` compact`:``}`,children:[o&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Read refused: {error}. Retained state has not been repaired.`,{error:r(o)})}),a&&(0,h.jsx)(`p`,{role:`status`,children:n(`Reading bounded history page…`)}),i&&`kind`in i&&(0,h.jsxs)(`p`,{role:`status`,children:[i.kind===`snapshot`?n(`Snapshot selected`):n(`Validating retained history`),n(`; continue this exact read. No data page yet.`)]}),i&&(0,h.jsx)(wi,{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)(qn,{"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 Ni({client:e,seed:t,entityId:n}){let{t:r,tx:i}=C(),a=Ci(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)(Mi,{pager:a}),n&&(0,h.jsx)(`p`,{children:(0,h.jsx)(y,{text:r(`Showing matches for entity {entity} on this page only. Continue paging for other fields/versions.`),slots:{entity:(0,h.jsx)(`code`,{children:n})}})}),c&&!(`kind`in c)&&c.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,h.jsxs)(`p`,{className:`omission`,children:[r(`Omitted source block:`),` `,(0,h.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`p`,{children:[i(e.owner.entity.kind),` `,(0,h.jsx)(`code`,{children:e.owner.entity.id}),` ·`,` `,i(e.content.field),` ·`,` `,r(`{bytes} retained bytes`,{bytes:e.content.bytes})]}),(0,h.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,h.jsx)(wi,{value:e.coverage}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>{c.request.scope.kind!==`workspace`&&c.request.snapshotSeq!==null&&s(xi(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)(ji,{client:e,cursor:o},`${o.recordId}:${o.recordVersion}`)]})}function Pi({client:e,seed:t}){return(0,h.jsx)(Fi,{client:e,seed:t},W(t))}function Fi({client:e,seed:t}){let{t:n,tx:r}=C(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),(i.kind===`message`?e.message(i,n.signal):i.kind===`tool`?e.tool(i,n.signal):e.task(i,n.signal)).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{"aria-label":n(`Exact entity metadata`),children:[u&&(0,h.jsx)(`p`,{children:n(`Reading exact entity version…`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Entity refused: {error}`,{error:r(c)})}),o&&`kind`in o&&(0,h.jsx)(wi,{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 Ii(e=typeof window>`u`?``:window.location.search){let t=new URLSearchParams(e).get(`project`);return t&&/^[a-f0-9]{64}$/.test(t)?t:null}function Li(){let e=Ii();return e?`/projects/${e}`:``}function Ri(e){let t=Cn(`download`,It(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=Li()+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 zi({request:e,onClose:t}){let{t:n,tx:r}=C(),[i]=(0,f.useState)(e),[a,o]=(0,f.useState)(e.format),[s,c]=(0,f.useState)(``);return(0,h.jsxs)(mi,{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{Ri({...i,format:a}),c(n(`Download requested — completion not verified by this browser UI.`))}catch{c(n(`Download unavailable; no archive claimed complete.`))}},children:n(`Request selected-scope download`)}),(0,h.jsx)(`p`,{role:`status`,children:s})]})}function Bi(e,t){if(!t||N(t)>D.queryBytes)throw Error(`Query must be 1–${D.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return ke({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function Vi(e){return e.next?`No hits in this bounded window; search is not finished.`:`No hits in the final retained window. Coverage limits above still apply.`}function Hi({client:e,seed:t,onClose:n,onHit:r}){let{t:i,tx:a}=C(),[o]=(0,f.useState)(t),s=(0,f.useRef)(null),c=(0,f.useRef)(0),[l,u]=(0,f.useState)(``),[d,p]=(0,f.useState)(0),[m,g]=(0,f.useState)(),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(),x=(0,f.useRef)(null),S=(0,f.useCallback)(async(t,n)=>{x.current?.abort();let r=new AbortController;x.current=r,v(!0),b(void 0);try{let i=await e.search(t,r.signal);if(c.current!==n||r.signal.aborted)return;i.kind===`error`?b(i.error.code):(g(i.value),p(0))}catch{c.current===n&&!r.signal.aborted&&b(`Search unavailable or invalid; no automatic retry.`)}finally{c.current===n&&!r.signal.aborted&&v(!1)}},[e]);return(0,f.useEffect)(()=>(s.current?.focus(),()=>{c.current++,x.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++c.current;if(x.current?.abort(),v(!1),g(void 0),p(0),b(void 0),!l)return;let t;try{t=Bi(o,l)}catch{b(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void S(t,e),300);return()=>{clearTimeout(n),c.current++,x.current?.abort()}},[l,o,S]),(0,h.jsx)(mi,{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)(Kn,{}),(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)(wi,{value:m.coverage}),(0,h.jsxs)(`div`,{className:`gs-section`,children:[(0,h.jsx)(`div`,{className:`gs-section-head`,children:i(`Matches on this page: {count}`,{count:m.hits.length})}),m.hits.map((e,t)=>(0,h.jsxs)(`button`,{type:`button`,className:`gs-item ${d===t?`active`:``}`,onMouseEnter:()=>p(t),onClick:()=>{r(e),n()},children:[(0,h.jsxs)(`span`,{className:`gs-item-title`,children:[a(e.owner.entity.kind),` · `,a(e.content.field),` · v`,e.content.version]}),(0,h.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,h.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` /`,` `,i(`bytes {start}–{end}`,{start:e.range.start,end:e.range.end})]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),m.hits.length===0&&(0,h.jsx)(`p`,{children:a(Vi(m))})]}),(0,h.jsx)(`button`,{type:`button`,disabled:_||!m.next,onClick:()=>{m.next&&S(m.next,++c.current)},children:i(`Continue same snapshot search`)})]})]}),(0,h.jsx)(`footer`,{className:`gs-foot`,children:i(`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`)})]})})}function Ui({run:e,historical:t=!1}){let{t:n,tx:r}=C();return(0,h.jsxs)(`article`,{className:`run-summary`,children:[(0,h.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,n(t?`historical projection`:`owner projection`)]}),(0,h.jsx)(`p`,{children:(0,h.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,h.jsxs)(`dl`,{children:[(0,h.jsx)(`dt`,{children:n(`Lifecycle`)}),(0,h.jsx)(`dd`,{children:r(e.lifecycle)}),(0,h.jsx)(`dt`,{children:n(`Execution`)}),(0,h.jsx)(`dd`,{children:e.outcome?r(e.outcome):n(`unsettled`)}),(0,h.jsx)(`dt`,{children:n(`Wait/block reason`)}),(0,h.jsx)(`dd`,{children:e.reason?r(e.reason):n(`none reported`)}),(0,h.jsx)(`dt`,{children:n(`Summary publication`)}),(0,h.jsx)(`dd`,{children:r(e.publication)})]}),(0,h.jsx)(wi,{value:e.coverage}),(0,h.jsxs)(`details`,{children:[(0,h.jsx)(`summary`,{children:n(`Native / recording / parent settlement facts (independent of human review)`)}),(0,h.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):n(`No settlement recorded`)})]})]})}function Wi({client:e,seed:t}){return(0,h.jsx)(Gi,{client:e,seed:t},W(t))}function Gi({client:e,seed:t}){let{t:n,tx:r}=C(),[i,a]=(0,f.useState)(t),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return d(!0),e.graph(i,n.signal).then(e=>{t&&(d(!1),e.kind===`error`?l(e.error.code):(s(e.value),l(void 0)))}).catch(()=>{t&&(l(`Read unavailable.`),d(!1))}),()=>{t=!1,n.abort()}},[e,i]),(0,h.jsxs)(`section`,{children:[(0,h.jsx)(`h3`,{children:n(`Immutable admitted graph`)}),c&&(0,h.jsx)(`p`,{role:`alert`,children:n(`Graph refused: {error}`,{error:r(c)})}),u&&(0,h.jsx)(`p`,{children:n(`Reading graph…`)}),o&&`kind`in o&&(0,h.jsx)(wi,{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)(ji,{client:e,cursor:xi(o.request.storeId,o.request.scope,o.request.snapshotSeq,o.graph.plan)}),o.graph.assignments.map(e=>(0,h.jsxs)(`article`,{children:[(0,h.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,h.jsx)(ui,{text:e.instructions}),(0,h.jsx)(`p`,{children:n(`Expected: {output}`,{output:e.expectedOutput})}),(0,h.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function Ki({client:e,seed:t,onScope:n}){let{t:r}=C(),i=Ci(e,{...t,reader:`runs`}),a=i.page,[o,s]=(0,f.useState)();return(0,h.jsxs)(`section`,{children:[(0,h.jsx)(Mi,{pager:i}),a&&!(`kind`in a)&&a.records.map(e=>e.kind===`run`?(0,h.jsxs)(`article`,{children:[(0,h.jsx)(Ui,{run:e.projection,historical:!0}),(0,h.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:r(`Open retained episode/child details`)}),e.projection.admission.graph&&(0,h.jsx)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&e.projection.admission.graph&&s({storeId:a.request.storeId,scope:a.request.scope,snapshotSeq:a.request.snapshotSeq,graph:e.projection.admission.graph})},children:r(`Inspect admitted graph and plan`)})]},e.projection.childRunId??e.projection.runId):null),o&&(0,h.jsx)(Wi,{client:e,seed:o},o.graph.recordId)]})}function qi({onOpen:e,disabled:t}){let{t:n}=C();return(0,h.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":n(`Search all retained pages in selected scope`),"data-tip":n(`Search all retained pages in selected scope`),disabled:t,onClick:e,children:(0,h.jsx)(Kn,{"aria-hidden":`true`})})}function Ji({client:e,storeId:t,context:n,runs:r,snapshotSeq:i,canAct:a,onResult:o}){let{t:s,tx:c}=C(),[l,u]=(0,f.useState)(),[d,p]=(0,f.useState)(!1),[m,g]=(0,f.useState)(``),_=(0,f.useRef)(null),v=(0,f.useRef)(!1),y=(0,f.useRef)({context:n,canAct:a});y.current={context:n,canAct:a},(0,f.useEffect)(()=>()=>_.current?.abort(),[]);let b=r.find(e=>e.childRunId&&e.admission.kind===`generate-plan`&&e.lifecycle===`settled`&&e.outcome===`completed`&&e.result&&e.coverage.observed===`complete`),x=b&&r.find(e=>!e.childRunId&&e.runId===b.runId),S=!!b&&x?.lifecycle===`settled`&&x.outcome===`completed`&&x.publication===`published`;l&&(!n||W(l.preflight.preview.version)!==W(n))&&(v.current=!0);let w=!!l&&v.current,T=async()=>{if(!a||!S||!b?.result||!b.childRunId||_.current||!t||!i||!n?.task)return;let r=new AbortController;_.current=r,p(!0),g(``);let o=()=>{if(r.signal.aborted||!y.current.canAct||W(y.current.context)!==W(n))throw Error(`stale`)};try{let a=await Si(e,xi(t,{kind:`child`,id:b.childRunId},i,b.result),r.signal);if(o(),!a.recordingComplete||!a.text.trim())throw Error(`incomplete-content`);let s=kr(e,t),c=await s.read(n);if(o(),c.kind===`error`)throw Error(c.error.code);if(`kind`in c.value)throw Error(`Plan metadata read in progress. Try again after observation completes.`);if(c.value.savedGraph||c.value.readablePlan.trim())throw Error(`This task already has a plan. Review it in Task details instead.`);let l=c.value.roles.find(e=>e.role===`implementation-worker`);if(!l)throw Error(`unavailable`);let d=await s.saveAction(n,{readablePlan:a.text,assignments:[{id:`implement`,purpose:`edit`,instructions:`Implement only the supplied human-approved plan. Stop and report any blocker or required scope change.`,expectedOutput:`Implement the approved plan and report changes, attempted checks and remaining issues.`,role:l,model:n.model,dependencies:[]}]});if(o(),d.kind===`error`)throw Error(d.error.code);let f=await xr(e,n,d.value);if(o(),f.kind===`error`)throw Error(f.error.code);v.current=!1,u(f.value)}catch(e){r.signal.aborted||g(e instanceof Error?e.message:`unavailable`)}finally{r.signal.aborted||p(!1),_.current===r&&(_.current=null)}},E=async()=>{if(!l||w||!a||!t||_.current||l.submitted)return;if(Date.now()>=Date.parse(l.preflight.expiresAt)){g(s(`Plan confirmation expired. Review the plan again.`)),u(void 0);return}let n=new AbortController;_.current=n,p(!0);try{await Ur({client:e,storeId:t,prepared:l,signal:n.signal,observe:o}),n.signal.aborted||u(void 0)}catch(e){n.signal.aborted||(u(void 0),g(s(`Plan execution stopped: {reason}. Observe the original receipt; no automatic retry.`,{reason:e instanceof Error?e.message:`unavailable`})))}finally{n.signal.aborted||p(!1),_.current===n&&(_.current=null)}};return n?.task?.kind!==`code`||!l&&!m&&r.some(e=>e.admission.kind===`start`)?null:(0,h.jsxs)(`section`,{className:`banner-notice`,"aria-label":s(`Plan approval`),children:[(0,h.jsx)(`p`,{children:s(S?`Analysis complete. Review the plan before making changes.`:`Analysis and progress appear below. No edits start before plan approval.`)}),(0,h.jsx)(`button`,{type:`button`,disabled:!a||!S||d,onClick:()=>void T(),children:s(`Review implementation plan`)}),m&&(0,h.jsx)(`p`,{role:`alert`,children:c(m)}),l&&(0,h.jsxs)(mi,{title:s(`Confirm plan and execute`),onClose:()=>{d||u(void 0)},children:[(0,h.jsx)(`p`,{children:s(`Approving saves this exact plan and starts it. No separate Start confirmation is needed.`)}),(0,h.jsxs)(`p`,{children:[(0,h.jsx)(`code`,{children:l.preflight.preview.cwdLabel}),` ·`,` `,n.model.provider,`/`,n.model.model,` ·`,` `,n.model.thinking]}),(0,h.jsx)(gi,{preview:l.preflight.preview}),l.preflight.preview.issues.length>0&&(0,h.jsx)(`p`,{role:`alert`,children:s(`Issues: {issues}`,{issues:l.preflight.preview.issues.map(c).join(`, `)})}),w&&!d&&(0,h.jsx)(`p`,{role:`alert`,children:s(`Context changed. Close and review the plan again.`)}),(0,h.jsxs)(`footer`,{children:[(0,h.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>u(void 0),children:s(`Back — no new effect`)}),(0,h.jsx)(`button`,{type:`button`,className:`primary`,disabled:d||w||!a,onClick:()=>void E(),children:s(`Confirm plan and execute`)})]})]})]})}function Yi(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 Xi(e,t){if(t.show.length===0&&t.hide.length===0)return e;let n=new Set(e);for(let e of t.show)n.delete(e);for(let e of t.hide)n.add(e);return n}function Zi(e,t,n){let r=new Set,i=0;for(let a=e.length-1;a>=0&&!(a<e.length-1&&i>=n);a--){let n=e[a];r.add(n.id),i+=t.get(n.id)??Qi(n.role,n.customType)}return r}function Qi(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 $i(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var ea=(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`})}),ta=(0,f.memo)(function({message:e,client:t,seed:n}){let{t:r,tx:i}=C(),[a,o]=(0,f.useState)(!1);return(0,h.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,h.jsxs)(`header`,{className:`msg-meta`,children:[(0,h.jsx)(`strong`,{className:`msg-role`,children:i(e.role)}),e.state!==`final`&&(0,h.jsx)(`span`,{className:`msg-state`,children:i(e.state)}),(0,h.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[a?(0,h.jsx)(mr,{"aria-hidden":`true`}):(0,h.jsx)(cr,{"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)(ji,{compact:!0,client:t,cursor:xi(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)(Ni,{client:t,seed:n,entityId:e.owner.entity.id})]})]})]})})]})]})});function na({messages:e,client:t,seed:n}){let{t:r}=C(),i=(0,f.useRef)(null),a=(0,f.useRef)(!0),[o,s]=(0,f.useState)(()=>new Set),c=(0,f.useRef)(o);c.current=o;let l=(0,f.useRef)(new Map),u=(0,f.useRef)(new Map),d=(0,f.useRef)(new Map),p=(0,f.useRef)(0),m=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,message:e})),[e]),g=(0,f.useRef)(new Map);g.current=new Map(m.map(e=>[e.id,e.message.version]));let _=(0,f.useRef)(new Set);_.current=Zi(m,l.current,1800);let v=(0,f.useCallback)((e,t)=>{let n=g.current.get(e);n!==void 0&&(u.current.set(e,{h:t,len:n}),l.current.set(e,t))},[]),y=(0,f.useCallback)(()=>{let e=i.current;if(!e)return;let t=e.getBoundingClientRect(),n=[];for(let[e,t]of d.current){let r=t.getBoundingClientRect();n.push({id:e,top:r.top,bottom:r.bottom}),c.current.has(e)||v(e,r.height)}let r=Yi(n,{top:t.top-1200,bottom:t.bottom+1200},_.current,c.current,{top:t.top-2400,bottom:t.bottom+2400});for(let e of r.hide){let t=d.current.get(e);t&&v(e,t.offsetHeight)}s(e=>Xi(e,r))},[v]),b=(0,f.useCallback)(()=>{p.current||=requestAnimationFrame(()=>{p.current=0,y()})},[y]);return(0,f.useLayoutEffect)(()=>{m.length?y():s(new Set)},[y,m]),(0,f.useEffect)(()=>{let e=new ResizeObserver(b);return i.current&&e.observe(i.current),()=>{e.disconnect(),cancelAnimationFrame(p.current)}},[b]),(0,h.jsxs)(`div`,{className:`messages-wrap`,children:[(0,h.jsx)(`div`,{className:`messages`,ref:i,onScroll:e=>{let t=e.currentTarget;a.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,b()},children:m.map(({id:e,role:r,message:a})=>(0,h.jsx)(ea,{id:e,show:!o.has(e),height:$i(e,a.version,u.current,r===`user`?100:280),containerRef:i,onMeasured:v,lazyRef:t=>{t?d.current.set(e,t):d.current.delete(e)},children:(0,h.jsx)(ta,{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)(br,{"aria-hidden":`true`}),r(`Latest on loaded page`)]})]})}function ra({client:e,seed:t}){let{t:n}=C(),r=Ci(e,{...t,reader:`messages`}),i=r.page;return(0,h.jsxs)(`section`,{className:`transcript`,children:[(0,h.jsx)(Mi,{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)(na,{messages:i.records.filter(e=>e.kind===`message`),client:e,seed:i.request},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})]})}function ia({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)(gr,{}):(0,h.jsx)(hr,{})}):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 aa=(0,f.memo)(function({record:e,client:t,seed:n}){let{t:r,tx:i}=C(),[a,o]=(0,f.useState)(!1),s=e.result?e.result.isError?r(`SDK tool error observed`):r(`SDK tool end observed`):e.startObserved?r(`Start observed; end not observed in this snapshot`):r(`No start observed`),c=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,h.jsxs)(`div`,{className:`toolcall${c===`err`?` err`:``}`,children:[(0,h.jsx)(ia,{open:a,onToggle:()=>o(e=>!e),headClassName:`toolcall-head`,titleText:r(`Inspect recorded tool call`),icon:(0,h.jsx)(Un,{}),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)(Ni,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})});function oa({client:e,active:t,taskId:n,runs:r,snapshot:i,onOpen:a}){let{t:o,tx:s}=C(),[c,l]=(0,f.useState)(!0),[u,d]=(0,f.useState)([]),[p,m]=(0,f.useState)(!1),g=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(g)){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||(d(i),m(a),n=setTimeout(()=>void r(),3e3))};return r(),()=>{t.abort(),clearTimeout(n)}},[e,g]);let _=n&&i?r.filter(e=>e.childRunId).map(e=>({taskId:n,run:e,snapshot:i})):[],v=[...u,..._.filter(e=>!u.some(t=>t.run.childRunId===e.run.childRunId))].sort((e,t)=>Number(e.run.lifecycle===`settled`)-Number(t.run.lifecycle===`settled`));return(0,h.jsxs)(`section`,{className:`agent-dock${c?``:` collapsed`}`,children:[(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-heading`,"aria-expanded":c,onClick:()=>l(e=>!e),children:[(0,h.jsx)(gr,{}),(0,h.jsx)(dr,{}),(0,h.jsx)(`span`,{children:o(`Subagents`)}),(0,h.jsx)(`span`,{className:`lp-count`,children:v.length})]}),c&&(0,h.jsxs)(`div`,{className:`agent-dock-body`,children:[(p||t?.status!==`complete`)&&(0,h.jsx)(`p`,{className:`panel-hint`,children:o(`Subagent roster unavailable`)}),v.length===0&&!p&&t?.status===`complete`&&(0,h.jsx)(`p`,{className:`panel-hint`,children:o(`Cadence subagents appear here when a task runs.`)}),v.map(e=>(0,h.jsxs)(`button`,{type:`button`,className:`agent-dock-row`,onClick:()=>a(e.taskId,e.run.childRunId,e.snapshot,e.run.assignmentId??o(`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??o(`Subagent`)}),(0,h.jsx)(`small`,{children:o(`Task {id}`,{id:e.taskId.slice(0,8)})})]}),(0,h.jsx)(`span`,{className:`ep-state ${e.run.outcome??e.run.lifecycle}`,children:s(e.run.outcome??e.run.lifecycle)})]},e.run.childRunId))]})]})}var sa=/^\s{0,3}(`{3,}|~{3,})/,ca=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function la(e){return e.trim()===``}function ua(e){let t=sa.exec(e);return t?t[1]:null}function da(e){let t=e.split(`
|
|
5
5
|
`),n=[],r=[],i=null;for(let e=0;e<t.length;e++){let a=t[e];if(i!==null){let e=ua(a);e&&e[0]===i[0]&&e.length>=i.length&&(i=null),r.push(a);continue}let o=ua(a);if(o&&!la(a))i=o,r.push(a);else if(la(a)){let i=e;for(;i<t.length&&la(t[i]);)i++;if(!(i<t.length&&ca.test(t[i]))&&r.length>0){n.push(r.join(`
|
|
6
6
|
`)),r=[];continue}r.push(a)}else r.push(a)}return{frozen:n,active:r.join(`
|
package/web/dist/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "cadence-web-assets/1",
|
|
3
|
-
"sourceHash": "
|
|
3
|
+
"sourceHash": "c77e313ffb7d7026a27190ad6ce4ce5365601f0ad411f0f902add702d2afb337",
|
|
4
4
|
"contractHash": "944f3b53bd5b7f1d3f30868e0947d900e356ae9a2bcfb9f591edd988b3d5eb3a",
|
|
5
|
-
"buildId": "
|
|
5
|
+
"buildId": "fc61e56158d0ae6106cb9f0000d593b05c0c8902e0f27e0df5e805d658a90d78",
|
|
6
6
|
"assets": [
|
|
7
7
|
{
|
|
8
8
|
"name": "assets/cadence.css",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
{
|
|
75
75
|
"name": "assets/cadence.js",
|
|
76
76
|
"bytes": 287232,
|
|
77
|
-
"sha256": "
|
|
77
|
+
"sha256": "ee082d83f0a29971183e5abf74d56dbb2255a976c4fa0f5f9b5ec0240fd3c68c",
|
|
78
78
|
"references": [
|
|
79
79
|
"assets/markdown.js",
|
|
80
80
|
"assets/react.js",
|