@bivy/bivy 0.20.1-staging.6 → 0.20.1-staging.7
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/bin/bivy.mjs +27 -0
- package/bin/cli-commands.mjs +2 -0
- package/bin/guides/talk-to-the-user.md +7 -0
- package/dist/agent-instructions.js +2 -0
- package/dist/server.js +15 -8
- package/dist/session/session-namer.js +8 -2
- package/dist/session/session-tokens.js +1 -1
- package/package.json +1 -1
- package/web/assets/{AutomationsView-C5FTAk5H.js → AutomationsView-BJ3gBIGf.js} +1 -1
- package/web/assets/{ChangesCard-Bq3EQIem.js → ChangesCard-BzRQTCVs.js} +1 -1
- package/web/assets/{LibraryView-DrOvEcbv.js → LibraryView-C6mluzPl.js} +1 -1
- package/web/assets/{ProviderConnect-B5UJ6o1x.js → ProviderConnect-BK6oEwlu.js} +1 -1
- package/web/assets/{Settings-BV1LvpeB.js → Settings-CG236bpZ.js} +3 -3
- package/web/assets/{Sheet-Db4Mndim.js → Sheet-YqJCwCtR.js} +1 -1
- package/web/assets/{Terminal-CvIBOJzq.js → Terminal-CWjLg3i2.js} +1 -1
- package/web/assets/{VoiceSettings-96Bha24X.js → VoiceSettings-DVlH29qG.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-D2Y5sPRp.js → abnfDiagram-VCTEODGH-DR5nREn3.js} +1 -1
- package/web/assets/architecture-7GRP2DOG-Mvf9rpFA.js +1 -0
- package/web/assets/{architectureDiagram-5GKGNRK7-BRYXZYo0.js → architectureDiagram-5GKGNRK7-BTtzbbP7.js} +1 -1
- package/web/assets/{blockDiagram-I7D4REHJ-BbZ6-1wB.js → blockDiagram-I7D4REHJ-B02cXkpO.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-CvOQdXuZ.js → c4Diagram-7LVT6UL2-DuMEAvRa.js} +1 -1
- package/web/assets/channel-BETA4C1-.js +1 -0
- package/web/assets/{chunk-4HAMMTFA-BI825_ZV.js → chunk-4HAMMTFA-C3z4iXsh.js} +1 -1
- package/web/assets/{chunk-75Z2AOVW-CxSd6Zxl.js → chunk-75Z2AOVW-BaELqtNa.js} +1 -1
- package/web/assets/{chunk-DU6HZSFF-1-mK49JE.js → chunk-DU6HZSFF-BBrnNwn_.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-jlR5FL7E.js → chunk-F27PBJKO-Bfuzd8Q8.js} +1 -1
- package/web/assets/{chunk-GMAD6QVW-BBnwhF5K.js → chunk-GMAD6QVW-B0Np7gv0.js} +1 -1
- package/web/assets/{chunk-GVQU2GXP-CHUTVqWw.js → chunk-GVQU2GXP-CiZeRFSW.js} +1 -1
- package/web/assets/{chunk-IMKFNOWR-D0BbcDj6.js → chunk-IMKFNOWR-DJGDP5h1.js} +1 -1
- package/web/assets/{chunk-L3NEJ4N5-DvDZiWe-.js → chunk-L3NEJ4N5-u67SBNSZ.js} +1 -1
- package/web/assets/{chunk-OSK3NFVY-JHuvasbP.js → chunk-OSK3NFVY-DJUfOWEW.js} +1 -1
- package/web/assets/{chunk-P2QGCYS3-wjuBF4Pd.js → chunk-P2QGCYS3-CYmch4EI.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-CngK4WUA.js → chunk-POPQ4Y6H-BOjVOrGx.js} +1 -1
- package/web/assets/{chunk-PWAF6VOD-CTRtPw_P.js → chunk-PWAF6VOD-ChmjsLTV.js} +1 -1
- package/web/assets/{chunk-SHT3W25Y-ABe0cu9b.js → chunk-SHT3W25Y-BU57QSGG.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-cnVb9wRh.js → chunk-SVP7TREG-3okF7bFJ.js} +1 -1
- package/web/assets/{chunk-TICWLB2K-DfKefWT6.js → chunk-TICWLB2K-DervhtUR.js} +1 -1
- package/web/assets/classDiagram-ZZMXUADV-DG1LzruI.js +1 -0
- package/web/assets/classDiagram-v2-VYDZK3BY-DG1LzruI.js +1 -0
- package/web/assets/{cynefin-OW5HDTMX-6Eym2I8q.js → cynefin-OW5HDTMX-BpkHeQ4U.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-DMcNShU2.js → cynefinDiagram-5FMLGOSQ-BY9V3rN7.js} +1 -1
- package/web/assets/{dagre-GXQ25YYZ-jyxO30Ra.js → dagre-GXQ25YYZ-DAmjU9c2.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-DyJSgUWQ.js → diagram-S7CK7UJ4-BE7RKay-.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-Bu-awgYc.js → diagram-UQ7AKVKN-CkizMHlG.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-CDG8WcFV.js → diagram-VSXAHHWV-BELxVnhK.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-eJK6IXRm.js → diagram-VX7I27RA-C3wu2cVu.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-4bfg0YVc.js → diagram-Z3DM3KII-CYX5IZ30.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-DLpKX0PA.js → ebnfDiagram-PWID7BFC-CgyMDCw8.js} +1 -1
- package/web/assets/{erDiagram-RLTQ6QDP-C9XoVCNz.js → erDiagram-RLTQ6QDP-CC1ZIoBl.js} +1 -1
- package/web/assets/eventmodeling-NTZA5JFV-YiXMtkrP.js +1 -0
- package/web/assets/flowDiagram-HODETNUW-UVK9K8aR.js +1 -0
- package/web/assets/{ganttDiagram-EL5Y4UJY-6GH5Yrgv.js → ganttDiagram-EL5Y4UJY-CLUlox-U.js} +1 -1
- package/web/assets/{gitGraph-4MIJSDKK-DFBb9ZSe.js → gitGraph-4MIJSDKK-B_yZBnXo.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-DVuclljM.js → gitGraphDiagram-WWUBYQGX-DNGTGoq6.js} +1 -1
- package/web/assets/{index-H1S-0dr5.js → index-D-0NDZis.js} +2 -2
- package/web/assets/{info-A6RAGUB7-DS--l7eH.js → info-A6RAGUB7-O_QhqiG0.js} +1 -1
- package/web/assets/{infoDiagram-27XIBGKW-A9tXXovL.js → infoDiagram-27XIBGKW-CfBbmLPf.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-C3bulOe4.js → ishikawaDiagram-5VMMS53U-BJj25HdR.js} +1 -1
- package/web/assets/{journeyDiagram-3NMN7TZE-PFpzT1t0.js → journeyDiagram-3NMN7TZE-D547gNvv.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-C96gUxZE.js → kanban-definition-UXKFOSKX-BziklmYw.js} +1 -1
- package/web/assets/{line-Bq-4Ddcs.js → line-CjB_oA8i.js} +1 -1
- package/web/assets/{mermaid-parser.core-BQCW99Ok.js → mermaid-parser.core-Bj5-yX0d.js} +3 -3
- package/web/assets/{mermaid.core-B30Wokvl.js → mermaid.core-CWsczu0T.js} +4 -4
- package/web/assets/{mindmap-definition-YA3MSWOX-ClwtCWm0.js → mindmap-definition-YA3MSWOX-BqsBs-D4.js} +1 -1
- package/web/assets/{mount-B_ShSdyJ.js → mount-BlTXC3tw.js} +5 -5
- package/web/assets/{packet-AYTQ26CC-YkeLgzv0.js → packet-AYTQ26CC-B8U6sMom.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-CaCibFki.js → pegDiagram-XKGWAZYB-BXV85Hj-.js} +1 -1
- package/web/assets/{pie-WAS4IAKB-OyMK5OfZ.js → pie-WAS4IAKB-CD71AvCo.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-DfGlDcKu.js → pieDiagram-E7YTZNPT-DNq8_A1r.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-C8ugAM99.js → quadrantDiagram-AXDQQJYC-ZNiXqFdJ.js} +1 -1
- package/web/assets/{radar-RG4KPBEZ-DPu0k7LD.js → radar-RG4KPBEZ-CpvF1rs-.js} +1 -1
- package/web/assets/{railroad-74A4TZTK-Co59jOcB.js → railroad-74A4TZTK-BIfz4cd-.js} +1 -1
- package/web/assets/railroad-abnf-HS5TGJTU-oAj9W4Xw.js +1 -0
- package/web/assets/railroad-ebnf-LZEXJU2U-B5J5VpFh.js +1 -0
- package/web/assets/railroad-peg-WCYAUIDC-DpqDcjfx.js +1 -0
- package/web/assets/{railroadDiagram-O6MQD6OU-COh170ve.js → railroadDiagram-O6MQD6OU-Fao_FZJL.js} +1 -1
- package/web/assets/{requirementDiagram-BXWQKSXE-Dh-wxNt2.js → requirementDiagram-BXWQKSXE-QnxN_viD.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-BHOSWXWw.js → sankeyDiagram-P5KCCOFB-DDhcKN50.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-ik5jL4SR.js → sequenceDiagram-WJ2MYXX4-bVK0aV05.js} +1 -1
- package/web/assets/{stateDiagram-D77RDMKH-Be31rRv9.js → stateDiagram-D77RDMKH-CZiiW4Zy.js} +1 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-B9Vt7f0v.js +1 -0
- package/web/assets/{swimlanes-42K2YHIH-DBK3hVdk.js → swimlanes-42K2YHIH-CYgOds43.js} +1 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-CfED88ct.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-DlW5MrNZ.js → timeline-definition-24CTP7MA-CnVLFUDs.js} +1 -1
- package/web/assets/{treeView-Q6P3EWNA-CfAW_qLZ.js → treeView-Q6P3EWNA-D6CxJQkK.js} +1 -1
- package/web/assets/{treemap-WGGIJYW6-QxQMH5Y8.js → treemap-WGGIJYW6-DFCHLN8D.js} +1 -1
- package/web/assets/{useStore-BxmpBglW.js → useStore-DcIB7b1-.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-D91iwoPB.js → vennDiagram-4TSXK5OY-CX5aQZNu.js} +1 -1
- package/web/assets/{wardley-WFR3VGLG-hq1e1BaT.js → wardley-WFR3VGLG-BCPDkPQh.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-BDiSY_RF.js → wardleyDiagram-VM6X3IG4-Cf0fwWD7.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-DX1lbV1q.js → xychartDiagram-S5SC5T6Z-DalYEP3d.js} +1 -1
- package/web/index.html +1 -1
- package/web/sw.js +1 -1
- package/web/assets/architecture-7GRP2DOG-BgbAf7AC.js +0 -1
- package/web/assets/channel-Ccxgwn49.js +0 -1
- package/web/assets/classDiagram-ZZMXUADV-B_nUbchH.js +0 -1
- package/web/assets/classDiagram-v2-VYDZK3BY-B_nUbchH.js +0 -1
- package/web/assets/eventmodeling-NTZA5JFV-DB9bp7xg.js +0 -1
- package/web/assets/flowDiagram-HODETNUW-Bt84xHsk.js +0 -1
- package/web/assets/railroad-abnf-HS5TGJTU-Cw5NEYkY.js +0 -1
- package/web/assets/railroad-ebnf-LZEXJU2U-nB_gqNFI.js +0 -1
- package/web/assets/railroad-peg-WCYAUIDC-2XU5RRzN.js +0 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-DV2_zzd4.js +0 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-D_QAhSyB.js +0 -8
package/bin/bivy.mjs
CHANGED
|
@@ -2554,6 +2554,30 @@ async function cmdSuggest(args = []) {
|
|
|
2554
2554
|
console.log(c.green("Suggested in the chat. The user can start it in one tap."));
|
|
2555
2555
|
}
|
|
2556
2556
|
|
|
2557
|
+
// `bivy title "<title>" [--session <id>]` — rename the session the agent runs in.
|
|
2558
|
+
async function cmdTitle(args = []) {
|
|
2559
|
+
const usage = 'Usage: bivy title "<title>" [--session <id>] [--json]';
|
|
2560
|
+
if (args.includes("-h") || args.includes("--help")) {
|
|
2561
|
+
console.log(`${usage}\n\nRename this session in the user's session list. Use a short title that says what the work is, when the first message made a poor title or the work changed direction. --json prints {"ok","title"}.`);
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
const json = wantsJson(args);
|
|
2565
|
+
const fail = (error) => cliError(error, { json, paint: c.red });
|
|
2566
|
+
const sessionFlag = args.indexOf("--session");
|
|
2567
|
+
const title = args.filter((a, i) => !a.startsWith("-") && !(sessionFlag >= 0 && i === sessionFlag + 1)).join(" ").trim();
|
|
2568
|
+
const sessionId = resolveAttachSessionId({ sessionFlag: sessionFlag >= 0 ? args[sessionFlag + 1] : undefined, env: process.env });
|
|
2569
|
+
if (!title) return fail({ code: "usage", message: usage, exit: EXIT.usage });
|
|
2570
|
+
if (!sessionId) return fail({ code: "no_session", message: "No session id.", hint: "Run inside an agent session ($BIVY_SESSION_ID) or pass --session <id>.", next: "bivy sessions --json", exit: EXIT.usage });
|
|
2571
|
+
const config = loadConfig();
|
|
2572
|
+
if (!(await ensureNodeRunning(config))) return fail({ code: "node_unreachable", message: `Could not reach the Bivy node at ${url(config)}.`, next: "bivy status", exit: EXIT.unavailable });
|
|
2573
|
+
const res = await sessionPost(config, sessionId, "title", { title }).catch((error) => error);
|
|
2574
|
+
if (res instanceof Error) return fail({ code: "node_unreachable", message: `Could not reach the Bivy node: ${res.message}`, next: "bivy status", exit: EXIT.unavailable });
|
|
2575
|
+
const body = await res.json().catch(() => ({}));
|
|
2576
|
+
if (!res.ok) return fail(sessionHttpError("Title", res.status, body));
|
|
2577
|
+
if (json) { console.log(JSON.stringify(body)); return; }
|
|
2578
|
+
console.log(c.green(`Renamed this session to "${body.title}".`));
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2557
2581
|
// Flags shared by the session commands: `--name value` pairs and bare switches,
|
|
2558
2582
|
// with every other word collected as positional text.
|
|
2559
2583
|
function parseSessionArgs(args, valueFlags) {
|
|
@@ -6204,6 +6228,9 @@ An agent's own --help passes through, e.g. 'bivy run claude --help'.`);
|
|
|
6204
6228
|
case "suggest":
|
|
6205
6229
|
await cmdSuggest(args);
|
|
6206
6230
|
break;
|
|
6231
|
+
case "title":
|
|
6232
|
+
await cmdTitle(args);
|
|
6233
|
+
break;
|
|
6207
6234
|
case "notify":
|
|
6208
6235
|
await cmdNotify(args);
|
|
6209
6236
|
break;
|
package/bin/cli-commands.mjs
CHANGED
|
@@ -48,6 +48,8 @@ export const COMMANDS = [
|
|
|
48
48
|
tools: [{ name: "notify_user", description: "Send the user a message: a card in the chat, and a push to their phone when nobody has the app open (the push names the session, not the text). Use it when long work finishes, you are blocked, or something needs their attention. At most one push a minute per session.", input: { message: { type: "string", description: "What to tell the user.", required: true }, urgent: { type: "boolean", description: "Push even while the user has the app open." } }, argv: ["notify", { arg: "message" }, { when: "urgent", flag: "--urgent" }] }] },
|
|
49
49
|
{ name: "ask", group: "session", scope: "session", json: true, usage: 'ask "<question>" [--option A --option B] [--async]', summary: "Ask the user a question and wait for the answer", subcommands: ["status", "wait"],
|
|
50
50
|
tools: [{ name: "ask_user", description: "Ask the user a question in the chat and wait for their answer (their phone gets a push). Offer 2-8 options, or none for a free-text answer; they can always write their own. Returns {status, answer}: status is answered, dismissed (decide yourself) or expired.", input: { question: { type: "string", description: "The question.", required: true }, options: { type: "array", items: { type: "string" }, description: "Choices to pick from (2-8)." }, multiple: { type: "boolean", description: "Allow several choices." }, header: { type: "string", description: "A short label for the card." }, timeout_seconds: { type: "number", description: "How long to wait (default 600)." } }, argv: ["ask", { arg: "question" }, { flag: "--option", from: "options" }, { when: "multiple", flag: "--multi" }, { flag: "--header", from: "header" }, { flag: "--timeout", from: "timeout_seconds" }] }] },
|
|
51
|
+
{ name: "title", group: "session", scope: "session", json: true, usage: 'title "<title>"', summary: "Rename this session",
|
|
52
|
+
tools: [{ name: "set_session_title", description: "Rename this session in the user's session list. Use a short title (under 60 characters) that says what the work is, when the first message made a poor title or the work changed direction.", input: { title: { type: "string", description: "The new title.", required: true } }, argv: ["title", { arg: "title" }] }] },
|
|
51
53
|
{ name: "suggest", group: "session", scope: "session", json: true, usage: 'suggest "<task>" [--title "label"] [--run here|subagents|new]', summary: "Propose a task the user can start in one tap",
|
|
52
54
|
tools: [{ name: "suggest_task", description: "Propose a next step the user can start in one tap: in this session, through your sub-agents, or in a parallel session with its own copy of the project. Write the task as a complete instruction with paths relative to the project root. Post one per idea instead of listing them.", input: { task: { type: "string", description: "The complete instruction.", required: true }, title: { type: "string", description: "A short label for the card." }, run: { type: "string", enum: ["here", "subagents", "new"], description: "Where you recommend running it: here (builds on this conversation), subagents (independent tasks you can split across your own sub-agents; only if you have them), or new (bigger independent work in its own session). Defaults: here for one card, new for several." } }, argv: ["suggest", { arg: "task" }, { flag: "--title", from: "title" }, { flag: "--run", from: "run" }] }] },
|
|
53
55
|
{ name: "app", group: "session", scope: "session", json: true, usage: "app <publish|shot|present|share|run|…>", summary: "Live previews: publish a web/terminal/desktop app, screenshot it, present it", subcommands: ["publish", "list", "remove", "shot", "present", "share", "notes", "run", "click", "type", "key", "scroll", "drag", "move", "menu"],
|
|
@@ -41,6 +41,13 @@ instead of a bulleted list.
|
|
|
41
41
|
| `subagents` | Independent tasks you can split across your own sub-agents and report back on. Only if you have sub-agents. |
|
|
42
42
|
| `new` | Bigger independent work the user will want to follow, review or merge on its own. Default for several cards. |
|
|
43
43
|
|
|
44
|
+
## Name the session: title
|
|
45
|
+
|
|
46
|
+
bivy title "Fix login redirect loop"
|
|
47
|
+
|
|
48
|
+
The session list shows a title taken from the first message. When that doesn't
|
|
49
|
+
say what the work is, or the work changes direction, rename it. Keep it short.
|
|
50
|
+
|
|
44
51
|
## Is anyone there?
|
|
45
52
|
|
|
46
53
|
`bivy context --json` reports `userConnected` (some device has the app open) and
|
|
@@ -45,6 +45,8 @@ export const BIVY_AGENT_NOTE = [
|
|
|
45
45
|
"project root. `--run` is the one you recommend: here when it builds on this conversation, subagents for " +
|
|
46
46
|
"independent tasks you can split and supervise (only if you have sub-agents), new for bigger work worth its " +
|
|
47
47
|
"own session.",
|
|
48
|
+
'- If this session\'s title (taken from the first message) doesn\'t say what the work is, or the work changes ' +
|
|
49
|
+
'direction: `bivy title "<short title>"`.',
|
|
48
50
|
"- When you finish long work, get blocked, or need the user to look at something: " +
|
|
49
51
|
'`bivy notify "<message>"` (a chat card, plus a push to their phone when they are away). To ask and wait for ' +
|
|
50
52
|
'an answer: `bivy ask "<question>" [--option A --option B]` prints their answer (or use your own ask-the-user tool).',
|
package/dist/server.js
CHANGED
|
@@ -2528,10 +2528,7 @@ const RELAY_COMMANDS = {
|
|
|
2528
2528
|
const rec = resolveSession(sid);
|
|
2529
2529
|
if (!rec)
|
|
2530
2530
|
return;
|
|
2531
|
-
|
|
2532
|
-
persistSessionMetadata(rec);
|
|
2533
|
-
ctx.broadcast({ type: "session.renamed", sessionId: rec.id, sessionFile: rec.sessionFile, name: newName });
|
|
2534
|
-
scheduleAdvertise();
|
|
2531
|
+
sessionNamer.setSessionName(rec, newName);
|
|
2535
2532
|
},
|
|
2536
2533
|
abort(msg, ctx) {
|
|
2537
2534
|
const sessionId = String(msg.sessionId ?? "");
|
|
@@ -9865,10 +9862,7 @@ app.post("/api/sessions/rename", (req, res, next) => {
|
|
|
9865
9862
|
const rec = resolveSession(sid);
|
|
9866
9863
|
if (!rec)
|
|
9867
9864
|
return res.status(404).json({ error: "Session not found" });
|
|
9868
|
-
|
|
9869
|
-
persistSessionMetadata(rec);
|
|
9870
|
-
broadcast({ type: "session.renamed", sessionId: rec.id, sessionFile: rec.sessionFile, name: newName });
|
|
9871
|
-
scheduleAdvertise();
|
|
9865
|
+
sessionNamer.setSessionName(rec, newName);
|
|
9872
9866
|
res.json({ ok: true, name: newName });
|
|
9873
9867
|
}
|
|
9874
9868
|
catch (error) {
|
|
@@ -11707,6 +11701,19 @@ app.get("/api/session/:id/automations/apply/:proposalId", (req, res) => {
|
|
|
11707
11701
|
return res.status(404).json({ error: "Proposal not found" });
|
|
11708
11702
|
res.json(proposal);
|
|
11709
11703
|
});
|
|
11704
|
+
// `bivy title "<title>"`: the agent names its own session, e.g. when the first
|
|
11705
|
+
// message made a poor title or the work changed direction.
|
|
11706
|
+
const MAX_SESSION_TITLE = 100;
|
|
11707
|
+
app.post("/api/session/:id/title", (req, res) => {
|
|
11708
|
+
const record = openSessions.get(String(req.params.id));
|
|
11709
|
+
if (!record)
|
|
11710
|
+
return res.status(404).json({ error: "Session not found" });
|
|
11711
|
+
const title = typeof req.body?.title === "string" ? req.body.title.replace(/\s+/g, " ").trim() : "";
|
|
11712
|
+
if (!title || title.length > MAX_SESSION_TITLE)
|
|
11713
|
+
return res.status(400).json({ error: `A title needs 1 to ${MAX_SESSION_TITLE} characters.` });
|
|
11714
|
+
sessionNamer.setSessionName(record, title);
|
|
11715
|
+
res.json({ ok: true, title });
|
|
11716
|
+
});
|
|
11710
11717
|
// `bivy suggest "<task>"`: the agent proposes a task the user can start in one
|
|
11711
11718
|
// tap, here, through this agent's sub-agents, or in a parallel session; `run`
|
|
11712
11719
|
// is the one the agent recommends (see packages/web SuggestionCard).
|
|
@@ -180,6 +180,12 @@ export function createSessionNamer(deps) {
|
|
|
180
180
|
catch (error) {
|
|
181
181
|
console.warn("Session naming suggestion failed", error);
|
|
182
182
|
}
|
|
183
|
+
// A title set while the model was thinking (the user, or the agent with
|
|
184
|
+
// `bivy title`) wins over the refinement.
|
|
185
|
+
if (record.session.getName() !== fallback) {
|
|
186
|
+
record.namedFromFirstPrompt = true;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
183
189
|
if (finalName !== fallback) {
|
|
184
190
|
record.session.setName(finalName);
|
|
185
191
|
deps.persistSessionMetadata(record);
|
|
@@ -211,8 +217,8 @@ export function createSessionNamer(deps) {
|
|
|
211
217
|
record.naming = false;
|
|
212
218
|
}
|
|
213
219
|
}
|
|
214
|
-
/** Manually set a session's title (
|
|
215
|
-
* first-prompt namer won't overwrite it. */
|
|
220
|
+
/** Manually set a session's title (a rename in the app, `bivy title`, a
|
|
221
|
+
* GitHub-issue pickup) and lock it so the first-prompt namer won't overwrite it. */
|
|
216
222
|
function setSessionName(record, name) {
|
|
217
223
|
const clean = name.trim();
|
|
218
224
|
if (!clean)
|
|
@@ -44,7 +44,7 @@ export function createSessionTokenCodec(key = randomBytes(32)) {
|
|
|
44
44
|
*/
|
|
45
45
|
export const SESSION_TOKEN_ROUTES = [
|
|
46
46
|
{ method: "GET", path: /^\/api\/session\/([^/]+)\/context$/, session: "path" },
|
|
47
|
-
{ method: "POST", path: /^\/api\/session\/([^/]+)\/(attach|suggest|notify)$/, session: "path" },
|
|
47
|
+
{ method: "POST", path: /^\/api\/session\/([^/]+)\/(attach|suggest|notify|title)$/, session: "path" },
|
|
48
48
|
{ method: "POST", path: /^\/api\/session\/([^/]+)\/ask$/, session: "path" },
|
|
49
49
|
{ method: "GET", path: /^\/api\/session\/([^/]+)\/ask\/[^/]+$/, session: "path" },
|
|
50
50
|
{ method: "POST", path: /^\/api\/session\/([^/]+)\/ask\/[^/]+\/wait$/, session: "path" },
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{O as n,R as r}from"./index-H1S-0dr5.js";import{$ as i,At as a,B as o,Ct as s,Et as c,M as l,Mt as u,Ot as d,Q as f,S as p,W as m,X as h,Y as g,Z as _,at as v,ct as y,et as b,gt as x,ht as S,i as C,it as ee,j as te,jt as ne,kt as re,mt as ie,n as w,ot as ae,rt as T,st as oe,t as se,tt as ce,x as E,yt as le}from"./useStore-BxmpBglW.js";import{A as D,O,a as k,f as A,h as j,i as M,k as ue,n as N,s as de,t as P,w as fe}from"./Sheet-Db4Mndim.js";import{t as F}from"./jsx-runtime-NZYk81nU.js";import{C as pe,D as me,E as he,O as I,S as L,T as R,b as ge,k as z,w as _e,x as B,y as ve}from"./mount-B_ShSdyJ.js";var V=t(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`cronstrue`,[],r):typeof e==`object`?e.cronstrue=r():n.cronstrue=r()})(globalThis,()=>(()=>{var e={6949(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.CronParser=void 0;var r=n(9515);t.CronParser=function(){function e(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=n}return e.prototype.parse=function(){var e,t=this.expression??``;if(t===`@reboot`)return e=[`@reboot`,``,``,``,``,``,``],e;if(t.startsWith(`@`)){var n=this.parseSpecial(this.expression);e=this.extractParts(n)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},e.prototype.parseSpecial=function(e){var t={"@yearly":`0 0 1 1 *`,"@annually":`0 0 1 1 *`,"@monthly":`0 0 1 * *`,"@weekly":`0 0 * * 0`,"@daily":`0 0 * * *`,"@midnight":`0 0 * * *`,"@hourly":`0 * * * *`,"@reboot":`@reboot`}[e];if(!t)throw Error(`Unknown special expression.`);return t},e.prototype.extractParts=function(e){if(!this.expression)throw Error(`cron expression is empty`);for(var t=e.trim().split(/[ ]+/),n=0;n<t.length;n++)if(t[n].includes(`,`)){var r=t[n].split(`,`).map(function(e){return e.trim()}).filter(function(e){return e!==``}).map(function(e){return isNaN(Number(e))?e:Number(e)}).filter(function(e){return e!==null&&e!==``});r.length===0&&r.push(`*`),r.sort(function(e,t){return e!==null&&t!==null?e-t:0}),t[n]=r.map(function(e){return e===null?``:e.toString()}).join(`,`)}if(t.length<5)throw Error(`Expression has only ${t.length} part${t.length==1?``:`s`}. At least 5 parts are required.`);if(t.length==5)t.unshift(``),t.push(``);else if(t.length==6)/\d{4}$/.test(t[5])||t[4]==`?`||t[2]==`?`?t.unshift(``):t.push(``);else if(t.length>7)throw Error(`Expression has ${t.length} parts; too many!`);return t},e.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace(`?`,`*`),e[5]=e[5].replace(`?`,`*`),e[2]=e[2].replace(`?`,`*`),e[0].indexOf(`0/`)==0&&(e[0]=e[0].replace(`0/`,`*/`)),e[1].indexOf(`0/`)==0&&(e[1]=e[1].replace(`0/`,`*/`)),e[2].indexOf(`0/`)==0&&(e[2]=e[2].replace(`0/`,`*/`)),e[3].indexOf(`1/`)==0&&(e[3]=e[3].replace(`1/`,`*/`)),e[4].indexOf(`1/`)==0&&(e[4]=e[4].replace(`1/`,`*/`)),e[6].indexOf(`1/`)==0&&(e[6]=e[6].replace(`1/`,`*/`)),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(e){var n=e.replace(/\D/,``),r=n;return t.dayOfWeekStartIndexZero?n==`7`&&(r=`0`):r=(parseInt(n)-1).toString(),e.replace(n,r)}),e[5]==`L`&&(e[5]=`6`),e[3]==`?`&&(e[3]=`*`),e[3].indexOf(`W`)>-1&&(e[3].indexOf(`,`)>-1||e[3].indexOf(`-`)>-1))throw Error(`The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.`);var n={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var r in n)e[5]=e[5].replace(new RegExp(r,`gi`),n[r].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(e){var n=e.replace(/\D/,``),r=n;return t.monthStartIndexZero&&(r=(parseInt(n)+1).toString()),e.replace(n,r)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)e[4]=e[4].replace(new RegExp(a,`gi`),i[a].toString());e[0]==`0`&&(e[0]=``),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+=`-${e[2]}`);for(var o=0;o<e.length;o++)if(e[o].indexOf(`,`)!=-1&&(e[o]=e[o].split(`,`).filter(function(e){return e!==``}).join(`,`)||`*`),e[o]==`*/1`&&(e[o]=`*`),e[o].indexOf(`/`)>-1&&!/^\*|\-|\,/.test(e[o])){var s=null;switch(o){case 4:s=`12`;break;case 5:s=`6`;break;case 6:s=`9999`;break;default:s=null}if(s!==null){var c=e[o].split(`/`);e[o]=`${c[0]}-${s}/${c[1]}`}}},e.prototype.validate=function(e){var t=`0-9,\\-*/`;this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],`0-9,\\-*/LW`),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],`0-9,\\-*/L#`),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},e.prototype.validateAnyRanges=function(e){r.default.secondRange(e[0]),r.default.minuteRange(e[1]),r.default.hourRange(e[2]),r.default.dayOfMonthRange(e[3]),r.default.monthRange(e[4],this.monthStartIndexZero),r.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},e.prototype.validateOnlyExpectedCharactersFound=function(e,t){var n=e.match(RegExp(`[^${t}]+`,`gi`));if(n&&n.length)throw Error(`Expression contains invalid values: '${n.toString()}'`)},e}()},8333(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ExpressionDescriptor=void 0;var r=n(1823),i=n(6949);t.ExpressionDescriptor=function(){function e(t,n){if(this.expression=t,this.options=n,this.expressionParts=[,,,,,],!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var r=Object.keys(e.locales)[0];console.warn(`Locale '${this.options.locale}' could not be found; falling back to '${r}'.`),this.options.locale=r}this.i18n=e.locales[this.options.locale],n.use24HourTimeFormat===void 0&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,n){var r=n===void 0?{}:n,i=r.throwExceptionOnParseError,a=i===void 0||i,o=r.verbose,s=o!==void 0&&o,c=r.dayOfWeekStartIndexZero,l=c===void 0||c,u=r.monthStartIndexZero,d=u!==void 0&&u,f=r.use24HourTimeFormat,p=r.trimHoursLeadingZero,m=p!==void 0&&p,h=r.locale,g=h===void 0?null:h,_=r.logicalAndDayFields,v={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:l,monthStartIndexZero:d,use24HourTimeFormat:f,trimHoursLeadingZero:m,locale:g,logicalAndDayFields:_!==void 0&&_};return v.tzOffset&&console.warn(`'tzOffset' option has been deprecated and is no longer supported.`),new e(t,v).getFullDescription()},e.initialize=function(t,n){n===void 0&&(n=`en`),e.specialCharacters=[`/`,`-`,`,`,`*`],e.defaultLocale=n,t.load(e.locales)},e.prototype.getFullDescription=function(){var e,t=``;try{var n=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=n.parse(),this.expressionParts[0]===`@reboot`)return(e=this.i18n).atReboot?.call(e)||`Run once, at startup`;var r=this.getTimeOfDayDescription(),a=this.getDayOfMonthDescription(),o=this.getMonthDescription(),s=this.getDayOfWeekDescription(),c=this.getYearDescription();t+=r+a+s+o+c,t=this.transformVerbosity(t,!!this.options.verbose),t=t.charAt(0).toLocaleUpperCase()+t.substr(1)}catch(e){if(!this.options.throwExceptionOnParseError)t=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw`${e}`}return t},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],n=this.expressionParts[1],i=this.expressionParts[2],a=``;if(!r.StringUtilities.containsAny(n,e.specialCharacters)&&!r.StringUtilities.containsAny(i,e.specialCharacters)&&!r.StringUtilities.containsAny(t,e.specialCharacters))a+=this.i18n.atSpace()+this.formatTime(i,n,t);else if(!t&&n.indexOf(`-`)>-1&&!(n.indexOf(`,`)>-1)&&!(n.indexOf(`/`)>-1)&&!r.StringUtilities.containsAny(i,e.specialCharacters)){var o=n.split(`-`);a+=r.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(i,o[0],``),this.formatTime(i,o[1],``))}else if(!t&&i.indexOf(`,`)>-1&&i.indexOf(`-`)==-1&&i.indexOf(`/`)==-1&&!r.StringUtilities.containsAny(n,e.specialCharacters)){var s=i.split(`,`);a+=this.i18n.at();for(var c=0;c<s.length;c++)a&&(a+=` `),a+=this.formatTime(s[c],n,``),c<s.length-2&&(a+=`,`),c==s.length-2&&(a+=this.i18n.spaceAnd())}else{var l=this.getSecondsDescription(),u=this.getMinutesDescription(),d=this.getHoursDescription();if(a+=l,a&&u&&(a+=`, `),a+=u,u===d)return a;a&&d&&(a+=`, `),a+=d}return a},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Seconds(t),t)},function(t){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(t){return t==`0`?``:parseInt(t)<20?e.i18n.atX0SecondsPastTheMinute(t):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(t)},{min:0,max:59})},e.prototype.getMinutesDescription=function(){var e=this,t=this.expressionParts[0],n=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Minutes(t),t)},function(t){return e.i18n.minutesX0ThroughX1PastTheHour()},function(r){var i;try{return r==`0`&&n.indexOf(`/`)==-1&&t==``?e.i18n.everyHour():r==`0`?(i=e.i18n).onTheHour?.call(i)||e.i18n.atX0MinutesPastTheHour(r):parseInt(r)<20?e.i18n.atX0MinutesPastTheHour(r):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(r)}catch{return e.i18n.atX0MinutesPastTheHour(r)}},{min:0,max:59})},e.prototype.getHoursDescription=function(){var e=this,t=this.expressionParts[2],n=0,i=[];t.split(`/`)[0].split(`,`).forEach(function(e){var t=e.split(`-`);t.length===2&&i.push({value:t[1],index:n+1}),n+=t.length});var a=0;return this.getSegmentDescription(t,this.i18n.everyHour(),function(t){var n=i.find(function(e){return e.value===t&&e.index===a})&&e.expressionParts[1]!==`0`;return a++,n?e.formatTime(t,`59`,``):e.formatTime(t,`0`,``)},function(t){return r.StringUtilities.format(e.i18n.everyX0Hours(t),t)},function(t){return e.i18n.betweenX0AndX1()},function(t){return e.i18n.atX0()},{min:0,max:23})},e.prototype.getDayOfWeekDescription=function(){var e=this,t=this.i18n.daysOfTheWeek(),n=null;return n=this.expressionParts[5]==`*`?``:this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(n,r){var i=n;n.indexOf(`#`)>-1?i=n.substring(0,n.indexOf(`#`)):n.indexOf(`L`)>-1&&(i=i.replace(`L`,``));var a=parseInt(i),o=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(r)[a]:t[a];if(n.indexOf(`#`)>-1){var s=null,c=n.substring(n.indexOf(`#`)+1),l=n.substring(0,n.indexOf(`#`));switch(c){case`1`:s=e.i18n.first(l);break;case`2`:s=e.i18n.second(l);break;case`3`:s=e.i18n.third(l);break;case`4`:s=e.i18n.fourth(l);break;case`5`:s=e.i18n.fifth(l)}o=s+` `+o}return o},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(t),t)},function(t){var n=t.substring(0,t.indexOf(`-`));return e.expressionParts[3]==`*`?e.i18n.commaX0ThroughX1(n):e.i18n.commaAndX0ThroughX1(n)},function(t){var n=null;if(t.indexOf(`#`)>-1){var r=t.substring(t.indexOf(`#`)+1),i=t.substring(0,t.indexOf(`#`));n=e.i18n.commaOnThe(r,i).trim()+e.i18n.spaceX0OfTheMonth()}else n=t.indexOf(`L`)>-1?e.i18n.commaOnTheLastX0OfTheMonth(t.replace(`L`,``)):e.expressionParts[3]==`*`||e.options.logicalAndDayFields?e.i18n.commaOnlyOnX0(t):e.i18n.commaAndOnX0();return n}),n},e.prototype.getMonthDescription=function(){var e=this,t=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],``,function(n,r){return r&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(r)[parseInt(n)-1]:t[parseInt(n)-1]},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0Months(t),t)},function(t){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()})},e.prototype.getDayOfMonthDescription=function(){var e=this,t=null,n=this.expressionParts[3];switch(n){case`L`:t=this.i18n.commaOnTheLastDayOfTheMonth();break;case`WL`:case`LW`:t=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace(`W`,``)),o=a==1?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());t=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),o);break}var s=n.match(/L-(\d{1,2})/);if(s){var c=s[1];t=r.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(c),c);break}if(n==`*`&&this.expressionParts[5]!=`*`)return``;t=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(t){return t==`L`?e.i18n.lastDay():e.i18n.dayX0?r.StringUtilities.format(e.i18n.dayX0(),t):t},function(t){return t==`1`?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(t)},function(t){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(t)},function(t){return e.i18n.commaOnDayX0OfTheMonth(t)})}return t},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],``,function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0Years(t),t)},function(t){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()})},e.prototype.getSegmentDescription=function(e,t,n,i,a,o,s){var c=null,l=e.indexOf(`/`)>-1,u=e.indexOf(`-`)>-1,d=e.indexOf(`,`)>-1;if(!e)c=``;else if(e===`*`)c=t;else if(!l&&!u&&!d)c=r.StringUtilities.format(o(e),n(e));else if(d){for(var f=e.split(`,`),p=``,m=this.i18n.spaceAnd(),h=0;h<f.length;h++)if(h>0&&f.length>2&&(p+=`,`,h<f.length-1&&(p+=` `)),h>0&&f.length>1&&(h==f.length-1||f.length==2)&&(p+=m==`,`&&f.length>2?` `:`${m} `),f[h].indexOf(`/`)>-1||f[h].indexOf(`-`)>-1){var g=f[h].indexOf(`-`)>-1&&f[h].indexOf(`/`)==-1,_=this.getSegmentDescription(f[h],t,n,i,g?this.i18n.commaX0ThroughX1:a,o);g&&(_=_.replace(`, `,``)),p+=_}else if(!l)p+=n(f[h]);else{var v=this.getSegmentDescription(f[h],t,n,i,a,o);v&&v.startsWith(`, `)&&(v=v.substring(2)),p+=v}c=l?p:r.StringUtilities.format(o(e),p)}else if(l){var f=e.split(`/`);if(c=r.StringUtilities.format(i(f[1]),f[1]),f[0].indexOf(`-`)>-1){var y=this.generateRangeSegmentDescription(f[0],a,n);y.indexOf(`, `)!=0&&(c+=`, `),c+=y}else if(f[0].indexOf(`*`)==-1){var b=r.StringUtilities.format(o(f[0]),n(f[0]));b=b.replace(`, `,``),c+=r.StringUtilities.format(this.i18n.commaStartingX0(),b)}c+=this.getWrappingIncrementDescription(e,s,t,n,i,a,o)}else u&&(c=this.generateRangeSegmentDescription(e,a,n));return c},e.prototype.getWrappingIncrementDescription=function(e,t,n,r,i,a,o){if(!this.options.verbose||!t)return``;var s=e.split(`/`),c=s[0],l=s[1],u=parseInt(l),d=t.max-t.min+1,f=c===`*`,p=Number.isInteger(u)&&u>1,m=p&&d%u===0;if(!f||!p||m)return``;for(var h=[],g=t.min;g<=t.max;g+=u)h.push(g);if(h.length<2)return``;var _=this.getSegmentDescription(h.join(`,`),n,r,i,a,o);return _?`, ${_}`:``},e.prototype.generateRangeSegmentDescription=function(e,t,n){var i=``,a=e.split(`-`),o=n(a[0],1),s=n(a[1],2),c=t(e);return i+=r.StringUtilities.format(c,o,s),i},e.prototype.formatTime=function(e,t,n){var r=0,i=0,a=parseInt(e)+r,o=parseInt(t)+i;o>=60?(o-=60,a+=1):o<0&&(o+=60,--a),a>=24?a-=24:a<0&&(a=24+a);var s=``,c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),s=c?`${this.getPeriod(a)} `:` ${this.getPeriod(a)}`,a>12&&(a-=12),a===0&&(a=12));var l=``;n&&(l=`:${(`00`+n).substring(n.length)}`);var u=a.toString(),d=(`00`+u).substring(u.length),f=o.toString(),p=(`00`+f).substring(f.length),m=this.options.trimHoursLeadingZero?u:d;return`${c?s:``}${m}:${p}${l}${c?``:s}`},e.prototype.transformVerbosity=function(e,t){if(!t&&(e=e.replace(RegExp(`, ${this.i18n.everyMinute()}`,`g`),``),e=e.replace(RegExp(`, ${this.i18n.everyHour()}`,`g`),``),e=e.replace(new RegExp(this.i18n.commaEveryDay(),`g`),``),e=e.replace(/\, ?$/,``),this.i18n.conciseVerbosityReplacements))for(var n=0,r=Object.entries(this.i18n.conciseVerbosityReplacements());n<r.length;n++){var i=r[n],a=i[0],o=i[1];e=e.replace(new RegExp(a,`g`),o)}return e},e.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||`PM`:this.i18n.am&&this.i18n.am()||`AM`},e.locales={},e}()},3747(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.enLocaleLoader=void 0;var r=n(9486);t.enLocaleLoader=function(){function e(){}return e.prototype.load=function(e){e.en=new r.en},e}()},9486(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.en=void 0,t.en=function(){function e(){}return e.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},e.prototype.atX0MinutesPastTheHourGt20=function(){return null},e.prototype.commaMonthX0ThroughMonthX1=function(){return null},e.prototype.commaYearX0ThroughYearX1=function(){return null},e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return`An error occurred when generating the expression description. Check the cron expression syntax.`},e.prototype.everyMinute=function(){return`every minute`},e.prototype.everyHour=function(){return`every hour`},e.prototype.atSpace=function(){return`At `},e.prototype.everyMinuteBetweenX0AndX1=function(){return`Every minute between %s and %s`},e.prototype.at=function(){return`At`},e.prototype.spaceAnd=function(){return` and`},e.prototype.everySecond=function(){return`every second`},e.prototype.everyX0Seconds=function(){return`every %s seconds`},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return`seconds %s through %s past the minute`},e.prototype.atX0SecondsPastTheMinute=function(){return`at %s seconds past the minute`},e.prototype.everyX0Minutes=function(){return`every %s minutes`},e.prototype.minutesX0ThroughX1PastTheHour=function(){return`minutes %s through %s past the hour`},e.prototype.atX0MinutesPastTheHour=function(){return`at %s minutes past the hour`},e.prototype.everyX0Hours=function(){return`every %s hours`},e.prototype.betweenX0AndX1=function(){return`between %s and %s`},e.prototype.atX0=function(){return`at %s`},e.prototype.commaEveryDay=function(){return`, every day`},e.prototype.commaEveryX0DaysOfTheWeek=function(){return`, every %s days of the week`},e.prototype.commaX0ThroughX1=function(){return`, %s through %s`},e.prototype.commaAndX0ThroughX1=function(){return`, %s through %s`},e.prototype.first=function(){return`first`},e.prototype.second=function(){return`second`},e.prototype.third=function(){return`third`},e.prototype.fourth=function(){return`fourth`},e.prototype.fifth=function(){return`fifth`},e.prototype.commaOnThe=function(){return`, on the `},e.prototype.spaceX0OfTheMonth=function(){return` %s of the month`},e.prototype.lastDay=function(){return`the last day`},e.prototype.commaOnTheLastX0OfTheMonth=function(){return`, on the last %s of the month`},e.prototype.commaOnlyOnX0=function(){return`, only on %s`},e.prototype.commaAndOnX0=function(){return`, and on %s`},e.prototype.commaEveryX0Months=function(){return`, every %s months`},e.prototype.commaOnlyInX0=function(){return`, only in %s`},e.prototype.commaOnTheLastDayOfTheMonth=function(){return`, on the last day of the month`},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return`, on the last weekday of the month`},e.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return`, %s days before the last day of the month`},e.prototype.firstWeekday=function(){return`first weekday`},e.prototype.weekdayNearestDayX0=function(){return`weekday nearest day %s`},e.prototype.commaOnTheX0OfTheMonth=function(){return`, on the %s of the month`},e.prototype.commaEveryX0Days=function(){return`, every %s days in a month`},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return`, between day %s and %s of the month`},e.prototype.commaOnDayX0OfTheMonth=function(){return`, on day %s of the month`},e.prototype.commaEveryHour=function(){return`, every hour`},e.prototype.commaEveryX0Years=function(){return`, every %s years`},e.prototype.commaStartingX0=function(){return`, starting %s`},e.prototype.daysOfTheWeek=function(){return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},e.prototype.monthsOfTheYear=function(){return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},e.prototype.atReboot=function(){return`Run once, at startup`},e.prototype.onTheHour=function(){return`on the hour`},e}()},9515(e,t){Object.defineProperty(t,"__esModule",{value:!0});function n(e,t){if(!e)throw Error(t)}t.default=function(){function e(){}return e.secondRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`seconds part must be >= 0 and <= 59`)}},e.minuteRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`minutes part must be >= 0 and <= 59`)}},e.hourRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=23,`hours part must be >= 0 and <= 23`)}},e.dayOfMonthRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=1&&i<=31,`DOM part must be >= 1 and <= 31`)}},e.monthRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=1&&a<=12,t?`month part must be >= 0 and <= 11`:`month part must be >= 1 and <= 12`)}},e.dayOfWeekRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=0&&a<=6,t?`DOW part must be >= 0 and <= 6`:`DOW part must be >= 1 and <= 7`)}},e}()},1823(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.StringUtilities=void 0,t.StringUtilities=function(){function e(){}return e.format=function(e){var t=[...arguments].slice(1);return e.replace(/%s/g,function(e){return t.shift()})},e.containsAny=function(e,t){return t.some(function(t){return e.indexOf(t)>-1})},e}()}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.toString=void 0;var t=n(8333),i=n(3747);t.ExpressionDescriptor.initialize(new i.enLocaleLoader),e.default=t.ExpressionDescriptor,e.toString=t.ExpressionDescriptor.toString})(),r})())})),ye=D(),be=e(V(),1),H=u();function U(e){if(!e.parentElement||!e.clientWidth)return;let t=getComputedStyle(e),n=e.cloneNode(!1);n.removeAttribute(`id`),n.removeAttribute(`name`),n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,n.value=e.value,Object.assign(n.style,{position:`fixed`,visibility:`hidden`,pointerEvents:`none`,width:t.width,height:`0`,minHeight:`0`,maxHeight:`none`}),e.parentElement.append(n);let r=n.scrollHeight+(t.boxSizing===`border-box`?parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth):-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom));n.remove(),e.style.height=`${r}px`}function xe(e,t){(0,H.useLayoutEffect)(()=>{e.current&&U(e.current)},[e,t]),(0,H.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.clientWidth,r=new ResizeObserver(()=>{t.clientWidth!==n&&(n=t.clientWidth,U(t))});return r.observe(t),()=>r.disconnect()},[e])}var W=`bivy-automation-v1
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{O as n,R as r}from"./index-D-0NDZis.js";import{$ as i,At as a,B as o,Ct as s,Et as c,M as l,Mt as u,Ot as d,Q as f,S as p,W as m,X as h,Y as g,Z as _,at as v,ct as y,et as b,gt as x,ht as S,i as C,it as ee,j as te,jt as ne,kt as re,mt as ie,n as w,ot as ae,rt as T,st as oe,t as se,tt as ce,x as E,yt as le}from"./useStore-DcIB7b1-.js";import{A as D,O,a as k,f as A,h as j,i as M,k as ue,n as N,s as de,t as P,w as fe}from"./Sheet-YqJCwCtR.js";import{t as F}from"./jsx-runtime-NZYk81nU.js";import{C as pe,D as me,E as he,O as I,S as L,T as R,b as ge,k as z,w as _e,x as B,y as ve}from"./mount-BlTXC3tw.js";var V=t(((e,t)=>{(function(n,r){typeof e==`object`&&typeof t==`object`?t.exports=r():typeof define==`function`&&define.amd?define(`cronstrue`,[],r):typeof e==`object`?e.cronstrue=r():n.cronstrue=r()})(globalThis,()=>(()=>{var e={6949(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.CronParser=void 0;var r=n(9515);t.CronParser=function(){function e(e,t,n){t===void 0&&(t=!0),n===void 0&&(n=!1),this.expression=e,this.dayOfWeekStartIndexZero=t,this.monthStartIndexZero=n}return e.prototype.parse=function(){var e,t=this.expression??``;if(t===`@reboot`)return e=[`@reboot`,``,``,``,``,``,``],e;if(t.startsWith(`@`)){var n=this.parseSpecial(this.expression);e=this.extractParts(n)}else e=this.extractParts(this.expression);return this.normalize(e),this.validate(e),e},e.prototype.parseSpecial=function(e){var t={"@yearly":`0 0 1 1 *`,"@annually":`0 0 1 1 *`,"@monthly":`0 0 1 * *`,"@weekly":`0 0 * * 0`,"@daily":`0 0 * * *`,"@midnight":`0 0 * * *`,"@hourly":`0 * * * *`,"@reboot":`@reboot`}[e];if(!t)throw Error(`Unknown special expression.`);return t},e.prototype.extractParts=function(e){if(!this.expression)throw Error(`cron expression is empty`);for(var t=e.trim().split(/[ ]+/),n=0;n<t.length;n++)if(t[n].includes(`,`)){var r=t[n].split(`,`).map(function(e){return e.trim()}).filter(function(e){return e!==``}).map(function(e){return isNaN(Number(e))?e:Number(e)}).filter(function(e){return e!==null&&e!==``});r.length===0&&r.push(`*`),r.sort(function(e,t){return e!==null&&t!==null?e-t:0}),t[n]=r.map(function(e){return e===null?``:e.toString()}).join(`,`)}if(t.length<5)throw Error(`Expression has only ${t.length} part${t.length==1?``:`s`}. At least 5 parts are required.`);if(t.length==5)t.unshift(``),t.push(``);else if(t.length==6)/\d{4}$/.test(t[5])||t[4]==`?`||t[2]==`?`?t.unshift(``):t.push(``);else if(t.length>7)throw Error(`Expression has ${t.length} parts; too many!`);return t},e.prototype.normalize=function(e){var t=this;if(e[3]=e[3].replace(`?`,`*`),e[5]=e[5].replace(`?`,`*`),e[2]=e[2].replace(`?`,`*`),e[0].indexOf(`0/`)==0&&(e[0]=e[0].replace(`0/`,`*/`)),e[1].indexOf(`0/`)==0&&(e[1]=e[1].replace(`0/`,`*/`)),e[2].indexOf(`0/`)==0&&(e[2]=e[2].replace(`0/`,`*/`)),e[3].indexOf(`1/`)==0&&(e[3]=e[3].replace(`1/`,`*/`)),e[4].indexOf(`1/`)==0&&(e[4]=e[4].replace(`1/`,`*/`)),e[6].indexOf(`1/`)==0&&(e[6]=e[6].replace(`1/`,`*/`)),e[5]=e[5].replace(/(^\d)|([^#/\s]\d)/g,function(e){var n=e.replace(/\D/,``),r=n;return t.dayOfWeekStartIndexZero?n==`7`&&(r=`0`):r=(parseInt(n)-1).toString(),e.replace(n,r)}),e[5]==`L`&&(e[5]=`6`),e[3]==`?`&&(e[3]=`*`),e[3].indexOf(`W`)>-1&&(e[3].indexOf(`,`)>-1||e[3].indexOf(`-`)>-1))throw Error(`The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.`);var n={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var r in n)e[5]=e[5].replace(new RegExp(r,`gi`),n[r].toString());e[4]=e[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g,function(e){var n=e.replace(/\D/,``),r=n;return t.monthStartIndexZero&&(r=(parseInt(n)+1).toString()),e.replace(n,r)});var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var a in i)e[4]=e[4].replace(new RegExp(a,`gi`),i[a].toString());e[0]==`0`&&(e[0]=``),!/\*|\-|\,|\//.test(e[2])&&(/\*|\//.test(e[1])||/\*|\//.test(e[0]))&&(e[2]+=`-${e[2]}`);for(var o=0;o<e.length;o++)if(e[o].indexOf(`,`)!=-1&&(e[o]=e[o].split(`,`).filter(function(e){return e!==``}).join(`,`)||`*`),e[o]==`*/1`&&(e[o]=`*`),e[o].indexOf(`/`)>-1&&!/^\*|\-|\,/.test(e[o])){var s=null;switch(o){case 4:s=`12`;break;case 5:s=`6`;break;case 6:s=`9999`;break;default:s=null}if(s!==null){var c=e[o].split(`/`);e[o]=`${c[0]}-${s}/${c[1]}`}}},e.prototype.validate=function(e){var t=`0-9,\\-*/`;this.validateOnlyExpectedCharactersFound(e[0],t),this.validateOnlyExpectedCharactersFound(e[1],t),this.validateOnlyExpectedCharactersFound(e[2],t),this.validateOnlyExpectedCharactersFound(e[3],`0-9,\\-*/LW`),this.validateOnlyExpectedCharactersFound(e[4],t),this.validateOnlyExpectedCharactersFound(e[5],`0-9,\\-*/L#`),this.validateOnlyExpectedCharactersFound(e[6],t),this.validateAnyRanges(e)},e.prototype.validateAnyRanges=function(e){r.default.secondRange(e[0]),r.default.minuteRange(e[1]),r.default.hourRange(e[2]),r.default.dayOfMonthRange(e[3]),r.default.monthRange(e[4],this.monthStartIndexZero),r.default.dayOfWeekRange(e[5],this.dayOfWeekStartIndexZero)},e.prototype.validateOnlyExpectedCharactersFound=function(e,t){var n=e.match(RegExp(`[^${t}]+`,`gi`));if(n&&n.length)throw Error(`Expression contains invalid values: '${n.toString()}'`)},e}()},8333(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.ExpressionDescriptor=void 0;var r=n(1823),i=n(6949);t.ExpressionDescriptor=function(){function e(t,n){if(this.expression=t,this.options=n,this.expressionParts=[,,,,,],!this.options.locale&&e.defaultLocale&&(this.options.locale=e.defaultLocale),!e.locales[this.options.locale]){var r=Object.keys(e.locales)[0];console.warn(`Locale '${this.options.locale}' could not be found; falling back to '${r}'.`),this.options.locale=r}this.i18n=e.locales[this.options.locale],n.use24HourTimeFormat===void 0&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,n){var r=n===void 0?{}:n,i=r.throwExceptionOnParseError,a=i===void 0||i,o=r.verbose,s=o!==void 0&&o,c=r.dayOfWeekStartIndexZero,l=c===void 0||c,u=r.monthStartIndexZero,d=u!==void 0&&u,f=r.use24HourTimeFormat,p=r.trimHoursLeadingZero,m=p!==void 0&&p,h=r.locale,g=h===void 0?null:h,_=r.logicalAndDayFields,v={throwExceptionOnParseError:a,verbose:s,dayOfWeekStartIndexZero:l,monthStartIndexZero:d,use24HourTimeFormat:f,trimHoursLeadingZero:m,locale:g,logicalAndDayFields:_!==void 0&&_};return v.tzOffset&&console.warn(`'tzOffset' option has been deprecated and is no longer supported.`),new e(t,v).getFullDescription()},e.initialize=function(t,n){n===void 0&&(n=`en`),e.specialCharacters=[`/`,`-`,`,`,`*`],e.defaultLocale=n,t.load(e.locales)},e.prototype.getFullDescription=function(){var e,t=``;try{var n=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero,this.options.monthStartIndexZero);if(this.expressionParts=n.parse(),this.expressionParts[0]===`@reboot`)return(e=this.i18n).atReboot?.call(e)||`Run once, at startup`;var r=this.getTimeOfDayDescription(),a=this.getDayOfMonthDescription(),o=this.getMonthDescription(),s=this.getDayOfWeekDescription(),c=this.getYearDescription();t+=r+a+s+o+c,t=this.transformVerbosity(t,!!this.options.verbose),t=t.charAt(0).toLocaleUpperCase()+t.substr(1)}catch(e){if(!this.options.throwExceptionOnParseError)t=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD();else throw`${e}`}return t},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],n=this.expressionParts[1],i=this.expressionParts[2],a=``;if(!r.StringUtilities.containsAny(n,e.specialCharacters)&&!r.StringUtilities.containsAny(i,e.specialCharacters)&&!r.StringUtilities.containsAny(t,e.specialCharacters))a+=this.i18n.atSpace()+this.formatTime(i,n,t);else if(!t&&n.indexOf(`-`)>-1&&!(n.indexOf(`,`)>-1)&&!(n.indexOf(`/`)>-1)&&!r.StringUtilities.containsAny(i,e.specialCharacters)){var o=n.split(`-`);a+=r.StringUtilities.format(this.i18n.everyMinuteBetweenX0AndX1(),this.formatTime(i,o[0],``),this.formatTime(i,o[1],``))}else if(!t&&i.indexOf(`,`)>-1&&i.indexOf(`-`)==-1&&i.indexOf(`/`)==-1&&!r.StringUtilities.containsAny(n,e.specialCharacters)){var s=i.split(`,`);a+=this.i18n.at();for(var c=0;c<s.length;c++)a&&(a+=` `),a+=this.formatTime(s[c],n,``),c<s.length-2&&(a+=`,`),c==s.length-2&&(a+=this.i18n.spaceAnd())}else{var l=this.getSecondsDescription(),u=this.getMinutesDescription(),d=this.getHoursDescription();if(a+=l,a&&u&&(a+=`, `),a+=u,u===d)return a;a&&d&&(a+=`, `),a+=d}return a},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],this.i18n.everySecond(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Seconds(t),t)},function(t){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(t){return t==`0`?``:parseInt(t)<20?e.i18n.atX0SecondsPastTheMinute(t):e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute(t)},{min:0,max:59})},e.prototype.getMinutesDescription=function(){var e=this,t=this.expressionParts[0],n=this.expressionParts[2];return this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Minutes(t),t)},function(t){return e.i18n.minutesX0ThroughX1PastTheHour()},function(r){var i;try{return r==`0`&&n.indexOf(`/`)==-1&&t==``?e.i18n.everyHour():r==`0`?(i=e.i18n).onTheHour?.call(i)||e.i18n.atX0MinutesPastTheHour(r):parseInt(r)<20?e.i18n.atX0MinutesPastTheHour(r):e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour(r)}catch{return e.i18n.atX0MinutesPastTheHour(r)}},{min:0,max:59})},e.prototype.getHoursDescription=function(){var e=this,t=this.expressionParts[2],n=0,i=[];t.split(`/`)[0].split(`,`).forEach(function(e){var t=e.split(`-`);t.length===2&&i.push({value:t[1],index:n+1}),n+=t.length});var a=0;return this.getSegmentDescription(t,this.i18n.everyHour(),function(t){var n=i.find(function(e){return e.value===t&&e.index===a})&&e.expressionParts[1]!==`0`;return a++,n?e.formatTime(t,`59`,``):e.formatTime(t,`0`,``)},function(t){return r.StringUtilities.format(e.i18n.everyX0Hours(t),t)},function(t){return e.i18n.betweenX0AndX1()},function(t){return e.i18n.atX0()},{min:0,max:23})},e.prototype.getDayOfWeekDescription=function(){var e=this,t=this.i18n.daysOfTheWeek(),n=null;return n=this.expressionParts[5]==`*`?``:this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(n,r){var i=n;n.indexOf(`#`)>-1?i=n.substring(0,n.indexOf(`#`)):n.indexOf(`L`)>-1&&(i=i.replace(`L`,``));var a=parseInt(i),o=e.i18n.daysOfTheWeekInCase?e.i18n.daysOfTheWeekInCase(r)[a]:t[a];if(n.indexOf(`#`)>-1){var s=null,c=n.substring(n.indexOf(`#`)+1),l=n.substring(0,n.indexOf(`#`));switch(c){case`1`:s=e.i18n.first(l);break;case`2`:s=e.i18n.second(l);break;case`3`:s=e.i18n.third(l);break;case`4`:s=e.i18n.fourth(l);break;case`5`:s=e.i18n.fifth(l)}o=s+` `+o}return o},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0DaysOfTheWeek(t),t)},function(t){var n=t.substring(0,t.indexOf(`-`));return e.expressionParts[3]==`*`?e.i18n.commaX0ThroughX1(n):e.i18n.commaAndX0ThroughX1(n)},function(t){var n=null;if(t.indexOf(`#`)>-1){var r=t.substring(t.indexOf(`#`)+1),i=t.substring(0,t.indexOf(`#`));n=e.i18n.commaOnThe(r,i).trim()+e.i18n.spaceX0OfTheMonth()}else n=t.indexOf(`L`)>-1?e.i18n.commaOnTheLastX0OfTheMonth(t.replace(`L`,``)):e.expressionParts[3]==`*`||e.options.logicalAndDayFields?e.i18n.commaOnlyOnX0(t):e.i18n.commaAndOnX0();return n}),n},e.prototype.getMonthDescription=function(){var e=this,t=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],``,function(n,r){return r&&e.i18n.monthsOfTheYearInCase?e.i18n.monthsOfTheYearInCase(r)[parseInt(n)-1]:t[parseInt(n)-1]},function(t){return parseInt(t)==1?``:r.StringUtilities.format(e.i18n.commaEveryX0Months(t),t)},function(t){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInMonthX0?e.i18n.commaOnlyInMonthX0():e.i18n.commaOnlyInX0()})},e.prototype.getDayOfMonthDescription=function(){var e=this,t=null,n=this.expressionParts[3];switch(n){case`L`:t=this.i18n.commaOnTheLastDayOfTheMonth();break;case`WL`:case`LW`:t=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var a=parseInt(i[0].replace(`W`,``)),o=a==1?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),a.toString());t=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),o);break}var s=n.match(/L-(\d{1,2})/);if(s){var c=s[1];t=r.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(c),c);break}if(n==`*`&&this.expressionParts[5]!=`*`)return``;t=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(t){return t==`L`?e.i18n.lastDay():e.i18n.dayX0?r.StringUtilities.format(e.i18n.dayX0(),t):t},function(t){return t==`1`?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days(t)},function(t){return e.i18n.commaBetweenDayX0AndX1OfTheMonth(t)},function(t){return e.i18n.commaOnDayX0OfTheMonth(t)})}return t},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],``,function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0Years(t),t)},function(t){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInYearX0?e.i18n.commaOnlyInYearX0():e.i18n.commaOnlyInX0()})},e.prototype.getSegmentDescription=function(e,t,n,i,a,o,s){var c=null,l=e.indexOf(`/`)>-1,u=e.indexOf(`-`)>-1,d=e.indexOf(`,`)>-1;if(!e)c=``;else if(e===`*`)c=t;else if(!l&&!u&&!d)c=r.StringUtilities.format(o(e),n(e));else if(d){for(var f=e.split(`,`),p=``,m=this.i18n.spaceAnd(),h=0;h<f.length;h++)if(h>0&&f.length>2&&(p+=`,`,h<f.length-1&&(p+=` `)),h>0&&f.length>1&&(h==f.length-1||f.length==2)&&(p+=m==`,`&&f.length>2?` `:`${m} `),f[h].indexOf(`/`)>-1||f[h].indexOf(`-`)>-1){var g=f[h].indexOf(`-`)>-1&&f[h].indexOf(`/`)==-1,_=this.getSegmentDescription(f[h],t,n,i,g?this.i18n.commaX0ThroughX1:a,o);g&&(_=_.replace(`, `,``)),p+=_}else if(!l)p+=n(f[h]);else{var v=this.getSegmentDescription(f[h],t,n,i,a,o);v&&v.startsWith(`, `)&&(v=v.substring(2)),p+=v}c=l?p:r.StringUtilities.format(o(e),p)}else if(l){var f=e.split(`/`);if(c=r.StringUtilities.format(i(f[1]),f[1]),f[0].indexOf(`-`)>-1){var y=this.generateRangeSegmentDescription(f[0],a,n);y.indexOf(`, `)!=0&&(c+=`, `),c+=y}else if(f[0].indexOf(`*`)==-1){var b=r.StringUtilities.format(o(f[0]),n(f[0]));b=b.replace(`, `,``),c+=r.StringUtilities.format(this.i18n.commaStartingX0(),b)}c+=this.getWrappingIncrementDescription(e,s,t,n,i,a,o)}else u&&(c=this.generateRangeSegmentDescription(e,a,n));return c},e.prototype.getWrappingIncrementDescription=function(e,t,n,r,i,a,o){if(!this.options.verbose||!t)return``;var s=e.split(`/`),c=s[0],l=s[1],u=parseInt(l),d=t.max-t.min+1,f=c===`*`,p=Number.isInteger(u)&&u>1,m=p&&d%u===0;if(!f||!p||m)return``;for(var h=[],g=t.min;g<=t.max;g+=u)h.push(g);if(h.length<2)return``;var _=this.getSegmentDescription(h.join(`,`),n,r,i,a,o);return _?`, ${_}`:``},e.prototype.generateRangeSegmentDescription=function(e,t,n){var i=``,a=e.split(`-`),o=n(a[0],1),s=n(a[1],2),c=t(e);return i+=r.StringUtilities.format(c,o,s),i},e.prototype.formatTime=function(e,t,n){var r=0,i=0,a=parseInt(e)+r,o=parseInt(t)+i;o>=60?(o-=60,a+=1):o<0&&(o+=60,--a),a>=24?a-=24:a<0&&(a=24+a);var s=``,c=!1;this.options.use24HourTimeFormat||(c=!!(this.i18n.setPeriodBeforeTime&&this.i18n.setPeriodBeforeTime()),s=c?`${this.getPeriod(a)} `:` ${this.getPeriod(a)}`,a>12&&(a-=12),a===0&&(a=12));var l=``;n&&(l=`:${(`00`+n).substring(n.length)}`);var u=a.toString(),d=(`00`+u).substring(u.length),f=o.toString(),p=(`00`+f).substring(f.length),m=this.options.trimHoursLeadingZero?u:d;return`${c?s:``}${m}:${p}${l}${c?``:s}`},e.prototype.transformVerbosity=function(e,t){if(!t&&(e=e.replace(RegExp(`, ${this.i18n.everyMinute()}`,`g`),``),e=e.replace(RegExp(`, ${this.i18n.everyHour()}`,`g`),``),e=e.replace(new RegExp(this.i18n.commaEveryDay(),`g`),``),e=e.replace(/\, ?$/,``),this.i18n.conciseVerbosityReplacements))for(var n=0,r=Object.entries(this.i18n.conciseVerbosityReplacements());n<r.length;n++){var i=r[n],a=i[0],o=i[1];e=e.replace(new RegExp(a,`g`),o)}return e},e.prototype.getPeriod=function(e){return e>=12?this.i18n.pm&&this.i18n.pm()||`PM`:this.i18n.am&&this.i18n.am()||`AM`},e.locales={},e}()},3747(e,t,n){Object.defineProperty(t,"__esModule",{value:!0}),t.enLocaleLoader=void 0;var r=n(9486);t.enLocaleLoader=function(){function e(){}return e.prototype.load=function(e){e.en=new r.en},e}()},9486(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.en=void 0,t.en=function(){function e(){}return e.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},e.prototype.atX0MinutesPastTheHourGt20=function(){return null},e.prototype.commaMonthX0ThroughMonthX1=function(){return null},e.prototype.commaYearX0ThroughYearX1=function(){return null},e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return`An error occurred when generating the expression description. Check the cron expression syntax.`},e.prototype.everyMinute=function(){return`every minute`},e.prototype.everyHour=function(){return`every hour`},e.prototype.atSpace=function(){return`At `},e.prototype.everyMinuteBetweenX0AndX1=function(){return`Every minute between %s and %s`},e.prototype.at=function(){return`At`},e.prototype.spaceAnd=function(){return` and`},e.prototype.everySecond=function(){return`every second`},e.prototype.everyX0Seconds=function(){return`every %s seconds`},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return`seconds %s through %s past the minute`},e.prototype.atX0SecondsPastTheMinute=function(){return`at %s seconds past the minute`},e.prototype.everyX0Minutes=function(){return`every %s minutes`},e.prototype.minutesX0ThroughX1PastTheHour=function(){return`minutes %s through %s past the hour`},e.prototype.atX0MinutesPastTheHour=function(){return`at %s minutes past the hour`},e.prototype.everyX0Hours=function(){return`every %s hours`},e.prototype.betweenX0AndX1=function(){return`between %s and %s`},e.prototype.atX0=function(){return`at %s`},e.prototype.commaEveryDay=function(){return`, every day`},e.prototype.commaEveryX0DaysOfTheWeek=function(){return`, every %s days of the week`},e.prototype.commaX0ThroughX1=function(){return`, %s through %s`},e.prototype.commaAndX0ThroughX1=function(){return`, %s through %s`},e.prototype.first=function(){return`first`},e.prototype.second=function(){return`second`},e.prototype.third=function(){return`third`},e.prototype.fourth=function(){return`fourth`},e.prototype.fifth=function(){return`fifth`},e.prototype.commaOnThe=function(){return`, on the `},e.prototype.spaceX0OfTheMonth=function(){return` %s of the month`},e.prototype.lastDay=function(){return`the last day`},e.prototype.commaOnTheLastX0OfTheMonth=function(){return`, on the last %s of the month`},e.prototype.commaOnlyOnX0=function(){return`, only on %s`},e.prototype.commaAndOnX0=function(){return`, and on %s`},e.prototype.commaEveryX0Months=function(){return`, every %s months`},e.prototype.commaOnlyInX0=function(){return`, only in %s`},e.prototype.commaOnTheLastDayOfTheMonth=function(){return`, on the last day of the month`},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return`, on the last weekday of the month`},e.prototype.commaDaysBeforeTheLastDayOfTheMonth=function(){return`, %s days before the last day of the month`},e.prototype.firstWeekday=function(){return`first weekday`},e.prototype.weekdayNearestDayX0=function(){return`weekday nearest day %s`},e.prototype.commaOnTheX0OfTheMonth=function(){return`, on the %s of the month`},e.prototype.commaEveryX0Days=function(){return`, every %s days in a month`},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return`, between day %s and %s of the month`},e.prototype.commaOnDayX0OfTheMonth=function(){return`, on day %s of the month`},e.prototype.commaEveryHour=function(){return`, every hour`},e.prototype.commaEveryX0Years=function(){return`, every %s years`},e.prototype.commaStartingX0=function(){return`, starting %s`},e.prototype.daysOfTheWeek=function(){return[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`]},e.prototype.monthsOfTheYear=function(){return[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`]},e.prototype.atReboot=function(){return`Run once, at startup`},e.prototype.onTheHour=function(){return`on the hour`},e}()},9515(e,t){Object.defineProperty(t,"__esModule",{value:!0});function n(e,t){if(!e)throw Error(t)}t.default=function(){function e(){}return e.secondRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`seconds part must be >= 0 and <= 59`)}},e.minuteRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=59,`minutes part must be >= 0 and <= 59`)}},e.hourRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=0&&i<=23,`hours part must be >= 0 and <= 23`)}},e.dayOfMonthRange=function(e){for(var t=e.split(`,`),r=0;r<t.length;r++)if(!isNaN(parseInt(t[r],10))){var i=parseInt(t[r],10);n(i>=1&&i<=31,`DOM part must be >= 1 and <= 31`)}},e.monthRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=1&&a<=12,t?`month part must be >= 0 and <= 11`:`month part must be >= 1 and <= 12`)}},e.dayOfWeekRange=function(e,t){for(var r=e.split(`,`),i=0;i<r.length;i++)if(!isNaN(parseInt(r[i],10))){var a=parseInt(r[i],10);n(a>=0&&a<=6,t?`DOW part must be >= 0 and <= 6`:`DOW part must be >= 1 and <= 7`)}},e}()},1823(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.StringUtilities=void 0,t.StringUtilities=function(){function e(){}return e.format=function(e){var t=[...arguments].slice(1);return e.replace(/%s/g,function(e){return t.shift()})},e.containsAny=function(e,t){return t.some(function(t){return e.indexOf(t)>-1})},e}()}},t={};function n(r){var i=t[r];if(i!==void 0)return i.exports;var a=t[r]={exports:{}};return e[r](a,a.exports,n),a.exports}var r={};return(()=>{var e=r;Object.defineProperty(e,"__esModule",{value:!0}),e.toString=void 0;var t=n(8333),i=n(3747);t.ExpressionDescriptor.initialize(new i.enLocaleLoader),e.default=t.ExpressionDescriptor,e.toString=t.ExpressionDescriptor.toString})(),r})())})),ye=D(),be=e(V(),1),H=u();function U(e){if(!e.parentElement||!e.clientWidth)return;let t=getComputedStyle(e),n=e.cloneNode(!1);n.removeAttribute(`id`),n.removeAttribute(`name`),n.setAttribute(`aria-hidden`,`true`),n.tabIndex=-1,n.value=e.value,Object.assign(n.style,{position:`fixed`,visibility:`hidden`,pointerEvents:`none`,width:t.width,height:`0`,minHeight:`0`,maxHeight:`none`}),e.parentElement.append(n);let r=n.scrollHeight+(t.boxSizing===`border-box`?parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth):-parseFloat(t.paddingTop)-parseFloat(t.paddingBottom));n.remove(),e.style.height=`${r}px`}function xe(e,t){(0,H.useLayoutEffect)(()=>{e.current&&U(e.current)},[e,t]),(0,H.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.clientWidth,r=new ResizeObserver(()=>{t.clientWidth!==n&&(n=t.clientWidth,U(t))});return r.observe(t),()=>r.disconnect()},[e])}var W=`bivy-automation-v1
|
|
2
2
|
`;function G(e){let t=e;if(!t||typeof t!=`object`||Array.isArray(t)||Object.keys(t).some(e=>![`command`,`cwd`,`timeoutSeconds`].includes(e))||!Array.isArray(t.command)||!t.command.length||t.command.length>64||t.command.some(e=>typeof e!=`string`||e.length>4096||e.includes(`\0`))||!t.command[0]?.trim()||typeof t.cwd!=`string`||t.cwd.length>4096||t.cwd.includes(`\0`)||!/^(\/|[A-Za-z]:[\\/])/.test(t.cwd)||t.timeoutSeconds!==void 0&&(!Number.isInteger(t.timeoutSeconds)||t.timeoutSeconds<1||t.timeoutSeconds>60))throw Error(`filter requires command (non-empty argv list), cwd (absolute trusted directory), and optional timeoutSeconds (1-60)`);return{command:[...t.command],cwd:t.cwd,timeoutSeconds:t.timeoutSeconds??5}}function Se(e,t,n){return n||Object.keys(t).length||e.startsWith(W)?W+JSON.stringify({instructions:e,credentialLabels:t,...n?{filter:G(n)}:{}}):e}function Ce(e){if(!e.startsWith(W))return{instructions:e,credentialLabels:{}};let t=JSON.parse(e.slice(19));if(!t||typeof t.instructions!=`string`||!t.credentialLabels||typeof t.credentialLabels!=`object`||Array.isArray(t.credentialLabels)||Object.entries(t.credentialLabels).some(([e,t])=>!e.trim()||e!==e.trim().toLowerCase()||typeof t!=`string`||!t.trim()))throw Error(`Invalid automation account selections`);return{instructions:t.instructions,credentialLabels:t.credentialLabels,...t.filter===void 0?{}:{filter:G(t.filter)}}}var we={sunday:0,sun:0,monday:1,mon:1,tuesday:2,tue:2,tues:2,wednesday:3,wed:3,weds:3,thursday:4,thu:4,thur:4,thurs:4,friday:5,fri:5,saturday:6,sat:6},Te={january:1,jan:1,february:2,feb:2,march:3,mar:3,april:4,apr:4,may:5,june:6,jun:6,july:7,jul:7,august:8,aug:8,september:9,sep:9,sept:9,october:10,oct:10,november:11,nov:11,december:12,dec:12};function Ee(e){let t=[],n=new Set,r=(e,r)=>{if(e<0||e>23||r<0||r>59)return;let i=`${e}:${r}`;n.has(i)||(n.add(i),t.push({h:e,m:r}))};/\bnoon\b/.test(e)&&r(12,0),/\bmidnight\b/.test(e)&&r(0,0);for(let t of e.matchAll(/\b(\d{1,2})(?::(\d{2}))?\s*(am|pm)\b/g)){let e=Number(t[1]),n=t[2]?Number(t[2]):0;e===12&&(e=0),t[3]===`pm`&&(e+=12),r(e,n)}for(let t of e.matchAll(/\b(\d{1,2}):(\d{2})\b(?!\s*(?:am|pm))/g))r(Number(t[1]),Number(t[2]));return t.sort((e,t)=>e.h-t.h||e.m-t.m)}function K(e){let t=new Set;/\b(weekday|weekdays|every weekday|business day|business days)\b/.test(e)&&[1,2,3,4,5].forEach(e=>t.add(e)),/\b(weekend|weekends)\b/.test(e)&&[0,6].forEach(e=>t.add(e));for(let n of e.matchAll(/\b([a-z]+?)(?:s)?\b/g)){let e=n[1];e&&e in we&&t.add(we[e])}return[...t].sort((e,t)=>e-t)}function q(e){let t=new Set;for(let n of e.matchAll(/\b([a-z]+)\b/g)){let e=n[1];e&&e in Te&&t.add(Te[e])}return[...t].sort((e,t)=>e-t)}function J(e){let t=e.match(/\b(?:on the|the)\s+(\d{1,2})(?:st|nd|rd|th)?\b/)||e.match(/\b(\d{1,2})(?:st|nd|rd|th)\s+(?:of|day)\b/);if(t&&t[1]){let e=Number(t[1]);if(e>=1&&e<=31)return e}return null}function De(e){let t=` ${e.toLowerCase().trim().replace(/\s+/g,` `)} `;if(!t.trim())return{error:`Describe a schedule, e.g. “every day at 9am”.`};let n=t.match(/\bevery\s+(\d+)\s*(minute|minutes|min|mins|hour|hours|hr|hrs)\b/),r=Ee(t),i=K(t),a=q(t),o=J(t),s=o==null?`*`:String(o),c=a.length?a.join(`,`):`*`,l=i.join(`,`)===`1,2,3,4,5`?`1-5`:i.length?i.join(`,`):`*`;if(n){let e=Number(n[1]),t=n[2]??``,i=/^h/.test(t);return e<1?{error:`Interval must be at least 1.`}:i?e>23?{error:`Hour interval must be 23 or less. Use a daily time instead.`}:Y({minute:r.length?String(r[0].m):`0`,hour:e===1?`*`:`*/${e}`,dom:s,month:c,dow:l}):e>59?{error:`Minute interval must be 59 or less. Use an hourly interval instead.`}:Y({minute:e===1?`*`:`*/${e}`,hour:`*`,dom:s,month:c,dow:l})}if(/\bevery\s+minute\b/.test(t))return Y({minute:`*`,hour:`*`,dom:s,month:c,dow:l});if(/\b(every\s+hour|hourly)\b/.test(t))return Y({minute:r.length?String(r[0].m):`0`,hour:`*`,dom:s,month:c,dow:l});let u,d;if(r.length===0){if(i.length===0&&o==null&&a.length===0)return{error:`Add a time, e.g. “every day at 9am” or “every 15 minutes”.`};u=`0`,d=`0`}else if(r.length===1)u=String(r[0].m),d=String(r[0].h);else{if(new Set(r.map(e=>e.m)).size>1)return{error:`Multiple times must share the same minute (e.g. “at 9am and 5pm”).`};u=String(r[0].m),d=r.map(e=>e.h).join(`,`)}return Y({minute:u,hour:d,dom:s,month:c,dow:l})}function Y(e){return{cron:`${e.minute} ${e.hour} ${e.dom} ${e.month} ${e.dow}`,fields:e}}function X(e){return e.cron!==void 0}function Oe(e){if(!e)return{tone:`warn`,label:`Status unavailable`,detail:`Refresh to check the GitHub App connection.`};if(!e.connected||!e.apps.length)return{tone:`off`,label:`Not connected`,detail:`Install the hosted Bivy App or connect a custom GitHub App.`};let t=e.apps.filter(e=>e.installed||(e.installCount??0)>0);if(!t.length)return{tone:`warn`,label:`App connected · installation needed`,detail:`Install the app on repositories, or refresh if installation status has not synced.`};let n=t.some(e=>e.central),r=t.some(e=>!e.central);return{tone:`on`,label:n&&r?`Hosted + custom apps connected`:n?`Hosted Bivy App connected`:`Custom GitHub App connected`,detail:`Repository access is connected. Automations separately need an available executor.`}}function ke(e,t=``){return[...new Set((e?.apps??[]).filter(e=>!t||e.appId===t).map(e=>e.mention?.replace(/^@/,``)).filter(e=>!!e))]}function Ae(e){let t=encodeURIComponent(e.installationId);return e.githubAccountType===`Organization`&&e.githubAccount?`https://github.com/organizations/${encodeURIComponent(e.githubAccount)}/settings/installations/${t}`:`https://github.com/settings/installations/${t}`}var Z=F();function je({info:e,onChanged:t}){let n=(0,H.useId)(),r=e.apps.find(e=>e.triggerAccess)?.triggerAccess??e.triggerAccess??`everyone`,[i,a]=(0,H.useState)(r),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(``),[u,d]=(0,H.useState)(!1);(0,H.useEffect)(()=>{a(r)},[r]);async function f(e){s(!0),l(``),d(!1);try{a(await C.setGithubAppTriggerAccess(e)),d(!0),t?.()}catch(e){l(String(e.message||e))}finally{s(!1)}}return(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:n,children:`Who can trigger with a GitHub mention?`}),(0,Z.jsxs)(`select`,{id:n,className:`picker-search`,value:i,disabled:o,onChange:e=>void f(e.target.value),children:[(0,Z.jsx)(`option`,{value:`everyone`,children:`Anyone on GitHub`}),(0,Z.jsx)(`option`,{value:`contributor`,children:`Contributors and collaborators`}),(0,Z.jsx)(`option`,{value:`collaborator`,children:`Collaborators with write access`})]}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Applies to every GitHub App on your Bivy account, not just this automation. Changes save immediately. Label events already require permission to apply labels on GitHub.`}),o&&(0,Z.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Saving permissions…`}),u&&!o&&(0,Z.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Permissions saved.`}),c&&(0,Z.jsx)(`p`,{className:`settings-error`,role:`alert`,children:c})]})}function Me(){try{sessionStorage.setItem(`bivy.githubAppPending`,`1`)}catch{}}function Q(e){return e.appId||e.hookId||e.slug||``}function Ne(e){return e.installUrl||(e.slug?`https://github.com/apps/${e.slug}/installations/new`:`https://github.com/settings/installations`)}function Pe(e){switch(e){case`linear`:return`Connect Linear`;case`slack`:return`Connect Slack`;default:return`GitHub App setup`}}function Fe(e){switch(e){case`linear`:return`Connect Linear to receive issue events. Your automation chooses which labels start a run and what the agent does.`;case`slack`:return`Turn a Slack slash command into an unattended run. Connect, copy the Request URL, or disconnect — all here.`;default:return`Manage the hosted Bivy GitHub App and your custom apps. App installation grants repository access; each automation configures which events start a run.`}}function Ie({state:e,onClose:t,focus:n=`github`,onChanged:r}){let a=!C.direct,o=(0,H.useRef)(r);o.current=r;let s=O(t);ue(s);let[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),[f,p]=(0,H.useState)(!0),[m,_]=(0,H.useState)([]),[v,x]=(0,H.useState)(null),[S,ee]=(0,H.useState)(null),[te,ne]=(0,H.useState)(null),[re,ie]=(0,H.useState)(``),[T,se]=(0,H.useState)(``),[ce,E]=(0,H.useState)(``),[le,D]=(0,H.useState)(!1),[k,A]=(0,H.useState)(null),[j,M]=(0,H.useState)(!1),[N,de]=(0,H.useState)(``),[P,fe]=(0,H.useState)(``),[F,pe]=(0,H.useState)(``),[me,he]=(0,H.useState)(!1),[I,L]=(0,H.useState)(null),[R,ge]=(0,H.useState)(``),[z,_e]=(0,H.useState)(!1),[B,ve]=(0,H.useState)(null),[V,ye]=(0,H.useState)(!1),be=(0,H.useRef)(null),[U,xe]=(0,H.useState)(null),[W,G]=(0,H.useState)(null),[Se,Ce]=(0,H.useState)(!1),[we,Te]=(0,H.useState)(null),[Ee,K]=(0,H.useState)(``),[q,J]=(0,H.useState)(``),[De,Y]=(0,H.useState)(!1),[X,Oe]=(0,H.useState)(``),[ke,Ie]=(0,H.useState)(!1),[Be,Ve]=(0,H.useState)(``),[He,Ue]=(0,H.useState)(``),[We,Ge]=(0,H.useState)(!1),[Ke,qe]=(0,H.useState)(``),[Je,Ye]=(0,H.useState)(!1),Xe=e.presentation.githubApp,$=Xe?.phase??`idle`,Ze=$===`submitting`&&Xe?.action&&Xe?.manifest,Qe=n===`github`||n===`work-queue`,$e=n===`linear`,et=n===`slack`,tt=(0,H.useCallback)(async()=>{if(!a){ie(`Source setup needs a hosted account connection.`),p(!1);return}ie(``),p(!0);try{let[e,t,n,r,i,a]=await Promise.all([C.fetchGithubApp(),C.listNodes(),oe(C.local).catch(()=>null),y(C.local).catch(()=>null),ae(C.local).catch(()=>null),C.centralGithubApp().catch(()=>null)]);d(a),l(e),_(t),x(n),ee(r),ne(i);let o=e.apps.find(e=>e.defaultNode)?.defaultNode??e.defaultNode??``;E(o||``),n?.defaultNode&&J(n.defaultNode),r?.defaultNode&&Ue(r.defaultNode)}catch(e){ie(String(e.message||e))}finally{p(!1)}},[a]);(0,H.useEffect)(()=>{tt();let e=()=>{tt(),o.current?.()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[tt]),(0,H.useEffect)(()=>{$===`done`&&(tt(),o.current?.())},[$,tt]);let nt=c?.apps??[],rt=nt.some(e=>e.installed),it=nt.some(e=>e.servedBy?.online),at=!!te?.execution.ready,ot=nt.length>0&&rt&&(at||it);async function st(){Ce(!0),Te(null);try{let e=await C.createCentralGithubInstall(`/automations`);window.location.assign(e.installUrl)}catch(e){Te(String(e?.message||e)),Ce(!1)}}async function ct(){D(!0),A(null);try{let e=await C.setGithubAppDefaultNode(ce.trim());A(`Saved`),l(t=>t&&{...t,defaultNode:e,apps:t.apps.map(t=>({...t,defaultNode:e}))}),r?.(),setTimeout(()=>A(null),1500)}catch(e){A(String(e.message||e))}finally{D(!1)}}async function lt(){he(!0),ge(``),_e(!1),L(null);try{if(e.connection.currentNodeId)await C.githubAppConnectExisting({appId:N.trim(),privateKeyPem:P.trim()}),_e(!0);else{let e=await C.connectHostedGithubApp({appId:N.trim(),privateKeyPem:P.trim(),...F.trim()?{installationId:F.trim()}:{}});L({webhookUrl:e.webhookUrl,webhookSecret:e.webhookSecret})}fe(``),await tt(),r?.()}catch(e){ge(String(e?.message||e))}finally{he(!1)}}async function ut(e){let t=Q(e);if(confirm(`Disconnect ${e.name||e.mention||`this GitHub App`}? The key is wiped on this machine; the app is not deleted on GitHub.`)){G(null),xe(t);try{await C.githubAppDisconnect(e.appId,e.hookId),await tt(),r?.(),(await C.fetchGithubApp()).apps.some(e=>Q(e)===t)&&G(`Disconnect didn't take effect — try again shortly.`)}catch(e){G(String(e.message||e))}finally{xe(null)}}}function dt(e){ve(e??null),de(e?.appId??``),fe(``),ge(``),_e(!1),L(null),M(!0),ye(!0)}(0,H.useEffect)(()=>{V&&j&&be.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[V,j,B]);function ft(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>fe(String(n.result||``).trim()),n.readAsText(t)}async function pt(){Y(!0),Oe(``);try{let e=await g(C.local,{defaultNode:q||void 0});x(e),r?.()}catch(e){Oe(String(e.message||e))}finally{Y(!1)}}async function mt(){Y(!0),Oe(``);try{let e=await g(C.local,{signingSecret:Ee.trim(),defaultNode:q||void 0});x(e),K(``),Ie(!!e.enabled),r?.()}catch(e){Oe(String(e.message||e))}finally{Y(!1)}}async function ht(){if(confirm(`Disconnect Linear? Its webhook URL will stop accepting issues.`)){Y(!0),Oe(``);try{await i(C.local),x(null),Ie(!1),r?.()}catch(e){Oe(String(e.message||e))}finally{Y(!1)}}}async function gt(){Ge(!0),qe(``);try{let e=await h(C.local,{signingSecret:Be.trim(),defaultNode:He||void 0});ee(e),Ve(``),Ye(!0),r?.()}catch(e){qe(String(e.message||e))}finally{Ge(!1)}}async function _t(){if(confirm(`Disconnect Slack? The slash-command URL will stop accepting requests.`)){Ge(!0),qe(``);try{await b(C.local),ee(null),Ye(!1),r?.()}catch(e){qe(String(e.message||e))}finally{Ge(!1)}}}let vt=n===`github`&&(c?.connected||rt)?`Manage GitHub Apps`:Pe(n),yt=n===`slack`&&S?.enabled?`Done — Slack is live`:n===`linear`&&v?.enabled?`Done — Linear is live`:n===`github`&&ot?`Done — GitHub is live`:ot&&n===`work-queue`?`Done — ready to run`:`Done`;return(0,Z.jsx)(`div`,{className:`wizard-scrim`,onClick:s,children:(0,Z.jsxs)(`div`,{className:`wizard autom-editor wq-setup`,role:`dialog`,"aria-modal":`true`,"aria-label":vt,onClick:e=>e.stopPropagation(),children:[(0,Z.jsxs)(`div`,{className:`wizard-head`,children:[(0,Z.jsxs)(`div`,{className:`wq-head-text`,children:[(0,Z.jsx)(`strong`,{children:vt}),(0,Z.jsx)(`span`,{className:`wq-head-sub`,children:`Automations · Sources`})]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:s,"aria-label":`Close`,children:`✕`})]}),(0,Z.jsxs)(`div`,{className:`wizard-body`,children:[(0,Z.jsx)(`p`,{className:`settings-hint wq-lead`,children:Fe(n)}),f&&(0,Z.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Checking source connection…`}),re&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:[re,(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void tt(),children:`Retry`})]}),Qe&&c&&(0,Z.jsxs)(`div`,{className:`autom-field-block`,children:[(0,Z.jsxs)(`div`,{className:`autom-field-label`,children:[(0,Z.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,Z.jsx)(Le,{})}),`GitHub Apps`]}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Enable label or mention events in an automation to start runs. Labels are configurable per automation; mention events use the app handles below and do not require a label.`}),!nt.some(e=>e.central)&&(0,Z.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[(0,Z.jsx)(`strong`,{children:`Hosted Bivy GitHub App · Recommended`}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Choose repositories on GitHub and start using Bivy. No app creation or private key is needed.`}),!u?.configured&&(0,Z.jsx)(`p`,{className:`settings-hint`,children:u?`The hosted app is not enabled on this deployment. You can use your own app below.`:`Could not check hosted app availability. Refresh status to try again.`}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:Se||!u?.configured,onClick:()=>void st(),children:Se?`Opening GitHub…`:`Install hosted Bivy App`}),(0,Z.jsx)(`a`,{className:`btn sm`,href:`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:`Manage hosted app access on GitHub ↗`}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Change repository access or uninstall the Bivy App on GitHub. For organization installations, use the organization’s Settings → GitHub Apps.`}),we&&(0,Z.jsx)(`p`,{className:`settings-error`,role:`alert`,children:we})]}),nt.length===0?(0,Z.jsxs)(`details`,{className:`card wq-status-card`,"data-tone":`muted`,children:[(0,Z.jsx)(`summary`,{children:`Use your own GitHub App`}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`No custom GitHub App connected. Create your own app on a connected machine, or connect an app you already own.`}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`wq-org`,children:`Organization (optional)`}),(0,Z.jsx)(`input`,{id:`wq-org`,className:`picker-search`,value:T,placeholder:`leave blank for your personal account`,disabled:$===`starting`||$===`submitting`||$===`completing`,onChange:e=>se(e.target.value)}),Ze?(0,Z.jsxs)(`form`,{method:`post`,action:Xe.action,onSubmit:Me,children:[(0,Z.jsx)(`input`,{type:`hidden`,name:`manifest`,value:JSON.stringify(Xe.manifest)}),(0,Z.jsx)(`button`,{className:`btn primary block`,type:`submit`,children:`Continue to GitHub →`})]}):(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:$===`starting`||$===`completing`||!a,onClick:()=>C.githubAppManifestStart(T.trim()||void 0),children:$===`starting`?`Preparing…`:$===`completing`?`Finishing…`:`Create GitHub App`}),!j&&(0,Z.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>M(!0),children:`Connect an existing app instead →`}),j&&(0,Z.jsxs)(`div`,{className:`ce-form`,children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`App ID`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:N,placeholder:`e.g. 123456`,onChange:e=>de(e.target.value)}),(0,Z.jsx)(`label`,{className:`field-label`,children:`Private key (.pem)`}),(0,Z.jsx)(`input`,{className:`ce-file`,type:`file`,accept:`.pem,application/x-pem-file,text/plain`,onChange:ft}),(0,Z.jsx)(`textarea`,{className:`picker-search ce-pem`,value:P,rows:3,placeholder:`…or paste the PEM here`,onChange:e=>fe(e.target.value)}),!e.connection.currentNodeId&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`Installation ID (only needed for apps installed on multiple accounts)`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:F,placeholder:`auto-selected when there is one`,onChange:e=>pe(e.target.value)})]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!N.trim()||!P.trim()||$===`completing`||me,onClick:()=>void lt(),children:$===`completing`||me?`Connecting…`:e.connection.currentNodeId?`Connect app to this machine`:`Connect app for isolated runs`}),R&&(0,Z.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:R}),z&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`App connected.`}),` This machine now holds the key and can claim GitHub work.`]}),I&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`Hosted App ready.`}),` Set its webhook URL to `,(0,Z.jsx)(`code`,{children:I.webhookUrl}),` and secret to `,(0,Z.jsx)(`code`,{children:I.webhookSecret}),`.`]})]}),$===`completing`&&(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Finishing on the machine…`}),$===`done`&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`App ready.`}),` Install it on a repository so it can receive issues.`,` `,(0,Z.jsx)(`a`,{href:Xe?.installUrl||`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:`Install on GitHub →`})]}),$===`error`&&(0,Z.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:Xe?.error||`GitHub App setup failed.`})]}):(0,Z.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[nt.map(t=>(0,Z.jsx)(`div`,{className:`wq-app-row`,children:(0,Z.jsxs)(`div`,{className:`wq-app-row-main`,children:[(0,Z.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,Z.jsx)(`strong`,{children:t.name||t.mention||`GitHub App`}),(0,Z.jsx)(w,{tone:t.installed?`ok`:`warn`,children:t.installed?`Connected`:t.installed===!1?`Needs install`:`Installation not verified`})]}),t.owner&&(0,Z.jsxs)(`span`,{className:`settings-hint`,children:[t.ownerType===`Organization`?`org`:`personal`,` · `,t.owner]}),(0,Z.jsxs)(`span`,{className:`settings-hint`,children:[(0,Z.jsx)(`strong`,{children:`Mention trigger:`}),` `,t.mention?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`code`,{children:[`@`,t.mention]}),` followed by your instructions`]}):`Handle not available yet — refresh app status.`]}),t.central?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{className:`settings-hint`,children:[`Hosted Bivy App · `,(t.installations??[]).map(e=>e.githubAccount).filter(Boolean).join(`, `)||`installed`]}),(t.installations??[]).map(e=>(0,Z.jsxs)(`a`,{className:`btn sm`,href:Ae(e),target:`_blank`,rel:`noreferrer`,children:[`Configure / uninstall · `,e.githubAccount||e.installationId,` ↗`]},e.installationId)),(0,Z.jsx)(`span`,{className:`settings-hint`,children:`Change repository access or uninstall on GitHub. Uninstalling stops events for that installation.`}),(0,Z.jsx)(`button`,{type:`button`,className:`btn link`,disabled:Se,onClick:()=>void st(),children:Se?`Opening GitHub…`:`Add another account or organization →`})]}):t.installed===!1?(0,Z.jsxs)(`p`,{className:`schedule-hint warn`,children:[`Not installed on any repo yet.`,` `,(0,Z.jsx)(`a`,{href:Ne(t),target:`_blank`,rel:`noreferrer`,children:`Install it now →`})]}):(0,Z.jsxs)(`span`,{className:`settings-hint`,children:[`Installed on `,t.installCount??`some`,` `,t.installCount===1?`repo`:`repos`,`.`,` `,(0,Z.jsx)(`a`,{href:Ne(t),target:`_blank`,rel:`noreferrer`,children:`Manage →`})]}),t.central?(0,Z.jsx)(`span`,{className:`settings-hint`,children:`Repository access is connected. Runs separately need an online machine or a ready isolated profile.`}):at?(0,Z.jsx)(`span`,{className:`settings-hint`,children:`An isolated machine profile is ready to run automations.`}):t.hosted?(0,Z.jsx)(`span`,{className:`settings-hint`,children:`Hosted custom app connected; configure an isolated machine profile to run automations.`}):t.servedBy===null?(0,Z.jsxs)(`p`,{className:`schedule-hint warn`,children:[`No online machine holds this app's key — queue items won't be claimed.`,` `]}):t.servedBy&&(0,Z.jsxs)(`span`,{className:`settings-hint`,children:[`Served by `,(0,Z.jsx)(`strong`,{children:t.servedBy.name||t.servedBy.id}),t.servedBy.online?``:` (offline)`,`.`]}),!t.central&&e.connection.currentNodeId&&(0,Z.jsx)(`span`,{className:`settings-hint`,children:`Using a new machine? Connect the existing App’s private key below — no reinstall on GitHub needed.`}),!t.central&&(0,Z.jsxs)(`div`,{className:`row-actions`,style:{marginTop:6},children:[e.connection.currentNodeId&&(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>dt(t),children:`Connect key on this machine`}),(0,Z.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:U!==null,onClick:()=>void ut(t),children:U===Q(t)?`Disconnecting…`:`Disconnect`})]})]})},Q(t))),(W||we)&&(0,Z.jsx)(`p`,{className:`settings-error`,children:W||we}),(0,Z.jsxs)(`div`,{className:`settings-field`,style:{marginTop:4},children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`wq-default-node`,children:`Default machine for untagged work`}),(0,Z.jsxs)(`select`,{id:`wq-default-node`,className:`picker-search`,value:ce,onChange:e=>E(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Shared queue (any online machine)`}),m.map(e=>(0,Z.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,Z.jsxs)(`div`,{className:`row-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:le,onClick:()=>void ct(),children:le?`Saving…`:`Save`}),k&&(0,Z.jsx)(`span`,{className:`settings-hint`,children:k})]})]}),(0,Z.jsx)(je,{info:c,onChanged:()=>{tt(),r?.()}}),V?(0,Z.jsxs)(`div`,{ref:be,className:`card wq-status-card`,"data-tone":`muted`,style:{marginTop:4},children:[(0,Z.jsx)(`div`,{className:`autom-field-label`,children:B?`Reconnect ${B.name||B.mention||`GitHub App`}`:`Add another app`}),B?(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[`Choose the private key for App ID `,N,` to connect it to this machine.`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`settings-hint`,children:`One app per personal account or organization you want Bivy to cover.`}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`wq-org-2`,children:`Organization (optional)`}),(0,Z.jsx)(`input`,{id:`wq-org-2`,className:`picker-search`,value:T,placeholder:`leave blank for your personal account`,disabled:$===`starting`||$===`submitting`||$===`completing`,onChange:e=>se(e.target.value)}),Ze?(0,Z.jsxs)(`form`,{method:`post`,action:Xe.action,onSubmit:Me,children:[(0,Z.jsx)(`input`,{type:`hidden`,name:`manifest`,value:JSON.stringify(Xe.manifest)}),(0,Z.jsx)(`button`,{className:`btn primary block`,type:`submit`,children:`Continue to GitHub →`})]}):(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:$===`starting`||$===`completing`||!a,onClick:()=>C.githubAppManifestStart(T.trim()||void 0),children:$===`starting`?`Preparing…`:$===`completing`?`Finishing…`:`Create GitHub App`}),(0,Z.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>dt(),children:`Connect an existing app instead →`})]}),j&&(0,Z.jsxs)(`div`,{className:`ce-form`,children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`App ID`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:N,placeholder:`e.g. 123456`,onChange:e=>de(e.target.value)}),(0,Z.jsx)(`label`,{className:`field-label`,children:`Private key (.pem)`}),(0,Z.jsx)(`input`,{className:`ce-file`,type:`file`,accept:`.pem,application/x-pem-file,text/plain`,onChange:ft}),(0,Z.jsx)(`textarea`,{className:`picker-search ce-pem`,value:P,rows:3,placeholder:`…or paste the PEM here`,onChange:e=>fe(e.target.value)}),!e.connection.currentNodeId&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`Installation ID (only needed for apps installed on multiple accounts)`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:F,placeholder:`auto-selected when there is one`,onChange:e=>pe(e.target.value)})]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!N.trim()||!P.trim()||$===`completing`||me,onClick:()=>void lt(),children:$===`completing`||me?`Connecting…`:e.connection.currentNodeId?`Connect app to this machine`:`Connect app for isolated runs`}),R&&(0,Z.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:R}),z&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`App connected.`}),` This machine now holds the key and can claim GitHub work.`]}),I&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`Hosted App ready.`}),` Set its webhook URL to `,(0,Z.jsx)(`code`,{children:I.webhookUrl}),` and secret to `,(0,Z.jsx)(`code`,{children:I.webhookSecret}),`.`]})]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>{ye(!1),ve(null)},children:`Cancel`})]}):(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{ye(!0),M(!1),ve(null)},children:`+ Connect another custom GitHub App`}),ot&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`App installed.`}),` Configure and enable an automation to choose its labels, mention events, and instructions.`]})]})]}),$e&&(0,Z.jsxs)(`div`,{className:`autom-field-block`,children:[(0,Z.jsxs)(`div`,{className:`autom-field-label`,children:[(0,Z.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,Z.jsx)(Re,{})}),`Linear`]}),(0,Z.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[X&&(0,Z.jsx)(`p`,{className:`settings-error`,children:X}),ke&&v?.enabled&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`Linear is live.`}),` Label an issue `,(0,Z.jsx)(`code`,{children:`bivy`}),` (or `,(0,Z.jsx)(`code`,{children:`bivy/<machine>`}),`) to enqueue it.`]}),v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,Z.jsx)(`strong`,{children:v.enabled?`Connected`:`Finish connecting`}),(0,Z.jsx)(w,{tone:v.enabled?`ok`:`warn`,children:v.enabled?`Live`:`Needs secret`})]}),(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[`In `,(0,Z.jsx)(`strong`,{children:`Linear → Settings → API → Webhooks`}),`, create an `,(0,Z.jsx)(`strong`,{children:`Issue`}),` webhook with this URL:`]}),(0,Z.jsxs)(`div`,{className:`reveal-row`,children:[(0,Z.jsx)(`code`,{className:`reveal-value`,children:v.endpoint}),(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void navigator.clipboard?.writeText(v.endpoint),children:`Copy`})]}),(0,Z.jsxs)(`ol`,{className:`wq-how-list`,style:{paddingLeft:18},children:[(0,Z.jsx)(`li`,{children:`Copy the signing secret Linear generates.`}),(0,Z.jsxs)(`li`,{children:[`Paste it below`,v.enabled?` to rotate`:` to finish`,`.`]}),(0,Z.jsxs)(`li`,{children:[`Create labels `,(0,Z.jsx)(`code`,{children:`bivy`}),` and optionally use the compatibility label `,(0,Z.jsx)(`code`,{children:`bivy/node-name`}),` to choose a machine.`]})]}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`lin-secret`,children:v.enabled?`Replace signing secret`:`Linear signing secret`}),(0,Z.jsx)(`input`,{id:`lin-secret`,className:`picker-search`,type:`password`,autoComplete:`off`,value:Ee,disabled:De,placeholder:`Signing secret from Linear`,onChange:e=>K(e.target.value)}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`lin-route-2`,children:`Default machine (optional)`}),(0,Z.jsxs)(`select`,{id:`lin-route-2`,className:`picker-search`,value:q,disabled:De,onChange:e=>J(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Shared queue`}),m.map(e=>(0,Z.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:De||Ee.trim().length<16,onClick:()=>void mt(),children:De?`Saving…`:v.enabled?`Update connection`:`Connect Linear`}),(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[`Each trusted workstation also needs `,(0,Z.jsx)(`code`,{children:`BIVY_LINEAR_API_KEY`}),` and a default `,(0,Z.jsx)(`code`,{children:`BIVY_LINEAR_REPO=owner/repo`}),`.`]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:De,onClick:()=>void ht(),children:`Disconnect Linear`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Create a Bivy webhook URL, paste it into Linear, then bring Linear's signing secret back here.`}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`lin-route`,children:`Default machine (optional)`}),(0,Z.jsxs)(`select`,{id:`lin-route`,className:`picker-search`,value:q,disabled:De,onChange:e=>J(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Shared queue`}),m.map(e=>(0,Z.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:De||!a,onClick:()=>void pt(),children:De?`Creating…`:`Create webhook URL`})]})]})]}),et&&(0,Z.jsxs)(`div`,{className:`autom-field-block`,children:[(0,Z.jsxs)(`div`,{className:`autom-field-label`,children:[(0,Z.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,Z.jsx)(ze,{})}),`Slack`]}),(0,Z.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[Ke&&(0,Z.jsx)(`p`,{className:`settings-error`,children:Ke}),Je&&S?.enabled&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,Z.jsx)(`strong`,{children:`Slack is live.`}),` Paste the Request URL into your slash command, then try`,` `,(0,Z.jsx)(`code`,{children:`/bivy fix the failing tests`}),`.`]}),S?.enabled?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,Z.jsx)(`strong`,{children:`Connected`}),(0,Z.jsx)(w,{tone:`ok`,children:`Live`})]}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Use this as your Slack app's slash-command Request URL:`}),(0,Z.jsxs)(`div`,{className:`reveal-row`,children:[(0,Z.jsx)(`code`,{className:`reveal-value`,children:S.endpoint}),(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void navigator.clipboard?.writeText(S.endpoint),children:`Copy`})]}),(0,Z.jsx)(`div`,{className:`autom-field-label`,style:{marginTop:4},children:`Commands`}),(0,Z.jsx)(`code`,{className:`wq-cmd`,children:`/bivy fix the failing tests`}),(0,Z.jsx)(`code`,{className:`wq-cmd`,children:`/bivy on macbook fix the failing tests`}),(0,Z.jsx)(`code`,{className:`wq-cmd`,children:`/bivy in owner/repo fix the failing tests`}),(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[`Add `,(0,Z.jsx)(`code`,{children:`in owner/repo`}),` for an isolated checkout + PR. Add `,(0,Z.jsx)(`code`,{children:`on machine-name`}),` to choose a machine.`]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:We,onClick:()=>void _t(),children:`Disconnect Slack`})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`ol`,{className:`wq-how-list`,style:{paddingLeft:18},children:[(0,Z.jsxs)(`li`,{children:[`Create a Slack app, then open `,(0,Z.jsx)(`strong`,{children:`Basic Information`}),`.`]}),(0,Z.jsxs)(`li`,{children:[`Copy its `,(0,Z.jsx)(`strong`,{children:`Signing Secret`}),` below.`]}),(0,Z.jsxs)(`li`,{children:[`After connecting, create a slash command named `,(0,Z.jsx)(`code`,{children:`/bivy`}),` and paste the Request URL shown here.`]})]}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`slack-secret`,children:`Slack signing secret`}),(0,Z.jsx)(`input`,{id:`slack-secret`,className:`picker-search`,type:`password`,autoComplete:`off`,value:Be,disabled:We,placeholder:`Signing Secret`,onChange:e=>Ve(e.target.value)}),(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`slack-route`,children:`Default machine (optional)`}),(0,Z.jsxs)(`select`,{id:`slack-route`,className:`picker-search`,value:He,disabled:We,onChange:e=>Ue(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`Shared queue`}),m.map(e=>(0,Z.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:We||Be.trim().length<16||!a,onClick:()=>void gt(),children:We?`Connecting…`:`Connect Slack`})]})]})]})]}),(0,Z.jsxs)(`div`,{className:`wizard-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`btn ghost`,"aria-label":`Refresh source status`,disabled:f,onClick:()=>{tt(),o.current?.()},children:`Refresh`}),(0,Z.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:s,children:yt})]})]})})}function Le(){return(0,Z.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:(0,Z.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27s1.36.09 2 .27c1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z`})})}function Re(){return(0,Z.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,Z.jsx)(`path`,{d:`M2.86 16.14a3.43 3.43 0 0 0 4.85 4.85L21.14 7.56A3.43 3.43 0 0 0 16.29 2.7L2.86 16.14Z`,opacity:`.35`}),(0,Z.jsx)(`path`,{d:`M3.43 12a.86.86 0 0 0-.86.86v4.28A5.14 5.14 0 0 0 7.71 22.3h4.29a.86.86 0 0 0 0-1.72H7.71A3.43 3.43 0 0 1 4.29 17.14v-4.28A.86.86 0 0 0 3.43 12Zm8.57-9.43a.86.86 0 0 0 0 1.72h4.29a3.43 3.43 0 0 1 3.42 3.42v4.29a.86.86 0 0 0 1.72 0V7.71A5.14 5.14 0 0 0 16.29 2.57H12Z`})]})}function ze(){return(0,Z.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:(0,Z.jsx)(`path`,{d:`M6 15a2 2 0 1 1-2-2h2v2Zm1 0a2 2 0 1 1 4 0v5a2 2 0 1 1-4 0v-5Zm2-8a2 2 0 1 1 2-2v2H9Zm0 1a2 2 0 1 1 0 4H4a2 2 0 1 1 0-4h5Zm8 2a2 2 0 1 1 2 2h-2V10Zm-1 0a2 2 0 1 1-4 0V5a2 2 0 1 1 4 0v5Zm-2 8a2 2 0 1 1-2 2v-2h2Zm0-1a2 2 0 1 1 0-4h5a2 2 0 1 1 0 4h-5Z`})})}function Be(e){if(e.trigger===`github_ci`)return{issuesLabeled:!1,issueMention:!1,prLabeled:!1,prMention:!1,workflowFailed:!0};let t=e.on;return t?.length?{issuesLabeled:t.some(e=>e.event===`issues`&&!e.mention),issueMention:t.some(e=>[`issues`,`pull_request`,`issue_comment`].includes(e.event)&&e.mention),prLabeled:t.some(e=>e.event===`pull_request`&&!e.mention),prMention:t.some(e=>e.event===`pull_request_review_comment`&&e.mention),workflowFailed:t.some(e=>e.event===`workflow_run`)}:{issuesLabeled:!0,issueMention:!0,prLabeled:!1,prMention:!1,workflowFailed:!1}}function Ve(e,t,n){let r=t?.length?t:[`bivy`],i=[];return e.issuesLabeled&&i.push({event:`issues`,labels:r}),e.issueMention&&i.push({event:`issues`,mention:!0},{event:`pull_request`,mention:!0},{event:`issue_comment`,mention:!0}),e.prLabeled&&i.push({event:`pull_request`,labels:r}),e.prMention&&i.push({event:`pull_request_review_comment`,mention:!0}),e.workflowFailed&&i.push({event:`workflow_run`,actions:[`completed`],conclusions:[`failure`,`timed_out`,`startup_failure`],workflows:n?.length?n:void 0}),i}function He({mode:e,header:t,secret:n,existing:r,onMode:i,onHeader:a,onSecret:o}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-mode`,children:`Authentication method`}),(0,Z.jsxs)(`select`,{id:`webhook-auth-mode`,className:`picker-search`,value:e,onChange:e=>i(e.target.value),children:[(0,Z.jsx)(`option`,{value:`hmac`,children:`HMAC-SHA256 signature (recommended)`}),(0,Z.jsx)(`option`,{value:`header`,children:`Static secret header`})]}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:e===`hmac`?`The sender signs the raw request body with your secret. The header value is sha256= followed by the hexadecimal HMAC digest, not the secret itself.`:`The sender puts the exact secret value in this header. Use HTTPS; unlike HMAC, this does not bind authentication to the request body.`})]}),(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-header`,children:`Header name`}),(0,Z.jsx)(`input`,{id:`webhook-auth-header`,className:`picker-search`,value:t,maxLength:128,spellCheck:!1,onChange:e=>a(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-secret`,children:e===`hmac`?`Custom signing secret (optional)`:`Custom header value (optional)`}),(0,Z.jsx)(`input`,{id:`webhook-auth-secret`,className:`picker-search`,type:`password`,autoComplete:`new-password`,value:n,minLength:32,maxLength:256,onChange:e=>o(e.target.value)}),(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[r?`Leave blank to keep the current secret. Enter a value to replace it immediately on save.`:`Leave blank to generate a secure secret on save.`,` Custom values must be 32–256 printable characters. Secrets are never included in list responses.`]})]})]})}function Ue({value:e,error:t,onChange:n}){let r=(0,H.useId)(),i=(t,r)=>n({...e,[t]:r});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`label`,{className:`settings-toggle-row webhook-signing-toggle`,children:[(0,Z.jsxs)(`span`,{className:`settings-toggle-text`,children:[(0,Z.jsx)(`strong`,{className:`settings-toggle-title`,children:`Filter deliveries with a script`}),(0,Z.jsx)(`small`,{className:`muted`,children:`Run a script on the machine first. It decides whether each delivery starts the agent.`})]}),(0,Z.jsx)(`input`,{className:`sr-only`,type:`checkbox`,checked:e.enabled,onChange:e=>i(`enabled`,e.target.checked)}),(0,Z.jsx)(`span`,{className:`settings-toggle${e.enabled?` on`:``}`,"aria-hidden":`true`,children:(0,Z.jsx)(`span`,{className:`settings-toggle-knob`})})]}),e.enabled&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-command`,children:`Command`}),(0,Z.jsx)(`input`,{id:`${r}-command`,className:`picker-search`,value:e.command,placeholder:`node filter.mjs`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,onChange:e=>i(`command`,e.target.value)}),(0,Z.jsxs)(`p`,{className:`settings-hint`,children:[`Runs directly, without a shell. Quote arguments that contain spaces. The script receives `,(0,Z.jsx)(`code`,{children:`{"event":{"payload":…}}`}),` on stdin and must print `,(0,Z.jsx)(`code`,{children:`{"decision":"accept"}`}),` or `,(0,Z.jsx)(`code`,{children:`{"decision":"skip","reason":"…"}`}),`.`]})]}),(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-cwd`,children:`Directory on the machine`}),(0,Z.jsx)(`input`,{id:`${r}-cwd`,className:`picker-search`,value:e.cwd,placeholder:`/srv/bivy/trusted-filters`,autoComplete:`off`,autoCapitalize:`off`,spellCheck:!1,onChange:e=>i(`cwd`,e.target.value)}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Absolute path to scripts you put there yourself. Do not use a repository the agent can edit: the script runs as the Bivy user and is not sandboxed.`})]}),(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-timeout`,children:`Timeout (seconds)`}),(0,Z.jsx)(`input`,{id:`${r}-timeout`,className:`picker-search`,type:`number`,inputMode:`numeric`,min:1,max:60,step:1,value:e.timeoutSeconds,onChange:e=>i(`timeoutSeconds`,e.target.value)}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`A skip completes the run without starting the agent. A script error, invalid output, or timeout marks the run as needing attention.`})]}),t&&(0,Z.jsx)(`p`,{className:`schedule-hint warn`,children:t})]})]})}function We(e){return e?{enabled:!0,command:qe(e.command),cwd:e.cwd,timeoutSeconds:String(e.timeoutSeconds)}:{enabled:!1,command:``,cwd:``,timeoutSeconds:`5`}}function Ge(e){if(!e.enabled)return{};let t=Ke(e.command);if(t===null)return{error:`Close the quote in the filter command.`};if(!t.length)return{error:`Enter the filter command.`};let n=e.cwd.trim();if(!/^(\/|[A-Za-z]:[\\/])/.test(n))return{error:`The filter directory must be an absolute path on the machine.`};let r=Number(e.timeoutSeconds.trim()||`5`);if(!Number.isInteger(r)||r<1||r>60)return{error:`The filter timeout must be a whole number from 1 to 60 seconds.`};try{return{filter:G({command:t,cwd:n,timeoutSeconds:r})}}catch(e){return{error:String(e.message||e)}}}function Ke(e){let t=[],n=``,r=!1,i=null;for(let a of e)i?a===i?i=null:n+=a:a===`'`||a===`"`?(i=a,r=!0):/\s/.test(a)?(r&&t.push(n),n=``,r=!1):(n+=a,r=!0);return i?null:(r&&t.push(n),t)}function qe(e){return e.map(e=>e&&!/[\s'"]/.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`).join(` `)}function Je({value:e,onChange:t,github:n}){let r=(0,H.useId)();return(0,Z.jsxs)(`div`,{className:`settings-field`,children:[(0,Z.jsx)(`label`,{className:`field-label`,htmlFor:r,children:`Limit to these repositories (optional)`}),(0,Z.jsx)(`input`,{id:r,className:`picker-search`,value:e,onChange:e=>t(e.target.value),placeholder:`acme/website, acme/api`}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:n?`Leave blank for any repository the selected GitHub App can access. To accept events only from specific repositories, enter their owner/name, separated by commas. This filters events; it does not grant repository access.`:`Leave blank for any repository. To limit which linked repositories can start this automation, enter their owner/name, separated by commas.`})]})}var Ye=new Set([`succeeded`,`failed`,`cancelled`,`done`]);function Xe(e){return Ye.has(e.status)}function $(e){let t=c(e),n=e.checks??[],r=n.filter(e=>e.status===`passed`).length,i=n.filter(e=>e.status===`failed`).length,a=n.filter(e=>e.status===`skipped`).length,o=n.length?[r?`${r} passed`:``,i?`${i} failed`:``,a?`${a} skipped`:``].filter(Boolean).join(` · `):void 0,s=e.output,l=s?.prUrl?{kind:`pull_request`,label:`Pull request`,url:s.prUrl}:s?.artifactUrl?{kind:`artifact`,label:`Artifact`,url:s.artifactUrl}:s?.branch?{kind:`branch`,label:`Branch ${s.branch}`}:s?.commit?{kind:`commit`,label:`Commit ${s.commit.slice(0,12)}`}:s?.checkpoint?{kind:`checkpoint`,label:`Checkpoint`}:void 0,u=[];return s?.sessionId&&u.push(`open_session`),s?.prUrl?u.push(`view_pull_request`):s?.artifactUrl&&u.push(`view_artifact`),{outcome:t,sessionId:s?.sessionId,attempt:Math.max(1,e.attempt??1),agent:[e.runtimeId,e.model].filter(Boolean).join(` · `)||void 0,failure:s?.failure,checks:n,checksSummary:o,artifact:l,availableActions:u}}var Ze=5;function Qe(e){let t=te(e);if(t)return`${t.repo} #${t.issueNumber}`;if(typeof e==`string`&&e.startsWith(`queue:`)){let t=e.slice(6);return t===`slack`?`Slack`:t===`github:comment`?`GitHub @-mention`:t===`github:issue`?`GitHub issue`:t===`linear:issue`?`Linear issue`:t||`Queue`}return``}function $e(e){return e===`github:comment`?`GitHub @-mention`:e===`github:issue`?`GitHub labelled issue`:e===`linear:issue`?`Linear issue`:e}function et({queue:e,onRefresh:t,onPick:n,onOpenRun:r,onOpenGithubSettings:i,showHistory:a=!0}){let{sessionIndex:{sessions:o},activeSession:{activeSessionId:s},presentation:{prRefreshAllResult:c},catalogs:{runtimes:u}}=se(),d=E(),f=p&&d,m=!C.direct,h=(0,H.useMemo)(()=>[{id:``,label:`Machine default`},...u.map(e=>({id:e.id,label:String(e.displayName||e.name||e.id)}))],[u]),[g,_]=(0,H.useState)(null),[v,y]=(0,H.useState)([]),[b,x]=(0,H.useState)(null),[S,ee]=(0,H.useState)(`shared`),[ne,re]=(0,H.useState)(``),[ie,ae]=(0,H.useState)([]),[T,oe]=(0,H.useState)(``),[ce,le]=(0,H.useState)(``),[D,O]=(0,H.useState)(!1),[A,j]=(0,H.useState)(null),[ue,N]=(0,H.useState)(null),[de,P]=(0,H.useState)(!1),[fe,F]=(0,H.useState)(null),[L,ge]=(0,H.useState)(!1),[B,ve]=(0,H.useState)(null),[V,ye]=(0,H.useState)(null),[be,U]=(0,H.useState)(!1);(0,H.useEffect)(()=>{be&&U(!1)},[c]),(0,H.useEffect)(()=>{if(!c)return;let e=setTimeout(()=>C.store.clearPrRefreshAllResult(),8e3);return()=>clearTimeout(e)},[c]);let xe=async()=>{let e=B;if(e){ve(null),F(null),ye(e.id);try{await C.cancelAutomationRun(e.id),t()}catch(e){F(String(e?.message||e))}finally{ye(null)}}},W=()=>{U(!0),C.refreshAllPrStatus()},[G,Se]=(0,H.useState)(!1),[Ce,we]=(0,H.useState)(null),Te=(0,H.useRef)(null);(0,H.useEffect)(()=>()=>{Te.current&&clearTimeout(Te.current)},[]);let Ee=async e=>{let t={id:e.id,source:e.source,status:e.status,repo:e.repo,issueNumber:e.issueNumber,url:e.url,createdAt:e.createdAt,claimedAt:e.claimedAt,startedAt:e.startedAt,completedAt:e.completedAt,attempt:e.attempt,runtimeId:e.runtimeId,model:e.model,routingReason:e.routingReason,approvalMode:e.approvalMode,sandbox:e.sandbox,output:e.output,checks:e.checks,events:e.events};await M(JSON.stringify(t,null,2))&&(we(e.id),Te.current&&clearTimeout(Te.current),Te.current=setTimeout(()=>we(null),1800))};(0,H.useEffect)(()=>{C.listRuntimes()},[]);let[K,q]=(0,H.useState)([]),[J,De]=(0,H.useState)(``),[Y,X]=(0,H.useState)(!1),[Oe,ke]=(0,H.useState)(!1);(0,H.useEffect)(()=>{m&&(C.fetchGithubApp().then(_).catch(()=>_(null)),C.listNodes().then(y).catch(()=>{}),C.listEphemeralKeys().then(q).catch(()=>{}),f&&C.listEphemeralConfigs().then(ae).catch(()=>{}),C.getGithubTaskToken().then(e=>X(!!e)).catch(()=>{}))},[m,f]);let Ae=(0,H.useMemo)(()=>K.filter(e=>e.configured),[K]),je=(0,H.useMemo)(()=>v.filter(e=>!e.id.startsWith(`eph-`)),[v]),Me=(0,H.useMemo)(()=>new Map(ie.map(e=>[e.id,e])),[ie]),Q=(e=>e.startsWith(`config:`)?{kind:`config`,id:e.slice(7)}:e.startsWith(`node:`)?{kind:`node`,node:e.slice(5)}:{kind:`shared`})(S),Ne=Q.kind===`node`?Q.node:``,Pe=Q.kind===`config`?Me.get(Q.id):void 0,Fe=ne.startsWith(`config:`)?Me.get(ne.slice(7)):void 0,Ie=!!Pe||!!Fe,Le=e=>{j(null),x(e.id);let t=e.label&&e.label.startsWith(`bivy/`)?e.label.slice(5):``;ee(t?`node:${t}`:`shared`),re(``),oe(e.runtimeId??``),le(e.model??``)},Re=async e=>{j(null),O(!0);try{let n=t=>C.runWorkItemOnEphemeral(e,{provider:t.provider,region:t.region||void 0,size:t.size||void 0,ttlMinutes:t.ttlMinutes||void 0,runtimeId:T||void 0,model:ce||void 0,configId:t.id});if(Q.kind===`config`){let e=Me.get(Q.id);if(!e)throw Error(`That isolated machine profile is no longer available`);await n(e)}else if(Q.kind===`node`){let t=je.find(e=>(e.name||e.id)===Q.node);t&&!t.online&&Fe?await n(Fe):await C.assignWorkItem(e,{node:Q.node,runtimeId:T,model:ce})}else await C.assignWorkItem(e,{node:``,runtimeId:T,model:ce});x(null),t()}catch(e){j(String(e?.message||e))}finally{O(!1)}},ze=async()=>{if(J.trim()){ke(!0);try{await C.setGithubTaskToken(J.trim()),De(``),X(!0)}catch(e){j(String(e?.message||e))}finally{ke(!1)}}},Be=async e=>{N(e),F(null);try{await C.deleteWorkItem(e),b===e&&x(null),t()}catch(e){F(String(e?.message||e))}finally{N(null)}},Ve=async()=>{P(!0),F(null);try{await C.clearWorkQueue(),x(null),t()}catch(e){F(String(e?.message||e))}finally{P(!1)}},He=(0,H.useMemo)(()=>[...o].filter(e=>l(e.source)).sort((e,t)=>he(t.updatedAt)-he(e.updatedAt)),[o]),Ue=G?He:He.slice(0,Ze),We=He.length-Ue.length,Ge=(0,H.useMemo)(()=>{let e=new Set;for(let t of He){let n=te(t.source);n&&e.add(`${n.repo}#${n.issueNumber}`)}return e},[He]),Ke=(0,H.useMemo)(()=>e&&e.filter(e=>!(e.status!==`pending`||e.repo&&e.issueNumber!=null&&Ge.has(`${e.repo}#${e.issueNumber}`))),[e,Ge]),qe=(0,H.useMemo)(()=>(e??[]).filter(e=>e.status!==`pending`&&!!e.events?.length).sort((e,t)=>he(t.startedAt??t.claimedAt??t.createdAt)-he(e.startedAt??e.claimedAt??e.createdAt)),[e]),Je=g?.apps??[],Ye=Je.filter(e=>e.servedBy===null);return(0,Z.jsxs)(`div`,{className:`settings-form`,children:[m&&g&&Je.length===0&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`neutral`,children:[`Install the hosted Bivy GitHub App, or connect your own app.`,` `,(0,Z.jsx)(`button`,{className:`btn link`,onClick:i,children:`Set up GitHub Apps →`})]}),m&&Ye.length>0&&(0,Z.jsxs)(`div`,{className:`banner inline`,"data-tone":`warn`,children:[Ye.length===Je.length?`${Je.length===1?`Your GitHub App is`:`Your GitHub Apps are`} set up, but no online machine is running ${Je.length===1?`it`:`them`} — nothing will pick these up.`:`${Ye.length} of your ${Je.length} GitHub Apps (${Ye.map(e=>e.name||e.mention||e.appId).join(`, `)}) aren't running on any machine — work for those won't be picked up.`,` `,(0,Z.jsx)(`button`,{className:`btn link`,onClick:i,children:Ye.length===1?`Connect it on a machine →`:`Connect them on a machine →`})]}),a&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`queue-head`,children:[(0,Z.jsx)(`h4`,{className:`settings-subhead`,children:`Sessions`}),(0,Z.jsxs)(`div`,{className:`queue-head-actions`,children:[c&&!be&&(0,Z.jsx)(`span`,{className:`muted`,children:c.error?c.error:`Checked ${c.scanned}, updated ${c.changed}`}),(0,Z.jsx)(`button`,{className:`btn link`,onClick:W,disabled:be,title:`Reconcile every session's PR status against GitHub now`,children:be?`Refreshing GitHub status…`:`Refresh GitHub status`})]})]}),He.length===0?(0,Z.jsxs)(`p`,{className:`muted`,children:[`No GitHub-triggered sessions yet. Label an issue `,(0,Z.jsx)(`code`,{children:`bivy`}),` or @-mention your app to see one here.`]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`ul`,{className:`queue-session-list`,children:Ue.map(e=>{let t=Qe(e.source),r=z(e),i=me(e.source);return(0,Z.jsx)(`li`,{className:`session-row`,children:(0,Z.jsx)(`button`,{className:`session-item${e.sessionId===s?` active`:``}`,onClick:()=>n(e.sessionId,e.path,e.nodeId),children:(0,Z.jsxs)(`span`,{className:`session-body`,children:[(0,Z.jsxs)(`span`,{className:`session-title-row`,children:[(0,Z.jsx)(_e,{status:I(e),srLabel:`${i.label} · ${r}`}),(0,Z.jsx)(`span`,{className:`session-name`,children:e.name}),(0,Z.jsx)(pe,{prs:e.prs}),R(e.updatedAt)&&(0,Z.jsx)(`span`,{className:`session-age`,title:r,children:R(e.updatedAt)})]}),t&&(0,Z.jsx)(`span`,{className:`session-meta`,children:t})]})})},e.sessionId)})}),He.length>Ze&&(0,Z.jsx)(`button`,{className:`btn link`,onClick:()=>Se(e=>!e),children:G?`Show less`:`Show more (${We})`})]})]}),m&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`queue-head`,children:[(0,Z.jsxs)(`h4`,{className:`settings-subhead`,children:[`Waiting to be picked up`,Ke&&Ke.length>0&&(0,Z.jsx)(`span`,{className:`queue-count`,children:Ke.length})]}),(0,Z.jsxs)(`div`,{className:`queue-head-actions`,children:[Ke&&Ke.length>0&&(0,Z.jsx)(`button`,{className:`btn link danger`,onClick:()=>ge(!0),disabled:de,children:de?`Clearing…`:`Clear queue`}),(0,Z.jsx)(`button`,{className:`btn link`,onClick:t,children:`Refresh`})]})]}),L&&(0,Z.jsx)(k,{title:`Clear the queue?`,message:`Remove all waiting items from the queue? Items already picked up keep running.`,confirmLabel:`Clear queue`,danger:!0,onCancel:()=>ge(!1),onConfirm:()=>{ge(!1),Ve()}}),fe&&(0,Z.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:fe}),Ke===null?(0,Z.jsx)(`p`,{className:`muted`,children:`—`}):Ke.length===0?(0,Z.jsx)(`p`,{className:`muted`,children:`Nothing waiting right now.`}):(0,Z.jsx)(`div`,{className:`queue-list`,children:Ke.map(e=>{let t=b===e.id,n=e.title||`${e.repo??``}#${e.issueNumber??``}`,r=`${e.repo??``}${e.issueNumber?` #${e.issueNumber}`:``} · ${$e(e.source)}`;return(0,Z.jsxs)(`div`,{className:`card queue-card${t?` open`:``}`,"data-tone":`muted`,children:[(0,Z.jsxs)(`div`,{className:`queue-card-row`,children:[e.url?(0,Z.jsxs)(`a`,{className:`queue-item-main link`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:n,children:[(0,Z.jsxs)(`span`,{className:`queue-item-title`,children:[n,f&&e.ephemeral&&(0,Z.jsx)(w,{title:`Dispatched to an ephemeral server`,children:`⚡ ephemeral`})]}),(0,Z.jsx)(`span`,{className:`queue-item-meta`,children:r})]}):(0,Z.jsxs)(`div`,{className:`queue-item-main`,title:n,children:[(0,Z.jsxs)(`span`,{className:`queue-item-title`,children:[n,f&&e.ephemeral&&(0,Z.jsx)(w,{title:`Dispatched to an ephemeral server`,children:`⚡ ephemeral`})]}),(0,Z.jsx)(`span`,{className:`queue-item-meta`,children:r})]}),(0,Z.jsxs)(`div`,{className:`queue-card-actions`,children:[(0,Z.jsx)(`button`,{className:`queue-action-btn${t?` active`:``}`,onClick:()=>t?x(null):Le(e),title:`Dispatch to a machine + agent`,children:t?`Cancel`:`Run…`}),(0,Z.jsx)(`button`,{className:`queue-action-btn danger icon`,onClick:()=>Be(e.id),disabled:ue===e.id,title:`Remove from queue`,"aria-label":`Remove from queue`,children:ue===e.id?`…`:`×`})]})]}),t&&(0,Z.jsxs)(`div`,{className:`queue-run`,children:[(0,Z.jsxs)(`label`,{className:`queue-run-field`,children:[(0,Z.jsx)(`span`,{children:`Machine`}),(0,Z.jsxs)(`select`,{value:S,onChange:e=>ee(e.target.value),children:[(0,Z.jsx)(`option`,{value:`shared`,children:`Shared queue (any online machine)`}),je.length>0&&(0,Z.jsx)(`optgroup`,{label:`Persistent machines`,children:je.map(e=>(0,Z.jsxs)(`option`,{value:`node:${e.name||e.id}`,children:[e.name||e.id,e.online?``:` (offline)`]},e.id))}),f&&ie.length>0&&(0,Z.jsx)(`optgroup`,{label:`Cloud machine profiles`,children:ie.map(e=>(0,Z.jsxs)(`option`,{value:`config:${e.id}`,children:[e.name,` · `,e.provider]},e.id))}),Q.kind===`node`&&!je.some(e=>(e.name||e.id)===Ne)&&(0,Z.jsx)(`option`,{value:S,children:Ne})]})]}),f&&Q.kind===`node`&&ie.length>0&&(0,Z.jsxs)(`label`,{className:`queue-run-field`,children:[(0,Z.jsx)(`span`,{children:`Fallback if machine is offline`}),(0,Z.jsxs)(`select`,{value:ne,onChange:e=>re(e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None — wait for the machine`}),ie.map(e=>(0,Z.jsxs)(`option`,{value:`config:${e.id}`,children:[e.name,` · `,e.provider]},e.id))]})]}),Ie&&(()=>{let e=Pe??Fe,t=Ae.some(t=>t.id===e.provider);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`p`,{className:`muted small`,children:[Pe?`Runs on`:`Falls back to`,` a fresh `,e.provider,` machine`,e.region?` · ${e.region}`:``,e.size?` · ${e.size}`:``,e.ttlMinutes?` · auto-destroy ${e.ttlMinutes}m`:``,`.`,!t&&` Add a ${e.provider} token on this device to launch it.`]}),(0,Z.jsxs)(`label`,{className:`queue-run-field`,children:[(0,Z.jsxs)(`span`,{children:[`GitHub token `,Y?`(saved on this device — leave blank to reuse it)`:`(needed to clone/push/open PRs)`]}),(0,Z.jsxs)(`div`,{className:`row-actions`,children:[(0,Z.jsx)(`input`,{type:`password`,value:J,placeholder:Y?`•••• saved`:`paste a token`,onChange:e=>De(e.target.value)}),(0,Z.jsx)(`button`,{className:`btn link`,disabled:!J.trim()||Oe,onClick:ze,children:Oe?`Saving…`:`Save`})]})]})]})})(),(0,Z.jsxs)(`label`,{className:`queue-run-field`,children:[(0,Z.jsx)(`span`,{children:`Agent`}),(0,Z.jsx)(`select`,{value:T,onChange:e=>oe(e.target.value),children:h.map(e=>(0,Z.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,Z.jsxs)(`label`,{className:`queue-run-field`,children:[(0,Z.jsx)(`span`,{children:`Model`}),(0,Z.jsx)(`input`,{value:ce,placeholder:`optional, e.g. claude-sonnet-5`,onChange:e=>le(e.target.value)})]}),(0,Z.jsxs)(`div`,{className:`queue-run-actions`,children:[(0,Z.jsx)(`button`,{className:`btn`,disabled:D||Q.kind===`config`&&!Pe,onClick:()=>Re(e.id),children:D?`Dispatching…`:Q.kind===`config`?`Provision & run`:`Run`}),A&&(0,Z.jsx)(w,{tone:`danger`,children:A})]})]})]},e.id)})})]}),a&&m&&qe.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`queue-head`,children:(0,Z.jsx)(`h4`,{className:`settings-subhead`,children:`Run details`})}),B&&(0,Z.jsx)(k,{title:`Cancel Run?`,message:`Request cancellation of this Run? It will remain active until the refreshed durable record reports a terminal result.`,confirmLabel:`Cancel Run`,danger:!0,onCancel:()=>ve(null),onConfirm:()=>void xe()}),(0,Z.jsx)(`div`,{className:`evidence-list`,children:qe.map(e=>{let t=$(e),n=t.outcome.tone===`danger`?`danger`:t.outcome.tone===`success`?`ok`:t.outcome.tone===`warning`?`warn`:void 0;return(0,Z.jsxs)(`details`,{className:`evidence-report`,children:[(0,Z.jsxs)(`summary`,{children:[(0,Z.jsxs)(`span`,{children:[e.repo,e.issueNumber?` #${e.issueNumber}`:``,` · `,$e(e.source)]}),(0,Z.jsx)(w,{tone:n,children:t.outcome.label})]}),(0,Z.jsxs)(`div`,{className:`evidence-meta`,children:[(0,Z.jsxs)(`span`,{children:[`Trigger: `,e.triggerKind??e.source]}),t.attempt>1&&(0,Z.jsxs)(`span`,{children:[`Attempt `,t.attempt]}),t.agent&&(0,Z.jsxs)(`span`,{children:[`Agent: `,t.agent]}),t.checksSummary&&(0,Z.jsxs)(`span`,{children:[`Checks: `,t.checksSummary]}),e.routingReason&&(0,Z.jsxs)(`span`,{children:[`Routing: `,e.routingReason]}),e.sandbox&&(0,Z.jsxs)(`span`,{children:[`Sandbox: `,e.sandbox]}),e.approvalMode&&(0,Z.jsxs)(`span`,{children:[`Approval: `,e.approvalMode]}),e.output?.branch&&(0,Z.jsxs)(`span`,{children:[`Branch: `,(0,Z.jsx)(`code`,{children:e.output.branch})]}),e.output?.commit&&(0,Z.jsxs)(`span`,{children:[`Commit: `,(0,Z.jsx)(`code`,{children:e.output.commit.slice(0,12)})]}),e.output?.prUrl&&(0,Z.jsx)(`a`,{href:e.output.prUrl,target:`_blank`,rel:`noreferrer`,children:`Pull request`}),e.output?.artifactUrl&&(0,Z.jsx)(`a`,{href:e.output.artifactUrl,target:`_blank`,rel:`noreferrer`,children:`Artifact`})]}),t.failure&&(0,Z.jsx)(`p`,{className:`muted`,children:t.failure}),(0,Z.jsx)(`ol`,{className:`evidence-timeline`,children:e.events.map((e,t)=>(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`time`,{children:new Date(e.at).toLocaleString()}),(0,Z.jsx)(`span`,{children:e.summary}),e.attempt!==void 0&&(0,Z.jsxs)(`small`,{children:[`Attempt `,e.attempt]})]},`${e.at}-${t}`))}),e.checks&&e.checks.length>0&&(0,Z.jsx)(`ul`,{className:`evidence-checks`,children:e.checks.map((e,t)=>(0,Z.jsxs)(`li`,{children:[e.name,`: `,e.status,e.exitCode===void 0?``:` (exit ${e.exitCode})`,e.durationMs===void 0?``:` · ${(e.durationMs/1e3).toFixed(1)}s`]},`${e.name}-${t}`))}),(0,Z.jsxs)(`div`,{className:`row-actions`,children:[r&&(0,Z.jsx)(`button`,{className:`btn link`,onClick:()=>r(e.id),children:`Open Run details`}),!Xe(e)&&(0,Z.jsx)(`button`,{className:`btn link danger`,disabled:V===e.id,onClick:()=>{F(null),ve(e)},children:V===e.id?`Cancelling…`:`Cancel Run`}),(0,Z.jsx)(`button`,{className:`btn link`,onClick:()=>void Ee(e),children:Ce===e.id?`Copied!`:`Copy sanitized Run JSON`})]})]},e.id)})})]}),!m&&(0,Z.jsx)(`p`,{className:`muted`,children:`Direct/local mode has no shared account queue — sessions a labelled issue starts on this machine still show above.`})]})}var tt=[{id:`rate_limited`,label:`Rate limited`,hint:`429 / overloaded / retry-after`},{id:`credits_exhausted`,label:`Session / credits`,hint:`quota, credit balance, or session usage limit; Retry waits for a supplied reset time`},{id:`context_overflow`,label:`Context overflow`,hint:`prompt exceeds the context window`},{id:`auth_failed`,label:`Auth failed`,hint:`401 / invalid key`},{id:`node_offline`,label:`Machine offline`,hint:`connection refused / unreachable`},{id:`transport_error`,label:`Transport error`,hint:`socket hang up / timeout / 502`},{id:`task_failed`,label:`Task failed`,hint:`tests failed / made no changes`},{id:`unknown`,label:`Unknown`,hint:`anything unclassified`}],nt=[{id:`retry`,label:`Retry`,hint:`Resume at the provider's reset/retry time when supplied; otherwise use backoff, up to the attempt limit.`},{id:`reroute`,label:`Reroute`,hint:`Fall back down a chain of routes, then park/give up.`},{id:`park`,label:`Park`,hint:`Stop and flag for a human — no automatic recovery.`}],rt=[{id:`queue`,label:`Work queue`,hint:`Unattended runs (GitHub / webhooks).`},{id:`session`,label:`Session`,hint:`Interactive chats — resume when a usage/rate limit resets, or reroute to a fallback model.`}],it={baseMs:2e3,factor:2,capMs:6e4,jitter:.3};function at(){return{version:1,name:``,appliesTo:[`queue`],rules:[{when:[`transport_error`,`node_offline`],action:`retry`,maxAttempts:3,backoff:{...it}}]}}function ot(e){let t=e.appliesTo.map(e=>rt.find(t=>t.id===e)?.label??e).join(` + `);return`${e.rules.length} rule${e.rules.length===1?``:`s`} · ${t||`no contexts`}`}function st(e){let t={when:e.when,action:e.action,maxAttempts:e.maxAttempts};return(e.action===`retry`||e.action===`reroute`)&&(e.backoff&&(t.backoff=e.backoff),e.onExhausted&&(t.onExhausted=e.onExhausted)),e.action===`reroute`&&(t.chain=(e.chain??[]).map(e=>{let t={};return e.runtimeId?.trim()&&(t.runtimeId=e.runtimeId.trim()),e.model?.trim()&&(t.model=e.model.trim()),e.account?.trim()&&(t.account=e.account.trim()),e.label?.trim()&&(t.label=e.label.trim()),t})),t}function ct({state:e}){let[t,n]=(0,H.useState)(null),[r,i]=(0,H.useState)(!1),[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null);(0,H.useEffect)(()=>{C.listRulesets()},[]);let p=()=>{u(null),o(!1),i(!0),n(at())},m=e=>{u(null),o(e.active),i(!1);let{active:t,...r}=e;n(JSON.parse(JSON.stringify(r)))},h=()=>{n(null),u(null)};return t?(0,Z.jsx)(lt,{draft:t,setDraft:n,isNew:r,active:a,setActive:o,busy:s,error:l,onCancel:h,onSave:async()=>{c(!0),u(null);try{let e={...t,name:t.name.trim(),rules:t.rules.map(st)};await C.saveRuleset(e,a),C.listRulesets(),h()}catch(e){u(String(e?.message||e))}finally{c(!1)}}}):(0,Z.jsxs)(`div`,{className:`settings-form`,children:[d&&(0,Z.jsx)(k,{title:d.title,message:d.message,confirmLabel:`Remove`,danger:!0,onCancel:()=>f(null),onConfirm:()=>{d.action(),f(null)}}),(0,Z.jsxs)(`p`,{className:`muted settings-intro`,children:[`A ruleset is policy for what happens when a run fails — a rate limit, an exhausted quota, an offline machine. Each rule matches one or more failure conditions and decides whether to retry, reroute through a fallback chain, or park the run for a human. The `,(0,Z.jsx)(`strong`,{children:`active`}),` ruleset steers this machine's work queue and interactive sessions (per the contexts it applies to); with none active, a safe built-in default applies. Rulesets are stored on this machine.`]}),(0,Z.jsxs)(`div`,{className:`picker-list`,children:[e.settings.rulesets.length===0&&(0,Z.jsx)(`div`,{className:`picker-empty`,children:`No rulesets yet.`}),e.settings.rulesets.map(e=>(0,Z.jsx)(P,{title:e.name,meta:ot(e),right:(0,Z.jsxs)(`span`,{className:`row-actions`,children:[e.active&&(0,Z.jsx)(w,{tone:`ok`,children:`Active`}),(0,Z.jsx)(`button`,{className:`btn danger-ghost sm`,onClick:t=>{t.stopPropagation(),f({title:`Remove ruleset?`,message:`Remove "${e.name}"?${e.active?` It's currently active — the work queue will fall back to the built-in default.`:``}`,action:()=>{C.removeRuleset(e.name),setTimeout(()=>C.listRulesets(),400)}})},children:`Remove`})]}),onClick:()=>m(e)},e.name))]}),(0,Z.jsx)(`button`,{className:`btn primary block`,onClick:p,children:`+ New ruleset`})]})}function lt({draft:e,setDraft:t,isNew:n,active:r,setActive:i,busy:a,error:o,onCancel:s,onSave:c}){let l=n=>t({...e,...n}),u=(t,n)=>l({rules:e.rules.map((e,r)=>r===t?n:e)}),d=t=>{let n=e.appliesTo.includes(t)?e.appliesTo.filter(e=>e!==t):[...e.appliesTo,t];l({appliesTo:n})},f=e.appliesTo.includes(`queue`),p=e.appliesTo.includes(`session`),m=f||p,h=e.name.trim().length>0,g=e.rules.length>0&&e.rules.every(e=>e.when.length>0),_=h&&e.appliesTo.length>0&&g&&!a;return(0,Z.jsxs)(`div`,{className:`settings-form`,children:[(0,Z.jsx)(`button`,{className:`btn link`,onClick:s,children:`‹ All rulesets`}),(0,Z.jsx)(`h3`,{children:n?`New ruleset`:e.name}),(0,Z.jsx)(`label`,{className:`field-label`,children:`Name`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:e.name,placeholder:`my-fallback-policy`,disabled:!n,onChange:e=>l({name:e.target.value})}),!n&&(0,Z.jsx)(`p`,{className:`muted small`,children:`The name is the identifier and can't be changed — create a new ruleset to rename.`}),(0,Z.jsx)(`label`,{className:`field-label`,style:{marginTop:8},children:`Applies to`}),(0,Z.jsx)(`div`,{className:`seg-row`,children:rt.map(t=>(0,Z.jsx)(`button`,{type:`button`,className:`selectable`,"aria-pressed":e.appliesTo.includes(t.id),title:t.hint,onClick:()=>d(t.id),children:t.label},t.id))}),(0,Z.jsxs)(`div`,{className:`settings-toggle-row`,style:{marginTop:8},children:[(0,Z.jsxs)(`div`,{className:`settings-toggle-text`,children:[(0,Z.jsx)(`span`,{className:`settings-toggle-title`,children:`Active on this machine`}),(0,Z.jsx)(`span`,{className:`muted small`,children:m?`Use this ruleset for ${f&&p?`queue runs and interactive sessions`:f?`unattended queue runs`:`interactive sessions`} on this machine. Only one ruleset is active at a time.`:`Add a context above (Work queue or Session) to make this ruleset selectable as active.`})]}),(0,Z.jsx)(mt,{checked:r&&m,disabled:!m,onChange:i,label:`Active on this machine`})]}),(0,Z.jsx)(`label`,{className:`field-label`,style:{marginTop:8},children:`Rules`}),(0,Z.jsx)(`p`,{className:`muted small`,children:`Rules are matched top to bottom; the first rule whose conditions include the failure wins.`}),e.rules.map((t,n)=>(0,Z.jsx)(ut,{index:n,rule:t,onChange:e=>u(n,e),onRemove:()=>l({rules:e.rules.filter((e,t)=>t!==n)})},n)),(0,Z.jsx)(`button`,{className:`btn block`,onClick:()=>l({rules:[...e.rules,{when:[],action:`retry`,maxAttempts:3,backoff:{...it}}]}),children:`+ Add rule`}),(0,Z.jsxs)(`div`,{className:`row-actions`,style:{marginTop:12},children:[(0,Z.jsx)(`button`,{className:`btn primary`,disabled:!_,onClick:c,children:a?`Saving…`:n?`Create ruleset`:`Save changes`}),(0,Z.jsx)(`button`,{className:`btn`,onClick:s,children:`Cancel`})]}),o&&(0,Z.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:o})]})}function ut({index:e,rule:t,onChange:n,onRemove:r}){let i=e=>n({...t,...e}),a=e=>{let n=t.when.includes(e);i({when:n?t.when.filter(t=>t!==e):[...t.when,e]})},o=e=>i({backoff:{...t.backoff??it,...e}}),s=t.action===`retry`||t.action===`reroute`;return(0,Z.jsxs)(`div`,{className:`card ruleset-rule-card`,"data-tone":`muted`,children:[(0,Z.jsxs)(`div`,{className:`ruleset-rule-head`,children:[(0,Z.jsxs)(`span`,{className:`settings-toggle-title`,children:[`Rule `,e+1]}),(0,Z.jsx)(`button`,{className:`btn danger-ghost sm`,onClick:r,children:`Remove`})]}),(0,Z.jsx)(`label`,{className:`field-label`,children:`When any of`}),(0,Z.jsx)(`div`,{className:`ruleset-choice-row`,children:tt.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`selectable`,title:e.hint,"aria-pressed":t.when.includes(e.id),onClick:()=>a(e.id),children:e.label},e.id))}),t.when.length===0&&(0,Z.jsx)(`p`,{className:`muted small`,children:`Pick at least one condition.`}),(0,Z.jsx)(`label`,{className:`field-label`,children:`Then`}),(0,Z.jsx)(`div`,{className:`seg-row`,children:nt.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`selectable`,"aria-pressed":t.action===e.id,title:e.hint,onClick:()=>i({action:e.id}),children:e.label},e.id))}),(0,Z.jsx)(`p`,{className:`muted small`,children:nt.find(e=>e.id===t.action)?.hint}),(0,Z.jsxs)(`div`,{className:`ruleset-field-grid`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`Max attempts`}),(0,Z.jsx)(`input`,{className:`picker-search`,type:`number`,min:1,max:100,value:t.maxAttempts,onChange:e=>i({maxAttempts:ft(e.target.value,1,100,t.maxAttempts)})})]}),s&&(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`When exhausted`}),(0,Z.jsxs)(`select`,{className:`picker-search`,value:t.onExhausted??`park`,onChange:e=>i({onExhausted:e.target.value}),children:[(0,Z.jsx)(`option`,{value:`park`,children:`Park for a human`}),(0,Z.jsx)(`option`,{value:`give_up`,children:`Give up (fail the run)`})]})]})]}),t.action===`reroute`&&(0,Z.jsx)(dt,{chain:t.chain??[],onChange:e=>i({chain:e})}),s&&(0,Z.jsx)(ht,{label:`Backoff (advanced)`,children:(0,Z.jsxs)(`div`,{className:`ruleset-field-grid`,children:[(0,Z.jsx)(pt,{label:`Base (ms)`,value:t.backoff?.baseMs??it.baseMs,min:0,onChange:e=>o({baseMs:e})}),(0,Z.jsx)(pt,{label:`Factor`,value:t.backoff?.factor??it.factor,min:1,step:.1,onChange:e=>o({factor:e})}),(0,Z.jsx)(pt,{label:`Cap (ms)`,value:t.backoff?.capMs??it.capMs,min:0,onChange:e=>o({capMs:e})}),(0,Z.jsx)(pt,{label:`Jitter (0–1)`,value:t.backoff?.jitter??it.jitter,min:0,max:1,step:.05,onChange:e=>o({jitter:e})})]})})]})}function dt({chain:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,Z.jsxs)(`div`,{className:`ruleset-chain`,children:[(0,Z.jsx)(`label`,{className:`field-label`,children:`Fallback chain`}),(0,Z.jsx)(`p`,{className:`muted small`,children:`Tried in order; the first candidate with valid credentials on the machine wins. Leave a field blank to keep the failed run's current value.`}),e.map((r,i)=>(0,Z.jsxs)(`div`,{className:`ruleset-chain-row`,children:[(0,Z.jsxs)(`div`,{className:`ruleset-chain-fields`,children:[(0,Z.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,Z.jsx)(`span`,{children:`Model`}),(0,Z.jsx)(`input`,{className:`picker-search`,placeholder:`e.g. claude-sonnet`,value:r.model??``,onChange:e=>n(i,{model:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,Z.jsx)(`span`,{children:`Agent`}),(0,Z.jsx)(`input`,{className:`picker-search`,placeholder:`e.g. codex`,value:r.runtimeId??``,onChange:e=>n(i,{runtimeId:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,Z.jsx)(`span`,{children:`Account`}),(0,Z.jsx)(`input`,{className:`picker-search`,placeholder:`Keep current`,value:r.account??``,onChange:e=>n(i,{account:e.target.value})})]})]}),(0,Z.jsx)(`button`,{className:`btn danger-ghost sm ruleset-chain-remove`,onClick:()=>t(e.filter((e,t)=>t!==i)),"aria-label":`Remove candidate ${i+1}`,children:`Remove`})]},i)),(0,Z.jsx)(`button`,{className:`btn sm`,onClick:()=>t([...e,{}]),children:`+ Add candidate`})]})}function ft(e,t,n,r){let i=Math.round(Number(e));return Number.isFinite(i)?Math.min(n,Math.max(t,i)):r}function pt({label:e,value:t,min:n,max:r,step:i,onChange:a}){return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`field-label`,children:e}),(0,Z.jsx)(`input`,{className:`picker-search`,type:`number`,value:t,min:n,max:r,step:i,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)}})]})}function mt({checked:e,onChange:t,disabled:n,label:r}){return(0,Z.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,className:`settings-toggle${e?` on`:``}`,onClick:()=>t(!e),children:(0,Z.jsx)(`span`,{className:`settings-toggle-knob`,"aria-hidden":!0})})}function ht({label:e,children:t}){let[n,r]=(0,H.useState)(!1);return(0,Z.jsxs)(`div`,{className:`ruleset-collapsible`,children:[(0,Z.jsxs)(`button`,{type:`button`,className:`btn link`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?`▾`:`▸`,` `,e]}),n&&(0,Z.jsx)(`div`,{className:`ruleset-collapsible-body`,children:t})]})}var gt=[{v:30,label:`30 min`},{v:60,label:`1 hour`},{v:180,label:`3 hours`}];function _t({hosted:e,onConfigureCredentials:t}){let[n,r]=(0,H.useState)([]),[i,a]=(0,H.useState)([]),[s,c]=(0,H.useState)(null),[l,u]=(0,H.useState)([]),[d,f]=(0,H.useState)(!1),[p,m]=(0,H.useState)(null),[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(null),y=()=>C.listEphemeralConfigs().then(a).catch(()=>{});(0,H.useEffect)(()=>{C.listNodes().then(r).catch(()=>{}),C.listEphemeralKeys().then(u).catch(()=>{}),C.getQueueRouting().then(c).catch(()=>c(null)),y()},[]);let b=n.filter(e=>!e.id.startsWith(`eph-`)),x=s?.primary.kind===`node`?`node:${s.primary.node}`:s?.primary.kind===`config`?`config:${s.primary.configId}`:`shared`,S=s?.fallback?.kind===`config`?`config:${s.fallback.configId}`:``,ee=s?.primary.kind===`node`,te=e=>l.find(t=>t.id===e)?.name||e,ne=e=>!!l.find(t=>t.id===e)?.configured,re=async(e,t)=>{m(null),f(!0);try{let n=e.startsWith(`node:`)?{kind:`node`,node:e.slice(5)}:e.startsWith(`config:`)?{kind:`config`,configId:e.slice(7)}:{kind:`shared`},r=n.kind===`node`&&t.startsWith(`config:`)?{primary:n,fallback:{kind:`config`,configId:t.slice(7)}}:{primary:n};c(await C.setQueueRouting(r))}catch(e){m(String(e?.message||e))}finally{f(!1)}},ie=async()=>{if(!h)return;let e=h.name.trim();if(!e){m(`Profile name is required`);return}if(!h.provider){m(`Choose a provider`);return}m(null),f(!0);try{let t={name:e,provider:h.provider,region:h.region.trim()||null,size:h.size.trim()||null,ttlMinutes:h.ttlMinutes??null,readyCapacity:ae&&h.readyCapacity?1:0,teardownOnAgentFinish:h.teardownOnAgentFinish};h.editing?await C.updateEphemeralConfig(h.editing,t):await C.createEphemeralConfig(t),g(null),y()}catch(e){m(String(e?.message||e))}finally{f(!1)}},ae=h?o(h.provider)?.computeClass===`byo-cloud`:!1,T=async e=>{v(null),f(!0);try{await C.removeEphemeralConfig(e.id),y()}catch(e){m(String(e?.message||e))}finally{f(!1)}},oe=s?.primary.kind===`config`?s.primary.configId:``,se=s?.fallback?.configId??``,ce=oe?i.find(e=>e.id===oe):void 0,E=se?i.find(e=>e.id===se):void 0,le=t=>!!(t&&(t.computeSource===`managed`?e?.execution.ready&&(!e.execution.configId||e.execution.configId===t.id):e?.enabled&&e.validatedProviders.includes(t.provider)&&e.credential!==`none`&&e.encryptionReady)),D=s?.primary.kind===`node`?s.primary.node:``,O=s?.primary.kind===`config`?le(ce):s?.primary.kind===`node`?b.some(e=>(e.name||e.id)===D&&e.online)||le(E):b.some(e=>e.online);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`banner routing-status`,"data-tone":O?`ok`:`warn`,role:`status`,children:[(0,Z.jsxs)(`div`,{className:`banner-text routing-status-copy`,children:[(0,Z.jsx)(`strong`,{children:s===null?`Checking run readiness…`:O?`Ready for unattended runs`:`Setup needs attention`}),(0,Z.jsx)(`span`,{children:s===null?`Loading machines, routing, and credential status.`:s.primary.kind===`config`?O?`${ce?.name||`Isolated profile`} can start without an online personal machine.`:`Ephemeral-only runs need hosted provisioning, a validated cloud credential, and GitHub/model sign-ins available to the fresh runner.`:s.primary.kind===`node`?`The selected persistent machine must be online, or have an isolated fallback.`:`The shared queue needs at least one online persistent machine.`})]}),s!==null&&!O&&t&&(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`Fix setup`})]}),(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Primary machine`}),(0,Z.jsxs)(`select`,{className:`picker-search`,value:x,disabled:d,onChange:e=>re(e.target.value,S),children:[(0,Z.jsx)(`option`,{value:`shared`,children:`Shared queue (any online machine)`}),b.length>0&&(0,Z.jsx)(`optgroup`,{label:`Trusted workstations`,children:b.map(e=>(0,Z.jsx)(`option`,{value:`node:${e.name||e.id}`,children:e.name||e.id},e.id))}),i.length>0&&(0,Z.jsx)(`optgroup`,{label:`Cloud machine profiles`,children:i.map(e=>(0,Z.jsxs)(`option`,{value:`config:${e.id}`,children:[e.name,` · `,e.provider]},e.id))})]})]}),ee&&(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Fallback if machine is offline`}),(0,Z.jsxs)(`select`,{className:`picker-search`,value:S,disabled:d,onChange:e=>re(x,e.target.value),children:[(0,Z.jsx)(`option`,{value:``,children:`None — wait for the machine`}),i.map(e=>(0,Z.jsxs)(`option`,{value:`config:${e.id}`,children:[e.name,` · `,e.provider]},e.id))]})]}),(0,Z.jsx)(`p`,{className:`muted small`,children:ee?`Runs wait for this machine; if it's offline and a fallback is set, a fresh isolated machine is provisioned instead.`:s?.primary.kind===`config`?`Every run starts from this isolated profile. Cloud credentials authorize machine creation; GitHub credentials clone and push; model credentials authorize the agent. These sign-ins are separate and secret values are never shown here.`:`Runs are picked up by any online persistent machine. No cloud credential is needed.`}),(0,Z.jsx)(`h4`,{className:`settings-subhead`,children:`Cloud machine profiles`}),h?(0,Z.jsxs)(`div`,{className:`settings-form`,children:[(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Name`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:h.name,placeholder:`e.g. fly-small-iad`,onChange:e=>g({...h,name:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Provider`}),(0,Z.jsxs)(`select`,{className:`picker-search`,value:h.provider,onChange:e=>g({...h,provider:e.target.value}),children:[(0,Z.jsx)(`option`,{value:``,disabled:!0,children:`Choose a provider`}),l.map(e=>(0,Z.jsxs)(`option`,{value:e.id,children:[e.name,e.configured?``:` (no token on this device)`]},e.id))]})]}),(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Region (optional)`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:h.region,placeholder:`provider default`,onChange:e=>g({...h,region:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Server type (optional)`}),(0,Z.jsx)(`input`,{className:`picker-search`,value:h.size,placeholder:`provider default`,onChange:e=>g({...h,size:e.target.value})})]}),(0,Z.jsxs)(`label`,{className:`field-label`,children:[(0,Z.jsx)(`span`,{children:`Auto-destroy after`}),(0,Z.jsxs)(`select`,{className:`picker-search`,value:h.ttlMinutes??``,onChange:e=>g({...h,ttlMinutes:e.target.value?Number(e.target.value):null}),children:[(0,Z.jsx)(`option`,{value:``,children:`Provider default`}),gt.map(e=>(0,Z.jsx)(`option`,{value:e.v,children:e.label},e.v))]})]}),(0,Z.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Z.jsxs)(`div`,{className:`settings-toggle-text`,children:[(0,Z.jsx)(`span`,{className:`settings-toggle-title`,children:`Destroy after the agent finishes`}),(0,Z.jsx)(`span`,{className:`muted small`,children:`Tear the machine down on agent_end; the TTL stays a safety fallback.`})]}),(0,Z.jsx)(L,{checked:h.teardownOnAgentFinish,onChange:e=>g({...h,teardownOnAgentFinish:e}),label:`Destroy after the agent finishes`})]}),(0,Z.jsxs)(`div`,{className:`settings-toggle-row`,children:[(0,Z.jsxs)(`div`,{className:`settings-toggle-text`,children:[(0,Z.jsx)(`span`,{className:`settings-toggle-title`,children:`Keep one machine ready`}),(0,Z.jsx)(`span`,{className:`muted small`,children:`Starts an account-owned machine before a Run arrives for faster startup. It may incur idle provider charges and remains bounded by the TTL.`})]}),(0,Z.jsx)(L,{checked:h.readyCapacity&&ae,disabled:!ae,onChange:e=>g({...h,readyCapacity:e}),label:`Keep one machine ready`})]}),!ae&&(0,Z.jsx)(`p`,{className:`muted small`,children:`Managed-compute providers use their native fast-start or suspend path instead of Bivy ready capacity.`}),(0,Z.jsxs)(`div`,{className:`row-actions`,children:[(0,Z.jsx)(`button`,{className:`btn primary`,disabled:d||!h.name.trim()||!h.provider,onClick:ie,children:d?`Saving…`:h.editing?`Save changes`:`Add profile`}),(0,Z.jsx)(`button`,{className:`btn`,onClick:()=>{m(null),g(null)},children:`Cancel`})]})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`picker-list`,children:[i.length===0&&(0,Z.jsx)(`div`,{className:`picker-empty`,children:`No cloud machine profiles yet.`}),i.map(e=>(0,Z.jsx)(P,{title:e.name,meta:`${te(e.provider)}${e.region?` · `+e.region:``}${e.size?` · `+e.size:``}${e.ttlMinutes?` · `+e.ttlMinutes+`m`:``}${e.readyCapacity?` · 1 ready`:``}${ne(e.provider)?``:` · no token here`}`,right:(0,Z.jsx)(`button`,{className:`btn danger-ghost sm`,onClick:t=>{t.stopPropagation(),v(e)},children:`Remove`}),onClick:()=>{m(null),g({editing:e.id,name:e.name,provider:e.provider,region:e.region??``,size:e.size??``,ttlMinutes:e.ttlMinutes??null,readyCapacity:!!e.readyCapacity,teardownOnAgentFinish:!!e.teardownOnAgentFinish})}},e.id))]}),(0,Z.jsx)(`button`,{className:`btn primary block`,onClick:()=>{m(null),g({name:``,provider:l[0]?.id??``,region:``,size:``,ttlMinutes:null,readyCapacity:!1,teardownOnAgentFinish:!1})},children:`+ Add profile`})]}),p&&(0,Z.jsx)(w,{tone:`danger`,children:p}),_&&(0,Z.jsx)(k,{title:`Remove profile?`,message:`Remove ${_.name}? Runs assigned to it will fall back to the shared queue.`,confirmLabel:`Remove`,danger:!0,onCancel:()=>v(null),onConfirm:()=>T(_)})]})}var vt={requested:`Requesting…`,enrolled:`Enrolling…`,"provider-accepted":`Booting…`,tracked:`Booting…`,ready:`Ready`,claimed:`Claimed`,working:`Working`,deleting:`Tearing down…`,deleted:`Deleted`,failed:`Failed`};function yt(e){return e.desiredState===`deleted`&&e.lifecycleState!==`deleted`?`Tearing down…`:(e.lifecycleState?vt[e.lifecycleState]:void 0)||m({milestones:e.milestones,purpose:e.purpose,claimedAt:e.claimedAt},!!e.lastError)}function bt(e,t){return t||e===`Failed`||e===`teardown-failed`?`err`:e===`Tearing down…`||e===`Requesting…`||e===`Enrolling…`||e===`Booting…`?`warn`:`ok`}function xt(e,t){if(!e)return null;let n=Date.parse(e)-t;if(!Number.isFinite(n))return null;if(n<=0)return`any moment`;let r=Math.round(n/6e4);return r<1?`under a minute`:r<60?`${r}m`:`${Math.round(r/60)}h`}function St(){let[e,t]=(0,H.useState)(null),[n,r]=(0,H.useState)(null),[i,a]=(0,H.useState)(null),[s,c]=(0,H.useState)(null),l=()=>C.listHostedMachines().then(t).catch(()=>t(e=>e??[]));if((0,H.useEffect)(()=>{l();let e=setInterval(l,15e3);return()=>clearInterval(e)},[]),!e||e.length===0)return null;let u=async e=>{r(e),c(null);try{await C.destroyHostedMachine(e)}catch(e){c(String(e.message||e))}finally{r(null),await l()}};return(0,Z.jsxs)(`section`,{className:`autom-section`,children:[(0,Z.jsx)(`h2`,{className:`autom-section-label`,children:`Hosted machines`}),(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Control-plane-launched runners for unattended work — phase, TTL, and teardown status.`}),(0,Z.jsx)(`div`,{className:`picker-list`,children:e.map(e=>{let t=o(e.provider),r=yt(e),i=bt(r,!!e.lastError),s=i===`err`?`danger`:i===`ok`?`ok`:i===`warn`?`warn`:void 0,c=xt(e.deadlineAt,Date.now()),l=!!e.milestones?.snapshotReadyAt,u=e.nodeId||e.id;return(0,Z.jsxs)(`div`,{className:`automation-row`,children:[(0,Z.jsxs)(`div`,{className:`automation-row-main`,children:[(0,Z.jsxs)(`div`,{className:`automation-row-title`,children:[(0,Z.jsx)(`strong`,{children:e.name||t?.name||e.provider}),(0,Z.jsx)(w,{tone:s,children:r})]}),(0,Z.jsx)(`div`,{className:`settings-hint`,children:[t?.name??e.provider,e.region,c?`next deadline ~${c}`:null,l?`snapshot ready`:null].filter(Boolean).join(` · `)}),e.lastError&&(0,Z.jsx)(`div`,{className:`settings-hint warn-text`,children:e.lastError})]}),(0,Z.jsx)(`div`,{className:`automation-row-actions`,children:e.nodeId&&(0,Z.jsx)(`button`,{type:`button`,className:`btn sm danger`,disabled:n===e.nodeId||e.desiredState===`deleted`,onClick:()=>a(e),children:e.desiredState===`deleted`?`Tearing down…`:n===e.nodeId?`…`:`Force destroy`})})]},u)})}),s&&(0,Z.jsx)(`p`,{className:`settings-hint warn-text`,children:s}),i&&(0,Z.jsx)(k,{title:`Force destroy this machine?`,message:`This immediately asks the provider to delete it. If that request fails, the record stays visible and the reconciler keeps retrying automatically until deletion is confirmed — it never silently disappears while it might still be billing.`,confirmLabel:`Force destroy`,danger:!0,onCancel:()=>a(null),onConfirm:()=>{let e=i.nodeId;a(null),u(e)}})]})}function Ct({sources:e}){let t=e.filter(e=>e.status.tone===`on`),n=e.filter(e=>e.status.tone===`warn`),r=n.length?`${n.length} ${n.length===1?`source needs`:`sources need`} attention`:t.length===e.length?`${t.length} sources connected`:t.length?`${t.map(e=>e.name).join(`, `)} connected · ${e.length-t.length} more`:`Connect GitHub, Linear, and Slack`;return(0,Z.jsxs)(`details`,{className:`autom-sources-panel`,children:[(0,Z.jsxs)(`summary`,{className:`autom-sources-summary`,children:[(0,Z.jsxs)(`span`,{className:`autom-sources-summary-copy`,children:[(0,Z.jsx)(`strong`,{children:`Sources`}),(0,Z.jsx)(`span`,{children:r})]}),(0,Z.jsx)(`span`,{className:`autom-sources-chevron`,children:(0,Z.jsx)(A,{})})]}),(0,Z.jsx)(`div`,{className:`autom-sources-list`,children:e.map(e=>{let t=e.status.tone===`off`?`Connect`:e.status.tone===`warn`?`Fix`:`Manage`;return(0,Z.jsxs)(`button`,{type:`button`,className:`autom-source-row`,onClick:e.onClick,children:[(0,Z.jsxs)(`span`,{className:`autom-source-row-copy`,children:[(0,Z.jsx)(`strong`,{children:e.name}),(0,Z.jsx)(`span`,{children:e.status.label})]}),(0,Z.jsx)(`span`,{className:`autom-source-row-cta`,children:t}),(0,Z.jsx)(A,{size:16})]},e.name)})})]})}function wt(e,t={}){let n=e instanceof Date?e:new Date(e);if(Number.isNaN(n.getTime()))return`Unknown time`;let r=t.now??new Date,i=t.locale,a=new Date(r.getFullYear(),r.getMonth(),r.getDate()),o=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=Math.round((o.getTime()-a.getTime())/864e5),c=new Intl.DateTimeFormat(i,{hour:`2-digit`,minute:`2-digit`}).format(n);return s===0?`Today at ${c}`:s===1?`Tomorrow at ${c}`:s===-1?`Yesterday at ${c}`:s>1&&s<7?`${new Intl.DateTimeFormat(i,{weekday:`long`}).format(n)} at ${c}`:`${new Intl.DateTimeFormat(i,{day:`numeric`,month:`short`,year:n.getFullYear()===r.getFullYear()?void 0:`numeric`}).format(n)} at ${c}`}function Tt(e,t={}){let n=wt(e,t).replace(/^Today/,`today`).replace(/^Tomorrow/,`tomorrow`);return`Next ${n.startsWith(`today`)?n:n.replace(/ at .+$/,``)}`}function Et(e,t){let[n,r,i,a,o,...s]=e.trim().split(/\s+/);if(s.length||!/^\d+$/.test(n||``)||!/^\d+$/.test(r||``))return null;let c=Number(r),l=Number(n);if(c>23||l>59||a!==`*`)return null;let u=new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`}).format(new Date(2020,0,1,c,l));return i===`*`&&o===`*`?`Daily at ${u}`:i===`*`&&/^[0-6]$/.test(o||``)?`Every ${new Intl.DateTimeFormat(t,{weekday:`long`}).format(new Date(2020,0,5+Number(o)))} at ${u}`:/^\d+$/.test(i||``)&&o===`*`?`Monthly on day ${Number(i)} at ${u}`:null}function Dt(e){return e.status===`needs_attention`||e.status===`waiting`?`parked`:e.status===`failed`?`dead_letter`:[`pending`,`claimed`,`running`].includes(e.status)?`active`:`all`}function Ot(e){return!!e.attention||e.status===`needs_attention`||e.status===`failed`||e.notification?.status===`failed`}function kt({runs:e,definitions:t,cancelBusyId:n,onRefresh:r,onCancel:i,onOpenRun:a,onOpenSession:o,compact:c=!1}){let[l,u]=(0,H.useState)(`all`),d=e.filter(Ot).length,f=(0,H.useMemo)(()=>e.filter(e=>l===`all`?!0:l===`attention`?Ot(e):Dt(e)===l),[l,e]),p=t=>t===`all`?e.length:t===`attention`?d:e.filter(e=>Dt(e)===t).length,m=[{id:`all`,label:`All · ${p(`all`)}`},{id:`active`,label:`Active · ${p(`active`)}`},{id:`attention`,label:`Attention · ${d}`},{id:`parked`,label:`Parked · ${p(`parked`)}`},{id:`dead_letter`,label:`Dead letter · ${p(`dead_letter`)}`}];return(0,Z.jsxs)(`section`,{className:`autom-section runs-overview`,children:[(0,Z.jsxs)(`div`,{className:`autom-section-head`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h2`,{className:`autom-section-label`,children:c?`History`:`Recent runs`}),!c&&(0,Z.jsx)(`p`,{className:`settings-hint`,children:`Live status and recent outcomes.`})]}),!c&&(0,Z.jsx)(`div`,{className:`autom-section-actions`,children:(0,Z.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:r,children:`Refresh`})})]}),d>0&&(0,Z.jsx)(`div`,{className:`banner`,"data-tone":`warn`,role:`alert`,children:(0,Z.jsxs)(`div`,{className:`banner-text`,children:[(0,Z.jsxs)(`strong`,{children:[d,` Run`,d===1?``:`s`,` need attention`]}),(0,Z.jsx)(`span`,{children:`Review parked work, failed notification delivery, or terminal failures before retrying.`})]})}),!c&&(0,Z.jsx)(`div`,{className:`run-history-filters`,role:`group`,"aria-label":`Filter Runs`,children:m.map(e=>(0,Z.jsx)(`button`,{type:`button`,className:`btn sm${l===e.id?` primary`:``}`,"aria-pressed":l===e.id,onClick:()=>u(e.id),children:e.label},e.id))}),f.length===0?(0,Z.jsx)(`p`,{className:`settings-hint autom-empty-hint`,children:c?`No runs yet. Run this automation now, or wait for its trigger.`:`No Runs match this filter.`}):(0,Z.jsx)(`div`,{className:`automation-list`,children:f.slice(0,30).map(e=>{let r=$(e),l=s(e),u=r.outcome.tone===`success`?`ok`:r.outcome.tone===`danger`?`danger`:r.outcome.tone===`warning`?`warn`:void 0;if(c&&a)return(0,Z.jsxs)(`button`,{type:`button`,className:`automation-history-row`,onClick:()=>a(e.id),children:[(0,Z.jsxs)(`span`,{className:`automation-history-row-copy`,children:[(0,Z.jsx)(`strong`,{children:e.title}),(0,Z.jsx)(`span`,{className:`settings-hint`,children:wt(e.createdAt)})]}),(0,Z.jsx)(w,{tone:u,children:r.outcome.label}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`›`})]},e.id);let d=t.find(t=>t.id===e.definitionId)?.name,f=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`automation-row-title`,children:[(0,Z.jsx)(`strong`,{children:e.title}),(0,Z.jsx)(w,{tone:u,children:r.outcome.label}),l.operationalState===`parked`&&(0,Z.jsx)(w,{tone:`warn`,children:`Parked`}),l.operationalState===`dead_letter`&&(0,Z.jsx)(w,{tone:`danger`,children:`Dead letter`})]}),(0,Z.jsx)(`div`,{className:`settings-hint`,children:[c?null:d,wt(e.createdAt),c?null:e.triggerKind,r.checksSummary,c?null:`attempt ${l.attempt}${l.maxAttempts?`/${l.maxAttempts}`:``}`].filter(Boolean).join(` · `)}),l.attemptReason&&(0,Z.jsx)(`div`,{className:`settings-hint`,children:l.attemptReason}),r.failure&&(0,Z.jsx)(`div`,{className:`settings-hint warn-text`,children:r.failure})]});return(0,Z.jsxs)(`div`,{className:`automation-row run-row`,children:[a?(0,Z.jsx)(`button`,{type:`button`,className:`automation-row-main run-row-open`,onClick:()=>a(e.id),children:f}):(0,Z.jsx)(`div`,{className:`automation-row-main`,children:f}),(0,Z.jsxs)(`div`,{className:`automation-row-actions`,children:[l.actions.some(e=>e.kind===`cancel`)&&(0,Z.jsx)(`button`,{type:`button`,className:`btn sm danger`,disabled:n===e.id,onClick:()=>i(e),children:n===e.id?`Cancelling…`:`Cancel`}),l.sessionId&&(0,Z.jsx)(`button`,{type:`button`,className:`btn sm primary`,onClick:()=>o(l.sessionId),children:`Open session`}),e.output?.prUrl&&(0,Z.jsx)(`a`,{className:`btn sm`,href:e.output.prUrl,target:`_blank`,rel:`noreferrer`,children:`View PR`}),a&&(0,Z.jsx)(`button`,{type:`button`,className:`run-row-chevron`,"aria-label":`Open Run details for ${e.title}`,onClick:()=>a(e.id),children:`›`})]})]},e.id)})})]})}function At(e){return e.trigger&&e.trigger!==`schedule`?!0:e.schedule.kind!==`once`}var jt=[{kind:`schedule`,key:`upgrade-dependencies`,title:`Upgrade dependencies`,tagline:`Bump dependencies on a schedule, run the checks, open a PR.`,prefill:{name:`Upgrade dependencies`,instructions:`Update this project's dependencies to safe, current versions.
|
|
3
3
|
|
|
4
4
|
1. Inspect the manifest and lockfile to find what is outdated.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Mt as e,i as t}from"./useStore-
|
|
1
|
+
import{Mt as e,i as t}from"./useStore-DcIB7b1-.js";import{k as n}from"./Sheet-YqJCwCtR.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{t as i}from"./StatusDot-dpbztK53.js";var a={shell:`Ran`,read:`Read`,write:`Created`,edit:`Edited`,search:`Searched`,fetch:`Fetched`,plan:`Planned`,delegation:`Delegated`,unknown:`Tool`};function o(e){return typeof e==`string`?e:e==null?``:String(e)}function s(e,t=120){let n=o(e);return n.length>t?n.slice(0,t-1)+`…`:n}function c(e,t=120){return s(o(e).replace(/\s+/g,` `).trim(),t)}function l(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)t--;let n=e.slice(0,t),r=Math.max(n.lastIndexOf(`/`),n.lastIndexOf(`\\`));return r>=0?n.slice(r+1):n}function u(e){let t=String(e||``).toLowerCase();return t===`stderr`||t===`stdout`||t===`agent_output`||t===`agent-output`||t===`agentoutput`?`Agent output`:t.includes(`read`)?`Read`:t.includes(`write`)?`Created`:t.includes(`edit`)?`Edited`:t.includes(`grep`)||t.includes(`search`)||t.includes(`find`)?`Searched`:t.includes(`ls`)||t.includes(`list`)?`Listed`:t.includes(`web`)||t.includes(`fetch`)?`Fetched`:t.includes(`bash`)||t.includes(`shell`)?`Ran`:e?e.charAt(0).toUpperCase()+e.slice(1):`Tool`}function d(e,t){return t||e===`Ran`||e===`Agent output`?`terminal`:e===`Edited`?`pencil`:e===`Created`?`create`:e===`Searched`?`search`:e===`Listed`?`list`:e===`Fetched`?`globe`:e===`Delegated`?`agent`:`eye`}function f(e){let t=String(e??``).replace(/\r\n/g,`
|
|
2
2
|
`);return t===``?[]:t.split(`
|
|
3
3
|
`)}function p(e,t){let n=e.length,r=t.length,i=Array.from({length:n+1},()=>Array(r+1).fill(0));for(let a=n-1;a>=0;a--)for(let n=r-1;n>=0;n--)i[a][n]=e[a]===t[n]?i[a+1][n+1]+1:Math.max(i[a+1][n],i[a][n+1]);return i}var m=900;function h(e,t){let n=f(e),r=f(t);if(n.length>m||r.length>m){let i=[];if(e)for(let e of n)i.push({type:`del`,text:e});if(t)for(let e of r)i.push({type:`add`,text:e});return i}let i=p(n,r),a=[],o=0,s=0;for(;o<n.length&&s<r.length;)n[o]===r[s]?(a.push({type:`ctx`,text:n[o]}),o++,s++):i[o+1][s]>=i[o][s+1]?(a.push({type:`del`,text:n[o]}),o++):(a.push({type:`add`,text:r[s]}),s++);for(;o<n.length;)a.push({type:`del`,text:n[o++]});for(;s<r.length;)a.push({type:`add`,text:r[s++]});return a}function g(e){let t=[],n=[],r=()=>{n.length>8?(t.push(n[0],n[1],n[2]),t.push({type:`skip`,count:n.length-6}),t.push(n[n.length-3],n[n.length-2],n[n.length-1])):t.push(...n),n=[]};for(let i of e)i.type===`ctx`?n.push(i):(r(),t.push(i));return r(),t}function _(e){let t=0,n=0;for(let r of e)r.type===`add`?t++:r.type===`del`&&n++;return{added:t,removed:n}}function v(e,t){for(let n of t)if(e?.[n]!=null&&e[n]!==``)return o(e[n])}var y=[`oldText`,`oldString`,`old_string`,`old`,`before`],b=[`newText`,`newString`,`new_string`,`new`,`after`];function x(e,t=!0){let n=Array.isArray(e?.edits)?e.edits:Array.isArray(e?.replacements)?e.replacements:Array.isArray(e?.changes)?e.changes:[e],r=[];for(let e of n){let n=v(e,y)??``,i=v(e,b)??``;if(!n&&!i)continue;let{added:a,removed:o}=t?_(h(n,i)):{added:0,removed:0};r.push({oldText:n,newText:i,added:a,removed:o})}return r}function S(e,t,n,r={}){let i=r.diffStats!==!1,o=String(e||``).toLowerCase(),c=t&&typeof t==`object`?t:{},p=u(o),m=v(c,[`path`,`file`,`filePath`,`file_path`,`pathname`]),g=v(c,[`command`,`cmd`,`shell`]),y=s(v(c,[`query`,`q`,`pattern`,`search`]),120),b=v(c,[`output`,`stdout`,`stderr`,`message`,`delta`]),S=v(c,[`stream`]),w=p===`Agent output`,T=w?`Agent output`:g||o.includes(`bash`)||o.includes(`shell`)?`Bash`:p===`Tool`?String(e||`Tool`):u(o),E=[],D;if(n?n.kind===`write`:o.includes(`write`)){let e=v(c,[`content`,`text`,`contents`,`data`,`file_text`])??``;e&&(E=[{oldText:``,newText:e,added:i?f(e.replace(/\r?\n$/,``)).length:0,removed:0,label:`New file`}])}else if(o.includes(`edit`)){let e=x(c,i);E=e,e.length>1&&(D=e.length)}let O=0,k=0;for(let e of E)O+=e.added,k+=e.removed;let A={verb:p,glyph:d(p,!!g),title:T,path:m,target:m?l(m):void 0,command:g,query:y||void 0,output:b,stream:S,added:O,removed:k,diffs:E,edits:D};if(n&&!w){if(A.verb=a[n.kind]??A.verb,A.glyph=d(A.verb,n.kind===`shell`),n.kind===`shell`)A.command=n.command,A.title=`Bash`;else if(n.kind===`read`||n.kind===`write`||n.kind===`edit`){if(A.path=n.path,A.target=l(n.path),A.title=A.verb,n.kind===`edit`&&A.diffs.length===0&&(n.oldText||n.newText)){let e=n.oldText??``,t=n.newText??``,{added:r,removed:a}=i?_(h(e,t)):{added:0,removed:0};A.diffs=[{oldText:e,newText:t,added:r,removed:a}],A.added=r,A.removed=a}}else n.kind===`search`?(A.query=n.query,A.title=`Search`,n.path&&(A.path=n.path)):n.kind===`fetch`?(A.query=n.url,A.title=`Fetch`):n.kind===`plan`?(A.title=`Plan`,n.text&&(A.query=s(n.text,120))):n.kind===`delegation`&&(A.title=n.label?`Delegated → ${n.label}`:`Delegated`,n.label&&(A.target=n.label),n.description&&(A.query=s(n.description,120)))}return n?.result&&(C(n)&&(A.isError=!0),typeof n.result.exitCode==`number`&&(A.exitCode=n.result.exitCode),n.result.truncated&&(A.truncated=!0)),A}function C(e){return!!(e?.result?.isError||typeof e?.result?.exitCode==`number`&&e.result.exitCode!==0)}function w(e){return c(e.command||e.path||e.target||e.query||e.output,120)}function T(e){let t=new Set,n=new Set,r=0,i=0,a=0,o=0;for(let s of e){let e=S(s.name,s.input,s.detail,{diffStats:!1});e.isError&&o++,e.verb===`Agent output`?i++:e.verb===`Delegated`?a++:e.command?r++:e.verb===`Edited`||e.verb===`Created`||e.diffs.length?t.add(e.path||`#${t.size}`):n.add(e.path||e.query||`#${n.size}`)}let s=t.size,c=n.size,l=[],u=(e,t,n)=>`${e===1?`a`:e} ${e===1?t:n}`;c&&l.push(`Read ${u(c,`file`,`files`)}`),r&&l.push(`ran ${u(r,`command`,`commands`)}`),s&&l.push(`edited ${u(s,`file`,`files`)}`),a&&l.push(`delegated ${u(a,`task`,`tasks`)}`),i&&l.push(i===1?`agent output`:`${i} agent output streams`);let d=o?` · ${o} failed`:``;if(!l.length)return`${e.length===1?`1 tool call`:`${e.length} tool calls`}${d}`;let f=l.join(`, `);return`${f.charAt(0).toUpperCase()}${f.slice(1)}${d}`}var E=e(),D=r();function O({size:e=`md`,tone:t=`accent`}){return(0,D.jsx)(`span`,{className:`spinner`,"data-size":e,"data-tone":t,"aria-hidden":!0})}var k=28;function A(){let e=[`audio/webm;codecs=opus`,`audio/webm`,`audio/mp4`,`audio/ogg;codecs=opus`,`audio/ogg`],t=globalThis.MediaRecorder?.isTypeSupported;if(typeof t==`function`)for(let n of e)try{if(t(n))return n}catch{}return``}function j(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>{let e=String(r.result||``);t(e.includes(`,`)?e.split(`,`).pop()||``:e)},r.onerror=()=>n(r.error||Error(`Could not read the recording.`)),r.readAsDataURL(e)})}function M(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function N({transcribe:e,onResult:t,onCancel:r,onError:i,stop:a=0}){let[o,s]=(0,E.useState)(0),[c,l]=(0,E.useState)(!1);n(()=>S());let u=(0,E.useRef)(null),d=(0,E.useRef)(null),f=(0,E.useRef)([]),p=(0,E.useRef)(null),m=(0,E.useRef)(null),h=(0,E.useRef)([]),g=(0,E.useRef)(!1),_=(0,E.useRef)(0);function v(){m.current!=null&&cancelAnimationFrame(m.current),m.current=null;try{d.current?.getTracks().forEach(e=>e.stop())}catch{}d.current=null;try{p.current?.close()}catch{}p.current=null}(0,E.useEffect)(()=>{let e=!1,t=navigator?.mediaDevices;if(!t?.getUserMedia||globalThis.MediaRecorder===void 0){i(`Voice input isn't supported in this browser.`),r();return}return t.getUserMedia({audio:!0}).then(t=>{if(e){t.getTracks().forEach(e=>e.stop());return}d.current=t;let n=A(),r=n?new MediaRecorder(t,{mimeType:n}):new MediaRecorder(t);u.current=r,r.ondataavailable=e=>{e.data&&e.data.size&&f.current.push(e.data)},r.onstop=()=>{if(v(),g.current)return;let e=r.mimeType||n||`audio/webm`;b(new Blob(f.current,{type:e}),e)},r.start(),_.current=Date.now(),y(t)}).catch(()=>{i(`Microphone access was denied.`),r()}),()=>{e=!0,g.current=!0;try{u.current&&u.current.state!==`inactive`&&u.current.stop()}catch{}v()}},[]),(0,E.useEffect)(()=>{let e=setInterval(()=>{_.current&&s(Date.now()-_.current)},250);return()=>clearInterval(e)},[]);function y(e){try{let t=new(window.AudioContext||window.webkitAudioContext);p.current=t;let n=t.createMediaStreamSource(e),r=t.createAnalyser();r.fftSize=64,n.connect(r);let i=new Uint8Array(r.frequencyBinCount),a=()=>{r.getByteFrequencyData(i);for(let e=0;e<k;e++){let t=h.current[e];if(!t)continue;let n=(i[Math.floor(e/k*i.length)]??0)/255;t.style.transform=`scaleY(${Math.max(.12,n)})`}m.current=requestAnimationFrame(a)};m.current=requestAnimationFrame(a)}catch{}}async function b(n,a){l(!0);try{if(!n.size)throw Error(`Nothing was recorded.`);let o=await e(await j(n),a);if(g.current)return;o?t(o):i(`No speech was detected.`),r()}catch(e){i(e instanceof Error?e.message:String(e)),r()}finally{l(!1)}}(0,E.useEffect)(()=>{a&&x()},[a]);function x(){if(c)return;let e=u.current;if(e&&e.state!==`inactive`)try{e.stop()}catch{r()}else S()}function S(){g.current=!0;try{u.current&&u.current.state!==`inactive`&&u.current.stop()}catch{}v(),r()}return(0,D.jsxs)(`div`,{className:`voice-bar`,role:`group`,"aria-label":`Voice recording`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voice-btn cancel`,onClick:S,"aria-label":`Cancel recording`,children:`✕`}),(0,D.jsx)(`div`,{className:`voice-wave`,"aria-hidden":!0,children:Array.from({length:k},(e,t)=>(0,D.jsx)(`span`,{className:`voice-bar-tick`,ref:e=>{h.current[t]=e}},t))}),(0,D.jsx)(`span`,{className:`voice-time`,children:c?`…`:M(o)}),(0,D.jsx)(`button`,{type:`button`,className:`voice-btn confirm`,onClick:x,disabled:c,"aria-label":`Use recording`,children:c?(0,D.jsx)(O,{size:`sm`,tone:`inverse`}):`✓`})]})}function P(){return typeof window<`u`&&!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function F({onResult:e,onCancel:t,onError:n,stop:r=0}){let[a,o]=(0,E.useState)(``),s=(0,E.useRef)(null),c=(0,E.useRef)(``),l=(0,E.useRef)(``),u=(0,E.useRef)(!1),d=r=>{if(!u.current){u.current=!0;try{r?s.current?.stop():s.current?.abort()}catch{}if(r){let t=`${c.current} ${l.current}`.trim();t?e(t):n(`No speech was detected.`)}t()}};return(0,E.useEffect)(()=>{let e=window.SpeechRecognition||window.webkitSpeechRecognition;if(!e){n(`Voice input isn't supported in this browser.`),t();return}let r=new e;s.current=r,r.continuous=!0,r.interimResults=!0;try{r.lang=navigator.language||`en-US`}catch{}r.onresult=e=>{let t=``;for(let n=e.resultIndex;n<e.results.length;n++){let r=e.results[n];r.isFinal?c.current+=r[0].transcript:t+=r[0].transcript}l.current=t,o(`${c.current} ${t}`.trim())},r.onerror=e=>{let t=e?.error;t!==`no-speech`&&t!==`aborted`&&(n(t===`not-allowed`||t===`service-not-allowed`?`Microphone access was denied.`:`Dictation error.`),d(!1))},r.onend=()=>d(!0);try{r.start()}catch{n(`Could not start dictation.`),t()}return()=>{u.current=!0;try{r.abort()}catch{}}},[]),(0,E.useEffect)(()=>{if(r)try{s.current?.stop()}catch{d(!0)}},[r]),(0,D.jsxs)(`div`,{className:`voice-bar`,role:`group`,"aria-label":`Voice dictation`,children:[(0,D.jsx)(`button`,{type:`button`,className:`voice-btn cancel`,onClick:()=>d(!1),"aria-label":`Cancel dictation`,children:`✕`}),(0,D.jsxs)(`div`,{className:`voice-listening`,children:[(0,D.jsx)(i,{status:`working`}),(0,D.jsx)(`span`,{className:`voice-listening-text`,children:a||`Listening…`})]}),(0,D.jsx)(`button`,{type:`button`,className:`voice-btn confirm`,onClick:()=>{try{s.current?.stop()}catch{d(!0)}},"aria-label":`Use dictation`,children:`✓`})]})}function I(e){return!e||e.providers.some(e=>e.configured)?`server`:P()?`webspeech`:null}var L=`Add a Groq or OpenAI key in Settings → Voice input to use voice input.`;function R({engine:e,stop:n,onResult:r,onCancel:i,onError:a}){return e===`server`?(0,D.jsx)(N,{transcribe:(e,n)=>t.transcribe(e,n),stop:n,onResult:r,onCancel:i,onError:a}):(0,D.jsx)(F,{stop:n,onResult:r,onCancel:i,onError:a})}function z({added:e,removed:t}){return!e&&!t?null:(0,D.jsxs)(`span`,{className:`tool-stat`,children:[e>0&&(0,D.jsxs)(`span`,{className:`add`,children:[`+`,e]}),t>0&&(0,D.jsxs)(`span`,{className:`del`,children:[`−`,t]})]})}var B=420,V=(0,E.memo)(function({hunks:e,single:t,mode:n=`unified`}){let r=B;return(0,D.jsx)(`div`,{className:`diff-viewer diff-${n}`,children:e.map((i,a)=>{let o=g(h(i.oldText,i.newText)),s=[];for(let e=0;e<o.length;e++){if(r<=0){s.push((0,D.jsxs)(`div`,{className:`diff-line skip`,children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,D.jsx)(`span`,{children:`Diff truncated`})]},`t${a}`));break}let t=o[e];if(t.type===`skip`){s.push(n===`split`?(0,D.jsxs)(`div`,{className:`diff-row skip`,children:[(0,D.jsxs)(`div`,{className:`diff-side`,children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,D.jsxs)(`span`,{children:[t.count,` unchanged`]})]}),(0,D.jsxs)(`div`,{className:`diff-side`,children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,D.jsxs)(`span`,{children:[t.count,` unchanged`]})]})]},e):(0,D.jsxs)(`div`,{className:`diff-line skip`,children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,D.jsxs)(`span`,{children:[t.count,` unchanged lines`]})]},e));continue}if(r--,n===`split`){let n=t.type===`add`?null:t.text||` `,r=t.type===`del`?null:t.text||` `;s.push((0,D.jsxs)(`div`,{className:`diff-row`,children:[(0,D.jsx)(`div`,{className:`diff-side ${t.type===`del`?`del`:t.type===`ctx`?``:`empty`}`,children:n!==null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:t.type===`del`?`−`:` `}),(0,D.jsx)(`span`,{className:`diff-code`,children:n})]})}),(0,D.jsx)(`div`,{className:`diff-side ${t.type===`add`?`add`:t.type===`ctx`?``:`empty`}`,children:r!==null&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:t.type===`add`?`+`:` `}),(0,D.jsx)(`span`,{className:`diff-code`,children:r})]})})]},e));continue}let i=t.type===`add`?`+`:t.type===`del`?`−`:` `;s.push((0,D.jsxs)(`div`,{className:`diff-line ${t.type}`,children:[(0,D.jsx)(`span`,{className:`diff-gutter`,children:i}),(0,D.jsx)(`span`,{className:`diff-code`,children:t.text||` `})]},e))}let c=e.length>1?`Hunk ${a+1}`:i.label||t||`Diff`;return(0,D.jsxs)(`div`,{className:`diff-hunk`,children:[(0,D.jsxs)(`div`,{className:`diff-hunk-title`,children:[(0,D.jsx)(`span`,{children:c}),(0,D.jsx)(z,{added:i.added,removed:i.removed})]}),s]},a)})})});function H(e){let t=[e.added?`+${e.added}`:``,e.removed?`−${e.removed}`:``].filter(Boolean).join(`/`);return`\`${e.path}\` (${e.status}${t?`, ${t}`:``})`}function U(e){return`Review the change to ${H(e)}. Explain why it changed, identify correctness or security risks, and suggest missing tests or follow-up edits.`}function W(e,t=[]){let n=e.slice(0,30),r=e.length-n.length,i=n.map(e=>`- ${H(e)}`);r>0&&i.push(`- …and ${r} more changed file${r===1?``:`s`}`);let a=t.filter(e=>e.status===`failed`).map(e=>e.name),o=a.length?`\n\nFailed checks to investigate: ${a.join(`, `)}.`:``;return`Review this turn's code changes:\n${i.join(`
|
|
4
4
|
`)}${o}\n\nFocus on correctness, regressions, security, and missing tests. Recommend concrete fixes where needed.`}var G={added:`+`,modified:`~`,deleted:`−`};function K(e){if(typeof e.added==`number`&&typeof e.removed==`number`)return{added:e.added,removed:e.removed};if(e.binary)return{added:0,removed:0};let t=0,n=0;for(let r of h(e.oldText,e.newText))r.type===`add`?t++:r.type===`del`&&n++;return{added:t,removed:n}}function q(e){if(!e)return``;let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);return n<60?`${n}m ago`:`${Math.round(n/60)}h ago`}function J({file:e,mode:n}){let[r,i]=(0,E.useState)(!1),[a,o]=(0,E.useState)(!1),{added:s,removed:c}=(0,E.useMemo)(()=>K(e),[e]);return(0,D.jsxs)(`div`,{className:`changes-file status-${e.status}`,children:[(0,D.jsxs)(`div`,{className:`changes-file-head`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`changes-file-open`,onClick:()=>i(e=>!e),children:[(0,D.jsx)(`span`,{className:`changes-file-glyph`,"aria-hidden":!0,children:G[e.status]}),(0,D.jsx)(`span`,{className:`changes-file-path`,children:e.path}),(s>0||c>0)&&(0,D.jsxs)(`span`,{className:`changes-file-stat`,children:[s>0&&(0,D.jsxs)(`span`,{className:`add`,children:[`+`,s]}),c>0&&(0,D.jsxs)(`span`,{className:`del`,children:[`−`,c]})]})]}),(0,D.jsxs)(`span`,{className:`changes-file-actions`,children:[(0,D.jsx)(`button`,{type:`button`,className:`changes-file-act`,onClick:()=>t.prefillComposer(U({...e,added:s,removed:c})),title:`Ask the agent about this file`,children:`Ask`}),(0,D.jsx)(`button`,{type:`button`,className:`changes-file-act danger`,onClick:()=>{o(!0),t.revertFile(e.path,e.status===`added`?null:e.oldText)},disabled:a,title:`Revert this file to its pre-turn state`,children:a?`…`:`Revert`})]})]}),r&&!e.binary&&(0,D.jsx)(V,{hunks:[{oldText:e.oldText,newText:e.newText,added:s,removed:c,label:e.path}],mode:n}),r&&e.binary&&(0,D.jsx)(`div`,{className:`changes-binary`,children:`Binary file — not shown.`})]})}function Y({node:e,byPath:t,mode:n,depth:r}){let[i,a]=(0,E.useState)(!0);if(e.type===`file`){let i=t.get(e.path);return i?(0,D.jsx)(`div`,{style:{paddingLeft:r*12},children:(0,D.jsx)(J,{file:i,mode:n})}):null}return(0,D.jsxs)(`div`,{className:`changes-dir`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`changes-dir-head`,style:{paddingLeft:r*12},onClick:()=>a(e=>!e),children:[(0,D.jsx)(`span`,{className:`changes-chevron`,"aria-hidden":!0,children:i?`▾`:`▸`}),(0,D.jsxs)(`span`,{className:`changes-dir-name`,children:[e.name,`/`]})]}),i&&e.children?.map(e=>(0,D.jsx)(Y,{node:e,byPath:t,mode:n,depth:r+1},e.path))]})}export{V as a,I as c,N as d,O as f,w as g,C as h,W as i,F as l,T as m,K as n,R as o,S as p,q as r,L as s,Y as t,P as u};
|