@hearsay-tools/squawk 0.19.0-dev.9162 → 0.19.0-dev.9168
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/delegation/routes.d.ts +78 -78
- package/dist/delegation/workspace-removal.d.ts +1 -1
- package/dist/delegation/workspace-removal.js +1 -1
- package/dist/delegation/workspace-removal.js.map +1 -1
- package/dist/features/hosts/routes.d.ts +44 -44
- package/dist/features/webhooks/routes.d.ts +38 -38
- package/dist/git-command.d.ts +11 -0
- package/dist/git-command.js +14 -0
- package/dist/git-command.js.map +1 -1
- package/dist/git-worktree-claims.d.ts +96 -0
- package/dist/git-worktree-claims.js +219 -0
- package/dist/git-worktree-claims.js.map +1 -0
- package/dist/git-worktree-lock.d.ts +4 -3
- package/dist/git-worktree-lock.js +220 -66
- package/dist/git-worktree-lock.js.map +1 -1
- package/dist/server/models-routes.d.ts +12 -12
- package/dist/server/providers-routes.d.ts +58 -58
- package/dist/server/runners-routes.d.ts +10 -10
- package/dist/server/workspace-live-routes.d.ts +5 -5
- package/dist/server/workspace-routes.d.ts +85 -85
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-m_1ntZJh.js → accounts-section-Bnr89jmC.js} +1 -1
- package/web/dist/assets/{activity-motion-DDqgr8eF.js → activity-motion-BW0tAmYF.js} +1 -1
- package/web/dist/assets/{activity-route-BlEZZxyI.js → activity-route-C2zP5vVV.js} +1 -1
- package/web/dist/assets/{agent-config-section-wICtFVks.js → agent-config-section-CwK_izpU.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-BC9Ypg0g.js → agent-defaults-section-RyEogH0g.js} +1 -1
- package/web/dist/assets/{appearance-fkDdWPlG.js → appearance-DvoRcoRX.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-B6kX09p-.js → archive-on-merge-field-DWPtF9dh.js} +1 -1
- package/web/dist/assets/ask-card-D-om0EtP.js +9 -0
- package/web/dist/assets/{automations-route-BfOpJjLK.js → automations-route-DfGE4xWT.js} +1 -1
- package/web/dist/assets/{commit-list-StLehTiQ.js → commit-list-CPJLP4DU.js} +1 -1
- package/web/dist/assets/{diff-DEw-tkVq.js → diff-BQJN6jzN.js} +2 -2
- package/web/dist/assets/{diff-controls-CSO8HgZ0.js → diff-controls-AsSX7gfO.js} +1 -1
- package/web/dist/assets/{diff-view-BcU4Rnuo.js → diff-view-BW5bbiaq.js} +1 -1
- package/web/dist/assets/{discard-changes-dialog-BEsdWdyJ.js → discard-changes-dialog-Bv4yc0N1.js} +1 -1
- package/web/dist/assets/{file-preview-_4nAs_Ai.js → file-preview-CnrFxbea.js} +1 -1
- package/web/dist/assets/{git-toolbar-DXnIUFi1.js → git-toolbar-C7iolhIi.js} +1 -1
- package/web/dist/assets/{github-g-Ykk4uE.js → github-DGElvfMU.js} +1 -1
- package/web/dist/assets/{global-activity-route-OsAvUny-.js → global-activity-route-Dijwg4OL.js} +1 -1
- package/web/dist/assets/index-BVRdRJAN.css +1 -0
- package/web/dist/assets/{index-Dp7K74Jw.js → index-DPfg7xSB.js} +4 -4
- package/web/dist/assets/{markdown-BB-PN03o.js → markdown-Cljq4S1h.js} +1 -1
- package/web/dist/assets/{option-select-Bmm4ktgQ.js → option-select-BcTkv-7t.js} +1 -1
- package/web/dist/assets/{preferences-section-dKDCZSWD.js → preferences-section-CEKXGhEj.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-DBbCXW1b.js → preview-pane-connected-CKRBfx7t.js} +1 -1
- package/web/dist/assets/{project-location-DJjcFmsE.js → project-location-hufc_p8y.js} +1 -1
- package/web/dist/assets/{projects-section-CVFyzORg.js → projects-section-vOFZ4lbx.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-Jj1YbCwG.js → prompt-templates-section-Caash2nq.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-Czl9yS5W.js → remote-settings-notice-fNgh5LdN.js} +1 -1
- package/web/dist/assets/{repo-git-C9N9wa5l.js → repo-git-5MK_RAR6.js} +1 -1
- package/web/dist/assets/{report-reader-Ci4sWoe1.js → report-reader-CK1WDtEH.js} +1 -1
- package/web/dist/assets/{reports-CQPRtR5G.js → reports-B-GImLAo.js} +1 -1
- package/web/dist/assets/{resources-section-lLpdP6MD.js → resources-section-ApF3gXrw.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-BjXqp0gY.js → review-notes-drafts-BdjEFs1G.js} +1 -1
- package/web/dist/assets/{review-panel-B4dp-Rol.js → review-panel-D4zmYH8O.js} +1 -1
- package/web/dist/assets/{review-strip-BE71YjB6.js → review-strip-BpHXklAn.js} +1 -1
- package/web/dist/assets/{run-header-DvbVw3uo.js → run-header-BUe92WWr.js} +1 -1
- package/web/dist/assets/{select-CYo1lo6a.js → select-CwDhRDtw.js} +1 -1
- package/web/dist/assets/{session-context-section-B_NEOGby.js → session-context-section-C87jx7RB.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-DeAST7qR.js → settings-agent-picker-Dk8yJ57U.js} +1 -1
- package/web/dist/assets/{settings-save-bar-Dd3bTznK.js → settings-save-bar-cu8BKCGT.js} +1 -1
- package/web/dist/assets/{settings-shell-Bt7NYun7.js → settings-shell-mhQfQKf1.js} +1 -1
- package/web/dist/assets/{sidebar-section-DdrFJBTL.js → sidebar-section-DOQ5N1L6.js} +1 -1
- package/web/dist/assets/{skills-DNCuhhKf.js → skills-DXJ1gQBD.js} +1 -1
- package/web/dist/assets/{task-changes-CdAzeh9M.js → task-changes-D9Sdmpmw.js} +1 -1
- package/web/dist/assets/{task-commits-CzZJZj2x.js → task-commits-A0UIqxpL.js} +1 -1
- package/web/dist/assets/{task-file-scope-BuFeMG6a.js → task-file-scope-ID220XKo.js} +1 -1
- package/web/dist/assets/{task-files-BFdMVAb3.js → task-files-Id2tuAAG.js} +1 -1
- package/web/dist/assets/{task-github-item-Dv0Uflz7.js → task-github-item-YKUcwp2o.js} +1 -1
- package/web/dist/assets/task-thread-A_vkygGX.js +2 -0
- package/web/dist/assets/{task-thread-a6CXLxwn.css → task-thread-BObu0KsD.css} +1 -1
- package/web/dist/assets/{thread-state-DqBwIoCM.js → thread-state-6-BzRrJ_.js} +1 -1
- package/web/dist/assets/{use-finish-run-CFEVvqeg.js → use-finish-run-DO-nnAaa.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-BYN578_s.js → use-hand-to-agent-state-CADaL8U8.js} +1 -1
- package/web/dist/assets/use-path-bases-CFAmFn_E.js +1 -0
- package/web/dist/assets/{workflows-IT5WTfLr.js → workflows-DOLG-Rns.js} +1 -1
- package/web/dist/assets/{workspace-tools-D_opTe6D.js → workspace-tools-DTCJVDTE.js} +1 -1
- package/web/dist/assets/{worktrees-section-B8ycJMoK.js → worktrees-section-BOHDbywt.js} +1 -1
- package/web/dist/index.html +2 -2
- package/dist/git-worktree-lock-helper.d.ts +0 -30
- package/dist/git-worktree-lock-helper.js +0 -300
- package/dist/git-worktree-lock-helper.js.map +0 -1
- package/web/dist/assets/ask-card-Cue5EajQ.js +0 -9
- package/web/dist/assets/index-D_WkVdwL.css +0 -1
- package/web/dist/assets/task-thread-C98mqSie.js +0 -2
- package/web/dist/assets/use-path-bases-B238cLk1.js +0 -1
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import * as fs from 'node:fs/promises';
|
|
2
|
-
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import { runGit } from './git-command.js';
|
|
4
|
-
/** Run one queued Git command; without input git sees an empty stdin, exactly as before. */
|
|
5
|
-
async function runGitCommand(message) {
|
|
6
|
-
const result = await runGit(message.args, { cwd: message.cwd, maxBuffer: 32 * 1024 * 1024, timeout: message.timeout, input: message.input ?? '' }).then(({ stdout, stderr }) => ({ ok: true, stdout, stderr }), (error) => ({ ok: false, stdout: error.stdout ?? '', stderr: error.stderr || error.message || '',
|
|
7
|
-
// A git killed at its bound says so: its stderr alone reads like any other failure.
|
|
8
|
-
...(error.killed && message.timeout ? { timedOut: true } : {}) }));
|
|
9
|
-
if (result.timedOut && await stopTimedOutChildren() !== 'stopped') {
|
|
10
|
-
return { ...result, childrenRunning: true, stderr: `${result.stderr}\nGit child processes of the timed-out command may still be running`.trim() };
|
|
11
|
-
}
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
/** The PIDs in this keeper's process group other than itself; undefined where the host cannot list them. */
|
|
15
|
-
async function groupMembers() {
|
|
16
|
-
if (process.platform !== 'linux')
|
|
17
|
-
return undefined;
|
|
18
|
-
const members = [];
|
|
19
|
-
// An unreadable /proc proves nothing: the caller reads undefined as unknown, never as exited.
|
|
20
|
-
const entries = await fs.readdir('/proc').catch(() => undefined);
|
|
21
|
-
if (!entries)
|
|
22
|
-
return undefined;
|
|
23
|
-
for (const entry of entries) {
|
|
24
|
-
if (!/^\d+$/.test(entry) || Number(entry) === process.pid)
|
|
25
|
-
continue;
|
|
26
|
-
let stat;
|
|
27
|
-
try {
|
|
28
|
-
stat = await fs.readFile(`/proc/${entry}/stat`, 'utf8');
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
// Only a process that is gone has no stat; any other failure leaves its group unknown.
|
|
32
|
-
if (error.code === 'ENOENT' || error.code === 'ESRCH')
|
|
33
|
-
continue;
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
// Fields after the parenthesised command name: state, ppid, pgrp.
|
|
37
|
-
const pgrp = Number(stat.slice(stat.lastIndexOf(')') + 2).split(' ')[2]);
|
|
38
|
-
if (pgrp === process.pid)
|
|
39
|
-
members.push(Number(entry));
|
|
40
|
-
}
|
|
41
|
-
return members;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* A timed-out git is killed alone; a child it started (the checkout of `worktree add`) can keep
|
|
45
|
-
* writing. Every Git child is in this keeper's process group (ADR 0003), and the keeper runs one
|
|
46
|
-
* command at a time, so the group's other members are that command's. Stop them before the caller
|
|
47
|
-
* sees the failure: `running` when some remain after 10 s, `unknown` where the host cannot list them.
|
|
48
|
-
*/
|
|
49
|
-
async function stopTimedOutChildren() {
|
|
50
|
-
// Windows has no process groups to signal or list: its children may still run.
|
|
51
|
-
if (process.platform === 'win32')
|
|
52
|
-
return 'unknown';
|
|
53
|
-
// The keeper is in its own group too: it ignores this one signal until the wait ends.
|
|
54
|
-
const ignore = () => undefined;
|
|
55
|
-
process.on('SIGTERM', ignore);
|
|
56
|
-
try {
|
|
57
|
-
try {
|
|
58
|
-
process.kill(-process.pid, 'SIGTERM');
|
|
59
|
-
}
|
|
60
|
-
catch { /* no other member */ }
|
|
61
|
-
for (let waited = 0; waited < 10_000; waited += 50) {
|
|
62
|
-
const members = await groupMembers();
|
|
63
|
-
if (!members)
|
|
64
|
-
return 'unknown';
|
|
65
|
-
if (!members.length)
|
|
66
|
-
return 'stopped';
|
|
67
|
-
await new Promise(resolve => setTimeout(resolve, 50));
|
|
68
|
-
}
|
|
69
|
-
return 'running';
|
|
70
|
-
}
|
|
71
|
-
finally {
|
|
72
|
-
process.off('SIGTERM', ignore);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
export async function readMutationClaim(path, platform, probe) {
|
|
76
|
-
let value;
|
|
77
|
-
try {
|
|
78
|
-
value = JSON.parse(await fs.readFile(path, 'utf8'));
|
|
79
|
-
}
|
|
80
|
-
catch (error) {
|
|
81
|
-
if (error.code === 'ENOENT')
|
|
82
|
-
return;
|
|
83
|
-
throw error;
|
|
84
|
-
}
|
|
85
|
-
if (!Number.isSafeInteger(value.pid) || value.pid <= 0 || !Number.isSafeInteger(value.ticket) || value.ticket < 0)
|
|
86
|
-
throw new Error('invalid worktree mutation claim');
|
|
87
|
-
// POSIX group lifetime survives the death of its keeper/leader: Git and
|
|
88
|
-
// its children inherit this group. Only ESRCH proves EVERY member gone.
|
|
89
|
-
// Do not replace this kernel probe with a PID/ps snapshot (forks can race it).
|
|
90
|
-
if (platform === 'win32') {
|
|
91
|
-
try {
|
|
92
|
-
probe(value.pid);
|
|
93
|
-
}
|
|
94
|
-
catch (error) {
|
|
95
|
-
if (error.code === 'ESRCH') {
|
|
96
|
-
// Re-read AFTER death is established. The first idle snapshot may
|
|
97
|
-
// predate a last command's busy publication and spawn. The unique
|
|
98
|
-
// filename cannot now be updated by its dead owner or a new keeper.
|
|
99
|
-
let final;
|
|
100
|
-
try {
|
|
101
|
-
final = JSON.parse(await fs.readFile(path, 'utf8'));
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
if (error.code === 'ENOENT')
|
|
105
|
-
return;
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
if (final && final.pid === value.pid && Number.isSafeInteger(final.ticket) && final.ticket >= 0 && final.gitRunning === false) {
|
|
109
|
-
await fs.unlink(path).catch(() => undefined);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
throw new Error('cannot prove a dead worktree keeper has no surviving Git children on Windows');
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
try {
|
|
118
|
-
probe(-value.pid);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
if (error.code === 'ESRCH') {
|
|
122
|
-
// Each claimant owns a unique filename, so recovery cannot unlink a new
|
|
123
|
-
// owner's lock (the ABA race of unlinking/replacing one shared lockfile).
|
|
124
|
-
await fs.unlink(path).catch(() => undefined);
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
// EPERM/unknown means possibly alive: never steal that claim.
|
|
128
|
-
}
|
|
129
|
-
return value;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Lamport bakery: choose a ticket above every visible ticket.
|
|
133
|
-
* Atomic rename keeps readers from observing partial JSON.
|
|
134
|
-
*/
|
|
135
|
-
async function selectTicket(directory, name, read) {
|
|
136
|
-
let ticket = 1;
|
|
137
|
-
for (const entry of await fs.readdir(directory)) {
|
|
138
|
-
if (!entry.endsWith('.json') || entry === name)
|
|
139
|
-
continue;
|
|
140
|
-
const claim = await read(entry);
|
|
141
|
-
if (claim)
|
|
142
|
-
ticket = Math.max(ticket, claim.ticket + 1);
|
|
143
|
-
}
|
|
144
|
-
return ticket;
|
|
145
|
-
}
|
|
146
|
-
/** A peer holds the turn while it is still choosing or holds a smaller (ticket, name) pair. */
|
|
147
|
-
function hasPriority(claim, ticket, entry, name) {
|
|
148
|
-
return claim.ticket === 0 || claim.ticket < ticket || (claim.ticket === ticket && entry < name);
|
|
149
|
-
}
|
|
150
|
-
/** The blocker whose turn it is: the smallest (ticket, name) pair; a peer still choosing (ticket 0) only when no other blocks. */
|
|
151
|
-
function turnHolder(blockers) {
|
|
152
|
-
const order = (value) => value.claim.ticket === 0 ? Number.MAX_SAFE_INTEGER : value.claim.ticket;
|
|
153
|
-
const first = blockers.reduce((best, next) => order(next) - order(best) < 0 || (order(next) === order(best) && next.entry < best.entry) ? next : best);
|
|
154
|
-
const { pid, operation, owner } = first.claim;
|
|
155
|
-
return { pid, ...(typeof operation === 'string' ? { operation } : {}), ...(typeof owner === 'string' ? { owner } : {}) };
|
|
156
|
-
}
|
|
157
|
-
/** Wait for choosing peers and smaller (ticket, name) pairs, or give up naming the claim whose turn it is. */
|
|
158
|
-
async function waitForTurn(directory, name, ticket, options) {
|
|
159
|
-
for (;;) {
|
|
160
|
-
if (options.isStopping())
|
|
161
|
-
return { turn: 'stopped' };
|
|
162
|
-
const late = Date.now() >= options.deadline;
|
|
163
|
-
const blockers = [];
|
|
164
|
-
for (const entry of await fs.readdir(directory)) {
|
|
165
|
-
if (!entry.endsWith('.json') || entry === name)
|
|
166
|
-
continue;
|
|
167
|
-
const claim = await options.read(entry);
|
|
168
|
-
if (claim && hasPriority(claim, ticket, entry, name))
|
|
169
|
-
blockers.push({ claim, entry });
|
|
170
|
-
// Before the deadline one blocker is enough; past it, read them all to name the right one.
|
|
171
|
-
if (blockers.length && !late)
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
const [head, ...rest] = blockers;
|
|
175
|
-
if (!head)
|
|
176
|
-
return { turn: 'ready' };
|
|
177
|
-
if (late)
|
|
178
|
-
return { turn: 'timeout', holder: turnHolder([head, ...rest]) };
|
|
179
|
-
await options.wait();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
/** The claims queued ahead of a ticket: those that can block it, a peer still choosing included.
|
|
183
|
-
* A peer that published a higher ticket before this count is behind it and does not count. */
|
|
184
|
-
async function claimsAhead(directory, name, ticket, read) {
|
|
185
|
-
let ahead = 0;
|
|
186
|
-
for (const entry of await fs.readdir(directory)) {
|
|
187
|
-
if (!entry.endsWith('.json') || entry === name)
|
|
188
|
-
continue;
|
|
189
|
-
const claim = await read(entry);
|
|
190
|
-
if (claim && hasPriority(claim, ticket, entry, name))
|
|
191
|
-
ahead += 1;
|
|
192
|
-
}
|
|
193
|
-
return ahead;
|
|
194
|
-
}
|
|
195
|
-
/** The longest any wait may last, its queue share included. */
|
|
196
|
-
export const MAX_QUEUED_WAIT_MS = 600_000;
|
|
197
|
-
/** The wait budget for a claim with `ahead` claims queued before it: the base, plus `perClaimMs` for each, at most 10 min. */
|
|
198
|
-
export function queuedWaitBudget(waitMs, perClaimMs, ahead) {
|
|
199
|
-
return Math.max(waitMs, Math.min(MAX_QUEUED_WAIT_MS, waitMs + perClaimMs * ahead));
|
|
200
|
-
}
|
|
201
|
-
/** The keeper's per-claim wait argument in ms: a whole number from 0 to 600 000, 0 when absent. */
|
|
202
|
-
export function keeperPerClaimBudget(value) {
|
|
203
|
-
const perClaimMs = Number(value ?? 0);
|
|
204
|
-
if (!Number.isSafeInteger(perClaimMs) || perClaimMs < 0 || perClaimMs > MAX_QUEUED_WAIT_MS)
|
|
205
|
-
throw new Error('invalid worktree mutation wait budget');
|
|
206
|
-
return perClaimMs;
|
|
207
|
-
}
|
|
208
|
-
/** The keeper's label argument: JSON with a non-empty `operation` and an optional `owner`; none when absent. */
|
|
209
|
-
export function keeperLabel(value) {
|
|
210
|
-
if (!value)
|
|
211
|
-
return undefined;
|
|
212
|
-
const parsed = JSON.parse(value);
|
|
213
|
-
if (typeof parsed.operation !== 'string' || !parsed.operation || (parsed.owner !== undefined && typeof parsed.owner !== 'string'))
|
|
214
|
-
throw new Error('invalid worktree mutation label');
|
|
215
|
-
return { operation: parsed.operation.slice(0, 80), ...(parsed.owner ? { owner: parsed.owner.slice(0, 80) } : {}) };
|
|
216
|
-
}
|
|
217
|
-
/** The keeper's wait budget argument in ms: a whole number from 0 to 120 000, 120 000 when absent. */
|
|
218
|
-
export function keeperWaitBudget(value) {
|
|
219
|
-
const waitMs = Number(value ?? 120_000);
|
|
220
|
-
if (!Number.isSafeInteger(waitMs) || waitMs < 0 || waitMs > 120_000)
|
|
221
|
-
throw new Error('invalid worktree mutation wait budget');
|
|
222
|
-
return waitMs;
|
|
223
|
-
}
|
|
224
|
-
/** Short-lived IPC keeper; launched only by git-worktree-lock.ts. */
|
|
225
|
-
async function keepWorktreeLock() {
|
|
226
|
-
const { join } = await import('node:path');
|
|
227
|
-
const { randomUUID } = await import('node:crypto');
|
|
228
|
-
const directory = process.argv[2];
|
|
229
|
-
const name = `${process.pid}-${randomUUID()}.json`;
|
|
230
|
-
const path = join(directory, name);
|
|
231
|
-
const temporary = `${path}.tmp`;
|
|
232
|
-
const wait = () => new Promise(resolve => setTimeout(resolve, 25));
|
|
233
|
-
let stopping = !process.connected;
|
|
234
|
-
let keepClaim = false;
|
|
235
|
-
let stop;
|
|
236
|
-
const stopped = new Promise(resolve => { stop = resolve; });
|
|
237
|
-
let commands = Promise.resolve();
|
|
238
|
-
process.on('disconnect', () => { stopping = true; stop(); });
|
|
239
|
-
const send = (message) => { if (process.connected)
|
|
240
|
-
process.send(message, () => undefined); };
|
|
241
|
-
const label = keeperLabel(process.argv[5]);
|
|
242
|
-
const write = async (ticket, gitRunning = false) => {
|
|
243
|
-
await fs.writeFile(temporary, JSON.stringify({ pid: process.pid, ticket, gitRunning, ...label }), { mode: 0o600 });
|
|
244
|
-
await fs.rename(temporary, path);
|
|
245
|
-
};
|
|
246
|
-
const read = (entry) => readMutationClaim(join(directory, entry), process.platform, pid => { process.kill(pid, 0); });
|
|
247
|
-
try {
|
|
248
|
-
await fs.mkdir(directory, { recursive: true });
|
|
249
|
-
// Lamport bakery: publish "choosing" atomically, then choose a ticket above
|
|
250
|
-
// every visible ticket. Atomic rename keeps readers from observing partial JSON.
|
|
251
|
-
await write(0);
|
|
252
|
-
const ticket = await selectTicket(directory, name, read);
|
|
253
|
-
await write(ticket);
|
|
254
|
-
const budget = queuedWaitBudget(keeperWaitBudget(process.argv[3]), keeperPerClaimBudget(process.argv[4]), await claimsAhead(directory, name, ticket, read));
|
|
255
|
-
const turn = await waitForTurn(directory, name, ticket, { read, isStopping: () => stopping, deadline: Date.now() + budget, wait });
|
|
256
|
-
if (turn.turn === 'timeout')
|
|
257
|
-
send({ kind: 'error', code: 'lock_timeout', error: 'timed out waiting for worktree mutation lock', ...(turn.holder ? { holder: turn.holder } : {}) });
|
|
258
|
-
if (turn.turn !== 'ready')
|
|
259
|
-
return; // finally withdraws ONLY this queued claim; no mutation was admitted
|
|
260
|
-
process.on('message', (message) => {
|
|
261
|
-
if (stopping || message.kind !== 'git')
|
|
262
|
-
return;
|
|
263
|
-
commands = commands.then(async () => {
|
|
264
|
-
// A command whose children may still write admits no further mutation.
|
|
265
|
-
if (keepClaim)
|
|
266
|
-
throw new Error('Git child processes of a timed-out command may still be running');
|
|
267
|
-
await write(ticket, true);
|
|
268
|
-
const result = await runGitCommand(message);
|
|
269
|
-
// Their claim outlives this keeper: the group probe frees it once every member is gone
|
|
270
|
-
// (readMutationClaim). Set before the next write, so a failed write cannot release it. Windows
|
|
271
|
-
// has no such probe; a claim kept there could never be freed, so it is released as before and
|
|
272
|
-
// only the rollback and retry are skipped.
|
|
273
|
-
if (result.childrenRunning && process.platform !== 'win32')
|
|
274
|
-
keepClaim = true;
|
|
275
|
-
await write(ticket);
|
|
276
|
-
send({ kind: 'result', id: message.id, result });
|
|
277
|
-
}).catch(error => {
|
|
278
|
-
send({ kind: 'error', error: `worktree mutation command failed: ${String(error)}` });
|
|
279
|
-
stopping = true;
|
|
280
|
-
stop();
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
send({ kind: 'ready' });
|
|
284
|
-
await stopped;
|
|
285
|
-
}
|
|
286
|
-
catch (error) {
|
|
287
|
-
send({ kind: 'error', error: `worktree mutation coordination failed: ${String(error)}` });
|
|
288
|
-
}
|
|
289
|
-
finally {
|
|
290
|
-
await commands;
|
|
291
|
-
if (!keepClaim)
|
|
292
|
-
await fs.unlink(path).catch(() => undefined);
|
|
293
|
-
await fs.unlink(temporary).catch(() => undefined);
|
|
294
|
-
if (process.connected)
|
|
295
|
-
process.disconnect();
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
if (process.argv[1] === fileURLToPath(import.meta.url))
|
|
299
|
-
await keepWorktreeLock();
|
|
300
|
-
//# sourceMappingURL=git-worktree-lock-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"git-worktree-lock-helper.js","sourceRoot":"","sources":["../src/git-worktree-lock-helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAoB,MAAM,kBAAkB,CAAC;AAY5D,4FAA4F;AAC5F,KAAK,UAAU,aAAa,CAAC,OAAsB;IACjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CACrJ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CA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,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;gBACrF,QAAQ,GAAG,IAAI,CAAC;gBAChB,IAAI,EAAE,CAAC;YACT,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QACxB,MAAM,OAAO,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,0CAA0C,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IAC5F,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC;QACf,IAAI,CAAC,SAAS;YAAE,MAAM,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC7D,MAAM,EAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAClD,IAAI,OAAO,CAAC,SAAS;YAAE,OAAO,CAAC,UAAU,EAAE,CAAC;IAC9C,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC;IAAE,MAAM,gBAAgB,EAAE,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{N as r,en as i,qt as a}from"./queries-IlC9MZgh.js";import{m as o}from"./host-context-DDbYAKpm.js";import{mn as s}from"./toaster-DNnL8v10.js";import{m as c,n as l,p as u}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as d}from"./dist-CCX8mhHc.js";import{J as f,Q as p,V as m,c as h,d as g,mt as _,pt as v,st as y,y as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{t as S}from"./check-OP-CVgZG.js";import{t as C}from"./chevron-right-BENZ-1ZN.js";import{n as w}from"./smartphone-Lr8Ug2z_.js";import{t as T}from"./loader-circle-CPBhhDbB.js";import{t as ee}from"./message-square-B-MD-8rD.js";import{n as te,t as ne}from"./tool-display-CTbToGmi.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-BV_AiLj2.js";import{n as O,r as k,t as A}from"./collapsible-D5i3hm2L.js";import{t as j}from"./project-router-Dc6KBQsv.js";import{a as M,c as re,i as ie,l as ae,o as oe,s as se,t as ce}from"./report-selection-CZ8eb9QP.js";import{r as le}from"./html-report-BX3msvci.js";import{S as ue,pr as de,un as fe,vr as N,wn as pe,wr as me,x as he}from"./index-Dp7K74Jw.js";import{t as ge}from"./zoomable-image-CULOtYYp.js";import{t as P}from"./textarea-BGp28xFr.js";import{t as F}from"./markdown-BB-PN03o.js";import{t as _e}from"./task-file-scope-BuFeMG6a.js";import{t as ve}from"./report-title-D4Mbu2Er.js";var ye=x(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),be=x(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),xe=x(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),I=x(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Se=x(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),L=e(t(),1),R=n();function Ce(e,t){if(e.length===1)return[t.replace(RegExp(`^${we(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Te(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Ee=`
|
|
2
|
-
|
|
3
|
-
Additional comments:
|
|
4
|
-
`;function De(e){let t=e.indexOf(Ee);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function Oe({ask:e}){let t=e.answer===void 0?void 0:De(e.answer),n=t===void 0?void 0:Ce(e.questions,t.body);return(0,R.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Te(t,i),o=i!==void 0&&a.length===0;return(0,R.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,R.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,R.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,R.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,R.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,R.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,R.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,R.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,R.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,R.jsx)(z,{text:i}):null]})]}):i===void 0?null:(0,R.jsx)(z,{text:i})]},t.id??r)}),n&&t?.comment?(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,R.jsx)(z,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,R.jsx)(z,{text:e.answer}):null]})}function z({text:e}){return(0,R.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function B(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function ke(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ae({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:a,showContextButtonRef:o,onOpenContext:s,onShowOrigin:c}){return(0,R.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,R.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[a?(0,R.jsxs)(D,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:s,children:[(0,R.jsx)(N,{"aria-hidden":`true`,className:`size-3.5`}),`Show context`]}):c?(0,R.jsx)(Le,{onShowOrigin:c}):null,r?(0,R.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":t===`options`,onClick:()=>n(`options`),className:d(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":t===`reply`,onClick:()=>n(`reply`),className:d(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]}):null]})]})}function je({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:a}){let o=e.length;return(0,R.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let o=t===i,s=B(i,n,r);return(0,R.jsxs)(`button`,{type:`button`,"aria-current":o?`step`:void 0,onClick:()=>a(i),className:d(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,o?`border-accent-strong bg-accent-strong/15 text-foreground`:s?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:s?(0,R.jsx)(S,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,R.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,R.jsxs)(`button`,{type:`button`,"aria-current":t===o?`step`:void 0,onClick:()=>a(o),className:d(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===o?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3`}),(0,R.jsx)(`span`,{children:`Comment`})]})]})}function Me({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:a,onJumpToQuestion:o}){let s=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,R.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=B(r,t,n);return(0,R.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,R.jsx)(`span`,{className:d(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:ke(r,t,n)})]},e.id??r)})})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:s,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:s,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>a(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Ne({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,L.useId)();return r?(0,R.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,R.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,R.jsx)(P,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function Pe({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:a,disabled:o,onBack:s,onNext:c,onOpenComment:l,onSend:u,questions:f,selections:p,otherAnswers:m,stopControl:h}){let g=e===t-1,_=e===t,v=a?`Send answer & reopen`:`Send answer`;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:s,children:[(0,R.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,R.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,i=B(n,p,m);return(0,R.jsx)(`span`,{className:d(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,R.jsx)(`span`,{className:d(`size-2 rounded-full motion-safe:transition-colors`,_?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,R.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),a?(0,R.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,!g&&!_?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[`Next`,(0,R.jsx)(C,{"aria-hidden":`true`,className:`size-4`})]}):null,g?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:i?`Edit comment`:`+ Comment`}):null,g||_||r?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o||!r,onClick:u,children:v}):null]})]})}function Fe({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,R.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,(0,R.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,R.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ie({blockedBy:e,reason:t,error:n}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,R.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function Le({onShowOrigin:e,className:t}){return(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:d(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function Re({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,L.useRef)(!1);return(0,R.jsx)(ie,{open:e,onOpenChange:t,children:(0,R.jsxs)(oe,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,R.jsxs)(re,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,R.jsx)(ae,{children:`Question context`}),(0,R.jsx)(se,{children:`Your selections and drafts stay intact while you read.`}),(0,R.jsx)(M,{asChild:!0,children:(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,R.jsx)(_,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,R.jsx)(_e,{runId:n,children:(0,R.jsx)(F,{breaks:!0,children:r})})}),i?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Be=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ve(e){return e.replaceAll(`'`,`'\\''`)}function He(e){return e===``?`''`:Be.test(e)?e:`\u0027${Ve(e)}\u0027`}function Ue(e){if(!ze(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(He).join(` `)}}function We(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Ge(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ke(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function V(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function qe(e){let t=We(Ge(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))V(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){V(e[2])&&i.push({label:Ke(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ke(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&V(t)&&i.push({label:t,href:t})}return i}var Je=(0,L.createContext)(void 0),Ye=(0,L.createContext)(void 0);function H(e,t){let n=new Map;for(let r of qe(e)){let e=ue(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function U(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Xe({text:e,messageKey:t}){let n=(0,L.useContext)(he),r=(0,L.useContext)(Ye),i=t??r;if(!n||i===void 0)return null;let a=H(e,n);return a.length===0?null:(0,R.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,R.jsx)(Ze,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Ze({reference:e,messageKey:t}){let{artifactId:n,runId:i,label:a,href:o}=e,s=(0,L.useContext)(Je),d=(0,L.useContext)(ce);(0,L.useLayoutEffect)(()=>d?.register(n,i),[d,n,i]);let f=r(i,n),p=u(),m=c();if(f.isError)return(0,R.jsx)(l,{id:U(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:a});let h=f.data?.artifact;if(h&&!le(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,R.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":i,"aria-busy":f.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,R.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?ve(h):a}),(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,R.jsx)(l,{id:U(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${f.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Qe={message:!0,reasoning:!0,tool:!0,hook:!0};function $e(e){return Object.hasOwn(Qe,e)&&Qe[e]}var W=e=>e.kind===`tool`,et=e=>e.kind===`conversation`,tt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,nt=(e,t,n)=>`${e} ${e===1?t:n}`;function rt(e,t){let n=[];return e>0&&n.push(nt(e,`file`,`files`)),t>0&&n.push(nt(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function it(e){return`${e} earlier tool call${e===1?``:`s`}`}var at=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ot(e){for(let t of at)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var st=new WeakMap;function ct(e){let t=st.get(e);if(t)return t;let n=lt(e);return st.set(e,n),n}function lt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(W).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=$e(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:rt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of ut(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(et(e)){s(),c.push(e);continue}l(),W(e)&&tt(e)&&!r.has(e.id)?o.push(e):(s(),W(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function ut(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var G=new Map,dt=(0,L.createContext)(null);function K(){return(0,L.useContext)(dt)}function ft({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>G.get(e)?.get(t),set:(t,n)=>{let r=G.get(e)??new Map;r.set(t,n),G.set(e,r)}}),[e]);return(0,R.jsx)(dt.Provider,{value:n,children:t})}function pt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function mt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function ht(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function gt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function _t(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var vt=new Map;function yt(e,t){vt.set(e,t)}function bt(e){return vt.get(e)}var q=new Map;function xt(e,t){q.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function St(e){return q.get(e)}function Ct(e,t,n){let r=q.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var wt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Tt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Et=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Dt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Ot=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function J(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Y(e){let t=J(e);return t===void 0?void 0:wt.format(t)}function kt(e){let t=J(e);return t===void 0?void 0:Tt.format(t)}var X=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function At(e){let t=J(e);return t===void 0?void 0:X(t)}function jt(e,t=new Date){let n=J(e);if(n===void 0)return;let r=X(n);return r===X(t)?`Today`:r===X(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Et:Dt).format(n)}function Mt(e,t){let n=J(e),r=J(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Nt({ts:e}){let t=Y(e);return t===void 0?null:(0,R.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:kt(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Pt({startedAt:e,completedAt:t}){let n=Y(t);if(n===void 0)return null;let r=Mt(e,t);return(0,R.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,R.jsx)(`time`,{dateTime:t,title:kt(t),children:n}),r===void 0?null:(0,R.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ft({ts:e}){let t=jt(e),n=J(e);if(t===void 0||n===void 0)return null;let r=Ot.format(n);return(0,R.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,R.jsx)(`time`,{dateTime:At(e),title:r,children:t}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var It={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Lt({note:e}){return e.icon===`handoff`?(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,R.jsx)(de,{className:`size-3`})}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,R.jsxs)(A,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,R.jsxs)(`div`,{className:d(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,R.jsxs)(k,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,R.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,R.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,R.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[It[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:d(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Rt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Z({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Rt[e],s=r===void 0?void 0:Y(r);return(0,R.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:d(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,R.jsxs)(`p`,{className:d(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,R.jsx)(ee,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,R.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,R.jsx)(Nt,{ts:r})})]}),(0,R.jsx)(`div`,{className:d(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}var zt=[],Bt=(0,L.memo)(function({text:e,imageCount:t=0,images:n=zt,ts:r,onEdit:i,onRemove:a,editLabel:c=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(e),[_,v]=(0,L.useState)(!1),[b,x]=(0,L.useState)(),S=()=>{g(e),x(void 0),m(!0)},C=async()=>{let t=h.trim();if(!t||t===e){m(!1);return}v(!0),x(void 0);try{await i?.(t),m(!1)}catch(e){x(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),x(void 0);try{await a?.()}catch(e){x(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return p?(0,R.jsxs)(Z,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,R.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),m(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,R.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>m(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,R.jsx)(T,{className:`size-3.5 animate-spin`}):`Save`})]}),b?(0,R.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:b}):null]}):(0,R.jsxs)(Z,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,R.jsx)(`button`,{type:`button`,"aria-label":c,onClick:S,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(Se,{className:`size-3.5`})}):null,a?(0,R.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(y,{className:`size-3.5`})}):null]}):null,b?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:b}):null,u??(0,R.jsx)(F,{breaks:!0,children:e}),n.length>0?(0,R.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>s(e.split(`/`).pop()??``)?(0,R.jsx)(ge,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,R.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,R.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),Vt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Ht=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ut(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Ht).forEach(e=>e.remove());let r=qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!V(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Wt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Ut(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Gt=(0,L.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,L.useRef)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),c=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Wt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,R.jsxs)(Z,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Vt,children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Vt,children:[(0,R.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,R.jsx)(`div`,{ref:r,children:(0,R.jsx)(F,{breaks:!0,children:e})}),(0,R.jsx)(Xe,{text:e,messageKey:n})]})});function Kt({incident:e}){let t=i().data;if(!t)return null;let n=a(t,e.provider);return(0,R.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,R.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,R.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var qt=(0,L.memo)(function({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
|
|
5
|
-
`,1)[0]??``,r=n.length<e.length;return(0,R.jsxs)(A,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,R.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,R.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,R.jsx)(F,{inline:!0,children:n})}),r?(0,R.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,R.jsx)(k,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,R.jsx)(F,{children:e})})})]})});function Jt(){return(0,R.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,R.jsx)(T,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,R.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Yt={read:N,edit:Se,delete:y,move:xe,search:p,execute:E,think:be,fetch:w,task:h,plan:m,other:v},Xt=e=>e.split(`
|
|
6
|
-
`).length;function Zt({text:e,streaming:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(null),a=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=Xt(e),s=!t&&!n&&o>12;return(0,R.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=gt(e.currentTarget)}:void 0,className:d(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,R.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,R.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,R.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function Qt({diffs:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,R.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...$t(e.oldText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...$t(e.newText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
|
|
7
|
-
`).map((e,t)=>(0,R.jsx)(en,{text:e},t))})]},`${e.path}:${t}`))})}function $t(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
|
|
8
|
-
`)}function en({text:e}){return(0,R.jsx)(`span`,{className:d(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function tn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function nn(e){let t=e.status===`running`||e.status===`pending`,n=ot(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Ue(e.input):te(e.name).toolKind===e.toolKind?ne(e.name,e.input):void 0)??i,Icon:Yt[e.toolKind]??v}}function rn(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function an({item:e,busy:t}){return(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,R.jsx)(T,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,R.jsx)(`span`,{"data-slot":`tool-exit`,className:d(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function on({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,R.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,R.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,R.jsx)(Qt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,R.jsx)(Zt,{text:e.output,streaming:n}):null,r.length>0?(0,R.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function sn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=K(),[a,o]=(0,L.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:c,verb:l,detail:u,expandedCommand:f,Icon:p}=nn(e),m=rn(e,t.length),h=f!==void 0||m,_=h&&(a??(m&&tn(e)));return(0,R.jsxs)(A,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:_,onOpenChange:s,className:d(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:d(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,R.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:d(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:l}),u===void 0?null:(0,R.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,R.jsx)(an,{item:e,busy:c})]}),(0,R.jsx)(O,{children:(0,R.jsx)(on,{item:e,command:f,busy:c,nested:t,cacheKey:n,renderNested:r})})]})}function cn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function ln({item:e,cacheKey:t}){let n=K(),[r,i]=(0,L.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),c=(e.stdout??``)!==``||(e.stderr??``)!==``,l=cn(e);return(0,R.jsxs)(A,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:d(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,R.jsx)(ye,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,R.jsx)(`code`,{title:l,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:l}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,R.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,R.jsx)(O,{children:(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,R.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:d(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,R.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),c?(0,R.jsxs)(A,{className:`border-t border-border`,children:[(0,R.jsxs)(k,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,R.jsxs)(O,{children:[e.stdout?(0,R.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,R.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function un({group:e,scope:t}){return(0,R.jsxs)(A,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,R.jsx)(sn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function dn({count:e,children:t}){return(0,R.jsxs)(A,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),it(e)]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function fn({image:e}){return(0,R.jsx)(ge,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var pn={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function mn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function hn(e,t,n,r=``){let i=e.map((e,r)=>mn(e,t[r]??[],n[r])).join(`
|
|
9
|
-
`),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function gn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`}){let h=m===`transcript`&&e.context?(0,R.jsx)(Q,{text:e.context}):null;if(e.resolved)return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,R.jsx)(Q,{text:e.context}):null,(0,R.jsxs)(Z,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?pn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,R.jsx)(Oe,{ask:e})]})]});let g=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(_n,{ask:e,runId:t.id,surface:m,onShowOrigin:g})]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(xn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:g,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p})]})}function Q({text:e}){return(0,R.jsx)(Z,{role:`agent`,children:(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,R.jsx)(F,{breaks:!0,children:e})})})}function _n({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,R.jsx)(D,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,R.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,R.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,R.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,R.jsxs)(`li`,{className:`break-words`,children:[(0,R.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,R.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,R.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,R.jsx)(j,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,R.jsx)(Le,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,R.jsx)(Re,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function vn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,L.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)({}),[_,v]=(0,L.useState)({}),[y,b]=(0,L.useState)(``),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(``),[T,ee]=(0,L.useState)(!1),te=s&&p===c,ne=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;pe(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let E=(e,t)=>g(n=>({...n,[e]:t})),D=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),O=e=>{E(e,[]),v(t=>({...t,[e]:t[e]??``}))},k=o.some((e,t)=>!e.options||_[t]!==void 0),A=o.filter((e,t)=>B(t,h,_)).length,j=A===o.length,M=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:ee,onCommentStep:te,oneTap:ne,setQuestion:E,clearOtherAnswer:D,selectOther:O,hasOtherAnswer:k,answeredCount:A,allAnswered:j,deliver:M,sendAll:()=>void M(hn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&M(e).then(e=>{e===void 0&&w(``)})}}}function yn({state:e,renderFreeTextReply:t}){let n=(0,L.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,R.jsx)(Ne,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,R.jsx)(Me,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(mn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,R.jsxs)(`div`,{className:`pt-1`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function bn({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e))})};return(0,R.jsxs)(R.Fragment,{children:[e?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`px-3`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`px-3`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function xn(e){return e.delivery===void 0?(0,R.jsx)(Sn,{...e}):(0,R.jsx)($,{...e,delivery:e.delivery})}function Sn(e){let t=fe(e.run,e.projectId);return(0,R.jsx)($,{...e,delivery:t})}function $({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:f,hideReplyBody:p,delivery:m}){let h=vn(e,m,u,f,i),[g,_]=(0,L.useState)(void 0),v=(0,L.useRef)(null),y=h.delivery.mode===`resume`,b=n===`decision-zone`||a!==void 0,x=n===`decision-zone`&&!!e.context,S=h.additionalComment.trim()!==``,C=h.mode===`reply`&&p,w=(0,R.jsx)(bn,{onFinish:c,finishing:l,onStop:o,stopping:s,onActionError:_});return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":h.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":h.delivery.mode,className:d(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,C&&`rounded-b-none border-b-0`),children:[(0,R.jsx)(Ae,{stepped:h.stepped,mode:h.mode,onModeChange:h.setMode,showModeSwitch:b,stepLabel:h.onCommentStep?`Comment (optional)`:`${h.stepIndex+1} of ${h.questions.length}`,hasSheetContext:x,showContextButtonRef:v,onOpenContext:()=>h.setContextOpen(!0),onShowOrigin:x?void 0:r}),h.stepped&&h.mode===`options`?(0,R.jsx)(je,{questions:h.questions,stepIndex:h.stepIndex,selections:h.selections,otherAnswers:h.otherAnswers,hasComment:S,onSelectStep:h.setStepIndex}):null,C?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,R.jsx)(yn,{state:h,renderFreeTextReply:a})}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,R.jsx)(Cn,{state:h,hasComment:S,resuming:y,hasCustomReply:a!==void 0,stopControl:w}),(0,R.jsx)(Ie,{blockedBy:h.delivery.blockedBy,reason:h.delivery.reason,error:h.delivery.error??g})]})]}),x&&e.context?(0,R.jsx)(Re,{open:h.contextOpen,onOpenChange:h.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:v}):null]})}function Cn({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i}){return e.mode===`reply`?r?null:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,R.jsx)(Pe,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i}):(0,R.jsx)(Fe,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i})}function wn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,L.useId)(),l=(0,L.useRef)(null),u=(0,L.useRef)(r),f=e.options,p=f!==void 0,m=p&&e.multiSelect===!0;(0,L.useEffect)(()=>{let e=r&&!u.current;u.current=r,e&&p&&l.current?.focus()},[r,p]);let h=e=>{if(!m){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,R.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,R.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,R.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[f.map(e=>{let r=n.includes(e.label);return(0,R.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:d(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:d(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,R.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,R.jsx)(D,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,size:`block`,className:d(`px-2.5`,f.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{ref:l,id:c,rows:2,value:i,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{id:c,rows:2,value:i,disabled:t,placeholder:`Type your answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{K as A,Ct as C,ht as D,yt as E,Je as F,U as I,H as L,ot as M,$e as N,_t as O,Ye as P,Oe as R,St as S,xt as T,Y as _,ln as a,gt as b,qt as c,Bt as d,Jt as f,Pt as g,Nt as h,un as i,ct as j,ft as k,sn as l,Ft as m,Q as n,fn as o,Lt as p,Gt as r,Kt as s,gn as t,dn as u,At as v,bt as w,pt as x,mt as y,I as z};
|