@coreplane/switchboard 1.248.0 → 1.249.1

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 (49) hide show
  1. package/dist/assets/config/config.example.yaml +44 -18
  2. package/dist/assets/deploy/cloudflare/preflight.mjs +21 -19
  3. package/dist/assets/deploy/cloudflare-memory/worker.ts +31 -0
  4. package/dist/assets/deploy/cloudflare-resident/drain.ts +109 -0
  5. package/dist/assets/deploy/cloudflare-resident/refresh.ts +5 -3
  6. package/dist/assets/deploy/cloudflare-resident/threadErr.ts +32 -3
  7. package/dist/assets/deploy/cloudflare-resident/worker.ts +235 -13
  8. package/dist/assets/deploy/cloudflare-sandbox/worker.ts +56 -9
  9. package/dist/assets/deploy/secrets.manifest.json +6 -0
  10. package/dist/assets/package-lock.json +3 -3
  11. package/dist/assets/package.json +1 -1
  12. package/dist/assets/source.json +3 -3
  13. package/dist/assets/src/agents/registry.ts +4 -4
  14. package/dist/assets/src/core/budgets.ts +24 -0
  15. package/dist/assets/src/core/coordinator/contract.ts +4 -3
  16. package/dist/assets/src/core/coordinator/driver.ts +40 -7
  17. package/dist/assets/src/core/modelCard.ts +348 -0
  18. package/dist/assets/src/core/modelPricing.ts +14 -5
  19. package/dist/assets/src/core/modelRegistry.ts +51 -0
  20. package/dist/assets/src/core/provider.ts +103 -0
  21. package/dist/assets/src/core/refusal.ts +181 -0
  22. package/dist/assets/src/core/runEvents.ts +43 -0
  23. package/dist/assets/src/core/ship/coordinator.ts +80 -12
  24. package/dist/assets/src/core/ship/handoff.ts +54 -19
  25. package/dist/assets/src/core/trace/workerTrace.ts +9 -3
  26. package/dist/assets/src/core/types.ts +327 -0
  27. package/dist/assets/src/deploy/liveGate.ts +35 -0
  28. package/dist/assets/src/deploy/restart.ts +12 -11
  29. package/dist/assets/src/execution/residentRefresh.ts +26 -1
  30. package/dist/assets/src/execution/sandboxErrors.ts +122 -4
  31. package/dist/assets/web/dist/.vite/manifest.json +30 -30
  32. package/dist/assets/web/dist/assets/DeliveryPage-DF4aQypG.js +1 -0
  33. package/dist/assets/web/dist/assets/{HomePage-DYxC0izY.js → HomePage-BpQRky8B.js} +1 -1
  34. package/dist/assets/web/dist/assets/{ResidentDetailPage-DLIpWYOc.js → ResidentDetailPage-BIUXyz6K.js} +1 -1
  35. package/dist/assets/web/dist/assets/{ResidentsIndexPage-6LipuDjR.js → ResidentsIndexPage-BZymgSAb.js} +1 -1
  36. package/dist/assets/web/dist/assets/{RunFoldRow-V-iSy64e.js → RunFoldRow-3m4CPRI4.js} +1 -1
  37. package/dist/assets/web/dist/assets/{RunRoutePage-DUalB1u2.js → RunRoutePage-bgkjkA0p.js} +3 -3
  38. package/dist/assets/web/dist/assets/{RunsIndexPage-B9Ba1KdD.js → RunsIndexPage-8S944AzB.js} +1 -1
  39. package/dist/assets/web/dist/assets/{ScheduledPage-KdjLtD_7.js → ScheduledPage-8bBtG9y3.js} +1 -1
  40. package/dist/assets/web/dist/assets/{SettingsPage-IT5l_NaL.js → SettingsPage-DQeNvfaV.js} +1 -1
  41. package/dist/assets/web/dist/assets/{StatusDot-DBHAl4Il.js → StatusDot-BPE5syBa.js} +1 -1
  42. package/dist/assets/web/dist/assets/{Tooltip-_LEjptLV.js → Tooltip-DkoeZfTs.js} +1 -1
  43. package/dist/assets/web/dist/assets/UnitRoutePage-BUzw--Ii.js +1 -0
  44. package/dist/assets/web/dist/assets/{dist-BcYPGOBL.js → dist-D11y9ZJ4.js} +1 -1
  45. package/dist/assets/web/dist/assets/{main-DUfSE0dj.js → main-B6LcgNM6.js} +2 -2
  46. package/dist/cli.js +2475 -1021
  47. package/package.json +1 -1
  48. package/dist/assets/web/dist/assets/DeliveryPage-NP4g6bQd.js +0 -1
  49. package/dist/assets/web/dist/assets/UnitRoutePage-DPBsvGPR.js +0 -1
@@ -22,6 +22,7 @@
22
22
  * interrupted one stopped instead of redoing the whole rebuild. */
23
23
 
24
24
  import { DISK_FULL_FREE_KIB, diskFullReason, isDiskFullMessage } from "./residentDisk.js";
25
+ import { carriesRuntimeBusyToken } from "./sandboxErrors.js";
25
26
 
26
27
  export interface RefreshDisk {
27
28
  /** `git rev-parse HEAD` of the warm checkout; null when unreadable. */
@@ -121,6 +122,9 @@ export function checkoutUpdateCommand(sha: string, clean: CleanScope): string {
121
122
  * repository: the container's control port never answered the SDK's connect
122
123
  * (`runtimeUnreachableReason`), so no command ran at all — the resident
123
124
  * escalates on its persisted count instead of recording a command failure.
125
+ * `busy` is the third: the container did not accept the cycle's connect
126
+ * inside the platform's allowance (`runtime-busy`, resident-repos item 68) —
127
+ * a run's command has its cores; nothing ran, and the cycle yields to it.
124
128
  * Everything else is the repo's own build failing. */
125
129
  export interface RefreshFailure {
126
130
  /** The reason. An interruption's is prefixed `refresh-interrupted:` and is
@@ -130,7 +134,8 @@ export interface RefreshFailure {
130
134
  * `disk-full:` (`residentDisk.ts` — the cycle's entry gate and the recycle
131
135
  * decision key on it); an unanswered control port is `runtime-unreachable:`
132
136
  * with the attempt count (the ladder below decides what the resident does
133
- * about it); real failures keep `<step>-failed:`. */
137
+ * about it); a busy container's is `refresh-yielded:` (the cycle ends
138
+ * `stopped`, the state it found put back); real failures keep `<step>-failed:`. */
134
139
  reason: string;
135
140
  /** The step that failed, as the caller named it (`refresh` for a failure
136
141
  * between steps): item 67 reads whether it ran the repository's own command
@@ -139,6 +144,7 @@ export interface RefreshFailure {
139
144
  interrupted: boolean;
140
145
  diskFull: boolean;
141
146
  runtimeUnreachable: boolean;
147
+ busy: boolean;
142
148
  }
143
149
 
144
150
  /** Root argv that kills every process the build user still owns and waits
@@ -290,15 +296,31 @@ export function classifyRefreshFailure(input: {
290
296
  interrupted: false,
291
297
  diskFull: false,
292
298
  runtimeUnreachable: true,
299
+ busy: false,
293
300
  reason: runtimeUnreachableReason(input.runtimeUnreachable.count),
294
301
  };
295
302
  }
303
+ // Item 68: the token the Worker's `run()` named the refused connect with,
304
+ // anywhere in the text — a wrapper (a StepError, the fetch's mint prefix)
305
+ // keeps it. Decided before the disk inference: no command ran, so a low
306
+ // free-disk reading says nothing about this failure.
307
+ if (carriesRuntimeBusyToken(message)) {
308
+ return {
309
+ step,
310
+ interrupted: false,
311
+ diskFull: false,
312
+ runtimeUnreachable: false,
313
+ busy: true,
314
+ reason: `refresh-yielded: ${step} ${message}`,
315
+ };
316
+ }
296
317
  if (isDiskFullMessage(message)) {
297
318
  return {
298
319
  step,
299
320
  interrupted: false,
300
321
  diskFull: true,
301
322
  runtimeUnreachable: false,
323
+ busy: false,
302
324
  reason: diskFullReason({ step, message, freeKiB: input.freeKiB ?? null }),
303
325
  };
304
326
  }
@@ -309,6 +331,7 @@ export function classifyRefreshFailure(input: {
309
331
  interrupted: true,
310
332
  diskFull: false,
311
333
  runtimeUnreachable: false,
334
+ busy: false,
312
335
  reason: `refresh-interrupted: ${step} ${message}`,
313
336
  };
314
337
  }
@@ -318,6 +341,7 @@ export function classifyRefreshFailure(input: {
318
341
  interrupted: false,
319
342
  diskFull: true,
320
343
  runtimeUnreachable: false,
344
+ busy: false,
321
345
  reason: diskFullReason({ step, message, freeKiB: input.freeKiB }),
322
346
  };
323
347
  }
@@ -326,6 +350,7 @@ export function classifyRefreshFailure(input: {
326
350
  interrupted: false,
327
351
  diskFull: false,
328
352
  runtimeUnreachable: false,
353
+ busy: false,
329
354
  reason: `${step}-failed: ${message}`,
330
355
  };
331
356
  }
@@ -169,12 +169,14 @@ export const SANDBOX_START_WAIT_MAX_MS = 10 * 60_000;
169
169
  * fleet wait's and a ready container is used within 15 s of coming up. */
170
170
  export const SANDBOX_START_BACKOFF_MS: readonly number[] = [5_000, 10_000, 15_000];
171
171
 
172
- /** The reasons whose answers the executor re-sends after a wait. Every other
173
- * `reason` — or none — is an ordinary failure after one send. */
174
- export type WaitReason = typeof FLEET_BUSY_REASON | typeof SANDBOX_STARTING_REASON;
172
+ /** The reasons whose answers the executor re-sends after a wait — a full
173
+ * fleet, a starting container, a container that did not accept the
174
+ * connection (`runtime-busy`, below). Every other `reason` — or none — is an
175
+ * ordinary failure after one send. */
176
+ export type WaitReason = typeof FLEET_BUSY_REASON | typeof SANDBOX_STARTING_REASON | typeof RUNTIME_BUSY_REASON;
175
177
 
176
178
  export function isWaitReason(reason: unknown): reason is WaitReason {
177
- return reason === FLEET_BUSY_REASON || reason === SANDBOX_STARTING_REASON;
179
+ return reason === FLEET_BUSY_REASON || reason === SANDBOX_STARTING_REASON || reason === RUNTIME_BUSY_REASON;
178
180
  }
179
181
 
180
182
  /** The Worker's answer on /read and /write (sent as HTTP 503) while the
@@ -320,3 +322,119 @@ export function runtimeUnreachableExecAnswer(message: string): {
320
322
  } {
321
323
  return { error: message, reason: RUNTIME_UNREACHABLE_REASON, stdout: "", stderr: message, exitCode: 127 };
322
324
  }
325
+
326
+ // ---- A container that did not accept the connection (docs/reference/specs/execution.md item 28) ----
327
+ //
328
+ // The container's runtime accepts one control connection per SDK call. When
329
+ // the platform's fetch to the container's port is not accepted inside the
330
+ // platform's own allowance — a few seconds, not the SDK's 30 s connect timeout
331
+ // — it throws a plain `Error` reading `Container is taking too long to accept
332
+ // the connection; the application could be overwhelmed with load`. Nothing
333
+ // ran: the SDK was still connecting, before any process was started. The
334
+ // platform's words name a cause it never measured: seen live under a command
335
+ // saturating every core (a whole repository's verify, three minutes in) AND
336
+ // on an idle container (a review thread running `sed` and `grep`, the
337
+ // connection accepted 0.9 s before and 0.8 s after the refused one). Both
338
+ // times the harness's one-second poll of its transcript log met it, the
339
+ // failure reached the bot as an ordinary in-body error, and the run was torn
340
+ // down while its container answered the next command a second later. The
341
+ // Worker names the refusal instead — never its cause — with a machine token
342
+ // the executor re-sends on: the identical request, once the container accepts.
343
+
344
+ /** The named reason the Worker answers with, beside `fleet-busy` and `sandbox-starting`. */
345
+ export const RUNTIME_BUSY_REASON = "runtime-busy" as const;
346
+
347
+ /** What the token means, in the words the model and the operator see. */
348
+ export const RUNTIME_BUSY_EXPLANATION =
349
+ "the thread's sandbox container is running but did not accept the connection inside the platform's allowance — nothing ran, the request is re-sent once it accepts";
350
+
351
+ /** The platform's wording for a container port that did not accept the SDK's
352
+ * connect inside the platform's own allowance. A wording, not a type: the
353
+ * platform throws a plain `Error`, and the SDK hands it on unwrapped. */
354
+ export const RUNTIME_BUSY_WORDING = /taking too long to accept the connection/i;
355
+
356
+ /** The executor waits at most this long for the container to accept, capped
357
+ * by the operation's own budget: when a command of the thread's own is what
358
+ * holds the container, it is bounded like every command, and a poll that
359
+ * waits past its own budget has nothing left to run. */
360
+ export const RUNTIME_BUSY_WAIT_MAX_MS = 5 * 60_000;
361
+
362
+ /** Backoff between re-sends: 3 s, 5 s, then 10 s. Each refusal already cost
363
+ * the platform's allowance (about six seconds live), and the container has
364
+ * accepted again within a second of every refusal seen, so the poll stays
365
+ * dense. */
366
+ export const RUNTIME_BUSY_BACKOFF_MS: readonly number[] = [3_000, 5_000, 10_000];
367
+
368
+ /** The name the Worker's typed error carries across the Durable Object RPC boundary. */
369
+ export const RUNTIME_BUSY_ERROR_NAME = "SandboxRuntimeBusyError";
370
+
371
+ /** Is this one link of an error's cause chain the platform's accept refusal?
372
+ * By the wording alone — the platform gives no type. Applied by the Worker
373
+ * to a failure met BEFORE a process was started (the spawn, the warm-up, a
374
+ * file operation), never to a failure of a running command's output. */
375
+ export function isRuntimeBusySignal(link: unknown): boolean {
376
+ if (link === null || typeof link !== "object") return false;
377
+ const { message } = link as { message?: unknown };
378
+ return typeof message === "string" && RUNTIME_BUSY_WORDING.test(message);
379
+ }
380
+
381
+ /** The text that names the condition: the token first (the executor reads
382
+ * it), the container so a reader finds it in the logs, the platform's words. */
383
+ export function runtimeBusyMessage(f: { containerId: string; cause: string }): string {
384
+ return `${RUNTIME_BUSY_REASON}: ${RUNTIME_BUSY_EXPLANATION} (container ${f.containerId}; ${f.cause.trim() || "no detail from the platform"})`;
385
+ }
386
+
387
+ /** The Worker's typed error for a container that did not accept the
388
+ * connection, built inside the Durable Object and read by the fetch handler
389
+ * across the RPC boundary — matched by name and by its message token, never
390
+ * by `instanceof`. */
391
+ export class SandboxRuntimeBusyError extends Error {
392
+ readonly reason = RUNTIME_BUSY_REASON;
393
+ constructor(readonly facts: { containerId: string; cause: string }) {
394
+ super(runtimeBusyMessage(facts));
395
+ this.name = RUNTIME_BUSY_ERROR_NAME;
396
+ }
397
+ }
398
+
399
+ /** Name first, token second: the typed error after the RPC boundary, or any
400
+ * message that starts with the token. */
401
+ export function isRuntimeBusyError(err: unknown): boolean {
402
+ const s = thrownShape(err);
403
+ return s.name === RUNTIME_BUSY_ERROR_NAME || !!s.message?.startsWith(`${RUNTIME_BUSY_REASON}:`);
404
+ }
405
+
406
+ /** Does a failure's text carry the token anywhere — the typed error's own
407
+ * message, or that message behind a wrapper's prefix (a `StepError` built
408
+ * from it, the fetch step's mint prefix)? The refresh cycle's classifier
409
+ * reads this: the token decides, never the platform's words. */
410
+ export function carriesRuntimeBusyToken(message: string): boolean {
411
+ return new RegExp(`(?:^|[\\s;(])${RUNTIME_BUSY_REASON}: `).test(message);
412
+ }
413
+
414
+ /** The `/read` and `/write` answer (sent as HTTP 503): the token and the text. */
415
+ export function runtimeBusyAnswer(message: string): { error: string; reason: typeof RUNTIME_BUSY_REASON } {
416
+ return { error: message, reason: RUNTIME_BUSY_REASON };
417
+ }
418
+
419
+ /** The `/exec` answer, in-body under the streamed HTTP 200 in the item-3 dual
420
+ * shape, like `fleetBusyExecAnswer`: the executor re-sends on the token. */
421
+ export function runtimeBusyExecAnswer(message: string): {
422
+ error: string;
423
+ reason: typeof RUNTIME_BUSY_REASON;
424
+ stdout: "";
425
+ stderr: string;
426
+ exitCode: 127;
427
+ } {
428
+ return { error: message, reason: RUNTIME_BUSY_REASON, stdout: "", stderr: message, exitCode: 127 };
429
+ }
430
+
431
+ /** The message `ExecCapacityError` carries when the container never accepted
432
+ * inside the wait: the wait, what was met, the one cause known and the one
433
+ * ruled out, and what to do. It never tells the reader to wait for a command
434
+ * that may not be running. */
435
+ export function runtimeBusyExhaustedMessage(waitedMs: number): string {
436
+ return (
437
+ `sandbox busy — the thread's container did not accept a connection within ${Math.round(waitedMs / 1000)}s ` +
438
+ "(the platform refused every connect of the wait; a command saturating its cores is one cause, an idle container has met it too); retry"
439
+ );
440
+ }
@@ -28,7 +28,7 @@
28
28
  "src": "../node_modules/@fontsource-variable/jetbrains-mono/files/jetbrains-mono-vietnamese-wght-normal.woff2"
29
29
  },
