@abelxiaoxing/cadence 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -374,6 +374,13 @@ Review the independently enumerated package member list and every emitted body,
374
374
  Keep public Pi peers external for the extension, the exact Undici/ws runtime edges, the exact optional SDK pins for the standalone owner and all upstream/font/vendor notices.
375
375
  Preserve original license bytes through their precise Git attributes; line-ending normalization must not invalidate audited source/notice hashes.
376
376
 
377
+ ### Release 2.0.4 acceptance snapshot
378
+
379
+ Full `verify` passed on `3987f65` (the `max` thinking change): 1925 root tests in 78 files, 111 web tests, 5 real-browser scenarios and the 132-member pack audit, in the 2.0.3 environment below.
380
+ On the same host, against a real Pi 1.4.0 user-scope install and a user-configured OpenAI-compatible provider, an owner model chosen in the WebUI ran a readonly research Start end to end: the child used `ls`/`find`/`read`, settled `completed`, published its summary and recorded hidden thinking as omitted.
381
+ A concurrent Pi TUI's agent panel followed that child from launch through its tool calls to `finished (ok=1)`.
382
+ A DeepSeek model whose `thinkingLevelMap` maps only `max` became selectable at `max` and its child made tool calls at that level; editing `models.json` during that run turned the owner's views `stale` until restart, as now documented.
383
+
377
384
  ### Release 2.0.3 acceptance snapshot
378
385
 
379
386
  Full `verify` passed on `c27b8ca`: 1924 root tests in 78 files (27 Windows-only controls skipped on Linux), 111 web tests in 8 files, 5 real-browser scenarios in 3 files and the 132-member real pack audit.
