@coreplane/switchboard 1.234.0 → 1.235.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/assets/deploy/cloudflare-resident/gc.ts +6 -9
  2. package/dist/assets/deploy/cloudflare-resident/worker.ts +125 -78
  3. package/dist/assets/deploy/cloudflare-sandbox/worker.ts +82 -13
  4. package/dist/assets/package-lock.json +3 -3
  5. package/dist/assets/package.json +1 -1
  6. package/dist/assets/source.json +3 -3
  7. package/dist/assets/src/core/runEvents.ts +7 -0
  8. package/dist/assets/src/execution/residentCleanliness.ts +24 -0
  9. package/dist/assets/src/execution/residentDiskBudget.ts +7 -6
  10. package/dist/assets/src/execution/sandboxErrors.ts +5 -0
  11. package/dist/assets/src/execution/sandboxIdle.ts +220 -0
  12. package/dist/assets/web/dist/.vite/manifest.json +26 -25
  13. package/dist/assets/web/dist/assets/{ResidentDetailPage-C_WNBUao.js → ResidentDetailPage-DSpsye5e.js} +1 -1
  14. package/dist/assets/web/dist/assets/{ResidentsIndexPage-D1sTyaZ_.js → ResidentsIndexPage-CT8fI1M3.js} +1 -1
  15. package/dist/assets/web/dist/assets/RunFoldRow-Cqh8pTXC.js +9 -0
  16. package/dist/assets/web/dist/assets/RunRoutePage-oN9GkVEA.js +6 -0
  17. package/dist/assets/web/dist/assets/{RunsIndexPage-H6GkSv0a.js → RunsIndexPage-sjXr8iCV.js} +1 -1
  18. package/dist/assets/web/dist/assets/{ScheduledPage-BLcPzm1S.js → ScheduledPage-Tz__zLzi.js} +1 -1
  19. package/dist/assets/web/dist/assets/{StatusDot-Ct6AtHhS.js → StatusDot-D14iJMy7.js} +1 -1
  20. package/dist/assets/web/dist/assets/{Tooltip-qol5Boof.js → Tooltip-B0Ob5MQ4.js} +1 -1
  21. package/dist/assets/web/dist/assets/UnitRoutePage-CbKCL58v.js +1 -0
  22. package/dist/assets/web/dist/assets/{dist-DwtJj-ou.js → dist-pOdUzj6D.js} +1 -1
  23. package/dist/assets/web/dist/assets/{main-CRtlGxRm.js → main-D3lG-yQ9.js} +2 -2
  24. package/dist/cli.js +84 -25
  25. package/package.json +1 -1
  26. package/dist/assets/web/dist/assets/RunFoldRow-C_bcTSjA.js +0 -5
  27. package/dist/assets/web/dist/assets/RunRoutePage-BWTi_6PG.js +0 -10
  28. package/dist/assets/web/dist/assets/UnitRoutePage-CIhTEwN7.js +0 -1