30
30
  "../node_modules/@pierre/diffs/dist/index.js": {
31
- "file": "assets/dist-BcYPGOBL.js",
31
+ "file": "assets/dist-D11y9ZJ4.js",
32
32
  "name": "dist",
33
33
  "src": "../node_modules/@pierre/diffs/dist/index.js",
34
34
  "isDynamicEntry": true,
@@ -2573,8 +2573,8 @@
2573
2573
  "_sseReplay-DXC7kGbN.js"
2574
2574
  ]
2575
2575
  },
2576
- "_RunFoldRow-V-iSy64e.js": {
2577
- "file": "assets/RunFoldRow-V-iSy64e.js",
2576
+ "_RunFoldRow-3m4CPRI4.js": {
2577
+ "file": "assets/RunFoldRow-3m4CPRI4.js",
2578
2578
  "name": "RunFoldRow",
2579
2579
  "imports": [
2580
2580
  "_browser-B6T5hjfR.js",
@@ -2583,7 +2583,7 @@
2583
2583
  "_format-BldUwl_R.js",
2584
2584
  "_durationTone-U_rOqo6r.js",
2585
2585
  "_sseReplay-DXC7kGbN.js",
2586
- "_StatusDot-DBHAl4Il.js"
2586
+ "_StatusDot-BPE5syBa.js"
2587
2587
  ]
2588
2588
  },
2589
2589
  "_RunsTabs-YSbUu5py.js": {
@@ -2602,16 +2602,16 @@
2602
2602
  "_browser-B6T5hjfR.js"
2603
2603
  ]
2604
2604
  },
2605
- "_StatusDot-DBHAl4Il.js": {
2606
- "file": "assets/StatusDot-DBHAl4Il.js",
2605
+ "_StatusDot-BPE5syBa.js": {
2606
+ "file": "assets/StatusDot-BPE5syBa.js",
2607
2607
  "name": "StatusDot",
2608
2608
  "imports": [
2609
2609
  "_browser-B6T5hjfR.js",
2610
- "_Tooltip-_LEjptLV.js"
2610
+ "_Tooltip-DkoeZfTs.js"
2611
2611
  ]
2612
2612
  },
2613
- "_Tooltip-_LEjptLV.js": {
2614
- "file": "assets/Tooltip-_LEjptLV.js",
2613
+ "_Tooltip-DkoeZfTs.js": {
2614
+ "file": "assets/Tooltip-DkoeZfTs.js",
2615
2615
  "name": "Tooltip",
2616
2616
  "imports": [
2617
2617
  "_AppShell-DAtHiuI6.js",
@@ -2856,7 +2856,7 @@
2856
2856
  ]
2857
2857
  },
2858
2858
  "src/main.ts": {
2859
- "file": "assets/main-DUfSE0dj.js",
2859
+ "file": "assets/main-B6LcgNM6.js",
2860
2860
  "name": "main",
2861
2861
  "src": "src/main.ts",
2862
2862
  "isEntry": true,
@@ -2904,7 +2904,7 @@
2904
2904
  ]
2905
2905
  },
2906
2906
  "src/pages/DeliveryPage.vue": {
2907
- "file": "assets/DeliveryPage-NP4g6bQd.js",
2907
+ "file": "assets/DeliveryPage-DF4aQypG.js",
2908
2908
  "name": "DeliveryPage",
2909
2909
  "src": "src/pages/DeliveryPage.vue",
2910
2910
  "isDynamicEntry": true,
@@ -2916,14 +2916,14 @@
2916
2916
  ]
2917
2917
  },
2918
2918
  "src/pages/HomePage.vue": {
2919
- "file": "assets/HomePage-DYxC0izY.js",
2919
+ "file": "assets/HomePage-BpQRky8B.js",
2920
2920
  "name": "HomePage",
2921
2921
  "src": "src/pages/HomePage.vue",
2922
2922
  "isDynamicEntry": true,
2923
2923
  "imports": [
2924
2924
  "_AppShell-DAtHiuI6.js",
2925
2925
  "_browser-B6T5hjfR.js",
2926
- "_Tooltip-_LEjptLV.js",
2926
+ "_Tooltip-DkoeZfTs.js",
2927
2927
  "_PendingTurnRow-BuRre8it.js",
2928
2928
  "src/main.ts",
2929
2929
  "_eventSource-Bj_dZf6M.js",
@@ -2936,7 +2936,7 @@
2936
2936
  ]
2937
2937
  },
2938
2938
  "src/pages/ResidentDetailPage.vue": {
2939
- "file": "assets/ResidentDetailPage-DLIpWYOc.js",
2939
+ "file": "assets/ResidentDetailPage-BIUXyz6K.js",
2940
2940
  "name": "ResidentDetailPage",
2941
2941
  "src": "src/pages/ResidentDetailPage.vue",
2942
2942
  "isDynamicEntry": true,
@@ -2944,36 +2944,36 @@
2944
2944
  "_AppShell-DAtHiuI6.js",
2945
2945
  "_browser-B6T5hjfR.js",
2946
2946
  "src/main.ts",
2947
- "_StatusDot-DBHAl4Il.js"
2947
+ "_StatusDot-BPE5syBa.js"
2948
2948
  ]
2949
2949
  },
2950
2950
  "src/pages/ResidentsIndexPage.vue": {
2951
- "file": "assets/ResidentsIndexPage-6LipuDjR.js",
2951
+ "file": "assets/ResidentsIndexPage-BZymgSAb.js",
2952
2952
  "name": "ResidentsIndexPage",
2953
2953
  "src": "src/pages/ResidentsIndexPage.vue",
2954
2954
  "isDynamicEntry": true,
2955
2955
  "imports": [
2956
2956
  "_AppShell-DAtHiuI6.js",
2957
2957
  "_browser-B6T5hjfR.js",
2958
- "_Tooltip-_LEjptLV.js",
2958
+ "_Tooltip-DkoeZfTs.js",
2959
2959
  "src/main.ts",
2960
2960
  "_eventSource-Bj_dZf6M.js",
2961
2961
  "_wallClock-DmaC1sKA.js",
2962
2962
  "_indexFormat-B-pd4r7Y.js",
2963
2963
  "_indexRow-BmK74Vp1.js",
2964
2964
  "_format-BldUwl_R.js",
2965
- "_StatusDot-DBHAl4Il.js"
2965
+ "_StatusDot-BPE5syBa.js"
2966
2966
  ]
2967
2967
  },
2968
2968
  "src/pages/RunRoutePage.vue": {
2969
- "file": "assets/RunRoutePage-DUalB1u2.js",
2969
+ "file": "assets/RunRoutePage-bgkjkA0p.js",
2970
2970
  "name": "RunRoutePage",
2971
2971
  "src": "src/pages/RunRoutePage.vue",
2972
2972
  "isDynamicEntry": true,
2973
2973
  "imports": [
2974
2974
  "_AppShell-DAtHiuI6.js",
2975
2975
  "_browser-B6T5hjfR.js",
2976
- "_Tooltip-_LEjptLV.js",
2976
+ "_Tooltip-DkoeZfTs.js",
2977
2977
  "_PendingTurnRow-BuRre8it.js",
2978
2978
  "src/main.ts",
2979
2979
  "_eventSource-Bj_dZf6M.js",
@@ -2984,7 +2984,7 @@
2984
2984
  "_durationTone-U_rOqo6r.js",
2985
2985
  "_sseReplay-DXC7kGbN.js",
2986
2986
  "_NotFoundPage-DtE-GgTk.js",
2987
- "_RunFoldRow-V-iSy64e.js"
2987
+ "_RunFoldRow-3m4CPRI4.js"
2988
2988
  ],
2989
2989
  "dynamicImports": [
2990
2990
  "../node_modules/@pierre/diffs/dist/index.js"
@@ -2994,14 +2994,14 @@
2994
2994
  ]
2995
2995
  },
2996
2996
  "src/pages/RunsIndexPage.vue": {
2997
- "file": "assets/RunsIndexPage-B9Ba1KdD.js",
2997
+ "file": "assets/RunsIndexPage-8S944AzB.js",
2998
2998
  "name": "RunsIndexPage",
2999
2999
  "src": "src/pages/RunsIndexPage.vue",
3000
3000
  "isDynamicEntry": true,
3001
3001
  "imports": [
3002
3002
  "_AppShell-DAtHiuI6.js",
3003
3003
  "_browser-B6T5hjfR.js",
3004
- "_Tooltip-_LEjptLV.js",
3004
+ "_Tooltip-DkoeZfTs.js",
3005
3005
  "_InputMenu-C6aPpe30.js",
3006
3006
  "src/main.ts",
3007
3007
  "_eventSource-Bj_dZf6M.js",
@@ -3011,18 +3011,18 @@
3011
3011
  "_format-BldUwl_R.js",
3012
3012
  "_durationTone-U_rOqo6r.js",
3013
3013
  "_RunsTabs-YSbUu5py.js",
3014
- "_StatusDot-DBHAl4Il.js"
3014
+ "_StatusDot-BPE5syBa.js"
3015
3015
  ]
3016
3016
  },
