@hearsay-tools/squawk 0.18.0-pr4335.8421 → 0.18.0-pr4337.8439

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 (146) hide show
  1. package/dist/automations/tools.d.ts +8 -8
  2. package/dist/autosave-cleanup.js +2 -1
  3. package/dist/autosave-cleanup.js.map +1 -1
  4. package/dist/boot.d.ts +5 -1
  5. package/dist/boot.js +5 -2
  6. package/dist/boot.js.map +1 -1
  7. package/dist/built-in-cli-commands.js +0 -4
  8. package/dist/built-in-cli-commands.js.map +1 -1
  9. package/dist/built-in-launch-parts.d.ts +0 -2
  10. package/dist/built-in-launch-parts.js +1 -8
  11. package/dist/built-in-launch-parts.js.map +1 -1
  12. package/dist/built-in-run-slots.js +1 -2
  13. package/dist/built-in-run-slots.js.map +1 -1
  14. package/dist/ci-wait/controller.d.ts +7 -7
  15. package/dist/ci-wait/tool-catalog.d.ts +2 -1
  16. package/dist/ci-wait/tool-catalog.js +22 -16
  17. package/dist/ci-wait/tool-catalog.js.map +1 -1
  18. package/dist/cli-dispatch.d.ts +1 -1
  19. package/dist/cli-dispatch.js +24 -16
  20. package/dist/cli-dispatch.js.map +1 -1
  21. package/dist/core/cli-registry.d.ts +3 -0
  22. package/dist/core/cli-registry.js +3 -0
  23. package/dist/core/cli-registry.js.map +1 -1
  24. package/dist/core/managed-session.d.ts +0 -5
  25. package/dist/core/managed-session.js +0 -25
  26. package/dist/core/managed-session.js.map +1 -1
  27. package/dist/core/process-ownership.d.ts +12 -0
  28. package/dist/core/process-ownership.js +33 -0
  29. package/dist/core/process-ownership.js.map +1 -0
  30. package/dist/delegation/process-liveness.d.ts +6 -3
  31. package/dist/delegation/process-liveness.js +0 -16
  32. package/dist/delegation/process-liveness.js.map +1 -1
  33. package/dist/delegation/scratch-cleanup.js +5 -5
  34. package/dist/delegation/scratch-cleanup.js.map +1 -1
  35. package/dist/delegation/transport.d.ts +10 -10
  36. package/dist/{jobs → features/jobs}/cli.js +1 -1
  37. package/dist/features/jobs/cli.js.map +1 -0
  38. package/dist/{jobs → features/jobs}/command.js +2 -2
  39. package/dist/features/jobs/command.js.map +1 -0
  40. package/dist/features/jobs/index.d.ts +11 -0
  41. package/dist/features/jobs/index.js +20 -0
  42. package/dist/features/jobs/index.js.map +1 -0
  43. package/dist/{jobs → features/jobs}/job.js +9 -10
  44. package/dist/features/jobs/job.js.map +1 -0
  45. package/dist/features/jobs/removal-slot.d.ts +14 -0
  46. package/dist/features/jobs/removal-slot.js +50 -0
  47. package/dist/features/jobs/removal-slot.js.map +1 -0
  48. package/dist/index.js +1 -1
  49. package/dist/index.js.map +1 -1
  50. package/dist/legacy-runs.js.map +1 -1
  51. package/dist/pack-check.d.ts +4 -1
  52. package/dist/pack-check.js +9 -1
  53. package/dist/pack-check.js.map +1 -1
  54. package/dist/plugin/bundled-features.d.ts +11 -0
  55. package/dist/plugin/bundled-features.js +37 -0
  56. package/dist/plugin/bundled-features.js.map +1 -0
  57. package/dist/plugin/cli.js +1 -1
  58. package/dist/plugin/index.d.ts +1 -1
  59. package/dist/plugin/loader.d.ts +2 -0
  60. package/dist/plugin/loader.js +23 -11
  61. package/dist/plugin/loader.js.map +1 -1
  62. package/dist/runners/antigravity/acp/events.d.ts +3 -5
  63. package/dist/runners/antigravity/acp/events.js +28 -13
  64. package/dist/runners/antigravity/acp/events.js.map +1 -1
  65. package/dist/runs/agent-tmpdir.d.ts +5 -4
  66. package/dist/runs/agent-tmpdir.js +7 -5
  67. package/dist/runs/agent-tmpdir.js.map +1 -1
  68. package/dist/runs/removal-slots.d.ts +15 -3
  69. package/dist/runs/removal-slots.js +12 -2
  70. package/dist/runs/removal-slots.js.map +1 -1
  71. package/dist/runs/run-exits.d.ts +352 -352
  72. package/dist/runs/worker-execution.js.map +1 -1
  73. package/dist/server/automations-routes.d.ts +150 -150
  74. package/dist/server/repo-routes.d.ts +13 -13
  75. package/dist/server/runner-install-routes.d.ts +10 -10
  76. package/dist/server/runs-routes.d.ts +956 -956
  77. package/dist/server/workspace-live-routes.d.ts +6 -6
  78. package/dist/worker-scope/groups.d.ts +0 -9
  79. package/dist/worker-scope/groups.js +3 -18
  80. package/dist/worker-scope/groups.js.map +1 -1
  81. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  82. package/dist/workflows/run/run-settlement.d.ts +0 -10
  83. package/dist/workflows/run/run-settlement.js +5 -38
  84. package/dist/workflows/run/run-settlement.js.map +1 -1
  85. package/dist/workflows/run/session-events.js +0 -16
  86. package/dist/workflows/run/session-events.js.map +1 -1
  87. package/dist/workflows/run/wait-engine.d.ts +72 -72
  88. package/dist/workflows/run/wait-input-descriptors.js +11 -2
  89. package/dist/workflows/run/wait-input-descriptors.js.map +1 -1
  90. package/dist/workflows/run/wait-kinds.d.ts +52 -52
  91. package/package.json +4 -4
  92. package/scripts/check-pack.mjs +5 -2
  93. package/scripts/measure-transcript-facts-health.mjs +41 -4
  94. package/scripts/measure-transcript-facts-lag.mjs +3 -3
  95. package/scripts/transcript-facts-timing.mjs +133 -9
  96. package/web/dist/assets/{accounts-section-DmCfsIhE.js → accounts-section-DPb768q9.js} +1 -1
  97. package/web/dist/assets/{activity-motion-Dl9i8LMp.js → activity-motion-D3CzGjrR.js} +1 -1
  98. package/web/dist/assets/{activity-route-Cu2YIdei.js → activity-route-DFJlsU13.js} +1 -1
  99. package/web/dist/assets/{agent-config-section-Bzm4-R__.js → agent-config-section-2esq_SCK.js} +1 -1
  100. package/web/dist/assets/{agent-defaults-section-BKqo164A.js → agent-defaults-section-DykQGFoV.js} +1 -1
  101. package/web/dist/assets/{appearance-BqzgpB-Y.js → appearance-CEhpCQZS.js} +1 -1
  102. package/web/dist/assets/{automations-route-CUgWc2Qw.js → automations-route-C6e7440u.js} +1 -1
  103. package/web/dist/assets/{commit-diff-panel-Cm558uOv.js → commit-diff-panel-CloSSaTz.js} +1 -1
  104. package/web/dist/assets/{diff-GEuSlT_R.js → diff-DVDzDVOV.js} +2 -2
  105. package/web/dist/assets/{diff-view-DLSixc9l.js → diff-view-isM51Pgu.js} +1 -1
  106. package/web/dist/assets/{file-preview-RPc0KAo_.js → file-preview-BZA9e981.js} +1 -1
  107. package/web/dist/assets/{git-toolbar-Dd_SYvD0.js → git-toolbar-DHAavjba.js} +1 -1
  108. package/web/dist/assets/{github-CQ7IuYHM.js → github-MN8flcF0.js} +1 -1
  109. package/web/dist/assets/{global-activity-route-BxZ0CMwG.js → global-activity-route-CAXyZ8LF.js} +1 -1
  110. package/web/dist/assets/{index-BRgRv29I.js → index-CHIFhfha.js} +4 -4
  111. package/web/dist/assets/{markdown-CIm2Q7mB.js → markdown-DhdLkyGx.js} +3 -3
  112. package/web/dist/assets/{notifications-section-Cw8yBZWz.js → notifications-section-Yiyd4TEk.js} +1 -1
  113. package/web/dist/assets/{preview-pane-connected-C3DmH_yh.js → preview-pane-connected-BnNucXbg.js} +1 -1
  114. package/web/dist/assets/{projects-section-DftkCQ4q.js → projects-section-CYnMlFyZ.js} +1 -1
  115. package/web/dist/assets/{prompt-templates-section-CKSYhpin.js → prompt-templates-section-BaaI89Ej.js} +1 -1
  116. package/web/dist/assets/{remote-settings-notice-C727a84A.js → remote-settings-notice-Drbpb7K4.js} +1 -1
  117. package/web/dist/assets/{repo-git-CfmNmHkb.js → repo-git-UR__WAGI.js} +1 -1
  118. package/web/dist/assets/{report-reader-wIj2Yog1.js → report-reader-DydKaDxP.js} +1 -1
  119. package/web/dist/assets/{reports-DSkGAItT.js → reports-FE9fPBLK.js} +1 -1
  120. package/web/dist/assets/{resources-section-DaEv2dar.js → resources-section-BAz7yc3V.js} +1 -1
  121. package/web/dist/assets/{run-header-CVZ0ZK7C.js → run-header-DsyPfNlS.js} +1 -1
  122. package/web/dist/assets/{settings-agent-picker-DMVlOQzv.js → settings-agent-picker-i4wCYEex.js} +1 -1
  123. package/web/dist/assets/{settings-shell-DfnGZk9I.js → settings-shell-C1RbQ--s.js} +1 -1
  124. package/web/dist/assets/{sidebar-section-DYJZAqtU.js → sidebar-section-CdvgsziI.js} +1 -1
  125. package/web/dist/assets/{skills-CfzNcHh1.js → skills-Cx1c72fB.js} +1 -1
  126. package/web/dist/assets/{task-changes-C1I9CMew.js → task-changes-CJCU26Rn.js} +1 -1
  127. package/web/dist/assets/{task-commits-d_R4H7pu.js → task-commits-BvDHw2z3.js} +1 -1
  128. package/web/dist/assets/{task-files-B2JBO9Dx.js → task-files-BtEb73_A.js} +1 -1
  129. package/web/dist/assets/{task-github-item-C9HMDHKn.js → task-github-item-DguvLtyn.js} +1 -1
  130. package/web/dist/assets/{task-thread-dKvX9xg6.js → task-thread-DiiErUqw.js} +9 -9
  131. package/web/dist/assets/thread-state-XrQOGOYN.js +4 -0
  132. package/web/dist/assets/{use-hand-to-agent-state-DzHDdmHn.js → use-hand-to-agent-state-CDqXR3F2.js} +1 -1
  133. package/web/dist/assets/{workflows-DqArthZn.js → workflows-C8Wu6BrK.js} +1 -1
  134. package/web/dist/assets/{workspace-tools-S5KvgCRm.js → workspace-tools-DG99Pw_m.js} +1 -1
  135. package/web/dist/assets/{worktrees-section-DNFnQfiW.js → worktrees-section-BtDBsA-d.js} +1 -1
  136. package/web/dist/index.html +1 -1
  137. package/dist/jobs/cli.js.map +0 -1
  138. package/dist/jobs/command.js.map +0 -1
  139. package/dist/jobs/job.js.map +0 -1
  140. package/dist/jobs/removal-slot.d.ts +0 -4
  141. package/dist/jobs/removal-slot.js +0 -10
  142. package/dist/jobs/removal-slot.js.map +0 -1
  143. package/web/dist/assets/thread-state-B3HGSNEy.js +0 -4
  144. /package/dist/{jobs → features/jobs}/cli.d.ts +0 -0
  145. /package/dist/{jobs → features/jobs}/command.d.ts +0 -0
  146. /package/dist/{jobs → features/jobs}/job.d.ts +0 -0
@@ -1,5 +1,7 @@
1
1
  /** Main-thread measurements only: worker CPU does not count as loop blocking. */
2
2
  import { readFileSync } from 'node:fs';
3
+ import { once } from 'node:events';
4
+ import { Worker } from 'node:worker_threads';
3
5
 
4
6
  export function readQueueWaitMs({ read = readFileSync, platform = process.platform } = {}) {
5
7
  // Linux schedstat field 2 is cumulative run-queue wait in nanoseconds.
@@ -11,34 +13,156 @@ export function readQueueWaitMs({ read = readFileSync, platform = process.platfo
11
13
  catch { return null; /* Optional diagnostic on restricted procfs mounts. */ }
12
14
  }
13
15
 
16
+ /** Linux per-thread major page faults and voluntary context switches: optional diagnostics
17
+ * that tell a disk page-in from a lock or I/O wait. Null where procfs cannot answer. */
18
+ export function readThreadStats({ read = readFileSync, platform = process.platform } = {}) {
19
+ if (platform !== 'linux') return null;
20
+ try {
21
+ const stat = read('/proc/thread-self/stat', 'utf8');
22
+ // Field 12 (majflt); the command name in field 2 may contain spaces, so count after ')'.
23
+ const majorFaults = Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[9]);
24
+ const switches = /^voluntary_ctxt_switches:\s*(\d+)$/m.exec(read('/proc/thread-self/status', 'utf8'));
25
+ return Number.isFinite(majorFaults) && switches ? { majorFaults, voluntarySwitches: Number(switches[1]) } : null;
26
+ }
27
+ catch { return null; /* Optional diagnostic on restricted procfs mounts. */ }
28
+ }
29
+
30
+ /** libuv idle time: the loop waited in its poll phase for I/O, a timer or another thread. */
31
+ export function readLoopIdleMs() {
32
+ return performance.eventLoopUtilization().idle;
33
+ }
34
+
14
35
  export function timingSnapshot({ now = () => performance.now(), readQueue = readQueueWaitMs,
15
- readCpu = () => process.threadCpuUsage() } = {}) {
36
+ readCpu = () => process.threadCpuUsage(), readLoopIdle = readLoopIdleMs, readThread = readThreadStats } = {}) {
37
+ const thread = readThread();
16
38
  const cpu = readCpu();
39
+ const loopIdleMs = readLoopIdle();
17
40
  const queueBeforeMs = readQueue();
18
41
  const at = now();
19
42
  const queueAfterMs = readQueue();
20
- return { at, cpuMs: (cpu.user + cpu.system) / 1000, queueBeforeMs, queueAfterMs };
43
+ return { at, cpuMs: (cpu.user + cpu.system) / 1000, loopIdleMs, queueBeforeMs, queueAfterMs, thread };
21
44
  }
22
45
 
23
46
  export function timingDelta(start, end) {
24
47
  const elapsedMs = end.at - start.at;
25
48
  const mainThreadCpuMs = end.cpuMs - start.cpuMs;
49
+ // Snapshots run JavaScript, never inside the poll phase, so the idle delta lies in the interval.
50
+ const loopIdleMs = Math.max(0, Math.min(elapsedMs, end.loopIdleMs - start.loopIdleMs));
26
51
  // Previous AFTER -> next BEFORE is contained in the wall-clock interval.
27
52
  // Subtract only this inner queue-wait delta. A pause between a scheduler
28
53
  // read and the clock must never credit wait from outside the interval.
29
54
  const queueWaitMs = start.queueAfterMs === null || end.queueBeforeMs === null ? null
30
55
  : Math.max(0, Math.min(elapsedMs, end.queueBeforeMs - start.queueAfterMs));
31
- // Residual includes timer/IO sleep and measurement overhead, not just IO.
32
- return { elapsedMs, mainThreadCpuMs, queueWaitMs,
33
- blockedMs: queueWaitMs === null ? null : Math.max(0, elapsedMs - mainThreadCpuMs - queueWaitMs) };
56
+ // Residual: off-CPU time outside the poll phase (synchronous disk I/O, locks, Atomics.wait)
57
+ // plus measurement overhead. See blockingBudget for why the larger wait is subtracted once.
58
+ return { elapsedMs, mainThreadCpuMs, loopIdleMs, queueWaitMs,
59
+ blockedMs: queueWaitMs === null ? null : Math.max(0, elapsedMs - mainThreadCpuMs - Math.max(loopIdleMs, queueWaitMs)),
60
+ ...(start.thread && end.thread ? { majorFaults: end.thread.majorFaults - start.thread.majorFaults,
61
+ voluntarySwitches: end.thread.voluntarySwitches - start.thread.voluntarySwitches } : {}) };
34
62
  }
35
63
 