package/dist/cli.js CHANGED
@@ -32280,6 +32280,16 @@ function openCodeFactsOf(v) {
32280
32280
  function factsBelongTo(harness, facts2) {
32281
32281
  return facts2.harness === harness.name;
32282
32282
  }
32283
+ function openThroughSeam(harness, deps, run2) {
32284
+ const facts2 = run2.resume?.facts;
32285
+ if (facts2 !== void 0 && !factsBelongTo(harness, facts2)) {
32286
+ const mismatch = new HarnessMismatchError(harness.name, facts2.harness);
32287
+ run2.onProgress?.(mismatch.message);
32288
+ run2.onEvent?.({ type: "run_note", kind: "harness_error", summary: mismatch.message });
32289
+ return Promise.reject(mismatch);
32290
+ }
32291
+ return harness.open(deps, run2);
32292
+ }
32283
32293
  var isRecord3, relaunchesOf, isPiFacts, HarnessInterruptedError, HarnessMismatchError;
32284
32294
  var init_contract4 = __esm({
32285
32295
  "../../src/core/harness/contract.ts"() {
@@ -32930,7 +32940,7 @@ var init_botHostContainer = __esm({
32930
32940
  }
32931
32941
  });
32932
32942
 
32933
- // ../../src/core/harness/pi/windDown.ts
32943
+ // ../../src/core/harness/windDown.ts
32934
32944
  function elapsedMinutes(ms) {
32935
32945
  const minutes = Math.round(ms / 6e4);
32936
32946
  if (minutes < 1) return "under a minute";
@@ -32938,7 +32948,7 @@ function elapsedMinutes(ms) {
32938
32948
  }
32939
32949
  var HARD_STOP_MESSAGE, wrapUpNote, wrapUpInstruction, WRITE_UP_REQUEST, timeBudgetInstruction, turnGuardInstruction, SOFT_STOP_INSTRUCTION, turnGuardPace, timeBudgetNote, turnGuardNote, softStopNote, hardStopNote, timeBudgetAnswer, turnGuardAnswer, softStopAnswer;
32940
32950
  var init_windDown = __esm({
32941
- "../../src/core/harness/pi/windDown.ts"() {
32951
+ "../../src/core/harness/windDown.ts"() {
32942
32952
  "use strict";
32943
32953
  HARD_STOP_MESSAGE = "\u26D4 Run aborted by an operator (hard stop). No summary was written; partial work may exist in the workspace.";
32944
32954
  wrapUpNote = (minutesLeft) => `~${minutesLeft} min left \u2014 signaling wrap-up`;
@@ -33616,6 +33626,9 @@ var init_mirror = __esm({
33616
33626
  deps;
33617
33627
  idx;
33618
33628
  pendingUser = [];
33629
+ /** The row of the last assistant turn the ledger holds — written here, or
33630
+ * met again on a re-attach (`alreadyHeld`); undefined until one is. */
33631
+ lastAssistantIdx;
33619
33632
  /** pi is about to echo the seed's prompt as a user message (see `expectSeedEcho`). */
33620
33633
  seedEchoPending = false;
33621
33634
  mirroredTail;
@@ -33626,6 +33639,19 @@ var init_mirror = __esm({
33626
33639
  get wired() {
33627
33640
  return this.deps.onStep !== void 0;
33628
33641
  }
33642
+ /** The row (the run's own index) the calls under way ride in — the last
33643
+ * assistant turn the ledger holds — for the `tool_call` stamp (run-history
33644
+ * item 53); undefined before any assistant turn, or when the transcript's
33645
+ * tail met again was a compaction and the turn before it is not known here. */
33646
+ get rowOfCalls() {
33647
+ return this.lastAssistantIdx;
33648
+ }
33649
+ /** The row the results pending now will make (the run's own index): the
33650
+ * next row written, since pending results and a steer's text go first in
33651
+ * the next step's turns — for the `tool_result` stamp. */
33652
+ get rowOfResults() {
33653
+ return this.idx;
33654
+ }
33629
33655
  /** pi answered the seed's prompt: the first user message without results
33630
33656
  * that follows is its echo — the seed, on the ledger already — and is not
33631
33657
  * written twice. A continue prompt (harness-pi item 8) expects none: its
@@ -33643,6 +33669,7 @@ var init_mirror = __esm({
33643
33669
  this.mirroredTail = void 0;
33644
33670
  if (!isDeepStrictEqual(row, tail)) return false;
33645
33671
  this.pendingUser = [];
33672
+ if ("turn" in row) this.lastAssistantIdx = this.idx - 1;
33646
33673
  return true;
33647
33674
  }
33648
33675
  /** Feeds one finished message; answers whether the ledger now holds
@@ -33678,6 +33705,7 @@ var init_mirror = __esm({
33678
33705
  inboxConsumedSeq: this.inboxConsumedSeq
33679
33706
  };
33680
33707
  this.idx += turns.length;
33708
+ this.lastAssistantIdx = this.idx - 1;
33681
33709
  await this.deps.onStep(report2);
33682
33710
  return true;
33683
33711
  }
@@ -34037,7 +34065,11 @@ async function runPiHarnessOpen(deps, run2) {
34037
34065
  }
34038
34066
  const agentSpan = run2.span?.start("run.agent");
34039
34067
  if (agentSpan) deps.bearers?.reparent(run2.runId, agentSpan);
34040
- const emit = (event) => run2.onEvent?.(event.at === void 0 ? { ...event, at: now() } : event);
34068
+ let placed = (event) => event;
34069
+ const emit = (event) => {
34070
+ const stamped = placed(event);
34071
+ run2.onEvent?.(stamped.at === void 0 ? { ...stamped, at: now() } : stamped);
34072
+ };
34041
34073
  const note = (kind, summary, mode) => {
34042
34074
  run2.onProgress?.(summary);
34043
34075
  emit({ type: "run_note", kind, summary, ...mode ? { mode } : {} });
@@ -34091,6 +34123,13 @@ async function runPiHarnessOpen(deps, run2) {
34091
34123
  ...tail ? { mirroredTail: tail } : {}
34092
34124
  });
34093
34125
  mirror.inboxConsumedSeq = run2.resume?.inboxConsumedSeq ?? 0;
34126
+ placed = (event) => {
34127
+ const logIndexOf = run2.logIndexOf;
34128
+ if (!logIndexOf || event.type !== "tool_call" && event.type !== "tool_result") return event;
34129
+ const row = event.type === "tool_call" ? mirror.rowOfCalls : mirror.rowOfResults;
34130
+ const logIndex = row === void 0 ? void 0 : logIndexOf(row);
34131
+ return logIndex === void 0 ? event : { ...event, logIndex };
34132
+ };
34094
34133
  let writeUp;
34095
34134
  let writeUpAt;
34096
34135
  let hardStopped = false;
@@ -35794,12 +35833,6 @@ async function runLoop(deps, ctx) {
35794
35833
  );
35795
35834
  if (ctx.bearer === void 0)
35796
35835
  throw new Error("the pi harness needs the run's model-proxy bearer, and this process minted none");
35797
- if (facts2 !== void 0 && !factsBelongTo(harnessDeps.harness, facts2)) {
35798
- const mismatch = new HarnessMismatchError(harnessDeps.harness.name, facts2.harness);
35799
- onProgress(mismatch.message);
35800
- onEvent({ type: "run_note", kind: "harness_error", summary: mismatch.message });
35801
- throw mismatch;
35802
- }
35803
35836
  const { provider: providerName, model: modelId } = parseModelRef(resolved.modelRef);
35804
35837
  const providerCfg = deps.config.config.providers[providerName];
35805
35838
  if (!providerCfg) throw new Error(`the pi harness found no provider named ${providerName} in the config`);
@@ -35812,7 +35845,8 @@ async function runLoop(deps, ctx) {
35812
35845
  )
35813
35846
  )
35814
35847
  ];
35815
- harnessSession = await harnessDeps.harness.open(
35848
+ harnessSession = await openThroughSeam(
35849
+ harnessDeps.harness,
35816
35850
  {
35817
35851
  container: harnessDeps.containerFor?.(executor, profile.machine) ?? harnessContainerFor(executor, profile.machine),
35818
35852
  bearer: ctx.bearer,
@@ -35848,6 +35882,7 @@ async function runLoop(deps, ctx) {
35848
35882
  onProgress,
35849
35883
  ...ledgerRun ? {
35850
35884
  onStep: ledgerRun.step.bind(ledgerRun),
35885
+ logIndexOf: ledgerRun.logIndexOf.bind(ledgerRun),
35851
35886
  saveFacts: (h) => ledgerRun.setState({ harness: h })
35852
35887
  } : {},
35853
35888
  ...reentry ? {
@@ -38701,6 +38736,16 @@ function createLedgerWriteThrough(opts) {
38701
38736
  get session() {
38702
38737
  return this.sessionRow;
38703
38738
  }
38739
+ /** Every row at its log index (session-log item 2): the run's local index
38740
+ * plus where its seed began; a run without a session writes its own
38741
+ * object from 0. The one arithmetic the seed, every step and `logIndexOf`
38742
+ * share. */
38743
+ rowIndex(localIndex) {
38744
+ return (this.sessionRow?.seedFrom ?? 0) + localIndex;
38745
+ }
38746
+ logIndexOf(localIndex) {
38747
+ return this.sessionRow ? this.rowIndex(localIndex) : void 0;
38748
+ }
38704
38749
  /** Turns of the run's conversation on the ledger, counted from its seed —
38705
38750
  * the last step record's `turnIndex` — so the finish can close the range. */
38706
38751
  turnsWritten;
@@ -38811,9 +38856,8 @@ function createLedgerWriteThrough(opts) {
38811
38856
  * no record at all was killed before its conversation was stored and
38812
38857
  * closes `interrupted`. */
38813
38858
  async seed(messages, budgetMs) {
38814
- const base = this.sessionRow?.seedFrom ?? 0;
38815
38859
  const reused = this.sessionRow && this.sessionRow.range !== "broken" ? this.sessionRow.range.from - this.sessionRow.seedFrom : 0;
38816
- const turns = messages.slice(reused).map((message3, i) => ({ idx: base + reused + i, message: message3 }));
38860
+ const turns = messages.slice(reused).map((message3, i) => ({ idx: this.rowIndex(reused + i), message: message3 }));
38817
38861
  try {
38818
38862
  const seeded = await ledger.seed(this.runId, gen, turns, this.sessionRow?.key);
38819
38863
  if (!seeded.ok) {
@@ -38845,10 +38889,12 @@ function createLedgerWriteThrough(opts) {
38845
38889
  }
38846
38890
  async step(report2) {
38847
38891
  if (this.detached) return;
38848
- const base = this.sessionRow?.seedFrom ?? 0;
38849
- const turns = report2.turns.map((message3, i) => ({ idx: base + report2.firstIdx + i, message: message3 }));
38892
+ const turns = report2.turns.map((message3, i) => ({
38893
+ idx: this.rowIndex(report2.firstIdx + i),
38894
+ message: message3
38895
+ }));
38850
38896
  if (report2.compaction)
38851
- turns.push({ idx: base + report2.firstIdx + report2.turns.length, compaction: report2.compaction });
38897
+ turns.push({ idx: this.rowIndex(report2.firstIdx + report2.turns.length), compaction: report2.compaction });
38852
38898
  const record2 = {
38853
38899
  step: ++this.stepNo,
38854
38900
  seq: this.lastSeq,
@@ -39134,6 +39180,9 @@ var init_writeThrough = __esm({
39134
39180
  tracked() {
39135
39181
  return false;
39136
39182
  }
39183
+ logIndexOf(_localIndex) {
39184
+ return void 0;
39185
+ }
39137
39186
  async step(_report) {
39138
39187
  }
39139
39188
  event(_event, _seq) {
@@ -41848,24 +41897,34 @@ var init_lookups = __esm({
41848
41897
  // ../../src/channels/slack/requester.ts
41849
41898
  function textOfBlocks(blocks) {
41850
41899
  if (!blocks) return "";
41851
- const out = [];
41852
- const walk2 = (b) => {
41853
- if (typeof b.text === "string") out.push(b.text);
41854
- else if (b.text && typeof b.text.text === "string") out.push(b.text.text);
41855
- for (const e of b.elements ?? []) walk2(e);
41856
- };
41900
+ const lines = [];
41857
41901
  for (const b of blocks) {
41858
- const before = out.length;
41902
+ const parts = [];
41903
+ const walk2 = (e) => {
41904
+ if (typeof e.text === "string") parts.push(e.text);
41905
+ else if (e.text && typeof e.text.text === "string") parts.push(e.text.text);
41906
+ else if (typeof e.url === "string") parts.push(e.url);
41907
+ else if (typeof e.user_id === "string") parts.push(`<@${e.user_id}>`);
41908
+ for (const c of e.elements ?? []) walk2(c);
41909
+ };
41859
41910
  walk2(b);
41860
- if (out.length > before) out.push("\n");
41911
+ const line3 = parts.join(b.type === "context" ? " " : "").trim();
41912
+ if (line3) lines.push(line3);
41861
41913
  }
41862
- return out.join("").replace(/\n+$/, "");
41914
+ return lines.join("\n");
41915
+ }
41916
+ function plainWordsOf(text) {
41917
+ return text.replace(/<@[A-Z0-9]+(?:\|[^>]*)?>/g, " ").replace(/<(https?:\/\/[^|>\s]+)\|([^>]*)>/g, "$2").replace(/<(https?:\/\/[^|>\s]+)>/g, "$1").replace(/https?:\/\//g, "").replace(/\s+/g, " ").trim();
41863
41918
  }
41864
41919
  function rawTextOf(text, blocks) {
41865
41920
  const base = text ?? "";
41866
41921
  const fromBlocks = textOfBlocks(blocks);
41867
41922
  if (!fromBlocks) return base;
41868
- const extra = fromBlocks.split("\n").map((l) => l.trim()).filter((l) => l.length > 0 && !base.includes(l));
41923
+ const known = plainWordsOf(base);
41924
+ const extra = fromBlocks.split("\n").filter((line3) => {
41925
+ const words = plainWordsOf(line3);
41926
+ return words.length > 0 && !known.includes(words);
41927
+ });
41869
41928
  return extra.length > 0 ? `${base}
41870
41929
  ${extra.join("\n")}` : base;
41871
41930
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreplane/switchboard",
3
- "version": "1.234.0",
3
+ "version": "1.235.0",
4
4
  "description": "Mention it in Slack and an agent reviews the PR, ships the fix, or answers the question — on the model you choose, with its tools running where you decide.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://openswitchboard.dev",
@@ -1,5 +0,0 @@
1
- import{n as e,r as t}from"./AppShell-lYVcj-k7.js";import{Ci as n,Mr as r,Qn as i,Wt as a,Xt as o,_n as s,ci as c,cn as l,gn as u,ir as d,ln as f,oi as p,on as m,sn as h,un as g,ur as _,vi as v,wi as y,xi as b,yn as x}from"./seed-DeKSHrt2.js";import{n as S}from"./wallClock-61NpVkY6.js";import{t as C}from"./StatusDot-Ct6AtHhS.js";import{r as w,t as T}from"./indexFormat-B-pd4r7Y.js";import{A as E,D,E as O,O as k,T as A,a as j,b as M,c as N,g as P,l as F,m as ee,o as I,t as L,v as te,w as ne,y as re}from"./indexRow-Bnj883ii.js";var ie={},ae={viewBox:`0 0 16 16`,class:`inline-block size-[1em] shrink-0`,"aria-hidden":`true`};function oe(e,t){return d(),g(`svg`,ae,[...t[0]||=[h(`path`,{fill:`currentColor`,d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z`},null,-1)]])}var se=t(ie,[[`render`,oe]]);function ce(){let e=[],t=null,n=0,r=[];function i(e){return typeof e==`number`&&isFinite(e)?e:void 0}function a(e){return typeof e==`string`?e:``}function o(n){let r={index:e.length,calls:[]};return n&&(r.narration=n),e.push(r),t=r,r}function s(e){return e<1e3?String(e):e<1e6?(Math.round(e/100)/10).toFixed(1)+`k`:(Math.round(e/1e5)/10).toFixed(1)+`M`}function c(e){let t=/\((\d+) chars(?:, (\d+) lines)?\)$/.exec(e.summary);if(t)return t[2]?Number(t[2]):1;if(e.output)return e.output.split(`
2
- `).length}function l(e){let t=[],n=e.result;if(!n)return t;n.infra?t.push(`sandbox error`):e.shell?t.push(n.exitCode===void 0?n.ok?`exit 0`:`error`:`exit `+n.exitCode):n.ok||t.push(`error`);let r=c(n);return r!==void 0&&r>1&&t.push(r+` lines`),e.durationMs!==void 0&&t.push(E(e.durationMs,`precise`)),t}function u(e,t){let n={ok:t.ok===!0,infra:t.infra===!0,summary:a(t.summary),output:a(t.output),at:i(t.at)},o=i(t.exitCode);o!==void 0&&(n.exitCode=o),e.result=n;let s=r.indexOf(e);s!==-1&&r.splice(s,1),e.status=n.infra?`infra`:n.ok?`ok`:`failed`,e.status!==`ok`&&(e.tags=e.tags.concat(e.status)),e.startedAt!==void 0&&n.at!==void 0&&n.at>=e.startedAt&&(e.durationMs=n.at-e.startedAt),e.facts=l(e)}let d=[[`tests`,/\b(npm|pnpm|yarn|bun)\s+(run\s+)?test\b|\b(vitest|jest|pytest|mocha|go test|cargo test)\b/],[`build`,/\b(npm|pnpm|yarn|bun)\s+run\s+(build|typecheck|lint)\b|\b(tsc|make|cargo build|go build|eslint|prettier)\b/],[`install`,/\b(npm|pnpm|yarn|bun)\s+(i|install|ci|add)\b|\bpip3?\s+install\b|\bapt(-get)?\s+install\b|\bbrew\s+install\b/],[`git`,/(^|[\s;&|(])(git|gh)\s/],[`network`,/(^|[\s;&|(])(curl|wget)\s/],[`read`,/(^|[\s;&|(])(cat|sed|head|tail|less|ls|find|grep|rg|wc|tree|pwd|echo|env|which|stat|file|diff)\b/]];function f(e){let t=e.replace(/^(\s*cd\s+("[^"]*"|'[^']*'|\S+)\s*(&&|;)\s*)+/,``);return t.trim()?t:e}function p(e){let t=f(e);for(let[e,n]of d)if(n.test(t))return e;return`shell`}function m(e,t){let n=t?f(e):e,r=n.indexOf(`
3
- `),i=r===-1?n:n.slice(0,r).trimEnd();return i.length<e.length?i+` …`:i}function h(e,t){let o=a(e.tool),s=o===`bash`,c=t||o,l=s&&c.startsWith(`$ `)?c.slice(2):!s&&c.startsWith(o+` `)?c.slice(o.length+1):c,u={id:a(e.callId)||`c`+ ++n,tool:o,title:l,headline:m(l,s),shell:s,quiet:o===`update_status`,tags:[s?p(l):o],status:`running`,startedAt:i(e.at),facts:[]};return r.push(u),u}function g(t){for(let n=e.length-1;n>=0;n--)for(let r of e[n].calls)if(r.id===t)return{step:e[n],call:r};return null}function _(t){let n=a(t.callId);if(!n)return null;for(let t=e.length-1;t>=0;t--)for(let r of e[t].calls)if(r.id===n&&!r.result)return{step:e[t],call:r};return null}function v(e){if(!e||typeof e!=`object`)return[];let n=e;switch(n.type){case`input`:{let e={kind:`input`,text:a(n.text),messageId:a(n.messageId),at:i(n.at)},t=n.source;if(t&&typeof t==`object`){let n=t,r={};a(n.url)&&(r.url=a(n.url)),a(n.channel)&&(r.channel=a(n.channel)),a(n.user)&&(r.user=a(n.user)),a(n.run)&&(r.run=a(n.run)),Object.keys(r).length>0&&(e.source=r)}return[e]}case`answer`:return[{kind:`answer`,text:a(n.text),at:i(n.at)}];case`pr_opened`:{let e=i(n.number);return!a(n.url)||e===void 0||!Number.isInteger(e)||e<=0?[]:[{kind:`pr_opened`,url:a(n.url),number:e,created:n.created===!0,at:i(n.at)}]}case`run_meta`:{if(!a(n.agent))return[];let e={kind:`meta`,agent:a(n.agent),model:a(n.model),at:i(n.at)};return a(n.effort)&&(e.effort=a(n.effort)),a(n.repo)&&(e.repo=a(n.repo)),a(n.ref)&&(e.ref=a(n.ref)),i(n.pr)!==void 0&&Number.isInteger(n.pr)&&n.pr>0&&(e.pr=n.pr),/^[0-9a-f]{7,40}$/i.test(a(n.headSha))&&(e.headSha=a(n.headSha)),[e]}case`context`:return[{kind:`context`,text:a(n.text),at:i(n.at)}];case`reference`:{let e=i(n.messages);return!a(n.url)||!a(n.channelName)||e===void 0?[]:[{kind:`reference`,url:a(n.url),channelName:a(n.channelName),messages:e,text:a(n.text),at:i(n.at)}]}case`notes`:return[{kind:`note`,text:a(n.text),noteKind:`notes`,at:i(n.at)}];case`replay_note`:return[{kind:`replay_note`,text:a(n.summary)}];case`run_note`:return[{kind:`note`,text:a(n.summary),noteKind:a(n.kind),mode:a(n.mode)||void 0,at:i(n.at)}];case`assistant`:return[{kind:`step`,step:o({text:a(n.text),at:i(n.at)})}];case`review_artifact`:return[];case`span_start`:{let e=a(n.name),t=a(n.spanId);return!e||!t||e.startsWith(`tool.`)||e.startsWith(`mcp.`)||e===`model.turn`?[]:[{kind:`span`,spanId:t,name:e,open:!0,at:i(n.at)}]}case`span_end`:{let e=a(n.name),r=a(n.spanId),o=i(n.durationMs);if(!e||!r||o===void 0)return[];let c=n.status===`error`?`error`:`ok`,u=typeof n.attrs==`object`&&n.attrs!==null?n.attrs:{};if(e===`model.turn`){t=null;let e=[],c=i(u.inputTokens),l=i(u.outputTokens),d=i(u.cacheReadTokens);c!==void 0&&e.push(s(c)+` in`),l!==void 0&&e.push(s(l)+` out`),d!==void 0&&e.push(s(d)+` cached`);let f=i(u.ttftMs);f!==void 0&&e.push(`first token `+E(f,`precise`));let p=i(u.thinkingMs);p!==void 0&&e.push(`thinking `+E(p,`precise`));let m=i(u.textMs);m!==void 0&&e.push(`writing `+E(m,`precise`));let h=a(u.model);return[{kind:`turn`,spanId:r,label:`Thought for `+E(o,`precise`),facts:e,durationMs:o,...h?{model:h}:{},at:i(n.at)}]}if(e.startsWith(`tool.`)||e.startsWith(`mcp.`)){if(!e.startsWith(`tool.`))return[];let t=a(u.callId);if(!t)return[];let n=g(t);return!n||n.call.durationMs!==void 0?[]:(n.call.durationMs=o,n.call.facts=l(n.call),[{kind:`result`,step:n.step,call:n.call}])}let d=i(n.startedAt);return[{kind:`span`,spanId:r,name:e,open:!1,durationMs:o,status:c,at:i(n.at),...d===void 0?{}:{startedAt:d}}]}case`artifact`:{let e=a(n.key),t=a(n.name);if(!e||!t)return[];let r={key:e,name:t,size:i(n.size)??0,contentType:a(n.contentType),at:i(n.at)},o=a(n.messageId),s=a(n.callId),c=n.direction===`in`&&o?{...r,direction:`in`,messageId:o}:n.direction===`out`&&s?{...r,direction:`out`,callId:s}:void 0;return c?[{kind:`artifact`,artifact:c}]:[]}case`skill_use`:{let e=a(n.skill);if(!e)return[];let r=[];t||r.push({kind:`step`,step:o()});let s=a(n.source),c={name:e,description:a(n.description),agent:a(n.agent),bodyBytes:i(n.bodyBytes)??0,at:i(n.at)};return/^https?:\/\//.test(s)&&(c.source=s),r.push({kind:`skill`,step:t,skill:c}),r}case`tool_call`:{let e=[];t||e.push({kind:`step`,step:o()});let r=h(n,a(n.summary));return t.calls.push(r),e.push({kind:`call`,step:t,call:r}),e}case`tool_result`:{let e=_(n);if(e)return u(e.call,n),[{kind:`result`,step:e.step,call:e.call}];let r=[];t||r.push({kind:`step`,step:o()});let i=h(n,``);return i.startedAt=void 0,u(i,n),t.calls.push(i),r.push({kind:`call`,step:t,call:i}),r}default:return[]}}function y(){return r.length>0?r[0]:null}return{push:v,pending:y,steps:()=>e}}new Set(`request,slack.receive,dispatch.history,dispatch.admission,dispatch.ack_card,dispatch.gate.repo,dispatch.gate.pr_head,dispatch.workspace.attach,dispatch.gate.attached_head,dispatch.mcp_discovery,dispatch.compose,dispatch.channel_visibility,dispatch.repo_context,dispatch.memory_read,dispatch.refuse,dispatch.ship_preflight,dispatch.ledger_claim,dispatch.route,run.agent,run.command,run.reading_diff,run.settle_reviewed_head,run.description_turn,run.verdict_turn,run.observe_workspace,run.pr_post_step,run.review_post_step,run.reading_diff_join,run.pr_description_join,model.turn,ship.round,post.card_close,post.reply`.split(`,`));var le=new Set([`slack.receive`,`dispatch.history`,`dispatch.admission`,`dispatch.ack_card`,`dispatch.gate.repo`,`dispatch.gate.pr_head`,`dispatch.workspace.attach`,`dispatch.gate.attached_head`,`dispatch.mcp_discovery`,`dispatch.compose`,`dispatch.channel_visibility`,`dispatch.repo_context`,`dispatch.memory_read`,`dispatch.refuse`,`dispatch.ship_preflight`,`dispatch.ledger_claim`,`dispatch.route`]),ue=new Set([`run.observe_workspace`,`run.pr_post_step`,`run.review_post_step`,`run.reading_diff_join`,`run.pr_description_join`]),de=new Set([`request`,`run.agent`,`ship.round`,`run.settle_reviewed_head`,`run.description_turn`,`run.verdict_turn`,`post.card_close`,`post.reply`]),fe=new Set([`run.reading_diff`]);function R(e,t){if(fe.has(e))return{kind:`background`};if(de.has(e))return{kind:`uncounted`};if(e===`model.turn`)return{kind:`counted`,bucket:`thinking`};if(e===`run.command`||e.startsWith(`run.command.`))return{kind:`counted`,bucket:t===`command`?`tools`:`getting_ready`};if(le.has(e)||e.startsWith(`dispatch.workspace.attach.`))return{kind:`counted`,bucket:`getting_ready`};if(ue.has(e))return{kind:`counted`,bucket:`finishing_up`};if(e.startsWith(`tool.`)||e.startsWith(`mcp.`))return{kind:`counted`,bucket:`tools`}}var z={clone:`cloning the repo`,"checkout-clone":`cloning the checkout`,"worktree-clone":`cloning the worktree`,"worktree-detach":`checking out the expected commit`,"op-clone":`cloning the op tree`,fetch:`fetching the branch`,"wake-fetch":`fetching the latest commits`,"reclaim-fetch":`fetching to reclaim the mirror`,"for-each-ref":`listing the branches`,checkout:`checking out the branch`,"checkout-update":`updating the checkout`,"rev-parse":`reading the commit`,"cat-file":`checking the mirror for the commit`,"show-ref":`reading the branch tip`,"detect-default-branch":`detecting the default branch`,git:`a git command`,"git-setup":`configuring git`,"stage-perms":`securing the credential stage`,install:`installing dependencies`,build:`building`,test:`running the tests`,"clear-markers":`clearing the build markers`,"lockfile-key":`hashing the lockfile`,"deps-store-dir":`preparing the dependency store`,"deps-scratch":`cloning a scratch tree for the dependency install`,"deps-install":`installing the dependency store`,"deps-harden":`locking down the installed dependencies`,"deps-commit":`recording the installed dependencies`,"deps-adopt":`adopting the dependency store`,"deps-restore-scratch":`restoring dependencies to scratch`,"deps-restore-chown":`setting the restored dependencies' owner`,"deps-restore-commit":`recording the restored dependencies`,"deps-scratch-chown":`setting the dependency scratch owner`,"deps-evict":`evicting an old dependency store`,"unlink-deps-view":`unlinking the dependency view`,"clear-installing-marker":`clearing the install marker`,chown:`setting the workspace owner`,"worktree-chown":`setting the worktree owner`,"op-chown":`setting the op tree's owner`,"worktree-clean":`cleaning the worktree`,"clean-workspace":`cleaning the workspace`,"clean-before-restore":`cleaning before the restore`,"unmount-restores":`unmounting earlier restores`,"mirror-restore-extract":`extracting the mirror snapshot`,"checkout-restore-extract":`extracting the checkout snapshot`,"deps-restore-extract":`extracting the dependency snapshot`,evict:`evicting a stale tree`,"thread-dir":`preparing a directory`,"threads-dir":`preparing a directory`,"op-dir":`preparing a directory`,"ops-dir":`preparing a directory`,"stage-dir":`preparing a directory`,stat:`checking a file`,"boot-id":`reading the container's identity`,touch:`touching a marker`,nproc:`counting CPUs`,mutex_wait:`waiting for the workspace`,kill:`stopping the previous step`};Object.keys(z);function B(e){return Object.prototype.hasOwnProperty.call(z,e)?e:void 0}function pe(e){let t=B(e);if(t!==void 0)return z[t];if(e.endsWith(`-stale-sweep`)){let t=B(e.slice(0,-12));if(t!==void 0)return`clearing leftovers before ${z[t]}`}}var V={request:`the request`,"slack.receive":`receiving`,"dispatch.history":`reading the thread`,"dispatch.admission":`checking the thread`,"dispatch.ack_card":`posting the status card`,"dispatch.gate.repo":`checking the repo`,"dispatch.gate.pr_head":`checking the PR`,"dispatch.workspace.attach":`attaching the workspace`,"dispatch.gate.attached_head":`checking out the branch`,"dispatch.mcp_discovery":`loading tools`,"dispatch.compose":`preparing the prompt`,"dispatch.channel_visibility":`checking the channel`,"dispatch.repo_context":`reading the repo's context`,"dispatch.memory_read":`recalling memory`,"dispatch.refuse":`refusing`,"dispatch.ship_preflight":`checking the ship request`,"dispatch.ledger_claim":`claiming the run's row`,"dispatch.route":`picking the preset`,"run.agent":`the agent loop`,"run.command":`the command`,"run.reading_diff":`reading the diff (in parallel)`,"run.settle_reviewed_head":`re-checking the moved branch`,"run.description_turn":`asking for the PR description`,"run.verdict_turn":`asking for the verdict`,"run.observe_workspace":`checking the workspace`,"run.pr_post_step":`posting the PR`,"run.review_post_step":`posting the review`,"run.reading_diff_join":`waiting for the diff`,"run.pr_description_join":`waiting for the PR description`,"model.turn":`a model turn`,"ship.round":`a ship round`,"post.card_close":`closing the card`,"post.reply":`posting the reply`},me=`a Switchboard step`;function H(e){if(e in V)return V[e];if(e.startsWith(`tool.`))return e.slice(5)||`a Switchboard step`;if(e.startsWith(`mcp.`)){let t=e.slice(e.lastIndexOf(`.`)+1);return t&&t!==`mcp`?t:me}for(let t of[`dispatch.workspace.attach.`,`run.command.`])if(e.startsWith(t))return pe(e.slice(t.length))??`a Switchboard step`;return me}var he=`A-Za-z0-9:@._-`;RegExp(`^[${he}]{1,128}$`),RegExp(`[^${he}]`,`g`);function ge(e){return e.type===`span_start`||e.type===`span_end`}function _e(e,t){return/^[A-Za-z0-9_-]{1,64}$/.test(e)?`synth:${e}`:`synth:${t}`}function ve(e){let t=[];for(let n of e)n.type===`span_end`&&n.name===`run.agent`&&t.push({spanId:n.spanId,startedAt:n.startedAt,endedAt:n.startedAt+n.durationMs});return t}function U(e,t){let n;for(let r of e)r.startedAt<=t&&t<=r.endedAt&&(!n||r.endedAt-r.startedAt<n.endedAt-n.startedAt)&&(n=r);return n?.spanId}function ye(e){let t=ve(e),n=new Set;for(let t of e){if(!ge(t))continue;let e=t.attrs??{};t.name.startsWith(`tool.`)&&typeof e.callId==`string`&&n.add(e.callId)}let r=[],i=new Map;return e.forEach((e,a)=>{switch(e.type){case`tool_call`:{let o=e.callId;if(o===void 0||e.at===void 0||n.has(o)){r.push(e);return}let s=_e(o,a);r.push(be(s,`tool.${e.tool}`,e.at,U(t,e.at),{callId:o}),e),i.set(o,{spanId:s,startedAt:e.at});return}case`tool_result`:{if(r.push(e),e.callId===void 0)return;let n=i.get(e.callId);if(!n)return;i.delete(e.callId);let a=e.at??n.startedAt,o={ok:e.ok,callId:e.callId};e.exitCode!==void 0&&(o.exitCode=e.exitCode),e.infra&&(o.infra=!0),r.push(xe(n.spanId,`tool.${e.tool}`,n.startedAt,Math.max(0,a-n.startedAt),U(t,n.startedAt),o,e.ok?`ok`:`error`));return}default:r.push(e)}}),r}function be(e,t,n,r,i){return{type:`span_start`,spanId:e,...r===void 0?{}:{parentSpanId:r},name:t,...i?{attrs:i}:{},at:n}}function xe(e,t,n,r,i,a,o=`ok`){return{type:`span_end`,spanId:e,...i===void 0?{}:{parentSpanId:i},name:t,startedAt:n,durationMs:r,status:o,...a?{attrs:a}:{},at:n+r}}function Se(e,t,n){let r=e.get(t.spanId);if(t.type===`span_start`){if(r)return;e.set(t.spanId,{traceId:n,spanId:t.spanId,...t.parentSpanId===void 0?{}:{parentSpanId:t.parentSpanId},name:t.name,startedAt:t.at??0,attrs:t.attrs??{}});return}e.set(t.spanId,{traceId:n,spanId:t.spanId,...t.parentSpanId===void 0?r?.parentSpanId===void 0?{}:{parentSpanId:r.parentSpanId}:{parentSpanId:t.parentSpanId},name:t.name,startedAt:t.startedAt,endedAt:t.startedAt+t.durationMs,durationMs:t.durationMs,status:t.status,...t.error===void 0?{}:{errorMessage:t.error},attrs:{...r?.attrs??{},...t.attrs??{}}})}function Ce(){let e,t,n=[];return{push(r){e?t&&r.seq!==void 0&&t.seq!==void 0&&r.seq>t.seq+1&&t.at!==void 0&&r.at!==void 0&&n.push({kind:`gap`,fromSeq:t.seq+1,toSeq:r.seq-1,from:Math.min(t.at,r.at),to:Math.max(t.at,r.at)}):e={seq:r.seq??1,at:r.at},r.type===`run_note`&&r.kind===`spans_dropped`&&r.from!==void 0&&r.to!==void 0&&r.to>=r.from&&n.push({kind:`note`,from:r.from,to:r.to}),t={seq:r.seq,at:r.at}},losses(t={}){let r=t.elided??[],i=(e,t)=>r.some(n=>n.fromSeq<=e&&t<=n.toSeq),a=[];e&&e.seq>1&&t.windowStart!==void 0&&e.at!==void 0&&e.at>t.windowStart&&a.push({from:t.windowStart,to:e.at,kind:`lost`});for(let e of n)a.push(e.kind===`note`?{from:e.from,to:e.to,kind:`lost`}:{from:e.from,to:e.to,kind:i(e.fromSeq,e.toSeq)?`elided`:`lost`});return a}}}var we=[/\bslack[\s-]?only\b/i,/\bpost\s*[:=]\s*(?:off|no|false|none)\b/i,/\bno[\s-]post\b/i,/\b(?:don['’]?t|do\s+not|never|skip|without)\s+(?:\w+\s+){0,2}?(?:post|comment)(?:ing|s)?\b/i,/\bno\s+need\s+to\s+(?:post|comment)\b/i];function Te(e){return we.some(t=>t.test(e))}var Ee=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,De=/^[0-9a-f]{7,40}$/,Oe=/^(?![.-])(?!.*\.\.)(?!.*\/\/)(?!.*@\{)(?!.*\.lock$)(?!.*[./]$)[\w][\w./-]*$/;function W(e){return e&&Ee.test(e)?`https://github.com/${e}`:void 0}function G(e,t){let n=W(e);if(!(!n||t===void 0||!Number.isInteger(t)||t<=0))return`${n}/pull/${t}`}function ke(e,t){let n=W(e);if(n&&t&&Oe.test(t))return`${n}/tree/${t.split(`/`).map(encodeURIComponent).join(`/`)}`}function Ae(e,t){let n=W(e);if(n&&t&&De.test(t))return`${n}/commit/${t}`}function je(e){return e.slice(0,7)}function Me(e){if(e===`slack.receive`||e.startsWith(`dispatch.`))return`getting_ready`;let t=R(e,`agent`);return t?.kind===`counted`&&t.bucket===`finishing_up`?`finishing_up`:void 0}function Ne(e){return e===`request`||e===`run.agent`}var Pe={getting_ready:`Getting ready`,finishing_up:`Finishing up`};function Fe(e){let t=e.rows.length,n=`${t} step${t===1?``:`s`}`,r=Pe[e.phase];if(t===0||e.rows.some(e=>e.open||e.at===void 0||e.durationMs===void 0))return`${r} · ${n}`;let i=Math.min(...e.rows.map(e=>e.at)),a=Math.max(...e.rows.map(e=>e.at+e.durationMs));return`${r} · ${n} · ${E(Math.max(0,a-i),`precise`)}`}function Ie(e){let t=e.split(`
4
- `),n=t.indexOf(`<<<UNTRUSTED`),r=t.lastIndexOf(`UNTRUSTED>>>`);return(n>=0&&r>n?t.slice(n+1,r):t.slice(1)).filter(e=>e.length>0)}function Le(e,t){let n=t.split(`/`).map(encodeURIComponent).join(`/`);return`${e.urlBase}${n}${e.token?`?t=${encodeURIComponent(e.token)}`:``}`}function Re(e){if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{fromSeq:n,toSeq:r}=t,i=e=>typeof e==`number`&&Number.isInteger(e)&&e>0;return!i(n)||!i(r)||n>r?null:{fromSeq:n,toSeq:r}}function ze(e){let t=e.toSeq-e.fromSeq+1,n=t===1?`event ${e.fromSeq}`:`events ${e.fromSeq}–${e.toSeq}`;return`${t} ${t===1?`event`:`events`} not loaded (${n}) — the record has them`}function Be(e,t,n){let r=!!e.model&&t!==null&&Ye(e.model,t),i=r?t:e.model??t??void 0,a=!!e.model&&t!==null&&!r;return{spanId:e.spanId,label:e.label,chip:e.label.replace(/^Thought for /,``),quick:e.durationMs<6e4,durationMs:e.durationMs,facts:e.facts,...i?{model:i}:{},switched:a,showModel:!!i&&(!n||a),at:e.at}}function Ve(e){let t=`${e.n} tool call${e.n===1?``:`s`}`;if(e.n===0)return`no tool calls`;if(e.ok===e.n)return`${t}, all succeeded`;if(e.running===e.n)return`${t}, all running`;let n=[];return e.bad&&n.push(`${e.bad} failed`),e.infra&&n.push(`${e.infra} sandbox error${e.infra===1?``:`s`}`),e.running&&n.push(`${e.running} still running`),`${t}, ${n.join(`, `)}`}function He(e){let{meta:t,prOpened:n}=e,r=t?.repo&&W(t.repo)?t.repo:void 0;if(t?.agent===`review`){if(Te(e.requestText))return{text:`verdict, Slack only`};if(r&&t.pr!==void 0){let e=G(r,t.pr);return e?{text:`verdict for ${r}#${t.pr}`,href:e}:{text:`verdict`}}return{text:`verdict`}}if(t?.agent===`coding`&&n){let e=n.created?`pull request opened`:`pull request updated`,t=r?G(r,n.number):void 0;return t?{text:`${e} ${r}#${n.number}`,href:t}:{text:e}}return t?.agent===`command`?{text:`output`}:{text:`answer`}}function K(e,t){return{id:e.id,tool:e.tool,title:e.title,headline:e.headline,shell:e.shell,status:e.status,facts:[...e.facts],startedAt:e.startedAt,output:e.result?e.result.output||e.result.summary:``,hasResult:e.result!==void 0,chipOnly:!e.shell&&e.title===e.tool,durationMs:e.durationMs,exitCode:e.result?.exitCode,timedOut:k(e.result?.exitCode),open:t}}function q(e={}){let t=e.openTags&&e.openTags.length>0?e.openTags:[`failed`,`infra`],n=ce(),r=p({request:null,meta:null,context:[],references:[],log:[],reply:null,prOpened:null,placeholder:!0,allOpen:!1,stopMode:null,model:null,firstAt:null,lastAt:null,lastAtWall:null,elided:[],traceVersion:0}),i=Ce(),a=new Map,o=new Map,s=new Map,c=new Map,l=new Map,u=new Map,d=new Map,f=new Set,m=null,h=!1,g=-1,_=0,v=e=>`${e}-${_++}`;function y(e){return t.includes(`all`)?!0:e.some(e=>t.includes(e))}function b(e){let t=0,n=0,r=0;for(let i of e.items)i.kind===`call`&&(i.call.status===`failed`?t++:i.call.status===`infra`?n++:i.call.status===`running`&&r++);return{bad:t,infra:n,running:r}}function x(e){let{bad:t,infra:n,running:r}=b(e);(t||n||r)&&(e.groupOpen=!0)}function C(e){let t=o.get(g);t&&(t.live=!1),g=e.index;let n=m;m=null;let i=p({kind:`step`,key:v(`step`),index:e.index,at:e.narration?e.narration.at:n?.at,turn:n,narration:e.narration?e.narration.text:null,note:`no commentary`,items:[],live:!0,manual:!1,groupOpen:!0});return o.set(e.index,i),r.log.push(i),i}function w(e){return o.get(e.index)??C(e)}function T(e,t){let n=w(e);if(t.quiet){f.add(t.id),n.items.push({kind:`quiet`,at:t.startedAt,text:`✎ ${t.tool===`update_status`?`status checklist updated`:t.title}`}),x(n);return}let i=p(K(t,r.allOpen||y(t.tags)));u.set(t.id,i),d.set(t.id,n),n.items.push({kind:`call`,call:i}),x(n)}function E(e,t){if(f.has(t.id)){let t=o.get(e.index);t&&x(t);return}let n=u.get(t.id);if(!n){T(e,t);return}Object.assign(n,K(t,n.open)),y(t.tags)&&(n.open=!0);let r=o.get(e.index);r&&x(r)}function D(e,t){m&&=(r.log.push({kind:`turn`,key:v(`turn`),turn:m,note:e,...t===void 0?{}:{noteHref:t}}),null)}let O=new Map,k=p([]);function A(e){if(e.direction===`in`){O.get(e.messageId)?.files.push(e);return}k.push(e);let t=u.get(e.callId);t&&((t.files??=[]).push(e),t.open=!0)}function j(e){switch(r.placeholder=!1,e.kind){case`input`:{let t={text:e.text,messageId:e.messageId,at:e.at,...e.source?{source:e.source}:{},files:[]};r.request?r.log.push({kind:`followup`,key:v(`followup`),input:t}):r.request=t,O.set(t.messageId,t);return}case`step`:C(e.step);return;case`call`:T(e.step,e.call);return;case`result`:E(e.step,e.call);return;case`turn`:D(``),m=Be(e,r.model,h),m.model&&(h=!0),e.model&&!(r.model!==null&&Ye(e.model,r.model))&&(r.model=e.model);return;case`meta`:r.model===null&&e.model&&(r.model=e.model),r.meta={agent:e.agent,model:e.model,...e.effort?{effort:e.effort}:{},...e.repo?{repo:e.repo}:{},...e.ref?{ref:e.ref}:{},...e.pr===void 0?{}:{pr:e.pr},...e.headSha?{headSha:e.headSha}:{}};return;case`pr_opened`:r.prOpened={url:e.url,number:e.number,created:e.created};return;case`skill`:w(e.step).items.push({kind:`skill`,skill:e.skill});return;case`artifact`:A(e.artifact);return;case`context`:r.context.push({key:v(`ctx`),at:e.at,text:e.text});return;case`reference`:r.references.push({key:v(`ref`),at:e.at,url:e.url,channelName:e.channelName,messages:e.messages,text:e.text});return;case`note`:if(e.noteKind===`follow_up`)return;r.log.push({kind:`note`,key:v(`note`),at:e.at,replay:!1,text:e.text,noteKind:e.noteKind}),(e.noteKind===`stop_requested`||e.noteKind===`stopped`)&&(e.mode===`soft`||e.mode===`hard`)&&I(e.mode);return;case`replay_note`:r.log.push({kind:`note`,key:v(`note`),replay:!0,text:e.text});return;case`span`:{if(Ne(e.name)){e.name===`run.agent`&&e.open&&M(`getting_ready`);return}e.name.startsWith(`post.`)&&e.open&&M(`finishing_up`);let t=s.get(e.spanId);if(t){t.open=e.open,e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.status&&(t.status=e.status);return}let n=p({kind:`span`,key:v(`span`),spanId:e.spanId,text:H(e.name),open:e.open,...e.durationMs===void 0?{}:{durationMs:e.durationMs},...e.status?{status:e.status}:{},at:e.open?e.at:e.startedAt??e.at});s.set(e.spanId,n);let i=Me(e.name);if(i){let t=l.get(i);t||(t={group:p({kind:`phase`,phase:i,key:v(i),rows:[],open:!0}),toggled:!1},l.set(i,t),r.log.push(t.group)),t.group.rows.push(n),c.set(e.spanId,t.group);return}r.log.push(n);return}case`answer`:D(`wrote the reply`,`#reply`),r.reply={text:e.text,at:e.at,files:k};return}}function M(e){let t=l.get(e);t&&!t.toggled&&(t.group.open=!1)}function N(e){let t=e,o=t?.type===`span_start`||t?.type===`span_end`;if(t&&typeof t.type==`string`){let t=e;i.push(t),ge(t)&&Se(a,t,``),r.traceVersion++}t&&!o&&typeof t.at==`number`&&((r.firstAt===null||t.at<r.firstAt)&&(r.firstAt=t.at),(r.lastAt===null||t.at>=r.lastAt)&&(r.lastAt=t.at,r.lastAtWall=S()));for(let t of n.push(e))j(t)}function P(){for(let e of u.values())if(e.status===`running`)return e;return null}function F(e){r.allOpen=e;for(let t of l.values())t.group.open=e,t.toggled=!0;for(let t of u.values())t.open=e}function ee(e){if(e.startsWith(`call-`)){let t=e.slice(5),n=d.get(t);return!n||!u.has(t)?!1:(n.manual=!0,n.groupOpen=!0,!0)}if(e.startsWith(`span-`)){let t=e.slice(5),n=c.get(t);if(n){n.open=!0;let e=l.get(n.phase);return e&&(e.toggled=!0),!0}if(s.has(t))return!0;for(let e of r.log)if(e.kind===`step`&&e.turn?.spanId===t||e.kind===`turn`&&e.turn.spanId===t)return!0}return!1}function I(e){r.stopMode=e}function L(e){r.elided.push(e),r.log.push({kind:`note`,key:v(`note`),replay:!0,text:ze(e)}),r.placeholder=!1,r.traceVersion++}return{state:r,handle:N,noteElided:L,spanSet:()=>[...a.values()],losses:e=>i.losses({windowStart:e,elided:r.elided}),pendingCall:P,flushPendingTurn:D,closePhases(){M(`getting_ready`),M(`finishing_up`)},setAllOpen:F,togglePhase(e){e.open=!e.open;let t=l.get(e.phase);t&&(t.toggled=!0)},reveal:ee,callHeadline:e=>u.get(e)?.headline,toggleGroup(e){e.manual=!0,e.groupOpen=!e.groupOpen},toggleCall(e){e.open=!e.open},markStopping:I,opensByDefault:y}}function J(e,t){return e.lastAt===null||e.lastAtWall===null?null:e.lastAt+(t-e.lastAtWall)}function Ue(e,t){return{now:n=>e.serverNow+(n-t),elapsedMs(t){return A(e,this.now(t))??0},elapsedAt(t){return A({receivedAt:e.receivedAt,startedAt:e.startedAt,finishedAt:t})??0}}}function We(e){if(typeof e!=`string`)return{};let t;try{t=JSON.parse(e)}catch{return{}}if(typeof t!=`object`||!t)return{};let{sealedAt:n,replyOk:r}=t;return{...typeof n==`number`&&Number.isFinite(n)&&n>0?{sealedAt:n}:{},...typeof r==`boolean`?{replyOk:r}:{}}}function Y(e){return e.replyOk===!1?`reply failed`:e.replyOk!==!0||e.finishedAt===void 0||e.sealedAt===void 0?``:`delivered in ${E(Math.max(0,e.sealedAt-e.finishedAt),`clock`)}`}function Ge(e){if(typeof e!=`string`)return null;let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let{finishedAt:n}=t;return typeof n==`number`&&Number.isFinite(n)&&n>0?{finishedAt:n}:null}var Ke=Symbol(`sb-runner-clock`),qe=Symbol(`sb-artifact-links`),Je=Symbol(`sb-reply-landed`);function Ye(e,t){return e===t||!e.includes(`/`)!=!t.includes(`/`)&&X(e)===X(t)}function X(e){if(!e)return`model`;let t=e.lastIndexOf(`/`);return(t===-1?e:e.slice(t+1))||e}var Xe=6e4;function Ze(e,t,n){let r=J(e,n);if(r===null||e.lastAt===null)return{kind:`starting`};if(t)return{kind:`call`,call:t,elapsedMs:Math.max(0,r-(t.startedAt??e.lastAt))};let i=Math.max(0,r-e.lastAt);return{kind:`thinking`,elapsedMs:i,slow:i>=Xe}}var Z={"getting ready":`paint-ready`,thinking:`paint-thinking`,"in tools":`paint-tools`,"finishing up":`paint-finishing`,"Switchboard overhead":`paint-overhead`,"not recorded":`paint-lost`,"not loaded":`paint-elided`},Qe={getting_ready:`getting ready`,finishing_up:`finishing up`};function $e(e){return Z[Qe[e]]}var et={id:`timeline`,class:`block mb-4 rounded-lg border border-default bg-(--ui-bg-muted) px-(--sb-gutter) py-3`,"data-testid":`timeline`},tt={class:`mb-2 flex items-baseline gap-2.5 font-mono text-xs font-medium uppercase tracking-wider text-muted`},nt={class:`ml-auto flex items-baseline gap-3 font-normal normal-case tracking-normal`},rt=[`href`],it={class:`lede font-mono text-sm text-toned`},at={class:`shape tabular-nums`},ot={key:0,class:`current text-muted`},st={key:0,class:`note mt-0.5 text-xs text-muted`},ct=[`aria-label`],lt=[`title`,`data-term`],ut={class:`legend mt-2 flex flex-wrap gap-x-4 gap-y-1 font-mono text-xs`},dt=[`title`,`data-term`],ft={class:`term text-muted`},pt={class:`ms tabular-nums text-toned`},mt=[`title`],ht={class:`ranked mt-1 flex flex-col gap-1 font-mono text-xs`},gt={class:`ms w-14 shrink-0 tabular-nums text-toned`},_t=[`href`,`data-anchor`,`onClick`],vt=x({__name:`TimelineSection`,props:{vm:{},eventsHref:{}},emits:[`reveal`],setup(t,{emit:r}){let i=t,s=r;function c(e){return`${E(e.ms,`clock`)} ${e.term}${e.hatched?` (in flight)`:``}`}function l(){e.copyText(JSON.stringify(i.vm.debug,null,2))}return(e,r)=>(d(),g(`section`,et,[h(`h2`,tt,[r[0]||=h(`span`,null,`Where the time went`,-1),h(`span`,nt,[t.eventsHref?(d(),g(`a`,{key:0,class:`text-dimmed no-underline hover:text-primary hover:underline`,href:t.eventsHref,title:`the stored events, as JSON lines`},`raw events`,8,rt)):f(``,!0),h(`button`,{type:`button`,class:`debug cursor-pointer text-dimmed hover:text-toned`,title:`the partition and the raw span names, for a bug report`,onClick:l},` Copy debug JSON `)])]),h(`p`,it,[h(`span`,at,y(t.vm.shown?t.vm.total:t.vm.lede),1),t.vm.current?(d(),g(`span`,ot,` · `+y(t.vm.current),1)):f(``,!0)]),(d(!0),g(o,null,_(t.vm.captions,e=>(d(),g(`p`,{key:e,class:`caption mt-0.5 text-xs text-muted`},y(e),1))),128)),t.vm.note?(d(),g(`p`,st,y(t.vm.note),1)):f(``,!0),t.vm.shown?(d(),g(o,{key:1},[h(`div`,{class:`bar mt-2.5 flex h-2 w-full overflow-hidden rounded-sm`,role:`img`,"aria-label":t.vm.lede},[(d(!0),g(o,null,_(t.vm.bar,(e,t)=>(d(),g(`div`,{key:t,class:b([`seg h-full`,[v(Z)[e.term],e.hatched?`paint-hatched hatched`:``]]),style:n({width:`${e.pct}%`}),title:c(e),"data-term":e.term},null,14,lt))),128))],8,ct),h(`ul`,ut,[(d(!0),g(o,null,_(t.vm.legend,e=>(d(),g(`li`,{key:e.term,class:`flex items-baseline gap-1.5 cursor-help`,title:e.definition,"data-term":e.term},[h(`span`,{class:b([`swatch inline-block size-2 shrink-0 self-center rounded-[2px]`,v(Z)[e.term]])},null,2),h(`span`,ft,y(e.term),1),h(`span`,pt,y(e.text),1)],8,dt))),128))]),t.vm.ranked.length>0?(d(),g(o,{key:0},[h(`h3`,{class:`ranked-head mt-3 inline-block cursor-help text-xs font-medium text-muted underline decoration-dotted decoration-(--ui-border-accented) underline-offset-2`,title:t.vm.rankedNote},` Longest steps `,8,mt),h(`ol`,ht,[(d(!0),g(o,null,_(t.vm.ranked,(e,t)=>(d(),g(`li`,{key:t,class:`flex items-baseline gap-2`},[h(`span`,gt,y(v(E)(e.ms,`clock`)),1),h(`a`,{class:`label min-w-0 truncate text-muted no-underline hover:text-primary hover:underline`,href:`#${e.anchor}`,"data-anchor":e.anchor,title:`scroll to this step`,onClick:a(t=>s(`reveal`,e.anchor),[`prevent`])},y(e.label),9,_t),(d(!0),g(o,null,_(e.facts,e=>(d(),g(`span`,{key:e,class:`fact shrink-0 rounded border border-accented px-1 text-dimmed`},y(e),1))),128))]))),128))])],64)):f(``,!0)],64)):f(``,!0)]))}});function yt(e,t){let{window:n,owner:r,finished:i}=t,a=Math.max(0,n.end-n.start),o=new Map(e.map(e=>[e.spanId,e])),s=new Map,c=e=>{let t=s.get(e.spanId);if(t!==void 0)return t;s.set(e.spanId,1);let n=e.parentSpanId?o.get(e.parentSpanId):void 0,r=n?c(n)+1:1;return s.set(e.spanId,r),r},l=e=>{let t=e,n=new Set;for(;t&&!n.has(t.spanId);){if(n.add(t.spanId),R(t.name,r)?.kind===`background`)return!0;t=t.parentSpanId?o.get(t.parentSpanId):void 0}return!1},u=t.losses.map(e=>Math.max(n.start,e.from)).sort((e,t)=>e-t),d=e=>{if(e.endedAt!==void 0)return Math.min(n.end,e.endedAt);if(!i)return n.end;let t=u.find(t=>t>e.startedAt);return t===void 0?n.end:Math.min(n.end,t)},f=[],p=[];for(let t of e){let e=R(t.name,r);if(!e)continue;let i=Math.max(n.start,t.startedAt);if(e.kind===`background`){let e=Math.min(n.end,t.endedAt??n.end);e>i&&p.push([i,e]);continue}if(e.kind!==`counted`||l(t))continue;let a=d(t);a<=i||f.push({start:i,end:a,bucket:e.bucket,depth:c(t),startedAt:t.startedAt,spanId:t.spanId})}f.sort((e,t)=>t.depth-e.depth||e.startedAt-t.startedAt||(e.spanId<t.spanId?-1:+(e.spanId>t.spanId)));let m=new Set([n.start,n.end]);for(let e of f)m.add(e.start),m.add(e.end);for(let e of t.losses)m.add(Q(e.from,n)),m.add(Q(e.to,n));for(let[e,t]of p)m.add(e),m.add(t);let h=[...m].filter(e=>e>=n.start&&e<=n.end).sort((e,t)=>e-t),g={getting_ready:0,thinking:0,tools:0,finishing_up:0},_=0,v=0,y=0;for(let e=0;e+1<h.length;e++){let r=h[e],i=h[e+1],a=i-r;if(a<=0)continue;let o=f.find(e=>e.start<=r&&e.end>=i);if(o){g[o.bucket]+=a;continue}if(t.losses.some(e=>e.kind===`lost`&&Q(e.from,n)<=r&&Q(e.to,n)>=i)){_+=a;continue}if(t.losses.some(e=>e.kind===`elided`&&Q(e.from,n)<=r&&Q(e.to,n)>=i)){v+=a;continue}p.some(([e,t])=>e<=r&&t>=i)&&(y+=a)}let b=g.getting_ready+g.thinking+g.tools+g.finishing_up;return{windowMs:a,gettingReadyMs:g.getting_ready,thinkingMs:g.thinking,toolsMs:g.tools,finishingUpMs:g.finishing_up,overheadMs:Math.max(0,a-b-_-v),notRecordedMs:_,notLoadedMs:v,backgroundOnlyMs:y}}function Q(e,t){return Math.min(t.end,Math.max(t.start,e))}function bt(e){let t=Math.floor(e.windowMs/1e3),n=[[`getting ready`,Math.floor(e.gettingReadyMs/1e3)],[`thinking`,Math.floor(e.thinkingMs/1e3)],[`in tools`,Math.floor(e.toolsMs/1e3)],[`finishing up`,Math.floor(e.finishingUpMs/1e3)],[`not recorded`,Math.floor(e.notRecordedMs/1e3)],[`not loaded`,Math.floor(e.notLoadedMs/1e3)]],r=n.reduce((e,[,t])=>e+t,0),i=n.filter(([,e])=>e>0).map(([e,t])=>({term:e,s:t})),a=t-r;a>0&&i.push({term:`Switchboard overhead`,s:a});let o=[`getting ready`,`thinking`,`in tools`,`finishing up`,`Switchboard overhead`,`not recorded`,`not loaded`];return i.sort((e,t)=>o.indexOf(e.term)-o.indexOf(t.term)),{totalS:t,items:i}}function xt(e){return[e.gettingReadyMs,e.thinkingMs,e.toolsMs,e.finishingUpMs,e.overheadMs,e.notRecordedMs,e.notLoadedMs].filter(t=>t>=2e3||e.windowMs>0&&t/e.windowMs>=.05).length>=2}function St(e,t){if(t===void 0||t<6e4)return;let n=E(t,`clock`);return e===`before`?`queued ${n} before we saw it`:`queued ${n} behind the previous run`}var Ct={"getting ready":`before the agent's first turn: reading the thread, finding the repo, checking out, loading tools`,thinking:`the model's turns — from a request to the model until its reply came back`,"in tools":`the commands and tool calls the model ran`,"finishing up":`after the agent's last turn: posting the PR, checking the workspace`,"Switchboard overhead":`orchestration between steps, and moments when only a background read was running — the time no step claims`,"not recorded":`a stretch of the run the record does not carry`,"not loaded":`a stretch of the run this page did not load — the record has the full shape`},wt=`Ranked by each step's own time, its children excluded — the bar counts every instant once.`,Tt=`currently delivering`,Et=`getting ready: not recorded (too large)`,Dt=`no timing data`,Ot=`not loaded (the record has the full shape)`,kt={getting_ready:`getting ready`,thinking:`thinking`,tools:`in tools`,finishing_up:`finishing up`};function At(e){let{spans:t,window:n,owner:r}=e,i=e.phase!==`live`,a=yt(t,{window:n,owner:r,finished:i,losses:e.losses}),o=bt(a),s=E(o.totalS*1e3,`clock`),c=t.find(e=>e.name===`request`&&e.parentSpanId===void 0),l=e.phase===`live`?jt(t,r,n):void 0,u=Nt(e,l),d=l?H(l.name):``,f={window:n,owner:r,phase:e.phase,partition:a,spans:t.map(e=>({spanId:e.spanId,parentSpanId:e.parentSpanId,name:e.name,startedAt:e.startedAt,endedAt:e.endedAt,status:e.status,attrs:e.attrs}))};if(e.untimed)return{total:s,current:u,openStep:d,captions:[],rankedNote:wt,debug:f,lede:s,shown:!1,bar:[],legend:[],ranked:[],note:Dt};let p={total:s,current:u,openStep:d,captions:[St(`before`,$(c,`queuedBeforeMs`)),St(`behind`,$(c,`queuedBehindMs`))].filter(e=>e!==void 0),rankedNote:wt,debug:f};if(!c)return{...p,lede:s,shown:!1,bar:[],legend:[],ranked:[],note:i?Et:``};let m=t=>t===`not recorded`?`not recorded${e.truncated?` (too large)`:``}`:t===`not loaded`?Ot:t,h=xt(a)&&o.items.length>0,g=h?`${s} — ${o.items.map(({term:e,s:t})=>`${E(t*1e3,`clock`)} ${m(e)}`).join(` · `)}`:a.windowMs>0?`${s} — ${m(Ft(a))}`:s,_=h?o.items.map(({term:t,s:n})=>({term:t,text:E(n*1e3,`clock`),definition:t===`not recorded`&&e.truncated?`${Ct[t]} (too large)`:Ct[t]})):[];return{...p,lede:g,shown:h,bar:h?It(a,l):[],legend:_,ranked:h?Lt(t,c,r,n,e.callTitle):[],note:``}}function $(e,t){let n=e?.attrs[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function jt(e,t,n){let r=new Map(e.map(e=>[e.spanId,e])),i=e=>{let t=1,n=new Set([e.spanId]),i=e.parentSpanId?r.get(e.parentSpanId):void 0;for(;i&&!n.has(i.spanId);)n.add(i.spanId),t++,i=i.parentSpanId?r.get(i.parentSpanId):void 0;return t},a;for(let o of e){if(o.endedAt!==void 0||o.startedAt>=n.end)continue;let e=R(o.name,t);if(e?.kind!==`counted`||Mt(o,r,t))continue;let s=i(o);(!a||s>a.depth||s===a.depth&&o.startedAt>a.span.startedAt)&&(a={span:o,depth:s,bucket:e.bucket})}if(a)return{bucket:a.bucket,name:a.span.name,elapsedMs:Math.max(0,n.end-Math.max(n.start,a.span.startedAt))}}function Mt(e,t,n){let r=e,i=new Set;for(;r&&!i.has(r.spanId);){if(i.add(r.spanId),R(r.name,n)?.kind===`background`)return!0;r=r.parentSpanId?t.get(r.parentSpanId):void 0}return!1}function Nt(e,t){return e.phase===`delivering`?Tt:e.phase===`ended`?Y(e.delivery??{}):t?`currently ${kt[t.bucket]} ${E(t.elapsedMs,`clock`)}`:``}function Pt(e){return[[`getting ready`,e.gettingReadyMs],[`thinking`,e.thinkingMs],[`in tools`,e.toolsMs],[`finishing up`,e.finishingUpMs],[`Switchboard overhead`,e.overheadMs],[`not recorded`,e.notRecordedMs],[`not loaded`,e.notLoadedMs]]}function Ft(e){let t=[`getting ready`,-1];for(let n of Pt(e))n[1]>t[1]&&(t=n);return t[0]}function It(e,t){let n=[],r=t=>e.windowMs>0?t/e.windowMs*100:0;for(let[i,a]of Pt(e))if(!(a<=0)){if(t&&kt[t.bucket]===i){let e=Math.min(t.elapsedMs,a);a-e>0&&n.push({term:i,ms:a-e,pct:r(a-e),hatched:!1}),e>0&&n.push({term:i,ms:e,pct:r(e),hatched:!0});continue}n.push({term:i,ms:a,pct:r(a),hatched:!1})}return n}function Lt(e,t,n,r,i){let a=new Map(e.map(e=>[e.spanId,e])),o=new Map;for(let t of e){if(t.parentSpanId===void 0)continue;let e=o.get(t.parentSpanId);e?e.push(t):o.set(t.parentSpanId,[t])}let s=e=>[Math.max(r.start,e.startedAt),Math.min(r.end,e.endedAt??r.end)],c=[];for(let r of e){if(r===t||r.name===`run.agent`||R(r.name,n)===void 0||Mt(r,a,n))continue;let[e,l]=s(r);if(l<=e)continue;let u=(o.get(r.spanId)??[]).map(s).map(([t,n])=>[Math.max(e,t),Math.min(l,n)]).filter(([e,t])=>t>e),d=l-e-Rt(u);if(d<=0)continue;let f=r.name.startsWith(`tool.`)&&typeof r.attrs.callId==`string`?r.attrs.callId:void 0,p=f?i?.(f):void 0;c.push({label:p??H(r.name),ms:d,facts:zt(r),anchor:f?`call-${f}`:`span-${r.spanId}`,startedAt:r.startedAt})}return c.sort((e,t)=>t.ms-e.ms||e.startedAt-t.startedAt),c.slice(0,3).map(({label:e,ms:t,facts:n,anchor:r})=>({label:e,ms:t,facts:n,anchor:r}))}function Rt(e){let t=[...e].sort((e,t)=>e[0]-t[0]),n=0,r;for(let[e,i]of t)!r||e>r[1]?(r&&(n+=r[1]-r[0]),r=[e,i]):i>r[1]&&(r[1]=i);return r&&(n+=r[1]-r[0]),n}function zt(e){let t=e.attrs,n=[];return(t.token===`expired`||t.token===`expiring`)&&n.push(`token ${t.token}`),t.budget===`clipped`&&n.push(`budget clipped`),typeof t.timeoutMs==`number`&&n.push(`timeout ${E(t.timeoutMs,`clock`)}`),typeof t.waitedMs==`number`&&n.push(`waited ${E(t.waitedMs,`clock`)}`),typeof t.exitCode==`number`&&t.exitCode!==0&&n.push(`exit ${t.exitCode}`),t.timedOut===!0&&n.push(`timed out`),typeof t.attempts==`number`&&t.attempts>1&&n.push(`${t.attempts} attempts`),e.status===`error`&&n.length===0&&n.push(`failed`),n}function Bt(e){let t=[];for(let n of e.split(/\r?\n\r?\n/)){let e=n.split(/\r?\n/);if(e.some(e=>e.startsWith(`event:`)))continue;let r=e.filter(e=>e.startsWith(`data:`)).map(e=>e.slice(5).replace(/^ /,``)).join(`
5
- `);if(r!==``)try{let e=JSON.parse(r);typeof e==`object`&&e&&typeof e.type==`string`&&t.push(e)}catch{}}return t}function Vt(e){return e===`command`?`command`:`agent`}var Ht=[`data-state`],Ut={key:0,class:`loading py-2 font-mono text-xs text-dimmed`},Wt={key:1,class:`failed py-2 font-mono text-xs text-warn`},Gt=[`href`],Kt=x({__name:`RunTimeline`,props:{run:{},fetch:{}},setup(t){let n=t,r=c(`loading`),a=q(),o=m(()=>{if(r.value!==`ready`)return null;a.state.traceVersion;let e=n.run,t=e.receivedAt??e.startedAt,i=A(e)??(e.finishedAt===void 0?0:Math.max(0,e.finishedAt-t));return At({spans:a.spanSet(),losses:a.losses(t),window:{start:t,end:t+i},owner:Vt(e.agent),totalMs:i,phase:`ended`,delivery:{finishedAt:e.finishedAt,sealedAt:e.sealedAt,replyOk:e.replyOk},...e.truncated===void 0?{}:{truncated:e.truncated},...(e.schema??0)>=2?{}:{untimed:!0},callTitle:a.callHeadline})}),s=m(()=>`/runs/${encodeURIComponent(n.run.id)}/events`);function p(t){e.navigate(`/runs/${encodeURIComponent(n.run.id)}#${t}`)}return i(async()=>{let e=n.fetch??((...e)=>globalThis.fetch(...e));try{let t=await e(s.value,{credentials:`same-origin`});if(!t.ok)throw Error(`HTTP ${t.status}`);let i=Bt(await t.text()).filter(e=>e.type!==`replay_note`);for(let e of(n.run.schema??0)>=2?ye(i):i)a.handle(e);a.closePhases(),r.value=`ready`}catch{r.value=`failed`}}),(e,n)=>(d(),g(`div`,{class:`runtimeline pl-5`,"data-state":r.value},[r.value===`loading`?(d(),g(`p`,Ut,`reading the run's record…`)):r.value===`failed`?(d(),g(`p`,Wt,[n[0]||=u(` the run's record could not be read — `,-1),h(`a`,{class:`text-primary no-underline hover:underline`,href:`/runs/${encodeURIComponent(t.run.id)}`},`open the run`,8,Gt)])):o.value?(d(),l(vt,{key:2,vm:o.value,"events-href":s.value,onReveal:p},null,8,[`vm`,`events-href`])):f(``,!0)],8,Ht))}}),qt=[`id`,`data-run-id`,`data-round`,`data-thread`],Jt=[`open`],Yt={class:`row flex min-w-0 cursor-pointer list-none flex-wrap items-center gap-x-2.5 gap-y-1 px-2 py-2 hover:bg-(--ui-bg-muted) [&::-webkit-details-marker]:hidden`},Xt={key:0,class:`round shrink-0 rounded border border-accented px-1.5 font-mono text-[0.7rem] font-medium tabular-nums text-toned`},Zt={key:2,class:`snippet min-w-0 flex-1 truncate text-muted`},Qt={key:3,class:`scope min-w-0 flex-1 truncate text-toned`},$t=[`title`],en=[`data-heat`],tn={class:`count shrink-0 text-right font-mono text-xs tabular-nums text-dimmed sm:min-w-[6em]`},nn=[`href`,`aria-label`],rn={key:1,class:`row flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1 px-2 py-2 hover:bg-(--ui-bg-muted)`},an={key:0,class:`round shrink-0 rounded border border-accented px-1.5 font-mono text-[0.7rem] font-medium tabular-nums text-toned`},on={key:2,class:`snippet min-w-0 flex-1 truncate text-muted`},sn={key:3,class:`scope min-w-0 flex-1 truncate text-highlighted`},cn=[`title`],ln={class:`elapsed shrink-0 text-right font-mono text-xs tabular-nums text-ok sm:min-w-[4.5em]`,title:`running for`},un={class:`count shrink-0 text-right font-mono text-xs tabular-nums text-dimmed sm:min-w-[6em]`},dn=[`href`,`aria-label`],fn=x({__name:`RunFoldRow`,props:{run:{},now:{},label:{},open:{type:Boolean}},setup(e){let t=e,i=c(t.open===!0);r(()=>t.open,e=>{e&&(i.value=!0)});let o=m(()=>w(t.run.label||P(t.run.id))),u=m(()=>te(t.run)),p=m(()=>ee(t.run)),_=m(()=>t.run.finished),x=m(()=>t.run.finished&&t.run.status&&t.run.status!==`completed`?re(t.run.status):``),S=m(()=>O(t.run.finished&&typeof t.run.finishedAt==`number`?t.run.finishedAt-t.run.startedAt:void 0,`run`)),E=m(()=>D(S.value));function k(e){i.value=e.target.open}return(t,r)=>(d(),g(`li`,{id:`run-${e.run.id}`,class:b([`fold group border-b border-muted`,e.run.finished?`finished`:`live`]),"data-run-id":e.run.id,"data-round":e.run.round,"data-thread":e.run.thread},[_.value?(d(),g(`details`,{key:0,class:`group/fold`,open:i.value,onToggle:k},[h(`summary`,Yt,[r[1]||=h(`span`,{class:`chev select-none text-xs text-dimmed transition-transform group-open/fold:rotate-90 motion-reduce:transition-none`,"aria-hidden":`true`},`❯`,-1),s(C,{tone:u.value,label:v(M)(e.run),tip:v(N)(e.run)},null,8,[`tone`,`label`,`tip`]),e.label?(d(),g(`span`,Xt,y(e.label),1)):f(``,!0),o.value.agent?(d(),g(`span`,{key:1,class:b([`agent shrink-0 rounded border px-1.5 font-mono text-[0.68rem] font-medium uppercase tracking-wider opacity-55`,v(L)[v(j)(o.value.agent)]])},y(o.value.agent),3)):f(``,!0),o.value.snippet===void 0?(d(),g(`span`,Qt,y(o.value.scope),1)):(d(),g(`span`,Zt,y(o.value.snippet),1)),x.value?(d(),g(`span`,{key:4,class:b([`outcome shrink-0 rounded border px-1.5 font-mono text-[0.7rem]`,u.value===`red`?`border-bad/30 text-bad`:`border-warn/30 text-warn`])},y(x.value),3)):f(``,!0),h(`span`,{class:`when shrink-0 font-mono text-xs tabular-nums text-dimmed`,title:v(ne)(e.run)},y(v(T)(e.run.startedAt,e.now)),9,$t),h(`span`,{class:b([`elapsed shrink-0 text-right font-mono text-xs tabular-nums sm:min-w-[4.5em]`,[E.value?`heat`:`text-muted`,S.value.level>=2?`font-medium`:``]]),style:n(E.value),"data-heat":S.value.level,title:`start to finish`},y(v(F)(e.run,e.now)),15,en),h(`span`,tn,y(v(I)(e.run)),1),h(`a`,{class:`open shrink-0 font-mono text-xs text-primary no-underline hover:underline`,href:p.value,"aria-label":`open run ${e.run.label||v(P)(e.run.id)}`,onClick:r[0]||=a(()=>{},[`stop`])},`open ↗`,8,nn)]),i.value?(d(),l(Kt,{key:0,run:e.run},null,8,[`run`])):f(``,!0)],40,Jt)):(d(),g(`div`,rn,[r[2]||=h(`span`,{class:`chev select-none text-xs text-transparent`,"aria-hidden":`true`},`❯`,-1),s(C,{tone:u.value,label:v(M)(e.run),tip:v(N)(e.run),pulse:``},null,8,[`tone`,`label`,`tip`]),e.label?(d(),g(`span`,an,y(e.label),1)):f(``,!0),o.value.agent?(d(),g(`span`,{key:1,class:b([`agent shrink-0 rounded border px-1.5 font-mono text-[0.68rem] font-medium uppercase tracking-wider`,v(L)[v(j)(o.value.agent)]])},y(o.value.agent),3)):f(``,!0),o.value.snippet===void 0?(d(),g(`span`,sn,y(o.value.scope),1)):(d(),g(`span`,on,y(o.value.snippet),1)),h(`span`,{class:`when shrink-0 font-mono text-xs tabular-nums text-muted`,title:v(ne)(e.run)},y(v(T)(e.run.startedAt,e.now)),9,cn),h(`span`,ln,y(v(F)(e.run,e.now)),1),h(`span`,un,y(v(I)(e.run)),1),h(`a`,{class:`open shrink-0 font-mono text-xs text-primary no-underline hover:underline`,href:p.value,"aria-label":`open run ${e.run.label||v(P)(e.run.id)}`},`open ↗`,8,dn)]))],10,qt))}});export{Ae as C,je as D,ke as E,se as O,J as S,W as T,Ge as _,$e as a,Ie as b,Ke as c,Ue as d,q as f,We as g,X as h,vt as i,Le as l,Ze as m,Vt as n,qe as o,Y as p,At as r,Je as s,fn as t,Ve as u,Re as v,G as w,He as x,Fe as y};