3017
3017
  "src/pages/ScheduledPage.vue": {
3018
- "file": "assets/ScheduledPage-KdjLtD_7.js",
3018
+ "file": "assets/ScheduledPage-8bBtG9y3.js",
3019
3019
  "name": "ScheduledPage",
3020
3020
  "src": "src/pages/ScheduledPage.vue",
3021
3021
  "isDynamicEntry": true,
3022
3022
  "imports": [
3023
3023
  "_AppShell-DAtHiuI6.js",
3024
3024
  "_browser-B6T5hjfR.js",
3025
- "_Tooltip-_LEjptLV.js",
3025
+ "_Tooltip-DkoeZfTs.js",
3026
3026
  "_wallClock-DmaC1sKA.js",
3027
3027
  "_indexFormat-B-pd4r7Y.js",
3028
3028
  "_format-BldUwl_R.js",
@@ -3030,7 +3030,7 @@
3030
3030
  ]
3031
3031
  },
3032
3032
  "src/pages/SettingsPage.vue": {
3033
- "file": "assets/SettingsPage-IT5l_NaL.js",
3033
+ "file": "assets/SettingsPage-DQeNvfaV.js",
3034
3034
  "name": "SettingsPage",
3035
3035
  "src": "src/pages/SettingsPage.vue",
3036
3036
  "isDynamicEntry": true,
@@ -3038,14 +3038,14 @@
3038
3038
  "_AppShell-DAtHiuI6.js",
3039
3039
  "_browser-B6T5hjfR.js",
3040
3040
  "_SettingSelect-BIzAsLk1.js",
3041
- "_Tooltip-_LEjptLV.js",
3041
+ "_Tooltip-DkoeZfTs.js",
3042
3042
  "_InputMenu-C6aPpe30.js",
3043
3043
  "_settingsApi-Dm6eaQcu.js",
3044
3044
  "_indexRow-BmK74Vp1.js"
3045
3045
  ]
3046
3046
  },
3047
3047
  "src/pages/UnitRoutePage.vue": {
3048
- "file": "assets/UnitRoutePage-DPBsvGPR.js",
3048
+ "file": "assets/UnitRoutePage-BUzw--Ii.js",
3049
3049
  "name": "UnitRoutePage",
3050
3050
  "src": "src/pages/UnitRoutePage.vue",
3051
3051
  "isDynamicEntry": true,
@@ -3059,7 +3059,7 @@
3059
3059
  "_durationTone-U_rOqo6r.js",
3060
3060
  "_sseReplay-DXC7kGbN.js",
3061
3061
  "_NotFoundPage-DtE-GgTk.js",
3062
- "_RunFoldRow-V-iSy64e.js"
3062
+ "_RunFoldRow-3m4CPRI4.js"
3063
3063
  ]
3064
3064
  }
3065
3065
  }