@@ -93,6 +93,9 @@ To keep the service off while Cadence stays installed, use `systemctl --user dis
93
93
  Their mode bits are not checked: Pi creates its agent directory with your umask (0755, or 0775 under umask 002), and Cadence's own state stays 0700 regardless.
94
94
  `models.json` may use only fields the pinned SDK supports.
95
95
  `supportsMidConvoSystemMessages` from newer Pi is accepted because the pinned SDK has no system-role conversation message; other unknown fields refuse rather than being silently ignored.
96
+ The owner model choice offers every thinking level the pinned SDK supports for a model, `off` through `xhigh` and `max`; a model whose `thinkingLevelMap` maps only `max` (as some DeepSeek configurations do) is chosen at `max`, and a child runs only at exactly that level.
97
+ The owner loads `models.json` once at start: after it changes, the model catalog, the chosen model and the workspace view refuse as `stale` (credential changes in `auth.json` are read fresh).
98
+ Restart the service to reload it (`systemctl --user restart cadence`, or `stop` then `start`), then choose the owner model again.
96
99
  - A foreground owner can be managed from another terminal.
97
100
  Ctrl-C, SIGTERM, machine crash or terminal destruction is **not** the authenticated orderly Stop route and can leave recovery fences.
98
101
  A recovered `stopped` registration means acknowledged fence release, not retroactive native closure certification.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abelxiaoxing/cadence",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "Shared Pi task workspace: native terminal and WebUI, persistent service, checks and human review.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -2,5 +2,5 @@
2
2
  export const nativeBuild = {
3
3
  kind: "native",
4
4
  contractHash:
5
- "e7e5248f8273a373827ac70d2d8be1d5aaea1e329379e59e4947fc10f82be818",
5
+ "ff017feffc6b6b4521e470d82514d0ca008e15472fa1442ec498b243b0f7cf87",
6
6
  } as const;
@@ -35,7 +35,7 @@ export interface ModelCandidate {
35
35
  model: string;
36
36
  api: ModelSelection["api"] | null;
37
37
  thinking: {
38
- level: ModelSelection["thinking"] | "max";
38
+ level: ModelSelection["thinking"];
39
39
  selectable: boolean;
40
40
  }[];
41
41
  eligibility: "candidate" | "unsupported" | "auth-unavailable";
@@ -93,7 +93,7 @@ export function decodeModelCandidate(value: unknown): ModelCandidate {
93
93
  thinking: list(o.thinking, 7, (v) => {
94
94
  const t = closed(v, ["level", "selectable"]);
95
95
  return {
96
- level: oneOf(t.level, [...thinkingLevels, "max"] as const),
96
+ level: oneOf(t.level, thinkingLevels),
97
97
  selectable: bool(t.selectable),
98
98
  };
99
99
  }),
@@ -109,9 +109,7 @@ export function decodeModelCandidate(value: unknown): ModelCandidate {
109
109
  candidate.thinking.some(
110
110
  (t) =>
111
111
  t.selectable &&
112
- (t.level === "max" ||
113
- candidate.api === null ||
114
- candidate.eligibility !== "candidate"),
112
+ (candidate.api === null || candidate.eligibility !== "candidate"),
115
113
  ) ||
116
114
  (candidate.eligibility === "candidate" &&
117
115
  !candidate.thinking.some((t) => t.selectable))
@@ -564,7 +564,8 @@ var thinkingLevels = [
564
564
  "low",
565
565
  "medium",
566
566
  "high",
567
- "xhigh"
567
+ "xhigh",
568
+ "max"
568
569
  ];
569
570
  function decodeModelSelector(v) {
570
571
  const o = closed(v, ["provider", "model", "api", "thinking"]);
@@ -951,7 +951,8 @@ var thinkingLevels = [
951
951
  "low",
952
952
  "medium",
953
953
  "high",
954
- "xhigh"
954
+ "xhigh",
955
+ "max"
955
956
  ];
956
957
  function decodeModelSelector(v) {
957
958
  const o = closed(v, ["provider", "model", "api", "thinking"]);
@@ -4002,7 +4003,7 @@ function decodeModelCandidate(value) {
4002
4003
  thinking: list(o.thinking, 7, (v) => {
4003
4004
  const t = closed(v, ["level", "selectable"]);
4004
4005
  return {
4005
- level: oneOf(t.level, [...thinkingLevels, "max"]),
4006
+ level: oneOf(t.level, thinkingLevels),
4006
4007
  selectable: bool(t.selectable)
4007
4008
  };
4008
4009
  }),
@@ -4012,7 +4013,7 @@ function decodeModelCandidate(value) {
4012
4013
  "auth-unavailable"
4013
4014
  ])
4014
4015
  };
4015
- if (new Set(candidate.thinking.map((t) => t.level)).size !== candidate.thinking.length || candidate.thinking.some((t) => t.selectable && (t.level === "max" || candidate.api === null || candidate.eligibility !== "candidate")) || candidate.eligibility === "candidate" && !candidate.thinking.some((t) => t.selectable))
4016
+ if (new Set(candidate.thinking.map((t) => t.level)).size !== candidate.thinking.length || candidate.thinking.some((t) => t.selectable && (candidate.api === null || candidate.eligibility !== "candidate")) || candidate.eligibility === "candidate" && !candidate.thinking.some((t) => t.selectable))
4016
4017
  invalid();
4017
4018
  return candidate;
4018
4019
  }
@@ -22608,7 +22609,7 @@ function refuseAt(stage, step) {
22608
22609
  }
22609
22610
  }
22610
22611
  async function createServiceHost(value, sourceBuild) {
22611
- const embedded = "e7e5248f8273a373827ac70d2d8be1d5aaea1e329379e59e4947fc10f82be818";
22612
+ const embedded = "ff017feffc6b6b4521e470d82514d0ca008e15472fa1442ec498b243b0f7cf87";
22612
22613
  if (embedded && sourceBuild)
22613
22614
  throw new ContractError("unsupported-context");
22614
22615
  const contractHash = decodeHash(embedded ?? sourceBuild?.contractHash);
package/src/task-shell.ts CHANGED
@@ -590,7 +590,7 @@ export function registerTaskShell(pi: ExtensionAPI): void {
590
590
  "Exact thinking level • no clamping/fallback",
591
591
  model.thinking.filter((t) => t.selectable).map((t) => t.level),
592
592
  );
593
- if (!level || level === "max") return;
593
+ if (!level) return;
594
594
  // Decode via the shared model-choice method; never inspect parent auth.
595
595
  const choice = {
596
596
  provider: model.provider,
@@ -411,6 +411,8 @@ export const modelApis = [
411
411
  "mistral-conversations",
412
412
  "azure-openai-responses",
413
413
  ];
414
+ // The pinned SDK's ThinkingLevel, including "max" (models whose
415
+ // thinkingLevelMap maps only max, such as some DeepSeek configurations).
414
416
  export const thinkingLevels = [
415
417
  "off",
416
418
  "minimal",
@@ -418,6 +420,7 @@ export const thinkingLevels = [
418
420
  "medium",
419
421
  "high",
420
422
  "xhigh",
423
+ "max",
421
424
  ];
422
425
  export function decodeModelSelector(v) {
423
426
  const o = closed(v, ["provider", "model", "api", "thinking"]);
@@ -1,7 +1,7 @@
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={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},m=f.createContext&&f.createContext(p),h=[`attr`,`size`,`title`];function g(e,t){if(e==null)return{};var n,r,i=_(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 _(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 v(){return v=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},v.apply(null,arguments)}function y(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 b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?y(Object(n),!0).forEach(function(t){x(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=ee(e,`string`);return typeof t==`symbol`?t:t+``}function ee(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 C(e){return e&&e.map((e,t)=>f.createElement(e.tag,b({key:t},e.attr),C(e.child)))}function w(e){return t=>f.createElement(T,v({attr:b({},e.attr)},t),C(e.child))}function T(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=g(e,h),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,v({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:b(b({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 m===void 0?t(p):f.createElement(m.Consumer,null,e=>t(e))}var E=t();function te(e){return w({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 D(e){return w({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 ne(e){return w({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 re(e){return w({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 ie(e){return w({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 ae(e){return w({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 oe(e){return w({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 se(e){return w({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 ce(e){return w({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 le(e){return w({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 ue(e){return w({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 de(e){return w({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 fe(e){return w({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 pe(e){return w({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 me(e){return w({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 O(e){return w({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 he(e){return w({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:`4`},child:[]},{tag:`line`,attr:{x1:`1.05`,y1:`12`,x2:`7`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`17.01`,y1:`12`,x2:`22.96`,y2:`12`},child:[]}]})(e)}function ge(e){return w({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 _e(e){return w({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 ve(e){return w({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 ye(e){return w({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 be(e){return w({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 xe(e){return w({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 Se(e){return w({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 Ce(e){return w({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 we(e){return w({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 Te(e){return w({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 Ee(e){return w({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 De(e){return w({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 Oe(e){return w({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 ke(e){return w({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 Ae(e){return w({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function je(e){return w({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var Me=`cadence-graph/2`,Ne=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),Pe=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`quarantine`,`capacity`,`unavailable`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],A=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function Fe(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 A}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 A(`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,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function W(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function Ie(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function G(e,t=k.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new A(`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 Le(e,t=k.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,Pe),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ze=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],Be=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],Ve=[`not-launched`,`direct-child-closed`,`unconfirmed`],He=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],Ue=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function We(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,He),thinking:I(t.thinking,Ue)}}function Ge(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...We(n)}}function Ke(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function qe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function K(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ze),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function Je(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function Ye(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:Ie(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=K(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,Je);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(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 Xe(e){G(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=K(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,Me),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,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:Ie(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,k.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,k.expectedOutputBytes,!0),role:Ke(t.role),model:Ge(t.model),dependencies:B(t.dependencies,k.assignments,Ye)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==qe(e.purpose))throw new A(`forbidden`);c(e)}return i}function Ze(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 Qe(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:Ge(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,Ze)}}function $e(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,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function et(e){switch(G(e),q(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=Xe(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:q(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:$e(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 tt(e){G(e);let t=z(e,[`expected`,`action`]);return{expected:Qe(t.expected),action:et(t.action)}}function nt(e){G(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:Qe(t.expected),action:et(t.action)}}function rt(e){if(G(e),q(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:Qe(t.expected),action:et(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 it(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function at(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,$e);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:Qe(n.version),action:et(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,Xe),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 ot(e){G(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:at(t.preview)}}function J(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 st(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=K(t.result);L(i.field,`final-text`);let a=R(t.range,Je);a&&a.end>i.bytes&&j();let o=M(t.text,k.predecessorBytes);if(n+=N(o),n>k.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:Ie(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:J(t.coverage)}})}}function ct(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,Ve),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:J(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 lt(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function ut(e){let t=M(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function Y(e){G(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:lt(t.scope),query:R(t.query,e=>{let t=M(e,k.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,ze)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:ut(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function dt(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=gt(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function ft(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function pt(e){let t=q(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=K(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.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,k.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,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function mt(e){let t=z(e,[`owner`,`field`,`encoding`]),n=pt(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 ht(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:pt(t.owner),sourceType:n,mimeType:i,reason:r}}function gt(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function _t(e){let t=q(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:dt(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...ft({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,k.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:ft(n.declaration),index:P(n.index,0,k.dataFrames),source:dt(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,ft),source:dt(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,ft),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:dt(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:ht(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:mt(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+N(r)>k.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,k.detailBytes),sha256:H(n.sha256),coverage:J(n.coverage)}}case`capture-status`:return{kind:t,coverage:J(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 vt(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,Ve),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 yt(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function bt(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:K(t.content),committedSeq:n}}function xt(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=yt(n.selected),i=bt(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,yt),error:Re(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,yt)}}function St(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&W(n,t.detail.committedSeq)<0)&&j(),n}function Ct(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function wt(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Ct(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function Tt(e){let t=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=xt(n.recording),i=St(n.settlementSeq,r);return{kind:t,native:ct(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:vt(n.native),capture:J(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=xt(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:Ie(t.assignmentId),childRunId:n,native:R(t.native,ct),recording:r,settlementSeq:St(t.settlementSeq,r)}}),i=I(n.outcome,Be);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(Ct))&&j(),{kind:`parent`,outcome:i,required:r}}function Et(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.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 Dt(e){let t=z(e,[`source`,`event`]),n=Et(t.source),r=q(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,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:J(e.coverage)}}}let i=_t(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ot(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 kt(e){G({kind:`ok`,value:e},k.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:At(n.error)};let i=B(n.runs,k.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 At(e){let t=Re(e);return L(t.effect,`none`),t}function jt(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Mt(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,...jt({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Nt(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:jt(t.assets)}}function Pt(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 Ft(e){G(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,Be)),settlement:R(t.settlement,Tt),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&&wt(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function It(e){G(e);let t=z(e,[`identity`,`receipt`]),n=rt(t.identity),r=Ft(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(q(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 Lt(e){switch(G(e),q(e,`status`)){case`found`:return{status:`found`,receipt:Ft(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 Rt(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,Ie),admission:Jt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,Be)),settlement:R(t.settlement,Tt),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:J(t.coverage),result:R(t.result,K)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&G(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==G(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&G(n.result)!==G(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&wt(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||wt(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function zt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Bt(e,t,n){return zt(e,t)&&e.taskId===Zt(n)&&e.admission.context.workspaceId===Xt(n)}function Vt(e){G(e,k.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:lt(t.scope),committedSeq:U(t.committedSeq),context:Yt(t.context),runs:B(t.runs,k.maxPageEntries,Rt),horizon:ln(t.horizon)};return(!Qt(n.context,n.epoch,n.scope)||G(n.horizon.historicalRuns.scope)!==G(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!Bt(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function Ht(e){G(e,k.pageBytes);let t=q(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:lt(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);W(r.committedSeq,e)<=0&&j();let i=Yt(n.context);Qt(i,r.epoch,r.scope)||j();let a=B(n.runs,k.maxPageEntries,Rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!Bt(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 Ut(e){let{navigation:t,...n}=e;return n}function Wt(e,t){(!t.navigation||t.navigation===e.navigation||G(Ut(e))!==G(Ut(t)))&&j()}function Gt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Kt(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=Y(t.cursor),r=Y(t.next);return Wt(n,r),{kind:`progress`,cursor:n,next:r,coverage:J(t.coverage)}}function Kt(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Y(t.cursor),content:K(t.content),range:R(t.range,Je),text:M(t.text,k.detailPageBytes),next:R(t.next,Y),coverage:J(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||G(Ut({...n.next,offset:n.cursor.offset}))!==G(Ut(n.cursor)))&&j(),n}function qt(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=Y(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=K(t.content),a=tn(t.owner);nn(a,n.scope)||j();let o=Je(t.range),s=Y(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||G(s.scope)!==G(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,Y);return a&&(a.storeId!==n.storeId||G(a.scope)!==G(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&j(),{cursor:n,hits:i,next:a,coverage:J(t.coverage)}}function Jt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=Qe(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,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:Ie(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 Yt(e){if(q(e,`status`)===`available`)return{status:`available`,version:Qe(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 Xt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Zt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Qt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Zt(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:Nt(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 en(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:kt(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:Yt(t.context),models:B(t.models,k.maxPageEntries,Ge)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(Xt(n.context)!==n.workspaceId||Zt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function tn(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 nn(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function rn(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function an(e){G(e,k.controlBytes);let t=q(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:Jt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=Tt(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:st(n.handoff),observation:rn(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=K(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:rn(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:$e(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:rn(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=vt(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=rn(r.before),c=rn(r.after),l=R(r.output,K),u=J(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||G({...s,checkoutGeneration:c.checkoutGeneration})!==G(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=K(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 on(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 sn(e){G(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=on(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=an(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=tn(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,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:J(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var cn=[`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,cn),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:ut(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,k.maxPageEntries)}}function ln(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 un(e){let t=q(e);if(t===`run`)return{kind:t,projection:Rt(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:Ot(n.link),capture:Dt(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=sn({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=tn(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,K);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,k.dataFrames)),s=R(i.finalText,K),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:dt(i.source)}}if(t===`tool`){let e=R(i.declaration,ft),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=_t(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:dt(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=mt(i.descriptor),n=K(i.content);return(e.field!==n.field||!dn(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:J(i.coverage)}}L(t,`omitted`);let s=ht(i.block);return dn(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function dn(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 fn(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 pn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Z(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,un),i=R(t.next,Z);return(r.some(e=>!fn(e,n))||i&&(i.after===null||G(Ut({...i,after:n.after}))!==G(Ut(n))||G(i.after)===G(n.after)))&&j(),{request:n,records:r,next:i,coverage:J(t.coverage)}}function mn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},k.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||G(Ut({...r,snapshotSeq:null}))!==G(Ut(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:J(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return pn(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Z(t.request),r=Z(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function hn(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function gn(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:ut(t.navigation)}:{},storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function _n(e){G({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=gn(t.request),r=Xe(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function vn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return _n(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=gn(t.request),r=gn(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function yn(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function bn(e){G(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(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,Ne),request:yn(e.request),coverage:J(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:un(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:_n(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=K(e.content),a=R(e.range,Je),o=M(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:tn(e.owner),content:i,range:a,text:o,coverage:J(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=J(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 xn(e,t){let n=bn(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var Sn=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=yn(e)}receive(e){let t=bn(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!nn(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(G(n.graph.request.scope)!==G(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Cn(n.record,this.request.scope)&&j(),this.bytes+=N(xn(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 Cn(e,t){return e.kind===`run`?zt(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:nn(e.owner,t)}function wn(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=$e(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 Tn(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:ut(t.navigation)}:{},storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function En(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Tn(t.request),r=un(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||!nn(r.owner,n.scope))&&j(),{request:n,record:r}}function Dn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return En(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tn(t.request),r=Tn(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}var On=e=>{let t=Re(e);return L(t.effect,`none`),t};function kn(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function An(e){let t=kn(e);return t.taskId===null&&j(),t}function jn(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 Mn(e){let t=B(e,3,Ke);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Nn(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:gn(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:On(n.error)}}function Pn(e){if((e.request.taskId!==(e.task?.id??null)||Xt(e.context)!==e.workspaceId||Zt(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 Fn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:kn(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:Yt(t.context),task:R(t.task,jn),roles:Mn(t.roles),savedGraph:Nn(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=J(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}})};Pn(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 In(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:An(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:Yt(t.context),task:jn(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:J(t.coverage)};if(Pn(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 Ln(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 Rn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:Ln(t.version),selected:R(t.selected,Ge)}}function zn(e){G(e);let t=z(e,[`expected`,`choice`]);return{expected:Ln(t.expected),choice:We(t.choice)}}function Bn(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,He)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,[...Ue,`max`]),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&&(e.level===`max`||n.api===null||n.eligibility!==`candidate`))||n.eligibility===`candidate`&&!n.thinking.some(e=>e.selectable))&&j(),n}function Vn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`]),n=B(t.entries,k.maxPageEntries,Bn),r=I(t.status,[`complete`,`capacity`]);return(r===`capacity`&&n.length||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length)&&j(),{version:Ln(t.version),selected:R(t.selected,Ge),status:r,entries:n}}async function Hn(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 Un(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 Q=e=>({kind:`error`,error:Fe(`unavailable`,e?`uncertain`:`none`)}),Wn=class{transport;constructor(e){this.transport=e}async current(e,t){let n=kn(e);try{if(!this.transport.current)return Q(!1);let e=X(await this.transport.current(n,t),Fn);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async currentChanges(e,t){let n=An(e);try{if(!this.transport.currentChanges)return Q(!1);let e=X(await this.transport.currentChanges(n,t),In);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async activeRuns(e){try{return this.transport.activeRuns?X(await this.transport.activeRuns(e),kt):Q(!1)}catch{return Q(!1)}}async models(e){try{return this.transport.models?X(await this.transport.models(e),Vn):Q(!1)}catch{return Q(!1)}}async chooseModel(e){let t=zn(e);try{if(!this.transport.chooseModel)return Q(!1);let e=X(await this.transport.chooseModel(t),Rn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(G(r)!==G(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return Q(!0)}return e}catch{return Q(!0)}}async checkObligations(e,t){V(e);try{let n=X(await this.transport.checkObligations(e,t),wn);return n.kind===`ok`&&n.value.taskId!==e?Q(!1):n}catch{return Q(!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=Tn({...t,kind:e});try{let e=X(await this.transport.entity(r,n),Dn);return e.kind===`ok`&&G(e.value.request)!==G(r)?Q(!1):e}catch{return Q(!1)}}async session(e){try{return X(await this.transport.session(e),$t)}catch{return Q(!1)}}async workspace(e){try{return X(await this.transport.workspace(e),en)}catch{return Q(!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),mn);return t.kind===`ok`&&!hn(r,t.value)?Q(!1):t}catch{return Q(!1)}}async graph(e,t){let n=gn(e);try{let e=X(await this.transport.graph(n,t),vn);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async*export(e,t){let n=yn(e),r=new Sn(n),i;try{if(t.aborted)throw new A(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new A(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new A(`unavailable`);yield i}catch{throw new A(`unavailable`)}}async preflight(e,t){let n=tt({expected:e,action:t});try{let e=X(await this.transport.preflight(n),ot);return e.kind===`ok`&&(G(e.value.preview.version)!==G(n.expected)||G(e.value.preview.action)!==G(n.action))?Q(!1):e}catch{return Q(!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=nt(t);if(n.action.kind!==e)return{kind:`error`,error:Fe(`invalid`)};try{let e=X(await this.transport.command(n),Ft);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Q(!0);It({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Q(!0)}}async cancel(e){let t=it(e);try{let e=X(await this.transport.cancel(t),Ft);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Q(!0);It({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Q(!0)}}async receipt(e,t){V(e);try{let n=Lt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:Fe(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=lt(e);try{let e=X(await this.transport.snapshot(n,t),Vt);return e.kind===`ok`&&G(e.value.scope)!==G(n)?Q(!1):e}catch{return Q(!1)}}async detail(e,t){let n=Y(e);try{let e=X(await this.transport.detail(n,t),Gt);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?Q(!1):e}catch{return Q(!1)}}async search(e,t){let n=Y(e);try{let e=X(await this.transport.search(n,t),qt);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?Q(!1):e}catch{return Q(!1)}}},Gn=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=Vt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&W(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=Ht(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||G(i.scope)!==G(a.scope))return this.resync();let o=W(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Xt(i.context)!==Xt(a.context)||Zt(i.context)!==Zt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||G(t.admission)!==G(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{Vt(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`}},Kn={session:`/api/v1/session`,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`},qn=`/api/v1/events`,Jn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Yn(e,t){if(Jn.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`)return k.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return k.pageBytes}return k.controlBytes}function Xn(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`].includes(e)}function Zn(e,t){switch(e){case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new A(`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 A(`invalid`);return n}case`current`:return kn(t);case`currentChanges`:return An(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Tn(t);case`graph`:return gn(t);case`snapshot`:return lt(t);case`detail`:case`search`:return Y(t);case`export`:case`download`:return yn(t);case`chooseModel`:return zn(t);case`preflight`:return tt(t);case`command`:return nt(t);case`cancel`:return it(t)}}function Qn(e,t){if(Jn.includes(e))return X(t,mn);switch(e){case`current`:return X(t,Fn);case`currentChanges`:return X(t,In);case`activeRuns`:return X(t,kt);case`models`:return X(t,Vn);case`chooseModel`:return X(t,Rn);case`session`:return X(t,$t);case`workspace`:return X(t,en);case`checkObligations`:return X(t,wn);case`entity`:return X(t,Dn);case`graph`:return X(t,vn);case`snapshot`:return X(t,Vt);case`detail`:return X(t,Gt);case`search`:return X(t,qt);case`preflight`:return X(t,ot);case`command`:case`cancel`:return X(t,Ft);case`receipt`:return Lt(t);case`detach`:return X(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function $n(e){return[...Jn,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function er(e,t){let n=Kn[e];return t===null||Xn(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function tr(e,t){let n=Zn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Kn[e]:er(e,n);return Xn(e)||$n(e)&&(r||N(i)>k.headerBytes/4)?{path:Kn[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function nr(e){G(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:Vt(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:Ht(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var rr=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))throw new A(`invalid`);this.origin=e.origin,e.build&&=Mt(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=G(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new A(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=tr(e,Zn(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${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 ir(a,Yn(e)),c=Le(s);if(N(s)>Yn(e,c))throw new A(`oversize`);let l=Qn(e,c);if(e===`session`){let e=X(l,$t);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`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`,zn(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`,Tn(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`,gn(e),t)}preflight(e){return this.request(`preflight`,tt(e))}command(e){return this.request(`command`,nt(e))}cancel(e){return this.request(`cancel`,it(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 A(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new A(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=tr(`export`,yn(e)),r=await this.fetcher(`${this.origin}${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 A(`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 A(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
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={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},m=f.createContext&&f.createContext(p),h=[`attr`,`size`,`title`];function g(e,t){if(e==null)return{};var n,r,i=_(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 _(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 v(){return v=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},v.apply(null,arguments)}function y(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 b(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?y(Object(n),!0).forEach(function(t){x(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):y(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function x(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=ee(e,`string`);return typeof t==`symbol`?t:t+``}function ee(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 C(e){return e&&e.map((e,t)=>f.createElement(e.tag,b({key:t},e.attr),C(e.child)))}function w(e){return t=>f.createElement(T,v({attr:b({},e.attr)},t),C(e.child))}function T(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=g(e,h),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),f.createElement(`svg`,v({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:b(b({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 m===void 0?t(p):f.createElement(m.Consumer,null,e=>t(e))}var E=t();function te(e){return w({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 D(e){return w({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 ne(e){return w({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 re(e){return w({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 ie(e){return w({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 ae(e){return w({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 oe(e){return w({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 se(e){return w({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 ce(e){return w({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 le(e){return w({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 ue(e){return w({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 de(e){return w({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 fe(e){return w({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 pe(e){return w({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 me(e){return w({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 O(e){return w({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 he(e){return w({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:`4`},child:[]},{tag:`line`,attr:{x1:`1.05`,y1:`12`,x2:`7`,y2:`12`},child:[]},{tag:`line`,attr:{x1:`17.01`,y1:`12`,x2:`22.96`,y2:`12`},child:[]}]})(e)}function ge(e){return w({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 _e(e){return w({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 ve(e){return w({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 ye(e){return w({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 be(e){return w({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 xe(e){return w({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 Se(e){return w({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 Ce(e){return w({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 we(e){return w({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 Te(e){return w({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 Ee(e){return w({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 De(e){return w({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 Oe(e){return w({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 ke(e){return w({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 Ae(e){return w({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`path`,attr:{d:`M22 11.08V12a10 10 0 1 1-5.93-9.14`},child:[]},{tag:`polyline`,attr:{points:`22 4 12 14.01 9 11.01`},child:[]}]})(e)}function je(e){return w({tag:`svg`,attr:{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`},child:[{tag:`line`,attr:{x1:`12`,y1:`5`,x2:`12`,y2:`19`},child:[]},{tag:`polyline`,attr:{points:`19 12 12 19 5 12`},child:[]}]})(e)}var Me=`cadence-graph/2`,Ne=`cadence-public-export/2`,k=Object.freeze({controlBytes:1048576,admissionCount:16,admissionBytes:33554432,cancelBytes:65536,headerBytes:8192,wsClientFrameBytes:16384,startWaitMs:1e4,stopWaitMs:6e4,authWaitMs:3e4,authValidityMarginMs:12e4,browserLifetimeMs:432e5,terminateGraceMs:1e3,unconfirmedStopMs:3e3,graphBytes:524288,grantMs:12e4,assignments:16,instructionsBytes:16384,expectedOutputBytes:2048,workerRequestBytes:131072,publicRequestBytes:98304,predecessorBytes:16384,handoffBytes:32768,frameBytes:65536,chunkBytes:8192,detailBytes:33554432,childProtocolBytes:134217728,dataFrames:1e5,controlFrames:256,sdkEvents:1e6,workerQueueBytes:4194304,workerQueueFrames:1024,ownerQueueBytes:8388608,ownerQueueFrames:2048,ownerControlBytes:1048576,ownerControlFrames:256,recordingStallMs:5e3,episodes:8,queuedAssignments:128,childReservations:2,episodeMs:216e5,readyWaitMs:6e5,workerMs:12e5,artifactPartBytes:262144,progressBatchMs:100,progressBatchBytes:262144,segmentBytes:8388608,segmentRecords:4096,checkoutQuotaBytes:10737418240,episodeReservationBytes:536870912,freeSpaceFloorBytes:268435456,episodeControlBytes:1048576,searchReaders:2,exportReaders:2,downloadIdleMs:12e4,pageEntries:50,maxPageEntries:200,pageBytes:524288,detailPageBytes:262144,previewBytes:4096,searchBytes:8388608,searchMs:100,queryBytes:1024,navigationBytes:8192,ringEvents:1024,ringBytes:2097152,viewers:16,viewerMessages:256,viewerBytes:1048576,heartbeatMs:5e3,staleMs:15e3,reconcileMs:3e4}),Pe=[`invalid`,`oversize`,`unauthenticated`,`forbidden`,`stale`,`conflict`,`corrupt-selected`,`expired-grant`,`consumed-grant`,`unsupported-context`,`quarantine`,`capacity`,`unavailable`,`auth-unavailable`,`recording-exhausted`,`receipt-inconclusive`],A=class extends Error{code;constructor(e=`invalid`){super(e),this.code=e}};function Fe(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 A}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 A(`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,k.controlBytes);return/^(0|[1-9][0-9]*)$/.test(t)||j(),t}function W(e,t){return U(e),U(t),e.length===t.length?e===t?0:e<t?-1:1:e.length<t.length?-1:1}function Ie(e){let t=M(e,48);return/^[a-z][a-z0-9-]{0,47}$/.test(t)||j(),t}function G(e,t=k.controlBytes){let n=t,r=e=>{if(n-=N(e),n<0)throw new A(`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 Le(e,t=k.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,Pe),effect:I(t.effect,[`none`,`accepted`,`uncertain`]),recovery:I(t.recovery,[`observe`,`fresh-confirmation`,`operator`])}}var ze=[`plan`,`context`,`message`,`final-text`,`tool-args`,`tool-update`,`tool-result`,`check`,`changes`,`review`],Be=[`completed`,`failed`,`canceled`,`timeout`,`unknown`,`blocked`],Ve=[`not-launched`,`direct-child-closed`,`unconfirmed`],He=[`openai-completions`,`openai-responses`,`openai-codex-responses`,`anthropic-messages`,`google-generative-ai`,`mistral-conversations`,`azure-openai-responses`],Ue=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`];function We(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,He),thinking:I(t.thinking,Ue)}}function Ge(e){let{sourceSelectionId:t,...n}=z(e,[`sourceSelectionId`,`provider`,`model`,`api`,`thinking`]);return{sourceSelectionId:V(t),...We(n)}}function Ke(e){let t=z(e,[`role`,`sha256`]);return{role:I(t.role,[`design-explorer`,`implementation-worker`,`diagnosis-worker`]),sha256:H(t.sha256)}}function qe(e){return e===`edit`?`implementation-worker`:e===`diagnosis`?`diagnosis-worker`:`design-explorer`}function K(e){let t=z(e,[`recordId`,`version`,`field`,`bytes`,`sha256`]);return{recordId:V(t.recordId),version:P(t.version,1),field:I(t.field,ze),bytes:P(t.bytes,0,k.detailBytes),sha256:H(t.sha256)}}function Je(e){let t=z(e,[`start`,`end`]),n=P(t.start);return{start:n,end:P(t.end,n+1,k.detailBytes)}}function Ye(e){let t=z(e,[`source`,`range`,`requireCompleteObservation`]),n=q(t.source),r;if(n===`current`)r={kind:n,assignmentId:Ie(z(t.source,[`kind`,`assignmentId`]).assignmentId)};else{let e=z(t.source,[`kind`,`runId`,`childRunId`,`result`]);L(n,`historical`);let i=K(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,Je);return r.kind===`historical`&&i&&i.end>r.result.bytes&&j(),{source:r,range:i,requireCompleteObservation:F(t.requireCompleteObservation)}}function q(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 Xe(e){G(e,k.graphBytes);let t=z(e,[`schema`,`taskId`,`taskKind`,`taskRevision`,`revision`,`planRevision`,`plan`,`assignments`]),n=K(t.plan);L(n.field,`plan`);let r=P(t.planRevision,1);n.version!==r&&j();let i={schema:L(t.schema,Me),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,k.assignments,e=>{let t=z(e,[`id`,`purpose`,`instructions`,`expectedOutput`,`role`,`model`,`dependencies`]);return{id:Ie(t.id),purpose:I(t.purpose,[`research`,`diagnosis`,`review`,`edit`]),instructions:M(t.instructions,k.instructionsBytes,!0),expectedOutput:M(t.expectedOutput,k.expectedOutputBytes,!0),role:Ke(t.role),model:Ge(t.model),dependencies:B(t.dependencies,k.assignments,Ye)}})};i.assignments.length||j();let a=new Map(i.assignments.map(e=>[e.id,e]));a.size!==i.assignments.length&&j();let o=new Set,s=new Set;function c(e){if(o.has(e.id)&&j(),s.has(e.id))return;o.add(e.id);let t=new Set;for(let n of e.dependencies){let e=G(n.source);if(t.has(e)&&j(),t.add(e),n.source.kind===`current`){let e=a.get(n.source.assignmentId);e||j(),c(e)}}o.delete(e.id),s.add(e.id)}for(let e of i.assignments){if(i.taskKind!==`code`&&e.purpose===`edit`||e.role.role!==qe(e.purpose))throw new A(`forbidden`);c(e)}return i}function Ze(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 Qe(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:Ge(t.model),checkEnvGeneration:P(t.checkEnvGeneration,1),checkoutGeneration:P(t.checkoutGeneration),observation:{identity:H(n.identity),complete:F(n.complete)},task:R(t.task,Ze)}}function $e(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,k.workerMs)},r=/[\x00-\x08\x0b-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069]/u;return(r.test(n.name)||r.test(n.command)||/[\n\t]/.test(n.name)||n.name===`Manual command`)&&j(),n.kind===`manual`&&(n.name!==`Manual`||n.timeoutMs!==12e4)&&j(),n}function et(e){switch(G(e),q(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=Xe(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:q(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:$e(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 tt(e){G(e);let t=z(e,[`expected`,`action`]);return{expected:Qe(t.expected),action:et(t.action)}}function nt(e){G(e);let t=z(e,[`commandId`,`grant`,`expected`,`action`]);return{commandId:V(t.commandId),grant:V(t.grant),expected:Qe(t.expected),action:et(t.action)}}function rt(e){if(G(e),q(e)===`action`){let t=z(e,[`kind`,`expected`,`action`]);return{kind:`action`,expected:Qe(t.expected),action:et(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 it(e){let t=z(e,[`commandId`,`epoch`,`runId`]);return{commandId:V(t.commandId),epoch:V(t.epoch),runId:V(t.runId)}}function at(e){G(e);let t=typeof e==`object`&&!!e&&Object.hasOwn(e,`checkEnvironmentPolicy`),n=z(e,[`version`,`action`,`rootLabel`,`cwdLabel`,`readablePlan`,`graph`,`activeRunId`,`issues`,`configuredChecks`,`checksRevision`,`reviewRunId`,...t?[`checkEnvironmentPolicy`]:[]]),r=B(n.configuredChecks,32,$e);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:Qe(n.version),action:et(n.action),rootLabel:M(n.rootLabel,4096,!0),cwdLabel:M(n.cwdLabel,4096,!0),readablePlan:M(n.readablePlan,32768),graph:R(n.graph,Xe),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 ot(e){G(e);let t=z(e,[`grant`,`expiresAt`,`preview`]),n=M(t.expiresAt,24);return(!/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d\.\d{3}Z$/.test(n)||!Number.isFinite(Date.parse(n))||new Date(n).toISOString()!==n)&&j(),{grant:V(t.grant),expiresAt:n,preview:at(t.preview)}}function J(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 st(e){let t=z(e,[`graphRevision`,`inputs`]),n=0,r=new Set;return{graphRevision:P(t.graphRevision,1),inputs:B(t.inputs,k.assignments,e=>{let t=z(e,[`assignmentId`,`dependencyIndex`,`runId`,`childRunId`,`result`,`range`,`text`,`coverage`]),i=K(t.result);L(i.field,`final-text`);let a=R(t.range,Je);a&&a.end>i.bytes&&j();let o=M(t.text,k.predecessorBytes);if(n+=N(o),n>k.handoffBytes)throw new A(`oversize`);let s=P(t.dependencyIndex,0,k.assignments-1);return r.has(s)&&j(),r.add(s),N(o)!==(a?a.end-a.start:i.bytes)&&j(),{assignmentId:Ie(t.assignmentId),dependencyIndex:s,runId:V(t.runId),childRunId:V(t.childRunId),result:i,range:a,text:o,coverage:J(t.coverage)}})}}function ct(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,Ve),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:J(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 lt(e){let t=z(e,[`kind`,`id`]);return{kind:I(t.kind,[`task`,`run`,`child`]),id:V(t.id)}}function ut(e){let t=M(e,k.navigationBytes,!0);return/^[\x21-\x7e]+$/.test(t)||j(),t}function Y(e){G(e);let t=z(e,[`storeId`,`scope`,`query`,`snapshotSeq`,`recordId`,`recordVersion`,`field`,`offset`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]),n={storeId:V(t.storeId),scope:lt(t.scope),query:R(t.query,e=>{let t=M(e,k.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,ze)),offset:P(t.offset),...Object.hasOwn(t,`navigation`)?{navigation:ut(t.navigation)}:{}};return(n.recordId===null!=(n.recordVersion===null)||n.recordId===null!=(n.field===null))&&j(),n}function dt(e){let t=z(e,[`disposition`,`value`]),n=I(t.disposition,[`observed`,`unavailable`,`redacted`]),r=gt(t.value);return n===`observed`!=(r!==null)&&j(),{disposition:n,value:r}}function ft(e){let t=z(e,[`messageId`,`blockId`]);return{messageId:V(t.messageId),blockId:V(t.blockId)}}function pt(e){let t=q(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=K(n.source);return L(r.field,`final-text`),{kind:t,dependencyIndex:P(n.dependencyIndex,0,k.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,k.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,k.dataFrames),stage:I(n.stage,[`arguments-partial`,`arguments-final`,`execution-arguments`,`update-snapshot`,`result`])}}function mt(e){let t=z(e,[`owner`,`field`,`encoding`]),n=pt(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 ht(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:pt(t.owner),sourceType:n,mimeType:i,reason:r}}function gt(e){if(e===null)return null;let t=M(e,128,!0);return/^[a-zA-Z0-9_-]+$/.test(t)||j(),t}function _t(e){let t=q(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:dt(n.source),resultCallId:i}}case`message-text`:{let n=z(e,[`kind`,`messageId`,`blockId`,`detailId`]);return{kind:t,...ft({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,k.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:ft(n.declaration),index:P(n.index,0,k.dataFrames),source:dt(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,ft),source:dt(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,ft),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:dt(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:ht(z(e,[`kind`,`block`]).block)};case`detail-begin`:{let n=z(e,[`kind`,`detailId`,`descriptor`]);return{kind:t,detailId:V(n.detailId),descriptor:mt(n.descriptor)}}case`detail-chunk`:{let n=z(e,[`kind`,`detailId`,`offset`,`text`]),r=M(n.text,k.chunkBytes),i=P(n.offset,0,k.detailBytes);return i+N(r)>k.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,k.detailBytes),sha256:H(n.sha256),coverage:J(n.coverage)}}case`capture-status`:return{kind:t,coverage:J(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 vt(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,Ve),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 yt(e){let t=z(e,[`messageId`,`detailId`]);return{messageId:V(t.messageId),detailId:V(t.detailId)}}function bt(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:K(t.content),committedSeq:n}}function xt(e){let t=q(e,`status`);if(t===`committed`){let n=z(e,[`status`,`selected`,`detail`]),r=yt(n.selected),i=bt(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,yt),error:Re(n.error)}}let n=z(e,[`status`,`selected`]);return{status:I(t,[`pending`,`uncertain`]),selected:R(n.selected,yt)}}function St(e,t){let n=R(e,U);return(n===`0`||n!==null&&t.status===`committed`&&W(n,t.detail.committedSeq)<0)&&j(),n}function Ct(e){return e.native?.outcome===`completed`&&e.recording.status===`committed`&&e.settlementSeq!==null}function wt(e){return e.kind===`parent`?e.outcome:e.native.outcome===`completed`?e.kind===`sdk`?Ct(e)?`completed`:`failed`:e.capture.observed===`complete`&&e.settlementSeq!==null?`completed`:`failed`:e.native.outcome}function Tt(e){let t=q(e);if(t===`sdk`){let n=z(e,[`kind`,`native`,`recording`,`settlementSeq`]),r=xt(n.recording),i=St(n.settlementSeq,r);return{kind:t,native:ct(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:vt(n.native),capture:J(n.capture),settlementSeq:r}}let n=z(e,[`kind`,`outcome`,`required`]);L(t,`parent`);let r=B(n.required,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`,`native`,`recording`,`settlementSeq`]),n=V(t.childRunId),r=xt(t.recording);return r.status===`committed`&&r.detail.childRunId!==n&&j(),{assignmentId:Ie(t.assignmentId),childRunId:n,native:R(t.native,ct),recording:r,settlementSeq:St(t.settlementSeq,r)}}),i=I(n.outcome,Be);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(Ct))&&j(),{kind:`parent`,outcome:i,required:r}}function Et(e){let t=z(e,[`first`,`last`,`firstObservedMs`,`lastObservedMs`]),n=P(t.first,1,k.dataFrames+k.controlFrames),r=P(t.last,n,k.dataFrames+k.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 Dt(e){let t=z(e,[`source`,`event`]),n=Et(t.source),r=q(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,k.chunkBytes)}}}if(r===`stored-end`){let e=z(t.event,[`kind`,`detailId`,`coverage`]);return{source:n,event:{kind:r,detailId:V(e.detailId),coverage:J(e.coverage)}}}let i=_t(t.event);return(i.kind===`detail-chunk`||i.kind===`detail-end`)&&j(),{source:n,event:i}}function Ot(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 kt(e){G({kind:`ok`,value:e},k.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:At(n.error)};let i=B(n.runs,k.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 At(e){let t=Re(e);return L(t.effect,`none`),t}function jt(e){let t=z(e,[`sourceHash`,`contractHash`,`buildId`]);return{sourceHash:H(t.sourceHash),contractHash:H(t.contractHash),buildId:H(t.buildId)}}function Mt(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,...jt({contractHash:n.contractHash,sourceHash:n.sourceHash,buildId:n.buildId})}}function Nt(e){let t=z(e,[`contractHash`,`assets`]);return{contractHash:H(t.contractHash),assets:jt(t.assets)}}function Pt(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 Ft(e){G(e);let t=z(e,[`commandId`,`operationId`,`runId`,`admission`,`committedSeq`,`execution`,`settlement`,`created`,`publication`]),n={commandId:V(t.commandId),operationId:V(t.operationId),runId:R(t.runId,V),admission:I(t.admission,[`accepted`,`refused`,`uncertain`]),committedSeq:U(t.committedSeq),execution:R(t.execution,e=>I(e,Be)),settlement:R(t.settlement,Tt),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&&wt(n.settlement)!==n.execution||n.created?.state===`published`&&n.publication!==`published`)&&j(),n}function It(e){G(e);let t=z(e,[`identity`,`receipt`]),n=rt(t.identity),r=Ft(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(q(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 Lt(e){switch(G(e),q(e,`status`)){case`found`:return{status:`found`,receipt:Ft(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 Rt(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,Ie),admission:Jt(t.admission),lifecycle:I(t.lifecycle,[`queued`,`preparing`,`running`,`closing`,`settled`]),outcome:R(t.outcome,e=>I(e,Be)),settlement:R(t.settlement,Tt),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:J(t.coverage),result:R(t.result,K)};return(n.admission.context.task?.id!==n.taskId||n.childRunId!==null&&!n.admission.assignments.some(e=>e.childRunId===n.childRunId&&e.assignmentId===n.assignmentId)||n.settlement?.kind===`parent`&&G(n.settlement.required.map(({assignmentId:e,childRunId:t})=>({assignmentId:e,childRunId:t})))!==G(n.admission.assignments)||n.settlement?.kind===`sdk`&&n.settlement.recording.status===`committed`&&(n.settlement.recording.detail.childRunId!==n.childRunId||n.result!==null&&G(n.result)!==G(n.settlement.recording.detail.content))||n.settlement!==null&&(n.childRunId!==null&&n.settlement.kind!==`sdk`||n.childRunId===null&&n.settlement.kind!==(n.admission.kind===`check`?`check`:`parent`)||n.outcome!==null&&wt(n.settlement)!==n.outcome)||n.childRunId===null!=(n.assignmentId===null)||n.lifecycle===`settled`!=(n.outcome!==null)||n.outcome===`completed`&&(!n.settlement||wt(n.settlement)!==`completed`||n.coverage.observed!==`complete`))&&j(),n}function zt(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function Bt(e,t,n){return zt(e,t)&&e.taskId===Zt(n)&&e.admission.context.workspaceId===Xt(n)}function Vt(e){G(e,k.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:lt(t.scope),committedSeq:U(t.committedSeq),context:Yt(t.context),runs:B(t.runs,k.maxPageEntries,Rt),horizon:ln(t.horizon)};return(!Qt(n.context,n.epoch,n.scope)||G(n.horizon.historicalRuns.scope)!==G(n.scope)||n.horizon.historicalRuns.snapshotSeq!==n.committedSeq||n.horizon.historicalRuns.storeId!==n.storeId||n.runs.some(e=>!Bt(e,n.scope,n.context))||new Set(n.runs.map(e=>e.childRunId??e.runId)).size!==n.runs.length)&&j(),n}function Ht(e){G(e,k.pageBytes);let t=q(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:lt(n.scope),committedSeq:U(n.committedSeq)};if(t===`update`){let e=U(n.previousSeq);W(r.committedSeq,e)<=0&&j();let i=Yt(n.context);Qt(i,r.epoch,r.scope)||j();let a=B(n.runs,k.maxPageEntries,Rt),o=B(n.removed,k.maxPageEntries,V),s=a.map(e=>e.childRunId??e.runId);return(a.some(e=>!Bt(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 Ut(e){let{navigation:t,...n}=e;return n}function Wt(e,t){(!t.navigation||t.navigation===e.navigation||G(Ut(e))!==G(Ut(t)))&&j()}function Gt(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return Kt(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`cursor`,`next`,`coverage`]),n=Y(t.cursor),r=Y(t.next);return Wt(n,r),{kind:`progress`,cursor:n,next:r,coverage:J(t.coverage)}}function Kt(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`content`,`range`,`text`,`next`,`coverage`]),n={cursor:Y(t.cursor),content:K(t.content),range:R(t.range,Je),text:M(t.text,k.detailPageBytes),next:R(t.next,Y),coverage:J(t.coverage)};return(n.cursor.recordId!==n.content.recordId||n.cursor.recordVersion!==n.content.version||n.cursor.field!==n.content.field||(n.range?n.range.start!==n.cursor.offset||n.range.end>n.content.bytes||n.range.end-n.range.start!==N(n.text):n.content.bytes!==0||n.cursor.offset!==0||n.text!==``))&&j(),n.coverage.observed===`complete`&&n.next!==null!=(n.range?.end??0)<n.content.bytes&&j(),n.next&&(n.next.offset!==n.range?.end||G(Ut({...n.next,offset:n.cursor.offset}))!==G(Ut(n.cursor)))&&j(),n}function qt(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`cursor`,`hits`,`next`,`coverage`]),n=Y(t.cursor);n.query||j();let r=N(n.query),i=B(t.hits,k.maxPageEntries,e=>{let t=z(e,[`content`,`range`,`preview`,`cursor`,`owner`]),i=K(t.content),a=tn(t.owner);nn(a,n.scope)||j();let o=Je(t.range),s=Y(t.cursor);return(o.end>i.bytes||o.end-o.start!==r||s.recordId!==i.recordId||s.recordVersion!==i.version||s.field!==i.field||s.offset!==o.start||s.storeId!==n.storeId||G(s.scope)!==G(n.scope)||s.snapshotSeq!==n.snapshotSeq||s.query!==n.query||s.navigation!==void 0)&&j(),{content:i,owner:a,range:o,preview:M(t.preview,k.previewBytes),cursor:s}}),a=R(t.next,Y);return a&&(a.storeId!==n.storeId||G(a.scope)!==G(n.scope)||a.query!==n.query||a.snapshotSeq!==n.snapshotSeq||a.recordId===n.recordId&&a.recordVersion===n.recordVersion&&a.field===n.field&&(a.offset<n.offset||a.offset===n.offset&&(!a.navigation||a.navigation===n.navigation)))&&j(),{cursor:n,hits:i,next:a,coverage:J(t.coverage)}}function Jt(e){let t=z(e,[`operationId`,`commandId`,`kind`,`context`,`assignments`,`graph`]),n=Qe(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,k.assignments,e=>{let t=z(e,[`assignmentId`,`childRunId`]);return{assignmentId:Ie(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 Yt(e){if(q(e,`status`)===`available`)return{status:`available`,version:Qe(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 Xt(e){return e.status===`available`?e.version.workspaceId:e.workspaceId}function Zt(e){return e.status===`available`?e.version.task?.id??null:e.taskId}function Qt(e,t,n){return(e.status!==`available`||e.version.epoch===t)&&(n.kind!==`task`||Zt(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:Nt(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 en(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`workspaceId`,`storeId`,`epoch`,`committedSeq`,`rootLabel`,`context`,`models`,...Object.hasOwn(e??{},`activeRuns`)?[`activeRuns`]:[]]),n={...t.activeRuns===void 0?{}:{activeRuns:kt(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:Yt(t.context),models:B(t.models,k.maxPageEntries,Ge)};return n.activeRuns&&(n.activeRuns.storeId!==n.storeId||n.activeRuns.workspaceId!==n.workspaceId||n.activeRuns.epoch!==n.epoch)&&j(),(Xt(n.context)!==n.workspaceId||Zt(n.context)!==null||n.context.status===`available`&&n.context.version.epoch!==n.epoch)&&j(),n}function tn(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 nn(e,t){return t.kind===`task`?e.taskId===t.id:t.kind===`run`?e.runId===t.id:e.childRunId===t.id}function rn(e){let t=z(e,[`identity`,`complete`,`checkoutGeneration`]);return{identity:H(t.identity),complete:F(t.complete),checkoutGeneration:P(t.checkoutGeneration)}}function an(e){G(e,k.controlBytes);let t=q(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:Jt(n.identity)}}case`parent-settled`:{let n=z(e,[`kind`,`runId`,`settlement`]),r=Tt(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:st(n.handoff),observation:rn(n.observation)}}case`changes`:{let n=z(e,[`kind`,`observationId`,`stage`,`observation`,`content`]),r=K(n.content);return L(r.field,`changes`),{kind:t,observationId:V(n.observationId),stage:I(n.stage,[`before`,`after`,`review`]),observation:rn(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:$e(n.selection),cwdId:V(n.cwdId),cwdLabel:M(n.cwdLabel,4096,!0),checkEnvGeneration:P(n.checkEnvGeneration,1),before:rn(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=vt(r.native),o=I(r.status,[`passed`,`failed`,`canceled`,`stale`]),s=rn(r.before),c=rn(r.after),l=R(r.output,K),u=J(r.coverage);return l&&l.field!==`check`&&j(),o===`passed`&&(a.outcome!==`completed`||G({...s,checkoutGeneration:c.checkoutGeneration})!==G(c)||(i?s.checkoutGeneration!==i.from||c.checkoutGeneration!==i.to||l===null:s.checkoutGeneration!==c.checkoutGeneration)||u.observed!==`complete`)&&j(),o===`canceled`&&![`canceled`,`timeout`].includes(a.outcome)&&j(),{kind:t,...i?{ownAdvance:i}:{},checkId:V(r.checkId),native:a,status:o,before:s,after:c,output:l,coverage:u}}case`review`:{let n=z(e,[`kind`,`reviewId`,`runId`,`checksRevision`,`changesIdentity`,`acceptIssues`,`outcome`,`content`]),r=F(n.acceptIssues),i=I(n.outcome,[`reviewed`,`reviewed-with-issues`]),a=K(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 on(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 sn(e){G(e,k.ownerQueueBytes);let t=z(e,[`observedMs`,`link`,`events`]),n=on(t.link),r=B(t.events,k.ownerQueueFrames,e=>{let t=q(e);if(t===`fact`){let r=an(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=tn(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,k.chunkBytes)}}let r=z(e,[`kind`,`detailId`,`coverage`]);return L(t,`content-end`),{kind:`content-end`,detailId:V(r.detailId),coverage:J(r.coverage)}});return{observedMs:P(t.observedMs),link:n,events:r}}var cn=[`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,cn),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:ut(t.navigation)}:{},storeId:V(t.storeId),scope:i,snapshotSeq:a,after:o,limit:P(t.limit,1,k.maxPageEntries)}}function ln(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 un(e){let t=q(e);if(t===`run`)return{kind:t,projection:Rt(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:Ot(n.link),capture:Dt(n.capture)}}if(t===`owner-fact`){let n=z(e,[`kind`,`recordId`,`committedSeq`,`observedMs`,`link`,`fact`]),r=sn({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=tn(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,K);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,k.dataFrames)),s=R(i.finalText,K),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:dt(i.source)}}if(t===`tool`){let e=R(i.declaration,ft),n=R(i.declarationStage,e=>I(e,[`partial`,`final`])),r=F(i.startObserved),s=R(i.result,e=>{let t=_t(e);return t.kind!==`tool-end`&&j(),t});return(e===null!=(n===null)||s&&(s.callId!==a.entity.id||s.startObserved!==r||G(s.declaration)!==G(e)))&&j(),{kind:t,owner:a,version:o,declaration:e,declarationStage:n,startObserved:r,result:s,source:dt(i.source),name:M(i.name,128,!0)}}if(t===`content`){let e=mt(i.descriptor),n=K(i.content);return(e.field!==n.field||!dn(e.owner,a))&&j(),{kind:t,owner:a,version:o,detailId:V(i.detailId),descriptor:e,content:n,coverage:J(i.coverage)}}L(t,`omitted`);let s=ht(i.block);return dn(s.owner,a)||j(),{kind:`omitted`,owner:a,version:o,block:s}}function dn(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 fn(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 pn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`records`,`next`,`coverage`]),n=Z(t.request);n.snapshotSeq===null&&j();let r=B(t.records,n.limit,un),i=R(t.next,Z);return(r.some(e=>!fn(e,n))||i&&(i.after===null||G(Ut({...i,after:n.after}))!==G(Ut(n))||G(i.after)===G(n.after)))&&j(),{request:n,records:r,next:i,coverage:J(t.coverage)}}function mn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value===`snapshot`){G({kind:`ok`,value:e},k.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||G(Ut({...r,snapshotSeq:null}))!==G(Ut(n)))&&j(),{kind:`snapshot`,request:n,next:r,coverage:J(t.coverage)}}if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return pn(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Z(t.request),r=Z(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function hn(e,t){return G({...t.request,snapshotSeq:e.snapshotSeq})===G(e)&&(e.snapshotSeq===null||e.snapshotSeq===t.request.snapshotSeq)}function gn(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:ut(t.navigation)}:{},storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),graph:{recordId:V(n.recordId),revision:P(n.revision,1),sha256:H(n.sha256)}}}function _n(e){G({kind:`ok`,value:e});let t=z(e,[`request`,`graph`]),n=gn(t.request),r=Xe(t.graph);return(r.revision!==n.graph.revision||n.scope.kind===`task`&&n.scope.id!==r.taskId)&&j(),{request:n,graph:r}}function vn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return _n(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=gn(t.request),r=gn(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}function yn(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`format`]);return{storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),format:I(t.format,[`ndjson`,`markdown`])}}function bn(e){G(e,k.controlBytes);let t=z(e,[`exportId`,`ordinal`,`event`]),n=q(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,Ne),request:yn(e.request),coverage:J(e.coverage),serviceProtocol:L(e.serviceProtocol,1),workerProtocol:L(e.workerProtocol,2)};break}case`record`:r={kind:n,record:un(z(t.event,[`kind`,`record`]).record)};break;case`graph`:r={kind:n,graph:_n(z(t.event,[`kind`,`graph`]).graph)};break;case`detail`:{let e=z(t.event,[`kind`,`owner`,`content`,`range`,`text`,`coverage`]),i=K(e.content),a=R(e.range,Je),o=M(e.text,k.detailPageBytes);(a?a.end>i.bytes||a.end-a.start!==N(o):i.bytes!==0||o!==``)&&j(),r={kind:n,owner:tn(e.owner),content:i,range:a,text:o,coverage:J(e.coverage)};break}case`markdown`:r={kind:n,text:M(z(t.event,[`kind`,`text`]).text,k.detailPageBytes)};break;case`trailer`:{let e=z(t.event,[`kind`,`complete`,`frames`,`encodedBytes`,`sha256`,`committedSeq`,`coverage`]),i=J(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 xn(e,t){let n=bn(e);return t===`ndjson`?`${G(n)}\n`:n.event.kind===`markdown`?n.event.text:(n.event.kind!==`manifest`&&n.event.kind!==`trailer`&&j(),`\n\n\`\`\`json\n${G(n)}\n\`\`\`\n`)}var Sn=class{exportId=null;ordinal=0;bytes=0;ended=!1;complete=!1;request;constructor(e){this.request=yn(e)}receive(e){let t=bn(e),n=t.event;return(this.ended||t.ordinal!==this.ordinal+1||this.exportId!==null&&this.exportId!==t.exportId)&&j(),this.ordinal===0?(n.kind!==`manifest`||G(n.request)!==G(this.request))&&j():n.kind===`manifest`&&j(),n.kind===`trailer`?((n.frames!==this.ordinal||n.encodedBytes!==this.bytes||n.committedSeq!==this.request.snapshotSeq)&&j(),this.ended=!0,this.complete=n.complete):(this.request.format===`markdown`&&n.kind!==`manifest`&&n.kind!==`markdown`&&j(),this.request.format===`ndjson`&&n.kind===`markdown`&&j(),n.kind===`detail`&&!nn(n.owner,this.request.scope)&&j(),n.kind===`graph`&&(G(n.graph.request.scope)!==G(this.request.scope)||n.graph.request.snapshotSeq!==this.request.snapshotSeq||n.graph.request.storeId!==this.request.storeId)&&j(),n.kind===`record`&&!Cn(n.record,this.request.scope)&&j(),this.bytes+=N(xn(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 Cn(e,t){return e.kind===`run`?zt(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:nn(e.owner,t)}function wn(e){let t=z(e,[`taskId`,`revision`,`definitions`]),n=B(t.definitions,32,e=>{let t=z(e,[`selection`,`status`,`checkId`]),n=$e(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 Tn(e){let t=z(e,[`storeId`,`scope`,`snapshotSeq`,`kind`,`id`,`version`,...Object.hasOwn(e??{},`navigation`)?[`navigation`]:[]]);return{...Object.hasOwn(t,`navigation`)?{navigation:ut(t.navigation)}:{},storeId:V(t.storeId),scope:lt(t.scope),snapshotSeq:U(t.snapshotSeq),kind:I(t.kind,[`task`,`message`,`tool`]),id:V(t.id),version:P(t.version,1)}}function En(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`record`]),n=Tn(t.request),r=un(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||!nn(r.owner,n.scope))&&j(),{request:n,record:r}}function Dn(e){if(Object.getOwnPropertyDescriptor(e??{},`kind`)?.value!==`progress`)return En(e);G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`kind`,`request`,`next`,`coverage`]),n=Tn(t.request),r=Tn(t.next);return Wt(n,r),{kind:`progress`,request:n,next:r,coverage:J(t.coverage)}}var On=e=>{let t=Re(e);return L(t.effect,`none`),t};function kn(e){let t=z(e,[`storeId`,`taskId`]);return{storeId:V(t.storeId),taskId:R(t.taskId,V)}}function An(e){let t=kn(e);return t.taskId===null&&j(),t}function jn(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 Mn(e){let t=B(e,3,Ke);return(t.length!==3||new Set(t.map(e=>e.role)).size!==3)&&j(),t}function Nn(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:gn(n.request),planRevision:P(n.planRevision,1)}}let n=z(e,[`status`,`error`]);return L(n.status,`unavailable`),{status:`unavailable`,error:On(n.error)}}function Pn(e){if((e.request.taskId!==(e.task?.id??null)||Xt(e.context)!==e.workspaceId||Zt(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 Fn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`roles`,`readablePlan`,`savedGraph`]),n={request:kn(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:Yt(t.context),task:R(t.task,jn),roles:Mn(t.roles),savedGraph:Nn(t.savedGraph),readablePlan:R(t.readablePlan,e=>{let t=z(e,[`source`,`text`,`editable`,`coverage`]),n=J(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}})};Pn(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 In(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`request`,`workspaceId`,`epoch`,`committedSeq`,`context`,`task`,`observation`,`text`,`git`,`coverage`]),n=z(t.observation,[`identity`,`complete`,`checkoutGeneration`]),r={request:An(t.request),workspaceId:V(t.workspaceId),epoch:V(t.epoch),committedSeq:U(t.committedSeq),context:Yt(t.context),task:jn(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:J(t.coverage)};if(Pn(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 Ln(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 Rn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`]);return{version:Ln(t.version),selected:R(t.selected,Ge)}}function zn(e){G(e);let t=z(e,[`expected`,`choice`]);return{expected:Ln(t.expected),choice:We(t.choice)}}function Bn(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,He)),thinking:B(t.thinking,7,e=>{let t=z(e,[`level`,`selectable`]);return{level:I(t.level,Ue),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 Vn(e){G({kind:`ok`,value:e},k.pageBytes);let t=z(e,[`version`,`selected`,`status`,`entries`]),n=B(t.entries,k.maxPageEntries,Bn),r=I(t.status,[`complete`,`capacity`]);return(r===`capacity`&&n.length||new Set(n.map(e=>G([e.provider,e.model]))).size!==n.length)&&j(),{version:Ln(t.version),selected:R(t.selected,Ge),status:r,entries:n}}async function Hn(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 Un(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 Q=e=>({kind:`error`,error:Fe(`unavailable`,e?`uncertain`:`none`)}),Wn=class{transport;constructor(e){this.transport=e}async current(e,t){let n=kn(e);try{if(!this.transport.current)return Q(!1);let e=X(await this.transport.current(n,t),Fn);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async currentChanges(e,t){let n=An(e);try{if(!this.transport.currentChanges)return Q(!1);let e=X(await this.transport.currentChanges(n,t),In);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async activeRuns(e){try{return this.transport.activeRuns?X(await this.transport.activeRuns(e),kt):Q(!1)}catch{return Q(!1)}}async models(e){try{return this.transport.models?X(await this.transport.models(e),Vn):Q(!1)}catch{return Q(!1)}}async chooseModel(e){let t=zn(e);try{if(!this.transport.chooseModel)return Q(!1);let e=X(await this.transport.chooseModel(t),Rn);if(e.kind===`ok`){let{sourceSelectionId:n,...r}=e.value.selected??{};if(G(r)!==G(t.choice)||e.value.version.epoch!==t.expected.epoch||e.value.version.accessGeneration!==t.expected.accessGeneration||![t.expected.configRev,t.expected.configRev+1].includes(e.value.version.configRev)||e.value.version.configRev===t.expected.configRev!=(e.value.version.catalogId===t.expected.catalogId))return Q(!0)}return e}catch{return Q(!0)}}async checkObligations(e,t){V(e);try{let n=X(await this.transport.checkObligations(e,t),wn);return n.kind===`ok`&&n.value.taskId!==e?Q(!1):n}catch{return Q(!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=Tn({...t,kind:e});try{let e=X(await this.transport.entity(r,n),Dn);return e.kind===`ok`&&G(e.value.request)!==G(r)?Q(!1):e}catch{return Q(!1)}}async session(e){try{return X(await this.transport.session(e),$t)}catch{return Q(!1)}}async workspace(e){try{return X(await this.transport.workspace(e),en)}catch{return Q(!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),mn);return t.kind===`ok`&&!hn(r,t.value)?Q(!1):t}catch{return Q(!1)}}async graph(e,t){let n=gn(e);try{let e=X(await this.transport.graph(n,t),vn);return e.kind===`ok`&&G(e.value.request)!==G(n)?Q(!1):e}catch{return Q(!1)}}async*export(e,t){let n=yn(e),r=new Sn(n),i;try{if(t.aborted)throw new A(`unavailable`);for await(let e of this.transport.export(n,t)){if(t.aborted)throw new A(`unavailable`);let n=r.receive(e);n.event.kind===`trailer`?i=n:yield n}if(t.aborted||!i)throw new A(`unavailable`);yield i}catch{throw new A(`unavailable`)}}async preflight(e,t){let n=tt({expected:e,action:t});try{let e=X(await this.transport.preflight(n),ot);return e.kind===`ok`&&(G(e.value.preview.version)!==G(n.expected)||G(e.value.preview.action)!==G(n.action))?Q(!1):e}catch{return Q(!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=nt(t);if(n.action.kind!==e)return{kind:`error`,error:Fe(`invalid`)};try{let e=X(await this.transport.command(n),Ft);if(e.kind===`ok`){if(e.value.commandId!==n.commandId)return Q(!0);It({identity:{kind:`action`,expected:n.expected,action:n.action},receipt:e.value})}return e}catch{return Q(!0)}}async cancel(e){let t=it(e);try{let e=X(await this.transport.cancel(t),Ft);if(e.kind===`ok`){if(e.value.commandId!==t.commandId)return Q(!0);It({identity:{kind:`cancel`,epoch:t.epoch,runId:t.runId},receipt:e.value})}return e}catch{return Q(!0)}}async receipt(e,t){V(e);try{let n=Lt(await this.transport.receipt(e,t));if(n.status===`found`&&n.receipt.commandId!==e)throw Error(`invalid`);return n}catch{return{status:`inconclusive`,error:Fe(`receipt-inconclusive`,`uncertain`)}}}async snapshot(e,t){let n=lt(e);try{let e=X(await this.transport.snapshot(n,t),Vt);return e.kind===`ok`&&G(e.value.scope)!==G(n)?Q(!1):e}catch{return Q(!1)}}async detail(e,t){let n=Y(e);try{let e=X(await this.transport.detail(n,t),Gt);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?Q(!1):e}catch{return Q(!1)}}async search(e,t){let n=Y(e);try{let e=X(await this.transport.search(n,t),qt);return e.kind===`ok`&&G(e.value.cursor)!==G(n)?Q(!1):e}catch{return Q(!1)}}},Gn=class{generation=0;snapshotRequest=0;observation;lastSnapshotMs=0;beginSnapshot(){return++this.snapshotRequest}install(e,t,n){if(n!==this.snapshotRequest)return;let r=Vt(e),i=this.observation?.snapshot;if(i&&i.storeId===r.storeId&&G(i.scope)===G(r.scope)&&W(r.committedSeq,i.committedSeq)<0)this.resync();else return this.observation={snapshot:r,connection:`current`,lastObservedMs:t},this.lastSnapshotMs=t,++this.generation}resync(){return this.observation&&(this.observation.connection=`resync`),this.snapshotRequest++,`resync`}get state(){return this.observation&&structuredClone(this.observation)}needsPoll(e){return!this.observation||this.observation.connection===`resync`||e<this.lastSnapshotMs||e-this.lastSnapshotMs>=k.reconcileMs}tick(e){let t=this.observation;t&&t.connection!==`resync`&&(e<t.lastObservedMs||e-t.lastObservedMs>=k.staleMs)&&(t.connection=`stale`)}receive(e,t,n){let r=this.observation;if(!r||t!==this.generation)return`ignored`;if(r.connection===`resync`)return`resync`;let i;try{i=Ht(e)}catch{return this.resync()}let a=r.snapshot;if(i.storeId!==a.storeId||i.epoch!==a.epoch||G(i.scope)!==G(a.scope))return this.resync();let o=W(i.committedSeq,a.committedSeq);if(o<0)return`duplicate`;if(i.kind===`heartbeat`)return o>0?this.resync():(r.lastObservedMs=n,r.connection=`current`,`applied`);if(o===0)return`duplicate`;if(i.previousSeq!==a.committedSeq||Xt(i.context)!==Xt(a.context)||Zt(i.context)!==Zt(a.context)||i.context.status===`available`&&a.context.status===`available`&&i.context.version.controlRev<a.context.version.controlRev)return this.resync();let s=[...a.runs];for(let e of i.removed){let t=s.findIndex(t=>(t.childRunId??t.runId)===e);if(t===-1||s[t].lifecycle!==`settled`)return this.resync();s.splice(t,1)}for(let e of i.runs){let t=e.childRunId??e.runId,n=s.findIndex(e=>(e.childRunId??e.runId)===t);if(n===-1)s.push(e);else{let t=s[n];if(t.runId!==e.runId||t.childRunId!==e.childRunId||t.assignmentId!==e.assignmentId||G(t.admission)!==G(e.admission))return this.resync();s[n]=e}}if(s.length>k.maxPageEntries)return this.resync();let c={...a,runs:s,context:i.context,committedSeq:i.committedSeq,horizon:{...a.horizon,historicalRuns:{...a.horizon.historicalRuns,snapshotSeq:i.committedSeq}}};try{Vt(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`}},Kn={session:`/api/v1/session`,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`},qn=`/api/v1/events`,Jn=[`tasks`,`runs`,`messages`,`tools`,`contents`,`events`,`checks`,`changes`,`reviews`];function Yn(e,t){if(Jn.includes(e)||e===`detail`||e===`search`||e===`entity`||e===`current`||e===`currentChanges`||e===`activeRuns`||e===`workspace`||e===`models`||e===`chooseModel`)return k.pageBytes;if(e===`graph`){let e=Object.getOwnPropertyDescriptor(t??{},`kind`)?.value,n=Object.getOwnPropertyDescriptor(t??{},`value`)?.value;if(e===`ok`&&Object.getOwnPropertyDescriptor(n??{},`kind`)?.value===`progress`)return k.pageBytes}return k.controlBytes}function Xn(e){return[`preflight`,`command`,`cancel`,`detach`,`chooseModel`].includes(e)}function Zn(e,t){switch(e){case`session`:case`models`:case`activeRuns`:case`workspace`:case`detach`:if(t!==null)throw new A(`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 A(`invalid`);return n}case`current`:return kn(t);case`currentChanges`:return An(t);case`checkObligations`:case`receipt`:return V(t);case`entity`:return Tn(t);case`graph`:return gn(t);case`snapshot`:return lt(t);case`detail`:case`search`:return Y(t);case`export`:case`download`:return yn(t);case`chooseModel`:return zn(t);case`preflight`:return tt(t);case`command`:return nt(t);case`cancel`:return it(t)}}function Qn(e,t){if(Jn.includes(e))return X(t,mn);switch(e){case`current`:return X(t,Fn);case`currentChanges`:return X(t,In);case`activeRuns`:return X(t,kt);case`models`:return X(t,Vn);case`chooseModel`:return X(t,Rn);case`session`:return X(t,$t);case`workspace`:return X(t,en);case`checkObligations`:return X(t,wn);case`entity`:return X(t,Dn);case`graph`:return X(t,vn);case`snapshot`:return X(t,Vt);case`detail`:return X(t,Gt);case`search`:return X(t,qt);case`preflight`:return X(t,ot);case`command`:case`cancel`:return X(t,Ft);case`receipt`:return Lt(t);case`detach`:return X(t,e=>{if(e!==null)throw new A(`invalid`);return null});default:throw new A(`invalid`)}}function $n(e){return[...Jn,`current`,`currentChanges`,`checkObligations`,`entity`,`graph`,`snapshot`,`detail`,`search`,`export`,`download`,`receipt`].includes(e)}function er(e,t){let n=Kn[e];return t===null||Xn(e)?n:`${n}?request=${encodeURIComponent(G(t))}`}function tr(e,t){let n=Zn(e,t),r=typeof n==`object`&&!!n&&Object.hasOwn(n,`navigation`),i=r?Kn[e]:er(e,n);return Xn(e)||$n(e)&&(r||N(i)>k.headerBytes/4)?{path:Kn[e],method:`POST`,body:G(n)}:{path:i,method:`GET`}}function nr(e){G(e,k.viewerBytes);let t=I(Object.getOwnPropertyDescriptor(e,`kind`)?.value,[`snapshot`,`event`,`resync`]);return t===`snapshot`?{kind:t,snapshot:Vt(z(e,[`kind`,`snapshot`]).snapshot)}:t===`event`?{kind:t,event:Ht(z(e,[`kind`,`event`]).event)}:(z(e,[`kind`]),{kind:t})}var rr=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))throw new A(`invalid`);this.origin=e.origin,e.build&&=Mt(e.build),this.fetcher=e.fetch??globalThis.fetch.bind(globalThis)}headers(e){let t={"Cache-Control":`no-store`};if(this.options.build&&(t[`X-Cadence-Build`]=G(this.options.build)),this.attachment&&(t[`X-Cadence-Attachment`]=this.attachment),this.options.localCapability&&(t[`X-Cadence-Local`]=this.options.localCapability),e){if(!this.attachment||!this.options.localCapability&&!this.csrf)throw new A(`stale`);t[`Content-Type`]=`application/json`,this.csrf&&(t[`X-Cadence-CSRF`]=this.csrf)}return t}async request(e,t,n){let r=tr(e,Zn(e,t)),i=r.method===`POST`,a=await this.fetcher(`${this.origin}${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 ir(a,Yn(e)),c=Le(s);if(N(s)>Yn(e,c))throw new A(`oversize`);let l=Qn(e,c);if(e===`session`){let e=X(l,$t);if(e.kind===`ok`){if(e.value.authority===`local`!=!!this.options.localCapability)throw new A(`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`,zn(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`,Tn(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`,gn(e),t)}preflight(e){return this.request(`preflight`,tt(e))}command(e){return this.request(`command`,nt(e))}cancel(e){return this.request(`cancel`,it(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 A(`invalid`);return null});if(t.kind===`error`&&t.error.code!==`stale`&&t.error.code!==`unauthenticated`)throw new A(t.error.code);return this.attachment===e&&(this.attachment=void 0,this.csrf=null),t}async*export(e,t){let n=tr(`export`,yn(e)),r=await this.fetcher(`${this.origin}${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 A(`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 A(`unavailable`);for(let t=0;t<(n?1:e.byteLength);t+=k.chunkBytes){o+=n?a.decode():a.decode(e.subarray(t,t+k.chunkBytes),{stream:!0});let r=o.indexOf(`
2
2
  `);for(;r!==-1;){let e=o.slice(0,r);o=o.slice(r+1),yield bn(Le(e,k.controlBytes)),r=o.indexOf(`
3
- `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new A(`oversize`)}if(n){if(o)throw new A(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=lt(e);if(!this.attachment||!this.options.socket)throw new A(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${qn}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(G({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new A(`invalid`);let n=nr(Le(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function ir(e,t){if(!e.body)throw new A(`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 A(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var ar={sourceHash:`c389e2006852275c06ea853030cb2c9f62e65eaa6b57c9557d43573833144dbb`,contractHash:`e7e5248f8273a373827ac70d2d8be1d5aaea1e329379e59e4947fc10f82be818`,buildId:`0bd45aeadc0810d97310596dbfd28f75669e4832c401b52622ac9f9eac01f585`};function or(){let e=new rr({origin:window.location.origin,...ar?{build:{kind:`browser`,...ar}}:{},socket:e=>new WebSocket(e)});return{client:new Wn(e),transport:e}}async function sr(e,t,n,r){let i=Fn(e);if(i.context.status!==`available`||!i.context.version.task||!i.readablePlan?.editable||i.savedGraph.status===`unavailable`)throw new A(`unavailable`);let a=i.context.version,o=a.task;if(!o)throw new A(`stale`);let s=M(t,32768),c=et({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 A(`invalid`);for(let e of c.graph.assignments){let t=i.roles.find(t=>t.role===qe(e.purpose));if(!t||G(t)!==G(e.role)||G(a.model)!==G(e.model))throw new A(`stale`)}c.graph.plan.sha256=await r.sha256(new TextEncoder().encode(s));let l=et(c);if(l.kind!==`save-plan`)throw new A(`invalid`);return l}var cr=`Current plan metadata unavailable. Observe again; historical text is not action authority.`;function lr(e,t){let n=async n=>{let r=await e.current({storeId:t,taskId:n.task?.id??null});if(r.kind===`error`)throw new A(r.error.code);if(r.value.context.status!==`available`||G(r.value.context.version)!==G(n))throw new A(`stale`);return r.value},r=e=>({kind:`error`,error:Fe(e instanceof A?e.code:`unavailable`)});return{async read(t,i){try{let r=await n(t);if(!r.readablePlan||r.savedGraph.status===`unavailable`)throw new A(`unavailable`);let a=null;if(r.savedGraph.status===`saved`){let o=r.savedGraph.request;if(i&&(i.storeId!==o.storeId||G(i.graph)!==G(o.graph)||G(i.scope)!==G(o.scope)))throw new A(`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 A(`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 sr(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 ur(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&W(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&G(t.settlement)!==G(r.settlement))?i=!0:(!r||W(t.committedSeq,r.committedSeq)>0||G(r)===G(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}var dr=e=>e===`unauthenticated`||e===`forbidden`,fr=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 Gn,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g={actions:!1,transportStatus:`closed`,attachmentVersion:0},_=()=>!r&&n===this.version,v=()=>{_()&&t({...g,observation:c.state})},y=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=y;let b=e=>{this.serial=this.serial.then(e).catch(()=>{_()&&(m=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),g.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,g.actions=!1,g.transportStatus=`closed`,g.workspace=void 0,c=new Gn,v())})},x=async()=>{await this.api.transport.detach()},S=async(t=!1)=>{if(!_()||!f||d||m)return;d=!0,g.actions=!1;let n=!1;v(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!_()||r.aborted?!1:e.kind===`error`?(g.actions=!1,g.error=e.error.code,dr(e.error.code)&&ee(),!1):(C(e.value),!0)};if(t&&!await i())return;e||(g.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!_()||r.aborted)return;if(a.kind===`ok`)g.activeRuns=a.value;else if(dr(a.error.code)){ee();return}else g.activeRuns=void 0;v();let o=await this.api.client.workspace(r);if(!_()||r.aborted)return;if(o.kind===`error`){g.error=o.error.code,dr(o.error.code)&&ee();return}if(!t&&G(g.workspace?.models??[])!==G(o.value.models)&&!await i())return;if(g.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!_()||r.aborted)return;if(i.kind===`error`)g.error=i.error.code,dr(i.error.code)&&ee();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),g.error=void 0,n=!0}}else g.error=void 0,n=!0}catch{_()&&(g.error=`Observation unavailable.`,g.actions=!1,g.transportStatus=`stale`)}finally{d=!1,g.actions=n&&h,v()}},ee=()=>{m=!0,g.actions=!1,g.transportStatus=`closed`,g.error=`Access revoked; explicit token re-entry required.`,g.workspace=void 0,g.activeRuns=void 0,c=new Gn,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),b(x),v()},C=e=>{let t=ar?{kind:`browser`,...ar}:null;g.compatible=Pt(e.build,t),g.cancelCompatible=Pt(e.build,t,!0),h=e.capabilities.actions&&g.compatible},w=async()=>{if(f=!1,await x(),!_()||m)return;let t=await this.api.client.session();if(!_()||m){await x();return}if(t.kind===`error`){m=!0,g.error=`${t.error.code}; explicit re-entry required.`,g.workspace=void 0,c=new Gn,g.actions=!1,v();return}if(f=!0,s=new AbortController,c=new Gn,g={actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:g.attachmentVersion+1},C(t.value),v(),await S(),!_()||m||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(_()&&!m&&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`&&S():S();v()}},e=>{_()&&!m&&n===u&&(g.transportStatus=e,e===`closed`&&(f=!1,g.actions=!1,g.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>b(w),1e3)),v())})};return b(w),this.pollCurrent=e=>{S(e)},a=setInterval(()=>{_()&&!m&&(c.tick(Date.now()),v(),(Date.now()-p>=3e4||e&&c.needsPoll(Date.now()))&&S())},1e3),()=>{_()&&(y(),b(x))}}};function pr(e,t,n){let r=(0,f.useMemo)(()=>new fr(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 mr=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}},$=r();function hr({title:e,children:t,onClose:n}){let r=(0,f.useRef)(null),i=(0,f.useId)(),a=(0,f.useRef)(n);return a.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=r.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,$.jsxs)(`dialog`,{ref:r,className:`action-dialog`,"aria-labelledby":i,onCancel:e=>{e.preventDefault(),a.current()},children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`h2`,{id:i,children:e}),(0,$.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":`Close dialog — no cancellation of accepted work`,title:`Close — accepted work is not cancelled`,onClick:n,children:(0,$.jsx)(te,{"aria-hidden":`true`})})]}),t]})}function gr(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
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 _r=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:vr(!0)},text:{92:vr(!1)}});let t={enter:{backslashMathInline:yr,backslashMathDisplay:yr,backslashMathBlock:yr},exit:{backslashMathInline:br,backslashMathDisplay:br,backslashMathBlock:br}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function vr(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 yr=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)},br=function(e){this.exit(e)};function xr(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function Sr(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return xr(e)}return xr(e)}function Cr(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 Sr(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 wr=(0,f.memo)(function({text:e}){let[t,n]=(0,f.useState)(!1),{copied:r,copy:i}=Cr();return(0,$.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:`Copy displayed text`,"aria-label":`Copy displayed text`,onClick:()=>{n(!1),i(e).then(e=>n(!e))},children:[r?(0,$.jsx)(Oe,{}):(0,$.jsx)(Ce,{}),t&&`Copy unavailable`]})}),Tr=[s,d,_r],Er=[s,l,d,_r],Dr=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Or(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 kr({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,$.jsx)(a,{remarkPlugins:n?Er:Tr,rehypePlugins:t?[i,o,...Dr]:Dr,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Mr,a:jr,img:({alt:e})=>(0,$.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var Ar=(0,f.memo)(function(e){return(0,$.jsx)(`div`,{className:`md`,children:(0,$.jsx)(kr,{...e})})});function jr({href:e,children:t}){let n=e&&Or(e);return n?(0,$.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,$.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function Mr({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=gr(r).map(e=>{let t=`code-offset:${i}`;return i+=Nr(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,$.jsxs)(`div`,{className:`codeblock`,children:[(0,$.jsx)(wr,{text:Nr(e)}),(0,$.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,$.jsxs)(`div`,{className:`code-line`,children:[o&&(0,$.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,$.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Nr(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Nr).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Nr(t?.children)}return``}function Pr({prepared:e,client:t,current:n,onClose:r,onResult:i,attachmentVersion:a}){let[o,s]=(0,f.useState)(Date.now()),[c,l]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let u=e.preflight,d=u.preview,p=(0,f.useRef)(a),m=(0,f.useRef)(!1);(!n||G(n)!==G(d.version)||o>=Date.parse(u.expiresAt)||p.current!==a)&&(m.current=!0);let h=m.current,g=async()=>{if(!(h||e.submitted)){l(!0),i({commandId:e.commandId,error:`Admission pending/unknown — observe this exact receipt.`});try{let n=await Un(t,e);i(n.kind===`ok`?{commandId:e.commandId,receipt:n.value}:{commandId:e.commandId,error:`${n.error.code}; effect ${n.error.effect}`})}catch{i({commandId:e.commandId,error:`Uncertain; do not repeat the action.`})}r()}};return(0,$.jsxs)(hr,{title:`Confirm ${d.action.kind}`,onClose:r,children:[(0,$.jsx)(`p`,{children:`Access is not consent. This confirmation applies only to the displayed context, once.`}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Checkout`}),(0,$.jsx)(`dd`,{children:d.rootLabel}),(0,$.jsx)(`dt`,{children:`Working directory`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`code`,{children:d.cwdLabel})}),(0,$.jsx)(`dt`,{children:`Model / API / thinking`}),(0,$.jsxs)(`dd`,{children:[d.version.model.provider,` / `,d.version.model.model,` /`,` `,d.version.model.api,` / `,d.version.model.thinking]}),(0,$.jsx)(`dt`,{children:`Check environment`}),(0,$.jsxs)(`dd`,{children:[`Service launch environment policy, generation`,` `,d.version.checkEnvGeneration,`; no browser environment overlays.`]}),(0,$.jsx)(`dt`,{children:`Observation`}),(0,$.jsx)(`dd`,{children:d.version.observation.complete?`Complete within bounded scope`:`Incomplete bounded coverage`}),(0,$.jsx)(`dt`,{children:`Expires`}),(0,$.jsx)(`dd`,{children:u.expiresAt})]}),(0,$.jsx)(Fr,{preview:d}),d.action.kind===`check`&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Exact parent check`}),(0,$.jsx)(`pre`,{children:d.action.check.command}),(0,$.jsxs)(`p`,{children:[d.action.check.name,`; timeout`,` `,d.action.check.timeoutMs,` ms; cwd above.`]})]}),d.action.kind===`generate-plan`&&(0,$.jsx)(`p`,{children:`Readonly proposal only. It will not save itself or dispatch editing.`}),d.issues.length>0&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Issues: `,d.issues.join(`, `)]}),h&&(0,$.jsx)(`p`,{role:`alert`,children:`Context changed or confirmation expired. Close, observe again and request a new preview.`}),(0,$.jsxs)(`footer`,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,children:`Back — no new effect`}),(0,$.jsxs)(`button`,{type:`button`,className:`primary`,disabled:h||c||e.submitted,onClick:()=>void g(),children:[`Confirm `,d.action.kind]})]})]})}function Fr({preview:e}){let t=e.action,n=t.kind===`save-plan`?t.graph:e.graph;return(0,$.jsxs)($.Fragment,{children:[t.kind===`create`&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`h3`,{children:[`Create `,t.taskKind,` task`]}),(0,$.jsx)(`pre`,{children:t.goal}),(0,$.jsx)(`p`,{children:`No Start is included.`})]}),t.kind!==`create`&&(0,$.jsx)(Ar,{text:t.kind===`save-plan`?t.plan:e.readablePlan}),n?.assignments.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`h3`,{children:[e.id,` · `,e.purpose]}),(0,$.jsxs)(`p`,{children:[e.role.role,` / `,e.role.sha256]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.model,null,2)}),(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.dependencies,null,2)})]},e.id)),t.kind===`save-plan`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{children:`Exact proposed graph and identities (not yet committed)`}),(0,$.jsx)(`pre`,{children:JSON.stringify(t.graph,null,2)})]}),t.kind===`review`&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Exact human review targets`}),(0,$.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),(0,$.jsxs)(`p`,{children:[`Human review only; failures, native exit, stale and not-run checks remain unchanged. Issues acknowledgment:`,` `,String(t.acceptIssues),`.`]})]})]})}function Ir({client:e,compatible:t,onClose:n,onChanged:r}){let[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(``),[u,d]=(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`?a(e.value):l(e.error.code))}).catch(()=>{t.signal.aborted||l(`Model catalog unavailable.`)}),()=>t.abort()},[e]),(0,$.jsxs)(hr,{title:`Choose owner model`,onClose:n,children:[(0,$.jsx)(`p`,{children:`Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.`}),(0,$.jsxs)(`p`,{children:[`Current:`,` `,i?.selected?`${i.selected.provider}/${i.selected.model} · ${i.selected.thinking}`:`No model selected`]}),(0,$.jsxs)(`label`,{children:[`Exact model / API / thinking`,(0,$.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select explicitly`}),i?.entries.flatMap(e=>e.thinking.filter(e=>e.selectable&&e.level!==`max`).map(t=>{let n=JSON.stringify({provider:e.provider,model:e.model,api:e.api,thinking:t.level});return(0,$.jsxs)(`option`,{value:n,children:[e.provider,`/`,e.model,` · `,e.api,` · `,t.level]},n)}))]})]}),i?.status===`capacity`&&(0,$.jsx)(`p`,{children:`Catalog capacity exceeded; no partial model list is selectable.`}),c&&(0,$.jsxs)(`p`,{role:`alert`,children:[c,`. No automatic replacement or retry.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!t||!i||!o||u,onClick:()=>{i&&(d(!0),e.chooseModel({expected:i.version,choice:We(JSON.parse(o))}).then(e=>{e.kind===`error`?l(e.error.code):(r(),n())}).catch(()=>l(`Choice response unconfirmed; observe catalog before another explicit choice.`)).finally(()=>d(!1)))},children:`Confirm owner model choice`})]})}function Lr({client:e,value:t,onChange:n}){let r=(0,f.useRef)(!0),i=(0,f.useRef)(null);(0,f.useEffect)(()=>(r.current=!0,()=>{r.current=!1,i.current?.abort()}),[]);let[a,o]=(0,f.useState)(!1),s=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,$.jsxs)(`section`,{className:`receipt`,"aria-label":`Command receipt`,children:[(0,$.jsx)(`h3`,{children:`Command receipt`}),(0,$.jsx)(`code`,{children:t.commandId}),t.error&&(0,$.jsx)(`p`,{role:`alert`,children:t.error}),s&&(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Admission`}),(0,$.jsx)(`dd`,{children:s.admission}),(0,$.jsx)(`dt`,{children:`Execution`}),(0,$.jsx)(`dd`,{children:s.execution??`not settled`}),(0,$.jsx)(`dt`,{children:`Publication`}),(0,$.jsx)(`dd`,{children:s.publication}),(0,$.jsx)(`dt`,{children:`Run`}),(0,$.jsx)(`dd`,{children:s.runId??`metadata action`})]}),t.lookup&&t.lookup.status!==`found`&&(0,$.jsxs)(`p`,{children:[t.lookup.status,`. This observation does not authorize replay.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>{o(!0),i.current=new AbortController,e.receipt(t.commandId,i.current.signal).then(e=>{r.current&&(n({commandId:t.commandId,lookup:e}),o(!1))})},children:`Observe exact receipt`})]})}function Rr(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 zr(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 Br(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 Vr(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=Rr(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 Hr(e,t){let n=t?G({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),zr(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 Ur({value:e}){return(0,$.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[`Recording: `,e.observed,`; source: `,e.source,`;`,` `,e.redacted?`redacted`:`no reported redaction`,e.omissions.length>0&&`; omitted: ${e.omissions.join(`, `)}`,`. Not a guarantee of complete original source or universal secret detection.`]})}function Wr(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 Gr=new Map;function Kr(e,t){t.length?Gr.set(e,t):Gr.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Gr].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 qr(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 Jr(e,t){let n=t.startContainer.parentElement;for(let r of qr(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 Yr({container:e,version:t}){let[n,r]=(0,f.useState)(``),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)(0),c=(0,f.useRef)([]),l=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let r=e.current,i=r&&n?Wr(r,n):[];return c.current=i,s(i.length),a(0),Kr(l,i),()=>Kr(l,[])},[n,e,t,l]);let u=t=>{let n=o?(i+t+o)%o:0;a(n),e.current&&c.current[n]&&(Jr(e.current,c.current[n]),Kr(`${l}-active`,[c.current[n]]))};return(0,f.useEffect)(()=>()=>Kr(`${l}-active`,[]),[l]),(0,$.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,$.jsxs)(`label`,{children:[`Find on displayed field page`,(0,$.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u(e.shiftKey?-1:1))}})]}),(0,$.jsxs)(`span`,{children:[o?i+1:0,`/`,o,o>=1e3?` (first 1000 visual highlights)`:``,`; not whole-history search`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>u(-1),children:`Previous match`}),(0,$.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>u(1),children:`Next match`})]})}function Xr({client:e,cursor:t,highlight:n,render:r}){let i=G(t),a=(0,f.useMemo)(()=>Y(JSON.parse(i)),[i]),[o,s]=(0,f.useState)(t),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(),[_,v]=(0,f.useState)(`raw`),[y,b]=(0,f.useState)(``),x=(0,f.useRef)(null),S=(0,f.useRef)(null);(0,f.useEffect)(()=>(s(a),d([]),l(void 0),g(void 0),()=>x.current?.abort()),[a]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return m(!0),g(void 0),e.detail(o,n.signal).then(e=>{t&&(m(!1),e.kind===`error`?g(e.error.code):l(e.value))}).catch(()=>{t&&(g(`Read unavailable.`),m(!1))}),()=>{t=!1,n.abort()}},[e,o]);let ee=async()=>{if(x.current)return;let n=new AbortController;x.current=n,b(`Reading all retained field pages…`);try{let r=await Vr(e,t,n.signal);if(n.signal.aborted)return;let i=await Sr(r.text);if(n.signal.aborted)return;b(i?r.recordingComplete?`Copied all retained field bytes (source omissions still apply).`:`Copied retained field bytes; recording is incomplete. No complete-source claim.`:`Clipboard unavailable.`)}catch{n.signal.aborted||b(`Full-field copy refused/incomplete.`)}finally{x.current===n&&(x.current=null)}},C=c&&!(`kind`in c)?c:void 0;return(0,$.jsxs)(`section`,{className:`detail-pane`,"aria-label":`Retained field`,children:[(0,$.jsxs)(`div`,{className:`detail-identity`,children:[(0,$.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` / `,t.field,` `,`/ snapshot `,t.snapshotSeq]}),n&&(0,$.jsxs)(`p`,{children:[`Exact hit bytes [`,n.start,`, `,n.end,`); only this immutable field is highlighted.`]}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e=>e===`raw`?`markdown`:`raw`),children:_===`raw`?`Markdown page`:`Raw page`}),(0,$.jsx)(`button`,{type:`button`,disabled:!!x.current,onClick:()=>void ee(),children:`Copy full retained field`}),!!x.current&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{x.current?.abort(),x.current=null,b(`Copy canceled; execution unchanged.`)},children:`Cancel copy`})]}),(0,$.jsx)(`p`,{role:`status`,children:y}),h&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Detail refused: `,h]}),p&&(0,$.jsx)(`p`,{role:`status`,children:`Reading…`}),c&&(0,$.jsx)(Ur,{value:c.coverage}),c&&`kind`in c&&(0,$.jsx)(`p`,{children:`Validation in progress. The retained field is not empty.`}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Bytes `,C.range?.start??0,`–`,C.range?.end??0,` of`,` `,C.content.bytes,`.`,` `,C.next?`More retained data available.`:`End of field.`]}),(0,$.jsx)(Yr,{container:S,version:`${C.content.recordId}:${C.content.version}:${C.range?.start??0}:${_}`}),(0,$.jsx)(`div`,{ref:S,"data-retained-field":!0,children:r?r(C.text):_===`markdown`?(0,$.jsx)(Ar,{text:C.text}):(0,$.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!C||!n||!C.range)return C?.text;let e=Math.max(n.start,C.range.start)-C.range.start,t=Math.min(n.end,C.range.end)-C.range.start;if(t<=e)return C.text;let r=new TextEncoder().encode(C.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,$.jsxs)($.Fragment,{children:[i(0,e),(0,$.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:p||!u.length,onClick:()=>{s(u[u.length-1]),d(e=>e.slice(0,-1))},children:`Previous`}),(0,$.jsx)(`button`,{type:`button`,disabled:p||!c?.next,onClick:()=>{c?.next&&(d(e=>[...e,o]),s(c.next))},children:c&&`kind`in c?`Continue validation`:`Next field page`})]})]})}function Zr({pager:e}){let{page:t,busy:n,error:r}=e;return(0,$.jsxs)(`div`,{className:`page-controls`,children:[r&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Read refused: `,r,`. Retained state has not been repaired.`]}),n&&(0,$.jsx)(`p`,{role:`status`,children:`Reading bounded history page…`}),t&&`kind`in t&&(0,$.jsxs)(`p`,{role:`status`,children:[t.kind===`snapshot`?`Snapshot selected`:`Validating retained history`,`; continue this exact read. No data page yet.`]}),t&&(0,$.jsx)(Ur,{value:t.coverage}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!e.canPrevious,onClick:e.previous,children:`Previous page`}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!t?.next,onClick:e.more,children:t&&`kind`in t?`Continue validation`:`Next page`}),(0,$.jsx)(`button`,{type:`button`,disabled:n,onClick:e.refresh,children:`Observe a new snapshot`}),t&&!(`kind`in t)&&!t.next&&(0,$.jsxs)(`span`,{className:`page-end`,children:[`End of this retained snapshot`,t.coverage.observed===`incomplete`?` (incomplete)`:``,`.`]})]})}function Qr({client:e,seed:t,entityId:n}){let r=Hr(e,{...t,reader:`contents`}),[i,a]=(0,f.useState)(),o=r.page;return(0,$.jsxs)(`section`,{"aria-label":`Retained content fields`,children:[(0,$.jsx)(Zr,{pager:r}),n&&(0,$.jsxs)(`p`,{children:[`Showing matches for entity `,(0,$.jsx)(`code`,{children:n}),` on this page only. Continue paging for other fields/versions.`]}),o&&!(`kind`in o)&&o.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,$.jsxs)(`p`,{className:`omission`,children:[`Omitted source block:`,` `,(0,$.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`p`,{children:[e.owner.entity.kind,` `,(0,$.jsx)(`code`,{children:e.owner.entity.id}),` `,`· `,e.content.field,` · `,e.content.bytes,` retained bytes`]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,$.jsx)(Ur,{value:e.coverage}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{o.request.scope.kind!==`workspace`&&o.request.snapshotSeq!==null&&a(Br(o.request.storeId,o.request.scope,o.request.snapshotSeq,e.content))},children:`Inspect complete retained field`})]},`${e.content.recordId}:${e.content.version}`)),i&&(0,$.jsx)(Xr,{client:e,cursor:i},`${i.recordId}:${i.recordVersion}`)]})}function $r({client:e,seed:t}){return(0,$.jsx)(ei,{client:e,seed:t},G(t))}function ei({client:e,seed:t}){let[n,r]=(0,f.useState)(t),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,r=new AbortController;return l(!0),(n.kind===`message`?e.message(n,r.signal):n.kind===`tool`?e.tool(n,r.signal):e.task(n,r.signal)).then(e=>{t&&(l(!1),e.kind===`error`?s(e.error.code):(a(e.value),s(void 0)))}).catch(()=>{t&&(s(`Read unavailable.`),l(!1))}),()=>{t=!1,r.abort()}},[e,n]),(0,$.jsxs)(`section`,{"aria-label":`Exact entity metadata`,children:[c&&(0,$.jsx)(`p`,{children:`Reading exact entity version…`}),o&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Entity refused: `,o]}),i&&`kind`in i&&(0,$.jsx)(Ur,{value:i.coverage}),i&&(`kind`in i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Entity validation in progress, not missing.`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>r(i.next),children:`Continue exact entity validation`})]}):(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Exact stored owner and associations`}),(0,$.jsx)(`pre`,{children:JSON.stringify(i.record,null,2)})]}))]})}function ti(e){let t=tr(`download`,yn(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=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 ni({request:e,onClose:t}){let[n]=(0,f.useState)(e),[r,i]=(0,f.useState)(e.format),[a,o]=(0,f.useState)(``);return(0,$.jsxs)(hr,{title:`Export retained history`,onClose:t,children:[(0,$.jsxs)(`p`,{children:[`Selected `,n.scope.kind,`: `,n.scope.id,` · snapshot`,` `,n.snapshotSeq]}),(0,$.jsxs)(`label`,{children:[`Format`,(0,$.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,$.jsx)(`option`,{value:`ndjson`,children:`NDJSON public archive`}),(0,$.jsx)(`option`,{value:`markdown`,children:`Readable Markdown with footer metadata`})]})]}),(0,$.jsx)(`p`,{children:`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`}),(0,$.jsx)(`p`,{children:`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{try{ti({...n,format:r}),o(`Download requested — completion not verified by this browser UI.`)}catch{o(`Download unavailable; no archive claimed complete.`)}},children:`Request selected-scope download`}),(0,$.jsx)(`p`,{role:`status`,children:a})]})}function ri(e,t){if(!t||N(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Y({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ii(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 ai({client:e,seed:t,onClose:n,onHit:r}){let[i]=(0,f.useState)(t),a=(0,f.useRef)(null),o=(0,f.useRef)(0),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(0),[d,p]=(0,f.useState)(),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(),v=(0,f.useRef)(null),y=(0,f.useCallback)(async(t,n)=>{v.current?.abort();let r=new AbortController;v.current=r,h(!0),_(void 0);try{let i=await e.search(t,r.signal);if(o.current!==n||r.signal.aborted)return;i.kind===`error`?_(i.error.code):(p(i.value),u(0))}catch{o.current===n&&!r.signal.aborted&&_(`Search unavailable or invalid; no automatic retry.`)}finally{o.current===n&&!r.signal.aborted&&h(!1)}},[e]);return(0,f.useEffect)(()=>(a.current?.focus(),()=>{o.current++,v.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++o.current;if(v.current?.abort(),h(!1),p(void 0),u(0),_(void 0),!s)return;let t;try{t=ri(i,s)}catch{_(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void y(t,e),300);return()=>{clearTimeout(n),o.current++,v.current?.abort()}},[s,i,y]),(0,$.jsx)(hr,{title:`Search retained history`,onClose:n,children:(0,$.jsxs)(`div`,{className:`gs-modal`,children:[(0,$.jsxs)(`div`,{className:`gs-input-row`,children:[(0,$.jsx)(oe,{}),(0,$.jsx)(`input`,{ref:a,"aria-label":`Case-sensitive literal query`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),u(e=>Math.max(0,Math.min(e+1,(d?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),u(e=>Math.max(e-1,0))),e.key===`Enter`&&d?.hits[l]&&(e.preventDefault(),r(d.hits[l]),n())}})]}),(0,$.jsxs)(`p`,{children:[`Case-sensitive literal UTF-8 search. Scope `,i.scope.kind,` `,i.scope.id,`; snapshot `,i.snapshotSeq,`. No regex, provider request or history repair.`]}),(0,$.jsxs)(`div`,{className:`gs-results`,children:[m&&(0,$.jsx)(`p`,{role:`status`,children:`Searching bounded retained range…`}),g&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Search refused: `,g]}),!s&&(0,$.jsx)(`p`,{children:`Enter a query to search this selected scope.`}),d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ur,{value:d.coverage}),(0,$.jsxs)(`div`,{className:`gs-section`,children:[(0,$.jsxs)(`div`,{className:`gs-section-head`,children:[`Matches on this page: `,d.hits.length]}),d.hits.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`gs-item ${l===t?`active`:``}`,onMouseEnter:()=>u(t),onClick:()=>{r(e),n()},children:[(0,$.jsxs)(`span`,{className:`gs-item-title`,children:[e.owner.entity.kind,` · `,e.content.field,` · v`,e.content.version]}),(0,$.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,$.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` / bytes `,e.range.start,`–`,e.range.end]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),d.hits.length===0&&(0,$.jsx)(`p`,{children:ii(d)})]}),(0,$.jsx)(`button`,{type:`button`,disabled:m||!d.next,onClick:()=>{d.next&&y(d.next,++o.current)},children:`Continue same snapshot search`})]})]}),(0,$.jsx)(`footer`,{className:`gs-foot`,children:`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`})]})})}function oi({run:e,historical:t=!1}){return(0,$.jsxs)(`article`,{className:`run-summary`,children:[(0,$.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,t?`historical projection`:`owner projection`]}),(0,$.jsx)(`p`,{children:(0,$.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Lifecycle`}),(0,$.jsx)(`dd`,{children:e.lifecycle}),(0,$.jsx)(`dt`,{children:`Execution`}),(0,$.jsx)(`dd`,{children:e.outcome??`unsettled`}),(0,$.jsx)(`dt`,{children:`Wait/block reason`}),(0,$.jsx)(`dd`,{children:e.reason??`none reported`}),(0,$.jsx)(`dt`,{children:`Summary publication`}),(0,$.jsx)(`dd`,{children:e.publication})]}),(0,$.jsx)(Ur,{value:e.coverage}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Native / recording / parent settlement facts (independent of human review)`}),(0,$.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):`No settlement recorded`})]})]})}function si({client:e,seed:t}){return(0,$.jsx)(ci,{client:e,seed:t},G(t))}function ci({client:e,seed:t}){let[n,r]=(0,f.useState)(t),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,r=new AbortController;return l(!0),e.graph(n,r.signal).then(e=>{t&&(l(!1),e.kind===`error`?s(e.error.code):(a(e.value),s(void 0)))}).catch(()=>{t&&(s(`Read unavailable.`),l(!1))}),()=>{t=!1,r.abort()}},[e,n]),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Immutable admitted graph`}),o&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Graph refused: `,o]}),c&&(0,$.jsx)(`p`,{children:`Reading graph…`}),i&&`kind`in i&&(0,$.jsx)(Ur,{value:i.coverage}),i&&(`kind`in i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Graph validation in progress; not an empty graph.`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>r(i.next),children:`Continue graph validation`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xr,{client:e,cursor:Br(i.request.storeId,i.request.scope,i.request.snapshotSeq,i.graph.plan)}),i.graph.assignments.map(e=>(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function li({client:e,seed:t,onScope:n}){let r=Hr(e,{...t,reader:`runs`}),i=r.page,[a,o]=(0,f.useState)();return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(Zr,{pager:r}),i&&!(`kind`in i)&&i.records.map(e=>e.kind===`run`?(0,$.jsxs)(`article`,{children:[(0,$.jsx)(oi,{run:e.projection,historical:!0}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:`Open retained episode/child details`}),e.projection.admission.graph&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i.request.scope.kind!==`workspace`&&i.request.snapshotSeq!==null&&e.projection.admission.graph&&o({storeId:i.request.storeId,scope:i.request.scope,snapshotSeq:i.request.snapshotSeq,graph:e.projection.admission.graph})},children:`Inspect admitted graph and plan`})]},e.projection.childRunId??e.projection.runId):null),a&&(0,$.jsx)(si,{client:e,seed:a},a.graph.recordId)]})}function ui({onOpen:e,disabled:t}){return(0,$.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":`Search all retained pages in selected scope`,"data-tip":`Search all retained pages in selected scope`,disabled:t,onClick:e,children:(0,$.jsx)(oe,{"aria-hidden":`true`})})}function di(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 fi(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 pi(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)??mi(n.role,n.customType)}return r}function mi(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 hi(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var gi=(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,$.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,$.jsx)(`div`,{ref:s,children:o})}):(0,$.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),_i=(0,f.memo)(function({message:e,client:t,seed:n}){let[r,i]=(0,f.useState)(!1);return(0,$.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,$.jsxs)(`header`,{className:`msg-meta`,children:[(0,$.jsx)(`strong`,{className:`msg-role`,children:e.role}),(0,$.jsxs)(`span`,{className:`msg-state`,children:[e.state,` message record, not execution outcome`]}),(0,$.jsxs)(`span`,{className:`msg-time`,children:[`v`,e.version]}),(0,$.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[r?(0,$.jsx)(Te,{"aria-hidden":`true`}):(0,$.jsx)(ye,{"aria-hidden":`true`}),r?`Collapse`:`Inspect message`]})]}),(0,$.jsxs)(`div`,{className:`msg-body`,children:[(0,$.jsxs)(`p`,{className:`msg-ident`,children:[`Child `,e.owner.childRunId,` · message `,e.owner.entity.id,` · version `,e.version]}),e.role===`tool-result`&&(0,$.jsxs)(`p`,{className:`msg-note`,children:[`Result call: `,e.resultCallId??`unassociated / orphan`,`. Kept visible independently of the tool card.`]}),r&&(0,$.jsx)(`div`,{className:`msg-text`,children:(0,$.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,$.jsx)(Xr,{client:t,cursor:Br(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,$.jsx)(`p`,{children:`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`All message blocks, source limits and tool associations`}),(0,$.jsx)(Qr,{client:t,seed:n,entityId:e.owner.entity.id})]})]})})]})]})});function vi({messages:e,client:t,seed:n}){let r=(0,f.useRef)(null),i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(()=>new Set),s=(0,f.useRef)(a);s.current=a;let c=(0,f.useRef)(new Map),l=(0,f.useRef)(new Map),u=(0,f.useRef)(new Map),d=(0,f.useRef)(0),p=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,message:e})),[e]),m=(0,f.useRef)(new Map);m.current=new Map(p.map(e=>[e.id,e.message.version]));let h=(0,f.useRef)(new Set);h.current=pi(p,c.current,1800);let g=(0,f.useCallback)((e,t)=>{let n=m.current.get(e);n!==void 0&&(l.current.set(e,{h:t,len:n}),c.current.set(e,t))},[]),_=(0,f.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect(),n=[];for(let[e,t]of u.current){let r=t.getBoundingClientRect();n.push({id:e,top:r.top,bottom:r.bottom}),s.current.has(e)||g(e,r.height)}let i=di(n,{top:t.top-1200,bottom:t.bottom+1200},h.current,s.current,{top:t.top-2400,bottom:t.bottom+2400});for(let e of i.hide){let t=u.current.get(e);t&&g(e,t.offsetHeight)}o(e=>fi(e,i))},[g]),v=(0,f.useCallback)(()=>{d.current||=requestAnimationFrame(()=>{d.current=0,_()})},[_]);return(0,f.useLayoutEffect)(()=>{p.length?_():o(new Set)},[_,p]),(0,f.useEffect)(()=>{let e=new ResizeObserver(v);return r.current&&e.observe(r.current),()=>{e.disconnect(),cancelAnimationFrame(d.current)}},[v]),(0,$.jsxs)(`div`,{className:`messages-wrap`,children:[(0,$.jsx)(`div`,{className:`messages`,ref:r,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,v()},children:p.map(({id:e,role:i,message:o})=>(0,$.jsx)(gi,{id:e,show:!a.has(e),height:hi(e,o.version,l.current,i===`user`?100:280),containerRef:r,onMeasured:g,lazyRef:t=>{t?u.current.set(e,t):u.current.delete(e)},children:(0,$.jsx)(_i,{message:o,client:t,seed:n})},e))}),(0,$.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight,i.current=!0)},children:[(0,$.jsx)(je,{"aria-hidden":`true`}),`Latest on loaded page`]})]})}function yi({client:e,seed:t}){let n=Hr(e,{...t,reader:`messages`}),r=n.page;return(0,$.jsxs)(`section`,{className:`transcript`,children:[(0,$.jsx)(Zr,{pager:n}),r&&!(`kind`in r)&&(0,$.jsxs)($.Fragment,{children:[r.records.length===0&&(0,$.jsxs)(`p`,{className:`empty-note panel-empty`,children:[`No message records on this page`,r.next?`; more history remains.`:`.`]}),(0,$.jsx)(vi,{messages:r.records.filter(e=>e.kind===`message`),client:e,seed:r.request},`${r.request.snapshotSeq}:${r.request.after?.recordId??`first`}`)]})]})}function bi({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,$.jsxs)(`div`,{className:`chead ${n}`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,$.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,$.jsx)(De,{}):(0,$.jsx)(Ee,{})}):c,(0,$.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,$.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var xi=(0,f.memo)(function({record:e,client:t,seed:n}){let[r,i]=(0,f.useState)(!1),a=e.result?e.result.isError?`SDK tool error observed`:`SDK tool end observed`:e.startObserved?`Start observed; end not observed in this snapshot`:`No start observed`,o=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,$.jsxs)(`div`,{className:`toolcall${o===`err`?` err`:``}`,children:[(0,$.jsx)(bi,{open:r,onToggle:()=>i(e=>!e),headClassName:`toolcall-head`,titleText:`Inspect recorded tool call`,icon:(0,$.jsx)(re,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`toolcall-path`,children:[`Child `,e.owner.childRunId,` · call `,e.owner.entity.id,` · v`,e.version]}),(0,$.jsx)(`span`,{className:`toolcall-badge ${o}`,children:a})]}),children:e.name}),r&&(0,$.jsxs)(`div`,{className:`toolcall-body`,children:[(0,$.jsx)(`p`,{children:`SDK tool observations are not native process launch/close or passing parent checks.`}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Source ID`}),(0,$.jsxs)(`dd`,{children:[e.source.disposition,`:`,` `,e.source.value??`unavailable`]}),(0,$.jsx)(`dt`,{children:`Declaration`}),(0,$.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${e.declarationStage})`:`No declaration recorded; orphan result remains accessible`})]}),(0,$.jsxs)(`div`,{className:`toolcall-output`,children:[(0,$.jsx)(`div`,{className:`toolcall-output-label`,children:`Recorded tool end (not parsed from output)`}),(0,$.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):`No end fact in this snapshot.`})]}),(0,$.jsx)(`div`,{className:`toolcall-args`,children:(0,$.jsx)(Qr,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})});function Si({draft:e,onChange:t,context:n,roles:r,onSave:i,onGenerate:a,onStart:o,canSave:s,canAct:c}){let[l,u]=(0,f.useState)(!0),[d,p]=(0,f.useState)(null),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(`research`),[b,x]=(0,f.useState)([]),[S,ee]=(0,f.useState)(``),[C,w]=(0,f.useState)(``),T=e.assignments,E=e=>{p(e.id),h(e.instructions),_(e.expectedOutput),y(e.purpose),x(e.dependencies),w(``)},te=()=>{p(null),h(``),_(``),w(``)},D=n=>{let i=r?.find(e=>e.role===qe(v));i?(t({...e,assignments:T.map(e=>e.id===n?{...e,purpose:v,instructions:m,expectedOutput:g,dependencies:b,role:i}:e)}),te()):w(cr)},re=()=>{let i=r?.find(e=>e.role===qe(`research`));if(!i){w(cr);return}let a=1;for(;T.some(e=>e.id===`assignment-${a}`);)a++;let o={id:`assignment-${a}`,purpose:`research`,instructions:``,expectedOutput:``,dependencies:[],role:i,model:n.model};t({...e,assignments:[...T,o]}),E(o)},ie=n=>{T.some(e=>e.dependencies.some(e=>e.source.kind===`current`&&e.source.assignmentId===n))?w(`Remove dependent edges explicitly before deleting this assignment.`):t({...e,assignments:T.filter(e=>e.id!==n)})};return(0,$.jsxs)(`section`,{className:`plan-board ${l?``:`plan-board-collapsed`}`,children:[(0,$.jsx)(`div`,{className:`plan-board-head`,children:(0,$.jsxs)(`button`,{type:`button`,className:`plan-board-head-main`,"aria-expanded":l,onClick:()=>u(!l),children:[(0,$.jsx)(fe,{}),(0,$.jsx)(`span`,{children:`Readable plan & decomposition`}),(0,$.jsxs)(`span`,{children:[T.length,` required assignments`]}),l?(0,$.jsx)(Te,{}):(0,$.jsx)(De,{})]})}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!c||n.task?.kind!==`code`,onClick:a,children:`Preview readonly Generate proposal`}),(0,$.jsx)(`button`,{type:`button`,disabled:!s,onClick:i,children:`Preview Save plan`}),(0,$.jsx)(`button`,{type:`button`,className:`primary`,disabled:!c,onClick:o,children:`Preview Start saved graph`})]}),(0,$.jsx)(`p`,{children:`Draft changes never execute. Start uses the saved graph shown in its fresh preview, not unsaved text. Generated proposals never save or start themselves.`}),T.some(e=>G(e.model)!==G(n.model))&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{children:`Saved assignments name an old model selection. Reading does not rebind them.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t({...e,assignments:T.map(e=>({...e,model:n.model}))}),children:`Explicitly rebind draft to current model (requires new Save)`})]}),!r&&(0,$.jsx)(`p`,{role:`status`,children:`Current plan metadata unavailable. Observe again; historical text is not action authority.`}),C&&(0,$.jsx)(`p`,{role:`alert`,children:C}),l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{children:[`Readable plan`,(0,$.jsx)(`textarea`,{"aria-label":`Readable plan`,value:e.readablePlan,onChange:n=>t({...e,readablePlan:n.target.value}),rows:8})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Read rendered plan`}),(0,$.jsx)(Ar,{text:e.readablePlan})]}),(0,$.jsx)(wr,{text:e.readablePlan}),(0,$.jsx)(`ol`,{className:`plan-board-steps`,children:T.map(e=>(0,$.jsxs)(`li`,{className:`plan-board-step`,children:[(0,$.jsxs)(`div`,{className:`plan-step-head`,children:[(0,$.jsx)(`strong`,{children:e.id}),(0,$.jsxs)(`span`,{children:[e.purpose,` —`,` `,e.purpose===`edit`?`checkout writer`:`readonly`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e),children:[(0,$.jsx)(be,{}),` Edit`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ie(e.id),children:[(0,$.jsx)(ne,{}),` Remove draft assignment`]})]}),d===e.id?(0,$.jsxs)(`div`,{className:`plan-step-edit`,children:[(0,$.jsxs)(`label`,{children:[`Purpose`,(0,$.jsx)(`select`,{value:v,onChange:e=>{let t=e.target.value;(t===`research`||t===`diagnosis`||t===`review`||t===`edit`&&n.task?.kind===`code`)&&y(t)},children:[`research`,`diagnosis`,`review`,`edit`].filter(e=>e!==`edit`||n.task?.kind===`code`).map(e=>(0,$.jsx)(`option`,{children:e},e))})]}),(0,$.jsxs)(`label`,{children:[`Instructions`,(0,$.jsx)(`textarea`,{"aria-label":`Instructions`,value:m,onChange:e=>h(e.target.value),rows:5})]}),(0,$.jsxs)(`label`,{children:[`Expected output`,(0,$.jsx)(`textarea`,{"aria-label":`Expected output`,value:g,onChange:e=>_(e.target.value),rows:3})]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsx)(`legend`,{children:`Current-episode dependencies (whole final text by default)`}),T.filter(t=>t.id!==e.id).map(e=>{let t=b.findIndex(t=>t.source.kind===`current`&&t.source.assignmentId===e.id);return(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t>=0,onChange:t=>x(n=>t.target.checked?[...n,{source:{kind:`current`,assignmentId:e.id},range:null,requireCompleteObservation:!1}]:n.filter(t=>t.source.kind!==`current`||t.source.assignmentId!==e.id))}),e.id]},e.id)})]}),b.map((e,t)=>(0,$.jsxs)(`div`,{className:`dependency-editor`,children:[(0,$.jsx)(`code`,{children:JSON.stringify(e.source)}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.requireCompleteObservation,onChange:e=>x(n=>n.map((n,r)=>t===r?{...n,requireCompleteObservation:e.target.checked}:n))}),`Require complete observation`]}),(0,$.jsxs)(`p`,{children:[`Selection:`,` `,e.range?`reviewed UTF-8 bytes ${e.range.start}–${e.range.end}`:`whole final text; no silent clipping`]}),(0,$.jsxs)(`label`,{children:[`Reviewed edge JSON (range/null and exact historical identity)`,(0,$.jsx)(`textarea`,{defaultValue:JSON.stringify(e),onBlur:e=>{try{let n=Ye(Le(e.target.value));x(e=>e.map((e,r)=>t===r?n:e)),w(``)}catch{w(`Invalid dependency. Original edge retained; review before Save.`)}}})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(e=>e.filter((e,n)=>t!==n)),children:`Remove edge`})]},e.source.kind===`current`?e.source.assignmentId:e.source.childRunId)),(0,$.jsxs)(`label`,{children:[`Explicit historical/advisory edge JSON`,(0,$.jsx)(`textarea`,{value:S,onChange:e=>ee(e.target.value),placeholder:`Exact committed run/child/result/version plus range and coverage requirement`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{try{let e=Ye(Le(S));if(e.source.kind!==`historical`)throw Error();x(t=>[...t,e]),ee(``),w(``)}catch{w(`Historical edge requires actual committed identity; no guessed result reference.`)}},children:`Add reviewed historical edge`}),(0,$.jsx)(`button`,{type:`button`,onClick:te,children:`Discard inline edits`}),(0,$.jsx)(`button`,{type:`button`,disabled:!!C,onClick:()=>D(e.id),children:`Apply to local draft`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsxs)(`p`,{children:[`Role `,e.role.role,` / `,(0,$.jsx)(`code`,{children:e.role.sha256})]}),(0,$.jsxs)(`p`,{children:[e.model.provider,`/`,e.model.model,` ·`,` `,e.model.thinking]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.dependencies,null,2)})]})]},e.id))}),(0,$.jsxs)(`button`,{type:`button`,disabled:!r||T.length>=16,onClick:re,children:[(0,$.jsx)(ce,{}),` Add assignment`]})]})]})}var Ci=`未命名章节`;function wi(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Ti(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=wi(r||Ci),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Ci}})}function Ei(e){return e.length>=2}function Di(e){let t=0,n=0;return e.split(`
3
+ `)}if(new TextEncoder().encode(o).length>k.controlBytes)throw new A(`oversize`)}if(n){if(o)throw new A(`invalid`);break}}}finally{await i.cancel().catch(()=>{}),i.releaseLock()}}subscribe(e,t,n){let r=lt(e);if(!this.attachment||!this.options.socket)throw new A(`unavailable`);let i=this.options.socket(`${this.origin.replace(/^http/,`ws`)}${qn}?attachment=${this.attachment}`),a=!1,o=!1,s=Date.now(),c=Date.now(),l=()=>{if(!o){o=!0,a=!1,clearInterval(d);try{i.close()}catch{}u(`closed`)}},u=e=>{try{n(e)}catch{}},d=setInterval(()=>{if(a){Date.now()-s>=k.staleMs&&u(`stale`);try{Date.now()-c>=k.reconcileMs?(i.send(G({kind:`resync`,scope:r})),c=Date.now()):i.send(`{"kind":"ping"}`)}catch{l()}}},k.heartbeatMs);return i.addEventListener(`open`,()=>{if(!o){a=!0;try{i.send(G({kind:`subscribe`,scope:r}))}catch{l()}}}),i.addEventListener(`message`,e=>{if(!o)try{if(typeof e.data!=`string`)throw new A(`invalid`);let n=nr(Le(e.data,k.viewerBytes));s=Date.now(),u(`current`),t(n)}catch{l()}}),i.addEventListener(`error`,l),i.addEventListener(`close`,l),l}};async function ir(e,t){if(!e.body)throw new A(`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 A(`oversize`);a+=r.decode(e,{stream:!0})}}finally{await n.cancel().catch(()=>{}),n.releaseLock()}}var ar={sourceHash:`b35385d2798537203cc68b5993d893bdb77b1140df35bb11b1251187c5e68236`,contractHash:`ff017feffc6b6b4521e470d82514d0ca008e15472fa1442ec498b243b0f7cf87`,buildId:`357c2882237d27e66e1dcec38c95f7c3d578ecdfce90b74db8ad50c9ef70c5ee`};function or(){let e=new rr({origin:window.location.origin,...ar?{build:{kind:`browser`,...ar}}:{},socket:e=>new WebSocket(e)});return{client:new Wn(e),transport:e}}async function sr(e,t,n,r){let i=Fn(e);if(i.context.status!==`available`||!i.context.version.task||!i.readablePlan?.editable||i.savedGraph.status===`unavailable`)throw new A(`unavailable`);let a=i.context.version,o=a.task;if(!o)throw new A(`stale`);let s=M(t,32768),c=et({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 A(`invalid`);for(let e of c.graph.assignments){let t=i.roles.find(t=>t.role===qe(e.purpose));if(!t||G(t)!==G(e.role)||G(a.model)!==G(e.model))throw new A(`stale`)}c.graph.plan.sha256=await r.sha256(new TextEncoder().encode(s));let l=et(c);if(l.kind!==`save-plan`)throw new A(`invalid`);return l}var cr=`Current plan metadata unavailable. Observe again; historical text is not action authority.`;function lr(e,t){let n=async n=>{let r=await e.current({storeId:t,taskId:n.task?.id??null});if(r.kind===`error`)throw new A(r.error.code);if(r.value.context.status!==`available`||G(r.value.context.version)!==G(n))throw new A(`stale`);return r.value},r=e=>({kind:`error`,error:Fe(e instanceof A?e.code:`unavailable`)});return{async read(t,i){try{let r=await n(t);if(!r.readablePlan||r.savedGraph.status===`unavailable`)throw new A(`unavailable`);let a=null;if(r.savedGraph.status===`saved`){let o=r.savedGraph.request;if(i&&(i.storeId!==o.storeId||G(i.graph)!==G(o.graph)||G(i.scope)!==G(o.scope)))throw new A(`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 A(`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 sr(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 ur(e,t){if(e.commandId!==t.commandId)return e;let n=[e.receipt,e.lookup?.status===`found`?e.lookup.receipt:void 0,t.receipt,t.lookup?.status===`found`?t.lookup.receipt:void 0],r,i=!1;for(let t of n)t&&t.commandId===e.commandId&&(r&&(r.operationId!==t.operationId||r.runId!==t.runId||r.created!==null&&r.created.taskId!==t.created?.taskId)||r&&W(t.committedSeq,r.committedSeq)>0&&(r.created?.state===`published`&&t.created?.state!==`published`||r.admission===`accepted`&&t.admission!==`accepted`||r.execution!==null&&t.execution!==r.execution||r.settlement!==null&&G(t.settlement)!==G(r.settlement))?i=!0:(!r||W(t.committedSeq,r.committedSeq)>0||G(r)===G(t))&&(r=t));return{commandId:e.commandId,receipt:r,lookup:r?{status:`found`,receipt:r}:t.lookup??e.lookup,error:i?`Conflicting receipt observation refused; prior committed facts preserved.`:r?void 0:t.error??e.error}}var dr=e=>e===`unauthenticated`||e===`forbidden`,fr=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 Gn,l=0,u=0,d=!1,f=!1,p=0,m=!1,h=!1,g={actions:!1,transportStatus:`closed`,attachmentVersion:0},_=()=>!r&&n===this.version,v=()=>{_()&&t({...g,observation:c.state})},y=()=>{r||(r=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),n===this.version&&(this.pollCurrent=void 0))};this.stopCurrent=y;let b=e=>{this.serial=this.serial.then(e).catch(()=>{_()&&(m=!0,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),g.error=`Observation unavailable or detach unconfirmed; explicit re-entry required.`,g.actions=!1,g.transportStatus=`closed`,g.workspace=void 0,c=new Gn,v())})},x=async()=>{await this.api.transport.detach()},S=async(t=!1)=>{if(!_()||!f||d||m)return;d=!0,g.actions=!1;let n=!1;v(),p=Date.now();let r=s.signal;try{let i=async()=>{let e=await this.api.client.session(r);return!_()||r.aborted?!1:e.kind===`error`?(g.actions=!1,g.error=e.error.code,dr(e.error.code)&&ee(),!1):(C(e.value),!0)};if(t&&!await i())return;e||(g.transportStatus=`current`);let a=await this.api.client.activeRuns(r);if(!_()||r.aborted)return;if(a.kind===`ok`)g.activeRuns=a.value;else if(dr(a.error.code)){ee();return}else g.activeRuns=void 0;v();let o=await this.api.client.workspace(r);if(!_()||r.aborted)return;if(o.kind===`error`){g.error=o.error.code,dr(o.error.code)&&ee();return}if(!t&&G(g.workspace?.models??[])!==G(o.value.models)&&!await i())return;if(g.workspace=o.value,e){let t=c.beginSnapshot(),i=await this.api.client.snapshot(e,r);if(!_()||r.aborted)return;if(i.kind===`error`)g.error=i.error.code,dr(i.error.code)&&ee();else{let e=c.install(i.value,Date.now(),t);e!==void 0&&(l=e),g.error=void 0,n=!0}}else g.error=void 0,n=!0}catch{_()&&(g.error=`Observation unavailable.`,g.actions=!1,g.transportStatus=`stale`)}finally{d=!1,g.actions=n&&h,v()}},ee=()=>{m=!0,g.actions=!1,g.transportStatus=`closed`,g.error=`Access revoked; explicit token re-entry required.`,g.workspace=void 0,g.activeRuns=void 0,c=new Gn,s.abort(),clearInterval(a),clearTimeout(o),u++,i?.(),b(x),v()},C=e=>{let t=ar?{kind:`browser`,...ar}:null;g.compatible=Pt(e.build,t),g.cancelCompatible=Pt(e.build,t,!0),h=e.capabilities.actions&&g.compatible},w=async()=>{if(f=!1,await x(),!_()||m)return;let t=await this.api.client.session();if(!_()||m){await x();return}if(t.kind===`error`){m=!0,g.error=`${t.error.code}; explicit re-entry required.`,g.workspace=void 0,c=new Gn,g.actions=!1,v();return}if(f=!0,s=new AbortController,c=new Gn,g={actions:t.value.capabilities.actions,transportStatus:`closed`,attachmentVersion:g.attachmentVersion+1},C(t.value),v(),await S(),!_()||m||!e)return;let n=++u;i=this.api.transport.subscribe(e,e=>{if(_()&&!m&&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`&&S():S();v()}},e=>{_()&&!m&&n===u&&(g.transportStatus=e,e===`closed`&&(f=!1,g.actions=!1,g.attachmentVersion++,s.abort(),u++,o=setTimeout(()=>b(w),1e3)),v())})};return b(w),this.pollCurrent=e=>{S(e)},a=setInterval(()=>{_()&&!m&&(c.tick(Date.now()),v(),(Date.now()-p>=3e4||e&&c.needsPoll(Date.now()))&&S())},1e3),()=>{_()&&(y(),b(x))}}};function pr(e,t,n){let r=(0,f.useMemo)(()=>new fr(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 mr=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}},$=r();function hr({title:e,children:t,onClose:n}){let r=(0,f.useRef)(null),i=(0,f.useId)(),a=(0,f.useRef)(n);return a.current=n,(0,f.useEffect)(()=>{let e=document.activeElement,t=r.current;return t?.showModal(),()=>{t?.close(),e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,$.jsxs)(`dialog`,{ref:r,className:`action-dialog`,"aria-labelledby":i,onCancel:e=>{e.preventDefault(),a.current()},children:[(0,$.jsxs)(`header`,{children:[(0,$.jsx)(`h2`,{id:i,children:e}),(0,$.jsx)(`button`,{type:`button`,className:`dialog-close`,"aria-label":`Close dialog — no cancellation of accepted work`,title:`Close — accepted work is not cancelled`,onClick:n,children:(0,$.jsx)(te,{"aria-hidden":`true`})})]}),t]})}function gr(e){let t=e=>{if(typeof e==`string`||typeof e==`number`){let t=String(e);return t===``?[[]]:t.split(`
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 _r=function(){let e=this.data();e.micromarkExtensions??=[],e.micromarkExtensions.push({flow:{92:vr(!0)},text:{92:vr(!1)}});let t={enter:{backslashMathInline:yr,backslashMathDisplay:yr,backslashMathBlock:yr},exit:{backslashMathInline:br,backslashMathDisplay:br,backslashMathBlock:br}};e.fromMarkdownExtensions??=[],e.fromMarkdownExtensions.push(t)};function vr(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 yr=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)},br=function(e){this.exit(e)};function xr(e){if(typeof document>`u`)return!1;let t=document.createElement(`textarea`),n=document.activeElement;try{return t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,t.setAttribute(`readonly`,``),document.body.appendChild(t),t.select(),document.execCommand(`copy`)}catch{return!1}finally{t.remove(),n instanceof HTMLElement&&n.isConnected&&n.focus()}}async function Sr(e){if(typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(e),!0}catch{return xr(e)}return xr(e)}function Cr(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 Sr(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 wr=(0,f.memo)(function({text:e}){let[t,n]=(0,f.useState)(!1),{copied:r,copy:i}=Cr();return(0,$.jsxs)(`button`,{type:`button`,className:`copy-btn`,title:`Copy displayed text`,"aria-label":`Copy displayed text`,onClick:()=>{n(!1),i(e).then(e=>n(!e))},children:[r?(0,$.jsx)(Oe,{}):(0,$.jsx)(Ce,{}),t&&`Copy unavailable`]})}),Tr=[s,d,_r],Er=[s,l,d,_r],Dr=[[c,{strict:!1,throwOnError:!1,trust:!1,maxExpand:1e3}],[u,{detect:!1,ignoreMissing:!0}]];function Or(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 kr({text:e,rawHtml:t=!1,hardBreaks:n=!1}){return(0,$.jsx)(a,{remarkPlugins:n?Er:Tr,rehypePlugins:t?[i,o,...Dr]:Dr,skipHtml:!t,disallowedElements:[`iframe`,`object`,`embed`,`script`,`style`,`video`,`audio`,`source`,`form`,`input`],components:{pre:Mr,a:jr,img:({alt:e})=>(0,$.jsxs)(`span`,{className:`omission`,children:[`[Image omitted: `,e||`external/media content`,`]`]})},children:e})}var Ar=(0,f.memo)(function(e){return(0,$.jsx)(`div`,{className:`md`,children:(0,$.jsx)(kr,{...e})})});function jr({href:e,children:t}){let n=e&&Or(e);return n?(0,$.jsx)(`a`,{href:n,target:n.startsWith(`#`)?void 0:`_blank`,rel:`noreferrer noopener`,referrerPolicy:`no-referrer`,children:t}):(0,$.jsxs)(`span`,{children:[t,` [link unavailable]`]})}function Mr({children:e,node:t,...n}){let r=e&&typeof e==`object`&&`props`in e?e.props?.children:e,i=0,a=gr(r).map(e=>{let t=`code-offset:${i}`;return i+=Nr(e).length+1,{key:t,nodes:e}}),o=a.length>1,s=o?`${String(a.length).length+1}ch`:void 0;return(0,$.jsxs)(`div`,{className:`codeblock`,children:[(0,$.jsx)(wr,{text:Nr(e)}),(0,$.jsx)(`pre`,{...n,children:a.map(({nodes:e,key:t},n)=>(0,$.jsxs)(`div`,{className:`code-line`,children:[o&&(0,$.jsx)(`span`,{className:`code-num`,style:s?{width:s}:void 0,children:n+1}),(0,$.jsx)(`code`,{className:`code-line-body hljs`,children:e})]},t))})]})}function Nr(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(Nr).join(``);if(e&&typeof e==`object`&&`props`in e){let t=e.props;return Nr(t?.children)}return``}function Pr({prepared:e,client:t,current:n,onClose:r,onResult:i,attachmentVersion:a}){let[o,s]=(0,f.useState)(Date.now()),[c,l]=(0,f.useState)(!1);(0,f.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let u=e.preflight,d=u.preview,p=(0,f.useRef)(a),m=(0,f.useRef)(!1);(!n||G(n)!==G(d.version)||o>=Date.parse(u.expiresAt)||p.current!==a)&&(m.current=!0);let h=m.current,g=async()=>{if(!(h||e.submitted)){l(!0),i({commandId:e.commandId,error:`Admission pending/unknown — observe this exact receipt.`});try{let n=await Un(t,e);i(n.kind===`ok`?{commandId:e.commandId,receipt:n.value}:{commandId:e.commandId,error:`${n.error.code}; effect ${n.error.effect}`})}catch{i({commandId:e.commandId,error:`Uncertain; do not repeat the action.`})}r()}};return(0,$.jsxs)(hr,{title:`Confirm ${d.action.kind}`,onClose:r,children:[(0,$.jsx)(`p`,{children:`Access is not consent. This confirmation applies only to the displayed context, once.`}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Checkout`}),(0,$.jsx)(`dd`,{children:d.rootLabel}),(0,$.jsx)(`dt`,{children:`Working directory`}),(0,$.jsx)(`dd`,{children:(0,$.jsx)(`code`,{children:d.cwdLabel})}),(0,$.jsx)(`dt`,{children:`Model / API / thinking`}),(0,$.jsxs)(`dd`,{children:[d.version.model.provider,` / `,d.version.model.model,` /`,` `,d.version.model.api,` / `,d.version.model.thinking]}),(0,$.jsx)(`dt`,{children:`Check environment`}),(0,$.jsxs)(`dd`,{children:[`Service launch environment policy, generation`,` `,d.version.checkEnvGeneration,`; no browser environment overlays.`]}),(0,$.jsx)(`dt`,{children:`Observation`}),(0,$.jsx)(`dd`,{children:d.version.observation.complete?`Complete within bounded scope`:`Incomplete bounded coverage`}),(0,$.jsx)(`dt`,{children:`Expires`}),(0,$.jsx)(`dd`,{children:u.expiresAt})]}),(0,$.jsx)(Fr,{preview:d}),d.action.kind===`check`&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Exact parent check`}),(0,$.jsx)(`pre`,{children:d.action.check.command}),(0,$.jsxs)(`p`,{children:[d.action.check.name,`; timeout`,` `,d.action.check.timeoutMs,` ms; cwd above.`]})]}),d.action.kind===`generate-plan`&&(0,$.jsx)(`p`,{children:`Readonly proposal only. It will not save itself or dispatch editing.`}),d.issues.length>0&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Issues: `,d.issues.join(`, `)]}),h&&(0,$.jsx)(`p`,{role:`alert`,children:`Context changed or confirmation expired. Close, observe again and request a new preview.`}),(0,$.jsxs)(`footer`,{children:[(0,$.jsx)(`button`,{type:`button`,onClick:r,children:`Back — no new effect`}),(0,$.jsxs)(`button`,{type:`button`,className:`primary`,disabled:h||c||e.submitted,onClick:()=>void g(),children:[`Confirm `,d.action.kind]})]})]})}function Fr({preview:e}){let t=e.action,n=t.kind===`save-plan`?t.graph:e.graph;return(0,$.jsxs)($.Fragment,{children:[t.kind===`create`&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`h3`,{children:[`Create `,t.taskKind,` task`]}),(0,$.jsx)(`pre`,{children:t.goal}),(0,$.jsx)(`p`,{children:`No Start is included.`})]}),t.kind!==`create`&&(0,$.jsx)(Ar,{text:t.kind===`save-plan`?t.plan:e.readablePlan}),n?.assignments.map(e=>(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`h3`,{children:[e.id,` · `,e.purpose]}),(0,$.jsxs)(`p`,{children:[e.role.role,` / `,e.role.sha256]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.model,null,2)}),(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.dependencies,null,2)})]},e.id)),t.kind===`save-plan`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{children:`Exact proposed graph and identities (not yet committed)`}),(0,$.jsx)(`pre`,{children:JSON.stringify(t.graph,null,2)})]}),t.kind===`review`&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Exact human review targets`}),(0,$.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),(0,$.jsxs)(`p`,{children:[`Human review only; failures, native exit, stale and not-run checks remain unchanged. Issues acknowledgment:`,` `,String(t.acceptIssues),`.`]})]})]})}function Ir({client:e,compatible:t,onClose:n,onChanged:r}){let[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(``),[c,l]=(0,f.useState)(``),[u,d]=(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`?a(e.value):l(e.error.code))}).catch(()=>{t.signal.aborted||l(`Model catalog unavailable.`)}),()=>t.abort()},[e]),(0,$.jsxs)(hr,{title:`Choose owner model`,onClose:n,children:[(0,$.jsx)(`p`,{children:`Explicit owner-wide choice, only while quiescent. This does not resolve credentials, probe a provider, save a plan or Start work.`}),(0,$.jsxs)(`p`,{children:[`Current:`,` `,i?.selected?`${i.selected.provider}/${i.selected.model} · ${i.selected.thinking}`:`No model selected`]}),(0,$.jsxs)(`label`,{children:[`Exact model / API / thinking`,(0,$.jsxs)(`select`,{value:o,onChange:e=>s(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select explicitly`}),i?.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,$.jsxs)(`option`,{value:n,children:[e.provider,`/`,e.model,` · `,e.api,` · `,t.level]},n)}))]})]}),i?.status===`capacity`&&(0,$.jsx)(`p`,{children:`Catalog capacity exceeded; no partial model list is selectable.`}),c&&(0,$.jsxs)(`p`,{role:`alert`,children:[c,`. No automatic replacement or retry.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!t||!i||!o||u,onClick:()=>{i&&(d(!0),e.chooseModel({expected:i.version,choice:We(JSON.parse(o))}).then(e=>{e.kind===`error`?l(e.error.code):(r(),n())}).catch(()=>l(`Choice response unconfirmed; observe catalog before another explicit choice.`)).finally(()=>d(!1)))},children:`Confirm owner model choice`})]})}function Lr({client:e,value:t,onChange:n}){let r=(0,f.useRef)(!0),i=(0,f.useRef)(null);(0,f.useEffect)(()=>(r.current=!0,()=>{r.current=!1,i.current?.abort()}),[]);let[a,o]=(0,f.useState)(!1),s=t.receipt??(t.lookup?.status===`found`?t.lookup.receipt:void 0);return(0,$.jsxs)(`section`,{className:`receipt`,"aria-label":`Command receipt`,children:[(0,$.jsx)(`h3`,{children:`Command receipt`}),(0,$.jsx)(`code`,{children:t.commandId}),t.error&&(0,$.jsx)(`p`,{role:`alert`,children:t.error}),s&&(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Admission`}),(0,$.jsx)(`dd`,{children:s.admission}),(0,$.jsx)(`dt`,{children:`Execution`}),(0,$.jsx)(`dd`,{children:s.execution??`not settled`}),(0,$.jsx)(`dt`,{children:`Publication`}),(0,$.jsx)(`dd`,{children:s.publication}),(0,$.jsx)(`dt`,{children:`Run`}),(0,$.jsx)(`dd`,{children:s.runId??`metadata action`})]}),t.lookup&&t.lookup.status!==`found`&&(0,$.jsxs)(`p`,{children:[t.lookup.status,`. This observation does not authorize replay.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>{o(!0),i.current=new AbortController,e.receipt(t.commandId,i.current.signal).then(e=>{r.current&&(n({commandId:t.commandId,lookup:e}),o(!1))})},children:`Observe exact receipt`})]})}function Rr(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 zr(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 Br(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 Vr(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=Rr(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 Hr(e,t){let n=t?G({reader:t.reader,storeId:t.storeId,scope:t.scope,limit:t.limit}):`absent`,[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(),[l,u]=(0,f.useState)(t),[d,p]=(0,f.useState)([]),m=(0,f.useRef)(0),[h,g]=(0,f.useState)(n);return h!==n&&(m.current++,g(n),i(void 0),c(void 0),u(t),p([])),(0,f.useEffect)(()=>{let t=++m.current;if(!l){o(!1);return}let n=new AbortController;return o(!0),c(void 0),zr(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 Ur({value:e}){return(0,$.jsxs)(`p`,{className:`coverage${e.observed===`complete`&&e.source===`complete`&&!e.redacted&&e.omissions.length===0?``:` partial`}`,children:[`Recording: `,e.observed,`; source: `,e.source,`;`,` `,e.redacted?`redacted`:`no reported redaction`,e.omissions.length>0&&`; omitted: ${e.omissions.join(`, `)}`,`. Not a guarantee of complete original source or universal secret detection.`]})}function Wr(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 Gr=new Map;function Kr(e,t){t.length?Gr.set(e,t):Gr.delete(e);let n=e.endsWith(`-active`);e=n?`cadence-page-active`:`cadence-page`,t=[...Gr].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 qr(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 Jr(e,t){let n=t.startContainer.parentElement;for(let r of qr(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 Yr({container:e,version:t}){let[n,r]=(0,f.useState)(``),[i,a]=(0,f.useState)(0),[o,s]=(0,f.useState)(0),c=(0,f.useRef)([]),l=`cadence-page-${(0,f.useId)().replace(/[^a-z0-9]/gi,``)}`;(0,f.useEffect)(()=>{if(!t)return;let r=e.current,i=r&&n?Wr(r,n):[];return c.current=i,s(i.length),a(0),Kr(l,i),()=>Kr(l,[])},[n,e,t,l]);let u=t=>{let n=o?(i+t+o)%o:0;a(n),e.current&&c.current[n]&&(Jr(e.current,c.current[n]),Kr(`${l}-active`,[c.current[n]]))};return(0,f.useEffect)(()=>()=>Kr(`${l}-active`,[]),[l]),(0,$.jsxs)(`div`,{className:`search-bar toolbar`,children:[(0,$.jsxs)(`label`,{children:[`Find on displayed field page`,(0,$.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),u(e.shiftKey?-1:1))}})]}),(0,$.jsxs)(`span`,{children:[o?i+1:0,`/`,o,o>=1e3?` (first 1000 visual highlights)`:``,`; not whole-history search`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>u(-1),children:`Previous match`}),(0,$.jsx)(`button`,{type:`button`,disabled:!o,onClick:()=>u(1),children:`Next match`})]})}function Xr({client:e,cursor:t,highlight:n,render:r}){let i=G(t),a=(0,f.useMemo)(()=>Y(JSON.parse(i)),[i]),[o,s]=(0,f.useState)(t),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)([]),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(),[_,v]=(0,f.useState)(`raw`),[y,b]=(0,f.useState)(``),x=(0,f.useRef)(null),S=(0,f.useRef)(null);(0,f.useEffect)(()=>(s(a),d([]),l(void 0),g(void 0),()=>x.current?.abort()),[a]),(0,f.useEffect)(()=>{let t=!0,n=new AbortController;return m(!0),g(void 0),e.detail(o,n.signal).then(e=>{t&&(m(!1),e.kind===`error`?g(e.error.code):l(e.value))}).catch(()=>{t&&(g(`Read unavailable.`),m(!1))}),()=>{t=!1,n.abort()}},[e,o]);let ee=async()=>{if(x.current)return;let n=new AbortController;x.current=n,b(`Reading all retained field pages…`);try{let r=await Vr(e,t,n.signal);if(n.signal.aborted)return;let i=await Sr(r.text);if(n.signal.aborted)return;b(i?r.recordingComplete?`Copied all retained field bytes (source omissions still apply).`:`Copied retained field bytes; recording is incomplete. No complete-source claim.`:`Clipboard unavailable.`)}catch{n.signal.aborted||b(`Full-field copy refused/incomplete.`)}finally{x.current===n&&(x.current=null)}},C=c&&!(`kind`in c)?c:void 0;return(0,$.jsxs)(`section`,{className:`detail-pane`,"aria-label":`Retained field`,children:[(0,$.jsxs)(`div`,{className:`detail-identity`,children:[(0,$.jsx)(`code`,{children:t.recordId}),` v`,t.recordVersion,` / `,t.field,` `,`/ snapshot `,t.snapshotSeq]}),n&&(0,$.jsxs)(`p`,{children:[`Exact hit bytes [`,n.start,`, `,n.end,`); only this immutable field is highlighted.`]}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>v(e=>e===`raw`?`markdown`:`raw`),children:_===`raw`?`Markdown page`:`Raw page`}),(0,$.jsx)(`button`,{type:`button`,disabled:!!x.current,onClick:()=>void ee(),children:`Copy full retained field`}),!!x.current&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{x.current?.abort(),x.current=null,b(`Copy canceled; execution unchanged.`)},children:`Cancel copy`})]}),(0,$.jsx)(`p`,{role:`status`,children:y}),h&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Detail refused: `,h]}),p&&(0,$.jsx)(`p`,{role:`status`,children:`Reading…`}),c&&(0,$.jsx)(Ur,{value:c.coverage}),c&&`kind`in c&&(0,$.jsx)(`p`,{children:`Validation in progress. The retained field is not empty.`}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Bytes `,C.range?.start??0,`–`,C.range?.end??0,` of`,` `,C.content.bytes,`.`,` `,C.next?`More retained data available.`:`End of field.`]}),(0,$.jsx)(Yr,{container:S,version:`${C.content.recordId}:${C.content.version}:${C.range?.start??0}:${_}`}),(0,$.jsx)(`div`,{ref:S,"data-retained-field":!0,children:r?r(C.text):_===`markdown`?(0,$.jsx)(Ar,{text:C.text}):(0,$.jsx)(`pre`,{className:`detail-text`,children:(()=>{if(!C||!n||!C.range)return C?.text;let e=Math.max(n.start,C.range.start)-C.range.start,t=Math.min(n.end,C.range.end)-C.range.start;if(t<=e)return C.text;let r=new TextEncoder().encode(C.text),i=(e,t)=>new TextDecoder(`utf-8`,{fatal:!0}).decode(r.subarray(e,t));return(0,$.jsxs)($.Fragment,{children:[i(0,e),(0,$.jsx)(`mark`,{children:i(e,t)}),i(t,r.length)]})})()})})]}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:p||!u.length,onClick:()=>{s(u[u.length-1]),d(e=>e.slice(0,-1))},children:`Previous`}),(0,$.jsx)(`button`,{type:`button`,disabled:p||!c?.next,onClick:()=>{c?.next&&(d(e=>[...e,o]),s(c.next))},children:c&&`kind`in c?`Continue validation`:`Next field page`})]})]})}function Zr({pager:e}){let{page:t,busy:n,error:r}=e;return(0,$.jsxs)(`div`,{className:`page-controls`,children:[r&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Read refused: `,r,`. Retained state has not been repaired.`]}),n&&(0,$.jsx)(`p`,{role:`status`,children:`Reading bounded history page…`}),t&&`kind`in t&&(0,$.jsxs)(`p`,{role:`status`,children:[t.kind===`snapshot`?`Snapshot selected`:`Validating retained history`,`; continue this exact read. No data page yet.`]}),t&&(0,$.jsx)(Ur,{value:t.coverage}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!e.canPrevious,onClick:e.previous,children:`Previous page`}),(0,$.jsx)(`button`,{type:`button`,disabled:n||!t?.next,onClick:e.more,children:t&&`kind`in t?`Continue validation`:`Next page`}),(0,$.jsx)(`button`,{type:`button`,disabled:n,onClick:e.refresh,children:`Observe a new snapshot`}),t&&!(`kind`in t)&&!t.next&&(0,$.jsxs)(`span`,{className:`page-end`,children:[`End of this retained snapshot`,t.coverage.observed===`incomplete`?` (incomplete)`:``,`.`]})]})}function Qr({client:e,seed:t,entityId:n}){let r=Hr(e,{...t,reader:`contents`}),[i,a]=(0,f.useState)(),o=r.page;return(0,$.jsxs)(`section`,{"aria-label":`Retained content fields`,children:[(0,$.jsx)(Zr,{pager:r}),n&&(0,$.jsxs)(`p`,{children:[`Showing matches for entity `,(0,$.jsx)(`code`,{children:n}),` on this page only. Continue paging for other fields/versions.`]}),o&&!(`kind`in o)&&o.records.map(e=>e.kind!==`content`&&e.kind!==`omitted`||n&&e.owner.entity.id!==n?null:e.kind===`omitted`?(0,$.jsxs)(`p`,{className:`omission`,children:[`Omitted source block:`,` `,(0,$.jsx)(`code`,{children:JSON.stringify(e.block)})]},`${e.owner.entity.id}:${e.version}:${JSON.stringify(e.block.owner)}`):(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`p`,{children:[e.owner.entity.kind,` `,(0,$.jsx)(`code`,{children:e.owner.entity.id}),` `,`· `,e.content.field,` · `,e.content.bytes,` retained bytes`]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.descriptor.owner)}),(0,$.jsx)(Ur,{value:e.coverage}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{o.request.scope.kind!==`workspace`&&o.request.snapshotSeq!==null&&a(Br(o.request.storeId,o.request.scope,o.request.snapshotSeq,e.content))},children:`Inspect complete retained field`})]},`${e.content.recordId}:${e.content.version}`)),i&&(0,$.jsx)(Xr,{client:e,cursor:i},`${i.recordId}:${i.recordVersion}`)]})}function $r({client:e,seed:t}){return(0,$.jsx)(ei,{client:e,seed:t},G(t))}function ei({client:e,seed:t}){let[n,r]=(0,f.useState)(t),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,r=new AbortController;return l(!0),(n.kind===`message`?e.message(n,r.signal):n.kind===`tool`?e.tool(n,r.signal):e.task(n,r.signal)).then(e=>{t&&(l(!1),e.kind===`error`?s(e.error.code):(a(e.value),s(void 0)))}).catch(()=>{t&&(s(`Read unavailable.`),l(!1))}),()=>{t=!1,r.abort()}},[e,n]),(0,$.jsxs)(`section`,{"aria-label":`Exact entity metadata`,children:[c&&(0,$.jsx)(`p`,{children:`Reading exact entity version…`}),o&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Entity refused: `,o]}),i&&`kind`in i&&(0,$.jsx)(Ur,{value:i.coverage}),i&&(`kind`in i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Entity validation in progress, not missing.`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>r(i.next),children:`Continue exact entity validation`})]}):(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Exact stored owner and associations`}),(0,$.jsx)(`pre`,{children:JSON.stringify(i.record,null,2)})]}))]})}function ti(e){let t=tr(`download`,yn(e));if(t.method!==`GET`)throw Error(`Native download needs the named GET attachment route.`);let n=document.createElement(`a`);n.href=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 ni({request:e,onClose:t}){let[n]=(0,f.useState)(e),[r,i]=(0,f.useState)(e.format),[a,o]=(0,f.useState)(``);return(0,$.jsxs)(hr,{title:`Export retained history`,onClose:t,children:[(0,$.jsxs)(`p`,{children:[`Selected `,n.scope.kind,`: `,n.scope.id,` · snapshot`,` `,n.snapshotSeq]}),(0,$.jsxs)(`label`,{children:[`Format`,(0,$.jsxs)(`select`,{value:r,onChange:e=>i(e.target.value===`markdown`?`markdown`:`ndjson`),children:[(0,$.jsx)(`option`,{value:`ndjson`,children:`NDJSON public archive`}),(0,$.jsx)(`option`,{value:`markdown`,children:`Readable Markdown with footer metadata`})]})]}),(0,$.jsx)(`p`,{children:`Includes retained context, messages/tools, graph, lifecycle, changes, checks, human review and coverage beyond loaded pages. Redactions and source omissions remain.`}),(0,$.jsx)(`p`,{children:`A native browser download request cannot establish completion. Inspect the original EOF and completion trailer/counts/digest in the downloaded artifact; missing footer means incomplete. Revoked access may terminate without a trailer.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{try{ti({...n,format:r}),o(`Download requested — completion not verified by this browser UI.`)}catch{o(`Download unavailable; no archive claimed complete.`)}},children:`Request selected-scope download`}),(0,$.jsx)(`p`,{role:`status`,children:a})]})}function ri(e,t){if(!t||N(t)>k.queryBytes)throw Error(`Query must be 1–${k.queryBytes} UTF-8 bytes; it was not clipped.`);let{navigation:n,...r}=e;return Y({...r,query:t,recordId:null,recordVersion:null,field:null,offset:0})}function ii(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 ai({client:e,seed:t,onClose:n,onHit:r}){let[i]=(0,f.useState)(t),a=(0,f.useRef)(null),o=(0,f.useRef)(0),[s,c]=(0,f.useState)(``),[l,u]=(0,f.useState)(0),[d,p]=(0,f.useState)(),[m,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(),v=(0,f.useRef)(null),y=(0,f.useCallback)(async(t,n)=>{v.current?.abort();let r=new AbortController;v.current=r,h(!0),_(void 0);try{let i=await e.search(t,r.signal);if(o.current!==n||r.signal.aborted)return;i.kind===`error`?_(i.error.code):(p(i.value),u(0))}catch{o.current===n&&!r.signal.aborted&&_(`Search unavailable or invalid; no automatic retry.`)}finally{o.current===n&&!r.signal.aborted&&h(!1)}},[e]);return(0,f.useEffect)(()=>(a.current?.focus(),()=>{o.current++,v.current?.abort()}),[]),(0,f.useEffect)(()=>{let e=++o.current;if(v.current?.abort(),h(!1),p(void 0),u(0),_(void 0),!s)return;let t;try{t=ri(i,s)}catch{_(`Query must be 1–1024 UTF-8 bytes; it was not clipped.`);return}let n=setTimeout(()=>void y(t,e),300);return()=>{clearTimeout(n),o.current++,v.current?.abort()}},[s,i,y]),(0,$.jsx)(hr,{title:`Search retained history`,onClose:n,children:(0,$.jsxs)(`div`,{className:`gs-modal`,children:[(0,$.jsxs)(`div`,{className:`gs-input-row`,children:[(0,$.jsx)(oe,{}),(0,$.jsx)(`input`,{ref:a,"aria-label":`Case-sensitive literal query`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),u(e=>Math.max(0,Math.min(e+1,(d?.hits.length??0)-1)))),e.key===`ArrowUp`&&(e.preventDefault(),u(e=>Math.max(e-1,0))),e.key===`Enter`&&d?.hits[l]&&(e.preventDefault(),r(d.hits[l]),n())}})]}),(0,$.jsxs)(`p`,{children:[`Case-sensitive literal UTF-8 search. Scope `,i.scope.kind,` `,i.scope.id,`; snapshot `,i.snapshotSeq,`. No regex, provider request or history repair.`]}),(0,$.jsxs)(`div`,{className:`gs-results`,children:[m&&(0,$.jsx)(`p`,{role:`status`,children:`Searching bounded retained range…`}),g&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Search refused: `,g]}),!s&&(0,$.jsx)(`p`,{children:`Enter a query to search this selected scope.`}),d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ur,{value:d.coverage}),(0,$.jsxs)(`div`,{className:`gs-section`,children:[(0,$.jsxs)(`div`,{className:`gs-section-head`,children:[`Matches on this page: `,d.hits.length]}),d.hits.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,className:`gs-item ${l===t?`active`:``}`,onMouseEnter:()=>u(t),onClick:()=>{r(e),n()},children:[(0,$.jsxs)(`span`,{className:`gs-item-title`,children:[e.owner.entity.kind,` · `,e.content.field,` · v`,e.content.version]}),(0,$.jsx)(`span`,{className:`gs-item-sub`,children:e.preview}),(0,$.jsxs)(`code`,{children:[e.owner.childRunId??e.owner.runId??e.owner.taskId,` `,`/ `,e.content.recordId,` / bytes `,e.range.start,`–`,e.range.end]})]},`${e.content.recordId}:${e.content.version}:${e.range.start}`)),d.hits.length===0&&(0,$.jsx)(`p`,{children:ii(d)})]}),(0,$.jsx)(`button`,{type:`button`,disabled:m||!d.next,onClick:()=>{d.next&&y(d.next,++o.current)},children:`Continue same snapshot search`})]})]}),(0,$.jsx)(`footer`,{className:`gs-foot`,children:`↑↓ Navigate · Enter Open exact hit · Escape Close. Reopening never resumes execution.`})]})})}function oi({run:e,historical:t=!1}){return(0,$.jsxs)(`article`,{className:`run-summary`,children:[(0,$.jsxs)(`h3`,{children:[e.assignmentId??e.admission.kind,` ·`,` `,t?`historical projection`:`owner projection`]}),(0,$.jsx)(`p`,{children:(0,$.jsx)(`code`,{children:e.childRunId??e.runId})}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Lifecycle`}),(0,$.jsx)(`dd`,{children:e.lifecycle}),(0,$.jsx)(`dt`,{children:`Execution`}),(0,$.jsx)(`dd`,{children:e.outcome??`unsettled`}),(0,$.jsx)(`dt`,{children:`Wait/block reason`}),(0,$.jsx)(`dd`,{children:e.reason??`none reported`}),(0,$.jsx)(`dt`,{children:`Summary publication`}),(0,$.jsx)(`dd`,{children:e.publication})]}),(0,$.jsx)(Ur,{value:e.coverage}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Native / recording / parent settlement facts (independent of human review)`}),(0,$.jsx)(`pre`,{children:e.settlement?JSON.stringify(e.settlement,null,2):`No settlement recorded`})]})]})}function si({client:e,seed:t}){return(0,$.jsx)(ci,{client:e,seed:t},G(t))}function ci({client:e,seed:t}){let[n,r]=(0,f.useState)(t),[i,a]=(0,f.useState)(),[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{let t=!0,r=new AbortController;return l(!0),e.graph(n,r.signal).then(e=>{t&&(l(!1),e.kind===`error`?s(e.error.code):(a(e.value),s(void 0)))}).catch(()=>{t&&(s(`Read unavailable.`),l(!1))}),()=>{t=!1,r.abort()}},[e,n]),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Immutable admitted graph`}),o&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Graph refused: `,o]}),c&&(0,$.jsx)(`p`,{children:`Reading graph…`}),i&&`kind`in i&&(0,$.jsx)(Ur,{value:i.coverage}),i&&(`kind`in i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{children:`Graph validation in progress; not an empty graph.`}),(0,$.jsx)(`button`,{type:`button`,disabled:c,onClick:()=>r(i.next),children:`Continue graph validation`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xr,{client:e,cursor:Br(i.request.storeId,i.request.scope,i.request.snapshotSeq,i.graph.plan)}),i.graph.assignments.map(e=>(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`h4`,{children:[e.id,` / `,e.purpose]}),(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsx)(`pre`,{children:JSON.stringify({model:e.model,role:e.role,dependencies:e.dependencies},null,2)})]},e.id))]}))]})}function li({client:e,seed:t,onScope:n}){let r=Hr(e,{...t,reader:`runs`}),i=r.page,[a,o]=(0,f.useState)();return(0,$.jsxs)(`section`,{children:[(0,$.jsx)(Zr,{pager:r}),i&&!(`kind`in i)&&i.records.map(e=>e.kind===`run`?(0,$.jsxs)(`article`,{children:[(0,$.jsx)(oi,{run:e.projection,historical:!0}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>n({kind:e.projection.childRunId?`child`:`run`,id:e.projection.childRunId??e.projection.runId}),children:`Open retained episode/child details`}),e.projection.admission.graph&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>{i.request.scope.kind!==`workspace`&&i.request.snapshotSeq!==null&&e.projection.admission.graph&&o({storeId:i.request.storeId,scope:i.request.scope,snapshotSeq:i.request.snapshotSeq,graph:e.projection.admission.graph})},children:`Inspect admitted graph and plan`})]},e.projection.childRunId??e.projection.runId):null),a&&(0,$.jsx)(si,{client:e,seed:a},a.graph.recordId)]})}function ui({onOpen:e,disabled:t}){return(0,$.jsx)(`button`,{type:`button`,className:`chip search-toggle`,"aria-label":`Search all retained pages in selected scope`,"data-tip":`Search all retained pages in selected scope`,disabled:t,onClick:e,children:(0,$.jsx)(oe,{"aria-hidden":`true`})})}function di(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 fi(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 pi(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)??mi(n.role,n.customType)}return r}function mi(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 hi(e,t,n,r){let i=n.get(e);return i&&i.len===t?i.h:r}var gi=(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,$.jsx)(`div`,{ref:a,"data-lazy-id":e,children:(0,$.jsx)(`div`,{ref:s,children:o})}):(0,$.jsx)(`div`,{ref:a,className:`msg-lazy-ph`,"data-msg-id":e,"data-lazy-id":e,style:{height:n},"aria-hidden":`true`})}),_i=(0,f.memo)(function({message:e,client:t,seed:n}){let[r,i]=(0,f.useState)(!1);return(0,$.jsxs)(`article`,{className:`msg msg-${e.role}`,"data-msg-id":e.owner.entity.id,children:[(0,$.jsxs)(`header`,{className:`msg-meta`,children:[(0,$.jsx)(`strong`,{className:`msg-role`,children:e.role}),(0,$.jsxs)(`span`,{className:`msg-state`,children:[e.state,` message record, not execution outcome`]}),(0,$.jsxs)(`span`,{className:`msg-time`,children:[`v`,e.version]}),(0,$.jsxs)(`button`,{type:`button`,className:`msg-inspect`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[r?(0,$.jsx)(Te,{"aria-hidden":`true`}):(0,$.jsx)(ye,{"aria-hidden":`true`}),r?`Collapse`:`Inspect message`]})]}),(0,$.jsxs)(`div`,{className:`msg-body`,children:[(0,$.jsxs)(`p`,{className:`msg-ident`,children:[`Child `,e.owner.childRunId,` · message `,e.owner.entity.id,` · version `,e.version]}),e.role===`tool-result`&&(0,$.jsxs)(`p`,{className:`msg-note`,children:[`Result call: `,e.resultCallId??`unassociated / orphan`,`. Kept visible independently of the tool card.`]}),r&&(0,$.jsx)(`div`,{className:`msg-text`,children:(0,$.jsxs)(`div`,{className:`msg-text-main`,children:[e.finalText&&n.scope.kind!==`workspace`&&n.snapshotSeq!==null?(0,$.jsx)(Xr,{client:t,cursor:Br(n.storeId,n.scope,n.snapshotSeq,e.finalText)}):(0,$.jsx)(`p`,{children:`No finalized text field in this snapshot. Inspect retained partial/final blocks and omission metadata below.`}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`All message blocks, source limits and tool associations`}),(0,$.jsx)(Qr,{client:t,seed:n,entityId:e.owner.entity.id})]})]})})]})]})});function vi({messages:e,client:t,seed:n}){let r=(0,f.useRef)(null),i=(0,f.useRef)(!0),[a,o]=(0,f.useState)(()=>new Set),s=(0,f.useRef)(a);s.current=a;let c=(0,f.useRef)(new Map),l=(0,f.useRef)(new Map),u=(0,f.useRef)(new Map),d=(0,f.useRef)(0),p=(0,f.useMemo)(()=>e.map(e=>({id:e.owner.entity.id,role:e.role,message:e})),[e]),m=(0,f.useRef)(new Map);m.current=new Map(p.map(e=>[e.id,e.message.version]));let h=(0,f.useRef)(new Set);h.current=pi(p,c.current,1800);let g=(0,f.useCallback)((e,t)=>{let n=m.current.get(e);n!==void 0&&(l.current.set(e,{h:t,len:n}),c.current.set(e,t))},[]),_=(0,f.useCallback)(()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect(),n=[];for(let[e,t]of u.current){let r=t.getBoundingClientRect();n.push({id:e,top:r.top,bottom:r.bottom}),s.current.has(e)||g(e,r.height)}let i=di(n,{top:t.top-1200,bottom:t.bottom+1200},h.current,s.current,{top:t.top-2400,bottom:t.bottom+2400});for(let e of i.hide){let t=u.current.get(e);t&&g(e,t.offsetHeight)}o(e=>fi(e,i))},[g]),v=(0,f.useCallback)(()=>{d.current||=requestAnimationFrame(()=>{d.current=0,_()})},[_]);return(0,f.useLayoutEffect)(()=>{p.length?_():o(new Set)},[_,p]),(0,f.useEffect)(()=>{let e=new ResizeObserver(v);return r.current&&e.observe(r.current),()=>{e.disconnect(),cancelAnimationFrame(d.current)}},[v]),(0,$.jsxs)(`div`,{className:`messages-wrap`,children:[(0,$.jsx)(`div`,{className:`messages`,ref:r,onScroll:e=>{let t=e.currentTarget;i.current=t.scrollHeight-t.scrollTop-t.clientHeight<80,v()},children:p.map(({id:e,role:i,message:o})=>(0,$.jsx)(gi,{id:e,show:!a.has(e),height:hi(e,o.version,l.current,i===`user`?100:280),containerRef:r,onMeasured:g,lazyRef:t=>{t?u.current.set(e,t):u.current.delete(e)},children:(0,$.jsx)(_i,{message:o,client:t,seed:n})},e))}),(0,$.jsxs)(`button`,{type:`button`,className:`scroll-bottom`,onClick:()=>{r.current&&(r.current.scrollTop=r.current.scrollHeight,i.current=!0)},children:[(0,$.jsx)(je,{"aria-hidden":`true`}),`Latest on loaded page`]})]})}function yi({client:e,seed:t}){let n=Hr(e,{...t,reader:`messages`}),r=n.page;return(0,$.jsxs)(`section`,{className:`transcript`,children:[(0,$.jsx)(Zr,{pager:n}),r&&!(`kind`in r)&&(0,$.jsxs)($.Fragment,{children:[r.records.length===0&&(0,$.jsxs)(`p`,{className:`empty-note panel-empty`,children:[`No message records on this page`,r.next?`; more history remains.`:`.`]}),(0,$.jsx)(vi,{messages:r.records.filter(e=>e.kind===`message`),client:e,seed:r.request},`${r.request.snapshotSeq}:${r.request.after?.recordId??`first`}`)]})]})}function bi({open:e,onToggle:t,headClassName:n,titleText:r,icon:i,iconClassName:a,titleClassName:o,toggleClassName:s,toggle:c,onHeadContextMenu:l,children:u,after:d}){return(0,$.jsxs)(`div`,{className:`chead ${n}`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`chead-main`,"aria-expanded":e,title:r,onClick:t,onContextMenu:l,children:[c===void 0?(0,$.jsx)(`span`,{className:s?`chead-toggle ${s}`:`chead-toggle`,children:e?(0,$.jsx)(De,{}):(0,$.jsx)(Ee,{})}):c,(0,$.jsx)(`span`,{className:a?`chead-icon ${a}`:`chead-icon`,children:i}),(0,$.jsx)(`span`,{className:o?`chead-title ${o}`:`chead-title`,children:u})]}),d]})}var xi=(0,f.memo)(function({record:e,client:t,seed:n}){let[r,i]=(0,f.useState)(!1),a=e.result?e.result.isError?`SDK tool error observed`:`SDK tool end observed`:e.startObserved?`Start observed; end not observed in this snapshot`:`No start observed`,o=e.result?e.result.isError?`err`:`ok`:e.startObserved?`pending`:``;return(0,$.jsxs)(`div`,{className:`toolcall${o===`err`?` err`:``}`,children:[(0,$.jsx)(bi,{open:r,onToggle:()=>i(e=>!e),headClassName:`toolcall-head`,titleText:`Inspect recorded tool call`,icon:(0,$.jsx)(re,{}),iconClassName:`toolcall-icon`,titleClassName:`toolcall-name`,after:(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`toolcall-path`,children:[`Child `,e.owner.childRunId,` · call `,e.owner.entity.id,` · v`,e.version]}),(0,$.jsx)(`span`,{className:`toolcall-badge ${o}`,children:a})]}),children:e.name}),r&&(0,$.jsxs)(`div`,{className:`toolcall-body`,children:[(0,$.jsx)(`p`,{children:`SDK tool observations are not native process launch/close or passing parent checks.`}),(0,$.jsxs)(`dl`,{children:[(0,$.jsx)(`dt`,{children:`Source ID`}),(0,$.jsxs)(`dd`,{children:[e.source.disposition,`:`,` `,e.source.value??`unavailable`]}),(0,$.jsx)(`dt`,{children:`Declaration`}),(0,$.jsx)(`dd`,{children:e.declaration?`${e.declaration.messageId} / ${e.declaration.blockId} (${e.declarationStage})`:`No declaration recorded; orphan result remains accessible`})]}),(0,$.jsxs)(`div`,{className:`toolcall-output`,children:[(0,$.jsx)(`div`,{className:`toolcall-output-label`,children:`Recorded tool end (not parsed from output)`}),(0,$.jsx)(`pre`,{children:e.result?JSON.stringify(e.result,null,2):`No end fact in this snapshot.`})]}),(0,$.jsx)(`div`,{className:`toolcall-args`,children:(0,$.jsx)(Qr,{client:t,seed:n,entityId:e.owner.entity.id})})]})]})});function Si({draft:e,onChange:t,context:n,roles:r,onSave:i,onGenerate:a,onStart:o,canSave:s,canAct:c}){let[l,u]=(0,f.useState)(!0),[d,p]=(0,f.useState)(null),[m,h]=(0,f.useState)(``),[g,_]=(0,f.useState)(``),[v,y]=(0,f.useState)(`research`),[b,x]=(0,f.useState)([]),[S,ee]=(0,f.useState)(``),[C,w]=(0,f.useState)(``),T=e.assignments,E=e=>{p(e.id),h(e.instructions),_(e.expectedOutput),y(e.purpose),x(e.dependencies),w(``)},te=()=>{p(null),h(``),_(``),w(``)},D=n=>{let i=r?.find(e=>e.role===qe(v));i?(t({...e,assignments:T.map(e=>e.id===n?{...e,purpose:v,instructions:m,expectedOutput:g,dependencies:b,role:i}:e)}),te()):w(cr)},re=()=>{let i=r?.find(e=>e.role===qe(`research`));if(!i){w(cr);return}let a=1;for(;T.some(e=>e.id===`assignment-${a}`);)a++;let o={id:`assignment-${a}`,purpose:`research`,instructions:``,expectedOutput:``,dependencies:[],role:i,model:n.model};t({...e,assignments:[...T,o]}),E(o)},ie=n=>{T.some(e=>e.dependencies.some(e=>e.source.kind===`current`&&e.source.assignmentId===n))?w(`Remove dependent edges explicitly before deleting this assignment.`):t({...e,assignments:T.filter(e=>e.id!==n)})};return(0,$.jsxs)(`section`,{className:`plan-board ${l?``:`plan-board-collapsed`}`,children:[(0,$.jsx)(`div`,{className:`plan-board-head`,children:(0,$.jsxs)(`button`,{type:`button`,className:`plan-board-head-main`,"aria-expanded":l,onClick:()=>u(!l),children:[(0,$.jsx)(fe,{}),(0,$.jsx)(`span`,{children:`Readable plan & decomposition`}),(0,$.jsxs)(`span`,{children:[T.length,` required assignments`]}),l?(0,$.jsx)(Te,{}):(0,$.jsx)(De,{})]})}),(0,$.jsxs)(`div`,{className:`toolbar`,children:[(0,$.jsx)(`button`,{type:`button`,disabled:!c||n.task?.kind!==`code`,onClick:a,children:`Preview readonly Generate proposal`}),(0,$.jsx)(`button`,{type:`button`,disabled:!s,onClick:i,children:`Preview Save plan`}),(0,$.jsx)(`button`,{type:`button`,className:`primary`,disabled:!c,onClick:o,children:`Preview Start saved graph`})]}),(0,$.jsx)(`p`,{children:`Draft changes never execute. Start uses the saved graph shown in its fresh preview, not unsaved text. Generated proposals never save or start themselves.`}),T.some(e=>G(e.model)!==G(n.model))&&(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{children:`Saved assignments name an old model selection. Reading does not rebind them.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>t({...e,assignments:T.map(e=>({...e,model:n.model}))}),children:`Explicitly rebind draft to current model (requires new Save)`})]}),!r&&(0,$.jsx)(`p`,{role:`status`,children:`Current plan metadata unavailable. Observe again; historical text is not action authority.`}),C&&(0,$.jsx)(`p`,{role:`alert`,children:C}),l&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{children:[`Readable plan`,(0,$.jsx)(`textarea`,{"aria-label":`Readable plan`,value:e.readablePlan,onChange:n=>t({...e,readablePlan:n.target.value}),rows:8})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{children:`Read rendered plan`}),(0,$.jsx)(Ar,{text:e.readablePlan})]}),(0,$.jsx)(wr,{text:e.readablePlan}),(0,$.jsx)(`ol`,{className:`plan-board-steps`,children:T.map(e=>(0,$.jsxs)(`li`,{className:`plan-board-step`,children:[(0,$.jsxs)(`div`,{className:`plan-step-head`,children:[(0,$.jsx)(`strong`,{children:e.id}),(0,$.jsxs)(`span`,{children:[e.purpose,` —`,` `,e.purpose===`edit`?`checkout writer`:`readonly`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>E(e),children:[(0,$.jsx)(be,{}),` Edit`]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ie(e.id),children:[(0,$.jsx)(ne,{}),` Remove draft assignment`]})]}),d===e.id?(0,$.jsxs)(`div`,{className:`plan-step-edit`,children:[(0,$.jsxs)(`label`,{children:[`Purpose`,(0,$.jsx)(`select`,{value:v,onChange:e=>{let t=e.target.value;(t===`research`||t===`diagnosis`||t===`review`||t===`edit`&&n.task?.kind===`code`)&&y(t)},children:[`research`,`diagnosis`,`review`,`edit`].filter(e=>e!==`edit`||n.task?.kind===`code`).map(e=>(0,$.jsx)(`option`,{children:e},e))})]}),(0,$.jsxs)(`label`,{children:[`Instructions`,(0,$.jsx)(`textarea`,{"aria-label":`Instructions`,value:m,onChange:e=>h(e.target.value),rows:5})]}),(0,$.jsxs)(`label`,{children:[`Expected output`,(0,$.jsx)(`textarea`,{"aria-label":`Expected output`,value:g,onChange:e=>_(e.target.value),rows:3})]}),(0,$.jsxs)(`fieldset`,{children:[(0,$.jsx)(`legend`,{children:`Current-episode dependencies (whole final text by default)`}),T.filter(t=>t.id!==e.id).map(e=>{let t=b.findIndex(t=>t.source.kind===`current`&&t.source.assignmentId===e.id);return(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t>=0,onChange:t=>x(n=>t.target.checked?[...n,{source:{kind:`current`,assignmentId:e.id},range:null,requireCompleteObservation:!1}]:n.filter(t=>t.source.kind!==`current`||t.source.assignmentId!==e.id))}),e.id]},e.id)})]}),b.map((e,t)=>(0,$.jsxs)(`div`,{className:`dependency-editor`,children:[(0,$.jsx)(`code`,{children:JSON.stringify(e.source)}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.requireCompleteObservation,onChange:e=>x(n=>n.map((n,r)=>t===r?{...n,requireCompleteObservation:e.target.checked}:n))}),`Require complete observation`]}),(0,$.jsxs)(`p`,{children:[`Selection:`,` `,e.range?`reviewed UTF-8 bytes ${e.range.start}–${e.range.end}`:`whole final text; no silent clipping`]}),(0,$.jsxs)(`label`,{children:[`Reviewed edge JSON (range/null and exact historical identity)`,(0,$.jsx)(`textarea`,{defaultValue:JSON.stringify(e),onBlur:e=>{try{let n=Ye(Le(e.target.value));x(e=>e.map((e,r)=>t===r?n:e)),w(``)}catch{w(`Invalid dependency. Original edge retained; review before Save.`)}}})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>x(e=>e.filter((e,n)=>t!==n)),children:`Remove edge`})]},e.source.kind===`current`?e.source.assignmentId:e.source.childRunId)),(0,$.jsxs)(`label`,{children:[`Explicit historical/advisory edge JSON`,(0,$.jsx)(`textarea`,{value:S,onChange:e=>ee(e.target.value),placeholder:`Exact committed run/child/result/version plus range and coverage requirement`})]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{try{let e=Ye(Le(S));if(e.source.kind!==`historical`)throw Error();x(t=>[...t,e]),ee(``),w(``)}catch{w(`Historical edge requires actual committed identity; no guessed result reference.`)}},children:`Add reviewed historical edge`}),(0,$.jsx)(`button`,{type:`button`,onClick:te,children:`Discard inline edits`}),(0,$.jsx)(`button`,{type:`button`,disabled:!!C,onClick:()=>D(e.id),children:`Apply to local draft`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ar,{text:e.instructions}),(0,$.jsxs)(`p`,{children:[`Expected: `,e.expectedOutput]}),(0,$.jsxs)(`p`,{children:[`Role `,e.role.role,` / `,(0,$.jsx)(`code`,{children:e.role.sha256})]}),(0,$.jsxs)(`p`,{children:[e.model.provider,`/`,e.model.model,` ·`,` `,e.model.thinking]}),(0,$.jsx)(`pre`,{children:JSON.stringify(e.dependencies,null,2)})]})]},e.id))}),(0,$.jsxs)(`button`,{type:`button`,disabled:!r||T.length>=16,onClick:re,children:[(0,$.jsx)(ce,{}),` Add assignment`]})]})]})}var Ci=`未命名章节`;function wi(e){return String(e??``).trim().replace(/[\s\u3000]+/g,`-`).replace(/[^\p{L}\p{N}_-]+/gu,`-`).replace(/-{2,}/g,`-`).replace(/^-+|-+$/g,``).slice(0,80)||`section`}function Ti(e){let t=new Map;return e.map(({level:e,label:n})=>{let r=String(n??``).replace(/\s+/g,` `).trim(),i=wi(r||Ci),a=(t.get(i)??0)+1;return t.set(i,a),{level:e,id:a===1?i:`${i}-${a}`,label:r||Ci}})}function Ei(e){return e.length>=2}function Di(e){let t=0,n=0;return e.split(`
5
5
  `).map(e=>{let r={key:`text-offset:${t}`,number:++n,text:e};return t+=e.length+1,r})}function Oi({text:e}){return(0,$.jsx)(`pre`,{className:`scm-diff-pre`,children:Di(e).map(({text:e,key:t})=>{let n=``;return[`diff --git`,`index `,`new file`,`deleted file`,`old mode`,`new mode`,`similarity index`,`rename `,`copy `,`Binary files`,`---`,`+++`].some(t=>e.startsWith(t))?n=`hdr`:e.startsWith(`@@`)?n=`hunk`:e.startsWith(`+`)?n=`add`:e.startsWith(`-`)&&(n=`del`),(0,$.jsx)(`div`,{className:`scm-diff-line ${n}`,children:e||` `},t)})})}function ki({text:e}){let[t,n]=(0,f.useState)(`raw`),[r,i]=(0,f.useState)(!0),[a,o]=(0,f.useState)(1),[s,c]=(0,f.useState)([]),[l,u]=(0,f.useState)(null),d=(0,f.useRef)(1),p=(0,f.useRef)(null),m=e.split(`
6
6
  `);return(0,f.useLayoutEffect)(()=>{if(t!==`markdown`)return;if(!e){c([]);return}let n=Array.from(p.current?.querySelectorAll(`h1,h2,h3,h4,h5,h6`)??[]),r=Ti(n.map(e=>({level:Number(e.tagName[1]),label:e.textContent??``})));r.forEach((e,t)=>{n[t].id=`preview-${e.id}`}),c(r)},[e,t]),(0,$.jsxs)(`div`,{className:`fp-preview`,children:[(0,$.jsxs)(`div`,{className:`fp-head toolbar`,children:[(0,$.jsxs)(`label`,{children:[`View`,(0,$.jsxs)(`select`,{value:t,onChange:e=>n(e.target.value===`markdown`?`markdown`:e.target.value===`diff`?`diff`:`raw`),children:[(0,$.jsx)(`option`,{value:`raw`,children:`Raw text / lines`}),(0,$.jsx)(`option`,{value:`markdown`,children:`Safe Markdown`}),(0,$.jsx)(`option`,{value:`diff`,children:`Observed diff`})]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),children:[`Wrap: `,r?`on`:`off`]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e=>Math.min(2,e+.1)),children:`Zoom +`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>o(e=>Math.max(.8,e-.1)),children:`Zoom −`}),(0,$.jsx)(wr,{text:l?m.slice(l.start-1,l.end).join(`
7
- `):e})]}),(0,$.jsx)(`p`,{className:`fp-notice`,children:`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`}),(0,$.jsx)(`div`,{style:{fontSize:`${a}em`},children:t===`markdown`?(0,$.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ei(s)&&(0,$.jsx)(`nav`,{className:`fp-toc`,"aria-label":`Page headings`,children:s.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,$.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,children:(0,$.jsx)(Ar,{text:e})})]}):t===`diff`?(0,$.jsx)(Oi,{text:e}):(0,$.jsx)(`div`,{className:`fp-code ${r?``:`no-wrap`}`,children:Di(e).map(({text:e,number:t,key:n})=>(0,$.jsxs)(`div`,{className:`fp-line ${l&&t>=l.start&&t<=l.end?`sel`:``}`,children:[(0,$.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":`Select page line ${t}`,onClick:e=>{e.shiftKey||(d.current=t),u({start:Math.min(d.current,t),end:Math.max(d.current,t)})},children:t}),(0,$.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},n))})}),l&&(0,$.jsxs)(`footer`,{className:`fp-foot`,children:[`Selected page lines `,l.start,`–`,l.end,(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(null),children:`Clear selection`})]})]})}function Ai({client:e,seed:t}){let n=Hr(e,t),[r,i]=(0,f.useState)(),a=n.page;return(0,$.jsxs)(`section`,{className:`scm-body`,children:[(0,$.jsx)(Zr,{pager:n}),(0,$.jsx)(`p`,{children:`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`}),(0,$.jsx)(`div`,{className:`scm-files-list`,children:a&&!(`kind`in a)&&a.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,n=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,$.jsxs)(`article`,{className:`scm-file`,children:[(0,$.jsxs)(`h3`,{children:[t.kind,` · committed #`,e.committedSeq]}),(0,$.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),n&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&i(Br(a.request.storeId,a.request.scope,a.request.snapshotSeq,n))},children:[`Inspect full retained `,n.field]})]},e.recordId)})}),r&&(0,$.jsx)(Xr,{client:e,cursor:r,render:e=>(0,$.jsx)(ki,{text:e})},`${r.recordId}:${r.recordVersion}`)]})}function ji({client:e,taskId:t,seed:n,canAct:r,onAction:i,onObligations:a}){let[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(0),p=(0,f.useRef)(u);return p.current=u,(0,f.useEffect)(()=>{let n=u,r=new AbortController,i=!0;return s(void 0),e.checkObligations(t,r.signal).then(e=>{i&&p.current===n&&(e.kind===`error`?l(e.error.code):(l(void 0),s(e.value),a(e.value)))}).catch(()=>{i&&l(`Obligations unavailable.`)}),()=>{r.abort(),i=!1}},[e,t,u,a]),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Current configured obligations`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(e=>e+1),children:`Observe obligations`}),c&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Obligations unavailable: `,c]}),o?.definitions.length===0&&(0,$.jsx)(`p`,{children:`No configured obligations. This is not passing check coverage.`}),o?.definitions.map(e=>(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`h4`,{children:[e.selection.name,`: `,e.status]}),(0,$.jsx)(`pre`,{children:e.selection.command}),(0,$.jsxs)(`p`,{children:[`Timeout `,e.selection.timeoutMs,` ms. Native outcome and freshness remain separate.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>i({kind:`check`,taskId:t,check:e.selection}),children:`Preview exact configured check`})]},e.selection.name)),(0,$.jsx)(`p`,{children:`Browser checks are configured selections only. Native-local manual commands are not a browser shell endpoint.`}),(0,$.jsx)(Ai,{client:e,seed:{...n,reader:`checks`}})]})}function Mi({client:e,storeId:t,taskId:n}){let[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(0);return(0,f.useEffect)(()=>{if(s<0)return;let r=new AbortController;return i(void 0),o(``),e.currentChanges({storeId:t,taskId:n},r.signal).then(e=>{r.signal.aborted||(e.kind===`ok`?i(e.value):o(e.error.code))}).catch(()=>{r.signal.aborted||o(`Current observation unavailable`)}),()=>r.abort()},[e,t,n,s]),(0,$.jsxs)(`section`,{"aria-label":`Current checkout changes`,children:[(0,$.jsx)(`h3`,{children:`Current checkout changes (not a captured historical diff)`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+1),children:`Observe current changes`}),a&&(0,$.jsx)(`p`,{role:`alert`,children:a}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Fingerprint `,(0,$.jsx)(`code`,{children:r.observation.identity}),` ·`,` `,r.observation.complete?`complete within bounded scope`:`incomplete coverage`,` `,`· includes pre-existing dirt; not attribution.`]}),(0,$.jsx)(`pre`,{children:JSON.stringify(r.coverage)}),(0,$.jsx)(ki,{text:r.text})]})]})}var Ni=[[`plan`,ve],[`checks`,ke],[`changes`,O],[`review`,D]];function Pi(){return(0,$.jsx)(`aside`,{className:`panel panel-right`,children:(0,$.jsx)(`p`,{className:`panel-empty`,children:`Select a task to inspect plans, checks, changes and review.`})})}function Fi({client:e,context:t,seed:n,runs:r,canAct:i,onAction:a,planMetadata:o}){let s=t?G(t):`unavailable`,c=(0,f.useMemo)(()=>s===`unavailable`?null:Qe(Le(s)),[s]),[l,u]=(0,f.useState)(`plan`),[d,p]=(0,f.useState)({readablePlan:``,assignments:[]}),[m,h]=(0,f.useState)(),[g,_]=(0,f.useState)(),[v,y]=(0,f.useState)(),[b,x]=(0,f.useState)(),[S,ee]=(0,f.useState)(``),[C,w]=(0,f.useState)(!1),T=c?.task?.id??(n.scope.kind===`task`?n.scope.id:null),E=(0,f.useRef)(new mr);E.current.select(G({context:c,tab:l,draft:d,canAct:i})),(0,f.useEffect)(()=>()=>E.current.depart(),[]),(0,f.useEffect)(()=>{let e=!0;if(_(void 0),h(void 0),!o||!c)y(cr);else return o.read(c).then(t=>{e&&(t.kind===`error`?y(t.error.code):G(t.value.context)===s?(`kind`in t.value?h(t.value):_(t.value),y(void 0)):y(`Owner metadata is stale.`))}).catch(()=>{e&&y(`Owner metadata unavailable.`)}),()=>{e=!1}},[o,c,s]);let te=(0,f.useCallback)(e=>x(e),[]);if(!T)return(0,$.jsx)(Pi,{});let D={...n,scope:{kind:`task`,id:T}};return(0,$.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,$.jsx)(`nav`,{className:`rp-tabs`,"aria-label":`Inspector`,children:Ni.map(([e,t])=>(0,$.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-label":e,"aria-pressed":l===e,onClick:()=>u(e),children:[(0,$.jsx)(t,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e})]},e))}),(0,$.jsxs)(`div`,{className:`inspector-body`,children:[l===`plan`&&(0,$.jsxs)($.Fragment,{children:[v&&(0,$.jsx)(`p`,{className:`inspector-note`,role:`status`,children:v}),m&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`p`,{children:[`Saved graph proof in progress.`,` `,JSON.stringify(m.coverage)]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!o||!c)return;let e=E.current.ticket();o.read(c,m.next).then(t=>{E.current.current(e)&&(t.kind===`error`?y(t.error.code):`kind`in t.value?h(t.value):(h(void 0),_(t.value)))})},children:`Continue saved graph read`})]}),g&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>p({readablePlan:g.readablePlan,assignments:g.savedGraph?.assignments??[]}),children:`Load observed saved plan into local draft`}),c?(0,$.jsx)(Si,{draft:d,onChange:p,context:c,roles:g?.roles??null,canAct:i,canSave:i&&!!g&&g.editable!==!1&&!!o,onGenerate:()=>a({kind:`generate-plan`,taskId:T}),onStart:()=>a({kind:`start`,taskId:T}),onSave:()=>{if(!o)return;let e=E.current.ticket();o.saveAction(c,structuredClone(d)).then(t=>{E.current.current(e)&&(t.kind===`error`?y(t.error.code):a(t.value))}).catch(()=>{E.current.current(e)&&y(`Plan proposal unavailable.`)})}}):(0,$.jsx)(`p`,{children:`Current control context unavailable. Historical data is not action authority.`})]}),l===`checks`&&(0,$.jsx)(ji,{client:e,taskId:T,seed:D,canAct:i,onAction:a,onObligations:te}),l===`changes`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Mi,{client:e,storeId:n.storeId,taskId:T}),(0,$.jsx)(`h3`,{children:`Captured historical observations`}),(0,$.jsx)(Ai,{client:e,seed:{...D,reader:`changes`}})]}),l===`review`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{children:`Human review`}),(0,$.jsx)(`p`,{children:`Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.`}),(0,$.jsxs)(`label`,{children:[`Episode to review`,(0,$.jsxs)(`select`,{value:S,onChange:e=>ee(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select an observed episode`}),r.filter(e=>e.childRunId===null&&e.admission.kind!==`check`).map(e=>(0,$.jsxs)(`option`,{value:e.runId,children:[e.runId,` · `,e.outcome??e.lifecycle]},e.runId))]})]}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked)}),`I acknowledge current unresolved issues if present; original results will not be rewritten.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!i||!c||!b||b.taskId!==T||!S,onClick:()=>{c&&b&&a({kind:`review`,taskId:T,runId:S,changesIdentity:c.observation.identity,checksRevision:b.revision,acceptIssues:C})},children:`Preview human review / Done`}),!b&&(0,$.jsx)(`p`,{children:`Observe current obligations in Checks before requesting review.`}),(0,$.jsx)(Ai,{client:e,seed:{...D,reader:`reviews`}})]})]})]})}function Ii(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function Li({client:e,workspace:t,taskId:n,runs:r,onTask:i,onScope:a,onNew:o}){let s=Hr(e,{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}),[c,l]=(0,f.useState)(new Set),u=(0,f.useMemo)(()=>Ii(r.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.assignmentId??e.admission.kind,active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),c),[r,c]),d=s.page&&!(`kind`in s.page)?s.page.records:null,p=d?.filter(e=>e.kind===`task`).length,m=p===void 0?``:` (${p}${s.page&&!(`kind`in s.page)&&s.page.next||s.canPrevious?`+`:``})`;return(0,$.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,$.jsxs)(`section`,{className:`lp-section grow`,children:[(0,$.jsxs)(`header`,{className:`lp-section-header`,children:[(0,$.jsxs)(`h2`,{className:`lp-section-title`,children:[`Tasks`,m]}),(0,$.jsx)(`div`,{className:`lp-section-actions`,children:(0,$.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-label":`New task`,title:`New task`,onClick:o,children:(0,$.jsx)(ce,{"aria-hidden":`true`})})})]}),(0,$.jsxs)(`nav`,{"aria-label":`Tasks`,className:`lp-section-body task-list`,children:[d?.map(e=>e.kind===`task`?(0,$.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===n?` active`:``}`,"aria-current":e.owner.taskId===n?`true`:void 0,title:e.goal,onClick:()=>i(e.owner.taskId),children:[(0,$.jsx)(`span`,{className:`session-icon`,children:(0,$.jsx)(ve,{"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`session-info`,children:[(0,$.jsx)(`span`,{className:`session-title`,children:e.goal}),` `,(0,$.jsxs)(`span`,{className:`session-sub`,children:[e.owner.taskId,` · v`,e.version]})]})]},e.owner.taskId):null),p===0&&(0,$.jsx)(`p`,{className:`panel-empty`,children:`No retained task on this page.`}),(0,$.jsx)(Zr,{pager:s})]}),(0,$.jsx)(`p`,{className:`panel-hint`,children:`One checkout owner. Open/history never executes.`})]}),n&&(0,$.jsxs)(`section`,{className:`lp-section episodes`,children:[(0,$.jsx)(`header`,{className:`lp-section-header`,children:(0,$.jsx)(`h3`,{className:`lp-section-title`,children:`Active and recent episodes`})}),(0,$.jsxs)(`div`,{className:`lp-section-body`,children:[(0,$.jsxs)(`nav`,{"aria-label":`Runs and assignments`,children:[u.map(e=>{let t=e.c.failed?`failed`:e.c.unknown?`unknown`:e.c.active?`active`:`settled`;return(0,$.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${e.depth*16}px`},children:[e.hasKids?(0,$.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":`Toggle assignments`,"aria-expanded":!e.isCollapsed,onClick:()=>l(t=>{let n=new Set(t);return n.has(e.c.id)?n.delete(e.c.id):n.add(e.c.id),n}),children:e.isCollapsed?(0,$.jsx)(Ee,{"aria-hidden":`true`}):(0,$.jsx)(De,{"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,$.jsxs)(`button`,{type:`button`,className:`session-item`,onClick:()=>a({kind:e.c.parentId?`child`:`run`,id:e.c.id}),children:[(0,$.jsxs)(`span`,{className:`session-info`,children:[(0,$.jsx)(`span`,{className:`session-title`,children:e.c.label}),e.isCollapsed&&` `,e.isCollapsed&&(0,$.jsx)(`span`,{className:`session-sub session-outcome`,children:`${e.descendantCount} descendants${e.hasFailure?` / failed child`:``}${e.hasUnknown?` / unknown child`:``}`})]}),` `,(0,$.jsx)(`span`,{className:`ep-state ${t}`,children:t})]})]},e.c.id)}),u.length===0&&(0,$.jsx)(`p`,{className:`panel-empty`,children:`No active or recent episode observed.`})]}),(0,$.jsxs)(`button`,{type:`button`,className:`ghost ep-all`,onClick:()=>a({kind:`task`,id:n}),children:[(0,$.jsx)(fe,{"aria-hidden":`true`}),`All retained episodes for task`]})]})]})]})}function Ri(e,t){let n=new URL(window.location.origin+window.location.pathname),r=new URLSearchParams({task:V(e)});if(t){let{navigation:e,...n}=t;r.set(`detail`,JSON.stringify(n))}return n.hash=r.toString(),n.href}function zi(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`);if(!n)return{taskId:t};let r=Y(Le(n));return r.navigation?null:{taskId:t,cursor:r}}catch{return null}}function Bi(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Vi({side:e,width:t,onResize:n}){let r=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>r.current?.(),[]),(0,$.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize ${e} pane`,"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:i=>{i.preventDefault(),r.current?.();let a=i.clientX,o=window.innerWidth,s=r=>{let i=Bi({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r.current=void 0};r.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function Hi(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus();let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus()}},[e,t,n,r])}var Ui=.4,Wi=1.05;function Gi(e){return Math.min(300,e*.86)}function Ki(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function qi(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Ji(e,t){return e===`left`?t:-t}function Yi(e,t){return Math.max(-e,Math.min(0,-e+t))}function Xi(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Zi(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Xi(r*Wi,n,t)>=Ui}var Qi=new Set([`auto`,`scroll`,`overlay`]);function $i(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Qi.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function ea(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function ta(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=Ki(r.clientX,window.innerWidth,n);i&&!$i(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=qi(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Gi(window.innerWidth),h=m*Wi;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=Ji(r,d);let b=Yi(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Xi(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Zi({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(ea(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function na(e,t,n,r){let i=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),a=i.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,i=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:i,group:`${r??`owner`}:${i}`,groupLabel:`${r??`Owner`} · ${i}`,kind:i===`tools`?`tool`:i===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:`Committed #${e.committedSeq}; ${r??`owner`}`,status:`recorded fact`,clock:e.kind===`capture-fact`?`Worker-local monotonic observations (${e.link.childRunId}): ${e.capture.source.firstObservedMs}–${e.capture.source.lastObservedMs} ms; not aligned to other workers.`:`Owner observation (${e.link.epoch}): ${e.observedMs} ms; clock origin not established by this reader.`,...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),o;return{onData(e){return o=e,()=>{o=void 0}},readState(){o?.({kind:`state`,conversations:[{id:e,title:`${e} — loaded committed page`,isStreaming:!1,segCount:a.length}],activeId:e})},readSegments(t){t===e&&o?.({kind:`segs`,convId:t,segs:a,reset:!0})},readSegment(t,n){let r=a.findIndex(e=>e.key===n);t!==e||r<0||o?.({kind:`seg_detail`,convId:t,key:n,seg:a[r],detail:JSON.stringify(i[r],null,2),analysis:{position:`Committed sequence ${i[r].committedSeq}; page ordinal ${r+1}. Timing shown in raw facts only; clocks may not be comparable.`}})},openDetail(t,r){let a=i.find(e=>e.recordId===r);t===e&&a&&n(a)},searchHistory:r}}var ra=`modulepreload`,ia=function(e){return`/`+e},aa={},oa=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ia(t,n),t=s(t),t in aa)return;aa[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ra,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function sa({client:e,seed:t,onSearch:n}){let r=Hr(e,{...t,reader:`events`}),i=r.page;return(0,$.jsxs)(`section`,{className:`timeline-view`,children:[(0,$.jsx)(`p`,{children:`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`}),(0,$.jsx)(Zr,{pager:r}),i&&!(`kind`in i)&&(0,$.jsx)(ca,{client:e,seed:i.request,records:i.records,onSearch:n},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})}function ca({client:e,seed:t,records:n,onSearch:r}){let i=(0,f.useRef)(null),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(!1),l=(0,f.useRef)(r);return l.current=r,(0,f.useEffect)(()=>{let e=!1,r;return oa(()=>import(`./timeline-client.js`).then(a=>{!e&&i.current&&(r=a.default.mount(i.current,na(t.scope.id,n,()=>o(!0),()=>l.current())))}),[]).catch(()=>{e||c(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id]),(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsx)(`p`,{role:`alert`,children:`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`}),(0,$.jsx)(`div`,{className:`timeline-mount`,ref:i}),a&&(0,$.jsx)(Qr,{client:e,seed:t})]})}var la=[[`messages`,le],[`tools`,re],[`context`,me],[`timeline`,we],[`runs`,ge],[`outcomes`,Ae]];function ua({api:e,planMetadata:t}){let[n]=(0,f.useState)(()=>e??or()),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(!1),[s]=(0,f.useState)(zi),[c,l]=(0,f.useState)(s?.taskId??null),[u,d]=(0,f.useState)(s?{kind:`task`,id:s.taskId}:null),p=pr(n,c?{kind:`task`,id:c}:null,!a),m={state:p.observation,transportStatus:p.transportStatus,error:p.error,refresh:p.refresh},h=p.workspace?.storeId,g=(0,f.useMemo)(()=>t??(h?lr(n.client,h):void 0),[t,n,h]),_=m.state?.snapshot.scope.kind===`task`&&m.state.snapshot.scope.id===c?m.state.snapshot.context:void 0,v=_?.status===`available`?_.version:null,y=p.actions&&m.state?.connection===`current`&&m.transportStatus===`current`&&!!v&&v.epoch===p.workspace?.epoch,[b,x]=(0,f.useState)(null),[S,ee]=(0,f.useState)(!1),C=(0,f.useRef)(null),[w,T]=(0,f.useState)(260),[E,te]=(0,f.useState)(360),D=(0,f.useCallback)(()=>x(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>ee(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),ta({enabled:S&&!a,open:b,onOpenChange:x,container:C}),Hi(C,b,S&&!a,D);let[ne,re]=(0,f.useState)(`messages`),[oe,le]=(0,f.useState)(!1),[fe,me]=(0,f.useState)(!1),[O,ge]=(0,f.useState)(),[ve,ye]=(0,f.useState)(s?.cursor),[be,Ce]=(0,f.useState)(!1),[we,Te]=(0,f.useState)(``),[Ee,De]=(0,f.useState)(`code`),[Oe,ke]=(0,f.useState)(),[Ae,je]=(0,f.useState)(!1),[Me,Ne]=(0,f.useState)(``),[k,Pe]=(0,f.useState)([]),[A,Fe]=(0,f.useState)(new Set),j=(0,f.useRef)(!0),M=e=>{j.current&&Pe(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?ur(t,e):t)})},N=(0,f.useRef)(new mr),P=G({taskId:c,scope:u,detached:a,context:v,attachment:p.attachmentVersion,workspaceContext:p.workspace?.context??null,observationError:p.error??null});N.current.select(P);let[F,I]=(0,f.useState)(P);F!==P&&(I(P),je(!1),ke(void 0)),(0,f.useEffect)(()=>(j.current=!0,()=>{j.current=!1,N.current.depart()}),[]);let L=Oe?.preflight.preview.action.kind===`create`?p.workspace?.context.status===`available`?p.workspace.context.version:null:v,R=async e=>{let t=e.kind===`create`?p.workspace?.context.status===`available`?p.workspace.context.version:null:v;if(!p.actions||!t||Ae||a){Ne(`Current action context unavailable; observe again.`);return}N.current.depart();let r=N.current.ticket();je(!0),Ne(``);try{let i=await Hn(n.client,t,e);if(!N.current.current(r))return;i.kind===`error`?Ne(`Preflight refused: ${i.error.code}`):ke(i.value)}catch{N.current.current(r)&&Ne(`Preflight unavailable. No automatic retry.`)}finally{N.current.current(r)&&je(!1)}},z=e=>{N.current.depart(),ke(void 0),je(!1),l(e),d({kind:`task`,id:e}),ge(void 0),ye(void 0),re(`messages`),D(),history.replaceState(null,``,Ri(e))};(0,f.useEffect)(()=>{let e=()=>{let e=zi();e&&(N.current.depart(),ke(void 0),je(!1),l(e.taskId),d({kind:`task`,id:e.taskId}),ge(void 0),ye(e.cursor),re(`messages`),D())};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[D]);let B=e=>{N.current.depart(),ke(void 0),je(!1),d(e),ge(void 0),ye(void 0),re(e.kind===`task`?`runs`:`messages`),D()},V=m.state?.snapshot.committedSeq??p.workspace?.committedSeq,H=p.workspace?.storeId,U=u&&H&&V?{storeId:H,scope:u,snapshotSeq:V,reader:`messages`,after:null,limit:50}:null,W=u&&H&&V?{storeId:H,scope:u,snapshotSeq:V,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,Ie=_?m.state?.snapshot.runs??[]:[],Le=N.current.ticket(),Re=e=>{M(e),e.receipt&&N.current.current(Le)&&(p.refresh(),e.receipt.created?.state===`published`&&z(e.receipt.created.taskId))},ze=e=>{if(A.has(e)||!p.cancelCompatible||!p.activeRuns)return;let t=crypto.randomUUID(),r=p.activeRuns.epoch;Fe(t=>new Set(t).add(e)),M({commandId:t,error:`Stop requested; settlement is not yet confirmed.`}),n.client.cancel({commandId:t,epoch:r,runId:e}).then(e=>{Re(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:`${e.error.code}; cancellation effect ${e.error.effect}. Observe exact receipt.`})}).catch(()=>M({commandId:t,error:`Cancellation effect uncertain. Observe exact receipt.`})).finally(()=>{j.current&&Fe(t=>{let n=new Set(t);return n.delete(e),n})})};if(a)return(0,$.jsxs)(`main`,{className:`entry`,children:[(0,$.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h1`,{children:`Detached`}),(0,$.jsx)(`p`,{children:`Accepted service work continues. No Cancel was requested.`}),k.map(e=>(0,$.jsxs)(`p`,{children:[`Observe command after reconnect: `,(0,$.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,$.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>o(!1),children:`Reconnect as a viewer`})]});let Be=p.activeRuns,Ve=Be?.status===`complete`?Be.runs:[],He=m.state?.connection??(p.workspace?c?`Task snapshot not observed yet`:`No task selected`:`Service unavailable`);return(0,$.jsxs)(`div`,{className:`app`,children:[(0,$.jsxs)(`header`,{className:`topbar`,children:[(0,$.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":`Tasks`,onClick:()=>x(e=>e===`left`?null:`left`),children:(0,$.jsx)(ue,{"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{className:`topbar-flow`,children:[(0,$.jsxs)(`span`,{className:`brand`,children:[(0,$.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),p.workspace&&(0,$.jsxs)(`span`,{className:`chip static chip-root`,title:p.workspace.rootLabel,children:[(0,$.jsx)(_e,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:p.workspace.rootLabel})]}),(0,$.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,$.jsx)(`nav`,{className:`tb-tabs`,"aria-label":`Recorded views`,children:la.map(([e,t])=>(0,$.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-label":e,"aria-pressed":ne===e,onClick:()=>{ye(void 0),ge(void 0),re(e)},children:[(0,$.jsx)(t,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e})]},e))}),(0,$.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:`tb-actions`,children:[(0,$.jsx)(ui,{disabled:!W,onOpen:()=>le(!0)}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Export selected scope`,"data-tip":`Export selected scope`,disabled:!U,onClick:()=>me(!0),children:(0,$.jsx)(xe,{"aria-hidden":`true`})}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Copy token-free link`,"data-tip":`Copy token-free link`,disabled:!c,onClick:()=>{c&&Sr(Ri(c,ve)).then(e=>Ne(e?``:`Link copy unavailable.`))},children:(0,$.jsx)(pe,{"aria-hidden":`true`})}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Observe current state`,"data-tip":`Observe current state`,onClick:()=>{p.refresh(),m.refresh()},children:(0,$.jsx)(se,{"aria-hidden":`true`})}),(0,$.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":`Choose owner model`,"data-tip":`Choose owner model`,onClick:()=>i(!0),children:[(0,$.jsx)(Se,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`chip-label`,children:`Model`})]}),(0,$.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":`Return — work continues`,"data-tip":`Return — accepted work continues`,onClick:()=>{ke(void 0),x(null),le(!1),me(!1),N.current.depart(),je(!1),o(!0)},children:[(0,$.jsx)(de,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`chip-label`,children:`Return`})]})]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"aria-label":`Plan / review`,onClick:()=>x(e=>e===`right`?null:`right`),children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Plan`})]})]}),Ve.length>0&&(0,$.jsx)(`section`,{className:`run-strip`,"aria-label":`Execution and cancellation`,children:Ve.map(e=>(0,$.jsxs)(`div`,{className:`run-strip-row`,children:[(0,$.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`run-strip-label`,children:[e.kind,` `,e.runId,` · `,e.stage]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>z(e.taskId),children:`Open active task`}),(0,$.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!p.cancelCompatible||A.has(e.runId),onClick:()=>ze(e.runId),children:[(0,$.jsx)(ie,{"aria-hidden":`true`}),`Cancel run — request stop`]})]},e.runId))}),(Me||p.error)&&(0,$.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[Me||p.error,`. Explicit service guidance:`,` `,(0,$.jsx)(`code`,{children:`cadence-service status`}),` /`,` `,(0,$.jsx)(`code`,{children:`cadence-service start --workspace <path>`}),`. No service is started by this page.`]}),(0,$.jsxs)(`div`,{ref:C,className:`layout`,style:{"--left-w":`${w}px`,"--right-w":`${E}px`},children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Close drawer`,tabIndex:-1,className:`drawer-backdrop persistent${b?` on`:``}`,onClick:D}),(0,$.jsx)(`section`,{className:`panel-drawer drawer-left${b===`left`?` open`:``}`,"aria-label":`Task navigation drawer`,tabIndex:-1,inert:S&&b!==`left`,children:p.workspace&&(0,$.jsx)(Li,{client:n.client,workspace:p.workspace,taskId:c,runs:Ie,onTask:z,onScope:B,onNew:()=>{D(),Ce(!0)}})}),(0,$.jsx)(Vi,{side:`left`,width:w,onResize:T}),(0,$.jsxs)(`main`,{className:`main`,inert:S&&b!==null,children:[u&&(0,$.jsxs)(`p`,{className:`scope-bar`,children:[(0,$.jsx)(he,{"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`scope-kind`,children:[`Selected `,u.kind,`:`]}),(0,$.jsx)(`code`,{children:u.id}),(0,$.jsxs)(`span`,{children:[`· snapshot `,V,`.`]}),(0,$.jsx)(`span`,{className:`scope-hint`,children:`Pages and old outcomes are historical observations, not renewed consent.`})]}),(0,$.jsxs)(`div`,{className:`workspace-content`,children:[!U&&(0,$.jsxs)(`section`,{className:`empty-state`,children:[(0,$.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h2`,{children:`Open a task or create one explicitly`}),(0,$.jsx)(`p`,{children:`Plans, children, checks and human review share one service owner. No chat or discovery activates execution.`}),(0,$.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!p.workspace,onClick:()=>Ce(!0),children:[(0,$.jsx)(ce,{"aria-hidden":`true`}),`Create task`]})]}),U&&ve?(0,$.jsxs)(`div`,{className:`tab-body`,children:[O&&(O.owner.entity.kind===`task`||O.owner.entity.kind===`message`||O.owner.entity.kind===`tool`)&&(0,$.jsx)($r,{client:n.client,seed:{storeId:ve.storeId,scope:ve.scope,snapshotSeq:ve.snapshotSeq,kind:O.owner.entity.kind,id:O.owner.entity.id,version:O.owner.entity.version}},`${O.owner.entity.id}:${O.owner.entity.version}`),(0,$.jsx)(Xr,{client:n.client,cursor:ve,highlight:O?.range},`${ve.recordId}:${ve.recordVersion}`)]}):U&&(0,$.jsxs)(`div`,{className:ne===`messages`||ne===`tools`?`tab-body transcript-body`:`tab-body`,children:[ne===`messages`&&(0,$.jsx)(yi,{client:n.client,seed:U}),ne===`tools`&&(0,$.jsx)(da,{client:n.client,seed:U}),ne===`context`&&(0,$.jsx)(Qr,{client:n.client,seed:U}),ne===`timeline`&&(0,$.jsx)(sa,{client:n.client,seed:U,onSearch:()=>le(!0)}),ne===`runs`&&(0,$.jsx)(li,{client:n.client,seed:{...U,scope:{kind:`task`,id:c??U.scope.id}},onScope:B},c),ne===`outcomes`&&(Ie.length>0?Ie.map(e=>(0,$.jsx)(oi,{run:e},e.childRunId??e.runId)):(0,$.jsx)(`p`,{className:`panel-empty`,children:_&&m.state?`No owner run projection in this snapshot.`:`No snapshot observed yet; absence is not proof of settlement.`}))]})]}),p.workspace&&k.length>0&&(0,$.jsx)(`div`,{className:`receipt-dock`,children:k.map(e=>(0,$.jsx)(Lr,{client:n.client,value:e,onChange:M},e.commandId))})]}),(0,$.jsx)(Vi,{side:`right`,width:E,onResize:te}),(0,$.jsx)(`section`,{className:`panel-drawer drawer-right${b===`right`?` open`:``}`,"aria-label":`Plan and review drawer`,tabIndex:-1,inert:S&&b!==`right`,children:U?(0,$.jsx)(Fi,{client:n.client,context:v,seed:U,runs:Ie,canAct:y&&!Ae,onAction:e=>void R(e),planMetadata:g},c):(0,$.jsx)(Pi,{})})]}),(0,$.jsxs)(`footer`,{className:`statusbar`,children:[(0,$.jsxs)(`div`,{className:`statusbar-left`,children:[(0,$.jsxs)(`span`,{className:`status-item`,role:`status`,title:`Connection freshness is not execution outcome.`,children:[(0,$.jsx)(`span`,{className:`status-dot ${m.error||!p.workspace?`error`:m.transportStatus===`current`?m.state?m.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),He,` · transport ${m.transportStatus}`,m.error?` · ${m.error}`:``]}),(0,$.jsx)(`span`,{className:`status-item${Be?.status===`complete`?Ve.length>0?` warn`:``:` faint`}`,children:Be?.status===`complete`?Ve.length>0?`${Ve.length} active run${Ve.length===1?``:`s`}`:`No active runs`:`Active roster unavailable; absence is not proof of settlement.`}),(0,$.jsx)(`span`,{className:`status-item faint`,children:`Connection freshness is not execution outcome.`})]}),(0,$.jsx)(`div`,{className:`statusbar-right`,children:(0,$.jsxs)(`span`,{className:`status-item${p.compatible?` faint`:` warn`}`,title:ar?.buildId??`unbuilt source`,children:[(0,$.jsxs)(`span`,{className:`build-part`,children:[`Local browser build:`,` `,(0,$.jsx)(`code`,{children:ar?.buildId??`unbuilt source`}),`.`,` `]}),(0,$.jsxs)(`span`,{children:[`Shared compatibility:`,` `,p.compatible?`compatible`:`unavailable / mismatch — reload built assets; normal actions disabled`,`.`]})]})})]}),r&&(0,$.jsx)(Ir,{client:n.client,compatible:!!p.compatible&&p.transportStatus===`current`&&!p.error,onClose:()=>i(!1),onChanged:()=>{ke(void 0),N.current.depart(),p.refresh(!0)}}),be&&(0,$.jsxs)(hr,{title:`Create task`,onClose:()=>Ce(!1),children:[(0,$.jsxs)(`label`,{children:[`Kind`,(0,$.jsxs)(`select`,{"aria-label":`Kind`,value:Ee,onChange:e=>De(e.target.value===`research`?`research`:e.target.value===`diagnosis`?`diagnosis`:`code`),children:[(0,$.jsx)(`option`,{value:`code`,children:`Code`}),(0,$.jsx)(`option`,{value:`research`,children:`Readonly research`}),(0,$.jsx)(`option`,{value:`diagnosis`,children:`Readonly diagnosis`})]})]}),(0,$.jsxs)(`label`,{children:[`Goal`,(0,$.jsx)(`textarea`,{"aria-label":`Goal`,value:we,onChange:e=>Te(e.target.value),rows:6})]}),(0,$.jsx)(`footer`,{children:(0,$.jsx)(`button`,{type:`button`,className:`primary`,disabled:!p.actions||p.workspace?.context.status!==`available`||Ae||!we.trim(),onClick:()=>{Ce(!1),R({kind:`create`,taskKind:Ee,goal:we})},children:`Preview Create (does not Start)`})})]}),Oe&&(0,$.jsx)(Pr,{prepared:Oe,client:n.client,current:p.actions&&(y||Oe.preflight.preview.action.kind===`create`)?L:null,attachmentVersion:p.attachmentVersion,onClose:()=>{N.current.current(Le)&&(N.current.depart(),ke(e=>e===Oe?void 0:e))},onResult:Re},Oe.commandId),oe&&W&&(0,$.jsx)(ai,{client:n.client,seed:W,onClose:()=>le(!1),onHit:e=>{ge(e),ye(e.cursor),c&&history.replaceState(null,``,Ri(c,e.cursor))}}),fe&&W&&(0,$.jsx)(ni,{request:{storeId:W.storeId,scope:W.scope,snapshotSeq:W.snapshotSeq,format:`ndjson`},onClose:()=>me(!1)})]})}function da({client:e,seed:t}){let n=Hr(e,{...t,reader:`tools`}),r=n.page;return(0,$.jsxs)(`section`,{className:`tools-list`,children:[(0,$.jsx)(Zr,{pager:n}),(0,$.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,$.jsx)(xi,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var fa=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,$.jsxs)(`main`,{className:`entry`,children:[(0,$.jsx)(`h1`,{children:`Presentation unavailable`}),(0,$.jsx)(`p`,{children:`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Reload observation`})]}):this.props.children}},pa=document.getElementById(`root`);if(!pa)throw Error(`Application root unavailable`);(0,E.createRoot)(pa).render((0,$.jsx)(fa,{children:(0,$.jsx)(ua,{})}));export{oa as t};
7
+ `):e})]}),(0,$.jsx)(`p`,{className:`fp-notice`,children:`Captured page only, not a current filesystem read. Line numbers are page-local. Full retained paging and copy are available above.`}),(0,$.jsx)(`div`,{style:{fontSize:`${a}em`},children:t===`markdown`?(0,$.jsxs)(`div`,{className:`fp-toc-layout`,children:[Ei(s)&&(0,$.jsx)(`nav`,{className:`fp-toc`,"aria-label":`Page headings`,children:s.map(e=>(0,$.jsx)(`button`,{type:`button`,className:`l${e.level}`,onClick:()=>p.current?.querySelector(`#${CSS.escape(`preview-${e.id}`)}`)?.scrollIntoView({block:`nearest`}),children:e.label},e.id))}),(0,$.jsx)(`div`,{className:`fp-markdown-zoom`,ref:p,children:(0,$.jsx)(Ar,{text:e})})]}):t===`diff`?(0,$.jsx)(Oi,{text:e}):(0,$.jsx)(`div`,{className:`fp-code ${r?``:`no-wrap`}`,children:Di(e).map(({text:e,number:t,key:n})=>(0,$.jsxs)(`div`,{className:`fp-line ${l&&t>=l.start&&t<=l.end?`sel`:``}`,children:[(0,$.jsx)(`button`,{type:`button`,className:`fp-num`,"aria-label":`Select page line ${t}`,onClick:e=>{e.shiftKey||(d.current=t),u({start:Math.min(d.current,t),end:Math.max(d.current,t)})},children:t}),(0,$.jsx)(`span`,{className:`fp-code-text`,children:e||` `})]},n))})}),l&&(0,$.jsxs)(`footer`,{className:`fp-foot`,children:[`Selected page lines `,l.start,`–`,l.end,(0,$.jsx)(`button`,{type:`button`,onClick:()=>u(null),children:`Clear selection`})]})]})}function Ai({client:e,seed:t}){let n=Hr(e,t),[r,i]=(0,f.useState)(),a=n.page;return(0,$.jsxs)(`section`,{className:`scm-body`,children:[(0,$.jsx)(Zr,{pager:n}),(0,$.jsx)(`p`,{children:`Captured observations include pre-existing dirt. They do not attribute every change to Cadence; bounded fingerprints are not filesystem snapshots.`}),(0,$.jsx)(`div`,{className:`scm-files-list`,children:a&&!(`kind`in a)&&a.records.map(e=>{if(e.kind!==`owner-fact`)return null;let t=e.fact,n=t.kind===`changes`||t.kind===`review`?t.content:t.kind===`check-settled`?t.output:null;return(0,$.jsxs)(`article`,{className:`scm-file`,children:[(0,$.jsxs)(`h3`,{children:[t.kind,` · committed #`,e.committedSeq]}),(0,$.jsx)(`pre`,{children:JSON.stringify(t,null,2)}),n&&(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{a.request.scope.kind!==`workspace`&&a.request.snapshotSeq!==null&&i(Br(a.request.storeId,a.request.scope,a.request.snapshotSeq,n))},children:[`Inspect full retained `,n.field]})]},e.recordId)})}),r&&(0,$.jsx)(Xr,{client:e,cursor:r,render:e=>(0,$.jsx)(ki,{text:e})},`${r.recordId}:${r.recordVersion}`)]})}function ji({client:e,taskId:t,seed:n,canAct:r,onAction:i,onObligations:a}){let[o,s]=(0,f.useState)(),[c,l]=(0,f.useState)(),[u,d]=(0,f.useState)(0),p=(0,f.useRef)(u);return p.current=u,(0,f.useEffect)(()=>{let n=u,r=new AbortController,i=!0;return s(void 0),e.checkObligations(t,r.signal).then(e=>{i&&p.current===n&&(e.kind===`error`?l(e.error.code):(l(void 0),s(e.value),a(e.value)))}).catch(()=>{i&&l(`Obligations unavailable.`)}),()=>{r.abort(),i=!1}},[e,t,u,a]),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{children:`Current configured obligations`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>d(e=>e+1),children:`Observe obligations`}),c&&(0,$.jsxs)(`p`,{role:`alert`,children:[`Obligations unavailable: `,c]}),o?.definitions.length===0&&(0,$.jsx)(`p`,{children:`No configured obligations. This is not passing check coverage.`}),o?.definitions.map(e=>(0,$.jsxs)(`article`,{children:[(0,$.jsxs)(`h4`,{children:[e.selection.name,`: `,e.status]}),(0,$.jsx)(`pre`,{children:e.selection.command}),(0,$.jsxs)(`p`,{children:[`Timeout `,e.selection.timeoutMs,` ms. Native outcome and freshness remain separate.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>i({kind:`check`,taskId:t,check:e.selection}),children:`Preview exact configured check`})]},e.selection.name)),(0,$.jsx)(`p`,{children:`Browser checks are configured selections only. Native-local manual commands are not a browser shell endpoint.`}),(0,$.jsx)(Ai,{client:e,seed:{...n,reader:`checks`}})]})}function Mi({client:e,storeId:t,taskId:n}){let[r,i]=(0,f.useState)(),[a,o]=(0,f.useState)(``),[s,c]=(0,f.useState)(0);return(0,f.useEffect)(()=>{if(s<0)return;let r=new AbortController;return i(void 0),o(``),e.currentChanges({storeId:t,taskId:n},r.signal).then(e=>{r.signal.aborted||(e.kind===`ok`?i(e.value):o(e.error.code))}).catch(()=>{r.signal.aborted||o(`Current observation unavailable`)}),()=>r.abort()},[e,t,n,s]),(0,$.jsxs)(`section`,{"aria-label":`Current checkout changes`,children:[(0,$.jsx)(`h3`,{children:`Current checkout changes (not a captured historical diff)`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(e=>e+1),children:`Observe current changes`}),a&&(0,$.jsx)(`p`,{role:`alert`,children:a}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`p`,{children:[`Fingerprint `,(0,$.jsx)(`code`,{children:r.observation.identity}),` ·`,` `,r.observation.complete?`complete within bounded scope`:`incomplete coverage`,` `,`· includes pre-existing dirt; not attribution.`]}),(0,$.jsx)(`pre`,{children:JSON.stringify(r.coverage)}),(0,$.jsx)(ki,{text:r.text})]})]})}var Ni=[[`plan`,ve],[`checks`,ke],[`changes`,O],[`review`,D]];function Pi(){return(0,$.jsx)(`aside`,{className:`panel panel-right`,children:(0,$.jsx)(`p`,{className:`panel-empty`,children:`Select a task to inspect plans, checks, changes and review.`})})}function Fi({client:e,context:t,seed:n,runs:r,canAct:i,onAction:a,planMetadata:o}){let s=t?G(t):`unavailable`,c=(0,f.useMemo)(()=>s===`unavailable`?null:Qe(Le(s)),[s]),[l,u]=(0,f.useState)(`plan`),[d,p]=(0,f.useState)({readablePlan:``,assignments:[]}),[m,h]=(0,f.useState)(),[g,_]=(0,f.useState)(),[v,y]=(0,f.useState)(),[b,x]=(0,f.useState)(),[S,ee]=(0,f.useState)(``),[C,w]=(0,f.useState)(!1),T=c?.task?.id??(n.scope.kind===`task`?n.scope.id:null),E=(0,f.useRef)(new mr);E.current.select(G({context:c,tab:l,draft:d,canAct:i})),(0,f.useEffect)(()=>()=>E.current.depart(),[]),(0,f.useEffect)(()=>{let e=!0;if(_(void 0),h(void 0),!o||!c)y(cr);else return o.read(c).then(t=>{e&&(t.kind===`error`?y(t.error.code):G(t.value.context)===s?(`kind`in t.value?h(t.value):_(t.value),y(void 0)):y(`Owner metadata is stale.`))}).catch(()=>{e&&y(`Owner metadata unavailable.`)}),()=>{e=!1}},[o,c,s]);let te=(0,f.useCallback)(e=>x(e),[]);if(!T)return(0,$.jsx)(Pi,{});let D={...n,scope:{kind:`task`,id:T}};return(0,$.jsxs)(`aside`,{className:`panel panel-right`,children:[(0,$.jsx)(`nav`,{className:`rp-tabs`,"aria-label":`Inspector`,children:Ni.map(([e,t])=>(0,$.jsxs)(`button`,{type:`button`,className:`rp-tab`,"aria-label":e,"aria-pressed":l===e,onClick:()=>u(e),children:[(0,$.jsx)(t,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e})]},e))}),(0,$.jsxs)(`div`,{className:`inspector-body`,children:[l===`plan`&&(0,$.jsxs)($.Fragment,{children:[v&&(0,$.jsx)(`p`,{className:`inspector-note`,role:`status`,children:v}),m&&(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`p`,{children:[`Saved graph proof in progress.`,` `,JSON.stringify(m.coverage)]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{if(!o||!c)return;let e=E.current.ticket();o.read(c,m.next).then(t=>{E.current.current(e)&&(t.kind===`error`?y(t.error.code):`kind`in t.value?h(t.value):(h(void 0),_(t.value)))})},children:`Continue saved graph read`})]}),g&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>p({readablePlan:g.readablePlan,assignments:g.savedGraph?.assignments??[]}),children:`Load observed saved plan into local draft`}),c?(0,$.jsx)(Si,{draft:d,onChange:p,context:c,roles:g?.roles??null,canAct:i,canSave:i&&!!g&&g.editable!==!1&&!!o,onGenerate:()=>a({kind:`generate-plan`,taskId:T}),onStart:()=>a({kind:`start`,taskId:T}),onSave:()=>{if(!o)return;let e=E.current.ticket();o.saveAction(c,structuredClone(d)).then(t=>{E.current.current(e)&&(t.kind===`error`?y(t.error.code):a(t.value))}).catch(()=>{E.current.current(e)&&y(`Plan proposal unavailable.`)})}}):(0,$.jsx)(`p`,{children:`Current control context unavailable. Historical data is not action authority.`})]}),l===`checks`&&(0,$.jsx)(ji,{client:e,taskId:T,seed:D,canAct:i,onAction:a,onObligations:te}),l===`changes`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Mi,{client:e,storeId:n.storeId,taskId:T}),(0,$.jsx)(`h3`,{children:`Captured historical observations`}),(0,$.jsx)(Ai,{client:e,seed:{...D,reader:`changes`}})]}),l===`review`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`h3`,{children:`Human review`}),(0,$.jsx)(`p`,{children:`Done records human acknowledgment, not execution success or certification. It cannot restart a blocked episode.`}),(0,$.jsxs)(`label`,{children:[`Episode to review`,(0,$.jsxs)(`select`,{value:S,onChange:e=>ee(e.target.value),children:[(0,$.jsx)(`option`,{value:``,children:`Select an observed episode`}),r.filter(e=>e.childRunId===null&&e.admission.kind!==`check`).map(e=>(0,$.jsxs)(`option`,{value:e.runId,children:[e.runId,` · `,e.outcome??e.lifecycle]},e.runId))]})]}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:C,onChange:e=>w(e.target.checked)}),`I acknowledge current unresolved issues if present; original results will not be rewritten.`]}),(0,$.jsx)(`button`,{type:`button`,disabled:!i||!c||!b||b.taskId!==T||!S,onClick:()=>{c&&b&&a({kind:`review`,taskId:T,runId:S,changesIdentity:c.observation.identity,checksRevision:b.revision,acceptIssues:C})},children:`Preview human review / Done`}),!b&&(0,$.jsx)(`p`,{children:`Observe current obligations in Checks before requesting review.`}),(0,$.jsx)(Ai,{client:e,seed:{...D,reader:`reviews`}})]})]})]})}function Ii(e,t=new Set){let n=new Map(e.map(e=>[e.id,e])),r=new Map,i=[];for(let t of e)if(t.parentId&&n.has(t.parentId)){let e=r.get(t.parentId)??[];e.push(t),r.set(t.parentId,e)}else i.push(t);let a=e=>{let t=[],n=[...r.get(e)??[]],i=new Set;for(;n.length>0;){let e=n.shift();if(!e)break;if(i.has(e.id))continue;i.add(e.id),t.push(e);let a=r.get(e.id);a&&n.push(...a)}return t},o=[],s=new Set,c=new Set,l=(e,n)=>{if(s.has(e.id)||c.has(e.id))return;s.add(e.id);let i=r.get(e.id)??[],u=i.length>0,d=u&&t.has(e.id),f=0,p=!1,m=!1,h=!1;if(u){let t=a(e.id);if(f=t.length,p=t.some(e=>e.active),m=t.some(e=>e.failed),h=t.some(e=>e.unknown),d)for(let e of t)c.add(e.id)}if(o.push({c:e,depth:n,hasKids:u,isCollapsed:d,descendantCount:f,hasActive:p,hasFailure:m,hasUnknown:h}),!d)for(let e of i)l(e,n+1)};for(let e of i)l(e,0);for(let t of e)l(t,0);return o}function Li({client:e,workspace:t,taskId:n,runs:r,onTask:i,onScope:a,onNew:o}){let s=Hr(e,{reader:`tasks`,storeId:t.storeId,scope:{kind:`workspace`,id:t.workspaceId},snapshotSeq:null,after:null,limit:50}),[c,l]=(0,f.useState)(new Set),u=(0,f.useMemo)(()=>Ii(r.map(e=>({id:e.childRunId??e.runId,parentId:e.childRunId?e.runId:null,label:e.assignmentId??e.admission.kind,active:e.lifecycle!==`settled`,failed:e.outcome===`failed`,unknown:e.outcome===`unknown`})),c),[r,c]),d=s.page&&!(`kind`in s.page)?s.page.records:null,p=d?.filter(e=>e.kind===`task`).length,m=p===void 0?``:` (${p}${s.page&&!(`kind`in s.page)&&s.page.next||s.canPrevious?`+`:``})`;return(0,$.jsxs)(`aside`,{className:`panel panel-left lp-panel`,children:[(0,$.jsxs)(`section`,{className:`lp-section grow`,children:[(0,$.jsxs)(`header`,{className:`lp-section-header`,children:[(0,$.jsxs)(`h2`,{className:`lp-section-title`,children:[`Tasks`,m]}),(0,$.jsx)(`div`,{className:`lp-section-actions`,children:(0,$.jsx)(`button`,{type:`button`,className:`lp-section-action`,"aria-label":`New task`,title:`New task`,onClick:o,children:(0,$.jsx)(ce,{"aria-hidden":`true`})})})]}),(0,$.jsxs)(`nav`,{"aria-label":`Tasks`,className:`lp-section-body task-list`,children:[d?.map(e=>e.kind===`task`?(0,$.jsxs)(`button`,{type:`button`,className:`session-item${e.owner.taskId===n?` active`:``}`,"aria-current":e.owner.taskId===n?`true`:void 0,title:e.goal,onClick:()=>i(e.owner.taskId),children:[(0,$.jsx)(`span`,{className:`session-icon`,children:(0,$.jsx)(ve,{"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`session-info`,children:[(0,$.jsx)(`span`,{className:`session-title`,children:e.goal}),` `,(0,$.jsxs)(`span`,{className:`session-sub`,children:[e.owner.taskId,` · v`,e.version]})]})]},e.owner.taskId):null),p===0&&(0,$.jsx)(`p`,{className:`panel-empty`,children:`No retained task on this page.`}),(0,$.jsx)(Zr,{pager:s})]}),(0,$.jsx)(`p`,{className:`panel-hint`,children:`One checkout owner. Open/history never executes.`})]}),n&&(0,$.jsxs)(`section`,{className:`lp-section episodes`,children:[(0,$.jsx)(`header`,{className:`lp-section-header`,children:(0,$.jsx)(`h3`,{className:`lp-section-title`,children:`Active and recent episodes`})}),(0,$.jsxs)(`div`,{className:`lp-section-body`,children:[(0,$.jsxs)(`nav`,{"aria-label":`Runs and assignments`,children:[u.map(e=>{let t=e.c.failed?`failed`:e.c.unknown?`unknown`:e.c.active?`active`:`settled`;return(0,$.jsxs)(`div`,{className:`ep-row`,style:{paddingInlineStart:`${e.depth*16}px`},children:[e.hasKids?(0,$.jsx)(`button`,{type:`button`,className:`ep-toggle`,"aria-label":`Toggle assignments`,"aria-expanded":!e.isCollapsed,onClick:()=>l(t=>{let n=new Set(t);return n.has(e.c.id)?n.delete(e.c.id):n.add(e.c.id),n}),children:e.isCollapsed?(0,$.jsx)(Ee,{"aria-hidden":`true`}):(0,$.jsx)(De,{"aria-hidden":`true`})}):(0,$.jsx)(`span`,{className:`ep-toggle-spacer`,"aria-hidden":`true`}),(0,$.jsxs)(`button`,{type:`button`,className:`session-item`,onClick:()=>a({kind:e.c.parentId?`child`:`run`,id:e.c.id}),children:[(0,$.jsxs)(`span`,{className:`session-info`,children:[(0,$.jsx)(`span`,{className:`session-title`,children:e.c.label}),e.isCollapsed&&` `,e.isCollapsed&&(0,$.jsx)(`span`,{className:`session-sub session-outcome`,children:`${e.descendantCount} descendants${e.hasFailure?` / failed child`:``}${e.hasUnknown?` / unknown child`:``}`})]}),` `,(0,$.jsx)(`span`,{className:`ep-state ${t}`,children:t})]})]},e.c.id)}),u.length===0&&(0,$.jsx)(`p`,{className:`panel-empty`,children:`No active or recent episode observed.`})]}),(0,$.jsxs)(`button`,{type:`button`,className:`ghost ep-all`,onClick:()=>a({kind:`task`,id:n}),children:[(0,$.jsx)(fe,{"aria-hidden":`true`}),`All retained episodes for task`]})]})]})]})}function Ri(e,t){let n=new URL(window.location.origin+window.location.pathname),r=new URLSearchParams({task:V(e)});if(t){let{navigation:e,...n}=t;r.set(`detail`,JSON.stringify(n))}return n.hash=r.toString(),n.href}function zi(){try{let e=new URLSearchParams(window.location.hash.slice(1)),t=V(e.get(`task`)),n=e.get(`detail`);if(!n)return{taskId:t};let r=Y(Le(n));return r.navigation?null:{taskId:t,cursor:r}}catch{return null}}function Bi(e){let t=e.start.above+e.start.below,n=Math.max(1,e.availablePx)/(e.totalWeight>0?e.totalWeight:1),r=e.minAbovePx/n,i=e.minBelowPx/n;if(r+i>=t){let n=e.minAbovePx+e.minBelowPx||1,r=t*e.minAbovePx/n;return{above:r,below:t-r}}let a=Math.min(t-i,Math.max(r,e.start.above+e.deltaPx/n));return{above:a,below:t-a}}function Vi({side:e,width:t,onResize:n}){let r=(0,f.useRef)(void 0);return(0,f.useEffect)(()=>()=>r.current?.(),[]),(0,$.jsx)(`input`,{type:`range`,min:220,max:600,step:20,value:t,onChange:e=>n(Number(e.target.value)),className:`resize-handle`,tabIndex:0,"aria-orientation":`vertical`,"aria-label":`Resize ${e} pane`,"aria-valuemin":220,"aria-valuemax":600,"aria-valuenow":t,onDoubleClick:()=>n(e===`left`?260:360),onPointerDown:i=>{i.preventDefault(),r.current?.();let a=i.clientX,o=window.innerWidth,s=r=>{let i=Bi({start:{above:t,below:Math.max(1,o-t)},deltaPx:(r.clientX-a)*(e===`left`?1:-1),availablePx:o,totalWeight:o,minAbovePx:220,minBelowPx:320});n(Math.min(600,i.above))},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r.current=void 0};r.current=c,window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c,{once:!0}),window.addEventListener(`pointercancel`,c,{once:!0})}})}function Hi(e,t,n,r){(0,f.useEffect)(()=>{if(!n||!t)return;let i=e.current?.querySelector(`.drawer-${t}`),a=document.activeElement,o=()=>Array.from(i?.querySelectorAll(`button:not(:disabled),input,textarea,select,a[href],[tabindex="0"]`)??[]).filter(e=>e.getClientRects().length>0);(o()[0]??i)?.focus();let s=e=>{if(e.key===`Escape`&&(e.preventDefault(),r()),e.key===`Tab`){let t=o(),n=t[0],r=t[t.length-1];if(!n){e.preventDefault();return}e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus())}};return i?.addEventListener(`keydown`,s),()=>{i?.removeEventListener(`keydown`,s),a instanceof HTMLElement&&a.isConnected&&a.focus()}},[e,t,n,r])}var Ui=.4,Wi=1.05;function Gi(e){return Math.min(300,e*.86)}function Ki(e,t,n){return n||(t<=144?null:e<=72?`left`:t-e<=72?`right`:null)}function qi(e,t){let n=Math.abs(e),r=Math.abs(t);return n<12&&r<12?`none`:n>r*1.2?`horizontal`:`vertical`}function Ji(e,t){return e===`left`?t:-t}function Yi(e,t){return Math.max(-e,Math.min(0,-e+t))}function Xi(e,t,n){let r=n?e+t:t;return Math.max(0,Math.min(1,r/e))}function Zi(e){let{wasOpen:t,pull:n,width:r,durationMs:i}=e;return i<=320&&Math.abs(n)>=48?n>0:Xi(r*Wi,n,t)>=Ui}var Qi=new Set([`auto`,`scroll`,`overlay`]);function $i(e,t){let n=e instanceof Element?e:null;for(;n;){if(n instanceof HTMLElement&&n.scrollWidth>n.clientWidth+4&&Qi.has(getComputedStyle(n).overflowX))return!0;if(n===t)break;n=n.parentElement}return!1}function ea(){let e=e=>{e.stopPropagation(),e.preventDefault()};window.addEventListener(`click`,e,{capture:!0,once:!0}),setTimeout(()=>window.removeEventListener(`click`,e,{capture:!0}),400)}function ta(e){let{enabled:t,open:n,onOpenChange:r,container:i}=e,{panelSelector:a,backdropSelector:o}=e;(0,f.useEffect)(()=>{let e=i.current;if(!t||!e)return;let s=null,c=`none`,l=0,u=0,d=0,f=0,p=!1,m=0,h=0,g=null,_=null,v=()=>{g&&(g.classList.remove(`drawer-dragging`),g.style.transform=``),_&&(_.style.opacity=``),s=null,c=`none`,g=null,_=null,f=0,p=!1},y=t=>{if(v(),t.touches.length!==1)return;let r=t.touches[0];if(!r)return;let i=Ki(r.clientX,window.innerWidth,n);i&&!$i(t.target,e)&&(s=i,l=r.clientX,u=r.clientY,d=Date.now())},b=t=>{let r=s;if(!r||t.touches.length!==1)return;let i=t.touches[0];if(!i)return;let d=i.clientX-l,v=i.clientY-u;if(c===`none`){let t=qi(d,v);if(t===`none`)return;if(t===`vertical`){s=null;return}c=`horizontal`,p=n===r,m=Gi(window.innerWidth),h=m*Wi;let i=e.querySelector(a?a(r):`.panel-drawer.drawer-${r}`);if(!i){s=null;return}g=i,_=o===null?null:e.querySelector(o??`.drawer-backdrop`),i.classList.add(`drawer-dragging`)}let y=g;if(!y)return;f=Ji(r,d);let b=Yi(h,p?h+f:f);y.style.transform=`translateX(${r===`left`?b:-b}px)`,_&&(_.style.opacity=String(Xi(h,f,p))),t.preventDefault()},x=()=>{let e=s,t=c===`horizontal`&&e!==null&&g!==null,i=f,a=Date.now()-d,o=t?Zi({wasOpen:p,pull:i,width:m,durationMs:a}):!1;v(),t&&e&&o!==(n===e)&&(ea(),r(o?e:null))},S=()=>v();return e.addEventListener(`touchstart`,y,{passive:!0}),e.addEventListener(`touchmove`,b,{passive:!1}),e.addEventListener(`touchend`,x),e.addEventListener(`touchcancel`,S),()=>{v(),e.removeEventListener(`touchstart`,y),e.removeEventListener(`touchmove`,b),e.removeEventListener(`touchend`,x),e.removeEventListener(`touchcancel`,S)}},[t,n,r,i,a,o])}function na(e,t,n,r){let i=t.filter(e=>e.kind===`owner-fact`||e.kind===`capture-fact`),a=i.map((e,t)=>{let n=e.kind===`owner-fact`?e.fact.kind:e.capture.event.kind,r=e.kind===`capture-fact`?e.link.childRunId:null,i=n.startsWith(`tool`)?`tools`:n.startsWith(`message`)?`model`:`input`;return{key:e.recordId,lane:i,group:`${r??`owner`}:${i}`,groupLabel:`${r??`Owner`} · ${i}`,kind:i===`tools`?`tool`:i===`model`?`text`:`system`,title:`#${e.committedSeq} ${n}`,summary:n,source:`Committed #${e.committedSeq}; ${r??`owner`}`,status:`recorded fact`,clock:e.kind===`capture-fact`?`Worker-local monotonic observations (${e.link.childRunId}): ${e.capture.source.firstObservedMs}–${e.capture.source.lastObservedMs} ms; not aligned to other workers.`:`Owner observation (${e.link.epoch}): ${e.observedMs} ms; clock origin not established by this reader.`,...e.kind===`owner-fact`&&e.fact.kind===`check-settled`?{dur:e.fact.native.durationMs}:{},t:t*1e3,end:t*1e3}}),o;return{onData(e){return o=e,()=>{o=void 0}},readState(){o?.({kind:`state`,conversations:[{id:e,title:`${e} — loaded committed page`,isStreaming:!1,segCount:a.length}],activeId:e})},readSegments(t){t===e&&o?.({kind:`segs`,convId:t,segs:a,reset:!0})},readSegment(t,n){let r=a.findIndex(e=>e.key===n);t!==e||r<0||o?.({kind:`seg_detail`,convId:t,key:n,seg:a[r],detail:JSON.stringify(i[r],null,2),analysis:{position:`Committed sequence ${i[r].committedSeq}; page ordinal ${r+1}. Timing shown in raw facts only; clocks may not be comparable.`}})},openDetail(t,r){let a=i.find(e=>e.recordId===r);t===e&&a&&n(a)},searchHistory:r}}var ra=`modulepreload`,ia=function(e){return`/`+e},aa={},oa=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=ia(t,n),t=s(t),t in aa)return;aa[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:ra,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function sa({client:e,seed:t,onSearch:n}){let r=Hr(e,{...t,reader:`events`}),i=r.page;return(0,$.jsxs)(`section`,{className:`timeline-view`,children:[(0,$.jsx)(`p`,{children:`Committed order, not wall time. Replay advances visualization only. Raw observations retain clock/sequence provenance; unknown timing is not reconstructed.`}),(0,$.jsx)(Zr,{pager:r}),i&&!(`kind`in i)&&(0,$.jsx)(ca,{client:e,seed:i.request,records:i.records,onSearch:n},`${i.request.snapshotSeq}:${i.request.after?.recordId??`first`}`)]})}function ca({client:e,seed:t,records:n,onSearch:r}){let i=(0,f.useRef)(null),[a,o]=(0,f.useState)(!1),[s,c]=(0,f.useState)(!1),l=(0,f.useRef)(r);return l.current=r,(0,f.useEffect)(()=>{let e=!1,r;return oa(()=>import(`./timeline-client.js`).then(a=>{!e&&i.current&&(r=a.default.mount(i.current,na(t.scope.id,n,()=>o(!0),()=>l.current())))}),[]).catch(()=>{e||c(!0)}),()=>{e=!0,r?.()}},[n,t.scope.id]),(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsx)(`p`,{role:`alert`,children:`Bundled timeline unavailable; retained events remain accessible, no CDN fallback.`}),(0,$.jsx)(`div`,{className:`timeline-mount`,ref:i}),a&&(0,$.jsx)(Qr,{client:e,seed:t})]})}var la=[[`messages`,le],[`tools`,re],[`context`,me],[`timeline`,we],[`runs`,ge],[`outcomes`,Ae]];function ua({api:e,planMetadata:t}){let[n]=(0,f.useState)(()=>e??or()),[r,i]=(0,f.useState)(!1),[a,o]=(0,f.useState)(!1),[s]=(0,f.useState)(zi),[c,l]=(0,f.useState)(s?.taskId??null),[u,d]=(0,f.useState)(s?{kind:`task`,id:s.taskId}:null),p=pr(n,c?{kind:`task`,id:c}:null,!a),m={state:p.observation,transportStatus:p.transportStatus,error:p.error,refresh:p.refresh},h=p.workspace?.storeId,g=(0,f.useMemo)(()=>t??(h?lr(n.client,h):void 0),[t,n,h]),_=m.state?.snapshot.scope.kind===`task`&&m.state.snapshot.scope.id===c?m.state.snapshot.context:void 0,v=_?.status===`available`?_.version:null,y=p.actions&&m.state?.connection===`current`&&m.transportStatus===`current`&&!!v&&v.epoch===p.workspace?.epoch,[b,x]=(0,f.useState)(null),[S,ee]=(0,f.useState)(!1),C=(0,f.useRef)(null),[w,T]=(0,f.useState)(260),[E,te]=(0,f.useState)(360),D=(0,f.useCallback)(()=>x(null),[]);(0,f.useEffect)(()=>{let e=matchMedia(`(max-width: 900px)`),t=()=>ee(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),ta({enabled:S&&!a,open:b,onOpenChange:x,container:C}),Hi(C,b,S&&!a,D);let[ne,re]=(0,f.useState)(`messages`),[oe,le]=(0,f.useState)(!1),[fe,me]=(0,f.useState)(!1),[O,ge]=(0,f.useState)(),[ve,ye]=(0,f.useState)(s?.cursor),[be,Ce]=(0,f.useState)(!1),[we,Te]=(0,f.useState)(``),[Ee,De]=(0,f.useState)(`code`),[Oe,ke]=(0,f.useState)(),[Ae,je]=(0,f.useState)(!1),[Me,Ne]=(0,f.useState)(``),[k,Pe]=(0,f.useState)([]),[A,Fe]=(0,f.useState)(new Set),j=(0,f.useRef)(!0),M=e=>{j.current&&Pe(t=>{let n=t.findIndex(t=>t.commandId===e.commandId);return n<0?[...t,e]:t.map((t,r)=>r===n?ur(t,e):t)})},N=(0,f.useRef)(new mr),P=G({taskId:c,scope:u,detached:a,context:v,attachment:p.attachmentVersion,workspaceContext:p.workspace?.context??null,observationError:p.error??null});N.current.select(P);let[F,I]=(0,f.useState)(P);F!==P&&(I(P),je(!1),ke(void 0)),(0,f.useEffect)(()=>(j.current=!0,()=>{j.current=!1,N.current.depart()}),[]);let L=Oe?.preflight.preview.action.kind===`create`?p.workspace?.context.status===`available`?p.workspace.context.version:null:v,R=async e=>{let t=e.kind===`create`?p.workspace?.context.status===`available`?p.workspace.context.version:null:v;if(!p.actions||!t||Ae||a){Ne(`Current action context unavailable; observe again.`);return}N.current.depart();let r=N.current.ticket();je(!0),Ne(``);try{let i=await Hn(n.client,t,e);if(!N.current.current(r))return;i.kind===`error`?Ne(`Preflight refused: ${i.error.code}`):ke(i.value)}catch{N.current.current(r)&&Ne(`Preflight unavailable. No automatic retry.`)}finally{N.current.current(r)&&je(!1)}},z=e=>{N.current.depart(),ke(void 0),je(!1),l(e),d({kind:`task`,id:e}),ge(void 0),ye(void 0),re(`messages`),D(),history.replaceState(null,``,Ri(e))};(0,f.useEffect)(()=>{let e=()=>{let e=zi();e&&(N.current.depart(),ke(void 0),je(!1),l(e.taskId),d({kind:`task`,id:e.taskId}),ge(void 0),ye(e.cursor),re(`messages`),D())};return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[D]);let B=e=>{N.current.depart(),ke(void 0),je(!1),d(e),ge(void 0),ye(void 0),re(e.kind===`task`?`runs`:`messages`),D()},V=m.state?.snapshot.committedSeq??p.workspace?.committedSeq,H=p.workspace?.storeId,U=u&&H&&V?{storeId:H,scope:u,snapshotSeq:V,reader:`messages`,after:null,limit:50}:null,W=u&&H&&V?{storeId:H,scope:u,snapshotSeq:V,query:null,recordId:null,recordVersion:null,field:null,offset:0}:null,Ie=_?m.state?.snapshot.runs??[]:[],Le=N.current.ticket(),Re=e=>{M(e),e.receipt&&N.current.current(Le)&&(p.refresh(),e.receipt.created?.state===`published`&&z(e.receipt.created.taskId))},ze=e=>{if(A.has(e)||!p.cancelCompatible||!p.activeRuns)return;let t=crypto.randomUUID(),r=p.activeRuns.epoch;Fe(t=>new Set(t).add(e)),M({commandId:t,error:`Stop requested; settlement is not yet confirmed.`}),n.client.cancel({commandId:t,epoch:r,runId:e}).then(e=>{Re(e.kind===`ok`?{commandId:t,receipt:e.value}:{commandId:t,error:`${e.error.code}; cancellation effect ${e.error.effect}. Observe exact receipt.`})}).catch(()=>M({commandId:t,error:`Cancellation effect uncertain. Observe exact receipt.`})).finally(()=>{j.current&&Fe(t=>{let n=new Set(t);return n.delete(e),n})})};if(a)return(0,$.jsxs)(`main`,{className:`entry`,children:[(0,$.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h1`,{children:`Detached`}),(0,$.jsx)(`p`,{children:`Accepted service work continues. No Cancel was requested.`}),k.map(e=>(0,$.jsxs)(`p`,{children:[`Observe command after reconnect: `,(0,$.jsx)(`code`,{children:e.commandId})]},e.commandId)),(0,$.jsx)(`button`,{type:`button`,className:`primary`,onClick:()=>o(!1),children:`Reconnect as a viewer`})]});let Be=p.activeRuns,Ve=Be?.status===`complete`?Be.runs:[],He=m.state?.connection??(p.workspace?c?`Task snapshot not observed yet`:`No task selected`:`Service unavailable`);return(0,$.jsxs)(`div`,{className:`app`,children:[(0,$.jsxs)(`header`,{className:`topbar`,children:[(0,$.jsx)(`button`,{type:`button`,className:`panel-toggle`,"aria-label":`Tasks`,onClick:()=>x(e=>e===`left`?null:`left`),children:(0,$.jsx)(ue,{"aria-hidden":`true`})}),(0,$.jsxs)(`div`,{className:`topbar-flow`,children:[(0,$.jsxs)(`span`,{className:`brand`,children:[(0,$.jsx)(`span`,{className:`brand-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h1`,{className:`brand-name`,children:`Cadence`})]}),p.workspace&&(0,$.jsxs)(`span`,{className:`chip static chip-root`,title:p.workspace.rootLabel,children:[(0,$.jsx)(_e,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:p.workspace.rootLabel})]}),(0,$.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,$.jsx)(`nav`,{className:`tb-tabs`,"aria-label":`Recorded views`,children:la.map(([e,t])=>(0,$.jsxs)(`button`,{type:`button`,className:`tb-tab`,"aria-label":e,"aria-pressed":ne===e,onClick:()=>{ye(void 0),ge(void 0),re(e)},children:[(0,$.jsx)(t,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:e})]},e))}),(0,$.jsx)(`span`,{className:`tb-spacer`,"aria-hidden":`true`}),(0,$.jsxs)(`div`,{className:`tb-actions`,children:[(0,$.jsx)(ui,{disabled:!W,onOpen:()=>le(!0)}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Export selected scope`,"data-tip":`Export selected scope`,disabled:!U,onClick:()=>me(!0),children:(0,$.jsx)(xe,{"aria-hidden":`true`})}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Copy token-free link`,"data-tip":`Copy token-free link`,disabled:!c,onClick:()=>{c&&Sr(Ri(c,ve)).then(e=>Ne(e?``:`Link copy unavailable.`))},children:(0,$.jsx)(pe,{"aria-hidden":`true`})}),(0,$.jsx)(`button`,{type:`button`,className:`chip`,"aria-label":`Observe current state`,"data-tip":`Observe current state`,onClick:()=>{p.refresh(),m.refresh()},children:(0,$.jsx)(se,{"aria-hidden":`true`})}),(0,$.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":`Choose owner model`,"data-tip":`Choose owner model`,onClick:()=>i(!0),children:[(0,$.jsx)(Se,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`chip-label`,children:`Model`})]}),(0,$.jsxs)(`button`,{type:`button`,className:`chip`,"aria-label":`Return — work continues`,"data-tip":`Return — accepted work continues`,onClick:()=>{ke(void 0),x(null),le(!1),me(!1),N.current.depart(),je(!1),o(!0)},children:[(0,$.jsx)(de,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`chip-label`,children:`Return`})]})]})]}),(0,$.jsxs)(`button`,{type:`button`,className:`panel-toggle has-label`,"aria-label":`Plan / review`,onClick:()=>x(e=>e===`right`?null:`right`),children:[(0,$.jsx)(ae,{"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:`Plan`})]})]}),Ve.length>0&&(0,$.jsx)(`section`,{className:`run-strip`,"aria-label":`Execution and cancellation`,children:Ve.map(e=>(0,$.jsxs)(`div`,{className:`run-strip-row`,children:[(0,$.jsx)(`span`,{className:`status-dot busy`,"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`run-strip-label`,children:[e.kind,` `,e.runId,` · `,e.stage]}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>z(e.taskId),children:`Open active task`}),(0,$.jsxs)(`button`,{type:`button`,className:`danger`,disabled:!p.cancelCompatible||A.has(e.runId),onClick:()=>ze(e.runId),children:[(0,$.jsx)(ie,{"aria-hidden":`true`}),`Cancel run — request stop`]})]},e.runId))}),(Me||p.error)&&(0,$.jsxs)(`p`,{className:`banner-notice`,role:`alert`,children:[Me||p.error,`.`,` `,!Me&&p.error===`stale`&&(0,$.jsxs)($.Fragment,{children:[`The service no longer matches the sources it loaded, for example after Pi's `,(0,$.jsx)(`code`,{children:`models.json`}),` changed; restart it to reload them: `,(0,$.jsx)(`code`,{children:`systemctl --user restart cadence`}),` (or`,` `,(0,$.jsx)(`code`,{children:`cadence-service stop`}),` then `,(0,$.jsx)(`code`,{children:`start`}),`).`,` `]}),`Explicit service guidance: `,(0,$.jsx)(`code`,{children:`cadence-service status`}),` /`,` `,(0,$.jsx)(`code`,{children:`cadence-service start --workspace <path>`}),`. No service is started by this page.`]}),(0,$.jsxs)(`div`,{ref:C,className:`layout`,style:{"--left-w":`${w}px`,"--right-w":`${E}px`},children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":`Close drawer`,tabIndex:-1,className:`drawer-backdrop persistent${b?` on`:``}`,onClick:D}),(0,$.jsx)(`section`,{className:`panel-drawer drawer-left${b===`left`?` open`:``}`,"aria-label":`Task navigation drawer`,tabIndex:-1,inert:S&&b!==`left`,children:p.workspace&&(0,$.jsx)(Li,{client:n.client,workspace:p.workspace,taskId:c,runs:Ie,onTask:z,onScope:B,onNew:()=>{D(),Ce(!0)}})}),(0,$.jsx)(Vi,{side:`left`,width:w,onResize:T}),(0,$.jsxs)(`main`,{className:`main`,inert:S&&b!==null,children:[u&&(0,$.jsxs)(`p`,{className:`scope-bar`,children:[(0,$.jsx)(he,{"aria-hidden":`true`}),(0,$.jsxs)(`span`,{className:`scope-kind`,children:[`Selected `,u.kind,`:`]}),(0,$.jsx)(`code`,{children:u.id}),(0,$.jsxs)(`span`,{children:[`· snapshot `,V,`.`]}),(0,$.jsx)(`span`,{className:`scope-hint`,children:`Pages and old outcomes are historical observations, not renewed consent.`})]}),(0,$.jsxs)(`div`,{className:`workspace-content`,children:[!U&&(0,$.jsxs)(`section`,{className:`empty-state`,children:[(0,$.jsx)(`span`,{className:`empty-logo`,"aria-hidden":`true`,children:`C`}),(0,$.jsx)(`h2`,{children:`Open a task or create one explicitly`}),(0,$.jsx)(`p`,{children:`Plans, children, checks and human review share one service owner. No chat or discovery activates execution.`}),(0,$.jsxs)(`button`,{type:`button`,className:`primary`,disabled:!p.workspace,onClick:()=>Ce(!0),children:[(0,$.jsx)(ce,{"aria-hidden":`true`}),`Create task`]})]}),U&&ve?(0,$.jsxs)(`div`,{className:`tab-body`,children:[O&&(O.owner.entity.kind===`task`||O.owner.entity.kind===`message`||O.owner.entity.kind===`tool`)&&(0,$.jsx)($r,{client:n.client,seed:{storeId:ve.storeId,scope:ve.scope,snapshotSeq:ve.snapshotSeq,kind:O.owner.entity.kind,id:O.owner.entity.id,version:O.owner.entity.version}},`${O.owner.entity.id}:${O.owner.entity.version}`),(0,$.jsx)(Xr,{client:n.client,cursor:ve,highlight:O?.range},`${ve.recordId}:${ve.recordVersion}`)]}):U&&(0,$.jsxs)(`div`,{className:ne===`messages`||ne===`tools`?`tab-body transcript-body`:`tab-body`,children:[ne===`messages`&&(0,$.jsx)(yi,{client:n.client,seed:U}),ne===`tools`&&(0,$.jsx)(da,{client:n.client,seed:U}),ne===`context`&&(0,$.jsx)(Qr,{client:n.client,seed:U}),ne===`timeline`&&(0,$.jsx)(sa,{client:n.client,seed:U,onSearch:()=>le(!0)}),ne===`runs`&&(0,$.jsx)(li,{client:n.client,seed:{...U,scope:{kind:`task`,id:c??U.scope.id}},onScope:B},c),ne===`outcomes`&&(Ie.length>0?Ie.map(e=>(0,$.jsx)(oi,{run:e},e.childRunId??e.runId)):(0,$.jsx)(`p`,{className:`panel-empty`,children:_&&m.state?`No owner run projection in this snapshot.`:`No snapshot observed yet; absence is not proof of settlement.`}))]})]}),p.workspace&&k.length>0&&(0,$.jsx)(`div`,{className:`receipt-dock`,children:k.map(e=>(0,$.jsx)(Lr,{client:n.client,value:e,onChange:M},e.commandId))})]}),(0,$.jsx)(Vi,{side:`right`,width:E,onResize:te}),(0,$.jsx)(`section`,{className:`panel-drawer drawer-right${b===`right`?` open`:``}`,"aria-label":`Plan and review drawer`,tabIndex:-1,inert:S&&b!==`right`,children:U?(0,$.jsx)(Fi,{client:n.client,context:v,seed:U,runs:Ie,canAct:y&&!Ae,onAction:e=>void R(e),planMetadata:g},c):(0,$.jsx)(Pi,{})})]}),(0,$.jsxs)(`footer`,{className:`statusbar`,children:[(0,$.jsxs)(`div`,{className:`statusbar-left`,children:[(0,$.jsxs)(`span`,{className:`status-item`,role:`status`,title:`Connection freshness is not execution outcome.`,children:[(0,$.jsx)(`span`,{className:`status-dot ${m.error||!p.workspace?`error`:m.transportStatus===`current`?m.state?m.state.connection===`current`?`ok`:`busy`:``:`busy`}`,"aria-hidden":`true`}),He,` · transport ${m.transportStatus}`,m.error?` · ${m.error}`:``]}),(0,$.jsx)(`span`,{className:`status-item${Be?.status===`complete`?Ve.length>0?` warn`:``:` faint`}`,children:Be?.status===`complete`?Ve.length>0?`${Ve.length} active run${Ve.length===1?``:`s`}`:`No active runs`:`Active roster unavailable; absence is not proof of settlement.`}),(0,$.jsx)(`span`,{className:`status-item faint`,children:`Connection freshness is not execution outcome.`})]}),(0,$.jsx)(`div`,{className:`statusbar-right`,children:(0,$.jsxs)(`span`,{className:`status-item${p.compatible?` faint`:` warn`}`,title:ar?.buildId??`unbuilt source`,children:[(0,$.jsxs)(`span`,{className:`build-part`,children:[`Local browser build:`,` `,(0,$.jsx)(`code`,{children:ar?.buildId??`unbuilt source`}),`.`,` `]}),(0,$.jsxs)(`span`,{children:[`Shared compatibility:`,` `,p.compatible?`compatible`:`unavailable / mismatch — reload built assets; normal actions disabled`,`.`]})]})})]}),r&&(0,$.jsx)(Ir,{client:n.client,compatible:!!p.compatible&&p.transportStatus===`current`&&!p.error,onClose:()=>i(!1),onChanged:()=>{ke(void 0),N.current.depart(),p.refresh(!0)}}),be&&(0,$.jsxs)(hr,{title:`Create task`,onClose:()=>Ce(!1),children:[(0,$.jsxs)(`label`,{children:[`Kind`,(0,$.jsxs)(`select`,{"aria-label":`Kind`,value:Ee,onChange:e=>De(e.target.value===`research`?`research`:e.target.value===`diagnosis`?`diagnosis`:`code`),children:[(0,$.jsx)(`option`,{value:`code`,children:`Code`}),(0,$.jsx)(`option`,{value:`research`,children:`Readonly research`}),(0,$.jsx)(`option`,{value:`diagnosis`,children:`Readonly diagnosis`})]})]}),(0,$.jsxs)(`label`,{children:[`Goal`,(0,$.jsx)(`textarea`,{"aria-label":`Goal`,value:we,onChange:e=>Te(e.target.value),rows:6})]}),(0,$.jsx)(`footer`,{children:(0,$.jsx)(`button`,{type:`button`,className:`primary`,disabled:!p.actions||p.workspace?.context.status!==`available`||Ae||!we.trim(),onClick:()=>{Ce(!1),R({kind:`create`,taskKind:Ee,goal:we})},children:`Preview Create (does not Start)`})})]}),Oe&&(0,$.jsx)(Pr,{prepared:Oe,client:n.client,current:p.actions&&(y||Oe.preflight.preview.action.kind===`create`)?L:null,attachmentVersion:p.attachmentVersion,onClose:()=>{N.current.current(Le)&&(N.current.depart(),ke(e=>e===Oe?void 0:e))},onResult:Re},Oe.commandId),oe&&W&&(0,$.jsx)(ai,{client:n.client,seed:W,onClose:()=>le(!1),onHit:e=>{ge(e),ye(e.cursor),c&&history.replaceState(null,``,Ri(c,e.cursor))}}),fe&&W&&(0,$.jsx)(ni,{request:{storeId:W.storeId,scope:W.scope,snapshotSeq:W.snapshotSeq,format:`ndjson`},onClose:()=>me(!1)})]})}function da({client:e,seed:t}){let n=Hr(e,{...t,reader:`tools`}),r=n.page;return(0,$.jsxs)(`section`,{className:`tools-list`,children:[(0,$.jsx)(Zr,{pager:n}),(0,$.jsx)(`div`,{className:`tools-body`,children:r&&!(`kind`in r)&&r.records.map(t=>t.kind===`tool`?(0,$.jsx)(xi,{record:t,client:e,seed:r.request},`${t.owner.entity.id}:${t.version}`):null)})]})}var fa=class extends f.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){return this.state.failed?(0,$.jsxs)(`main`,{className:`entry`,children:[(0,$.jsx)(`h1`,{children:`Presentation unavailable`}),(0,$.jsx)(`p`,{children:`No execution result is inferred. Reconnect to observe the owner; accepted work continues.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),children:`Reload observation`})]}):this.props.children}},pa=document.getElementById(`root`);if(!pa)throw Error(`Application root unavailable`);(0,E.createRoot)(pa).render((0,$.jsx)(fa,{children:(0,$.jsx)(ua,{})}));export{oa as t};
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": "cadence-web-assets/1",
3
- "sourceHash": "c389e2006852275c06ea853030cb2c9f62e65eaa6b57c9557d43573833144dbb",
4
- "contractHash": "e7e5248f8273a373827ac70d2d8be1d5aaea1e329379e59e4947fc10f82be818",
5
- "buildId": "0bd45aeadc0810d97310596dbfd28f75669e4832c401b52622ac9f9eac01f585",
3
+ "sourceHash": "b35385d2798537203cc68b5993d893bdb77b1140df35bb11b1251187c5e68236",
4
+ "contractHash": "ff017feffc6b6b4521e470d82514d0ca008e15472fa1442ec498b243b0f7cf87",
5
+ "buildId": "357c2882237d27e66e1dcec38c95f7c3d578ecdfce90b74db8ad50c9ef70c5ee",
6
6
  "assets": [
7
7
  {
8
8
  "name": "assets/cadence.css",
@@ -73,8 +73,8 @@
73
73
  },
74
74
  {
75
75
  "name": "assets/cadence.js",
76
- "bytes": 187360,
77
- "sha256": "6349b72e6cbf474c285d37cdf63f14ab9ac929db89b09c7c168b1189be84bc41",
76
+ "bytes": 187728,
77
+ "sha256": "3c88a77fff85dfc7127da357d4bebc74af95b03a129f60cd44f29f972bcd7c33",
78
78
  "references": [
79
79
  "assets/markdown.js",
80
80
  "assets/react.js",