36
- /** Timer samples exclude their planned sleep; requests have no planned sleep. */
37
- export function blockingBudget(sample, periodMs = 0) {
64
+ /** Main-thread blocking is loop-active time without run-queue wait. Loop idle time is excluded:
65
+ * a planned timer sleep, and a request waiting on the thread pool, a worker or the kernel, are
66
+ * latency but do not block the loop. CPU, synchronous disk I/O and Atomics.wait still count.
67
+ * libuv counts a run-queue wait after a poll wake-up as idle time too, and the two cannot be
68
+ * told apart, so only the larger of idle and run-queue wait is subtracted. Subtracting both
69
+ * could hide a synchronous stall; this choice can only over-count, never above elapsed minus
70
+ * run-queue wait. It never drops below main-thread CPU. */
71
+ export function blockingBudget(sample) {
38
72
  const mode = sample.queueWaitMs === null ? 'cpu-only' : 'scheduler-adjusted';
39
73
  const blockingMs = sample.queueWaitMs === null ? sample.mainThreadCpuMs
40
- : Math.max(0, sample.elapsedMs - periodMs - sample.queueWaitMs);
41
- return { mode, blockingMs: Math.max(0, periodMs > 0 ? Math.max(sample.mainThreadCpuMs, blockingMs) : blockingMs) };
74
+ : Math.max(sample.mainThreadCpuMs, sample.elapsedMs - Math.max(sample.loopIdleMs, sample.queueWaitMs));
75
+ return { mode, blockingMs: Math.max(0, blockingMs) };
76
+ }
77
+
78
+ /** Light per-call timing (clock and thread CPU only), so many hooked calls add little loop time.
79
+ * Each call records its start; nested hooked calls are recorded too, under their own phase. */
80
+ export function hookCalls(hooks, calls) {
81
+ const restore = hooks.map(([target, name]) => {
82
+ const original = target[name];
83
+ target[name] = function (...args) {
84
+ const at = performance.now();
85
+ const cpu = process.threadCpuUsage();
86
+ try { return original.apply(this, args); }
87
+ finally {
88
+ const used = process.threadCpuUsage(cpu);
89
+ calls.push({ phase: name, at, elapsedMs: performance.now() - at, mainThreadCpuMs: (used.user + used.system) / 1000 });
90
+ }
91
+ };
92
+ return () => { target[name] = original; };
93
+ });
94
+ return () => { for (const undo of restore) undo(); };
95
+ }
96
+
97
+ /** Per-phase totals of the calls that started in [from, to). */
98
+ export function callsWithin(calls, from, to) {
99
+ const phases = {};
100
+ for (const call of calls) {
101
+ if (call.at < from || call.at >= to) continue;
102
+ const total = phases[call.phase] ??= { count: 0, elapsedMs: 0, mainThreadCpuMs: 0, maxElapsedMs: 0 };
103
+ total.count++;
104
+ total.elapsedMs += call.elapsedMs;
105
+ total.mainThreadCpuMs += call.mainThreadCpuMs;
106
+ total.maxElapsedMs = Math.max(total.maxElapsedMs, call.elapsedMs);
107
+ }
108
+ return phases;
109
+ }
110
+
111
+ // Polls the main thread's kernel state from another thread; records it whenever it is not running.
112
+ const WATCH_SOURCE = `
113
+ const { workerData, parentPort } = require('node:worker_threads');
114
+ const { readFileSync } = require('node:fs');
115
+ const flag = new Int32Array(workerData.flag);
116
+ const base = '/proc/' + workerData.pid + '/task/' + workerData.pid + '/';
117
+ const read = name => { try { return readFileSync(base + name, 'utf8').trim(); } catch { return null; } };
118
+ const seen = [];
119
+ parentPort.postMessage('ready');
120
+ for (let mode; (mode = Atomics.load(flag, 0)) !== 2;) {
121
+ if (mode === 0) { Atomics.wait(flag, 0, 0); continue; }
122
+ const stat = read('stat');
123
+ const state = stat === null ? '?' : stat.charAt(stat.lastIndexOf(')') + 2);
124
+ if (state !== 'R') {
125
+ seen.push({ at: performance.timeOrigin + performance.now(), state, wchan: read('wchan'),
126
+ syscall: read('syscall')?.split(' ')[0] ?? null });
127
+ Atomics.add(flag, 1, 1);
128
+ Atomics.notify(flag, 1);
129
+ }
130
+ Atomics.wait(flag, 0, 1, 1);
131
+ }
132
+ parentPort.postMessage(seen);
133
+ `;
134
+
135
+ /** Diagnostics only (Linux): name what the main thread waits in, such as a futex, a sleep, a
136
+ * child process or a page fault, about once a millisecond while watching is on. */
137
+ export async function startThreadWatch() {
138
+ if (process.platform !== 'linux') return null;
139
+ // [0]: 0 paused, 1 watching, 2 stop. [1]: samples recorded so far.
140
+ const flag = new Int32Array(new SharedArrayBuffer(8));
141
+ const worker = new Worker(WATCH_SOURCE, { eval: true, workerData: { flag: flag.buffer, pid: process.pid } });
142
+ await once(worker, 'message');
143
+ const set = mode => { Atomics.store(flag, 0, mode); Atomics.notify(flag, 0); };
144
+ return {
145
+ watch: on => set(on ? 1 : 0),
146
+ /** Block the main thread until the watcher records one more sample: 'ok' or 'timed-out'. */
147
+ awaitRecord: timeoutMs => Atomics.wait(flag, 1, Atomics.load(flag, 1), timeoutMs) === 'timed-out' ? 'timed-out' : 'ok',
148
+ async stop() {
149
+ const reply = once(worker, 'message');
150
+ set(2);
151
+ const [seen] = await reply;
152
+ await worker.terminate();
153
+ return seen.map(entry => ({ ...entry, at: entry.at - performance.timeOrigin }));
154
+ },
155
+ };
156
+ }
157
+
158
+ /** Counts of watched waits by state, syscall number and kernel wait channel. */
159
+ export function summarizeWaits(seen) {
160
+ const counts = {};
161
+ for (const entry of seen) {
162
+ const key = `${entry.state} syscall=${entry.syscall} ${entry.wchan}`;
163
+ counts[key] = (counts[key] ?? 0) + 1;
164
+ }
165
+ return counts;
42
166
  }
43
167
 
44
168
  /** Instrument only the synchronous open call. Imports and hook setup are outside its budget.
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{An as r,Ar as i,Pn as a,ci as o,jn as s,nn as c}from"./project-scope-context-D9axDY18.js";import{$t as l,Ct as u,Gt as d,Ht as f,Kt as p,Mt as m,Rt as h,Ut as g,Xt as _,bt as v,ht as y,in as b,kt as x,lt as S,ot as C,st as w,ut as ee,yt as te}from"./queries-DzwCG927.js";import{t as ne}from"./useQuery-CzVHT8UE.js";import{f as T}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{y as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as k}from"./folder-browser-CffyHz8w.js";import{t as A}from"./button-BQ2y4XRB.js";import{t as j}from"./badge-D9JrXe0o.js";import{a as M,i as N,o as P,r as F,s as I,t as L}from"./dialog-BVF6dIeS.js";import{t as R}from"./status-dot-DtAOFiIi.js";import{n as z}from"./agents-settings-path-7X6_cvUg.js";import{t as B}from"./centered-state-V15AR_qo.js";import{Gt as V,Ht as H,Jt as U,Kt as W,N as G,Ut as K,Vt as q,Wt as J,j as re,qt as Y}from"./index-BRgRv29I.js";import{n as X,r as ie,t as ae}from"./settings-agent-picker-DMVlOQzv.js";import{n as oe,r as se,t as ce}from"./remote-settings-notice-C727a84A.js";var le=O(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Z=e(t(),1),Q=n(),ue=`~/.claude-second`;function de({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=_().data,[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(r??n[0]??`claude`),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,v]=(0,Z.useState)(!1),y=ee(),b=m.trim();return(0,Q.jsx)(L,{open:e,onOpenChange:t,children:(0,Q.jsxs)(F,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(I,{children:`Add agent account`}),(0,Q.jsx)(N,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,Q.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:l,onChange:e=>u(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:f,placeholder:`Work`,onChange:e=>p(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:m,placeholder:d(i,l)?.accountFolderExample??ue,onChange:e=>{h(e.target.value),c(null),y.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":g,onClick:()=>v(e=>!e),children:g?`Hide folders`:`Browse…`})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),g?(0,Q.jsx)(k,{path:a,selected:s,onSelect:e=>{c(e),h(e.path),y.reset()},onEnter:e=>{o(e),c(null),y.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,y.isError?(0,Q.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:y.error instanceof Error?y.error.message:`could not add that folder`}):null,(0,Q.jsxs)(M,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(A,{"data-slot":`add-account-confirm`,disabled:b===``||y.isPending,onClick:()=>{b===``||y.isPending||y.mutate({provider:l,configDir:b,...f.trim()?{label:f.trim()}:{}},{onSuccess:()=>{t(!1),p(``),h(``),c(null),v(!1),E(`Account added — use Connect to sign in`)}})},children:y.isPending?`Adding…`:`Add account`})]})]})})}async function fe(e){return a(await s.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function pe(e,t){return a(await s.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var me={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function he(e){let t=y().data?.capabilities?.settingsAdmin===!0,n=o(),r=[`runner-install`,e],i=ne({queryKey:r,queryFn:()=>fe(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),a=b({mutationFn:t=>pe(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),s=i.data;return{allowed:t,data:s,busy:a.isPending||!!s&&s.phase!==`idle`&&s.phase!==`failed`,error:a.error?.message??i.error?.message??s?.error,action:a,status:i}}function ge({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,Q.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function _e({runner:e}){let t=he(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,Q.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${me[r.phase]}`:``]}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,Q.jsx)(ge,{state:t}),r?.installedVersion?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var ve={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function ye(){let e=w(),t=_();if(e.isPending||t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,Q.jsx)(B,{icon:(0,Q.jsx)(le,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,Q.jsx)($,{data:e.data,runners:t.data})}function be(){let{hash:e}=T();(0,Z.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function $({data:e,runners:t}){let n=y(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=u();return be(),se(),(0,Q.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Install, update and sign in to each agent, and set what a project runs when it has not chosen.`}),(0,Q.jsx)(oe,{risk:`Agent accounts run each CLI with the configured host folder`}),e.editable?null:(0,Q.jsxs)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:[`Agent accounts are read-only on this remote cockpit. Run`,` `,(0,Q.jsx)(`code`,{children:ce}),` on the host to add, edit, or sign in to accounts here.`]}),(0,Q.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-4`,children:t.runners.map(r=>(0,Q.jsx)(Se,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>i(r.id),onRemove:o},r.id))}),(0,Q.jsx)(Ce,{runners:t}),r===null?null:(0,Q.jsx)(de,{open:!0,onOpenChange:e=>!e&&i(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,Q.jsx)(q,{open:a!==null,onOpenChange:e=>!e&&o(null),children:(0,Q.jsxs)(J,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(Y,{children:[(0,Q.jsxs)(U,{children:[`Remove “`,a?.label,`”?`]}),(0,Q.jsxs)(V,{children:[`This only forgets the account. Nothing in `,a?.configDir??`this account’s folder`,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,Q.jsxs)(W,{children:[(0,Q.jsx)(K,{children:`Cancel`}),(0,Q.jsx)(H,{"data-action":`accounts-remove-confirm`,disabled:s.isPending,onClick:()=>{let e=a;e&&s.mutate(e.id,{onSuccess:()=>{o(null),E(`Removed ${e.label}`)},onError:e=>E(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function xe({entry:e,check:t}){return t===void 0?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking…`}):t.available?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}),t.version?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,Q.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null]}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed`,e.installHint?(0,Q.jsxs)(Q.Fragment,{children:[` — `,(0,Q.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function Se({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.managedInstall===!0&&n,d=a.filter(e=>e.isDefault).length,f=`${z(l)}-title`;return(0,Q.jsxs)(`section`,{id:z(l),tabIndex:-1,"aria-labelledby":f,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col gap-4 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h3`,{id:f,className:`settings-account-provider-title`,children:e.displayName}),u?(0,Q.jsx)(_e,{runner:l}):null,(0,Q.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[u?null:(0,Q.jsx)(xe,{entry:e,check:t}),i||a.length>0?(0,Q.jsxs)(`span`,{className:`settings-account-count`,children:[a.length,` `,a.length===1?`account`:`accounts`,` (`,d,` discovered, `,a.length-d,` added)`]}):null]}),a.length>0?(0,Q.jsx)(`ul`,{children:a.map(e=>(0,Q.jsx)(De,{account:e,runners:r,editable:i,onRemove:()=>c(e)},e.id))}):null,i?o?(0,Q.jsx)(`div`,{className:`settings-account-add-row`,children:(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`})}):(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11px] text-soft-foreground`,children:[e.displayName,` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]}):a.length===0&&e.browserLogin?(0,Q.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Discovered account`}),(0,Q.jsx)(X,{provider:l,label:e.displayName})]}):null]})}function Ce({runners:e}){let[t,n]=(0,Z.useState)(null),r=o(),i=m(),a=te(),s=l(p(e)),u=b({mutationFn:e=>c(e),onSuccess:e=>r.setQueryData(h.config,e),onError:e=>E(e.message,{tone:`danger`})});if(i.data===void 0)return null;let d=ie([],e),g=i.data.agentDefaults.runner??`claude`,_=f(t??g,p(e))??t??g,v=i.data.agentDefaults.models??{};return(0,Q.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,Q.jsx)(ae,{rows:d,runner:g,accountFor:()=>null,providerStatus:a,disabled:u.isPending,onPick:e=>{e!==g&&u.mutate({agentDefaults:{runner:e}})}}),(0,Q.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,Q.jsx)(`span`,{children:`Default model for`}),(0,Q.jsx)(`select`,{"aria-label":`Model agent`,value:_,onChange:e=>n(e.target.value),children:e.runners.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),e.runners.filter(e=>e.id===_).map(t=>(0,Q.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,Q.jsx)(D,{className:`size-4 text-accent-icon shrink-0`}),(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:v[t.id]??``,disabled:u.isPending,onChange:e=>u.mutate({agentDefaults:{models:{[t.id]:e.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[G(t.id,e,s[t.id]?.data,[v[t.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),(0,Q.jsx)(we,{runner:t.id,runners:e,catalog:s[t.id]})]})]},t.id))]})]})}function we({runner:e,runners:t,catalog:n}){let r=re(e,t,n);return r?(0,Q.jsx)(`option`,{disabled:!0,children:r}):null}function Te({account:e,runners:t,status:n,editable:i}){let a=S();return(0,Q.jsxs)(Q.Fragment,{children:[n&&n.status!==`connected`&&d(t,e.provider)?.browserLogin?(0,Q.jsx)(X,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,i&&n&&n.status!==`connected`&&d(t,e.provider)?.terminalLogin!==!1?(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:a.isPending,onClick:()=>a.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>E(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>E(e instanceof r&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function Ee({account:e,runners:t,status:n,editable:r}){return!n||n.requiresAccountHome===!1?null:e.exists?!e.looksValid&&e.configDir?(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,g(t,e.provider),` config yet`]}):null:(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:r?`— folder not created yet; Connect will make it`:`— not initialized on host yet`})}function De({account:e,runners:t,editable:n,onRemove:r}){let a=i(e),o=v(),s=C(a,e.status===void 0),c=e.status??s.data?.status,l=c?ve[c.status]:void 0;return(0,Q.jsx)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:(0,Q.jsxs)(`div`,{className:`settings-account-card`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)(j,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`discovered`}):null]}),(0,Q.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[e.configDir?(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11px] text-soft-foreground`,title:e.path,children:e.configDir}):null,(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(R,{tone:l?.tone??`neutral`,pulse:l===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:l?.label??`Checking…`}),(0,Q.jsx)(Ee,{account:e,runners:t,status:c,editable:n})]}),c?.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c.hint}):null]})]}),(0,Q.jsxs)(`div`,{className:`settings-account-actions`,children:[(0,Q.jsx)(Te,{account:e,runners:t,status:c,editable:n}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:o.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>o.mutate(a,{onError:e=>E(e.message,{tone:`danger`})}),children:`Check again`}),n?(0,Q.jsx)(Oe,{account:e,onRemove:r}):null]})]})})}function Oe({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.label),o=x();return(0,Q.jsx)(Q.Fragment,{children:e.isDefault?null:(0,Q.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>E(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{ye as GlobalAgentsSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{An as r,Ar as i,Pn as a,ci as o,jn as s,nn as c}from"./project-scope-context-D9axDY18.js";import{$t as l,Ct as u,Gt as d,Ht as f,Kt as p,Mt as m,Rt as h,Ut as g,Xt as _,bt as v,ht as y,in as b,kt as x,lt as S,ot as C,st as w,ut as ee,yt as te}from"./queries-DzwCG927.js";import{t as ne}from"./useQuery-CzVHT8UE.js";import{f as T}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{n as E}from"./toaster-Bo5vCbz-.js";import{y as D}from"./design-icons-CzEoMH9c.js";import{t as O}from"./createLucideIcon-BHp8sXmF.js";import{t as k}from"./folder-browser-CffyHz8w.js";import{t as A}from"./button-BQ2y4XRB.js";import{t as j}from"./badge-D9JrXe0o.js";import{a as M,i as N,o as P,r as F,s as I,t as L}from"./dialog-BVF6dIeS.js";import{t as R}from"./status-dot-DtAOFiIi.js";import{n as z}from"./agents-settings-path-7X6_cvUg.js";import{t as B}from"./centered-state-V15AR_qo.js";import{Gt as V,Ht as H,Jt as U,Kt as W,N as G,Ut as K,Vt as q,Wt as J,j as re,qt as Y}from"./index-CHIFhfha.js";import{n as X,r as ie,t as ae}from"./settings-agent-picker-i4wCYEex.js";import{n as oe,r as se,t as ce}from"./remote-settings-notice-Drbpb7K4.js";var le=O(`id-card`,[[`path`,{d:`M16 10h2`,key:`8sgtl7`}],[`path`,{d:`M16 14h2`,key:`epxaof`}],[`path`,{d:`M6.17 15a3 3 0 0 1 5.66 0`,key:`n6f512`}],[`circle`,{cx:`9`,cy:`11`,r:`2`,key:`yxgjnd`}],[`rect`,{x:`2`,y:`5`,width:`20`,height:`14`,rx:`2`,key:`qneu4z`}]]),Z=e(t(),1),Q=n(),ue=`~/.claude-second`;function de({open:e,onOpenChange:t,providers:n,initialProvider:r}){let i=_().data,[a,o]=(0,Z.useState)(null),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(r??n[0]??`claude`),[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(``),[g,v]=(0,Z.useState)(!1),y=ee(),b=m.trim();return(0,Q.jsx)(L,{open:e,onOpenChange:t,children:(0,Q.jsxs)(F,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(P,{children:[(0,Q.jsx)(I,{children:`Add agent account`}),(0,Q.jsx)(N,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,Q.jsx)(`select`,{"aria-label":`Agent`,"data-slot":`add-account-provider`,value:l,onChange:e=>u(e.target.value),className:`rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`,children:n.map(e=>(0,Q.jsx)(`option`,{value:e,children:e},e))})]}),(0,Q.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,Q.jsx)(`input`,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:f,placeholder:`Work`,onChange:e=>p(e.target.value),className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 text-[13px] outline-none focus-visible:border-ring`})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-[13px]`,children:[(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,Q.jsx)(`input`,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:m,placeholder:d(i,l)?.accountFolderExample??ue,onChange:e=>{h(e.target.value),c(null),y.reset()},className:`min-w-0 flex-1 rounded-md border border-input bg-card px-2 py-1 font-mono text-[13px] outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":g,onClick:()=>v(e=>!e),children:g?`Hide folders`:`Browse…`})]}),(0,Q.jsxs)(`p`,{className:`text-[11px] text-soft-foreground`,children:[`A `,(0,Q.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),g?(0,Q.jsx)(k,{path:a,selected:s,onSelect:e=>{c(e),h(e.path),y.reset()},onEnter:e=>{o(e),c(null),y.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,y.isError?(0,Q.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:y.error instanceof Error?y.error.message:`could not add that folder`}):null,(0,Q.jsxs)(M,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,Q.jsx)(A,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(A,{"data-slot":`add-account-confirm`,disabled:b===``||y.isPending,onClick:()=>{b===``||y.isPending||y.mutate({provider:l,configDir:b,...f.trim()?{label:f.trim()}:{}},{onSuccess:()=>{t(!1),p(``),h(``),c(null),v(!1),E(`Account added — use Connect to sign in`)}})},children:y.isPending?`Adding…`:`Add account`})]})]})})}async function fe(e){return a(await s.api.v1[`runner-install`][`:runner`].$get({param:{runner:e}}),`/runner-install/:runner`)}async function pe(e,t){return a(await s.api.v1[`runner-install`][`:runner`].$post({param:{runner:e},json:{action:t}}),`/runner-install/:runner`)}var me={idle:``,checking:`Checking for updates…`,downloading:`Downloading CLI…`,verifying:`Verifying CLI…`,extracting:`Extracting CLI…`,activating:`Activating CLI…`,removing:`Removing CLI…`,failed:``};function he(e){let t=y().data?.capabilities?.settingsAdmin===!0,n=o(),r=[`runner-install`,e],i=ne({queryKey:r,queryFn:()=>fe(e),enabled:t,retry:!1,refetchInterval:e=>{if(e.state.error)return!1;let t=e.state.data?.phase;return t&&t!==`idle`&&t!==`failed`?1e3:6e4}}),a=b({mutationFn:t=>pe(e,t),retry:!1,onSuccess:e=>{n.setQueryData(r,e)}}),s=i.data;return{allowed:t,data:s,busy:a.isPending||!!s&&s.phase!==`idle`&&s.phase!==`failed`,error:a.error?.message??i.error?.message??s?.error,action:a,status:i}}function ge({state:e}){let{data:t,busy:n,action:r,status:i}=e;if(t?.supported===!1)return(0,Q.jsx)(`p`,{children:`This host is not supported by the CLI installer.`});let a=!!t?.installedVersion;return(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,disabled:n||!t,onClick:()=>r.mutate(a?`update`:`install`),children:a?`Update CLI`:`Install CLI`}),a?(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>r.mutate(`remove`),children:`Remove CLI`}):null,(0,Q.jsx)(A,{className:`min-h-11 active:opacity-80`,variant:`outline`,disabled:n,onClick:()=>{i.isError?i.refetch():r.mutate(`check`)},children:`Check for updates`})]})}function _e({runner:e}){let t=he(e),{allowed:n,data:r,busy:i,error:a}=t;return n?(0,Q.jsxs)(`section`,{"aria-label":`CLI installation`,className:`grid gap-3`,children:[(0,Q.jsxs)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:[r?.installedVersion?`Installed CLI ${r.installedVersion}`:`CLI not installed`,r?.latestVersion?` · Latest ${r.latestVersion}`:``,i&&r?` · ${me[r.phase]}`:``]}),a?(0,Q.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:a}):null,(0,Q.jsx)(ge,{state:t}),r?.installedVersion?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Removing the CLI keeps account data and lets running tasks finish.`}):null]}):null}var ve={connected:{label:`Connected`,tone:`success`},disconnected:{label:`Not connected`,tone:`pending`},"not-installed":{label:`Not installed`,tone:`neutral`},unknown:{label:`Could not verify`,tone:`danger`}};function ye(){let e=w(),t=_();if(e.isPending||t.isPending)return(0,Q.jsx)(`p`,{"data-slot":`accounts-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agents…`});let n=e.error??t.error;return n?(0,Q.jsx)(B,{icon:(0,Q.jsx)(le,{}),tone:`danger`,title:`Agents did not load`,subtitle:n.message,heading:`h2`}):(0,Q.jsx)($,{data:e.data,runners:t.data})}function be(){let{hash:e}=T();(0,Z.useEffect)(()=>{if(!e)return;let t=document.getElementById(decodeURIComponent(e.slice(1)));t&&(t.scrollIntoView?.({block:`start`}),t.focus({preventScroll:!0}))},[e])}function $({data:e,runners:t}){let n=y(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(null),s=u();return be(),se(),(0,Q.jsxs)(`div`,{"data-slot":`accounts-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-5 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Install, update and sign in to each agent, and set what a project runs when it has not chosen.`}),(0,Q.jsx)(oe,{risk:`Agent accounts run each CLI with the configured host folder`}),e.editable?null:(0,Q.jsxs)(`p`,{"data-slot":`accounts-hosted`,className:`text-[13px] text-soft-foreground`,children:[`Agent accounts are read-only on this remote cockpit. Run`,` `,(0,Q.jsx)(`code`,{children:ce}),` on the host to add, edit, or sign in to accounts here.`]}),(0,Q.jsx)(`div`,{"data-slot":`agent-cards`,className:`flex flex-col gap-4`,children:t.runners.map(r=>(0,Q.jsx)(Se,{entry:r,check:n.data?.checks?.find(e=>e.name===r.id),settingsAdmin:n.data?.capabilities?.settingsAdmin===!0,runners:t,editable:e.editable,accounts:e.profiles.filter(e=>e.provider===r.id),canCarryAccounts:e.profileCapableProviders.includes(r.id),onAdd:()=>i(r.id),onRemove:o},r.id))}),(0,Q.jsx)(Ce,{runners:t}),r===null?null:(0,Q.jsx)(de,{open:!0,onOpenChange:e=>!e&&i(null),providers:e.profileCapableProviders,initialProvider:r},r),(0,Q.jsx)(q,{open:a!==null,onOpenChange:e=>!e&&o(null),children:(0,Q.jsxs)(J,{"data-slot":`accounts-remove-confirm`,children:[(0,Q.jsxs)(Y,{children:[(0,Q.jsxs)(U,{children:[`Remove “`,a?.label,`”?`]}),(0,Q.jsxs)(V,{children:[`This only forgets the account. Nothing in `,a?.configDir??`this account’s folder`,` is deleted — not your login, not your sessions. Projects using it fall back to the default account, and tasks that ran under it can no longer be resumed from here.`]})]}),(0,Q.jsxs)(W,{children:[(0,Q.jsx)(K,{children:`Cancel`}),(0,Q.jsx)(H,{"data-action":`accounts-remove-confirm`,disabled:s.isPending,onClick:()=>{let e=a;e&&s.mutate(e.id,{onSuccess:()=>{o(null),E(`Removed ${e.label}`)},onError:e=>E(e.message,{tone:`danger`})})},children:`Remove`})]})]})})]})}function xe({entry:e,check:t}){return t===void 0?(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Checking…`}):t.available?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"data-slot":`agent-installed`,children:`Installed`}),t.version?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `}),(0,Q.jsx)(`span`,{"data-slot":`agent-version`,children:t.version})]}):null]}):(0,Q.jsxs)(`span`,{"data-slot":`agent-installed`,children:[`Not installed`,e.installHint?(0,Q.jsxs)(Q.Fragment,{children:[` — `,(0,Q.jsx)(`code`,{className:`break-all`,children:e.installHint})]}):null]})}function Se({entry:e,check:t,settingsAdmin:n,runners:r,editable:i,accounts:a,canCarryAccounts:o,onAdd:s,onRemove:c}){let l=e.id,u=e.managedInstall===!0&&n,d=a.filter(e=>e.isDefault).length,f=`${z(l)}-title`;return(0,Q.jsxs)(`section`,{id:z(l),tabIndex:-1,"aria-labelledby":f,"data-slot":`accounts-provider`,"data-provider":l,className:`settings-agent-card flex flex-col gap-4 rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h3`,{id:f,className:`settings-account-provider-title`,children:e.displayName}),u?(0,Q.jsx)(_e,{runner:l}):null,(0,Q.jsxs)(`div`,{className:`settings-account-installation settings-readout`,children:[u?null:(0,Q.jsx)(xe,{entry:e,check:t}),i||a.length>0?(0,Q.jsxs)(`span`,{className:`settings-account-count`,children:[a.length,` `,a.length===1?`account`:`accounts`,` (`,d,` discovered, `,a.length-d,` added)`]}):null]}),a.length>0?(0,Q.jsx)(`ul`,{children:a.map(e=>(0,Q.jsx)(De,{account:e,runners:r,editable:i,onRemove:()=>c(e)},e.id))}):null,i?o?(0,Q.jsx)(`div`,{className:`settings-account-add-row`,children:(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`accounts-add`,"data-provider":l,onClick:s,children:`Add account`})}):(0,Q.jsxs)(`p`,{"data-slot":`accounts-single-only`,className:`text-[11px] text-soft-foreground`,children:[e.displayName,` can only hold one account here: it keeps its credentials outside its config folder, so a second folder would change settings without changing the login — which would say “work account” while billing the other one.`]}):a.length===0&&e.browserLogin?(0,Q.jsxs)(`div`,{"data-slot":`hosted-sign-in`,className:`flex flex-wrap items-center gap-3`,children:[(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Discovered account`}),(0,Q.jsx)(X,{provider:l,label:e.displayName})]}):null]})}function Ce({runners:e}){let[t,n]=(0,Z.useState)(null),r=o(),i=m(),a=te(),s=l(p(e)),u=b({mutationFn:e=>c(e),onSuccess:e=>r.setQueryData(h.config,e),onError:e=>E(e.message,{tone:`danger`})});if(i.data===void 0)return null;let d=ie([],e),g=i.data.agentDefaults.runner??`claude`,_=f(t??g,p(e))??t??g,v=i.data.agentDefaults.models??{};return(0,Q.jsxs)(`section`,{"data-slot":`accounts-defaults`,className:`flex flex-col gap-3 rounded-lg border border-border bg-card/40 p-3.5`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:`Defaults for new projects`}),(0,Q.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`What a project runs when it has not chosen for itself — set once instead of per repository. A project that has chosen keeps its own.`})]}),(0,Q.jsx)(ae,{rows:d,runner:g,accountFor:()=>null,providerStatus:a,disabled:u.isPending,onPick:e=>{e!==g&&u.mutate({agentDefaults:{runner:e}})}}),(0,Q.jsxs)(`div`,{className:`settings-account-models flex flex-col gap-2`,children:[(0,Q.jsxs)(`label`,{className:`settings-model-agent-choice`,children:[(0,Q.jsx)(`span`,{children:`Default model for`}),(0,Q.jsx)(`select`,{"aria-label":`Model agent`,value:_,onChange:e=>n(e.target.value),children:e.runners.map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.displayName},e.id))})]}),e.runners.filter(e=>e.id===_).map(t=>(0,Q.jsxs)(`label`,{className:`settings-account-model flex items-center gap-3`,children:[(0,Q.jsx)(D,{className:`size-4 text-accent-icon shrink-0`}),(0,Q.jsx)(`span`,{className:`w-24 shrink-0 text-xs text-muted-foreground`,children:t.displayName}),(0,Q.jsxs)(`select`,{"aria-label":`Default model for ${t.pickerLabel}`,"data-slot":`accounts-default-model`,"data-runner":t.id,value:v[t.id]??``,disabled:u.isPending,onChange:e=>u.mutate({agentDefaults:{models:{[t.id]:e.target.value||null}}}),className:`block w-full max-w-xs rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`,children:[G(t.id,e,s[t.id]?.data,[v[t.id]]).map(e=>(0,Q.jsx)(`option`,{value:e.id,children:e.id===``?`Native default`:e.label},e.id)),(0,Q.jsx)(we,{runner:t.id,runners:e,catalog:s[t.id]})]})]},t.id))]})]})}function we({runner:e,runners:t,catalog:n}){let r=re(e,t,n);return r?(0,Q.jsx)(`option`,{disabled:!0,children:r}):null}function Te({account:e,runners:t,status:n,editable:i}){let a=S();return(0,Q.jsxs)(Q.Fragment,{children:[n&&n.status!==`connected`&&d(t,e.provider)?.browserLogin?(0,Q.jsx)(X,{provider:e.provider,...e.isDefault?{}:{profileId:e.id},label:e.label}):null,i&&n&&n.status!==`connected`&&d(t,e.provider)?.terminalLogin!==!1?(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-connect`,disabled:a.isPending,onClick:()=>a.mutate({provider:e.provider,...e.isDefault?{}:{profileId:e.id}},{onSuccess:e=>E(e.opened?`Finish signing in in the terminal, then Check again.`:`This account is already connected.`),onError:e=>E(e instanceof r&&e.command?`${e.message} — run: ${e.command}`:e.message,{tone:`danger`})}),children:`Connect`}):null]})}function Ee({account:e,runners:t,status:n,editable:r}){return!n||n.requiresAccountHome===!1?null:e.exists?!e.looksValid&&e.configDir?(0,Q.jsxs)(`span`,{"data-slot":`account-unrecognised`,children:[`— this folder does not look like `,g(t,e.provider),` config yet`]}):null:(0,Q.jsx)(`span`,{"data-slot":`account-missing`,children:r?`— folder not created yet; Connect will make it`:`— not initialized on host yet`})}function De({account:e,runners:t,editable:n,onRemove:r}){let a=i(e),o=v(),s=C(a,e.status===void 0),c=e.status??s.data?.status,l=c?ve[c.status]:void 0;return(0,Q.jsx)(`li`,{"data-slot":`account-row`,"data-account":e.id,className:`flex flex-col gap-2 px-3.5 py-3`,children:(0,Q.jsxs)(`div`,{className:`settings-account-card`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-foreground`,children:e.label}),e.isDefault?(0,Q.jsx)(j,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`discovered`}):null]}),(0,Q.jsxs)(`div`,{className:`settings-account-readout settings-readout`,children:[e.configDir?(0,Q.jsx)(`p`,{"data-slot":`account-path`,className:`mt-0.5 truncate font-mono text-[11px] text-soft-foreground`,title:e.path,children:e.configDir}):null,(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(R,{tone:l?.tone??`neutral`,pulse:l===void 0}),(0,Q.jsx)(`span`,{"data-slot":`account-status`,children:l?.label??`Checking…`}),(0,Q.jsx)(Ee,{account:e,runners:t,status:c,editable:n})]}),c?.hint?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:c.hint}):null]})]}),(0,Q.jsxs)(`div`,{className:`settings-account-actions`,children:[(0,Q.jsx)(Te,{account:e,runners:t,status:c,editable:n}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-recheck`,disabled:o.isPending,title:`Re-probe this account's login now, instead of waiting for the cached answer`,onClick:()=>o.mutate(a,{onError:e=>E(e.message,{tone:`danger`})}),children:`Check again`}),n?(0,Q.jsx)(Oe,{account:e,onRemove:r}):null]})]})})}function Oe({account:e,onRemove:t}){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(e.label),o=x();return(0,Q.jsx)(Q.Fragment,{children:e.isDefault?null:(0,Q.jsx)(`div`,{"data-slot":`account-manage`,className:`settings-account-management`,children:n?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`input`,{type:`text`,autoFocus:!0,"aria-label":`Name for ${e.label}`,"data-slot":`account-rename-input`,value:i,onChange:e=>a(e.target.value),className:`w-48 rounded-md border border-input bg-card px-2 py-1 text-xs outline-none focus-visible:border-ring`}),(0,Q.jsx)(A,{type:`button`,size:`sm`,"data-action":`account-rename-save`,disabled:o.isPending||i.trim()===``||i.trim()===e.label,onClick:()=>o.mutate({id:e.id,label:i.trim()},{onSuccess:()=>r(!1),onError:e=>E(e.message,{tone:`danger`})}),children:`Save`}),(0,Q.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{a(e.label),r(!1)},children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-rename`,onClick:()=>r(!0),children:`Rename`}),(0,Q.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-action":`account-remove`,onClick:t,children:`Remove account`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Renaming changes what Squawk calls this account, not its folder.`})]})})})}export{ye as GlobalAgentsSection};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./live-refetch-CZb2VOyu.js";import{An as a,Dn as o,Kr as s,Lr as c,Mn as l,Pn as u,Xn as d,Xr as f,ci as p,hn as m,hr as ee,jn as te,wn as h,xn as ne,zr as re}from"./project-scope-context-D9axDY18.js";import{B as g,F as ie,G as ae,I as _,J as oe,N as v,P as se,S as ce,T as le,W as y,Y as ue,j as b,z as x}from"./live-protocol-DteqtbyN.js";import{t as de}from"./useQuery-CzVHT8UE.js";import{n as fe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as pe,t as me}from"./live-reads-BxjlQXfN.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{t as C}from"./bot-TkDIw4y-.js";import{n as he,r as ge,t as _e}from"./hourglass-B0lPAJvT.js";import{t as ve}from"./eye-B8okNWXU.js";import{t as ye}from"./message-square-B-MD-8rD.js";import{t as be}from"./button-BQ2y4XRB.js";import{t as w}from"./project-router-CDPfL2Jz.js";import"./attention-CvHM4cjG.js";import{t as T}from"./status-dot-DtAOFiIi.js";import{$t as xe}from"./index-BRgRv29I.js";var Se=S(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Ce=S(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),we=S(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Te=S(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Ee=S(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),De=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Oe=S(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ke=S(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ae=S(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),E=e(t(),1),D=n(),O=ue(),k=x().int().nonnegative(),A=y().min(1),je=g({title:y().max(160),toolKind:b([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:b([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:O,endedAt:O.optional()}).strict(),Me=b([`pass`,`fail`,`pending`,`skipping`,`cancel`]),Ne=g({checks:v(g({name:y().max(100),bucket:Me}).strict()).max(100),counts:g({pass:k,fail:k,pending:k,skipping:k,cancel:k}).strict(),truncated:_(!0).optional()}).strict(),Pe=ie(`kind`,[g({kind:_(`human`),since:O,detail:g({question:y().max(500).optional(),reason:b([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:x().int().positive().optional()}).strict()}).strict(),g({kind:_(`usage-limit`),detail:g({resumeAt:y()}).strict()}).strict(),g({kind:_(`workers`),since:O,deadline:O.optional(),detail:g({owed:k,total:k,settled:k,replies:_(!0).optional(),mode:ce.optional(),recipientRunIds:v(A)}).strict()}).strict(),g({kind:_(`peers`),since:O,deadline:O,detail:g({peerRunIds:v(A)}).strict()}).strict(),g({kind:_(`subagents`),since:O,deadline:O,detail:g({running:k}).strict()}).strict(),g({kind:_(`pr`),since:O,deadline:O,detail:g({number:x().int().positive(),target:d,checks:Ne.shape.checks.optional(),counts:Ne.shape.counts.optional(),truncated:_(!0).optional()}).strict()}).strict(),g({kind:_(`process`),since:O,deadline:O,detail:g({pid:x().int(),note:y().optional()}).strict()}).strict(),g({kind:_(`plugin`),since:O,deadline:O.optional(),detail:g({pluginKind:y().min(1).max(64),summary:y().max(256)}).strict()}).strict(),g({kind:_(`timer`),since:O,deadline:O,detail:g({wakeAt:O,note:y().optional()}).strict()}).strict()]),Fe={runId:A,title:y(),status:ee,rung:b(ne),runner:f.optional(),model:y().optional(),currentStepId:y().optional(),startedAt:y().optional(),wait:Pe.optional(),tool:je.optional(),rate:v(k).length(30),error:y().max(200).optional()},Ie=g({...Fe,revision:k,collected:se()}).strict(),Le=g({...Fe,workers:v(Ie)}).strict(),Re=g({requestId:oe(),relationship:b([`family`,`peer`]),senderRunId:A,recipientRunId:A,text:y().max(500),senderTitle:y().optional(),recipientTitle:y().optional(),createdAt:O,deadline:O.optional()}).strict(),ze=g({requestId:oe(),senderRunId:A,recipientRunId:A,status:le.shape.status,observedAt:O}).strict(),Be=g({generatedAt:O,projects:v(g({projectId:y(),name:y(),loaded:se(),unavailable:g({status:ae([_(404),_(409),_(503)]),error:y()}).strict().optional(),inReview:k,tasks:v(Le),requests:v(Re),closed:v(ze)}).strict())}).strict();g({project:ae([_(`default`),y().regex(m)]).optional()});var Ve=5e3,He=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],Ue=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,We=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,Ge=`the Squawk server answered /workspace/activity with an unexpected body`;function Ke(e){let t=Be.safeParse(e);if(!t.success)throw new a(200,Ge);return t.data}async function qe(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return Ke(await u(await te.api.v1.workspace.activity.$get({query:n},l(t)),`/workspace/activity`))}function Je(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var Ye=new Date(0).toISOString();function Xe(e){return e!==void 0&&e!==Ye&&!Number.isNaN(Date.parse(e))}var Ze=new Set([404,409,503]);function Qe(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??Ye,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function $e(e,t){return new a(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var et=(e,t)=>e.kind===`project`&&Ze.has(t.status)?t.status:void 0;function tt(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,E.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,E.useMemo)(()=>He(n),[n]),o=p(),s=de({queryKey:r,queryFn:async({signal:e})=>{let t=o.getQueryData(r);try{return Je(t,await qe(n,{signal:e}))}catch(e){let r=e instanceof a?et(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return Qe(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,E.useEffect)(()=>{let e=!0,t=t=>{o.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let i=et(n,t);if(i!==void 0&&n.kind===`project`){o.setQueryData(r,e=>Qe(e,n.projectId,i,t.message));return}let a=o.getQueryCache().find({queryKey:r,exact:!0});a?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:a.state.errorUpdateCount+1,fetchStatus:`idle`})})},a=n=>{let i;try{i=Ke(n)}catch(e){t(e);return}o.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&o.setQueryData(r,e=>Je(e,i))})},s=pe(Ue(n),a),l=i(Ve),u,d=()=>{let e=c()===`finite`&&l!==!1;e&&!u?u=me({path:We(n),intervalMs:l},(e,n)=>{n===void 0?a(e):t($e(e,n))}):!e&&u&&(u(),u=void 0)};d();let f=re(d);return()=>{e=!1,f(),u?.(),s()}},[o,r,n]),s}var j=e=>String(e).padStart(2,`0`);function M(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${j(r)}:${j(i)}`:`${r}:${j(i)}`}function nt(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min`:`${Math.floor(n/60)} h ${j(n%60)} min`}function N(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var rt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function P(e){let t=Date.parse(e);return Number.isNaN(t)?e:rt.format(t)}function it(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var at=new Set([`queued`,`running`,`waiting`]),ot={review:`In review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},st={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},F=e=>at.has(e),I=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,L=e=>h(e.rung).tone,R=(e,t=`Deadline`)=>e?`${t} ${P(e)}`:void 0;function ct(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${I(t.length,`task`)}`}function lt(e,t){let n=e.tool,r={verb:`Doing`,tone:L(e),icon:`tool`},i=n?.endedAt!==void 0&&N(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${nt(N(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function ut(e,t){let n={verb:`Needs you`,tone:L(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${I(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function dt(e){return{verb:`Needs you`,tone:L(e),icon:`user`,main:`Permission`,action:`open`}}function ft(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:L(e),since:t.since};if(o){let e=c.length>0?ct(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...z(`detail`,R(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${pt[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...z(`detail`,R(t.deadline))}}var pt={one:`One`,any:`Any`,all:`All`};function mt(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var ht=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function gt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=ht.reduce((e,t)=>e+i(t),0),o=ht.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var _t=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function vt(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=_t.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=gt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function yt(e,t){let n={tone:L(e),since:t.since,...z(`detail`,R(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:mt(t),...z(`checks`,r),...z(`overflow`,gt(t)),...z(`checkSummary`,vt(t))}}function z(e,t){return t===void 0?{}:{[e]:t}}function bt(e,t,n){let r=L(e);switch(t.kind){case`workers`:return ft(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:ct(`For`,t.detail.peerRunIds,n),detail:`Deadline ${P(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:I(t.detail.running,`native subagent`),detail:`Deadline ${P(t.deadline)}`};case`pr`:return yt(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${M(N(t.since,n.now))} · deadline ${P(t.deadline)}`};case`plugin`:return{verb:`Waiting`,tone:r,icon:`timer`,since:t.since,main:t.detail.summary,...z(`detail`,R(t.deadline))};case`timer`:return{verb:`Waiting for timer`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${P(t.detail.wakeAt)} · in ${M(-N(t.detail.wakeAt,n.now))}`};case`usage-limit`:return xt(e,t.detail.resumeAt,n);case`human`:return}}function xt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${P(t)} · in ${M(r-n.now)}`;return{verb:`Paused`,tone:L(e),icon:`pause`,main:`Usage limit`,detail:i}}function St(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:L(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${nt(N(n,t.now))}`}:{}}}function B(e,t){return{verb:ot[e.status]??e.status,tone:L(e),icon:st[e.status]??`done`,main:t}}function Ct(e,t){return F(e.status)?wt(e,t):B(e,I(e.workers.filter(e=>F(e.status)).length,`live worker`))}function wt(e,t){let n=e.wait;switch(e.rung){case`running`:return lt(e,t);case`needs-permission`:return dt(e);case`needs-you`:return ut(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?xt(e,n.detail.resumeAt,t):{verb:`Paused`,tone:L(e),icon:`pause`,main:`Usage limit`};case`queued`:case`waiting-for-capacity`:return St(e,t);default:return(n&&bt(e,n,t))??St(e,t)}}function Tt(e,t,n){if(n!==void 0&&F(e.status))return{verb:`Asks parent`,tone:L(e),main:`“${n}”`,asks:!0};let r=Et(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Et(e,t){switch(e.status){case`done`:return B(e,e.collected?`Collected`:`Ready to collect`);case`review`:return B(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return B(e,e.error??ot[e.status]??e.status);default:return wt({...e,workers:[]},t)}}function Dt(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function Ot(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function V(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var kt=(e,t)=>V(e,t.senderRunId,t.senderTitle),H=(e,t)=>V(e,t.recipientRunId,t.recipientTitle),At=(e,t)=>`wait:${e}:${t}`;function jt(e){let t=[];for(let n of e){let e=n.wait;if(!(!F(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:At(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function Mt(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function Nt(e,t){return t.filter(t=>t.waiterRunId===e)}function Pt(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${H(n,r)}`),r.recipientRunId===e&&i.push(`${kt(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${V(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${V(n,t.waiterRunId)} waits for you to write`);return i}function Ft(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function It(e,t){let n=-N(e,t);return n>=1e3?`reply due in ${M(n)}`:`reply overdue`}function Lt(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function Rt(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:zt[Bt(e,t)]}}var zt={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function Bt(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var Vt=new Set([`queued`,`waiting-for-capacity`]);function Ht(e){if(F(e.status))return o(e.rung)?`needsYou`:e.rung===`running`?`working`:Vt.has(e.rung)?`queued`:`waiting`}function Ut(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=Ht(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>F(e.status)).length}}return t}function Wt(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Gt({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var U={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},W={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},Kt=(e,t)=>`${e}\n${t}`;function qt(e,t){let n=Kt(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var Jt=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Yt={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function Xt(e,t){let n=Yt[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.workerHold+U.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},U.workerHold)}function Zt(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},U.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},U.comet)}function Qt(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},U.fade);return}let a=U.comet+U.replied+U.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},U.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},U.comet+U.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},U.comet)}function $t(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:h(t.task.rung).tone},U.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},U.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},U.workerEnter);case`worker-settled`:return Xt(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},U.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},U.cardLeave);case`check-passed`:return e.timed(`checks`,Kt(t.runId,t.name),{},U.check);case`request-opened`:return Zt(e,t.request);case`request-closed`:return Qt(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},U.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},U.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},U.fade)}}function en(e,t,n){let r=new Jt(t);if(!n)for(let t of e)$t(r,t);return{changes:r.changes,timers:r.timers}}function tn(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function nn(e,t){return t.reduce(tn,e)}function rn(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}var an={success:`text-success`,pending:`text-signal-word-amber`,danger:`text-signal-word-red`,accent:`text-accent-text`,info:`text-info`,running:`text-status-running`,neutral:`text-muted-foreground`};function on({tone:e,className:t,children:n,...i}){return(0,D.jsx)(`span`,{...i,className:r(`bg-card-2`,{"text-success":e===`success`,"text-signal-word-amber":e===`pending`,"text-signal-word-red":e===`danger`,"text-accent-text":e===`accent`,"text-info":e===`info`,"text-status-running":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var sn={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},cn={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`},ln={tool:Ae,user:ke,workers:C,reply:ye,peer:Ee,subagents:C,ci:Te,merge:we,command:Oe,timer:Ce,pause:De,queued:_e,review:ve,failed:he,done:ge,cancelled:Se};function un(e,t){let n=h(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:pn(e,t)??n.label}}var dn=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function fn(e){return e?.kind===`workers`&&!e.detail.replies&&e.detail.owed>0}function pn(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`&&!fn(n))return`waiting on parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return dn(`waiting on`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`waiting on replies`;if(n?.kind===`workers`&&n.detail.owed>0)return dn(`waiting on`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return dn(`waiting for`,n.detail.running,`subagent`)}function mn(e,t){if(F(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function G({run:e,role:t}){let{tone:n,shape:i,label:a}=un(e,t);return(0,D.jsx)(`span`,{"data-activity-anchor":e.runId,className:r(`inline-flex size-[12px] shrink-0 items-center justify-center`,mn(e,i)),children:(0,D.jsx)(T,{tone:n,shape:i,role:`img`,"aria-label":a})})}function hn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=Lt(e,t),l=Nt(e,n);return c.length===0&&l.length===0?null:(0,D.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,H(r,e)]})},e.requestId)),l.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,V(r,e.peerRunId)]})},e.id))]})}var gn={pass:`bg-success`,fail:`bg-danger`,pending:`bg-info`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},_n=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function vn({checks:e,overflow:t,passed:n}){return(0,D.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:r(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,D.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:r(`h-[5px] min-w-px flex-1 rounded-[2px]`,gn[e.bucket],_n(e.bucket,n.has(e.name)))},e.name)),t?(0,D.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-[10px] leading-none text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`i`,{className:r(`h-[5px] w-2 rounded-[2px]`,gn[t.bucket])}),`+`,t.count]}):null]})}function yn({value:e,ink:t}){return(0,D.jsx)(`span`,{"data-slot":`activity-bar`,"aria-hidden":`true`,className:`col-start-2 mt-[5px] block h-1 overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:r(`block h-full bg-current`,t),style:{width:`${Math.round(e*100)}%`}})})}var bn=new Set;function xn({box:e,now:t,dense:n,motion:i={}}){let a=ln[e.icon],o=an[e.tone];return(0,D.jsxs)(`div`,{"data-slot":`activity-now`,"data-verb":e.verb,className:`relative grid grid-cols-[16px_minmax(0,1fr)] gap-x-2 gap-y-px overflow-hidden rounded-lg bg-card-2 px-2.5 py-2`,children:[i.sweep?(0,D.jsx)(`span`,{"data-slot":`activity-sweep`,"aria-hidden":`true`,className:`activity-sweep`}):null,(0,D.jsx)(a,{"aria-hidden":`true`,className:r(`mt-px size-[15px]`,o)}),(0,D.jsxs)(on,{tone:e.tone,className:`flex gap-2 text-[11px] font-semibold tracking-[0.04em] uppercase`,children:[(0,D.jsx)(`span`,{"data-slot":`activity-verb`,children:e.verb}),e.since?(0,D.jsx)(`span`,{"data-slot":`activity-age`,className:`ml-auto font-medium tracking-normal text-muted-foreground normal-case tabular-nums`,children:M(N(e.since,t))}):null]}),(0,D.jsx)(`span`,{"data-slot":`activity-main`,className:r(`col-start-2 truncate text-[12.5px] text-foreground`,e.mono&&`font-mono text-[12px]`,i.slideKey!==void 0&&`activity-slide`),children:e.main},i.slideKey??`still`),e.checks?(0,D.jsx)(vn,{checks:e.checks,overflow:e.overflow,passed:i.passed??bn}):null,e.checkSummary?(0,D.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:e.checkSummary}):null,e.bar===void 0?null:(0,D.jsx)(yn,{value:e.bar,ink:o}),e.detail&&!n?(0,D.jsx)(`span`,{"data-slot":`activity-detail`,className:`col-start-2 text-[11.5px] text-muted-foreground tabular-nums`,children:e.detail}):null]})}function Sn({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),i=Math.max(4,...e);return(0,D.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:r(`block h-4 w-[62px] shrink-0`,t),children:[(0,D.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}),e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/i*14);return(0,D.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var K=e=>`/tasks/${encodeURIComponent(e)}`;function Cn(e,t){return[e.runner,e.model,e.currentStepId?`step ${e.currentStepId}`:void 0,e.startedAt?nt(N(e.startedAt,t)):void 0].filter(e=>!!e).join(` · `)}function wn({texts:e}){return e.length===0?null:(0,D.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,D.jsx)(`li`,{children:e},t))})}function Tn({worker:e,parentId:t,requests:n,index:i,ctx:a,motion:o}){let s=Tt(e,a,Ft(e.runId,t,n)?.text),c=o.workerHold[e.runId];return(0,D.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":s.asks?`true`:void 0,"data-hold":c?.phase,className:r(`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,s.asks&&`-mx-1.5 bg-message-inbound-bg px-1.5`,e.runId in o.workerEnter&&`activity-row-enter`,c?.phase===`fold`&&`activity-row-fold`),children:[c?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:r(`activity-row-flash`,cn[c.tone])},c.key):null,(0,D.jsx)(`span`,{className:`mt-[3px]`,children:(0,D.jsx)(G,{run:e,role:`worker`})}),(0,D.jsxs)(`span`,{className:`min-w-0 truncate text-[12.5px] font-medium`,children:[(0,D.jsx)(w,{to:K(e.runId),className:`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:e.title}),(0,D.jsx)(`span`,{className:`ml-1.5 text-[11px] font-normal text-muted-foreground`,children:[e.runner,e.model].filter(Boolean).join(` · `)})]}),(0,D.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:`col-start-2 truncate text-[11.5px] text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`b`,{className:r(`font-semibold`,an[s.tone]),children:s.verb}),` · `,(0,D.jsx)(`span`,{className:r(s.mono&&`font-mono`),children:s.main})]}),(0,D.jsx)(wn,{texts:Pt(e.runId,n,i)})]})}function En({workers:e}){return(0,D.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[e.map(e=>(0,D.jsx)(G,{run:e,role:`worker`},e.runId)),(0,D.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function Dn({task:e,requests:t,index:n,ctx:r,dense:i,motion:a}){let o=e=>e in a.workerHold,s=e.workers.filter(e=>F(e.status)||e.status===`review`||o(e.runId)),c=Gt(Wt(e,o));return(0,D.jsxs)(D.Fragment,{children:[s.length>0&&i?(0,D.jsx)(En,{workers:s}):null,s.length>0&&!i?(0,D.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:s.map(i=>(0,D.jsx)(Tn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,c?(0,D.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-[11px] text-muted-foreground`,children:c}):null]})}var On=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;function kn(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function An(e,t,n){return n?`activity-card-leave`:e.runId in t.entering?`activity-card-enter`:void 0}function jn({task:e,motion:t,glow:n}){let i=t.flash[e.runId];return(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,i?(0,D.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":i.tone,"aria-hidden":`true`,className:r(`activity-flash`,sn[i.tone])},i.key):null]})}var Mn=[];function Nn({task:e,requests:t,waits:n=Mn,index:i,ctx:a,dense:o,narrow:s,motion:c=W,ghost:l=!1,linked:u=!1,onHover:d}){let f=Ct(e,a),p=l?{"data-activity-ghost":e.runId,inert:!0,"aria-hidden":!0}:{"data-activity-card":e.runId},m={sweep:e.rung===`running`&&F(e.status),slideKey:c.slides[e.runId]?.key,passed:qt(c,e.runId)};return(0,D.jsxs)(`article`,{...p,"data-flip":e.runId,"data-rung":e.rung,"data-action":f.action,"data-linked":u&&!l?`true`:void 0,...l?{}:kn(e.runId,d),className:r(`relative min-w-0 rounded-xl border bg-card px-3.5 py-3`,f.action?`border-pending`:`border-border`,u&&!l&&`outline-2 outline-offset-2 outline-message-peer-accent`,An(e,c,l)),children:[(0,D.jsx)(jn,{task:e,motion:c,glow:f.action!==void 0&&!l}),(0,D.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(G,{run:e,role:`root`}),(0,D.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[13.5px] font-semibold`,children:(0,D.jsx)(w,{to:K(e.runId),className:`after:absolute after:inset-0 after:rounded-xl after:content-[''] focus-visible:outline-2 focus-visible:outline-ring`,children:e.title})}),(0,D.jsx)(Sn,{rate:e.rate})]}),(0,D.jsx)(`p`,{className:`mt-0.5 mb-2 ml-5 truncate text-[11.5px] text-muted-foreground`,children:Cn(e,a.now)}),(0,D.jsx)(wn,{texts:Pt(e.runId,t,i,n)}),(0,D.jsx)(xn,{box:f,now:a.now,dense:o,motion:m}),f.action?(0,D.jsx)(`div`,{className:`mt-2 flex gap-1.5`,children:(0,D.jsx)(be,{asChild:!0,size:`sm`,variant:f.action===`answer`?`primary`:`outline`,className:`relative z-[1] max-md:min-h-11`,children:(0,D.jsx)(w,{to:K(e.runId),children:f.action===`answer`?`Answer`:`Open task`})})}):null,s?(0,D.jsx)(hn,{runId:e.runId,requests:t,waits:n,index:i,link:w,pathOf:K,className:`mt-2 flex flex-col gap-1`,linkClassName:On}):null,(0,D.jsx)(Dn,{task:e,requests:t,index:i,ctx:a,dense:o,motion:c})]})}function Pn(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+96)/396))}function Fn(e,t){let n=e[0],r=1/0;for(let i of e){let e=i.reduce((e,n)=>e+t(n),0);e<r&&(n=i,r=e)}return n}function In(e,t,n,r=()=>1){let i=Math.max(1,Math.floor(n)),a=new Set(t),o=e?.length===i?e.map(e=>e.filter(e=>a.has(e))):Array.from({length:i},()=>[]),s=new Set(o.flat());for(let e of t)s.has(e)||(Fn(o,r).push(e),s.add(e));return o}function Ln(e,t){return e!==void 0&&e.length===t.length&&e.every((e,n)=>e.length===t[n]?.length&&e.every((e,r)=>e===t[n]?.[r]))}var Rn=(e,t)=>({x0:Math.min(e.x,t.x),y0:Math.min(e.y,t.y),x1:Math.max(e.x,t.x),y1:Math.max(e.y,t.y)});function zn(e,t,n=1){return t.some(t=>t.x+n<e.x1&&e.x0<t.x+t.w-n&&t.y+n<e.y1&&e.y0<t.y+t.h-n)}var q=(e,...t)=>e.filter(e=>!t.some(t=>Bn(e,t))),Bn=(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,Vn=e=>Math.round(e*10)/10,J=e=>`${Vn(e.x)} ${Vn(e.y)}`;function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.x===n.x&&e.y===n.y)continue;let r=t[t.length-2];r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)&&t.pop(),t.push(n)}return t}function Un(e,t=8){let n=Hn(e),r=n[0];if(!r)return``;let i=`M${J(r)}`;for(let e=1;e<n.length;e++){let r=n[e],a=n[e-1],o=n[e+1];if(!o){i+=` L ${J(r)}`;continue}let s=Math.min(t,Math.hypot(r.x-a.x,r.y-a.y)/2,Math.hypot(o.x-r.x,o.y-r.y)/2),c=(e,t,n)=>{let r=Math.hypot(t.x-e.x,t.y-e.y)||1;return{x:e.x+(t.x-e.x)/r*n,y:e.y+(t.y-e.y)/r*n}};i+=` L ${J(c(r,a,s))} Q ${J(r)}, ${J(c(r,o,s))}`}return i}function Wn(e,t,n){let r=[];for(let i of[...e].sort((e,n)=>t(e)-t(n))){let e=r[r.length-1];e&&Math.abs(t(i)-e.from)<=2?e.to=Math.max(e.to,n(i)):r.push({from:t(i),to:n(i)})}return r}function Gn(e){return{rows:Wn(e,e=>e.y,e=>e.y+e.h).map(({from:e,to:t})=>({top:e,bottom:t})),cols:Wn(e,e=>e.x,e=>e.x+e.w).map(({from:e,to:t})=>({left:e,right:t}))}}var Y=(e,t,n)=>Math.max(0,e.findIndex(e=>Math.abs(t(e)-n)<=2)),X=(e,t)=>((e.rows[t]?.bottom??0)+(e.rows[t+1]?.top??(e.rows[t]?.bottom??0)+16))/2;function Kn(e,t,n){let r=e.cols,i=e=>((r[e]?.right??0)+(r[e+1]?.left??0))/2;return t<n?i(t):t>n?i(t-1):t+1<r.length?i(t):t>0?i(t-1):(r[t]?.right??0)+8}function qn(e,t,n,r=0){let i=Gn(n),a=Y(i.rows,e=>e.top,e.y),o=Y(i.rows,e=>e.top,t.y),s=o>a,c=e.x+e.w/2+r,l=t.x+t.w/2+r,u=(s?X(i,a):X(i,a-1))+r/2,d=(s?X(i,o-1):X(i,o))+r/2,f=Kn(i,Y(i.cols,e=>e.left,e.x),Y(i.cols,e=>e.left,t.x))+r/2,p={x:c,y:s?e.y+e.h+1:e.y-1},m={x:l,y:s?t.y-3:t.y+t.h+3};return{points:[p,{x:c,y:u},{x:f,y:u},{x:f,y:d},{x:l,y:d},m],label:{x:(c+f)/2,y:u}}}var Jn=15;function Yn(e,t,n){let r=[...n,...e.flatMap(e=>[e.y-Jn,e.y+e.h+Jn])].filter(t=>t>=0&&!e.some(e=>e.y-6<t&&t<e.y+e.h+6));return r.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e,r[0]??t)}function Xn(e,t,n,r,i=0){let a=t.x>e.x?1:-1,o=e.x+a*n/2+i,s=t.x-a*n/2+i,c=Yn(r.filter(e=>e.x+e.w>Math.min(o,s)&&e.x<Math.max(o,s)),(e.y+t.y)/2,[e.y,t.y])+(i===0?0:Math.sign(i)*Math.min(Math.abs(i),Jn-6)),l=c===e.y?{x:s,y:(c+t.y)/2}:{x:o,y:(e.y+c)/2};return{points:[e,{x:o,y:e.y},{x:o,y:c},{x:s,y:c},{x:s,y:t.y},{x:t.x-a*2,y:t.y}],label:l}}function Zn(e){let t=new Map;for(let n of e){let e=[n.senderRunId,n.recipientRunId].sort().join(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{t as i}from"./live-refetch-CZb2VOyu.js";import{An as a,Dn as o,Kr as s,Lr as c,Mn as l,Pn as u,Xn as d,Xr as f,ci as p,hn as m,hr as ee,jn as te,wn as h,xn as ne,zr as re}from"./project-scope-context-D9axDY18.js";import{B as g,F as ie,G as ae,I as _,J as oe,N as v,P as se,S as ce,T as le,W as y,Y as ue,j as b,z as x}from"./live-protocol-DteqtbyN.js";import{t as de}from"./useQuery-CzVHT8UE.js";import{n as fe}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as pe,t as me}from"./live-reads-BxjlQXfN.js";import{t as S}from"./createLucideIcon-BHp8sXmF.js";import{t as C}from"./bot-TkDIw4y-.js";import{n as he,r as ge,t as _e}from"./hourglass-B0lPAJvT.js";import{t as ve}from"./eye-B8okNWXU.js";import{t as ye}from"./message-square-B-MD-8rD.js";import{t as be}from"./button-BQ2y4XRB.js";import{t as w}from"./project-router-CDPfL2Jz.js";import"./attention-CvHM4cjG.js";import{t as T}from"./status-dot-DtAOFiIi.js";import{$t as xe}from"./index-CHIFhfha.js";var Se=S(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),Ce=S(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),we=S(`git-merge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),Te=S(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Ee=S(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),De=S(`pause`,[[`rect`,{x:`14`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`kaeet6`}],[`rect`,{x:`5`,y:`3`,width:`5`,height:`18`,rx:`1`,key:`1wsw3u`}]]),Oe=S(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),ke=S(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),Ae=S(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),E=e(t(),1),D=n(),O=ue(),k=x().int().nonnegative(),A=y().min(1),je=g({title:y().max(160),toolKind:b([`read`,`edit`,`delete`,`move`,`search`,`execute`,`think`,`fetch`,`task`,`plan`,`other`]),status:b([`pending`,`running`,`completed`,`failed`,`declined`]),startedAt:O,endedAt:O.optional()}).strict(),Me=b([`pass`,`fail`,`pending`,`skipping`,`cancel`]),Ne=g({checks:v(g({name:y().max(100),bucket:Me}).strict()).max(100),counts:g({pass:k,fail:k,pending:k,skipping:k,cancel:k}).strict(),truncated:_(!0).optional()}).strict(),Pe=ie(`kind`,[g({kind:_(`human`),since:O,detail:g({question:y().max(500).optional(),reason:b([`question`,`turn-end`,`budget`,`completion`]),queuedMessages:x().int().positive().optional()}).strict()}).strict(),g({kind:_(`usage-limit`),detail:g({resumeAt:y()}).strict()}).strict(),g({kind:_(`workers`),since:O,deadline:O.optional(),detail:g({owed:k,total:k,settled:k,replies:_(!0).optional(),mode:ce.optional(),recipientRunIds:v(A)}).strict()}).strict(),g({kind:_(`peers`),since:O,deadline:O,detail:g({peerRunIds:v(A)}).strict()}).strict(),g({kind:_(`subagents`),since:O,deadline:O,detail:g({running:k}).strict()}).strict(),g({kind:_(`pr`),since:O,deadline:O,detail:g({number:x().int().positive(),target:d,checks:Ne.shape.checks.optional(),counts:Ne.shape.counts.optional(),truncated:_(!0).optional()}).strict()}).strict(),g({kind:_(`process`),since:O,deadline:O,detail:g({pid:x().int(),note:y().optional()}).strict()}).strict(),g({kind:_(`plugin`),since:O,deadline:O.optional(),detail:g({pluginKind:y().min(1).max(64),summary:y().max(256)}).strict()}).strict(),g({kind:_(`timer`),since:O,deadline:O,detail:g({wakeAt:O,note:y().optional()}).strict()}).strict()]),Fe={runId:A,title:y(),status:ee,rung:b(ne),runner:f.optional(),model:y().optional(),currentStepId:y().optional(),startedAt:y().optional(),wait:Pe.optional(),tool:je.optional(),rate:v(k).length(30),error:y().max(200).optional()},Ie=g({...Fe,revision:k,collected:se()}).strict(),Le=g({...Fe,workers:v(Ie)}).strict(),Re=g({requestId:oe(),relationship:b([`family`,`peer`]),senderRunId:A,recipientRunId:A,text:y().max(500),senderTitle:y().optional(),recipientTitle:y().optional(),createdAt:O,deadline:O.optional()}).strict(),ze=g({requestId:oe(),senderRunId:A,recipientRunId:A,status:le.shape.status,observedAt:O}).strict(),Be=g({generatedAt:O,projects:v(g({projectId:y(),name:y(),loaded:se(),unavailable:g({status:ae([_(404),_(409),_(503)]),error:y()}).strict().optional(),inReview:k,tasks:v(Le),requests:v(Re),closed:v(ze)}).strict())}).strict();g({project:ae([_(`default`),y().regex(m)]).optional()});var Ve=5e3,He=e=>[`workspace`,`activity`,e.kind===`project`?e.projectId:null],Ue=e=>e.kind===`project`?`activity:project:${e.projectId}`:`activity:workspace`,We=e=>e.kind===`project`?`/api/v1/workspace/activity?project=${encodeURIComponent(e.projectId)}`:`/api/v1/workspace/activity`,Ge=`the Squawk server answered /workspace/activity with an unexpected body`;function Ke(e){let t=Be.safeParse(e);if(!t.success)throw new a(200,Ge);return t.data}async function qe(e,t){let n=e.kind===`project`?{project:e.projectId}:{};return Ke(await u(await te.api.v1.workspace.activity.$get({query:n},l(t)),`/workspace/activity`))}function Je(e,t){return e!==void 0&&Date.parse(t.generatedAt)<Date.parse(e.generatedAt)?e:t}var Ye=new Date(0).toISOString();function Xe(e){return e!==void 0&&e!==Ye&&!Number.isNaN(Date.parse(e))}var Ze=new Set([404,409,503]);function Qe(e,t,n,r){let i=e?.projects.find(e=>e.projectId===t)?.name??t;return{generatedAt:e?.generatedAt??Ye,projects:[{projectId:t,name:i,loaded:!0,unavailable:{status:n,error:r},inReview:0,tasks:[],requests:[],closed:[]}]}}function $e(e,t){return new a(Number(/^HTTP (\d+)$/.exec(t)?.[1]??0),e&&typeof e==`object`&&typeof e.error==`string`?e.error:t)}var et=(e,t)=>e.kind===`project`&&Ze.has(t.status)?t.status:void 0;function tt(e){let t=e.kind===`project`?e.projectId:void 0,n=(0,E.useMemo)(()=>t===void 0?{kind:`workspace`}:{kind:`project`,projectId:t},[t]),r=(0,E.useMemo)(()=>He(n),[n]),o=p(),s=de({queryKey:r,queryFn:async({signal:e})=>{let t=o.getQueryData(r);try{return Je(t,await qe(n,{signal:e}))}catch(e){let r=e instanceof a?et(n,e):void 0;if(r===void 0||n.kind!==`project`)throw e;return Qe(t,n.projectId,r,e.message)}},staleTime:1/0});return(0,E.useEffect)(()=>{let e=!0,t=t=>{o.cancelQueries({queryKey:r,exact:!0}).then(()=>{if(!e)return;let i=et(n,t);if(i!==void 0&&n.kind===`project`){o.setQueryData(r,e=>Qe(e,n.projectId,i,t.message));return}let a=o.getQueryCache().find({queryKey:r,exact:!0});a?.setState({status:`error`,error:t,errorUpdatedAt:Date.now(),errorUpdateCount:a.state.errorUpdateCount+1,fetchStatus:`idle`})})},a=n=>{let i;try{i=Ke(n)}catch(e){t(e);return}o.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&o.setQueryData(r,e=>Je(e,i))})},s=pe(Ue(n),a),l=i(Ve),u,d=()=>{let e=c()===`finite`&&l!==!1;e&&!u?u=me({path:We(n),intervalMs:l},(e,n)=>{n===void 0?a(e):t($e(e,n))}):!e&&u&&(u(),u=void 0)};d();let f=re(d);return()=>{e=!1,f(),u?.(),s()}},[o,r,n]),s}var j=e=>String(e).padStart(2,`0`);function M(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t/60)%60,i=t%60;return n>0?`${n}:${j(r)}:${j(i)}`:`${r}:${j(i)}`}function nt(e){let t=Math.max(0,Math.floor(e/1e3));if(t<60)return`${t} s`;let n=Math.floor(t/60);return n<60?`${n} min`:`${Math.floor(n/60)} h ${j(n%60)} min`}function N(e,t){let n=e===void 0?NaN:Date.parse(e);return Number.isNaN(n)?0:t-n}var rt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`});function P(e){let t=Date.parse(e);return Number.isNaN(t)?e:rt.format(t)}function it(){return Intl.DateTimeFormat().resolvedOptions().timeZone}var at=new Set([`queued`,`running`,`waiting`]),ot={review:`In review`,failed:`Failed`,done:`Done`,cancelled:`Cancelled`},st={review:`review`,failed:`failed`,done:`done`,cancelled:`cancelled`},F=e=>at.has(e),I=(e,t,n=`${t}s`)=>`${e} ${e===1?t:n}`,L=e=>h(e.rung).tone,R=(e,t=`Deadline`)=>e?`${t} ${P(e)}`:void 0;function ct(e,t,n){return t.length===1&&t[0]!==void 0?`${e} ${n.titleOf(t[0])}`:`${e} ${I(t.length,`task`)}`}function lt(e,t){let n=e.tool,r={verb:`Doing`,tone:L(e),icon:`tool`},i=n?.endedAt!==void 0&&N(n.endedAt,t.now)>1e4;if(n===void 0)return{...r,main:`Thinking`,...e.startedAt?{since:e.startedAt}:{}};let a=`Last tool ${nt(N(n.endedAt??n.startedAt,t.now))} ago`;return i?{...r,main:`Thinking`,detail:a,since:n.endedAt??n.startedAt}:{...r,main:n.title,mono:!0,detail:a,since:n.startedAt}}function ut(e,t){let n={verb:`Needs you`,tone:L(e),icon:`user`,...t?{since:t.since}:{}};if(t?.detail.reason===`question`)return t.detail.question?{...n,main:t.detail.question,action:`answer`}:{...n,main:`Your turn`,action:`answer`};if(t?.detail.reason===`budget`){let e=t.detail.queuedMessages;return{...n,main:e?`Automatic wakes used up · ${I(e,`message`)} queued`:`Automatic wakes used up`,action:`open`}}return{...n,main:`Your turn`,action:`open`}}function dt(e){return{verb:`Needs you`,tone:L(e),icon:`user`,main:`Permission`,action:`open`}}function ft(e,t,n){let{owed:r,total:i,settled:a,replies:o,mode:s,recipientRunIds:c}=t.detail,l=i>0?a/i:0,u={tone:L(e),since:t.since};if(o){let e=c.length>0?ct(`From`,c,n):`Waiting for replies`;return{...u,verb:`Waiting for reply`,icon:`reply`,main:e,...z(`detail`,R(t.deadline,`Reply due`))}}let d=c.length>0?`${r} owed · ${a} settled`:s?`${pt[s]} of ${i} · ${a} settled`:`${r} owed`;return{...u,verb:`Waiting for workers`,icon:`workers`,main:d,bar:l,...z(`detail`,R(t.deadline))}}var pt={one:`One`,any:`Any`,all:`All`};function mt(e){let t=e.detail.counts;if(t===void 0)return`PR ${e.detail.number} checks`;let n=t.pass+t.fail+t.pending;return`PR ${e.detail.number} checks · ${t.pass} of ${n} passed`}var ht=[`fail`,`pending`,`pass`,`skipping`,`cancel`];function gt(e){let{counts:t,checks:n=[],truncated:r}=e.detail;if(!r||t===void 0)return;let i=e=>Math.max(0,t[e]-n.filter(t=>t.bucket===e).length),a=ht.reduce((e,t)=>e+i(t),0),o=ht.find(e=>i(e)>0);return a>0&&o?{count:a,bucket:o}:void 0}var _t=[[`pass`,`passed`],[`fail`,`failed`],[`pending`,`pending`],[`skipping`,`skipped`],[`cancel`,`cancelled`]];function vt(e){let{counts:t,checks:n}=e.detail,r=e=>t?t[e]:(n??[]).filter(t=>t.bucket===e).length,i=_t.filter(([e])=>r(e)>0).map(([e,t])=>`${r(e)} ${t}`),a=gt(e);return a&&i.push(`+${a.count} more not listed`),i.length>0?i.join(`, `):void 0}function yt(e,t){let n={tone:L(e),since:t.since,...z(`detail`,R(t.deadline))};if(t.detail.target!==`checks`)return{...n,verb:`Waiting for merge`,icon:`merge`,main:`PR ${t.detail.number}`};let r=t.detail.checks?[...t.detail.checks].sort((e,t)=>e.name.localeCompare(t.name)):void 0;return{...n,verb:`Waiting for CI`,icon:`ci`,main:mt(t),...z(`checks`,r),...z(`overflow`,gt(t)),...z(`checkSummary`,vt(t))}}function z(e,t){return t===void 0?{}:{[e]:t}}function bt(e,t,n){let r=L(e);switch(t.kind){case`workers`:return ft(e,t,n);case`peers`:return{verb:`Waiting for a peer`,tone:r,icon:`peer`,since:t.since,main:ct(`For`,t.detail.peerRunIds,n),detail:`Deadline ${P(t.deadline)}`};case`subagents`:return{verb:`Waiting for subagents`,tone:r,icon:`subagents`,since:t.since,main:I(t.detail.running,`native subagent`),detail:`Deadline ${P(t.deadline)}`};case`pr`:return yt(e,t);case`process`:return{verb:`Waiting for command`,tone:r,icon:`command`,since:t.since,main:t.detail.note??`Process ${t.detail.pid}`,detail:`Running ${M(N(t.since,n.now))} · deadline ${P(t.deadline)}`};case`plugin`:return{verb:`Waiting`,tone:r,icon:`timer`,since:t.since,main:t.detail.summary,...z(`detail`,R(t.deadline))};case`timer`:return{verb:`Waiting for timer`,tone:r,icon:`timer`,since:t.since,main:t.detail.note??`Timer`,detail:`Wakes ${P(t.detail.wakeAt)} · in ${M(-N(t.detail.wakeAt,n.now))}`};case`usage-limit`:return xt(e,t.detail.resumeAt,n);case`human`:return}}function xt(e,t,n){let r=Date.parse(t),i=Number.isNaN(r)?`Resumes ${t}`:`Resumes ${P(t)} · in ${M(r-n.now)}`;return{verb:`Paused`,tone:L(e),icon:`pause`,main:`Usage limit`,detail:i}}function St(e,t){let n=e.wait&&`since`in e.wait?e.wait.since:e.startedAt;return{verb:`Queued`,tone:L(e),icon:`queued`,main:`Waiting for a free slot`,...n?{since:n,detail:`Waiting ${nt(N(n,t.now))}`}:{}}}function B(e,t){return{verb:ot[e.status]??e.status,tone:L(e),icon:st[e.status]??`done`,main:t}}function Ct(e,t){return F(e.status)?wt(e,t):B(e,I(e.workers.filter(e=>F(e.status)).length,`live worker`))}function wt(e,t){let n=e.wait;switch(e.rung){case`running`:return lt(e,t);case`needs-permission`:return dt(e);case`needs-you`:return ut(e,n?.kind===`human`?n:void 0);case`usage-limit`:return n?.kind===`usage-limit`?xt(e,n.detail.resumeAt,t):{verb:`Paused`,tone:L(e),icon:`pause`,main:`Usage limit`};case`queued`:case`waiting-for-capacity`:return St(e,t);default:return(n&&bt(e,n,t))??St(e,t)}}function Tt(e,t,n){if(n!==void 0&&F(e.status))return{verb:`Asks parent`,tone:L(e),main:`“${n}”`,asks:!0};let r=Et(e,t);return{verb:r.verb,tone:r.tone,main:r.main,...r.mono?{mono:!0}:{}}}function Et(e,t){switch(e.status){case`done`:return B(e,e.collected?`Collected`:`Ready to collect`);case`review`:return B(e,`Waiting for the parent’s review`);case`failed`:case`cancelled`:return B(e,e.error??ot[e.status]??e.status);default:return wt({...e,workers:[]},t)}}function Dt(e){if(e.unavailable)return e.unavailable.error;if(!e.loaded)return`Not loaded in this cockpit`}function Ot(e){let t=new Map;for(let n of e.tasks){t.set(n.runId,{title:n.title,cardId:n.runId,role:`root`});for(let e of n.workers)t.set(e.runId,{title:e.title,cardId:n.runId,role:`worker`})}return t}function V(e,t,n){return e.get(t)?.title??n??`Unreadable task`}var kt=(e,t)=>V(e,t.senderRunId,t.senderTitle),H=(e,t)=>V(e,t.recipientRunId,t.recipientTitle),At=(e,t)=>`wait:${e}:${t}`;function jt(e){let t=[];for(let n of e){let e=n.wait;if(!(!F(n.status)||e?.kind!==`peers`))for(let r of new Set(e.detail.peerRunIds))r!==n.runId&&t.push({id:At(n.runId,r),waiterRunId:n.runId,peerRunId:r,since:e.since,deadline:e.deadline})}return t}function Mt(e,t){let n=new Set;for(let r of t)r.waiterRunId===e&&n.add(r.peerRunId),r.peerRunId===e&&n.add(r.waiterRunId);return n}function Nt(e,t){return t.filter(t=>t.waiterRunId===e)}function Pt(e,t,n,r=[]){let i=[];for(let r of t)r.senderRunId===e&&i.push(`Waiting for a reply from ${H(n,r)}`),r.recipientRunId===e&&i.push(`${kt(n,r)} waits for your reply`);for(let t of r)t.waiterRunId===e&&i.push(`Waiting for a message from ${V(n,t.peerRunId)}`),t.peerRunId===e&&i.push(`${V(n,t.waiterRunId)} waits for you to write`);return i}function Ft(e,t,n){return n.find(n=>n.relationship===`family`&&n.senderRunId===e&&n.recipientRunId===t)}function It(e,t){let n=-N(e,t);return n>=1e3?`reply due in ${M(n)}`:`reply overdue`}function Lt(e,t){return t.filter(t=>t.relationship===`peer`&&t.senderRunId===e)}function Rt(e,t){return e.relationship===`peer`?{kind:`Request`,relation:`Peer`}:{kind:`Question`,relation:zt[Bt(e,t)]}}var zt={worker:`Worker → parent`,parent:`Parent → worker`,unknown:`Family`};function Bt(e,t){let n=t.get(e.senderRunId)?.role;if(n)return n===`worker`?`worker`:`parent`;let r=t.get(e.recipientRunId)?.role;return r?r===`root`?`worker`:`parent`:`unknown`}var Vt=new Set([`queued`,`waiting-for-capacity`]);function Ht(e){if(F(e.status))return o(e.rung)?`needsYou`:e.rung===`running`?`working`:Vt.has(e.rung)?`queued`:`waiting`}function Ut(e){let t={needsYou:0,working:0,waiting:0,queued:0,activeWorkers:0,openRequests:0,inReview:0};for(let n of e){t.inReview+=n.inReview,t.openRequests+=n.requests.length;for(let e of n.tasks){let n=Ht(e);n&&(t[n]+=1),t.activeWorkers+=e.workers.filter(e=>F(e.status)).length}}return t}function Wt(e,t=()=>!1){let n=0,r=0;for(let i of e.workers)t(i.runId)||((i.status===`done`||i.status===`cancelled`)&&(n+=1),i.status===`failed`&&(n+=1,r+=1));return{finished:n,failed:r}}function Gt({finished:e,failed:t}){if(e!==0)return t>0?`✓ ${e} finished · ${t} failed`:`✓ ${e} worker${e===1?``:`s`} finished`}var U={flash:1300,cardEnter:700,cardLeave:500,workerEnter:700,workerHold:3e3,workerFold:500,comet:1100,replied:900,fade:800,bump:500,slide:450,check:800},W={flash:{},entering:{},leaving:{},workerEnter:{},workerHold:{},opening:{},closing:{},waitsClosing:{},comets:{},bumps:{},slides:{},checks:{}},Kt=(e,t)=>`${e}\n${t}`;function qt(e,t){let n=Kt(t,``);return new Set(Object.keys(e.checks).filter(e=>e.startsWith(n)).map(e=>e.slice(n.length)))}var Jt=class{key;changes=[];timers=[];constructor(e){this.key=e}timed(e,t,n,r){this.changes.push({field:e,id:t,value:{...n,key:this.key}}),this.timers.push({after:r,change:{field:e,id:t,ifKey:this.key}})}later(e,t,n,r){this.timers.push({after:r,change:{field:e,id:t,value:{...n,key:this.key},ifKey:this.key}})}drop(e,t){this.changes.push({field:e,id:t})}},Yt={done:`success`,review:`success`,failed:`danger`,cancelled:`neutral`};function Xt(e,t){let n=Yt[t.status]??`success`;if(t.status===`review`){e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.flash);return}e.timed(`workerHold`,t.runId,{tone:n,phase:`flash`},U.workerHold+U.workerFold),e.later(`workerHold`,t.runId,{tone:n,phase:`fold`},U.workerHold)}function Zt(e,t){e.drop(`closing`,t.requestId),e.timed(`opening`,t.requestId,{},U.fade),e.timed(`comets`,`${t.requestId}:open:${e.key}`,{requestId:t.requestId,reverse:!1,tone:t.relationship},U.comet)}function Qt(e,t,n,r){let i=n.requestId;if(e.drop(`opening`,i),!r){e.timed(`closing`,i,{projectId:t,request:n,replied:!1,phase:`fade`},U.fade);return}let a=U.comet+U.replied+U.fade;e.timed(`closing`,i,{projectId:t,request:n,replied:!0,phase:`reply`},a),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`replied`},U.comet),e.later(`closing`,i,{projectId:t,request:n,replied:!0,phase:`fade`},U.comet+U.replied),e.timed(`comets`,`${i}:reply:${e.key}`,{requestId:i,reverse:!0,tone:`success`},U.comet)}function $t(e,t){switch(t.kind){case`rung-changed`:return e.timed(`flash`,t.task.runId,{tone:h(t.task.rung).tone},U.flash);case`tool-started`:return e.timed(`slides`,t.runId,{},U.slide);case`worker-started`:return e.timed(`workerEnter`,t.worker.runId,{},U.workerEnter);case`worker-settled`:return Xt(e,t.worker);case`card-entered`:return e.drop(`leaving`,t.task.runId),e.timed(`entering`,t.task.runId,{},U.cardEnter);case`card-left`:return e.timed(`leaving`,t.task.runId,{projectId:t.projectId,task:t.task},U.cardLeave);case`check-passed`:return e.timed(`checks`,Kt(t.runId,t.name),{},U.check);case`request-opened`:return Zt(e,t.request);case`request-closed`:return Qt(e,t.projectId,t.request,t.status===`replied`);case`chip-changed`:return e.timed(`bumps`,t.chip,{},U.bump);case`wait-opened`:return e.drop(`waitsClosing`,t.wait.id),e.timed(`opening`,t.wait.id,{},U.fade);case`wait-closed`:return e.drop(`opening`,t.wait.id),e.timed(`waitsClosing`,t.wait.id,{projectId:t.projectId,wait:t.wait},U.fade)}}function en(e,t,n){let r=new Jt(t);if(!n)for(let t of e)$t(r,t);return{changes:r.changes,timers:r.timers}}function tn(e,t){let n=e[t.field];if(t.ifKey!==void 0&&n[t.id]?.key!==t.ifKey||t.value===void 0&&!(t.id in n))return e;let r={...n};return t.value===void 0?delete r[t.id]:r[t.id]=t.value,{...e,[t.field]:r}}function nn(e,t){return t.reduce(tn,e)}function rn(e,t,n){let r=new Set(t.map(e=>e.id));return Object.values(n.waitsClosing).filter(t=>t.projectId===e&&!r.has(t.wait.id)).map(e=>e.wait)}var an={success:`text-success`,pending:`text-signal-word-amber`,danger:`text-signal-word-red`,accent:`text-accent-text`,info:`text-info`,running:`text-status-running`,neutral:`text-muted-foreground`};function on({tone:e,className:t,children:n,...i}){return(0,D.jsx)(`span`,{...i,className:r(`bg-card-2`,{"text-success":e===`success`,"text-signal-word-amber":e===`pending`,"text-signal-word-red":e===`danger`,"text-accent-text":e===`accent`,"text-info":e===`info`,"text-status-running":e===`running`,"text-muted-foreground":e===`neutral`},t),children:n})}var sn={success:`border-success`,pending:`border-pending-strong`,danger:`border-danger`,accent:`border-accent-strong`,info:`border-info`,running:`border-status-running`,neutral:`border-soft-foreground`},cn={success:`bg-success`,pending:`bg-pending-strong`,danger:`bg-danger`,accent:`bg-accent-strong`,info:`bg-info`,running:`bg-status-running`,neutral:`bg-soft-foreground`},ln={tool:Ae,user:ke,workers:C,reply:ye,peer:Ee,subagents:C,ci:Te,merge:we,command:Oe,timer:Ce,pause:De,queued:_e,review:ve,failed:he,done:ge,cancelled:Se};function un(e,t){let n=h(e.rung),r=e.rung===`waiting-on-workers`&&(t===`worker`||e.wait?.kind===`peers`);return{tone:n.tone,shape:r?`ring`:n.shape,label:pn(e,t)??n.label}}var dn=(e,t,n)=>`${e} ${t} ${n}${t===1?``:`s`}`;function fn(e){return e?.kind===`workers`&&!e.detail.replies&&e.detail.owed>0}function pn(e,t){let n=e.wait;if(e.rung===`waiting-on-workers`){if(t===`worker`&&!fn(n))return`waiting on parent reply`;if(n?.kind===`peers`&&n.detail.peerRunIds.length>0)return dn(`waiting on`,n.detail.peerRunIds.length,`task`);if(n?.kind===`workers`&&n.detail.replies)return`waiting on replies`;if(n?.kind===`workers`&&n.detail.owed>0)return dn(`waiting on`,n.detail.owed,`worker`)}if(e.rung===`waiting-on-subagents`&&n?.kind===`subagents`&&n.detail.running>0)return dn(`waiting for`,n.detail.running,`subagent`)}function mn(e,t){if(F(e.status))return e.rung===`running`&&t===`filled`?`activity-pulse`:t===`filled`?void 0:`activity-breathe`}function G({run:e,role:t}){let{tone:n,shape:i,label:a}=un(e,t);return(0,D.jsx)(`span`,{"data-activity-anchor":e.runId,className:r(`inline-flex size-[12px] shrink-0 items-center justify-center`,mn(e,i)),children:(0,D.jsx)(T,{tone:n,shape:i,role:`img`,"aria-label":a})})}function hn({runId:e,requests:t,waits:n,index:r,link:i,pathOf:a,className:o,linkClassName:s}){let c=Lt(e,t),l=Nt(e,n);return c.length===0&&l.length===0?null:(0,D.jsxs)(`ul`,{"data-slot":`activity-peer-links`,className:o,children:[c.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.recipientRunId),className:s,children:[`→ `,H(r,e)]})},e.requestId)),l.map(e=>(0,D.jsx)(`li`,{children:(0,D.jsxs)(i,{to:a(e.peerRunId),className:s,children:[`⋯ waits on `,V(r,e.peerRunId)]})},e.id))]})}var gn={pass:`bg-success`,fail:`bg-danger`,pending:`bg-info`,skipping:`border border-soft-foreground`,cancel:`border border-soft-foreground`},_n=(e,t)=>t?`activity-check-pass`:e===`pending`?`activity-breathe-fast`:void 0;function vn({checks:e,overflow:t,passed:n}){return(0,D.jsxs)(`span`,{"data-slot":`activity-checks`,"aria-hidden":`true`,className:r(`col-start-2 mt-[5px] flex items-center`,e.length>40?`gap-px`:`gap-[3px]`),children:[e.map(e=>(0,D.jsx)(`i`,{"data-bucket":e.bucket,"data-passed":n.has(e.name)?`true`:void 0,title:e.name,className:r(`h-[5px] min-w-px flex-1 rounded-[2px]`,gn[e.bucket],_n(e.bucket,n.has(e.name)))},e.name)),t?(0,D.jsxs)(`span`,{"data-slot":`activity-checks-overflow`,"data-bucket":t.bucket,className:`ml-1 flex shrink-0 items-center gap-1 text-[10px] leading-none text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`i`,{className:r(`h-[5px] w-2 rounded-[2px]`,gn[t.bucket])}),`+`,t.count]}):null]})}function yn({value:e,ink:t}){return(0,D.jsx)(`span`,{"data-slot":`activity-bar`,"aria-hidden":`true`,className:`col-start-2 mt-[5px] block h-1 overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:r(`block h-full bg-current`,t),style:{width:`${Math.round(e*100)}%`}})})}var bn=new Set;function xn({box:e,now:t,dense:n,motion:i={}}){let a=ln[e.icon],o=an[e.tone];return(0,D.jsxs)(`div`,{"data-slot":`activity-now`,"data-verb":e.verb,className:`relative grid grid-cols-[16px_minmax(0,1fr)] gap-x-2 gap-y-px overflow-hidden rounded-lg bg-card-2 px-2.5 py-2`,children:[i.sweep?(0,D.jsx)(`span`,{"data-slot":`activity-sweep`,"aria-hidden":`true`,className:`activity-sweep`}):null,(0,D.jsx)(a,{"aria-hidden":`true`,className:r(`mt-px size-[15px]`,o)}),(0,D.jsxs)(on,{tone:e.tone,className:`flex gap-2 text-[11px] font-semibold tracking-[0.04em] uppercase`,children:[(0,D.jsx)(`span`,{"data-slot":`activity-verb`,children:e.verb}),e.since?(0,D.jsx)(`span`,{"data-slot":`activity-age`,className:`ml-auto font-medium tracking-normal text-muted-foreground normal-case tabular-nums`,children:M(N(e.since,t))}):null]}),(0,D.jsx)(`span`,{"data-slot":`activity-main`,className:r(`col-start-2 truncate text-[12.5px] text-foreground`,e.mono&&`font-mono text-[12px]`,i.slideKey!==void 0&&`activity-slide`),children:e.main},i.slideKey??`still`),e.checks?(0,D.jsx)(vn,{checks:e.checks,overflow:e.overflow,passed:i.passed??bn}):null,e.checkSummary?(0,D.jsx)(`span`,{"data-slot":`activity-checks-summary`,className:`sr-only`,children:e.checkSummary}):null,e.bar===void 0?null:(0,D.jsx)(yn,{value:e.bar,ink:o}),e.detail&&!n?(0,D.jsx)(`span`,{"data-slot":`activity-detail`,className:`col-start-2 text-[11.5px] text-muted-foreground tabular-nums`,children:e.detail}):null]})}function Sn({rate:e,className:t}){let n=e.reduce((e,t)=>e+t,0),i=Math.max(4,...e);return(0,D.jsxs)(`svg`,{"data-slot":`activity-heartbeat`,role:`img`,"aria-label":`${n} tool call${n===1?``:`s`} in the last ${e.length} s`,viewBox:`0 0 62 16`,className:r(`block h-4 w-[62px] shrink-0`,t),children:[(0,D.jsx)(`path`,{d:`M0 15.5h62`,className:`stroke-border`}),e.map((e,t)=>{if(e<=0)return null;let n=Math.max(1.5,e/i*14);return(0,D.jsx)(`rect`,{x:t*2.07,y:15-n,width:1.4,height:n,className:`fill-status-running`},t)})]})}var K=e=>`/tasks/${encodeURIComponent(e)}`;function Cn(e,t){return[e.runner,e.model,e.currentStepId?`step ${e.currentStepId}`:void 0,e.startedAt?nt(N(e.startedAt,t)):void 0].filter(e=>!!e).join(` · `)}function wn({texts:e}){return e.length===0?null:(0,D.jsx)(`ul`,{"data-slot":`activity-line-text`,className:`sr-only`,children:e.map((e,t)=>(0,D.jsx)(`li`,{children:e},t))})}function Tn({worker:e,parentId:t,requests:n,index:i,ctx:a,motion:o}){let s=Tt(e,a,Ft(e.runId,t,n)?.text),c=o.workerHold[e.runId];return(0,D.jsxs)(`li`,{"data-slot":`activity-worker`,"data-run":e.runId,"data-asks":s.asks?`true`:void 0,"data-hold":c?.phase,className:r(`relative grid grid-cols-[14px_minmax(0,1fr)] items-start gap-x-2 rounded-lg py-[5px] before:absolute before:top-[13px] before:-left-3.5 before:w-2.5 before:border-t before:border-border`,s.asks&&`-mx-1.5 bg-message-inbound-bg px-1.5`,e.runId in o.workerEnter&&`activity-row-enter`,c?.phase===`fold`&&`activity-row-fold`),children:[c?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:r(`activity-row-flash`,cn[c.tone])},c.key):null,(0,D.jsx)(`span`,{className:`mt-[3px]`,children:(0,D.jsx)(G,{run:e,role:`worker`})}),(0,D.jsxs)(`span`,{className:`min-w-0 truncate text-[12.5px] font-medium`,children:[(0,D.jsx)(w,{to:K(e.runId),className:`relative z-[1] hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`,children:e.title}),(0,D.jsx)(`span`,{className:`ml-1.5 text-[11px] font-normal text-muted-foreground`,children:[e.runner,e.model].filter(Boolean).join(` · `)})]}),(0,D.jsxs)(`span`,{"data-slot":`activity-worker-line`,className:`col-start-2 truncate text-[11.5px] text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`b`,{className:r(`font-semibold`,an[s.tone]),children:s.verb}),` · `,(0,D.jsx)(`span`,{className:r(s.mono&&`font-mono`),children:s.main})]}),(0,D.jsx)(wn,{texts:Pt(e.runId,n,i)})]})}function En({workers:e}){return(0,D.jsxs)(`div`,{"data-slot":`activity-worker-dots`,className:`mt-2 ml-[18px] flex flex-wrap items-center gap-1 text-[11px] text-muted-foreground`,children:[e.map(e=>(0,D.jsx)(G,{run:e,role:`worker`},e.runId)),(0,D.jsxs)(`span`,{className:`ml-1`,children:[e.length,` worker`,e.length===1?``:`s`]})]})}function Dn({task:e,requests:t,index:n,ctx:r,dense:i,motion:a}){let o=e=>e in a.workerHold,s=e.workers.filter(e=>F(e.status)||e.status===`review`||o(e.runId)),c=Gt(Wt(e,o));return(0,D.jsxs)(D.Fragment,{children:[s.length>0&&i?(0,D.jsx)(En,{workers:s}):null,s.length>0&&!i?(0,D.jsx)(`ul`,{"data-slot":`activity-workers`,className:`mt-2 ml-1 border-l border-border pl-3.5`,children:s.map(i=>(0,D.jsx)(Tn,{worker:i,parentId:e.runId,requests:t,index:n,ctx:r,motion:a},i.runId))}):null,c?(0,D.jsx)(`p`,{"data-slot":`activity-finished`,className:`mt-1.5 ml-[18px] text-[11px] text-muted-foreground`,children:c}):null]})}var On=`relative z-[1] text-[12px] text-message-peer-accent hover:underline focus-visible:outline-2 focus-visible:outline-ring max-md:inline-flex max-md:min-h-11 max-md:items-center`;function kn(e,t){return t?{onPointerEnter:()=>t(`pointer`,e),onPointerLeave:()=>t(`pointer`,void 0),onFocus:()=>t(`focus`,e),onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t(`focus`,void 0)}}:{}}function An(e,t,n){return n?`activity-card-leave`:e.runId in t.entering?`activity-card-enter`:void 0}function jn({task:e,motion:t,glow:n}){let i=t.flash[e.runId];return(0,D.jsxs)(D.Fragment,{children:[n?(0,D.jsx)(`span`,{"aria-hidden":`true`,className:`activity-glow`}):null,i?(0,D.jsx)(`span`,{"data-slot":`activity-flash`,"data-tone":i.tone,"aria-hidden":`true`,className:r(`activity-flash`,sn[i.tone])},i.key):null]})}var Mn=[];function Nn({task:e,requests:t,waits:n=Mn,index:i,ctx:a,dense:o,narrow:s,motion:c=W,ghost:l=!1,linked:u=!1,onHover:d}){let f=Ct(e,a),p=l?{"data-activity-ghost":e.runId,inert:!0,"aria-hidden":!0}:{"data-activity-card":e.runId},m={sweep:e.rung===`running`&&F(e.status),slideKey:c.slides[e.runId]?.key,passed:qt(c,e.runId)};return(0,D.jsxs)(`article`,{...p,"data-flip":e.runId,"data-rung":e.rung,"data-action":f.action,"data-linked":u&&!l?`true`:void 0,...l?{}:kn(e.runId,d),className:r(`relative min-w-0 rounded-xl border bg-card px-3.5 py-3`,f.action?`border-pending`:`border-border`,u&&!l&&`outline-2 outline-offset-2 outline-message-peer-accent`,An(e,c,l)),children:[(0,D.jsx)(jn,{task:e,motion:c,glow:f.action!==void 0&&!l}),(0,D.jsxs)(`header`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(G,{run:e,role:`root`}),(0,D.jsx)(`h3`,{className:`min-w-0 flex-1 truncate text-[13.5px] font-semibold`,children:(0,D.jsx)(w,{to:K(e.runId),className:`after:absolute after:inset-0 after:rounded-xl after:content-[''] focus-visible:outline-2 focus-visible:outline-ring`,children:e.title})}),(0,D.jsx)(Sn,{rate:e.rate})]}),(0,D.jsx)(`p`,{className:`mt-0.5 mb-2 ml-5 truncate text-[11.5px] text-muted-foreground`,children:Cn(e,a.now)}),(0,D.jsx)(wn,{texts:Pt(e.runId,t,i,n)}),(0,D.jsx)(xn,{box:f,now:a.now,dense:o,motion:m}),f.action?(0,D.jsx)(`div`,{className:`mt-2 flex gap-1.5`,children:(0,D.jsx)(be,{asChild:!0,size:`sm`,variant:f.action===`answer`?`primary`:`outline`,className:`relative z-[1] max-md:min-h-11`,children:(0,D.jsx)(w,{to:K(e.runId),children:f.action===`answer`?`Answer`:`Open task`})})}):null,s?(0,D.jsx)(hn,{runId:e.runId,requests:t,waits:n,index:i,link:w,pathOf:K,className:`mt-2 flex flex-col gap-1`,linkClassName:On}):null,(0,D.jsx)(Dn,{task:e,requests:t,index:i,ctx:a,dense:o,motion:c})]})}function Pn(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+96)/396))}function Fn(e,t){let n=e[0],r=1/0;for(let i of e){let e=i.reduce((e,n)=>e+t(n),0);e<r&&(n=i,r=e)}return n}function In(e,t,n,r=()=>1){let i=Math.max(1,Math.floor(n)),a=new Set(t),o=e?.length===i?e.map(e=>e.filter(e=>a.has(e))):Array.from({length:i},()=>[]),s=new Set(o.flat());for(let e of t)s.has(e)||(Fn(o,r).push(e),s.add(e));return o}function Ln(e,t){return e!==void 0&&e.length===t.length&&e.every((e,n)=>e.length===t[n]?.length&&e.every((e,r)=>e===t[n]?.[r]))}var Rn=(e,t)=>({x0:Math.min(e.x,t.x),y0:Math.min(e.y,t.y),x1:Math.max(e.x,t.x),y1:Math.max(e.y,t.y)});function zn(e,t,n=1){return t.some(t=>t.x+n<e.x1&&e.x0<t.x+t.w-n&&t.y+n<e.y1&&e.y0<t.y+t.h-n)}var q=(e,...t)=>e.filter(e=>!t.some(t=>Bn(e,t))),Bn=(e,t)=>e.x===t.x&&e.y===t.y&&e.w===t.w&&e.h===t.h,Vn=e=>Math.round(e*10)/10,J=e=>`${Vn(e.x)} ${Vn(e.y)}`;function Hn(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.x===n.x&&e.y===n.y)continue;let r=t[t.length-2];r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)&&t.pop(),t.push(n)}return t}function Un(e,t=8){let n=Hn(e),r=n[0];if(!r)return``;let i=`M${J(r)}`;for(let e=1;e<n.length;e++){let r=n[e],a=n[e-1],o=n[e+1];if(!o){i+=` L ${J(r)}`;continue}let s=Math.min(t,Math.hypot(r.x-a.x,r.y-a.y)/2,Math.hypot(o.x-r.x,o.y-r.y)/2),c=(e,t,n)=>{let r=Math.hypot(t.x-e.x,t.y-e.y)||1;return{x:e.x+(t.x-e.x)/r*n,y:e.y+(t.y-e.y)/r*n}};i+=` L ${J(c(r,a,s))} Q ${J(r)}, ${J(c(r,o,s))}`}return i}function Wn(e,t,n){let r=[];for(let i of[...e].sort((e,n)=>t(e)-t(n))){let e=r[r.length-1];e&&Math.abs(t(i)-e.from)<=2?e.to=Math.max(e.to,n(i)):r.push({from:t(i),to:n(i)})}return r}function Gn(e){return{rows:Wn(e,e=>e.y,e=>e.y+e.h).map(({from:e,to:t})=>({top:e,bottom:t})),cols:Wn(e,e=>e.x,e=>e.x+e.w).map(({from:e,to:t})=>({left:e,right:t}))}}var Y=(e,t,n)=>Math.max(0,e.findIndex(e=>Math.abs(t(e)-n)<=2)),X=(e,t)=>((e.rows[t]?.bottom??0)+(e.rows[t+1]?.top??(e.rows[t]?.bottom??0)+16))/2;function Kn(e,t,n){let r=e.cols,i=e=>((r[e]?.right??0)+(r[e+1]?.left??0))/2;return t<n?i(t):t>n?i(t-1):t+1<r.length?i(t):t>0?i(t-1):(r[t]?.right??0)+8}function qn(e,t,n,r=0){let i=Gn(n),a=Y(i.rows,e=>e.top,e.y),o=Y(i.rows,e=>e.top,t.y),s=o>a,c=e.x+e.w/2+r,l=t.x+t.w/2+r,u=(s?X(i,a):X(i,a-1))+r/2,d=(s?X(i,o-1):X(i,o))+r/2,f=Kn(i,Y(i.cols,e=>e.left,e.x),Y(i.cols,e=>e.left,t.x))+r/2,p={x:c,y:s?e.y+e.h+1:e.y-1},m={x:l,y:s?t.y-3:t.y+t.h+3};return{points:[p,{x:c,y:u},{x:f,y:u},{x:f,y:d},{x:l,y:d},m],label:{x:(c+f)/2,y:u}}}var Jn=15;function Yn(e,t,n){let r=[...n,...e.flatMap(e=>[e.y-Jn,e.y+e.h+Jn])].filter(t=>t>=0&&!e.some(e=>e.y-6<t&&t<e.y+e.h+6));return r.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e,r[0]??t)}function Xn(e,t,n,r,i=0){let a=t.x>e.x?1:-1,o=e.x+a*n/2+i,s=t.x-a*n/2+i,c=Yn(r.filter(e=>e.x+e.w>Math.min(o,s)&&e.x<Math.max(o,s)),(e.y+t.y)/2,[e.y,t.y])+(i===0?0:Math.sign(i)*Math.min(Math.abs(i),Jn-6)),l=c===e.y?{x:s,y:(c+t.y)/2}:{x:o,y:(e.y+c)/2};return{points:[e,{x:o,y:e.y},{x:o,y:c},{x:s,y:c},{x:s,y:t.y},{x:t.x-a*2,y:t.y}],label:l}}function Zn(e){let t=new Map;for(let n of e){let e=[n.senderRunId,n.recipientRunId].sort().join(`
2
2
  `);t.set(e,[...t.get(e)??[],n.requestId])}let n=new Map;for(let e of t.values())e.forEach((t,r)=>n.set(t,(r-(e.length-1)/2)*12));return n}function Qn(e,t,n,r=4){let i=[],a=new Map;for(let{id:o,at:s}of e){let e={...s};for(let a=0;a<=i.length;a++){let a=i.find(n=>Math.abs(e.x-n.x)<t.w+r&&Math.abs(e.y-n.y)<t.h+r);if(!a)break;n===`x`?e.x=a.x+t.w+r:e.y=a.y+t.h+r}i.push(e),a.set(o,e)}return a}var $n=e=>Math.round(e*10)/10,Z=e=>`${$n(e.x)} ${$n(e.y)}`;function er(e,t,n){return t&&t.x>e.x+40?1:t&&t.x<e.x-40?-1:e.x+e.w+96<=n+1?1:-1}function tr(e,t,n,r,i,a){let o=r>0?Math.max(e.x+e.w,t.x+t.w):Math.min(e.x,t.x),s=(70+n)*r;return{d:`M${Z({x:o,y:i})} C ${Z({x:o+s,y:i})}, ${Z({x:o+s,y:a})}, ${Z({x:o+2*r,y:a})}`,label:{x:o+s*.75,y:(i+a)/2}}}function nr(e,t,n=[],r=0,i=1){let a=e.y+22+r,o=t.y+22+r;if(Math.abs(e.x-t.x)<40)return tr(e,t,r,i,a,o);let s=t.x>e.x,c=s?e.x+e.w:e.x,l=s?t.x:t.x+t.w,u=Math.max(40,Math.abs(l-c)*.5)*(s?1:-1),d=l-(s?2:-2);if(zn(Rn({x:c,y:a},{x:l,y:o}),q(n,e,t))){let i=Xn({x:c,y:a},{x:l,y:o},96,q(n,e,t),r);return{d:Un(i.points),label:i.label}}return{d:`M${Z({x:c,y:a})} C ${Z({x:c+u,y:a})}, ${Z({x:l-u,y:o})}, ${Z({x:d,y:o})}`,label:{x:(c+l)/2,y:(a+o)/2}}}function rr(e,{other:t,view:n,labelHeight:r}){let i=r/2+4,a=!t||!n?e+44:t.y>e?Math.max(e+44,n.y1-i):Math.min(e-44,n.y0+i);return n?ir(a,n.y0+i,n.y1-i):a}var ir=(e,t,n)=>Math.max(t,Math.min(n,e));function ar(e,t,n){let r=n.lane??0,i=e.y+22+r,a=n.side>0?e.x+e.w:e.x,o=a+n.side*96/2+r/2,s={x:o,y:rr(i,n)};return{d:Un(t===`sender`?[{x:a,y:i},{x:o,y:i},s]:[s,{x:o,y:i},{x:a+2*n.side,y:i}]),label:s}}function or(e,t,n,r=0){let i={x:e.x,y:e.y+e.h/2},a={x:t.x-2,y:t.y+t.h/2},o=n.x-18+r/2;return{d:`M${Z(i)} C ${Z({x:o,y:i.y})}, ${Z({x:o,y:a.y})}, ${Z(a)}`,label:{x:o,y:(i.y+a.y)/2}}}function sr(e,t,n=[],r=0){let i=e.x+e.w/2+r,a=t.x+t.w/2+r;if(t.y>=e.y+e.h||t.y+t.h<=e.y){let o=t.y>e.y,s=o?e.y+e.h+1:e.y-1,c=o?t.y-3:t.y+t.h+3,l=(c-s)/2;if(zn(Rn({x:i,y:s},{x:a,y:c}),q(n,e,t))){let i=qn(e,t,n,r);return{d:Un(i.points),label:i.label}}return{d:`M${Z({x:i,y:s})} C ${Z({x:i,y:s+l})}, ${Z({x:a,y:c-l})}, ${Z({x:a,y:c})}`,label:{x:(i+a)/2,y:(s+c)/2}}}let o=e.y-1,s=t.y-1,c=Math.min(o,s),l=Math.max(8,Math.min(30,18+Math.abs(a-i)*.05)+r);return{d:`M${Z({x:i,y:o})} C ${Z({x:i,y:c-l})}, ${Z({x:a,y:c-l})}, ${Z({x:a,y:s-3})}`,label:{x:(i+a)/2,y:c-l*.75}}}function cr(e,t){return{x:e.left-t.left,y:e.top-t.top,w:e.width,h:e.height}}function lr(e,t){let n=[];for(let r of e){let e=n.find(e=>Math.abs((e[0]?.at.x??NaN)-r.at.x)<t);e?e.push(r):n.push([r])}return n}function ur(e,t,n,r){let i=e.map(e=>Math.min(r,Math.max(n,e.at.y))),a=i.map((e,t)=>t).sort((e,t)=>i[e]-i[t]);for(let e=1;e<a.length;e++){let n=a[e];i[n]=Math.max(i[n],i[a[e-1]]+t)}for(let e=a.length-1;e>=0;e--){let n=a[e],o=e+1<a.length?i[a[e+1]]-t:r;i[n]=Math.min(i[n],o)}return e.map((e,t)=>({id:e.id,at:{x:e.at.x,y:i[t]}}))}function dr(e,t,n,r=4){let i=n?n.y0+t.h/2:-1/0,a=n?n.y1-t.h/2:1/0,o=new Map;for(let n of lr(e,t.w+r))for(let e of ur(n,t.h+r,i,a))o.set(e.id,e.at);return o}var fr=(e,t)=>e.x<=t.x1&&t.x0<=e.x+e.w&&e.y<=t.y1&&t.y0<=e.y+e.h;function pr(e,t,n){let r=e!==void 0&&fr(e,n),i=t!==void 0&&fr(t,n);return r&&i?`both`:r?`sender`:i?`recipient`:`none`}var mr=e=>/(auto|scroll|hidden|clip)/.test(getComputedStyle(e).overflowY);function hr(e){let t=[];for(let n=e.parentElement;n&&n!==document.body&&n!==document.documentElement;n=n.parentElement)mr(n)&&t.push(n);return t}function gr(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}function _r(e){let t=e.getBoundingClientRect(),n={x0:0,y0:0,x1:window.innerWidth,y1:window.innerHeight};for(let t of hr(e)){let e=t.getBoundingClientRect();e.width>0&&e.height>0&&(n=gr(n,{x0:e.left,y0:e.top,x1:e.right,y1:e.bottom}))}return{x0:n.x0-t.left,y0:n.y0-t.top,x1:n.x1-t.left,y1:n.y1-t.top}}var Q={w:88,h:40};function vr(e,t){let n=e.getBoundingClientRect(),r=new Map;for(let i of e.querySelectorAll(`[${t}]`)){let e=i.getAttribute(t);e&&r.set(e,cr(i.getBoundingClientRect(),n))}return r}function yr({base:e,from:t,to:n,fromName:r,toName:i},a,o,s){let c=a.get(t),l=a.get(n),u=s.view??{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0},d=(e,t)=>({side:er(e,t,s.width),labelHeight:Q.h,lane:o??0,view:u,...t?{other:t}:{}});switch(pr(c,l,u)){case`both`:return c&&l?{...e,...nr(c,l,[...a.values()],o,er(c,void 0,s.width))}:void 0;case`sender`:return c?{...e,...ar(c,`sender`,d(c,l)),away:i()}:void 0;case`recipient`:return l?{...e,...ar(l,`recipient`,d(l,c)),away:r()}:void 0;case`none`:return}}var br=(e,t)=>({base:{id:e.requestId,kind:`peer`},from:e.senderRunId,to:e.recipientRunId,fromName:()=>kt(t,e),toName:()=>H(t,e)}),xr=(e,t)=>({base:{id:e.id,kind:`wait`},from:e.peerRunId,to:e.waiterRunId,fromName:()=>V(t,e.peerRunId),toName:()=>V(t,e.waiterRunId)}),Sr=e=>({requestId:e.id,senderRunId:e.peerRunId,recipientRunId:e.waiterRunId});function Cr(e,t){return[...new Set([...e.values()].map(e=>Math.round(e.x+e.w)))].filter(e=>e+96<=t+1).map(e=>e+96/2)}function wr(e,t){return t.length===0?e:{x:t.reduce((t,n)=>Math.abs(n-e.x)<Math.abs(t-e.x)?n:t),y:e.y}}function Tr(e,t,n,r,i,a){let o=r.get(e.senderRunId)?.cardId??r.get(e.recipientRunId)?.cardId,s=o===void 0?void 0:t.get(o),c=n.get(e.senderRunId),l=n.get(e.recipientRunId);if(!(!s||!c||!l||a&&!fr(s,a)))return{id:e.requestId,kind:`family`,...or(c,l,s,i)}}function Er(e,t,n,{peers:r,frame:i={width:e.clientWidth},waits:a=[]}){let o=vr(e,`data-activity-card`),s=vr(e,`data-activity-anchor`),c=Zn([...t,...a.map(Sr)]),l=[];for(let e of t){let t=c.get(e.requestId),a=e.relationship===`peer`?r?yr(br(e,n),o,t,i):void 0:Tr(e,o,s,n,t,i.view);a&&l.push(a)}for(let e of r?a:[]){let t=yr(xr(e,n),o,c.get(e.id),i);t&&l.push(t)}let u=Cr(o,i.width),d=dr(l.filter(e=>e.kind!==`family`).map(e=>({id:e.id,at:wr(e.label,u)})),Q,i.view);return l.map(e=>({...e,label:d.get(e.id)??e.label}))}function Dr(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!==void 0&&e.id===r.id&&e.d===r.d&&e.away===r.away&&e.label.x===r.label.x&&e.label.y===r.label.y})}function Or({frame:e,cancel:t,draw:n}){let r=[],i,a=t=>{i=void 0,r=r.map(e=>({...e,start:e.start??t})).filter(e=>t<e.start+e.duration),n(r,t),r.length>0&&(i=e(a))};return{launch(t){r.some(e=>e.id===t.id)||(r.push(t),i===void 0&&(i=e(a)))},stop(){i!==void 0&&t(i),i=void 0,r=[],n([],0)},running:()=>i!==void 0}}var kr=e=>e<.5?2*e*e:1-(-2*e+2)**2/2;function Ar(e,t,n=0){let r=Math.min(1,Math.max(0,(t-e.start)/e.duration)),i=Math.max(0,kr(r)-n);return e.reverse?1-i:i}var jr=`http://www.w3.org/2000/svg`,Mr=[0,.03,.06,.09,.12],Nr=[4.5,3.5,3,2.5,2],Pr={peer:`fill-message-peer-accent`,family:`fill-message-inbound-accent`,success:`fill-success`};function Fr(e,t){let n=e.querySelector(`g[data-comet="${CSS.escape(t.id)}"]`);if(n)return n;let r=document.createElementNS(jr,`g`);r.setAttribute(`data-comet`,t.id);let i=document.createElementNS(jr,`circle`);return i.setAttribute(`r`,`9`),i.setAttribute(`class`,`${Pr[t.tone]} opacity-35`),r.append(i),Mr.forEach((e,n)=>{let i=document.createElementNS(jr,`circle`);i.setAttribute(`r`,String(Nr[n])),i.setAttribute(`class`,n===0?`fill-foreground`:Pr[t.tone]),i.setAttribute(`opacity`,String(1-n*.15)),r.append(i)}),e.append(r),r}function Ir(e,t,n){let r=new Set(t.map(e=>e.id));for(let t of e.querySelectorAll(`g[data-comet]`))r.has(t.getAttribute(`data-comet`)??``)||t.remove();let i=e.ownerSVGElement;for(let r of t){let t=i?.querySelector(`path[data-request="${CSS.escape(r.requestId)}"]`);if(!t||typeof t.getTotalLength!=`function`)continue;let a=t.getTotalLength();Fr(e,r).querySelectorAll(`circle`).forEach((e,i)=>{let o=t.getPointAtLength(Ar(r,n,Mr[Math.max(0,i-1)])*a);e.setAttribute(`transform`,`translate(${o.x} ${o.y})`)})}}var Lr=e=>typeof requestAnimationFrame==`function`?requestAnimationFrame(e):setTimeout(()=>e(performance.now()),16),Rr=e=>typeof cancelAnimationFrame==`function`?cancelAnimationFrame(e):clearTimeout(e);function zr(e,t,n){let r=E.useRef(null),i=E.useRef(void 0),a=E.useRef(new Set);return E.useEffect(()=>{let e=r.current;if(!e)return;let t=Or({frame:Lr,cancel:Rr,draw:(t,n)=>Ir(e,t,n)});return i.current=t,()=>{t.stop(),i.current=void 0}},[]),E.useEffect(()=>{if(n){i.current?.stop();return}for(let t of a.current)t in e||a.current.delete(t);for(let[n,r]of Object.entries(e))a.current.has(n)||!t.has(r.requestId)||(a.current.add(n),i.current?.launch({id:n,requestId:r.requestId,reverse:r.reverse,tone:r.tone,duration:U.comet}))},[e,t,n]),r}function Br(e,t){let n=new Map;for(let[r,i]of t){let t=e.get(r);if(!t)continue;let a={x:t.x-i.x,y:t.y-i.y};(Math.abs(a.x)>=1||Math.abs(a.y)>=1)&&n.set(r,a)}return n}function Vr(e,t){let n=new Map;for(let r of e.querySelectorAll(`[${t}]`)){let e=r.getBoundingClientRect();n.set(r.getAttribute(t)??``,{el:r,at:{x:e.left,y:e.top}})}return n}var Hr=`activity-layout-settled`;function Ur(e,t,n,r){let i=E.useRef(void 0),a=E.useRef(new Set);E.useLayoutEffect(()=>{let o=e.current;if(!o)return;let s=Vr(o,t),c=new Map([...s].map(([e,t])=>[e,t.at])),l=i.current;if(i.current={key:n,at:c},!(!r||!l||l.key===n))for(let[e,t]of Br(l.at,c)){let n=s.get(e)?.el.animate?.([{transform:`translate(${t.x}px, ${t.y}px)`},{transform:`none`}],{duration:400,easing:`cubic-bezier(0.2, 0, 0, 1)`});n&&Wr(n,a.current,o)}}),E.useEffect(()=>{if(!r)for(let e of[...a.current])e.cancel()},[r])}function Wr(e,t,n){t.add(e);let r=()=>{t.delete(e)&&t.size===0&&n.dispatchEvent(new Event(Hr))};e.addEventListener(`finish`,r),e.addEventListener(`cancel`,r)}function Gr(e,t,n,r,i,a=!1){let[o,s]=E.useState([]);return E.useLayoutEffect(()=>{let i=e.current?.parentElement;if(!i)return;let o=()=>{let e=t(i);s(t=>n(t,e)?t:e)};o();let c=a?Kr(i,o):void 0;i.addEventListener(Hr,o);let l=typeof ResizeObserver>`u`?void 0:new ResizeObserver(o);l?.observe(i);for(let e of i.querySelectorAll(r))l?.observe(e);return()=>{l?.disconnect(),i.removeEventListener(Hr,o),c?.()}},[e,t,n,r,i,a]),o}function Kr(e,t){let n,r=()=>{n===void 0&&(n=requestAnimationFrame(()=>{n=void 0,t()}))},i=[...hr(e),window];for(let e of i)e.addEventListener(`scroll`,r,{passive:!0});return window.addEventListener(`resize`,r),()=>{for(let e of i)e.removeEventListener(`scroll`,r);window.removeEventListener(`resize`,r),n!==void 0&&cancelAnimationFrame(n)}}var qr=28;function Jr(e){let t=e.replace(/\s+/g,` `).trim();return t.length>qr?`${t.slice(0,qr-1).trimEnd()}…`:t}function Yr(e,t){if(e.deadline!==void 0)return Xr(e.createdAt,e.deadline,t)}function Xr(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isNaN(r)||Number.isNaN(i)||i<=r?1:Math.min(1,Math.max(0,(n-r)/(i-r)))}function Zr(e,t){if(e===`fade`)return`activity-line-out`;if(e!==`replied`)return r(`activity-march`,t&&`activity-line-in`)}function Qr(e,t){return t in e.waitsClosing?`activity-line-out`:r(`activity-drift`,t in e.opening&&`activity-line-in`)}var $r=`pointer-events-none absolute z-[4] -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-background px-1.5 py-[3px] text-[10px] leading-[1.3] text-foreground tabular-nums`;function ei({line:e,wait:t,now:n,motion:i}){return(0,D.jsxs)(`div`,{"data-slot":`activity-line-label`,"data-wait":t.id,"aria-hidden":`true`,style:{left:e.label.x,top:e.label.y,width:Q.w},className:r($r,`border-dashed border-message-peer-accent`,t.id in i.waitsClosing&&`activity-line-out`),children:[(0,D.jsxs)(`span`,{className:`flex gap-1 font-semibold`,children:[(0,D.jsx)(`span`,{className:`min-w-0 truncate text-message-peer-accent`,children:`Waiting`}),(0,D.jsx)(`span`,{className:`ml-auto shrink-0`,children:M(N(t.since,n))})]}),e.away?(0,D.jsx)(`span`,{className:`block truncate`,children:e.away}):null,(0,D.jsx)(`span`,{"data-slot":`activity-wait-bar`,className:`mt-[3px] block h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:`block h-full bg-message-peer-accent opacity-70`,style:{width:`${Math.round(Xr(t.since,t.deadline,n)*100)}%`}})})]})}function ti({line:e,request:t,now:n,phase:i,replied:a}){let o=Yr(t,n);return(0,D.jsxs)(`div`,{"data-slot":`activity-line-label`,"data-request":t.requestId,"data-phase":i,"aria-hidden":`true`,style:{left:e.label.x,top:e.label.y,width:Q.w},className:r($r,a?`border-success`:`border-message-peer-accent`,i===`fade`&&`activity-line-out`),children:[(0,D.jsxs)(`span`,{className:`flex gap-1 font-semibold`,children:[a?(0,D.jsx)(`span`,{className:`text-success`,children:`Replied`}):(0,D.jsx)(`span`,{className:`min-w-0 truncate text-message-peer-accent`,children:`Request`}),(0,D.jsx)(`span`,{className:`ml-auto shrink-0`,children:M(N(t.createdAt,n))})]}),(0,D.jsx)(`span`,{className:`block truncate`,children:e.away??Jr(t.text)}),o===void 0||a?null:(0,D.jsx)(`span`,{className:`mt-[3px] block h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,D.jsx)(`span`,{className:`block h-full bg-message-peer-accent`,style:{width:`${Math.round(o*100)}%`}})})]})}var ni=(e,t)=>e.closing[t]?.phase??`open`;function ri(e,t){let n=e.closing[t];return n!==void 0&&n.replied&&n.phase!==`reply`}var ii=new Set;function ai({line:e,motion:t}){let n=ni(t,e.id);return(0,D.jsx)(`path`,{"data-request":e.id,"data-kind":e.kind,"data-phase":n,d:e.d,fill:`none`,strokeDasharray:n===`replied`?void 0:`6 5`,strokeWidth:e.kind===`peer`?2.2:1.8,markerEnd:`url(#activity-arrow-${e.kind})`,className:r(e.kind===`peer`?`stroke-message-peer-accent`:`stroke-message-inbound-accent`,Zr(n,e.id in t.opening))})}function oi({line:e,motion:t,active:n}){return(0,D.jsx)(`path`,{"data-wait":e.id,"data-kind":`wait`,"data-active":n?`true`:void 0,d:e.d,fill:`none`,strokeDasharray:`0 8`,strokeLinecap:`round`,strokeWidth:n?3.2:2.4,markerEnd:`url(#activity-ring-wait)`,className:r(`stroke-message-peer-accent`,n?`opacity-100`:`opacity-80`,Qr(t,e.id))})}function si({id:e}){return(0,D.jsx)(`marker`,{id:e,viewBox:`0 0 12 12`,refX:`10`,refY:`6`,markerWidth:`5`,markerHeight:`5`,markerUnits:`strokeWidth`,orient:`auto`,children:(0,D.jsx)(`circle`,{cx:`6`,cy:`6`,r:`4`,strokeWidth:`2.4`,className:`fill-background stroke-message-peer-accent`})})}var ci=[];function li({requests:e,waits:t=ci,active:n=ii,index:r,peers:i,layoutKey:a,now:o,motion:s=W,paused:c=!1}){let l=E.useRef(null),u=Gr(l,E.useCallback(n=>Er(n,e,r,{peers:i,waits:t,frame:{width:n.clientWidth,view:_r(n)}}),[e,t,r,i]),Dr,`[data-activity-card]`,a,!0),d=E.useMemo(()=>new Set(u.map(e=>e.id)),[u]),f=zr(s.comets,d,c),p=new Map(e.map(e=>[e.requestId,e])),m=new Map(t.map(e=>[e.id,e]));return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`svg`,{ref:l,"data-slot":`activity-lines`,"aria-hidden":`true`,className:`pointer-events-none absolute inset-0 z-[3] size-full overflow-visible`,children:[(0,D.jsxs)(`defs`,{children:[(0,D.jsx)(`marker`,{id:`activity-arrow-peer`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0 0 10 5 0 10z`,className:`fill-message-peer-accent`})}),(0,D.jsx)(`marker`,{id:`activity-arrow-family`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`6`,markerHeight:`6`,orient:`auto`,children:(0,D.jsx)(`path`,{d:`M0 0 10 5 0 10z`,className:`fill-message-inbound-accent`})}),(0,D.jsx)(si,{id:`activity-ring-wait`})]}),u.map(e=>e.kind===`wait`?(0,D.jsx)(oi,{line:e,motion:s,active:n.has(e.id)},e.id):(0,D.jsx)(ai,{line:e,motion:s},e.id)),(0,D.jsx)(`g`,{ref:f,"data-slot":`activity-comets`})]}),u.map(e=>{let t=e.kind===`wait`?m.get(e.id):void 0;if(t)return(0,D.jsx)(ei,{line:e,wait:t,now:o,motion:s},e.id);let n=p.get(e.id);return e.kind===`peer`&&n?(0,D.jsx)(ti,{line:e,request:n,now:o,phase:ni(s,e.id),replied:ri(s,e.id)},e.id):null})]})}function ui(e,t){let n=new Map;for(let r of[...e?.projects??[],...t.projects])for(let[e,t]of Ot(r))n.set(e,t);return n}var di={"timed-out":`timed out`,cancelled:`was cancelled`,destroyed:`closed: the recipient was destroyed`,failed:`closed: the recipient failed`,"completed-without-reply":`closed without a reply`,"sender-closed":`was closed by its sender`,"human-fallback":`went to a human`,deleted:`closed: the recipient was deleted`};function fi(e,t,n){let r=n(e.senderRunId,e.senderTitle),i=n(e.recipientRunId,e.recipientTitle);return t===`replied`?`${i} replied to ${r}`:`${r}’s request to ${i} ${di[t??``]??`closed`}`}var pi={done:{tone:`success`,word:`finished`},failed:{tone:`danger`,word:`failed`},cancelled:{tone:`neutral`,word:`was cancelled`},review:{tone:`info`,word:`waits for review`}},mi=e=>e.relationship===`peer`?`peer`:`family`;function hi(e,t,n){let r=(e,n)=>V(t,e,n);switch(e.kind){case`request-opened`:return{tone:mi(e.request),text:`${r(e.request.senderRunId,e.request.senderTitle)} asked ${r(e.request.recipientRunId,e.request.recipientTitle)}`};case`request-closed`:return{tone:e.status===`replied`?`success`:`neutral`,text:fi(e.request,e.status,r)};case`rung-changed`:return{tone:h(e.task.rung).tone,text:`${e.task.title}: ${Ct(e.task,{now:n,titleOf:e=>r(e)}).verb}`};case`worker-started`:return{tone:`running`,text:`${e.worker.title} started`};case`worker-settled`:{let t=pi[e.worker.status]??{tone:`neutral`,word:`settled`};return{tone:t.tone,text:`${e.worker.title} ${t.word}`}}case`card-entered`:return{tone:h(e.task.rung).tone,text:`${e.task.title} started`};case`card-left`:return{tone:`neutral`,text:`${e.task.title} left active work`};case`check-passed`:return{tone:`success`,text:`PR ${e.pr}: check “${e.name}” passed`};default:return}}function gi(e,t,n,r){return[...t.map((e,t)=>({...e,id:r+t,at:n})),...e].slice(0,6)}function _i(e){let t=Math.max(0,Math.floor(e/1e3));return t<5?`now`:t<60?`${t} s`:`${Math.floor(t/60)} min`}var vi=new Set;function yi(e){let[t,n]=E.useState({}),r=t.pointer??t.focus,i=E.useCallback((e,t)=>n(n=>n[e]===t?n:{...n,[e]:t}),[]);return{linked:E.useMemo(()=>r===void 0?vi:Mt(r,e),[r,e]),active:E.useMemo(()=>r===void 0?vi:new Set(e.filter(e=>e.waiterRunId===r||e.peerRunId===r).map(e=>e.id)),[r,e]),onHover:i}}var bi=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}),xi=`inline-flex items-center px-3 py-[5px] text-[12px] font-medium focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring max-md:min-h-11`;function Si({scope:e,projectId:t}){let n=e=>r(xi,e?`bg-card-2 text-foreground`:`text-muted-foreground hover:text-foreground`);return(0,D.jsxs)(`nav`,{"aria-label":`Activity scope`,"data-slot":`activity-scope`,className:`ml-auto inline-flex overflow-hidden rounded-lg border border-border`,children:[t===null?null:(0,D.jsx)(fe,{to:`/p/${encodeURIComponent(t)}/activity`,"aria-current":e===`project`?`page`:void 0,className:n(e===`project`),children:`This project`}),(0,D.jsx)(fe,{to:`/activity`,state:{activityProjectId:t},"aria-current":e===`all`?`page`:void 0,className:n(e===`all`),children:`All projects`})]})}function Ci({now:e,stale:t}){return(0,D.jsxs)(`span`,{"data-slot":`activity-clock`,"data-stale":t?`true`:void 0,className:`inline-flex items-center gap-1.5 text-[12px] text-muted-foreground tabular-nums`,children:[(0,D.jsx)(`span`,{"data-tone":`success`,className:r(`inline-flex size-[12px] items-center justify-center`,!t&&`activity-pulse`),children:(0,D.jsx)(T,{tone:t?`neutral`:`success`,"aria-hidden":`true`})}),(0,D.jsx)(`b`,{className:r(`font-semibold`,t?`text-muted-foreground`:`text-success`),children:t?`Not updating`:`Live`}),bi.format(e),` `,it()]})}function wi({name:e,now:t,stale:n=!1,children:r}){return(0,D.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[(0,D.jsxs)(`h1`,{className:`min-w-0 truncate text-[18px] font-semibold`,children:[`Activity `,(0,D.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[`· `,e]})]}),t===void 0?null:(0,D.jsx)(Ci,{now:t,stale:n}),r]})}function Ti({value:e,bump:t}){return(0,D.jsx)(`strong`,{"data-bump":t===void 0?void 0:`true`,className:r(`font-semibold text-foreground tabular-nums`,t!==void 0&&`activity-bump`),children:e},t??`still`)}function $({icon:e,count:t,label:n,bump:r}){return(0,D.jsxs)(`li`,{"data-slot":`activity-chip`,"data-chip":n,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground`,children:[e,(0,D.jsx)(Ti,{value:t,bump:r}),` `,n]})}function Ei({summary:e,tasksTo:t,bumps:n={}}){let r=e=>n[e]?.key;return(0,D.jsxs)(`ul`,{"data-slot":`activity-summary`,"aria-live":`polite`,"aria-label":`Summary`,className:`flex flex-wrap gap-2`,children:[(0,D.jsx)($,{icon:(0,D.jsx)(T,{tone:`pending`,"aria-hidden":`true`}),count:e.needsYou,label:`needs you`,bump:r(`needsYou`)}),(0,D.jsx)($,{icon:(0,D.jsx)(T,{tone:`running`,"aria-hidden":`true`}),count:e.working,label:`working`,bump:r(`working`)}),(0,D.jsx)($,{icon:(0,D.jsx)(T,{tone:`running`,shape:`ring`,"aria-hidden":`true`}),count:e.waiting,label:`waiting`,bump:r(`waiting`)}),(0,D.jsx)($,{icon:(0,D.jsx)(T,{tone:`neutral`,shape:`ring`,"aria-hidden":`true`}),count:e.queued,label:`queued`,bump:r(`queued`)}),(0,D.jsx)($,{icon:(0,D.jsx)(C,{"aria-hidden":`true`,className:`size-3.5`}),count:e.activeWorkers,label:`active workers`,bump:r(`activeWorkers`)}),(0,D.jsx)($,{icon:(0,D.jsx)(ye,{"aria-hidden":`true`,className:`size-3.5 text-message-peer-accent`}),count:e.openRequests,label:`open requests`,bump:r(`openRequests`)}),(0,D.jsx)(`li`,{"data-slot":`activity-chip`,"data-chip":`in review`,children:(0,D.jsxs)(w,{to:t,className:`inline-flex items-center gap-[7px] rounded-full border border-border bg-card px-[11px] py-[5px] text-[12px] text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11`,children:[(0,D.jsx)(T,{tone:`info`,"aria-hidden":`true`}),(0,D.jsx)(Ti,{value:e.inReview,bump:r(`inReview`)}),` in review`]})})]})}var Di=e=>new Map(e.map(e=>[e.runId,e])),Oi=e=>e!==void 0&&Dt(e)===void 0;function ki(e,t,n,r){let i=Di(t.workers);for(let t of n.workers){let a=i.get(t.runId);!a&&F(t.status)&&r({kind:`worker-started`,projectId:e,parentId:n.runId,worker:t}),a&&F(a.status)&&!F(t.status)&&r({kind:`worker-settled`,projectId:e,parentId:n.runId,worker:t})}}function Ai(e,t,n,r){if(t.wait?.kind!==`pr`||n.wait?.kind!==`pr`||t.wait.detail.number!==n.wait.detail.number)return;let i=new Set((t.wait.detail.checks??[]).filter(e=>e.bucket===`pending`).map(e=>e.name));for(let t of n.wait.detail.checks??[])t.bucket===`pass`&&i.has(t.name)&&r({kind:`check-passed`,projectId:e,runId:n.runId,pr:n.wait.detail.number,name:t.name})}var ji=(e,t)=>t.tool!==void 0&&(t.tool.startedAt!==e.tool?.startedAt||t.tool.title!==e.tool?.title);function Mi(e,t,n,r){t.rung!==n.rung&&r({kind:`rung-changed`,projectId:e,task:n,from:t.rung}),ji(t,n)&&r({kind:`tool-started`,projectId:e,runId:n.runId}),ki(e,t,n,r),Ai(e,t,n,r)}function Ni(e,t,n){let r=Di(e.tasks),i=Di(t.tasks);for(let e of t.tasks){let i=r.get(e.runId);i?Mi(t.projectId,i,e,n):n({kind:`card-entered`,projectId:t.projectId,task:e})}for(let r of e.tasks)i.has(r.runId)||n({kind:`card-left`,projectId:t.projectId,task:r})}function Pi(e,t,n){let r=new Set(e.requests.map(e=>e.requestId)),i=new Set(t.requests.map(e=>e.requestId)),a=new Map(t.closed.map(e=>[e.requestId,e.status]));for(let e of t.requests)r.has(e.requestId)||n({kind:`request-opened`,projectId:t.projectId,request:e});for(let r of e.requests){if(i.has(r.requestId))continue;let e=a.get(r.requestId);n({kind:`request-closed`,projectId:t.projectId,request:r,...e?{status:e}:{}})}}function Fi(e,t,n){let r=jt(e.tasks),i=jt(t.tasks),a=new Set(r.map(e=>e.id)),o=new Set(i.map(e=>e.id));for(let e of i)a.has(e.id)||n({kind:`wait-opened`,projectId:t.projectId,wait:e});for(let e of r)o.has(e.id)||n({kind:`wait-closed`,projectId:t.projectId,wait:e})}var Ii=[`needsYou`,`working`,`waiting`,`queued`,`activeWorkers`,`openRequests`,`inReview`];function Li(e,t,n){let r=Ut(e),i=Ut(t);for(let e of Ii)r[e]!==i[e]&&n({kind:`chip-changed`,chip:e,from:r[e],to:i[e]})}function Ri(e,t){if(e===void 0)return[];let n=[],r=e=>n.push(e),i=new Map(e.projects.map(e=>[e.projectId,e]));for(let e of t.projects){let t=i.get(e.projectId);!Oi(t)||!Oi(e)||(Ni(t,e,r),Pi(t,e,r),Fi(t,e,r))}return Li(e.projects,t.projects,r),n}function zi(e){return{input:e,reconcile:!1,seq:0,motion:W,feed:[],epoch:0,...e.snapshot?{seen:e.snapshot}:{}}}function Bi(e){let{plan:t,...n}=e;return{...n,motion:W,epoch:e.epoch+1}}function Vi(e,t,n){let r=Ri(t,n);if(r.length===0)return e;let i=Date.parse(n.generatedAt),a=ui(t,n),o=r.flatMap(e=>hi(e,a,i)??[]),s=e.seq+o.length+1,c=en(r,s,e.input.reduced);return{...e,seq:s,feed:o.length>0?gi(e.feed,o,i,e.seq+1):e.feed,motion:nn(e.motion,c.changes),...c.timers.length>0?{plan:{key:s,timers:c.timers}}:{}}}function Hi(e,t){let n=e.seen;if(!t||t===n)return e;let r={...e,seen:t};return!n||!e.input.active?r:e.reconcile?{...r,reconcile:!1}:Vi(r,n,t)}function Ui(e,t){let n=e.input;if(t.scope!==n.scope)return{...zi(t),seq:e.seq,epoch:e.epoch+1};if(t.snapshot===n.snapshot&&t.active===n.active&&t.reduced===n.reduced)return e;let r={...e,input:t};return n.active&&!t.active&&(r={...Bi(r),reconcile:!0}),!n.reduced&&t.reduced&&(r=Bi(r)),Hi(r,t.snapshot)}var Wi=`(prefers-reduced-motion: reduce)`,Gi=()=>typeof window<`u`&&typeof window.matchMedia==`function`?window.matchMedia(Wi):void 0;function Ki(e){let t=Gi();return t?.addEventListener?.(`change`,e),()=>t?.removeEventListener?.(`change`,e)}function qi(){return Gi()?.matches??!1}function Ji(){return(0,E.useSyncExternalStore)(Ki,qi,()=>!1)}function Yi(e,t){let n=E.useRef(new Set);E.useEffect(()=>{let e=n.current;return()=>{for(let t of e)clearTimeout(t);e.clear()}},[e.epoch]),E.useEffect(()=>{for(let{after:r,change:i}of e.plan?.timers??[]){let e=setTimeout(()=>{n.current.delete(e),t(e=>({...e,motion:nn(e.motion,[i])}))},r);n.current.add(e)}},[e.plan?.key])}function Xi(e,t){let n=Ji(),r=s(),i={snapshot:e,scope:t,active:r,reduced:n},[a,o]=E.useState(()=>zi(i)),c=Ui(a,i);return c!==a&&o(c),Yi(c,o),{motion:c.motion,feed:c.feed,reduced:n,paused:!r}}function Zi(e,t){let n=xe(1e3),[r,i]=E.useState({offset:0}),a=r.offset;return Xe(e)&&e!==r.generatedAt&&t!==0&&(a=Date.parse(e)-t,i({generatedAt:e,offset:a})),n+a}export{Sn as A,jt as B,Pn as C,jn as D,Nn as E,W as F,kt as G,H,rn as I,Ct as J,Ut as K,Rt as L,G as M,cn as N,wn as O,on as P,tt as Q,Pt as R,Qn as S,Ln as T,It as U,Dt as V,Ot as W,M as X,P as Y,N as Z,zr as _,Ei as a,cr as b,li as c,ni as d,ri as f,Ur as g,Gr as h,Si as i,hn as j,kn as k,si as l,Yr as m,Xi as n,yi as o,Qr as p,F as q,wi as r,_i as s,Zi as t,Zr as u,Sr as v,In as w,Zn as x,sr as y,V as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{t as a}from"./arrow-right-Dh_Lx3um.js";import{A as o,B as s,C as c,E as l,F as u,G as d,H as f,I as p,K as m,L as h,N as g,Q as _,T as v,U as y,V as b,W as x,X as S,Y as C,Z as w,a as T,c as E,g as D,i as O,m as k,n as A,o as j,r as M,s as N,t as P,w as F,z as I}from"./activity-motion-Dl9i8LMp.js";import{t as L}from"./button-BQ2y4XRB.js";import{s as R}from"./project-router-CDPfL2Jz.js";import{t as z}from"./status-dot-DtAOFiIi.js";import{st as B}from"./index-BRgRv29I.js";var V=e(t(),1),H=n(),U=`rounded-xl border border-border bg-card px-3.5 py-3`,W=`mb-2 flex gap-2 text-[11.5px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`;function G({request:e,index:t,now:n,motion:r}){let{kind:o,relation:s}=h(e,t),c=k(e,n),l=e.relationship===`peer`?`text-message-peer-accent`:`text-message-inbound-accent`;return(0,H.jsxs)(`li`,{"data-slot":r===`fold`?`activity-request-closing`:`activity-request`,"data-request":e.requestId,"aria-hidden":r===`fold`||void 0,className:i(`border-t border-border py-2.5 first:border-t-0 first:pt-0`,r===`enter`&&`activity-row-enter`,r===`fold`&&`activity-row-fold`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[12px] font-medium`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:d(t,e)}),(0,H.jsx)(a,{"aria-label":`to`,className:`size-3 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:f(t,e)}),(0,H.jsx)(`span`,{className:i(`ml-auto shrink-0 text-[10px] font-semibold tracking-[0.05em] uppercase`,l),children:o})]}),(0,H.jsxs)(`p`,{className:`my-1 line-clamp-3 text-[12px] text-muted-foreground`,children:[`“`,e.text,`”`]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] text-muted-foreground tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[s,` · open `,S(w(e.createdAt,n))]}),e.deadline?(0,H.jsx)(`span`,{className:`ml-auto`,children:y(e.deadline,n)}):null]}),c===void 0?null:(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`mt-1.5 h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,H.jsx)(`span`,{className:i(`block h-full bg-current`,l),style:{width:`${Math.round(c*100)}%`}})})]})}function K({className:e}){return(0,H.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,H.jsx)(`path`,{d:`M2 5h30`,strokeWidth:2,strokeDasharray:`6 5`,className:e})})}function q(){return(0,H.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:[(0,H.jsx)(`path`,{d:`M2 5h24`,strokeWidth:2.2,strokeLinecap:`round`,strokeDasharray:`0 6`,className:`stroke-message-peer-accent opacity-80`}),(0,H.jsx)(`circle`,{cx:`29.5`,cy:`5`,r:`3`,strokeWidth:1.6,className:`fill-card stroke-message-peer-accent`})]})}function J(){let e=`flex items-center gap-2`;return(0,H.jsxs)(`div`,{"data-slot":`activity-legend`,className:i(U,`grid gap-1.5 text-[11.5px] text-muted-foreground`),children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Legend`}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`running`,"aria-hidden":`true`}),`Filled: working now`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`info`,shape:`ring`,"aria-hidden":`true`}),`Ring: waiting for something outside`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`running`,shape:`workers`,"aria-hidden":`true`}),`Robot: waiting for its own workers`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(o,{rate:[0,2,5,1,3,0,4,2],className:`w-[34px]`}),`Heartbeat: tool calls, last 30 s`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(K,{className:`stroke-message-peer-accent`}),`Open request, task to task`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(q,{}),`Waits for a peer to write`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(K,{className:`stroke-message-inbound-accent`}),`Open question, worker to parent`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,H.jsx)(`circle`,{cx:`17`,cy:`5`,r:`4`,className:`fill-foreground`})}),`Comet: a message is travelling`]})]})}var Y={...g,peer:`bg-message-peer-accent`,family:`bg-message-inbound-accent`};function X({feed:e,now:t,watchingSince:n}){return(0,H.jsxs)(`section`,{"data-slot":`activity-just-now`,className:U,children:[(0,H.jsx)(`h2`,{className:W,children:`Just now`}),e.length>0?(0,H.jsx)(`ul`,{"data-slot":`activity-feed`,children:e.map((e,n)=>(0,H.jsxs)(`li`,{"data-slot":`activity-feed-entry`,className:i(`grid grid-cols-[10px_minmax(0,1fr)_auto] items-baseline gap-2 py-1 text-[12px] text-muted-foreground`,n===0&&`activity-feed-enter`),children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:i(`size-[7px] -translate-y-px rounded-full`,Y[e.tone])}),(0,H.jsx)(`span`,{className:`min-w-0`,children:e.text}),(0,H.jsx)(`span`,{"data-slot":`activity-feed-age`,className:`text-[11px] tabular-nums`,children:N(t-e.at)})]},e.id))}):null,(0,H.jsxs)(`p`,{className:`py-1.5 text-[12px] text-muted-foreground`,children:[`Watching since `,C(n)]})]})}function Z({requests:e,closing:t=[],index:n,now:r,watchingSince:i,feed:a=[],motion:o=u}){return(0,H.jsxs)(`aside`,{"data-slot":`activity-rail`,"aria-label":`Activity details`,className:`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start gap-4`,children:[(0,H.jsxs)(`section`,{"data-slot":`activity-open-requests`,className:U,children:[(0,H.jsxs)(`h2`,{className:W,children:[`Open requests `,(0,H.jsx)(`b`,{className:`text-foreground`,children:e.length})]}),e.length===0&&t.length===0?(0,H.jsx)(`p`,{className:`py-1.5 text-[12px] text-muted-foreground`,children:`No task waits for a reply.`}):(0,H.jsxs)(`ul`,{children:[e.map(e=>(0,H.jsx)(G,{request:e,index:n,now:r,motion:e.requestId in o.opening?`enter`:void 0},e.requestId)),t.map(e=>(0,H.jsx)(G,{request:e,index:n,now:r,motion:`fold`},e.requestId))]})]}),(0,H.jsx)(X,{feed:a,now:r,watchingSince:i}),(0,H.jsx)(J,{})]})}function Q(e){let[t,n]=V.useState(0);return V.useLayoutEffect(()=>{let t=e.current;if(!t)return;let r=()=>n(t.clientWidth);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function $(e,t,n){let[r,i]=V.useState(void 0),a=F(r,e,t,n);return v(r,a)||i(a),a}function ee(e,t,n=s(e.tasks)){let r=new Set(e.tasks.map(e=>e.runId)),i=new Set(e.requests.map(e=>e.requestId)),a=Object.values(t.closing).filter(t=>t.projectId===e.projectId&&!i.has(t.request.requestId));return{cards:Object.values(t.leaving).filter(t=>t.projectId===e.projectId&&!r.has(t.task.runId)).map(e=>e.task),requests:a.map(e=>e.request),waits:p(e.projectId,n,t),folding:a.filter(e=>e.phase===`reply`||!e.replied).map(e=>e.request)}}function te({project:e,now:t,watchingSince:n,motion:r=u,feed:i,still:a=!1,paused:o=!1}){let d=V.useRef(null),f=c(Q(d)),p=V.useMemo(()=>x(e),[e]),m=V.useMemo(()=>s(e.tasks),[e.tasks]),h=V.useMemo(()=>ee(e,r,m),[e,r,m]),g=V.useMemo(()=>[...e.requests,...h.requests],[e.requests,h.requests]),_=V.useMemo(()=>[...m,...h.waits],[m,h.waits]),v=j(m),y=new Map([...h.cards,...e.tasks].map(e=>[e.runId,e])),b=new Set(h.cards.map(e=>e.runId)),S=e=>1+.35*(y.get(e)?.workers.length??0),C=$([...y.keys()],f,S),w=f===1,T=e.tasks.length>12,O={now:t,titleOf:e=>I(p,e)},k=C.map(e=>e.join(`,`)).join(`|`),A=`${e.tasks.length}:${f}:${T}:${k}:${g.map(e=>e.requestId).join(`,`)}:${_.map(e=>e.id).join(`,`)}`;return D(d,`data-flip`,k,!a&&!o),(0,H.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 pl-5`,children:[e.tasks.length===0?(0,H.jsx)(`p`,{"data-slot":`activity-empty`,className:`py-6 text-[13px] text-muted-foreground`,children:`No active work in this project.`}):null,(0,H.jsxs)(`div`,{ref:d,"data-slot":`activity-graph`,"data-columns":f,"data-dense":T?`true`:void 0,className:`relative grid items-start`,style:{gridTemplateColumns:`repeat(${f}, minmax(0, 1fr))`,columnGap:w?0:96},children:[C.map((t,n)=>(0,H.jsx)(`div`,{"data-slot":`activity-column`,className:`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start gap-[30px] max-md:gap-4`,children:t.map(t=>{let n=y.get(t);return n?(0,H.jsx)(l,{task:n,requests:e.requests,waits:m,index:p,ctx:O,dense:T,narrow:w,motion:r,ghost:b.has(t),linked:v.linked.has(t),onHover:v.onHover},t):null})},n)),(0,H.jsx)(E,{requests:g,waits:_,active:v.active,index:p,peers:!w,layoutKey:A,now:t,motion:r,paused:o||a})]})]}),(0,H.jsx)(Z,{requests:e.requests,closing:h.folding,index:p,now:t,watchingSince:n,feed:i,motion:r})]})}function ne(){let e=r(),t=_({kind:`project`,projectId:e}),n=R(),[i]=V.useState(()=>new Date().toISOString()),a=P(t.data?.generatedAt,t.dataUpdatedAt),{motion:o,feed:s,reduced:c,paused:l}=A(t.data,e),u=t.data?.projects[0];if(t.isPending)return(0,H.jsx)(B,{});let d=u?b(u):void 0;return u?(0,H.jsxs)(`div`,{"data-route":`activity`,"data-activity-paused":l?`true`:void 0,className:`flex min-h-full w-full flex-col gap-4 px-[18px] py-6 md:px-7`,children:[(0,H.jsx)(M,{name:u.name,now:a,stale:t.isError,children:(0,H.jsx)(O,{scope:`project`,projectId:n??u.projectId})}),(0,H.jsx)(T,{summary:m([u]),tasksTo:`/`,bumps:o.bumps}),d?(0,H.jsx)(`p`,{"data-slot":`activity-project-notice`,role:`status`,className:`py-6 text-[13px] text-muted-foreground`,children:d}):(0,H.jsx)(te,{project:u,now:a,watchingSince:i,motion:o,feed:s,still:c,paused:l})]}):(0,H.jsxs)(`div`,{"data-route":`activity`,className:`min-h-full w-full px-[18px] py-6 md:px-7`,children:[(0,H.jsx)(M,{name:n??`project`,children:(0,H.jsx)(O,{scope:`project`,projectId:n})}),(0,H.jsxs)(`div`,{role:`alert`,className:`mt-6 flex items-center gap-3 text-[13px] text-muted-foreground`,children:[t.error?`Could not load activity: ${t.error.message}`:`This project has no activity snapshot.`,(0,H.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void t.refetch(),className:`max-md:min-h-11`,children:`Retry`})]})]})}export{ne as ProjectActivityRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{c as r,t as i}from"./utils-DSMR_WLb.js";import{t as a}from"./arrow-right-Dh_Lx3um.js";import{A as o,B as s,C as c,E as l,F as u,G as d,H as f,I as p,K as m,L as h,N as g,Q as _,T as v,U as y,V as b,W as x,X as S,Y as C,Z as w,a as T,c as E,g as D,i as O,m as k,n as A,o as j,r as M,s as N,t as P,w as F,z as I}from"./activity-motion-D3CzGjrR.js";import{t as L}from"./button-BQ2y4XRB.js";import{s as R}from"./project-router-CDPfL2Jz.js";import{t as z}from"./status-dot-DtAOFiIi.js";import{st as B}from"./index-CHIFhfha.js";var V=e(t(),1),H=n(),U=`rounded-xl border border-border bg-card px-3.5 py-3`,W=`mb-2 flex gap-2 text-[11.5px] font-semibold tracking-[0.06em] text-muted-foreground uppercase`;function G({request:e,index:t,now:n,motion:r}){let{kind:o,relation:s}=h(e,t),c=k(e,n),l=e.relationship===`peer`?`text-message-peer-accent`:`text-message-inbound-accent`;return(0,H.jsxs)(`li`,{"data-slot":r===`fold`?`activity-request-closing`:`activity-request`,"data-request":e.requestId,"aria-hidden":r===`fold`||void 0,className:i(`border-t border-border py-2.5 first:border-t-0 first:pt-0`,r===`enter`&&`activity-row-enter`,r===`fold`&&`activity-row-fold`),children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[12px] font-medium`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:d(t,e)}),(0,H.jsx)(a,{"aria-label":`to`,className:`size-3 shrink-0 text-muted-foreground`}),(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:f(t,e)}),(0,H.jsx)(`span`,{className:i(`ml-auto shrink-0 text-[10px] font-semibold tracking-[0.05em] uppercase`,l),children:o})]}),(0,H.jsxs)(`p`,{className:`my-1 line-clamp-3 text-[12px] text-muted-foreground`,children:[`“`,e.text,`”`]}),(0,H.jsxs)(`div`,{className:`flex gap-1.5 text-[11px] text-muted-foreground tabular-nums`,children:[(0,H.jsxs)(`span`,{children:[s,` · open `,S(w(e.createdAt,n))]}),e.deadline?(0,H.jsx)(`span`,{className:`ml-auto`,children:y(e.deadline,n)}):null]}),c===void 0?null:(0,H.jsx)(`div`,{"aria-hidden":`true`,className:`mt-1.5 h-[3px] overflow-hidden rounded-sm bg-border`,children:(0,H.jsx)(`span`,{className:i(`block h-full bg-current`,l),style:{width:`${Math.round(c*100)}%`}})})]})}function K({className:e}){return(0,H.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,H.jsx)(`path`,{d:`M2 5h30`,strokeWidth:2,strokeDasharray:`6 5`,className:e})})}function q(){return(0,H.jsxs)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:[(0,H.jsx)(`path`,{d:`M2 5h24`,strokeWidth:2.2,strokeLinecap:`round`,strokeDasharray:`0 6`,className:`stroke-message-peer-accent opacity-80`}),(0,H.jsx)(`circle`,{cx:`29.5`,cy:`5`,r:`3`,strokeWidth:1.6,className:`fill-card stroke-message-peer-accent`})]})}function J(){let e=`flex items-center gap-2`;return(0,H.jsxs)(`div`,{"data-slot":`activity-legend`,className:i(U,`grid gap-1.5 text-[11.5px] text-muted-foreground`),children:[(0,H.jsx)(`h2`,{className:`sr-only`,children:`Legend`}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`running`,"aria-hidden":`true`}),`Filled: working now`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`info`,shape:`ring`,"aria-hidden":`true`}),`Ring: waiting for something outside`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(z,{tone:`running`,shape:`workers`,"aria-hidden":`true`}),`Robot: waiting for its own workers`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(o,{rate:[0,2,5,1,3,0,4,2],className:`w-[34px]`}),`Heartbeat: tool calls, last 30 s`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(K,{className:`stroke-message-peer-accent`}),`Open request, task to task`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(q,{}),`Waits for a peer to write`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(K,{className:`stroke-message-inbound-accent`}),`Open question, worker to parent`]}),(0,H.jsxs)(`div`,{className:e,children:[(0,H.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 34 10`,className:`h-2.5 w-[34px] shrink-0`,children:(0,H.jsx)(`circle`,{cx:`17`,cy:`5`,r:`4`,className:`fill-foreground`})}),`Comet: a message is travelling`]})]})}var Y={...g,peer:`bg-message-peer-accent`,family:`bg-message-inbound-accent`};function X({feed:e,now:t,watchingSince:n}){return(0,H.jsxs)(`section`,{"data-slot":`activity-just-now`,className:U,children:[(0,H.jsx)(`h2`,{className:W,children:`Just now`}),e.length>0?(0,H.jsx)(`ul`,{"data-slot":`activity-feed`,children:e.map((e,n)=>(0,H.jsxs)(`li`,{"data-slot":`activity-feed-entry`,className:i(`grid grid-cols-[10px_minmax(0,1fr)_auto] items-baseline gap-2 py-1 text-[12px] text-muted-foreground`,n===0&&`activity-feed-enter`),children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:i(`size-[7px] -translate-y-px rounded-full`,Y[e.tone])}),(0,H.jsx)(`span`,{className:`min-w-0`,children:e.text}),(0,H.jsx)(`span`,{"data-slot":`activity-feed-age`,className:`text-[11px] tabular-nums`,children:N(t-e.at)})]},e.id))}):null,(0,H.jsxs)(`p`,{className:`py-1.5 text-[12px] text-muted-foreground`,children:[`Watching since `,C(n)]})]})}function Z({requests:e,closing:t=[],index:n,now:r,watchingSince:i,feed:a=[],motion:o=u}){return(0,H.jsxs)(`aside`,{"data-slot":`activity-rail`,"aria-label":`Activity details`,className:`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start gap-4`,children:[(0,H.jsxs)(`section`,{"data-slot":`activity-open-requests`,className:U,children:[(0,H.jsxs)(`h2`,{className:W,children:[`Open requests `,(0,H.jsx)(`b`,{className:`text-foreground`,children:e.length})]}),e.length===0&&t.length===0?(0,H.jsx)(`p`,{className:`py-1.5 text-[12px] text-muted-foreground`,children:`No task waits for a reply.`}):(0,H.jsxs)(`ul`,{children:[e.map(e=>(0,H.jsx)(G,{request:e,index:n,now:r,motion:e.requestId in o.opening?`enter`:void 0},e.requestId)),t.map(e=>(0,H.jsx)(G,{request:e,index:n,now:r,motion:`fold`},e.requestId))]})]}),(0,H.jsx)(X,{feed:a,now:r,watchingSince:i}),(0,H.jsx)(J,{})]})}function Q(e){let[t,n]=V.useState(0);return V.useLayoutEffect(()=>{let t=e.current;if(!t)return;let r=()=>n(t.clientWidth);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function $(e,t,n){let[r,i]=V.useState(void 0),a=F(r,e,t,n);return v(r,a)||i(a),a}function ee(e,t,n=s(e.tasks)){let r=new Set(e.tasks.map(e=>e.runId)),i=new Set(e.requests.map(e=>e.requestId)),a=Object.values(t.closing).filter(t=>t.projectId===e.projectId&&!i.has(t.request.requestId));return{cards:Object.values(t.leaving).filter(t=>t.projectId===e.projectId&&!r.has(t.task.runId)).map(e=>e.task),requests:a.map(e=>e.request),waits:p(e.projectId,n,t),folding:a.filter(e=>e.phase===`reply`||!e.replied).map(e=>e.request)}}function te({project:e,now:t,watchingSince:n,motion:r=u,feed:i,still:a=!1,paused:o=!1}){let d=V.useRef(null),f=c(Q(d)),p=V.useMemo(()=>x(e),[e]),m=V.useMemo(()=>s(e.tasks),[e.tasks]),h=V.useMemo(()=>ee(e,r,m),[e,r,m]),g=V.useMemo(()=>[...e.requests,...h.requests],[e.requests,h.requests]),_=V.useMemo(()=>[...m,...h.waits],[m,h.waits]),v=j(m),y=new Map([...h.cards,...e.tasks].map(e=>[e.runId,e])),b=new Set(h.cards.map(e=>e.runId)),S=e=>1+.35*(y.get(e)?.workers.length??0),C=$([...y.keys()],f,S),w=f===1,T=e.tasks.length>12,O={now:t,titleOf:e=>I(p,e)},k=C.map(e=>e.join(`,`)).join(`|`),A=`${e.tasks.length}:${f}:${T}:${k}:${g.map(e=>e.requestId).join(`,`)}:${_.map(e=>e.id).join(`,`)}`;return D(d,`data-flip`,k,!a&&!o),(0,H.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,1fr)_300px]`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 pl-5`,children:[e.tasks.length===0?(0,H.jsx)(`p`,{"data-slot":`activity-empty`,className:`py-6 text-[13px] text-muted-foreground`,children:`No active work in this project.`}):null,(0,H.jsxs)(`div`,{ref:d,"data-slot":`activity-graph`,"data-columns":f,"data-dense":T?`true`:void 0,className:`relative grid items-start`,style:{gridTemplateColumns:`repeat(${f}, minmax(0, 1fr))`,columnGap:w?0:96},children:[C.map((t,n)=>(0,H.jsx)(`div`,{"data-slot":`activity-column`,className:`grid min-w-0 grid-cols-[minmax(0,1fr)] content-start gap-[30px] max-md:gap-4`,children:t.map(t=>{let n=y.get(t);return n?(0,H.jsx)(l,{task:n,requests:e.requests,waits:m,index:p,ctx:O,dense:T,narrow:w,motion:r,ghost:b.has(t),linked:v.linked.has(t),onHover:v.onHover},t):null})},n)),(0,H.jsx)(E,{requests:g,waits:_,active:v.active,index:p,peers:!w,layoutKey:A,now:t,motion:r,paused:o||a})]})]}),(0,H.jsx)(Z,{requests:e.requests,closing:h.folding,index:p,now:t,watchingSince:n,feed:i,motion:r})]})}function ne(){let e=r(),t=_({kind:`project`,projectId:e}),n=R(),[i]=V.useState(()=>new Date().toISOString()),a=P(t.data?.generatedAt,t.dataUpdatedAt),{motion:o,feed:s,reduced:c,paused:l}=A(t.data,e),u=t.data?.projects[0];if(t.isPending)return(0,H.jsx)(B,{});let d=u?b(u):void 0;return u?(0,H.jsxs)(`div`,{"data-route":`activity`,"data-activity-paused":l?`true`:void 0,className:`flex min-h-full w-full flex-col gap-4 px-[18px] py-6 md:px-7`,children:[(0,H.jsx)(M,{name:u.name,now:a,stale:t.isError,children:(0,H.jsx)(O,{scope:`project`,projectId:n??u.projectId})}),(0,H.jsx)(T,{summary:m([u]),tasksTo:`/`,bumps:o.bumps}),d?(0,H.jsx)(`p`,{"data-slot":`activity-project-notice`,role:`status`,className:`py-6 text-[13px] text-muted-foreground`,children:d}):(0,H.jsx)(te,{project:u,now:a,watchingSince:i,motion:o,feed:s,still:c,paused:l})]}):(0,H.jsxs)(`div`,{"data-route":`activity`,className:`min-h-full w-full px-[18px] py-6 md:px-7`,children:[(0,H.jsx)(M,{name:n??`project`,children:(0,H.jsx)(O,{scope:`project`,projectId:n})}),(0,H.jsxs)(`div`,{role:`alert`,className:`mt-6 flex items-center gap-3 text-[13px] text-muted-foreground`,children:[t.error?`Could not load activity: ${t.error.message}`:`This project has no activity snapshot.`,(0,H.jsx)(L,{size:`sm`,variant:`outline`,onClick:()=>void t.refetch(),className:`max-md:min-h-11`,children:`Retry`})]})]})}export{ne as ProjectActivityRoute};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{An as i,ci as a}from"./project-scope-context-D9axDY18.js";import{Kt as o,Lt as s,Wt as c,Xt as l,g as u,h as d,ht as f,x as p}from"./queries-DzwCG927.js";import{n as m}from"./toaster-Bo5vCbz-.js";import{t as h}from"./button-BQ2y4XRB.js";import{t as g}from"./badge-D9JrXe0o.js";import{t as _}from"./centered-state-V15AR_qo.js";import{A as v,_n as y,er as b}from"./index-BRgRv29I.js";import{i as x,n as S,r as C}from"./highlighter-DvLzHjjY.js";import{n as w,r as T,t as E}from"./remote-settings-notice-C727a84A.js";var D=e(t(),1),O=n(),k=1500;function A(e,t){let n=(0,D.useMemo)(()=>e.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DSMR_WLb.js";import{An as i,ci as a}from"./project-scope-context-D9axDY18.js";import{Kt as o,Lt as s,Wt as c,Xt as l,g as u,h as d,ht as f,x as p}from"./queries-DzwCG927.js";import{n as m}from"./toaster-Bo5vCbz-.js";import{t as h}from"./button-BQ2y4XRB.js";import{t as g}from"./badge-D9JrXe0o.js";import{t as _}from"./centered-state-V15AR_qo.js";import{A as v,_n as y,er as b}from"./index-CHIFhfha.js";import{i as x,n as S,r as C}from"./highlighter-DvLzHjjY.js";import{n as w,r as T,t as E}from"./remote-settings-notice-Drbpb7K4.js";var D=e(t(),1),O=n(),k=1500;function A(e,t){let n=(0,D.useMemo)(()=>e.split(`
2
2
  `).map(e=>[{content:e}]),[e]),r=(0,D.useMemo)(()=>S(t),[t]),i=n.length>k,[a,o]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(r===null||i)return;let t=!1;return C(e,r).then(n=>{t||o({key:e,tokens:n.tokens})}),()=>{t=!0}},[e,r,i]),r===null||i?n:a?.key===e?a.tokens:x(e,r)?.tokens??n}var j=`code-editor-surface m-0 min-h-full w-full whitespace-pre font-mono text-xs leading-[1.7] px-3 py-2 [tab-size:2]`;function M({value:e,onChange:t,language:n,readOnly:i,className:a,...o}){let s=A(e,n),c=(0,D.useRef)(null),l=(0,D.useRef)(null),u=()=>{let e=l.current,t=c.current;!e||!t||(t.scrollTop=e.scrollTop,t.scrollLeft=e.scrollLeft)};return(0,D.useLayoutEffect)(u,[e]),(0,O.jsxs)(`div`,{"data-slot":`code-editor`,className:r(`relative overflow-hidden rounded-md border border-input bg-card`,a),children:[(0,O.jsx)(`pre`,{ref:c,"aria-hidden":`true`,className:r(j,`pointer-events-none absolute inset-0 overflow-auto text-soft-foreground`),children:s.map((e,t)=>(0,O.jsx)(`span`,{className:`block`,children:e.length===0?`
3
3
  `:(0,O.jsxs)(O.Fragment,{children:[e.map((e,t)=>(0,O.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t)),`
4
4
  `]})},t))}),(0,O.jsx)(`textarea`,{ref:l,"data-slot":`code-editor-input`,value:e,readOnly:i,onChange:e=>t?.(e.target.value),onScroll:u,spellCheck:!1,autoCorrect:`off`,autoCapitalize:`off`,autoComplete:`off`,wrap:`off`,className:r(j,`relative block resize-none overflow-auto bg-transparent text-transparent caret-foreground outline-hidden`,`selection:bg-accent-strong/30 focus-visible:ring-0`,i&&`cursor-default`),...o})]})}function N(e){return t=>t.runners.includes(e)}function P(e,t){let n=N(e);return t===`mcp`?e=>n(e)&&(e.holdsMcp===!0||e.kind===`mcp`):e=>n(e)&&e.kind===t}function F(e){let{label:t,note:n,groups:r}=e.agentConfig;return{id:e.id,label:t,note:n,groups:r.map(({id:t,label:n,note:r,empty:i,showsUserMcp:a})=>({id:t,label:n,note:r,...i?{empty:i}:{},...a?{showsUserMcp:a}:{},files:P(e.id,t)}))}}function I(e){return c(e).map(F)}function L(e){return e.seeded?`Copied into each run’s worktree — takes effect on your next run.`:e.tracked===`tracked`?`Runs read the committed copy — this edit applies after you commit it.`:e.tracked===`outside-repo`?`Applies to every session on this machine.`:`Personal, git-ignored.`}function R(){let e=d();T();let t=f(),n=l(),r=n.data,i=(0,D.useMemo)(()=>I(r),[r]),a=(0,D.useMemo)(()=>t.data?v(t.data.checks,r):o(r),[t.data,r]);return n.isError?(0,O.jsx)(_,{icon:(0,O.jsx)(b,{}),tone:`danger`,title:`Runners did not load`,subtitle:n.error.message,heading:`h2`}):e.isError?(0,O.jsx)(_,{icon:(0,O.jsx)(b,{}),tone:`danger`,title:`Agent config did not load`,subtitle:e.error.message,heading:`h2`}):e.isPending||r===void 0?(0,O.jsx)(`p`,{"data-slot":`agent-config-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent config…`}):(0,O.jsx)(z,{listing:e.data,descriptors:i,installed:a})}function z({listing:e,descriptors:t,installed:n}){let[i,a]=(0,D.useState)(`claude`),[o,s]=(0,D.useState)(null),c=t.find(e=>e.id===i)??t[0];if(c===void 0)return null;let l=e.files.find(e=>e.id===o)??null,u=e=>{a(e),s(null)};return(0,O.jsxs)(`div`,{"data-slot":`agent-config`,className:`flex flex-col gap-5 p-4 md:p-6`,children:[(0,O.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Edit agent instructions and MCP configuration for this project.`}),!e.editable&&(0,O.jsxs)(`div`,{"data-slot":`agent-config-readonly`,className:`rounded-md border border-border bg-muted/40 px-3 py-2 text-[13px] text-soft-foreground`,children:[`Read-only: this remote cockpit cannot edit agent config. You can still see every file and which one wins. To edit here, the host operator runs `,(0,O.jsx)(`code`,{children:E}),`.`]}),(0,O.jsx)(w,{risk:`Agent config can define hooks and MCP servers that run commands on the machine running Squawk`}),(0,O.jsx)(`div`,{"data-slot":`agent-config-agents`,role:`tablist`,className:`flex flex-wrap gap-1`,children:t.map(e=>(0,O.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===c.id,"data-slot":`agent-config-agent`,"data-agent":e.id,"data-selected":e.id===c.id,onClick:()=>u(e.id),className:r(`flex min-w-11 items-center justify-center gap-2 rounded-md px-3 py-1.5 text-[13px] transition-colors`,e.id===c.id?`bg-background font-semibold shadow-sm`:`hover:bg-muted/60`),children:[e.label,!n.includes(e.id)&&(0,O.jsx)(g,{variant:`outline`,className:`text-[12px] text-soft-foreground`,children:`not installed`})]},e.id))}),c.note&&(0,O.jsx)(`p`,{"data-slot":`agent-config-agent-note`,className:`text-[12px] text-soft-foreground`,children:c.note}),(0,O.jsxs)(`div`,{className:`grid min-w-0 gap-6 lg:grid-cols-[minmax(0,20rem)_minmax(0,1fr)]`,children:[(0,O.jsx)(`nav`,{"data-slot":`agent-config-nav`,className:`flex min-w-0 flex-col gap-5`,children:(0,O.jsx)(B,{agent:c,listing:e,selectedId:o,onSelect:s})}),(0,O.jsx)(`div`,{"data-slot":`agent-config-editor-pane`,className:`min-w-0`,children:l?(0,O.jsx)(H,{file:l},l.id):(0,O.jsx)(`div`,{className:`flex h-full min-h-40 items-center justify-center rounded-md border border-dashed border-border text-[13px] text-soft-foreground`,children:`Select a config file to view or edit it.`})})]})]})}function B({agent:e,listing:t,selectedId:n,onSelect:i}){return(0,O.jsx)(O.Fragment,{children:e.groups.map(a=>{let o=t.files.filter(a.files),s=a.showsUserMcp?t.userMcp:void 0;return o.length===0&&!s&&!a.empty?null:(0,O.jsxs)(`section`,{"data-slot":`agent-config-group`,"data-group":a.id,"data-agent":e.id,children:[(0,O.jsx)(`p`,{className:`mb-1 text-[11px] font-medium uppercase tracking-wide text-soft-foreground`,children:a.label}),a.note&&(0,O.jsx)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:a.note}),o.length===0&&a.empty&&(0,O.jsx)(`p`,{"data-slot":`agent-config-group-empty`,className:`rounded-md border border-dashed border-border px-3 py-2 text-[12px] text-soft-foreground`,children:a.empty}),(0,O.jsx)(`ul`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`agent-config-file`,"data-selected":e.id===n,onClick:()=>i(e.id),className:r(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] transition-colors`,e.id===n?`bg-accent-strong/15 text-foreground`:`hover:bg-muted/60`),children:[(0,O.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-[12px]`,children:e.label}),e.seeded&&(0,O.jsx)(g,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`seeded`}),!e.exists&&(0,O.jsx)(`span`,{className:`shrink-0 text-[11px] text-soft-foreground`,children:`absent`})]})},e.id))}),s&&(0,O.jsx)(V,{userMcp:s})]},a.id)})})}function V({userMcp:e}){return(0,O.jsxs)(`div`,{"data-slot":`agent-config-user-mcp`,className:`mt-3`,children:[(0,O.jsx)(`h4`,{className:`mb-1 text-[12px] font-semibold`,children:`User & local scopes`}),(0,O.jsxs)(`p`,{className:`mb-2 text-[12px] text-soft-foreground`,children:[`Managed by `,(0,O.jsx)(`code`,{className:`font-mono`,children:`claude mcp add`}),` in `,e.path,` — Squawk does not edit Claude’s state file.`]}),e.readable?e.servers.length>0?(0,O.jsx)(`ul`,{className:`flex flex-wrap gap-1`,children:e.servers.map(e=>(0,O.jsx)(`li`,{children:(0,O.jsx)(g,{variant:`outline`,className:`font-mono text-[11px]`,children:e})},e))}):(0,O.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`No user-scoped MCP servers.`}):(0,O.jsx)(`p`,{className:`text-[12px] text-soft-foreground`,children:`Could not read the file.`})]})}function H({file:e}){let t=u(e.id),[n,r]=(0,D.useState)(null),[i,a]=(0,D.useState)(!1),[o,s]=(0,D.useState)(null),c=t.data?.version??null,l=n??t.data?.content??``,d=t.data?l!==t.data.content:!1,f=e.writable,p=e.kind===`mcp`||e.holdsMcp;y(f&&d);let{save:m,isSaving:_}=G({file:e,content:l,loadedVersion:c,setDraft:r,setConflict:a,setFormatError:s});return(0,D.useEffect)(()=>{t.data&&(r(t.data.content),a(!1),s(null))},[t.data?.version,t.data]),(0,O.jsxs)(`div`,{"data-slot":`settings-config-editor`,"data-reports-dirty":``,className:`flex flex-col gap-3`,children:[(0,O.jsx)(`h3`,{className:`text-sm`,children:`Configuration file`}),(0,O.jsxs)(`p`,{"data-slot":`agent-config-scope`,title:e.path,className:`text-[12px] text-muted-foreground break-words`,children:[e.scope.charAt(0).toUpperCase()+e.scope.slice(1),` scope · `,e.path]}),(0,O.jsxs)(`div`,{className:`settings-readout flex flex-wrap items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`font-mono text-[13px]`,children:e.label}),(0,O.jsx)(g,{variant:`outline`,className:`text-[12px] uppercase`,children:e.format}),(0,O.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noreferrer`,className:`text-[12px] text-soft-foreground underline hover:text-foreground`,children:`docs`})]}),(0,O.jsxs)(`div`,{className:`settings-config-content-heading`,children:[(0,O.jsx)(`h3`,{children:p?`MCP configuration`:`File contents`}),p&&(0,O.jsx)(`p`,{children:`Review server commands before saving. MCP servers execute locally.`})]}),t.isPending?(0,O.jsx)(`p`,{className:`text-[13px] text-soft-foreground`,children:`Loading file…`}):t.isError?(0,O.jsx)(`p`,{className:`text-[13px] text-destructive`,children:t.error.message}):(0,O.jsx)(M,{value:l,language:e.format,readOnly:!f,onChange:r,"aria-label":`${e.label} contents`,className:`h-[210px]`}),(0,O.jsx)(U,{formatError:o,conflict:i,onReload:()=>void t.refetch()}),f&&(0,O.jsxs)(`div`,{className:`settings-form-actions`,children:[(0,O.jsx)(h,{size:`sm`,onClick:m,disabled:!d||_,children:e.exists?`Save file`:`Create file`}),(0,O.jsx)(h,{size:`sm`,variant:`outline`,onClick:()=>r(null),disabled:!d||_,children:`Reset`}),d&&(0,O.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`Unsaved changes`})]}),(0,O.jsxs)(`div`,{className:`settings-config-save-help`,children:[(0,O.jsx)(`p`,{"data-slot":`agent-config-precedence`,className:`text-[12px] text-soft-foreground`,children:e.precedence}),(0,O.jsxs)(`p`,{"data-slot":`agent-config-effect`,className:`text-[12px] text-foreground/80`,children:[L(e),e.hotReload?` ${e.hotReload}`:``]}),(0,O.jsx)(W,{reason:e.readOnlyReason})]})]})}function U({formatError:e,conflict:t,onReload:n}){return(0,O.jsxs)(O.Fragment,{children:[e&&(0,O.jsx)(`p`,{"data-slot":`agent-config-format-error`,className:`text-[12px] text-destructive`,children:e}),t&&(0,O.jsxs)(`div`,{"data-slot":`agent-config-conflict`,className:`flex items-center justify-between gap-2 rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-[12px]`,children:[(0,O.jsx)(`span`,{children:`The file changed on disk since you opened it.`}),(0,O.jsx)(h,{size:`sm`,variant:`outline`,onClick:n,children:`Reload from disk`})]})]})}function W({reason:e}){return e&&(0,O.jsx)(`p`,{children:e})}function G({file:e,content:t,loadedVersion:n,setDraft:r,setConflict:o,setFormatError:c}){let l=p(e.id),u=a(),d=T();return{save:()=>{c(null),o(!1),l.mutate({content:t,version:n},{onSuccess:()=>{r(null),m(`${e.exists?`Saved`:`Created`} ${e.label}`)},onError:e=>{e instanceof i&&e.status===409?d().then(()=>{u.getQueryData(s.health)?.capabilities.settingsAdmin===!1?m(e.message,{tone:`danger`}):o(!0)}):e instanceof i&&e.status===400?c(e.message):m(e.message,{tone:`danger`})}})},isSaving:l.isPending}}export{R as AgentConfigSection};