@@ -0,0 +1 @@
1
+ import{t as e}from"./AppShell-DAtHiuI6.js";import{An as t,Cn as n,Cr as r,Li as i,Mn as a,Pi as o,Sn as s,Tr as ee,Xr as c,_r as l,bn as u,ji as d,kn as f,ln as p,o as m,xn as h,yn as g}from"./browser-B6T5hjfR.js";import{a as _,c as te,d as ne,i as re,l as v,n as y,o as b,r as x,s as S,t as C,u as ie}from"./delivery-CTdOqpVK.js";import{t as ae}from"./wallClock-DmaC1sKA.js";var w=6e4;1440*w,10*w,5*w,60*w,10*w,60*w;var T={general:2,coding:15,review:5,research:3,explore:15,conductor:15};T.coding,T.coding,T.review;function E(e,t){return e.truncated&&e.completeFrom!==void 0&&Date.parse(`${t}T00:00:00Z`)<Date.parse(e.completeFrom)}Object.freeze({reviewers:[],agentLogins:[],agentCoauthors:[]}),Object.freeze({default:60,min:5,max:1440});var D={class:`text-xs text-muted`},O={key:1,class:`text-highlighted`},k={class:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-2`},A={key:0,class:`flex items-center gap-1`,"aria-label":`Repositories`},j={key:0,class:`rounded-md bg-accented px-2.5 py-1 text-xs font-medium text-highlighted`,"aria-current":`page`},M={class:`font-mono text-sm tabular-nums text-muted`},N={class:`mb-5 grid gap-3`},P={key:0,class:`text-sm text-muted`},F={class:`grid grid-cols-[repeat(auto-fit,minmax(190px,1fr))] gap-3`},I={class:`font-mono text-[0.6875rem] font-medium uppercase tracking-widest text-dimmed`},L={class:`font-mono text-2xl font-medium tabular-nums`},R={class:`text-xs text-muted`},z={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},B={class:`overflow-x-auto`},V={class:`weeks w-full min-w-[52rem] border-collapse whitespace-nowrap font-mono text-[0.8125rem] tabular-nums`},H=[`title`],U={key:0,class:`ml-1 text-xs`},oe={key:0,class:`text-xs text-muted`},W={class:`mb-5 grid gap-3 rounded-lg border border-default bg-elevated px-5 py-4`},G={key:0,class:`text-sm text-muted`},K={key:1,class:`overflow-x-auto`},q={class:`units w-full min-w-[52rem] border-collapse font-mono text-[0.8125rem] tabular-nums`},se=[`href`],ce={key:1,class:`text-dimmed`},le=[`title`],ue=[`href`],de={class:`text-xs text-muted`},fe={class:`rounded bg-accented px-1 py-0.5`},pe={class:`border-t border-default pt-3.5 text-xs text-dimmed`},me={key:0,class:`mb-2 font-mono tabular-nums text-muted`},he={class:`mt-2 grid gap-1.5`},J=`border-b border-muted bg-(--ui-bg-muted) px-2.5 py-1.5 text-xs font-medium text-muted whitespace-nowrap`,Y=`border-b border-muted px-2.5 py-1.5`,X=a({__name:`DeliveryPage`,setup(a){let w=m(`delivery`),T=g(()=>w?.report??null),X=g(()=>w?.repos??[]),Z=g(()=>T.value?ie(T.value):[]),Q=g(()=>T.value?y(T.value):void 0),$=e=>T.value?E(T.value,e):!1,ge=g(()=>T.value?.weeks.some(e=>$(e.week))??!1),_e=[1,2,4,8,13],ve=ae(void 0,6e4),ye=typeof window>`u`?``:window.location.search;return(a,m)=>{let g=ee(`RouterLink`);return T.value?(l(),h(e,{key:0,title:`${T.value.repo} delivery`,nav:`delivery`},{actions:c(()=>[u(`span`,D,[(l(),n(p,null,r(_e,(e,t)=>(l(),n(p,{key:e},[t>0?(l(),n(p,{key:0},[f(` · `)],64)):s(``,!0),e===T.value.range.weeks?(l(),n(`b`,O,i(e)+`w`,1)):(l(),h(g,{key:2,class:`text-primary hover:underline`,to:`/delivery/${T.value.repo}?weeks=${e}`},{default:c(()=>[f(i(e)+`w`,1)]),_:2},1032,[`to`]))],64))),64))])]),default:c(()=>[u(`div`,k,[X.value.length>1?(l(),n(`nav`,A,[(l(!0),n(p,null,r(X.value,e=>(l(),n(p,{key:e},[e===T.value.repo?(l(),n(`span`,j,i(e),1)):(l(),h(g,{key:1,class:`rounded-md px-2.5 py-1 text-xs text-muted no-underline hover:bg-elevated hover:text-highlighted`,to:`/delivery/${e}`},{default:c(()=>[f(i(e),1)]),_:2},1032,[`to`]))],64))),128))])):s(``,!0),u(`p`,M,i(d(b)(T.value.range.since))+` → `+i(d(b)(T.value.range.until))+` · `+i(T.value.range.weeks)+`w · weeks start Monday, UTC `,1)]),u(`section`,N,[Q.value?(l(),n(`p`,P,i(Q.value),1)):s(``,!0),u(`div`,F,[(l(!0),n(p,null,r(Z.value,e=>(l(),n(`div`,{key:e.label,class:`grid gap-0.5 rounded-lg border border-default bg-elevated px-4 py-3.5`},[u(`span`,I,i(e.label),1),u(`span`,L,i(e.value),1),u(`span`,R,i(e.note),1)]))),128))])]),u(`section`,z,[m[0]||=u(`div`,null,[u(`h2`,{class:`text-[0.9375rem] font-medium`},`By week`),u(`p`,{class:`text-sm text-muted`},`One row per Monday-start week · merged pull requests only`)],-1),u(`div`,B,[u(`table`,V,[u(`thead`,null,[u(`tr`,null,[u(`th`,{class:o([J,`text-left`])},`Week`,2),u(`th`,{class:o([J,`text-right`])},`Merged`,2),u(`th`,{class:o([J,`text-right`])},`Agent-authored`,2),u(`th`,{class:o([J,`text-right`])},`Issue → merge`,2),u(`th`,{class:o([J,`text-right`])},`First-pass CI`,2),u(`th`,{class:o([J,`text-right`])},`Rounds / PR`,2),u(`th`,{class:o([J,`text-right`])},`Findings`,2),u(`th`,{class:o([J,`text-right`])},`No human edit`,2),u(`th`,{class:o([J,`text-right`])},`Agent run min`,2)])]),u(`tbody`,null,[(l(!0),n(p,null,r(T.value.weeks,e=>(l(),n(`tr`,{key:e.week,class:o($(e.week)?`text-dimmed`:``)},[u(`td`,{class:o(Y),title:`${e.week} → ${e.until}`},[f(i(d(b)(e.week))+` – `+i(d(b)(e.until))+` `,1),$(e.week)?(l(),n(`span`,U,`(incomplete)`)):s(``,!0)],8,H),u(`td`,{class:o([Y,`text-right font-medium`])},i(e.prsMerged),3),u(`td`,{class:o([Y,`text-right`])},i(e.agentAuthoredPrs),3),u(`td`,{class:o([Y,`text-right`])},i(d(_)(e.leadTimeHours.median)),3),u(`td`,{class:o([Y,`text-right`])},i(d(C)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(te)(e.reviewRounds.perPr)),3),u(`td`,{class:o([Y,`text-right`])},i(d(x)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(S)(e.findings.noHumanEditShare)),3),u(`td`,{class:o([Y,`text-right`])},i(e.agentRuns.minutes.toFixed(0)),3)],2))),128))])])]),ge.value&&T.value.completeFrom?(l(),n(`p`,oe,` Incomplete weeks hold the newest pull requests the read reached — it is complete from `+i(d(v)(T.value.completeFrom))+` — so their numbers are a floor on the merges, not the week's. `,1)):s(``,!0)]),u(`section`,W,[m[3]||=u(`div`,null,[u(`h2`,{class:`text-[0.9375rem] font-medium`},`By unit`),u(`p`,{class:`text-sm text-muted`},` One row per board issue the pull requests link · the issue's opening starts the clock `)],-1),T.value.units.length===0?(l(),n(`p`,G,`Nothing merged in range.`)):(l(),n(`div`,K,[u(`table`,q,[u(`thead`,null,[u(`tr`,null,[u(`th`,{class:o([J,`text-left`])},`Issue`,2),u(`th`,{class:o([J,`text-left`])},`Unit`,2),u(`th`,{class:o([J,`text-left`])},`PRs`,2),u(`th`,{class:o([J,`text-right`])},`Issue → merge`,2),u(`th`,{class:o([J,`text-right`])},`First-pass CI`,2),u(`th`,{class:o([J,`text-right`])},`Rounds`,2),u(`th`,{class:o([J,`text-right`])},`Findings`,2),u(`th`,{class:o([J,`text-right`])},`No human edit`,2)])]),u(`tbody`,null,[(l(!0),n(p,null,r(T.value.units,e=>(l(),n(`tr`,{key:e.issue??`none`},[u(`td`,{class:o([Y,`whitespace-nowrap`])},[e.issue===null?(l(),n(`span`,ce,`—`)):(l(),n(`a`,{key:0,class:`text-primary hover:underline`,href:`https://github.com/${T.value.repo}/issues/${e.issue}`},`#`+i(e.issue),9,se))],2),u(`td`,{class:o([Y,`max-w-[28rem] truncate font-sans`]),title:e.title},i(e.title),11,le),u(`td`,{class:o([Y,`whitespace-nowrap`])},[(l(!0),n(p,null,r(e.prs,(e,t)=>(l(),n(p,{key:e},[t>0?(l(),n(p,{key:0},[f(`, `)],64)):s(``,!0),u(`a`,{class:`text-primary hover:underline`,href:`https://github.com/${T.value.repo}/pull/${e}`},i(e),9,ue)],64))),128))],2),u(`td`,{class:o([Y,`text-right`])},i(d(_)(e.leadTimeHours.median)),3),u(`td`,{class:o([Y,`text-right`])},i(d(C)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(e.reviewRounds.verdicts),3),u(`td`,{class:o([Y,`text-right`])},i(d(x)(e)),3),u(`td`,{class:o([Y,`text-right`])},i(d(S)(e.findings.noHumanEditShare)),3)]))),128))])])])),u(`p`,de,[m[1]||=f(` Machine-readable twin: `,-1),u(`code`,fe,`GET /delivery/`+i(T.value.repo)+`.json`,1),m[2]||=f(` (same gate). `,-1)])]),u(`footer`,pe,[T.value.snapshotAt?(l(),n(`p`,me,[f(` As of `+i(d(v)(T.value.snapshotAt))+`, `+i(d(ne)(T.value.snapshotAt,d(ve)))+` · `,1),t(g,{class:`text-primary hover:underline`,to:`/delivery/${T.value.repo}${d(re)(d(ye))}`},{default:c(()=>[...m[4]||=[f(`read GitHub now`,-1)]]),_:1},8,[`to`])])):s(``,!0),u(`details`,null,[m[14]||=u(`summary`,{class:`cursor-pointer text-muted`},`How these numbers are computed`,-1),u(`div`,he,[m[12]||=u(`div`,null,[u(`b`,null,`Snapshot.`),f(` GitHub's record of the merged pull requests (each one's timeline and its branch's workflow runs, the board issue its body links) is read on an interval and kept as a snapshot the page, its JSON twin and `),u(`code`,null,`delivery report`),f(` serve; `),u(`code`,null,`?fresh=1`),f(` reads GitHub now. The run history you may see joins on every load. `)],-1),m[13]||=u(`div`,null,[u(`b`,null,`Issue → merge`),f(` runs from the linked board issue's opening (a closing keyword or a `),u(`code`,null,`board item`),f(` reference in the body) to the merge; a pull request that links no issue counts from its own opening. `),u(`b`,null,`First-pass CI`),f(` is green when every pull-request-triggered workflow run (`),u(`code`,null,`pull_request`),f(`, `),u(`code`,null,`pull_request_target`),f(`) on the first head succeeded at its first attempt — a rerun or a red run fails it; a head with no such run is not counted. `),u(`b`,null,`Review rounds`),f(` are the review agent's verdicts; a `),u(`i`,null,`fix round`),f(` is a verdict that followed a push. `),u(`b`,null,`No human edit`),f(` is the share of the agent's findings on pull requests where every push after the first verdict was an agent's: a bot login, or a commit co-authored by an agent. `),u(`b`,null,`Agent run minutes`),f(` are the finished runs of this repository that named a pull request. `)],-1),u(`div`,null,[m[6]||=u(`b`,null,`Identities.`,-1),m[7]||=f(` Verdicts by `,-1),u(`code`,null,i(T.value.identities.reviewers.join(`, `)||`(none configured)`),1),m[8]||=f(`; agent logins end in `,-1),m[9]||=u(`code`,null,`[bot]`,-1),T.value.identities.agentLogins.length?(l(),n(p,{key:0},[m[5]||=f(`, plus `,-1),u(`code`,null,i(T.value.identities.agentLogins.join(`, `)),1)],64)):s(``,!0),m[10]||=f(`; agent co-authors named `,-1),u(`code`,null,i(T.value.identities.agentCoauthors.join(`, `)||`(none)`),1),m[11]||=f(`. `,-1)])])])])]),_:1},8,[`title`])):s(``,!0)}}});export{X as default};
@@ -1,2 +1,2 @@
1
- import{i as e,r as t,t as n}from"./AppShell-DAtHiuI6.js";import{An as r,Cn as i,Cr as a,Ft as o,Gr as s,Ii as c,Li as l,Mn as u,Pi as d,Pt as f,Qr as p,Sn as m,Tr as h,Xr as g,_r as _,bn as v,c as y,dr as ee,en as b,hr as x,ir as S,ji as C,kn as w,l as te,ln as T,o as E,rn as D,sr as O,t as k,wr as A,xi as j,xn as M,y as N,yi as P,yn as F,yr as I}from"./browser-B6T5hjfR.js";import{t as L}from"./Tooltip-_LEjptLV.js";import{i as R,n as ne,r as re,t as z}from"./PendingTurnRow-BuRre8it.js";import{b as ie,x as ae}from"./main-DUfSE0dj.js";import{t as oe}from"./eventSource-Bj_dZf6M.js";import{t as B}from"./wallClock-DmaC1sKA.js";import{n as V,r as se,t as H}from"./indexFormat-B-pd4r7Y.js";import{O as ce,a as le,i as ue,t as de,y as fe}from"./indexRow-BmK74Vp1.js";import{i as pe}from"./format-BldUwl_R.js";import{i as me,n as he,t as U}from"./durationTone-U_rOqo6r.js";import{D as W,E as ge,a as _e,c as G,d as ve,i as ye,n as be,o as xe,s as Se,t as K,u as q,v as Ce}from"./sseReplay-DXC7kGbN.js";var J=`To run this:`;function we(e,t){return e?t.trim()===``?`stop`:`steer`:`send`}var Te=`↪ Folded into`;function Ee(e){let t=e.trim();return t.startsWith(`To run this:`)?{kind:`handBack`,command:t.slice(J.length).trim()}:t.startsWith(Te)?{kind:`steerAck`,text:t}:{kind:`inline`,text:t}}function De(e){let t=/^\/runs\/([^/?#]+)(\?t=([^&#]+))?$/.exec(e);if(!t)return null;let n=decodeURIComponent(t[1]),r=t[3]?`?t=${t[3]}`:``;return{id:n,eventsUrl:`/runs/${t[1]}/events${r}`,stopUrl:`/runs/${t[1]}/stop${r}`}}function Y(e,t=60){let n=e.split(/\r?\n/).find(e=>e.trim()!==``)?.trim()??``;return n.length<=t?n||`New conversation`:`${n.slice(0,t-1).trimEnd()}…`}function Oe(e,t){let n=t-e;if(!(n>45e3))return`now`;let r=Math.floor(n/6e4);if(r<60)return`${Math.max(1,r)}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:V(e,t)}function ke(e,t){let n=e.surface??`web`,r=ue[n]??n,i=e.channelName?`${r} #${e.channelName}`:r;return{title:e.excerpt||e.title,when:H(e.lastAt,t),source:n===`web`?r:`${i} · read-only here`,runs:`${e.runs} run${e.runs===1?``:`s`}`,live:e.live}}var X={min:224,default:288,max:448,step:16};function Ae(e){let t=typeof e==`string`?Number(e):e;return typeof t!=`number`||!Number.isFinite(t)?X.default:Math.min(X.max,Math.max(X.min,Math.round(t)))}var Z={width:`sb.rail.width`,collapsed:`sb.rail.collapsed`};function je(e){return{width:Ae(e.width??void 0),collapsed:e.collapsed===`1`}}function Me(e,t){let n=e<5?`Still up`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`;return t?`${n}, ${t}.`:`${n}.`}function Ne(e,t){let n=t.trim();for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r.folded&&r.text.trim()===n)return r}return null}function Pe(e,t=60){return e<=t}function Fe(e){return e.key===`Enter`&&!e.shiftKey&&!e.isComposing}function Ie(e,t){let n=e.trim().toLowerCase();if(n===``)return 0;let r=t.toLowerCase(),i=0,a=-1,o=-1;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,i);if(t===-1)return null;a===-1&&(a=t),o=t,i=t+1}return a===-1?0:o-a}function Le(e,t){return t.trim()===``?[...e]:e.map((e,n)=>({row:e,i:n,score:Ie(t,e.title)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.row)}function Re(e){if(!(e.metaKey||e.ctrlKey))return null;let t=e.key.toLowerCase();return t===`o`&&e.shiftKey?`newThread`:t===`k`&&!e.shiftKey?`search`:null}function ze(e,t){return t?``:e===`steer`?`Say what to add — it folds into the run at its next step`:e===`stop`?`A run is working — type to steer it, or stop it`:`Review a pull request, ship a fix, investigate a run… or type / for a command`}function Q(e){let t=new Map;for(let n of e){let[e,r]=n.chat.split(` `,2);if(!e)continue;let i=t.get(e)??{name:e,verbs:[]};r===void 0?i.bare=n:i.verbs.push({verb:r,command:n}),t.set(e,i)}return[...t.values()]}function Be(e,t,n){if(t===``)return[...e];let r=t.toLowerCase(),i=e.filter(e=>n(e)[0].toLowerCase().startsWith(r));return i.length>0?i:e.map((e,r)=>{let i=n(e).map(e=>Ie(t,e)).filter(e=>e!==null);return i.length===0?null:{item:e,i:r,score:Math.min(...i)}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.item)}function Ve(e,t=0,n=new Set){let r=(e.args??[]).slice(t),i=(e.options??[]).filter(e=>!n.has(He(e.form))).map(e=>`[${e.form}]`);return[...r,...i].join(` `)}var He=e=>e.split(` `,1)[0];function Ue(e,t){let n=new Set,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a.startsWith(`-`)){n.add(a);let t=(e.options??[]).find(e=>He(e.form)===a);t&&t.form.includes(` `)&&i++}else r++}return{positionals:r,flags:n}}function We(e,t){let n=/^\/([^\n]*)$/.exec(e);if(!n||t.length===0)return null;let r=n[1].split(` `),i=r[r.length-1],a=r.slice(0,-1).filter(e=>e!==``),o=e.slice(0,e.length-i.length),s=Q(t);if(a.length===0)return{level:`group`,head:o,partial:i,rows:Be(s,i,e=>[e.name,...e.bare?[e.bare.describe]:[],...e.verbs.map(e=>e.command.describe)]).map(e=>({insert:e.name,label:`/${e.name}`,describe:e.bare?e.verbs.length>0?`${e.bare.describe} · also ${e.verbs.map(e=>e.verb).join(`, `)}`:e.bare.describe:e.verbs.map(e=>e.verb).join(` · `),kind:e.bare&&e.verbs.length===0?`command`:`group`,acceptable:!0}))};let c=s.find(e=>e.name===a[0]);if(!c)return null;if(a.length===1){let e=Be(c.verbs,i,e=>[e.verb,e.command.describe]);if(e.length===0&&c.bare&&i!==``)return Ke(c.bare,o,i,[]);if(e.length===0&&!c.bare)return{level:`verb`,head:o,partial:i,rows:[]};let t=e.map(e=>({insert:e.verb,label:`/${e.command.chat}`,describe:e.command.describe,kind:`command`,acceptable:!0}));return c.bare&&i===``&&t.unshift(Ge(c.bare,0,new Set)),{level:`verb`,head:o,partial:i,rows:t}}let l=c.verbs.find(e=>e.verb===a[1]);return l?Ke(l.command,o,i,a.slice(2)):c.bare?Ke(c.bare,o,i,a.slice(1)):null}function Ge(e,t,n){let r=Ve(e,t,n);return{insert:``,label:`/${e.chat}`,describe:r?`${r} — ${e.describe}`:e.describe,kind:`usage`,acceptable:!1}}function Ke(e,t,n,r){let i=Ue(e,r);return n.startsWith(`-`)?{level:`tail`,head:t,partial:n,rows:Be((e.options??[]).filter(e=>!i.flags.has(He(e.form))),n,e=>[He(e.form),e.describe]).map(e=>({insert:He(e.form),label:e.form,describe:e.describe,kind:`option`,acceptable:!0})),command:e}:{level:`tail`,head:t,partial:n,rows:[Ge(e,i.positionals,i.flags)],command:e}}function qe(e,t){let n=e.rows[t];if(!n)return null;if(n.acceptable){if(!n.insert.toLowerCase().startsWith(e.partial.toLowerCase()))return null;let t=n.insert.slice(e.partial.length);return t===``?null:{text:t,acceptable:!0}}if(e.partial!==``||n.kind!==`usage`)return null;let[r,...i]=n.describe.split(` — `);return i.length===0?null:{text:r,acceptable:!1}}function $(e,t){return`${e.head}${t.insert} `}function Je(e,t){if(!e.startsWith(`/`))return e;let n=e.slice(1),[r,i]=n.split(/\s+/,2);return t.some(e=>e.chat===r||i!==void 0&&e.chat===`${r} ${i}`)?n:e}var Ye={class:`composer-wrap relative`},Xe={key:0,class:`palette absolute bottom-full left-0 right-0 z-20 mb-2 max-h-72 overflow-y-auto rounded-xl border border-default bg-(--ui-bg-elevated) p-1 shadow-sm`,role:`listbox`,"aria-label":`Commands`,"data-testid":`palette`},Ze={key:0,class:`px-3 py-2 font-mono text-xs text-dimmed`},Qe=[`aria-selected`,`data-insert`,`data-kind`,`data-label`,`onClick`,`onMouseenter`],$e={class:`chat shrink-0 font-mono text-[0.8rem] font-medium text-highlighted`},et={class:`describe min-w-0 flex-1 truncate text-[0.8rem] text-muted`},tt={key:0,class:`shrink-0 rounded border border-default px-1 font-mono text-[0.62rem] text-dimmed`,"aria-hidden":`true`},nt=[`data-mode`],rt={class:`relative min-w-0 flex-1`},it=[`data-acceptable`],at={class:`invisible`},ot={class:`text-dimmed`},st=[`rows`,`value`,`placeholder`,`autofocus`,`aria-expanded`],ct=[`aria-hidden`,`data-hint`,`data-shown`],lt=u({__name:`ChatComposer`,props:{modelValue:{},mode:{},hint:{},autofocus:{type:Boolean},sweepOnMount:{type:Boolean},commands:{}},emits:[`update:modelValue`,`submit`,`stop`],setup(e,{expose:t,emit:n}){let o=e,c=n,u=j(null),p=j(!1),h=j(!1),y=F(()=>Math.min(8,Math.max(1,o.modelValue.split(`
1
+ import{i as e,r as t,t as n}from"./AppShell-DAtHiuI6.js";import{An as r,Cn as i,Cr as a,Ft as o,Gr as s,Ii as c,Li as l,Mn as u,Pi as d,Pt as f,Qr as p,Sn as m,Tr as h,Xr as g,_r as _,bn as v,c as y,dr as ee,en as b,hr as x,ir as S,ji as C,kn as w,l as te,ln as T,o as E,rn as D,sr as O,t as k,wr as A,xi as j,xn as M,y as N,yi as P,yn as F,yr as I}from"./browser-B6T5hjfR.js";import{t as L}from"./Tooltip-DkoeZfTs.js";import{i as R,n as ne,r as re,t as z}from"./PendingTurnRow-BuRre8it.js";import{b as ie,x as ae}from"./main-B6LcgNM6.js";import{t as oe}from"./eventSource-Bj_dZf6M.js";import{t as B}from"./wallClock-DmaC1sKA.js";import{n as V,r as se,t as H}from"./indexFormat-B-pd4r7Y.js";import{O as ce,a as le,i as ue,t as de,y as fe}from"./indexRow-BmK74Vp1.js";import{i as pe}from"./format-BldUwl_R.js";import{i as me,n as he,t as U}from"./durationTone-U_rOqo6r.js";import{D as W,E as ge,a as _e,c as G,d as ve,i as ye,n as be,o as xe,s as Se,t as K,u as q,v as Ce}from"./sseReplay-DXC7kGbN.js";var J=`To run this:`;function we(e,t){return e?t.trim()===``?`stop`:`steer`:`send`}var Te=`↪ Folded into`;function Ee(e){let t=e.trim();return t.startsWith(`To run this:`)?{kind:`handBack`,command:t.slice(J.length).trim()}:t.startsWith(Te)?{kind:`steerAck`,text:t}:{kind:`inline`,text:t}}function De(e){let t=/^\/runs\/([^/?#]+)(\?t=([^&#]+))?$/.exec(e);if(!t)return null;let n=decodeURIComponent(t[1]),r=t[3]?`?t=${t[3]}`:``;return{id:n,eventsUrl:`/runs/${t[1]}/events${r}`,stopUrl:`/runs/${t[1]}/stop${r}`}}function Y(e,t=60){let n=e.split(/\r?\n/).find(e=>e.trim()!==``)?.trim()??``;return n.length<=t?n||`New conversation`:`${n.slice(0,t-1).trimEnd()}…`}function Oe(e,t){let n=t-e;if(!(n>45e3))return`now`;let r=Math.floor(n/6e4);if(r<60)return`${Math.max(1,r)}m`;let i=Math.floor(r/60);if(i<24)return`${i}h`;let a=Math.floor(i/24);return a<7?`${a}d`:V(e,t)}function ke(e,t){let n=e.surface??`web`,r=ue[n]??n,i=e.channelName?`${r} #${e.channelName}`:r;return{title:e.excerpt||e.title,when:H(e.lastAt,t),source:n===`web`?r:`${i} · read-only here`,runs:`${e.runs} run${e.runs===1?``:`s`}`,live:e.live}}var X={min:224,default:288,max:448,step:16};function Ae(e){let t=typeof e==`string`?Number(e):e;return typeof t!=`number`||!Number.isFinite(t)?X.default:Math.min(X.max,Math.max(X.min,Math.round(t)))}var Z={width:`sb.rail.width`,collapsed:`sb.rail.collapsed`};function je(e){return{width:Ae(e.width??void 0),collapsed:e.collapsed===`1`}}function Me(e,t){let n=e<5?`Still up`:e<12?`Good morning`:e<18?`Good afternoon`:`Good evening`;return t?`${n}, ${t}.`:`${n}.`}function Ne(e,t){let n=t.trim();for(let t=e.length-1;t>=0;t--){let r=e[t];if(!r.folded&&r.text.trim()===n)return r}return null}function Pe(e,t=60){return e<=t}function Fe(e){return e.key===`Enter`&&!e.shiftKey&&!e.isComposing}function Ie(e,t){let n=e.trim().toLowerCase();if(n===``)return 0;let r=t.toLowerCase(),i=0,a=-1,o=-1;for(let e of n){if(e===` `)continue;let t=r.indexOf(e,i);if(t===-1)return null;a===-1&&(a=t),o=t,i=t+1}return a===-1?0:o-a}function Le(e,t){return t.trim()===``?[...e]:e.map((e,n)=>({row:e,i:n,score:Ie(t,e.title)})).filter(e=>e.score!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.row)}function Re(e){if(!(e.metaKey||e.ctrlKey))return null;let t=e.key.toLowerCase();return t===`o`&&e.shiftKey?`newThread`:t===`k`&&!e.shiftKey?`search`:null}function ze(e,t){return t?``:e===`steer`?`Say what to add — it folds into the run at its next step`:e===`stop`?`A run is working — type to steer it, or stop it`:`Review a pull request, ship a fix, investigate a run… or type / for a command`}function Q(e){let t=new Map;for(let n of e){let[e,r]=n.chat.split(` `,2);if(!e)continue;let i=t.get(e)??{name:e,verbs:[]};r===void 0?i.bare=n:i.verbs.push({verb:r,command:n}),t.set(e,i)}return[...t.values()]}function Be(e,t,n){if(t===``)return[...e];let r=t.toLowerCase(),i=e.filter(e=>n(e)[0].toLowerCase().startsWith(r));return i.length>0?i:e.map((e,r)=>{let i=n(e).map(e=>Ie(t,e)).filter(e=>e!==null);return i.length===0?null:{item:e,i:r,score:Math.min(...i)}}).filter(e=>e!==null).sort((e,t)=>e.score-t.score||e.i-t.i).map(e=>e.item)}function Ve(e,t=0,n=new Set){let r=(e.args??[]).slice(t),i=(e.options??[]).filter(e=>!n.has(He(e.form))).map(e=>`[${e.form}]`);return[...r,...i].join(` `)}var He=e=>e.split(` `,1)[0];function Ue(e,t){let n=new Set,r=0;for(let i=0;i<t.length;i++){let a=t[i];if(a.startsWith(`-`)){n.add(a);let t=(e.options??[]).find(e=>He(e.form)===a);t&&t.form.includes(` `)&&i++}else r++}return{positionals:r,flags:n}}function We(e,t){let n=/^\/([^\n]*)$/.exec(e);if(!n||t.length===0)return null;let r=n[1].split(` `),i=r[r.length-1],a=r.slice(0,-1).filter(e=>e!==``),o=e.slice(0,e.length-i.length),s=Q(t);if(a.length===0)return{level:`group`,head:o,partial:i,rows:Be(s,i,e=>[e.name,...e.bare?[e.bare.describe]:[],...e.verbs.map(e=>e.command.describe)]).map(e=>({insert:e.name,label:`/${e.name}`,describe:e.bare?e.verbs.length>0?`${e.bare.describe} · also ${e.verbs.map(e=>e.verb).join(`, `)}`:e.bare.describe:e.verbs.map(e=>e.verb).join(` · `),kind:e.bare&&e.verbs.length===0?`command`:`group`,acceptable:!0}))};let c=s.find(e=>e.name===a[0]);if(!c)return null;if(a.length===1){let e=Be(c.verbs,i,e=>[e.verb,e.command.describe]);if(e.length===0&&c.bare&&i!==``)return Ke(c.bare,o,i,[]);if(e.length===0&&!c.bare)return{level:`verb`,head:o,partial:i,rows:[]};let t=e.map(e=>({insert:e.verb,label:`/${e.command.chat}`,describe:e.command.describe,kind:`command`,acceptable:!0}));return c.bare&&i===``&&t.unshift(Ge(c.bare,0,new Set)),{level:`verb`,head:o,partial:i,rows:t}}let l=c.verbs.find(e=>e.verb===a[1]);return l?Ke(l.command,o,i,a.slice(2)):c.bare?Ke(c.bare,o,i,a.slice(1)):null}function Ge(e,t,n){let r=Ve(e,t,n);return{insert:``,label:`/${e.chat}`,describe:r?`${r} — ${e.describe}`:e.describe,kind:`usage`,acceptable:!1}}function Ke(e,t,n,r){let i=Ue(e,r);return n.startsWith(`-`)?{level:`tail`,head:t,partial:n,rows:Be((e.options??[]).filter(e=>!i.flags.has(He(e.form))),n,e=>[He(e.form),e.describe]).map(e=>({insert:He(e.form),label:e.form,describe:e.describe,kind:`option`,acceptable:!0})),command:e}:{level:`tail`,head:t,partial:n,rows:[Ge(e,i.positionals,i.flags)],command:e}}function qe(e,t){let n=e.rows[t];if(!n)return null;if(n.acceptable){if(!n.insert.toLowerCase().startsWith(e.partial.toLowerCase()))return null;let t=n.insert.slice(e.partial.length);return t===``?null:{text:t,acceptable:!0}}if(e.partial!==``||n.kind!==`usage`)return null;let[r,...i]=n.describe.split(` — `);return i.length===0?null:{text:r,acceptable:!1}}function $(e,t){return`${e.head}${t.insert} `}function Je(e,t){if(!e.startsWith(`/`))return e;let n=e.slice(1),[r,i]=n.split(/\s+/,2);return t.some(e=>e.chat===r||i!==void 0&&e.chat===`${r} ${i}`)?n:e}var Ye={class:`composer-wrap relative`},Xe={key:0,class:`palette absolute bottom-full left-0 right-0 z-20 mb-2 max-h-72 overflow-y-auto rounded-xl border border-default bg-(--ui-bg-elevated) p-1 shadow-sm`,role:`listbox`,"aria-label":`Commands`,"data-testid":`palette`},Ze={key:0,class:`px-3 py-2 font-mono text-xs text-dimmed`},Qe=[`aria-selected`,`data-insert`,`data-kind`,`data-label`,`onClick`,`onMouseenter`],$e={class:`chat shrink-0 font-mono text-[0.8rem] font-medium text-highlighted`},et={class:`describe min-w-0 flex-1 truncate text-[0.8rem] text-muted`},tt={key:0,class:`shrink-0 rounded border border-default px-1 font-mono text-[0.62rem] text-dimmed`,"aria-hidden":`true`},nt=[`data-mode`],rt={class:`relative min-w-0 flex-1`},it=[`data-acceptable`],at={class:`invisible`},ot={class:`text-dimmed`},st=[`rows`,`value`,`placeholder`,`autofocus`,`aria-expanded`],ct=[`aria-hidden`,`data-hint`,`data-shown`],lt=u({__name:`ChatComposer`,props:{modelValue:{},mode:{},hint:{},autofocus:{type:Boolean},sweepOnMount:{type:Boolean},commands:{}},emits:[`update:modelValue`,`submit`,`stop`],setup(e,{expose:t,emit:n}){let o=e,c=n,u=j(null),p=j(!1),h=j(!1),y=F(()=>Math.min(8,Math.max(1,o.modelValue.split(`
2
2
  `).length))),b={send:{icon:`i-lucide-arrow-up`,label:`Send`},steer:{icon:`i-lucide-corner-down-right`,label:`Steer the run`},stop:{icon:`i-lucide-square`,label:`Stop the run`}},x=F(()=>b[o.mode]),C=F(()=>ze(o.mode,o.hint)),w=F(()=>o.hint?o.hint:o.mode===`steer`?`Enter folds this into the run in flight`:o.mode===`stop`?`A run is in flight · type to steer it, or stop it`:`Enter to send · Shift+Enter for a new line · / for a command`),E=F(()=>p.value||o.hint!==void 0||o.mode!==`send`),O=F(()=>We(o.modelValue,o.commands??[])),k=F(()=>O.value?.rows??[]),A=j(!1),P=j(0),I=F(()=>O.value!==null&&!A.value),L=F(()=>I.value&&O.value?qe(O.value,P.value):null);s(()=>`${O.value?.level??``}|${O.value?.head??``}`,()=>{A.value=!1,P.value=0}),s(k,e=>{P.value>=e.length&&(P.value=Math.max(0,e.length-1))});function R(e){O.value&&e.acceptable&&(c(`update:modelValue`,$(O.value,e)),B())}function ne(){let e=u.value;return!e||e.selectionStart===e.value.length&&e.selectionEnd===e.value.length}function re(e){c(`update:modelValue`,e.target.value)}function z(e){if(I.value){if(e.key===`ArrowDown`){e.preventDefault(),k.value.length>0&&(P.value=(P.value+1)%k.value.length);return}if(e.key===`ArrowUp`){e.preventDefault(),k.value.length>0&&(P.value=(P.value-1+k.value.length)%k.value.length);return}if(e.key===`Escape`){e.preventDefault(),A.value=!0;return}let t=k.value[P.value];if(e.key===`Tab`&&t?.acceptable){e.preventDefault(),R(t);return}if(e.key===`ArrowRight`&&L.value?.acceptable&&t&&ne()){e.preventDefault(),R(t);return}if(e.key===`Enter`&&!e.shiftKey&&t?.acceptable){e.preventDefault(),R(t);return}}Fe(e)&&(e.preventDefault(),ie())}function ie(){o.mode===`stop`?c(`stop`):o.modelValue.trim()!==``&&c(`submit`)}function ae(){h.value=!1,S().then(()=>{h.value=!0})}function oe(){p.value=!0,ae()}function B(){S().then(()=>{let e=u.value;e&&(e.focus(),e.setSelectionRange(e.value.length,e.value.length),document.activeElement===e&&!p.value&&oe())})}return s(()=>o.hint,e=>{e&&B()}),ee(()=>{o.autofocus&&B(),o.sweepOnMount&&ae()}),t({focus:B}),(t,n)=>{let o=N,s=te;return _(),i(`div`,Ye,[r(f,{name:`sb-rise`},{default:g(()=>[I.value?(_(),i(`div`,Xe,[k.value.length===0?(_(),i(`p`,Ze,` No command matches "`+l(e.modelValue)+`". `,1)):m(``,!0),(_(!0),i(T,null,a(k.value,(e,t)=>(_(),i(`button`,{key:e.label,type:`button`,role:`option`,class:d([`item flex w-full items-baseline gap-3 rounded-lg px-3 py-1.5 text-left transition-colors duration-150 ease-out`,t===P.value?`bg-(--ui-bg-accented)`:`hover:bg-(--ui-bg-muted)`]),"aria-selected":t===P.value?`true`:`false`,"data-insert":e.insert,"data-kind":e.kind,"data-label":e.label,onMousedown:n[0]||=D(()=>{},[`prevent`]),onClick:t=>R(e),onMouseenter:e=>P.value=t},[v(`span`,$e,l(e.label),1),v(`span`,et,l(e.describe),1),t===P.value&&e.acceptable?(_(),i(`kbd`,tt,`Tab`)):m(``,!0)],42,Qe))),128))])):m(``,!0)]),_:1}),v(`div`,{class:d([`ring relative rounded-2xl`,h.value?`ring-sweep`:``]),onAnimationend:n[2]||=e=>h.value=!1},[v(`form`,{class:d([`composer relative flex items-end gap-2 rounded-2xl border bg-default px-3 py-2 transition-colors duration-150 ease-out`,p.value?`border-primary`:`border-default hover:border-accented`]),"data-mode":e.mode,onSubmit:D(ie,[`prevent`])},[v(`div`,rt,[L.value?(_(),i(`div`,{key:0,class:`ghost composer-text pointer-events-none absolute inset-0 overflow-hidden whitespace-pre-wrap break-words`,"aria-hidden":`true`,"data-testid":`ghost`,"data-acceptable":L.value.acceptable?`1`:`0`},[v(`span`,at,l(e.modelValue),1),v(`span`,ot,l(L.value.text),1)],8,it)):m(``,!0),v(`textarea`,{ref_key:`box`,ref:u,class:`box composer-text relative block min-h-6 w-full resize-none bg-transparent text-highlighted outline-none placeholder:text-dimmed`,rows:y.value,value:e.modelValue,placeholder:C.value,autofocus:e.autofocus,"aria-label":`Message`,"aria-expanded":I.value?`true`:void 0,autocomplete:`off`,spellcheck:`true`,onInput:re,onKeydown:z,onFocus:oe,onBlur:n[1]||=e=>p.value=!1},null,40,st)]),r(s,{type:`submit`,class:`control shrink-0 rounded-full transition-transform duration-150 ease-out active:scale-95`,color:e.mode===`stop`?`neutral`:`primary`,variant:e.mode===`stop`?`outline`:`solid`,size:`sm`,"aria-label":x.value.label,title:x.value.label,disabled:e.mode===`send`&&e.modelValue.trim()===``,"data-mode":e.mode},{default:g(()=>[r(f,{name:`sb-fade`,mode:`out-in`},{default:g(()=>[(_(),M(o,{key:x.value.icon,name:x.value.icon,class:`size-4`,"aria-hidden":`true`},null,8,[`name`]))]),_:1})]),_:1},8,[`color`,`variant`,`aria-label`,`title`,`disabled`,`data-mode`])],42,nt)],34),v(`p`,{class:d([`hint mt-1.5 min-h-[1.1rem] select-none px-3 font-mono text-[0.7rem] text-dimmed transition-opacity duration-150 ease-out`,E.value?`opacity-100`:`opacity-0`]),"aria-hidden":E.value?void 0:`true`,"data-hint":e.hint?`handback`:e.mode,"data-shown":E.value?`1`:`0`},l(w.value),11,ct)])}}}),ut={class:`thread-tip flex max-w-xs flex-col gap-1 text-xs`},dt={class:`tip-title leading-snug text-highlighted`},ft={class:`flex flex-wrap items-center gap-x-1.5 gap-y-0.5 font-mono text-[0.68rem] text-muted`},pt={class:`tip-when tabular-nums`},mt={class:`tip-source inline-flex items-center gap-1`},ht={class:`tip-runs`},gt={key:0,class:`tip-live inline-flex items-center gap-1 text-toned`},_t=u({__name:`ThreadTip`,props:{row:{},now:{}},setup(e){let t=e,n=F(()=>ke(t.row,t.now));return(t,r)=>(_(),i(`div`,ut,[v(`p`,dt,l(n.value.title),1),v(`p`,ft,[v(`span`,pt,l(n.value.when),1),r[1]||=v(`span`,{"aria-hidden":`true`},`·`,-1),v(`span`,mt,[e.row.surface===`slack`?(_(),M(me,{key:0})):m(``,!0),w(l(n.value.source),1)]),r[2]||=v(`span`,{"aria-hidden":`true`},`·`,-1),v(`span`,ht,l(n.value.runs),1),n.value.live?(_(),i(`span`,gt,[...r[0]||=[v(`span`,{class:`size-1.5 rounded-full bg-ok`,"aria-hidden":`true`},null,-1),w(`live`,-1)]])):m(``,!0)])]))}}),vt={class:`rail flex flex-col gap-1 text-[0.8rem]`,"aria-label":`Recent threads`},yt={class:`filter mb-2 flex items-center gap-2 rounded-lg border border-default px-2.5 py-1.5 transition-colors duration-150 ease-out focus-within:border-primary hover:border-accented`},bt={key:0,class:`rounded border border-default px-1 font-mono text-[0.65rem] text-dimmed`},xt={key:0,class:`empty px-3 py-1 text-xs text-dimmed`},St={key:1,class:`nomatch px-3 py-1 text-xs text-dimmed`},Ct={key:0,class:`dot mt-px size-1.5 shrink-0 self-center rounded-full bg-ok motion-safe:animate-pulse`,"aria-label":`a run is in flight`},wt={class:`title min-w-0 flex-1 truncate text-toned group-hover:text-highlighted group-aria-[current=page]:text-highlighted`},Tt={class:`when shrink-0 font-mono text-[0.7rem] tabular-nums text-dimmed`},Et={class:`retention px-3 pt-1 text-[0.7rem] leading-relaxed text-dimmed`},Dt={class:`model px-3 pt-2 text-[0.7rem] leading-relaxed text-dimmed`,"data-testid":`what-is-a-thread`},Ot=500,kt=u({__name:`ConversationRail`,props:{rows:{},current:{},now:{},retention:{}},setup(e,{expose:t}){let n=e,s=j(``),c=j(null),u=F(()=>Le(n.rows,s.value));function d(){c.value?.focus(),c.value?.select()}function f(e){e.key===`Escape`&&(s.value=``,c.value?.blur())}return t({focusFilter:d}),(t,n)=>{let d=N,y=h(`RouterLink`),ee=L;return _(),i(`nav`,vt,[r(y,{class:`new group mb-3 flex items-center gap-2 rounded-xl bg-inverted px-3 py-2 font-medium text-inverted no-underline transition-[transform,opacity] duration-150 ease-out hover:-translate-y-px hover:opacity-90 active:translate-y-0 active:opacity-100`,to:`/threads`,"aria-current":e.current===``?`page`:void 0,"data-testid":`new-thread`},{default:g(()=>[r(d,{name:`i-lucide-plus`,class:`size-4 shrink-0 transition-transform duration-150 ease-out group-hover:rotate-90`,"aria-hidden":`true`}),n[1]||=v(`span`,null,`New thread`,-1),n[2]||=v(`span`,{class:`kbd ml-auto flex gap-0.5 font-mono text-[0.65rem] opacity-70`,"aria-label":`shortcut shift command O`},[v(`kbd`,{class:`rounded border border-current/30 px-1`},`⇧`),v(`kbd`,{class:`rounded border border-current/30 px-1`},`⌘`),v(`kbd`,{class:`rounded border border-current/30 px-1`},`O`)],-1)]),_:1},8,[`aria-current`]),v(`label`,yt,[r(d,{name:`i-lucide-search`,class:`size-3.5 shrink-0 text-dimmed`,"aria-hidden":`true`}),p(v(`input`,{ref_key:`filter`,ref:c,"onUpdate:modelValue":n[0]||=e=>s.value=e,class:`min-w-0 flex-1 bg-transparent text-[0.8rem] text-highlighted outline-none placeholder:text-dimmed`,type:`text`,placeholder:`Filter recent`,"aria-label":`Filter recent threads`,autocomplete:`off`,onKeydown:f},null,544),[[b,s.value]]),s.value?m(``,!0):(_(),i(`kbd`,bt,`⌘K`))]),n[8]||=v(`p`,{class:`label px-3 pb-1 font-mono text-[0.65rem] font-medium uppercase tracking-wider text-dimmed`},`Recent`,-1),e.rows.length===0?(_(),i(`p`,xt,`Nothing yet. Ask something.`)):u.value.length===0?(_(),i(`p`,St,`Nothing matches "`+l(s.value)+`".`,1)):m(``,!0),r(o,{name:`sb-rise`,tag:`div`,class:`rows flex flex-col gap-0.5`},{default:g(()=>[(_(!0),i(T,null,a(u.value,t=>(_(),i(`div`,{key:t.id},[r(ee,{"delay-duration":Ot,content:{side:`right`,sideOffset:12,align:`start`},ui:{content:`h-auto max-w-xs px-2.5 py-2`}},{content:g(()=>[r(_t,{row:t,now:e.now},null,8,[`row`,`now`])]),default:g(()=>[r(y,{class:`row group relative flex items-baseline gap-2 rounded-lg px-3 py-1.5 no-underline transition-colors duration-150 ease-out hover:bg-(--ui-bg-muted) aria-[current=page]:bg-(--ui-bg-accented)`,to:`/threads/${encodeURIComponent(t.id)}`,"aria-current":t.id===e.current?`page`:void 0,"data-surface":t.surface},{default:g(()=>[n[3]||=v(`span`,{class:`bar absolute left-0 top-1/2 h-4 w-0.5 -translate-y-1/2 rounded-full bg-primary opacity-0 transition-opacity duration-150 ease-out group-aria-[current=page]:opacity-100`,"aria-hidden":`true`},null,-1),t.live?(_(),i(`span`,Ct)):m(``,!0),v(`span`,wt,l(t.title),1),v(`span`,Tt,l(C(Oe)(t.lastAt,e.now)),1)]),_:2},1032,[`to`,`aria-current`,`data-surface`])]),_:2},1024)]))),128))]),_:1}),r(y,{class:`all mt-3 flex items-center gap-1.5 px-3 py-1 text-xs font-medium text-muted no-underline transition-colors duration-150 ease-out hover:text-highlighted`,to:`/runs`,"data-testid":`all-runs`},{default:g(()=>[n[4]||=w(` All runs `,-1),r(d,{name:`i-lucide-arrow-right`,class:`size-3 transition-transform duration-150 ease-out group-hover:translate-x-0.5`,"aria-hidden":`true`})]),_:1}),v(`p`,Et,l(e.retention),1),v(`p`,Dt,[n[6]||=w(` A thread is a conversation; each message you send is a run. `,-1),r(y,{class:`text-muted hover:text-highlighted`,to:`/runs`},{default:g(()=>[...n[5]||=[w(`Runs`,-1)]]),_:1}),n[7]||=w(` lists every run across everyone's threads. `,-1)])])}}}),At={class:`empty mx-auto flex w-full max-w-2xl flex-col items-center gap-5 px-3 py-6 text-center`},jt={class:`flex flex-col gap-1.5`},Mt={class:`greeting sb-stagger text-xl font-medium tracking-tight text-highlighted`,style:{"--sb-i":`1`}},Nt={class:`sb-stagger w-full text-left`,style:{"--sb-i":`3`}},Pt={key:0,class:`chips flex flex-wrap justify-center gap-2`,"aria-label":`Suggestions`},Ft=[`onClick`],It=u({__name:`EmptyState`,props:{name:{},hour:{},suggestions:{}},emits:[`pick`],setup(e,{emit:n}){let o=n;return(n,s)=>(_(),i(`section`,At,[r(t,{draw:``,idle:``,class:`mark-lg sb-stagger text-highlighted`,style:{"font-size":`3.25rem`,"--sb-i":`0`}}),v(`div`,jt,[v(`h2`,Mt,l(C(Me)(e.hour,e.name)),1),s[0]||=v(`p`,{class:`sub sb-stagger text-[0.875rem] text-muted`,style:{"--sb-i":`2`}},` Ask in plain words. The right agent picks it up, and you watch it work here. `,-1)]),v(`div`,Nt,[A(n.$slots,`default`)]),e.suggestions.length>0?(_(),i(`ul`,Pt,[(_(!0),i(T,null,a(e.suggestions,(e,t)=>(_(),i(`li`,{key:e,class:`sb-stagger`,style:c({"--sb-i":t+4})},[v(`button`,{type:`button`,class:`chip rounded-full border border-default px-3 py-1 text-[0.8rem] text-toned transition-[color,border-color,background-color,transform] duration-150 ease-out hover:-translate-y-px hover:border-accented hover:bg-(--ui-bg-muted) hover:text-highlighted focus-visible:outline-2 focus-visible:outline-primary active:translate-y-0`,onClick:t=>o(`pick`,e)},l(e),9,Ft)],4))),128))])):m(``,!0)]))}}),Lt=[`data-pending`],Rt={class:`meta flex items-baseline gap-2 pr-1 font-mono text-[0.7rem] text-dimmed`},zt={key:0,class:`failed text-bad`},Bt={key:0,class:`folded text-muted`},Vt=[`title`],Ht=u({__name:`PersonTurn`,props:{text:{},at:{},now:{},pending:{type:Boolean},folded:{},failed:{}},setup(e){let t=e,n=F(()=>H(t.at,t.now));return(t,a)=>(_(),i(`div`,{class:`turn person flex flex-col items-end gap-1`,"data-pending":e.pending?`1`:void 0},[v(`div`,{class:d([`bubble max-w-[min(42rem,88%)] whitespace-pre-wrap break-words rounded-2xl rounded-br-md bg-(--ui-bg-accented) px-4 py-2.5 text-[0.875rem] leading-normal text-highlighted transition-opacity duration-150 ease-out`,e.pending?`opacity-70`:``])},l(e.text),3),v(`div`,Rt,[e.failed?(_(),i(`span`,zt,l(e.failed),1)):m(``,!0),r(f,{name:`sb-fade`},{default:g(()=>[e.folded?(_(),i(`span`,Bt,`↪ folded in `+l(e.folded),1)):m(``,!0)]),_:1}),v(`span`,{class:`ts select-none`,title:C(pe)(e.at)},l(n.value),9,Vt)])],8,Lt))}}),Ut=[`title`],Wt={class:`preset font-medium`},Gt={class:`reason truncate font-normal opacity-80`},Kt=u({__name:`ReceiptChip`,props:{route:{}},setup(e){let t=e,n=F(()=>de[le(t.route.preset)]);return(t,r)=>(_(),i(`span`,{class:d([`receipt inline-flex max-w-full items-baseline gap-1.5 rounded border px-1.5 py-px font-mono text-[0.7rem] leading-relaxed`,n.value]),title:`routed: ${e.route.reason}`,"data-testid":`receipt`},[v(`span`,Wt,l(e.route.preset),1),v(`span`,Gt,`· `+l(e.route.reason),1)],10,Ut))}}),qt=[`data-phase`,`data-run-id`,`data-live`],Jt={class:`head flex flex-wrap items-baseline gap-2 font-mono text-[0.7rem] text-dimmed`},Yt={key:0,class:`model`},Xt={key:1,class:`elapsed ml-auto tabular-nums`,"data-testid":`elapsed`},Zt={key:0,class:`disconnected flex items-baseline gap-2 rounded-lg border border-dashed border-bad/40 px-3 py-2 font-mono text-xs text-bad`,"data-testid":`disconnected`},Qt=[`open`],$t={class:`flex min-h-6 cursor-pointer list-none items-baseline gap-2 font-mono text-[0.7rem] text-dimmed hover:text-toned [&::-webkit-details-marker]:hidden`},en={class:`summary`},tn={class:`pl-1 pt-1`},nn={key:0,class:`py-2 font-mono text-xs text-dimmed`},rn={key:1,class:`py-2 font-mono text-xs text-warn`},an={key:2,class:`m-0 list-none p-0`},on={key:0,class:`reply`,"data-testid":`reply`},sn={key:1,class:`outcome font-mono text-xs text-warn`,"data-testid":`outcome`},cn={key:2,class:`facts flex flex-wrap items-baseline gap-x-3 font-mono text-[0.7rem] text-dimmed`},ln=u({__name:`AssistantTurn`,props:{turn:{},now:{},live:{},fetch:{}},emits:[`ended`,`input`,`stop`],setup(e,{emit:t}){let n=e,u=t,p=G(),y=p.state,b=j(n.live?`connecting`:`ended`),S=j(n.turn.route??null),te=j(!0),E=F(()=>y.reply?.text??n.turn.answer??``),D=F(()=>y.meta?.agent??n.turn.agent??``),O=F(()=>{let e=y.meta?.model??n.turn.model;return e?ve(e):``}),k=F(()=>n.live!==null&&n.live!==void 0&&b.value!==`ended`),A=F(()=>b.value===`disconnected`),N=n.live?.serverNow?Se({startedAt:n.turn.startedAt,receivedAt:n.turn.receivedAt,serverNow:n.live.serverNow},n.now):null,P=n.now,L=j(void 0),R=F(()=>n.turn.finished&&n.turn.finishedAt!==void 0?Math.max(0,n.turn.finishedAt-(n.turn.receivedAt??n.turn.startedAt)):L.value===void 0?N?N.elapsedMs(n.now):Math.max(0,n.now-P):L.value),ie=F(()=>ce(R.value,`clock`)),ae=F(()=>U(k.value?void 0:R.value,`run`)),B=F(()=>he(ae.value)),V=F(()=>k.value?Ce(y,n.now):null);I(xe,V),I(ye,null),I(_e,F(()=>y.reply!==null));let se=F(()=>k.value?q(y,p.pendingCall(),n.now):null),H=F(()=>{let e=se.value;return A.value||!e||e.kind===`call`?null:e.kind===`starting`?{verb:`Starting`,elapsedMs:R.value,slow:!1}:{verb:ne(e.elapsedMs),elapsedMs:e.elapsedMs,slow:e.slow}}),ue=F(()=>y.log.filter(e=>e.kind===`step`)),pe=F(()=>ue.value.length>0?ue.value.length:n.turn.stepCount??0),me=F(()=>n.turn.finished&&n.turn.status&&n.turn.status!==`completed`?fe(n.turn.status):``),J=F(()=>`/runs/${encodeURIComponent(n.turn.id)}`),we=oe(),Te=null;function Ee(e){let t=e;t.type===`route`&&typeof t.preset==`string`&&(S.value={preset:t.preset,reason:typeof t.reason==`string`?t.reason:``}),t.type===`input`&&typeof t.text==`string`&&(te.value?te.value=!1:u(`input`,t.text,t.at)),p.handle(e)}ee(()=>{n.live&&(u(`stop`,n.live.stopUrl),Te=re({url:n.live.eventsUrl,factory:we,model:p,handle:Ee,onFinished:e=>{L.value=N&&e?N.elapsedAt(e.finishedAt):R.value},onEnd:()=>{L.value??=R.value,u(`ended`)},onDisconnected:()=>{L.value??=R.value}}),s(Te.phase,e=>b.value=e,{immediate:!0}))}),x(()=>Te?.close());let De=j(n.live!==null&&n.live!==void 0),Y=j(n.live?`ready`:`none`);s(k,e=>{e||(De.value=!1)});async function Oe(e){if(De.value=e.target.open,!De.value||Y.value!==`none`)return;Y.value=`loading`;let t=n.fetch??((...e)=>globalThis.fetch(...e));try{let e=await t(`/runs/${encodeURIComponent(n.turn.id)}/events`,{credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let r=K(await e.text()).filter(e=>e.type!==`replay_note`);for(let e of(n.turn.schema??0)>=2?W(r):r)p.handle(e);p.closePhases(),Y.value=`ready`}catch{Y.value=`failed`}}let ke=F(()=>{let e=pe.value;return e>0?`${e} step${e===1?``:`s`}`:k.value?`starting`:`no steps recorded`});return(t,n)=>{let s=h(`RouterLink`);return _(),i(`div`,{class:`turn assistant flex flex-col gap-2`,"data-phase":b.value,"data-run-id":e.turn.id,"data-live":k.value?`1`:void 0},[v(`div`,Jt,[r(f,{name:`sb-rise`},{default:g(()=>[S.value?(_(),M(Kt,{key:`receipt`,route:S.value},null,8,[`route`])):D.value?(_(),i(`span`,{key:`agent`,class:d([`agent rounded border px-1.5 py-px font-medium`,C(de)[C(le)(D.value)]])},l(D.value),3)):m(``,!0)]),_:1}),O.value?(_(),i(`span`,Yt,l(O.value),1)):m(``,!0),k.value?(_(),i(`span`,Xt,l(ie.value),1)):m(``,!0)]),r(f,{name:`sb-fade`},{default:g(()=>[k.value&&H.value?(_(),M(z,{key:0,tag:`div`,verb:H.value.verb,"elapsed-ms":H.value.elapsedMs,slow:H.value.slow,model:C(y).meta?.model??e.turn.model??null},null,8,[`verb`,`elapsed-ms`,`slow`,`model`])):m(``,!0)]),_:1}),A.value?(_(),i(`p`,Zt,[n[1]||=v(`span`,null,`stream disconnected · the run may still be working`,-1),r(s,{class:`ml-auto text-primary no-underline hover:underline`,to:J.value},{default:g(()=>[...n[0]||=[w(`open the run`,-1)]]),_:1},8,[`to`])])):m(``,!0),k.value||pe.value>0||Y.value!==`none`?(_(),i(`details`,{key:1,class:`work group`,open:De.value,"data-testid":`work`,onToggle:Oe},[v(`summary`,$t,[n[2]||=v(`span`,{class:`chev select-none transition-transform duration-150 ease-out group-open:rotate-90 motion-reduce:transition-none`},`❯`,-1),v(`span`,en,l(ke.value),1)]),v(`div`,tn,[Y.value===`loading`?(_(),i(`p`,nn,`reading the run's record…`)):Y.value===`failed`?(_(),i(`p`,rn,[n[4]||=w(` the run's record could not be read — `,-1),r(s,{class:`text-primary no-underline hover:underline`,to:J.value},{default:g(()=>[...n[3]||=[w(`open the run`,-1)]]),_:1},8,[`to`])])):(_(),i(`ol`,an,[r(o,{name:`sb-rise`},{default:g(()=>[(_(!0),i(T,null,a(ue.value,e=>(_(),M(be,{key:e.key,step:e,class:`mt-3 first:mt-0`,onToggleGroup:t=>C(p).toggleGroup(e)},null,8,[`step`,`onToggleGroup`]))),128))]),_:1})]))])],40,Qt)):m(``,!0),r(f,{name:`sb-rise`},{default:g(()=>[E.value?(_(),i(`div`,on,[r(ge,{text:E.value},null,8,[`text`])])):me.value?(_(),i(`p`,sn,l(me.value),1)):m(``,!0)]),_:1}),k.value?m(``,!0):(_(),i(`div`,cn,[v(`span`,{class:d([`dur tabular-nums`,B.value?`heat`:``]),style:c(B.value)},l(ie.value),7),r(s,{class:`open text-dimmed no-underline hover:text-primary hover:underline`,to:J.value},{default:g(()=>[...n[5]||=[w(`open run`,-1)]]),_:1},8,[`to`])]))],8,qt)}}});function un(){return{runs:new Map,connected:!1}}function dn(e,t){t.type===`upsert`&&t.run?t.run.finished||!t.run.threadKey?e.runs.delete(t.run.id):e.runs.set(t.run.id,{threadKey:t.run.threadKey,startedAt:t.run.startedAt,...t.run.label===void 0?{}:{label:t.run.label},...t.run.channelId===void 0?{}:{channelId:t.run.channelId}}):t.type===`removed`&&t.id&&e.runs.delete(t.id)}function fn(e){let t=new Map;for(let n of e.runs.values()){let e=t.get(n.threadKey)??[];e.push(n),t.set(n.threadKey,e)}return t}function pn(e,t){return t.includes(`:`)?t:`${e}:${t}`}function mn(e){let t=e.indexOf(`:`);return t>0?e.slice(0,t):`unknown`}function hn(e,t,n){if(!t.connected)return[...e];let r=fn(t),i=new Set,a=e.map(e=>{let t=pn(n,e.id);i.add(t);let a=r.get(t);if(!a)return e.live?{...e,live:!1}:e;let o=e.live?0:a.length;return{...e,live:!0,runs:e.runs+o,lastAt:Math.max(e.lastAt,...a.map(e=>e.startedAt))}}),o=[];for(let[e,t]of r){if(i.has(e))continue;let r=t.reduce((e,t)=>t.startedAt>e.startedAt?t:e),a=r.label?se(r.label).snippet:void 0;o.push({id:e.startsWith(`${n}:`)?e.slice(n.length+1):e,title:a??r.label??e,excerpt:a??r.label??e,lastAt:r.startedAt,runs:t.length,live:!0,surface:mn(r.channelId??e)})}return o.sort((e,t)=>t.lastAt-e.lastAt),[...o,...a]}var gn={key:0,class:`mx-auto my-12 max-w-xl text-center text-toned`},_n=[`data-rail`],vn={key:0,class:`relative hidden md:block`},yn=[`aria-valuemin`,`aria-valuemax`,`aria-valuenow`],bn={class:`thread mx-auto flex min-h-[calc(100vh-8rem)] w-full max-w-3xl flex-col`},xn={key:2,class:`inline text-[0.875rem] text-toned`,"data-testid":`inline`},Sn={key:2,class:`elsewhere sticky bottom-0 z-10 -mx-3 mt-auto bg-default/85 px-3 py-4 text-center text-[0.8rem] text-toned backdrop-blur sm:-mx-5 sm:px-5`,"data-testid":`elsewhere`},Cn=[`href`],wn={key:3,class:`composer-dock sticky bottom-0 z-10 -mx-3 mt-auto bg-default/85 px-3 pb-[max(0.75rem,env(safe-area-inset-bottom))] pt-3 backdrop-blur sm:-mx-5 sm:px-5`},Tn=`(min-width: 48rem)`,En=u({__name:`HomePage`,setup(t){let u=E(`home`),p=B(u?.now),h=u?.conversation??``,b=y(u?.retentionDays??null),D=0,A=e=>`${e}-${++D}`,N=P([]);for(let e of u?.turns??[]){N.push({key:A(`p`),kind:`person`,text:e.request,at:e.receivedAt??e.startedAt,pending:!1});let t=!e.finished&&e.token?{eventsUrl:`/runs/${encodeURIComponent(e.id)}/events?t=${e.token}`,stopUrl:`/runs/${encodeURIComponent(e.id)}/stop?t=${e.token}`,serverNow:u?.now}:null;N.push({key:A(`a`),kind:`assistant`,turn:e,live:t,ended:e.finished})}let L=F(()=>{for(let e=N.length-1;e>=0;e--){let t=N[e];if(t.kind===`assistant`&&t.live&&!t.ended)return t}return null}),ne=j(null),re=j(0);I(e,re);let z=j(``),V=j(void 0),se=F(()=>we(L.value!==null,z.value)),H=j(!1);s(z,()=>{V.value&&z.value===``&&(V.value=void 0)});function le(e){z.value=e,de()}async function de(){if(!u||H.value)return;let e=Je(z.value.trim(),u.commands);if(e===``)return;let t=P({key:A(`p`),kind:`person`,text:e,at:p.value,pending:!0});N.push(t),z.value=``,V.value=void 0,H.value=!0,re.value++;try{let n=await fetch(u.sendUrl,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify({text:e})}),r=await n.json().catch(()=>({}));if(n.status===202&&typeof r.viewPath==`string`&&typeof r.runId==`string`){let n=De(r.viewPath);if(!n)throw Error(`the run's view path was not one`);t.pending=!1,k.pathname()===`/threads`&&k.replaceUrl(`/threads/${encodeURIComponent(h)}`),N.push({key:A(`a`),kind:`assistant`,turn:{id:r.runId,request:e,startedAt:p.value,receivedAt:p.value,finished:!1,eventCount:0},live:{eventsUrl:n.eventsUrl,stopUrl:n.stopUrl},ended:!1});return}if(n.ok&&typeof r.reply==`string`){t.pending=!1;let e=Ee(r.reply);e.kind===`handBack`?(z.value=e.command,V.value=`Enter runs it`):e.kind===`inline`&&N.push({key:A(`i`),kind:`inline`,text:e.text});return}throw Error(r.error??`HTTP ${n.status}`)}catch(e){t.pending=!1,t.failed=`not sent: ${e instanceof Error?e.message:`error`}`}finally{H.value=!1}}function fe(){let e=ne.value;e&&fetch(`${e}${e.includes(`?`)?`&`:`?`}mode=soft`,{method:`POST`,credentials:`same-origin`})}function pe(e,t,n){let r=Ne(N.filter(e=>e.kind===`person`).map(e=>({text:e.text,folded:e.folded!==void 0,ref:e})),t);if(!r)return;let i=e.turn.receivedAt??e.turn.startedAt;r.ref.folded=n===void 0?``:`at ${ce(Math.max(0,n-i),`clock`)}`}function me(e){e.ended=!0,ne.value=null}let he=je({width:k.readPref(Z.width),collapsed:k.readPref(Z.collapsed)}),U=j(he.width),W=j(he.collapsed),_e=j(!1),G=j(k.mediaMatches(Tn)),ve=k.onMediaChange(Tn,e=>{G.value=e}),ye=j(null),be=j(null),xe=F(()=>G.value?W.value?`Show recent threads`:`Hide recent threads`:`Recent threads`);function Se(){if(G.value=k.mediaMatches(Tn),G.value){W.value=!W.value,k.writePref(Z.collapsed,W.value?`1`:`0`);return}_e.value=!0}function K(e,t){U.value=Ae(e),t&&k.writePref(Z.width,String(U.value))}let q=null;function Ce(e){q&&K(q.startWidth+(e.clientX-q.startX),!1)}function J(){window.removeEventListener(`pointermove`,Ce),q&&(q=null,k.writePref(Z.width,String(U.value)))}function Te(e){e.button===0&&(e.preventDefault(),q={startX:e.clientX,startWidth:U.value},e.currentTarget?.setPointerCapture?.(e.pointerId),window.addEventListener(`pointermove`,Ce),window.addEventListener(`pointerup`,J,{once:!0}))}function Oe(e){if(e.key===`ArrowRight`)K(U.value+X.step,!0);else if(e.key===`ArrowLeft`)K(U.value-X.step,!0);else if(e.key===`Home`)K(X.min,!0);else if(e.key===`End`)K(X.max,!0);else return;e.preventDefault()}O(()=>{window.removeEventListener(`pointermove`,Ce),window.removeEventListener(`pointerup`,J),ve()});function ke(e){let t=Re(e);if(t){if(e.preventDefault(),t===`newThread`){k.navigate(`/threads`);return}if(ye.value){ye.value.focusFilter();return}if(W.value&&k.mediaMatches(Tn)){W.value=!1,k.writePref(Z.collapsed,`0`),S().then(()=>ye.value?.focusFilter());return}_e.value=!0,S().then(()=>be.value?.focusFilter())}}let Me=j(null),Fe=j(!1);function Ie(){return document.body.scrollHeight-(window.innerHeight+window.scrollY)}s(()=>N.length,()=>{let e=Pe(Ie());S().then(()=>{e?Me.value?.scrollIntoView?.({block:`end`}):Fe.value=!0})});function Le(){Pe(Ie())&&(Fe.value=!1)}function ze(){Me.value?.scrollIntoView?.({block:`end`,behavior:`smooth`}),Fe.value=!1}ee(()=>{window.addEventListener(`scroll`,Le,{passive:!0}),window.addEventListener(`keydown`,ke),u&&We()}),x(()=>{window.removeEventListener(`scroll`,Le),window.removeEventListener(`keydown`,ke),Ue?.close()});let Q=P(un()),Be=F(()=>hn(u?.conversations??[],Q,u?.lane??``)),Ve=F(()=>{let e=L.value?.turn.id;return Q.runs.size+(e&&!Q.runs.has(e)?1:0)}),He=oe(),Ue=null;function We(){Ue=He(`/runs?stream=1&mine=1`);let e=!1;Ue.onopen=()=>{e&&Q.runs.clear(),e=!0,Q.connected=!0},Ue.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}dn(Q,t)}}let Ge=F(()=>{let e=N.find(e=>e.kind===`person`);return e?Y(e.text):`Switchboard`});s([Ge,Ve],([e,t])=>{k.setTitle(t>0?`(${t}) ${e}`:e),k.setFavicon(t>0?ae:ie)},{immediate:!0});let Ke=F(()=>new Date(p.value).getHours()),qe=F(()=>N.length===0),$=u?.elsewhere,Ye=$?$.surface===`web`?`This thread is another person's conversation. You can read it here.`:`This thread lives in ${ue[$.surface]??$.surface}.`:``;return(e,t)=>{let s=te,y=R;return _(),M(n,{title:`Threads`,nav:`home`},{leading:g(()=>[r(s,{class:`rail-toggle -ml-1`,size:`xs`,color:`neutral`,variant:`ghost`,icon:G.value&&!W.value?`i-lucide-panel-left-close`:`i-lucide-panel-left`,"aria-label":xe.value,"aria-expanded":G.value?!W.value:void 0,onClick:Se},null,8,[`icon`,`aria-label`,`aria-expanded`])]),default:g(()=>[C(u)?(_(),i(`div`,{key:1,class:d([`home gap-8 md:grid`,W.value?`md:grid-cols-[minmax(0,1fr)]`:`md:grid-cols-[var(--rail-w)_minmax(0,1fr)]`]),style:c({"--rail-w":`${U.value}px`}),"data-rail":W.value?`hidden`:`shown`},[W.value?m(``,!0):(_(),i(`aside`,vn,[r(kt,{ref_key:`rail`,ref:ye,class:`sticky top-20`,rows:Be.value,current:C(h),now:C(p),retention:C(b)},null,8,[`rows`,`current`,`now`,`retention`]),v(`div`,{class:`handle group/handle absolute inset-y-0 -right-5 flex w-3 cursor-col-resize touch-none select-none justify-center outline-none`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the recent threads column`,"aria-valuemin":C(X).min,"aria-valuemax":C(X).max,"aria-valuenow":U.value,tabindex:`0`,"data-testid":`rail-handle`,onPointerdown:Te,onKeydown:Oe,onDblclick:t[0]||=e=>K(C(X).default,!0)},[...t[5]||=[v(`span`,{class:`w-px rounded-full bg-(--ui-border-accented) opacity-0 transition-opacity duration-150 ease-out group-hover/handle:opacity-100 group-focus-visible/handle:opacity-100`,"aria-hidden":`true`},null,-1)]],40,yn)])),r(y,{open:_e.value,"onUpdate:open":t[1]||=e=>_e.value=e,side:`left`,title:`Recent threads`,ui:{content:`max-w-xs`}},{body:g(()=>[r(kt,{ref_key:`sheetRail`,ref:be,rows:Be.value,current:C(h),now:C(p),retention:C(b)},null,8,[`rows`,`current`,`now`,`retention`])]),_:1},8,[`open`]),v(`section`,bn,[qe.value?(_(),M(It,{key:0,class:`mb-auto mt-[clamp(1.5rem,14vh,9rem)]`,name:C(u).viewer.name,hour:Ke.value,suggestions:C(u).suggestions,onPick:le},{default:g(()=>[r(lt,{modelValue:z.value,"onUpdate:modelValue":t[2]||=e=>z.value=e,mode:se.value,hint:V.value,commands:C(u).commands,autofocus:``,"sweep-on-mount":``,onSubmit:de,onStop:fe},null,8,[`modelValue`,`mode`,`hint`,`commands`])]),_:1},8,[`name`,`hour`,`suggestions`])):(_(),M(o,{key:1,name:`sb-rise`,"move-class":`sb-move-move`,tag:`ol`,class:`transcript m-0 flex list-none flex-col gap-6 p-0 pb-32 pt-2`},{default:g(()=>[(_(!0),i(T,null,a(N,e=>(_(),i(`li`,{key:e.key},[e.kind===`person`?(_(),M(Ht,{key:0,text:e.text,at:e.at,now:C(p),pending:e.pending,folded:e.folded,failed:e.failed},null,8,[`text`,`at`,`now`,`pending`,`folded`,`failed`])):e.kind===`assistant`?(_(),M(ln,{key:1,turn:e.turn,live:e.live,now:C(p),onInput:(t,n)=>pe(e,t,n),onEnded:t=>me(e),onStop:t[3]||=e=>ne.value=e},null,8,[`turn`,`live`,`now`,`onInput`,`onEnded`])):(_(),i(`div`,xn,[r(ge,{text:e.text},null,8,[`text`])]))]))),128))]),_:1})),v(`div`,{ref_key:`end`,ref:Me,class:`end`,"aria-hidden":`true`},null,512),!qe.value&&C($)?(_(),i(`p`,Sn,[w(l(C(Ye))+` `,1),C($).url?(_(),i(`a`,{key:0,href:C($).url,target:`_blank`,rel:`noopener`,class:`text-highlighted`},`Reply there ↗`,8,Cn)):C($).surface===`web`?m(``,!0):(_(),i(T,{key:1},[w(`Reply there.`)],64))])):qe.value?m(``,!0):(_(),i(`div`,wn,[r(f,{name:`sb-rise`},{default:g(()=>[Fe.value?(_(),i(`button`,{key:0,type:`button`,class:`new-pill absolute -top-9 left-1/2 -translate-x-1/2 rounded-full border border-default bg-(--ui-bg-elevated) px-3 py-1 font-mono text-[0.7rem] text-toned shadow-sm hover:text-highlighted`,onClick:ze},` ↓ new `)):m(``,!0)]),_:1}),r(lt,{modelValue:z.value,"onUpdate:modelValue":t[4]||=e=>z.value=e,mode:se.value,hint:V.value,commands:C(u).commands,autofocus:``,onSubmit:de,onStop:fe},null,8,[`modelValue`,`mode`,`hint`,`commands`])]))])],14,_n)):(_(),i(`div`,gn,`This page needs its seed.`))]),_:1})}}});export{En as default};