@bivy/bivy 0.20.9-staging.32 → 0.20.9-staging.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config-cli.js +2 -0
- package/dist/node-config.js +4 -3
- package/dist/server.js +19 -4
- package/dist/session/event-log.js +40 -5
- package/dist/work-instructions.js +50 -0
- package/package.json +1 -1
- package/web/assets/{AutomationsView-i4WFESaK.js → AutomationsView-ByhN0iAC.js} +1 -1
- package/web/assets/{ChangesCard-pUuoQdsU.js → ChangesCard-Dkca25Id.js} +1 -1
- package/web/assets/{LibraryView-Dgy1wnp9.js → LibraryView-D3XxcJiu.js} +1 -1
- package/web/assets/{ProviderConnect-DNVVwDKr.js → ProviderConnect-DcZq9COd.js} +1 -1
- package/web/assets/{SessionList-BHN8OlMo.js → SessionList-CSl6olZS.js} +1 -1
- package/web/assets/{Settings-DpR-Dmt4.js → Settings-CI6PV7Al.js} +3 -3
- package/web/assets/{Sheet-B0pVye_R.js → Sheet-C_l8Qiz6.js} +1 -1
- package/web/assets/{Terminal-CZ7y37Va.js → Terminal-cgiGAc8k.js} +1 -1
- package/web/assets/{VoiceSettings-BdPWUHft.js → VoiceSettings-mTi8Ab7q.js} +1 -1
- package/web/assets/{abnfDiagram-VCTEODGH-CRSGAimf.js → abnfDiagram-VCTEODGH-DKCrQ2G4.js} +1 -1
- package/web/assets/architecture-7GRP2DOG-CWj-KJ1u.js +1 -0
- package/web/assets/{architectureDiagram-5GKGNRK7-D_fk9A45.js → architectureDiagram-5GKGNRK7-BwWDMLXc.js} +1 -1
- package/web/assets/{blockDiagram-I7D4REHJ-DGKVdQvi.js → blockDiagram-I7D4REHJ-9RYpTd76.js} +1 -1
- package/web/assets/{c4Diagram-7LVT6UL2-Dmd2jgHX.js → c4Diagram-7LVT6UL2-C4WWj2Vs.js} +1 -1
- package/web/assets/channel-CHtVGBTS.js +1 -0
- package/web/assets/{chunk-4HAMMTFA-Db2xJKq1.js → chunk-4HAMMTFA-BoI4F3m1.js} +1 -1
- package/web/assets/{chunk-75Z2AOVW-CS8j4YSU.js → chunk-75Z2AOVW-CTKoxMoa.js} +1 -1
- package/web/assets/{chunk-DU6HZSFF-ek_nfK21.js → chunk-DU6HZSFF-C2tT7Twc.js} +1 -1
- package/web/assets/{chunk-F27PBJKO-CXS71Of9.js → chunk-F27PBJKO-8i5XnuZF.js} +1 -1
- package/web/assets/{chunk-GMAD6QVW-B307Or5u.js → chunk-GMAD6QVW-Co8GsPRG.js} +1 -1
- package/web/assets/{chunk-GVQU2GXP-BfA-Ownm.js → chunk-GVQU2GXP-BJ6Ojn0H.js} +1 -1
- package/web/assets/{chunk-IMKFNOWR-DFS5yX7D.js → chunk-IMKFNOWR-e9cqKsBR.js} +1 -1
- package/web/assets/{chunk-L3NEJ4N5-yQz5-WF3.js → chunk-L3NEJ4N5-D9ZfmxbD.js} +1 -1
- package/web/assets/{chunk-OSK3NFVY-D9JtSJLm.js → chunk-OSK3NFVY-0JBTHOE8.js} +1 -1
- package/web/assets/{chunk-P2QGCYS3-BRES72H-.js → chunk-P2QGCYS3-BIg0jTg4.js} +1 -1
- package/web/assets/{chunk-POPQ4Y6H-B7j4MjAI.js → chunk-POPQ4Y6H-D6qxbpsr.js} +1 -1
- package/web/assets/{chunk-PWAF6VOD-DaAiOOxK.js → chunk-PWAF6VOD-DZW_AvL4.js} +1 -1
- package/web/assets/{chunk-SHT3W25Y-JRoDslmC.js → chunk-SHT3W25Y-C9MSHwa2.js} +1 -1
- package/web/assets/{chunk-SVP7TREG-DV7lU3Jb.js → chunk-SVP7TREG-CMPUFvQb.js} +1 -1
- package/web/assets/{chunk-TICWLB2K-BtXvT-K1.js → chunk-TICWLB2K-Dc7nqh9g.js} +1 -1
- package/web/assets/classDiagram-ZZMXUADV-D2NqYopu.js +1 -0
- package/web/assets/classDiagram-v2-VYDZK3BY-D2NqYopu.js +1 -0
- package/web/assets/{cynefin-OW5HDTMX-C-G_CO1Z.js → cynefin-OW5HDTMX-BT57AAKC.js} +1 -1
- package/web/assets/{cynefinDiagram-5FMLGOSQ-DozkgaP4.js → cynefinDiagram-5FMLGOSQ-n-ipb6S7.js} +1 -1
- package/web/assets/{dagre-GXQ25YYZ-DWk1skmJ.js → dagre-GXQ25YYZ-BnVzkDsP.js} +1 -1
- package/web/assets/{diagram-S7CK7UJ4-j8NazwP5.js → diagram-S7CK7UJ4-BVioSGH9.js} +1 -1
- package/web/assets/{diagram-UQ7AKVKN-DutyaWjs.js → diagram-UQ7AKVKN-BQv4C5rR.js} +1 -1
- package/web/assets/{diagram-VSXAHHWV-B6umWMIn.js → diagram-VSXAHHWV-C7Wej_5I.js} +1 -1
- package/web/assets/{diagram-VX7I27RA-DxXCUCef.js → diagram-VX7I27RA-_FGhGEH-.js} +1 -1
- package/web/assets/{diagram-Z3DM3KII-faLxScgc.js → diagram-Z3DM3KII-DWrf-9yh.js} +1 -1
- package/web/assets/{ebnfDiagram-PWID7BFC-tpaPohcY.js → ebnfDiagram-PWID7BFC-6khuXE0E.js} +1 -1
- package/web/assets/{erDiagram-RLTQ6QDP-IT4AEczt.js → erDiagram-RLTQ6QDP-DfHFa81O.js} +1 -1
- package/web/assets/eventmodeling-NTZA5JFV-C6uGitqg.js +1 -0
- package/web/assets/flowDiagram-HODETNUW-C_aWcAPC.js +1 -0
- package/web/assets/{ganttDiagram-EL5Y4UJY-BtgUpFnL.js → ganttDiagram-EL5Y4UJY-Dp9UUO-3.js} +1 -1
- package/web/assets/{gitGraph-4MIJSDKK-z9754uzG.js → gitGraph-4MIJSDKK-DuinPWHD.js} +1 -1
- package/web/assets/{gitGraphDiagram-WWUBYQGX-CdfEAIlY.js → gitGraphDiagram-WWUBYQGX-B0WCV5Dy.js} +1 -1
- package/web/assets/{index-DpOoTT2W.js → index-3STLeiP_.js} +2 -2
- package/web/assets/{info-A6RAGUB7-BwSBzo9_.js → info-A6RAGUB7-CHLdK2lJ.js} +1 -1
- package/web/assets/{infoDiagram-27XIBGKW-Bgddyufq.js → infoDiagram-27XIBGKW-DtwI8_Wr.js} +1 -1
- package/web/assets/{ishikawaDiagram-5VMMS53U-DBD0HttR.js → ishikawaDiagram-5VMMS53U-DrU0f09X.js} +1 -1
- package/web/assets/{journeyDiagram-3NMN7TZE-DasYl-Ui.js → journeyDiagram-3NMN7TZE-CCf6Dwuf.js} +1 -1
- package/web/assets/{kanban-definition-UXKFOSKX-e4AZj7dB.js → kanban-definition-UXKFOSKX-Dq6bxV8s.js} +1 -1
- package/web/assets/{mermaid-parser.core-Bi7yzEm6.js → mermaid-parser.core-BqlBu2gd.js} +3 -3
- package/web/assets/{mermaid.core-DVB41_lM.js → mermaid.core-CGeH3snX.js} +4 -4
- package/web/assets/{mindmap-definition-YA3MSWOX-C9QKaN46.js → mindmap-definition-YA3MSWOX-BQypm25v.js} +1 -1
- package/web/assets/{mount-CUfgVvvJ.js → mount-B1a0Zf1O.js} +5 -5
- package/web/assets/{packet-AYTQ26CC-qz-tfjwz.js → packet-AYTQ26CC-C3hkXwnH.js} +1 -1
- package/web/assets/{pegDiagram-XKGWAZYB-BPYsTXFo.js → pegDiagram-XKGWAZYB-Cuezekh9.js} +1 -1
- package/web/assets/{pie-WAS4IAKB-ItCVxuFl.js → pie-WAS4IAKB-BLbLKNL9.js} +1 -1
- package/web/assets/{pieDiagram-E7YTZNPT-nx8ixc_7.js → pieDiagram-E7YTZNPT-Dh6pwEKU.js} +1 -1
- package/web/assets/{quadrantDiagram-AXDQQJYC-L_yNi0sK.js → quadrantDiagram-AXDQQJYC-Eif7oTUZ.js} +1 -1
- package/web/assets/{radar-RG4KPBEZ-TDh7Iye7.js → radar-RG4KPBEZ-CkBcZ874.js} +1 -1
- package/web/assets/{railroad-74A4TZTK-CTwTALGw.js → railroad-74A4TZTK-JtNCOtjW.js} +1 -1
- package/web/assets/railroad-abnf-HS5TGJTU-BkYs956v.js +1 -0
- package/web/assets/railroad-ebnf-LZEXJU2U-PMvT_JN9.js +1 -0
- package/web/assets/railroad-peg-WCYAUIDC-dTeHnWpJ.js +1 -0
- package/web/assets/{railroadDiagram-O6MQD6OU-DPJBYQNX.js → railroadDiagram-O6MQD6OU-CJ0zen7b.js} +1 -1
- package/web/assets/{requirementDiagram-BXWQKSXE-F52G9Be_.js → requirementDiagram-BXWQKSXE-D5EmmhBX.js} +1 -1
- package/web/assets/{sankeyDiagram-P5KCCOFB-SrUWPhYL.js → sankeyDiagram-P5KCCOFB-CpSU9XvZ.js} +1 -1
- package/web/assets/{sequenceDiagram-WJ2MYXX4-Dc3KDhMK.js → sequenceDiagram-WJ2MYXX4-DS9yh-En.js} +1 -1
- package/web/assets/{settingsRoute-C1wjo3JT.js → settingsRoute-CXooOZge.js} +1 -1
- package/web/assets/{stateDiagram-D77RDMKH-DRzzgSg0.js → stateDiagram-D77RDMKH-s0vohbtg.js} +1 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-BRD10_kF.js +1 -0
- package/web/assets/{swimlanes-42K2YHIH-BIg6fRKJ.js → swimlanes-42K2YHIH-Bk5QsrpR.js} +1 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-CA1cNOQT.js +8 -0
- package/web/assets/{timeline-definition-24CTP7MA-DshCNX0_.js → timeline-definition-24CTP7MA-CFuk44Ce.js} +1 -1
- package/web/assets/{treeView-Q6P3EWNA-DfLNgeBd.js → treeView-Q6P3EWNA-DmCDmIp1.js} +1 -1
- package/web/assets/{treemap-WGGIJYW6-9I-0hvSN.js → treemap-WGGIJYW6-taMzWoTg.js} +1 -1
- package/web/assets/{useStore-CcEpTfsH.js → useStore-UrxvGCn8.js} +1 -1
- package/web/assets/{vennDiagram-4TSXK5OY-jAl4zKI0.js → vennDiagram-4TSXK5OY-BUKABlPl.js} +1 -1
- package/web/assets/{wardley-WFR3VGLG-DD9rjjkf.js → wardley-WFR3VGLG-BnNRb9_w.js} +1 -1
- package/web/assets/{wardleyDiagram-VM6X3IG4-E_DGCWDx.js → wardleyDiagram-VM6X3IG4-Bk-JQDfa.js} +1 -1
- package/web/assets/{xychartDiagram-S5SC5T6Z-DwI9Y2Uo.js → xychartDiagram-S5SC5T6Z-UARcsy88.js} +1 -1
- package/web/index.html +1 -1
- package/web/sw.js +1 -1
- package/web/assets/architecture-7GRP2DOG-DcmiDWn-.js +0 -1
- package/web/assets/channel-mekEDsNC.js +0 -1
- package/web/assets/classDiagram-ZZMXUADV-DF-si_Ha.js +0 -1
- package/web/assets/classDiagram-v2-VYDZK3BY-DF-si_Ha.js +0 -1
- package/web/assets/eventmodeling-NTZA5JFV-K8kCPdlr.js +0 -1
- package/web/assets/flowDiagram-HODETNUW-Bl6Vx-XN.js +0 -1
- package/web/assets/railroad-abnf-HS5TGJTU-o_h3d-Gc.js +0 -1
- package/web/assets/railroad-ebnf-LZEXJU2U-BTGstpxT.js +0 -1
- package/web/assets/railroad-peg-WCYAUIDC-IQz14-us.js +0 -1
- package/web/assets/stateDiagram-v2-MP3YSRHH-DiX__IXc.js +0 -1
- package/web/assets/swimlanesDiagram-VR7AAH4N-CjEk-RfJ.js +0 -8
package/dist/config-cli.js
CHANGED
|
@@ -112,6 +112,7 @@ const ENV_FOR_KEY = {
|
|
|
112
112
|
"sessions.previewBadge": "BIVY_PREVIEW_BADGE",
|
|
113
113
|
"automation.checks": "BIVY_AUTOMATION_CHECKS",
|
|
114
114
|
"automation.checkTimeoutMinutes": "BIVY_AUTOMATION_CHECK_TIMEOUT_MS",
|
|
115
|
+
"automation.slackPrompts": "BIVY_SLACK_PROMPTS",
|
|
115
116
|
};
|
|
116
117
|
const BUILTIN_VALUES = {
|
|
117
118
|
"node.port": 4317,
|
|
@@ -128,6 +129,7 @@ const BUILTIN_VALUES = {
|
|
|
128
129
|
"sessions.previewBadge": true,
|
|
129
130
|
"automation.checks": ["test", "lint", "typecheck"],
|
|
130
131
|
"automation.checkTimeoutMinutes": 10,
|
|
132
|
+
"automation.slackPrompts": false,
|
|
131
133
|
};
|
|
132
134
|
function baseEffectiveValue(config, key) {
|
|
133
135
|
const configured = getConfigValue(config, key);
|
package/dist/node-config.js
CHANGED
|
@@ -76,7 +76,7 @@ export function validateNodeConfig(value) {
|
|
|
76
76
|
const safety = section(root, "safety", ["maxSandbox", "approvalFloor"], errors);
|
|
77
77
|
const sessions = section(root, "sessions", ["sync", "worktreeSync", "standbyNodeId", "resume", "autoAttachToolImages", "appScreenshots", "previewBadge", "forkWorkspaceMaxBytes", "wedgedTurnMinutes"], errors);
|
|
78
78
|
const github = section(root, "github", ["issuePrompt"], errors);
|
|
79
|
-
const automation = section(root, "automation", ["checks", "checkTimeoutMinutes"], errors);
|
|
79
|
+
const automation = section(root, "automation", ["checks", "checkTimeoutMinutes", "slackPrompts"], errors);
|
|
80
80
|
const agentsRaw = section(root, "agents", Object.keys(record(root.agents) ?? {}), errors);
|
|
81
81
|
const environment = section(root, "environment", Object.keys(record(root.environment) ?? {}), errors);
|
|
82
82
|
const workspace = optionalString(node.workspace, "node.workspace", errors);
|
|
@@ -157,6 +157,7 @@ export function validateNodeConfig(value) {
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
const checkTimeoutMinutes = optionalInteger(automation.checkTimeoutMinutes, "automation.checkTimeoutMinutes", errors, 1, 30);
|
|
160
|
+
const slackPrompts = optionalBoolean(automation.slackPrompts, "automation.slackPrompts", errors);
|
|
160
161
|
const agents = {};
|
|
161
162
|
for (const [id, raw] of Object.entries(agentsRaw)) {
|
|
162
163
|
const at = `agents.${id}`;
|
|
@@ -220,7 +221,7 @@ export function validateNodeConfig(value) {
|
|
|
220
221
|
...(Object.keys(safety).length ? { safety: { maxSandbox, approvalFloor } } : {}),
|
|
221
222
|
...(Object.keys(sessions).length ? { sessions: { sync, worktreeSync, standbyNodeId, resume, autoAttachToolImages, appScreenshots, previewBadge, forkWorkspaceMaxBytes, wedgedTurnMinutes } } : {}),
|
|
222
223
|
...(Object.keys(github).length ? { github: { issuePrompt } } : {}),
|
|
223
|
-
...(Object.keys(automation).length ? { automation: { checks, checkTimeoutMinutes } } : {}),
|
|
224
|
+
...(Object.keys(automation).length ? { automation: { checks, checkTimeoutMinutes, slackPrompts } } : {}),
|
|
224
225
|
...(Object.keys(agents).length ? { agents } : {}),
|
|
225
226
|
...(Object.keys(envOut).length ? { environment: envOut } : {}),
|
|
226
227
|
};
|
|
@@ -368,7 +369,7 @@ export function setConfigValue(config, dotted, value) {
|
|
|
368
369
|
"defaults.agent", "defaults.model", "defaults.sandbox", "defaults.approval",
|
|
369
370
|
"safety.maxSandbox", "safety.approvalFloor",
|
|
370
371
|
"sessions.sync", "sessions.worktreeSync", "sessions.standbyNodeId", "sessions.resume", "sessions.autoAttachToolImages", "sessions.appScreenshots", "sessions.previewBadge", "sessions.forkWorkspaceMaxBytes", "sessions.wedgedTurnMinutes",
|
|
371
|
-
"github.issuePrompt", "automation.checks", "automation.checkTimeoutMinutes",
|
|
372
|
+
"github.issuePrompt", "automation.checks", "automation.checkTimeoutMinutes", "automation.slackPrompts",
|
|
372
373
|
]);
|
|
373
374
|
if (!allowed.has(dotted) && !/^agents\.[a-z][a-z0-9-]{1,47}$/.test(dotted) && !/^environment\.[A-Z][A-Z0-9_]+$/.test(dotted))
|
|
374
375
|
throw new Error(`Unknown configuration key: ${dotted}`);
|
package/dist/server.js
CHANGED
|
@@ -177,6 +177,7 @@ import { getSttConfig, isSttProvider, removeSttKey, setSttKey, setSttProvider, t
|
|
|
177
177
|
import { synthesizeOpenAiSpeech } from "./tts.js";
|
|
178
178
|
import { seal, open } from "./e2e.js";
|
|
179
179
|
import { recoverModelAuthKey } from "./model-auth-key-recovery.js";
|
|
180
|
+
import { runPrompt, trustedInstructions } from "./work-instructions.js";
|
|
180
181
|
import { RunDelegationService, parseDelegationSource } from "./run-tools.js";
|
|
181
182
|
import { delegationCard } from "./session/delegation-cards.js";
|
|
182
183
|
import { TERMINAL_DELEGATION, isDelegatedFrom } from "./session/delegations.js";
|
|
@@ -1563,6 +1564,15 @@ function nodeConfiguredDefaultAgent() {
|
|
|
1563
1564
|
}
|
|
1564
1565
|
/** How interactive sessions recover after a restart interrupted them mid-turn.
|
|
1565
1566
|
* Defaults to "auto" (re-drive the turn); "manual" waits for a user tap. */
|
|
1567
|
+
/** This machine runs Slack prompts, which arrive unsealed: the node setting, or BIVY_SLACK_PROMPTS. Off by default. */
|
|
1568
|
+
function slackPromptsEnabled() {
|
|
1569
|
+
const env = process.env.BIVY_SLACK_PROMPTS;
|
|
1570
|
+
if (env === "1" || env === "true")
|
|
1571
|
+
return true;
|
|
1572
|
+
if (env === "0" || env === "false")
|
|
1573
|
+
return false;
|
|
1574
|
+
return readNodeConfig(appDir)?.automation?.slackPrompts === true;
|
|
1575
|
+
}
|
|
1566
1576
|
/** Agents may screenshot app previews: the node setting, or BIVY_APP_SCREENSHOTS. */
|
|
1567
1577
|
function appScreenshotsEnabled() {
|
|
1568
1578
|
const env = process.env.BIVY_APP_SCREENSHOTS;
|
|
@@ -5588,7 +5598,8 @@ async function executeWorkItem(item, report, signal) {
|
|
|
5588
5598
|
// source.
|
|
5589
5599
|
let credentialLabels;
|
|
5590
5600
|
let filter;
|
|
5591
|
-
|
|
5601
|
+
const sealed = Boolean(item.body?.startsWith("bivy-room-v1:"));
|
|
5602
|
+
if (sealed) {
|
|
5592
5603
|
const [, nodeId, ...payload] = item.body.split(":");
|
|
5593
5604
|
if (nodeId !== identity.nodeId || payload.length === 0) {
|
|
5594
5605
|
throw new Error("automation instructions were encrypted for a different node");
|
|
@@ -5603,6 +5614,12 @@ async function executeWorkItem(item, report, signal) {
|
|
|
5603
5614
|
throw new Error("could not decrypt automation instructions on this node");
|
|
5604
5615
|
}
|
|
5605
5616
|
}
|
|
5617
|
+
// Only sealed, fetched, built-in or opted-in Slack instructions reach the agent
|
|
5618
|
+
// (src/work-instructions.ts): the control plane can't author a run.
|
|
5619
|
+
const trusted = trustedInstructions(item, { sealed, slackPrompts: slackPromptsEnabled() });
|
|
5620
|
+
if (!trusted.ok)
|
|
5621
|
+
throw new Error(trusted.reason);
|
|
5622
|
+
item = { ...item, body: trusted.body };
|
|
5606
5623
|
// Gate before any repository fetch, session continuation, or agent creation.
|
|
5607
5624
|
// A skip finishes this selected automation; it does not fall through to another.
|
|
5608
5625
|
if (filter && !await passWebhookFilter(filter, item, report, signal))
|
|
@@ -5739,9 +5756,7 @@ async function executeWorkItem(item, report, signal) {
|
|
|
5739
5756
|
// into the prompt. A scheduled chat message must arrive verbatim; the name is
|
|
5740
5757
|
// only the run/session label.
|
|
5741
5758
|
const delegatedProvenance = parseDelegationSource(item.source);
|
|
5742
|
-
const request = item.
|
|
5743
|
-
? (item.body || item.title)
|
|
5744
|
-
: item.body ? `${item.title}\n\n${item.body}` : item.title;
|
|
5759
|
+
const request = runPrompt(item, trusted.titleInPrompt);
|
|
5745
5760
|
// Plain chat messages (scheduled "message me later" reminders) skip
|
|
5746
5761
|
// auto-push and required checks — even when a workspace target happens to be
|
|
5747
5762
|
// a git checkout.
|
|
@@ -236,7 +236,46 @@ export function mergeBases(logged, runtime) {
|
|
|
236
236
|
if (add(m))
|
|
237
237
|
sequence.push({ fresh: m }); // not in the logged base
|
|
238
238
|
}
|
|
239
|
-
return placeFresh(merged, sequence);
|
|
239
|
+
return placeLoggedOnly(placeFresh(merged, sequence), sequence);
|
|
240
|
+
}
|
|
241
|
+
function timeOf(m) {
|
|
242
|
+
const t = m.timestamp;
|
|
243
|
+
return typeof t === "number" && Number.isFinite(t) ? t : undefined;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Put runs of messages only the log has back where they happened. A reload can
|
|
247
|
+
* drop messages the log stored: Claude's reloaded transcript has no subagent
|
|
248
|
+
* sidechain. Such a run kept its spot after its last shared message, so every
|
|
249
|
+
* later turn went in ahead of it and the old subagent work sat below the newest
|
|
250
|
+
* reply. A run that is older than the shared message before it moves to just
|
|
251
|
+
* before the first shared message that came later.
|
|
252
|
+
*/
|
|
253
|
+
function placeLoggedOnly(list, sequence) {
|
|
254
|
+
const shared = new Set(sequence.map((item) => ("anchor" in item ? item.anchor : item.fresh)));
|
|
255
|
+
const out = [];
|
|
256
|
+
let previous; // last shared message already in `out`
|
|
257
|
+
for (let i = 0; i < list.length;) {
|
|
258
|
+
if (shared.has(list[i])) {
|
|
259
|
+
previous = list[i];
|
|
260
|
+
out.push(previous);
|
|
261
|
+
i++;
|
|
262
|
+
continue;
|
|
263
|
+
}
|
|
264
|
+
let end = i;
|
|
265
|
+
while (end < list.length && !shared.has(list[end]))
|
|
266
|
+
end++;
|
|
267
|
+
const run = list.slice(i, end);
|
|
268
|
+
i = end;
|
|
269
|
+
const t = timeOf(run[0]);
|
|
270
|
+
const before = previous && timeOf(previous);
|
|
271
|
+
if (t === undefined || before === undefined || before <= t) {
|
|
272
|
+
out.push(...run);
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const at = out.findIndex((m) => shared.has(m) && (timeOf(m) ?? -Infinity) > t);
|
|
276
|
+
out.splice(at < 0 ? out.length : at, 0, ...run);
|
|
277
|
+
}
|
|
278
|
+
return out;
|
|
240
279
|
}
|
|
241
280
|
/**
|
|
242
281
|
* Put messages only the runtime had where they happened, not at the end. A
|
|
@@ -251,10 +290,6 @@ function placeFresh(merged, sequence) {
|
|
|
251
290
|
const freshSet = new Set(sequence.flatMap((item) => ("fresh" in item ? [item.fresh] : [])));
|
|
252
291
|
if (!freshSet.size)
|
|
253
292
|
return merged;
|
|
254
|
-
const timeOf = (m) => {
|
|
255
|
-
const t = m.timestamp;
|
|
256
|
-
return typeof t === "number" && Number.isFinite(t) ? t : undefined;
|
|
257
|
-
};
|
|
258
293
|
const placed = merged.filter((m) => !freshSet.has(m));
|
|
259
294
|
let previous; // last anchor seen, or last fresh placed after it
|
|
260
295
|
for (let i = 0; i < sequence.length; i++) {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 Petter André Sjulstad
|
|
3
|
+
/**
|
|
4
|
+
* Which instructions a queued run may give the agent. The control plane relays
|
|
5
|
+
* work but must not be able to author it, so instructions come only from:
|
|
6
|
+
* - a template sealed to this node (`bivy-room-v1:`), opened before this runs;
|
|
7
|
+
* - content the node fetches itself from the source (GitHub, Linear);
|
|
8
|
+
* - a prompt built into the node (CI failures without a template);
|
|
9
|
+
* - a Slack prompt, which the control plane relays in plaintext, only when this
|
|
10
|
+
* node has turned Slack prompts on.
|
|
11
|
+
* Anything else the control plane sends in plaintext (a title, an unsealed body)
|
|
12
|
+
* is a label, never part of the prompt.
|
|
13
|
+
*/
|
|
14
|
+
/** Built-in prompt for a failed CI build when its automation has no template. */
|
|
15
|
+
export const FIX_CI_PROMPT = `Investigate a failed CI build and prepare a tested fix.
|
|
16
|
+
|
|
17
|
+
1. Use the incoming event context (build URL, job name, conclusion) to locate the failure. Fetch logs with credentials already on this machine — never ask the event for secrets.
|
|
18
|
+
2. Reproduce the failure locally with the project's own test/CI commands.
|
|
19
|
+
3. Make the smallest safe fix. Do not refactor unrelated code.
|
|
20
|
+
4. Run the affected checks and the project's tests, linter, and type checks.
|
|
21
|
+
5. Commit on a new branch and open a pull request that links the failing build and summarises the root cause and the checks that passed.
|
|
22
|
+
|
|
23
|
+
If the failure cannot be reproduced or is clearly an infrastructure flake, make no code changes and report the evidence.`;
|
|
24
|
+
/** What to do with a run whose instructions arrived unsealed, by source. */
|
|
25
|
+
const UNSEALED = {
|
|
26
|
+
"github:issue": "fetched",
|
|
27
|
+
"github:comment": "fetched",
|
|
28
|
+
"linear:issue": "fetched",
|
|
29
|
+
"github:ci": "builtin-ci",
|
|
30
|
+
slack: "slack",
|
|
31
|
+
};
|
|
32
|
+
export const SLACK_PROMPTS_OFF = "Slack prompts are off on this machine. Turn them on with `bivy config set automation.slackPrompts true` and restart Bivy.";
|
|
33
|
+
export function trustedInstructions(item, opts) {
|
|
34
|
+
if (opts.sealed)
|
|
35
|
+
return { ok: true, body: item.body, titleInPrompt: false };
|
|
36
|
+
switch (UNSEALED[item.source]) {
|
|
37
|
+
case "fetched": return { ok: true, body: undefined, titleInPrompt: false };
|
|
38
|
+
case "builtin-ci": return { ok: true, body: FIX_CI_PROMPT, titleInPrompt: false };
|
|
39
|
+
case "slack":
|
|
40
|
+
return opts.slackPrompts ? { ok: true, body: item.body, titleInPrompt: true } : { ok: false, reason: SLACK_PROMPTS_OFF };
|
|
41
|
+
default:
|
|
42
|
+
return { ok: false, reason: "This run's instructions aren't end-to-end encrypted for this machine, so it won't run them. Save the automation again from the app to re-encrypt it." };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/** The prompt for a generic run, after `trustedInstructions` and any event context. */
|
|
46
|
+
export function runPrompt(item, titleInPrompt) {
|
|
47
|
+
if (!titleInPrompt)
|
|
48
|
+
return item.body ?? "";
|
|
49
|
+
return item.body ? `${item.title}\n\n${item.body}` : item.title;
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{V as n,j as r}from"./index-DpOoTT2W.js";import{$ as i,At as a,C as o,Dt as s,Et as c,G as l,J as u,K as d,N as f,Ot as p,P as m,Q as h,W as g,X as _,Y as v,dt as y,et as b,i as x,kt as S,lt as C,mt as ee,n as w,nt as te,q as ne,rt as re,t as ie,tt as ae,ut as oe,vt as se,xt as T}from"./useStore-CcEpTfsH.js";import{A as E,E as D,M as O,a as k,f as A,h as j,i as ce,j as M,n as N,s as le,t as P}from"./Sheet-B0pVye_R.js";import{t as F}from"./jsx-runtime-NZYk81nU.js";import{E as ue,T as de,a as fe,g as pe,n as me,o as I,r as L,s as R}from"./SessionList-BHN8OlMo.js";import{C as he,T as z,w as ge}from"./mount-CUfgVvvJ.js";var _e=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})())})),ve=O(),B=e(_e(),1),V=a();function H(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 U(e,t){(0,V.useLayoutEffect)(()=>{e.current&&H(e.current)},[e,t]),(0,V.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.clientWidth,r=new ResizeObserver(()=>{t.clientWidth!==n&&(n=t.clientWidth,H(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{V as n,j as r}from"./index-3STLeiP_.js";import{$ as i,At as a,C as o,Dt as s,Et as c,G as l,J as u,K as d,N as f,Ot as p,P as m,Q as h,W as g,X as _,Y as v,dt as y,et as b,i as x,kt as S,lt as C,mt as ee,n as w,nt as te,q as ne,rt as re,t as ie,tt as ae,ut as oe,vt as se,xt as T}from"./useStore-UrxvGCn8.js";import{A as E,E as D,M as O,a as k,f as A,h as j,i as ce,j as M,n as N,s as le,t as P}from"./Sheet-C_l8Qiz6.js";import{t as F}from"./jsx-runtime-NZYk81nU.js";import{E as ue,T as de,a as fe,g as pe,n as me,o as I,r as L,s as R}from"./SessionList-CSl6olZS.js";import{C as he,T as z,w as ge}from"./mount-B1a0Zf1O.js";var _e=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})())})),ve=O(),B=e(_e(),1),V=a();function H(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 U(e,t){(0,V.useLayoutEffect)(()=>{e.current&&H(e.current)},[e,t]),(0,V.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=t.clientWidth,r=new ResizeObserver(()=>{t.clientWidth!==n&&(n=t.clientWidth,H(t))});return r.observe(t),()=>r.disconnect()},[e])}var W=`bivy-automation-v1
|
|
2
2
|
`;function ye(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 be(e,t,n){return n||Object.keys(t).length||e.startsWith(W)?W+JSON.stringify({instructions:e,credentialLabels:t,...n?{filter:ye(n)}:{}}):e}function xe(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:ye(t.filter)}}}var G={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},K={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 Se(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 Ce(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 G&&t.add(G[e])}return[...t].sort((e,t)=>e-t)}function we(e){let t=new Set;for(let n of e.matchAll(/\b([a-z]+)\b/g)){let e=n[1];e&&e in K&&t.add(K[e])}return[...t].sort((e,t)=>e-t)}function Te(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 Ee(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=Se(t),i=Ce(t),a=we(t),o=Te(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.`}:q({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.`}:q({minute:e===1?`*`:`*/${e}`,hour:`*`,dom:s,month:c,dow:l})}if(/\bevery\s+minute\b/.test(t))return q({minute:`*`,hour:`*`,dom:s,month:c,dow:l});if(/\b(every\s+hour|hourly)\b/.test(t))return q({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 q({minute:u,hour:d,dom:s,month:c,dow:l})}function q(e){return{cron:`${e.minute} ${e.hour} ${e.dom} ${e.month} ${e.dow}`,fields:e}}function De(e){return e.cron!==void 0}function J(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 Oe(e,t=``){return[...new Set((e?.apps??[]).filter(e=>!t||e.appId===t).map(e=>e.mention?.replace(/^@/,``)).filter(e=>!!e))]}function Y(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 X=F();function ke({info:e,onChanged:t}){let n=(0,V.useId)(),r=e.apps.find(e=>e.triggerAccess)?.triggerAccess??e.triggerAccess??`everyone`,[i,a]=(0,V.useState)(r),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1);(0,V.useEffect)(()=>{a(r)},[r]);async function f(e){s(!0),l(``),d(!1);try{a(await x.setGithubAppTriggerAccess(e)),d(!0),t?.()}catch(e){l(String(e.message||e))}finally{s(!1)}}return(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:n,children:`Who can trigger with a GitHub mention?`}),(0,X.jsxs)(`select`,{id:n,className:`picker-search`,value:i,disabled:o,onChange:e=>void f(e.target.value),children:[(0,X.jsx)(`option`,{value:`everyone`,children:`Anyone on GitHub`}),(0,X.jsx)(`option`,{value:`contributor`,children:`Contributors and collaborators`}),(0,X.jsx)(`option`,{value:`collaborator`,children:`Collaborators with write access`})]}),(0,X.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,X.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Saving permissions…`}),u&&!o&&(0,X.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Permissions saved.`}),c&&(0,X.jsx)(`p`,{className:`settings-error`,role:`alert`,children:c})]})}function Z(){try{sessionStorage.setItem(`bivy.githubAppPending`,`1`)}catch{}}function Ae(e){return e.appId||e.hookId||e.slug||``}function je(e){return e.installUrl||(e.slug?`https://github.com/apps/${e.slug}/installations/new`:`https://github.com/settings/installations`)}function Me(e){switch(e){case`linear`:return`Connect Linear`;case`slack`:return`Connect Slack`;default:return`GitHub App setup`}}function Ne(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 Pe({state:e,onClose:t,focus:n=`github`,onChanged:r}){let i=!x.direct,a=(0,V.useRef)(r);a.current=r;let o=E(t);M(o);let[s,c]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(!0),[h,_]=(0,V.useState)([]),[y,b]=(0,V.useState)(null),[S,C]=(0,V.useState)(null),[ee,ne]=(0,V.useState)(null),[ie,oe]=(0,V.useState)(``),[se,T]=(0,V.useState)(``),[D,O]=(0,V.useState)(``),[k,A]=(0,V.useState)(!1),[j,ce]=(0,V.useState)(null),[N,le]=(0,V.useState)(!1),[P,F]=(0,V.useState)(``),[ue,de]=(0,V.useState)(``),[fe,pe]=(0,V.useState)(``),[me,I]=(0,V.useState)(!1),[L,R]=(0,V.useState)(null),[he,z]=(0,V.useState)(``),[ge,_e]=(0,V.useState)(!1),[ve,B]=(0,V.useState)(null),[H,U]=(0,V.useState)(!1),W=(0,V.useRef)(null),[ye,be]=(0,V.useState)(null),[xe,G]=(0,V.useState)(null),[K,Se]=(0,V.useState)(!1),[Ce,we]=(0,V.useState)(null),[Te,Ee]=(0,V.useState)(``),[q,De]=(0,V.useState)(``),[J,Oe]=(0,V.useState)(!1),[Pe,Re]=(0,V.useState)(``),[ze,Be]=(0,V.useState)(!1),[Ve,He]=(0,V.useState)(``),[Ue,We]=(0,V.useState)(``),[Ge,Ke]=(0,V.useState)(!1),[qe,Je]=(0,V.useState)(``),[Ye,Xe]=(0,V.useState)(!1),Ze=e.presentation.githubApp,Q=Ze?.phase??`idle`,Qe=Q===`submitting`&&Ze?.action&&Ze?.manifest,$e=n===`github`||n===`work-queue`,et=n===`linear`,tt=n===`slack`,$=(0,V.useCallback)(async()=>{if(!i){oe(`Source setup needs a hosted account connection.`),m(!1);return}oe(``),m(!0);try{let[e,t,n,r,i,a]=await Promise.all([x.fetchGithubApp(),x.listNodes(),te(x.local).catch(()=>null),re(x.local).catch(()=>null),ae(x.local).catch(()=>null),x.centralGithubApp().catch(()=>null)]);f(a),c(e),_(t),b(n),C(r),ne(i);let o=e.apps.find(e=>e.defaultNode)?.defaultNode??e.defaultNode??``;O(o||``),n?.defaultNode&&De(n.defaultNode),r?.defaultNode&&We(r.defaultNode)}catch(e){oe(String(e.message||e))}finally{m(!1)}},[i]);(0,V.useEffect)(()=>{$();let e=()=>{$(),a.current?.()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[$]),(0,V.useEffect)(()=>{Q===`done`&&($(),a.current?.())},[Q,$]);let nt=s?.apps??[],rt=nt.some(e=>e.installed),it=nt.some(e=>e.servedBy?.online),at=!!ee?.execution.ready,ot=nt.length>0&&rt&&(at||it);async function st(){Se(!0),we(null);try{let e=await x.createCentralGithubInstall(`/automations`);window.location.assign(e.installUrl)}catch(e){we(String(e?.message||e)),Se(!1)}}async function ct(){A(!0),ce(null);try{let e=await x.setGithubAppDefaultNode(D.trim());ce(`Saved`),c(t=>t&&{...t,defaultNode:e,apps:t.apps.map(t=>({...t,defaultNode:e}))}),r?.(),setTimeout(()=>ce(null),1500)}catch(e){ce(String(e.message||e))}finally{A(!1)}}async function lt(){I(!0),z(``),_e(!1),R(null);try{if(e.connection.currentNodeId)await x.githubAppConnectExisting({appId:P.trim(),privateKeyPem:ue.trim()}),_e(!0);else{let e=await x.connectHostedGithubApp({appId:P.trim(),privateKeyPem:ue.trim(),...fe.trim()?{installationId:fe.trim()}:{}});R({webhookUrl:e.webhookUrl,webhookSecret:e.webhookSecret})}de(``),await $(),r?.()}catch(e){z(String(e?.message||e))}finally{I(!1)}}async function ut(e){let t=Ae(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),be(t);try{await x.githubAppDisconnect(e.appId,e.hookId),await $(),r?.(),(await x.fetchGithubApp()).apps.some(e=>Ae(e)===t)&&G(`Disconnect didn't take effect — try again shortly.`)}catch(e){G(String(e.message||e))}finally{be(null)}}}function dt(e){B(e??null),F(e?.appId??``),de(``),z(``),_e(!1),R(null),le(!0),U(!0)}(0,V.useEffect)(()=>{H&&N&&W.current?.scrollIntoView({behavior:`smooth`,block:`nearest`})},[H,N,ve]);function ft(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>de(String(n.result||``).trim()),n.readAsText(t)}async function pt(){Oe(!0),Re(``);try{let e=await g(x.local,{defaultNode:q||void 0});b(e),r?.()}catch(e){Re(String(e.message||e))}finally{Oe(!1)}}async function mt(){Oe(!0),Re(``);try{let e=await g(x.local,{signingSecret:Te.trim(),defaultNode:q||void 0});b(e),Ee(``),Be(!!e.enabled),r?.()}catch(e){Re(String(e.message||e))}finally{Oe(!1)}}async function ht(){if(confirm(`Disconnect Linear? Its webhook URL will stop accepting issues.`)){Oe(!0),Re(``);try{await u(x.local),b(null),Be(!1),r?.()}catch(e){Re(String(e.message||e))}finally{Oe(!1)}}}async function gt(){Ke(!0),Je(``);try{let e=await l(x.local,{signingSecret:Ve.trim(),defaultNode:Ue||void 0});C(e),He(``),Xe(!0),r?.()}catch(e){Je(String(e.message||e))}finally{Ke(!1)}}async function _t(){if(confirm(`Disconnect Slack? The slash-command URL will stop accepting requests.`)){Ke(!0),Je(``);try{await v(x.local),C(null),Xe(!1),r?.()}catch(e){Je(String(e.message||e))}finally{Ke(!1)}}}let vt=n===`github`&&(s?.connected||rt)?`Manage GitHub Apps`:Me(n),yt=n===`slack`&&S?.enabled?`Done — Slack is live`:n===`linear`&&y?.enabled?`Done — Linear is live`:n===`github`&&ot?`Done — GitHub is live`:ot&&n===`work-queue`?`Done — ready to run`:`Done`;return(0,X.jsx)(`div`,{className:`wizard-scrim`,onClick:o,children:(0,X.jsxs)(`div`,{className:`wizard autom-editor wq-setup`,role:`dialog`,"aria-modal":`true`,"aria-label":vt,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`wizard-head`,children:[(0,X.jsxs)(`div`,{className:`wq-head-text`,children:[(0,X.jsx)(`strong`,{children:vt}),(0,X.jsx)(`span`,{className:`wq-head-sub`,children:`Automations · Sources`})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn ghost icon`,onClick:o,"aria-label":`Close`,children:`✕`})]}),(0,X.jsxs)(`div`,{className:`wizard-body`,children:[(0,X.jsx)(`p`,{className:`settings-hint wq-lead`,children:Ne(n)}),p&&(0,X.jsx)(`p`,{className:`settings-hint`,role:`status`,children:`Checking source connection…`}),ie&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:[ie,(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void $(),children:`Retry`})]}),$e&&s&&(0,X.jsxs)(`div`,{className:`autom-field-block`,children:[(0,X.jsxs)(`div`,{className:`autom-field-label`,children:[(0,X.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Fe,{})}),`GitHub Apps`]}),(0,X.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,X.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[(0,X.jsx)(`strong`,{children:`Hosted Bivy GitHub App · Recommended`}),(0,X.jsx)(`p`,{className:`settings-hint`,children:`Choose repositories on GitHub and start using Bivy. No app creation or private key is needed.`}),!d?.configured&&(0,X.jsx)(`p`,{className:`settings-hint`,children:d?`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,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:K||!d?.configured,onClick:()=>void st(),children:K?`Opening GitHub…`:`Install hosted Bivy App`}),(0,X.jsx)(`a`,{className:`btn sm`,href:`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:`Manage hosted app access on GitHub ↗`}),(0,X.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.`}),Ce&&(0,X.jsx)(`p`,{className:`settings-error`,role:`alert`,children:Ce})]}),nt.length===0?(0,X.jsxs)(`details`,{className:`card wq-status-card`,"data-tone":`muted`,children:[(0,X.jsx)(`summary`,{children:`Use your own GitHub App`}),(0,X.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,X.jsx)(`label`,{className:`field-label`,htmlFor:`wq-org`,children:`Organization (optional)`}),(0,X.jsx)(`input`,{id:`wq-org`,className:`picker-search`,value:se,placeholder:`leave blank for your personal account`,disabled:Q===`starting`||Q===`submitting`||Q===`completing`,onChange:e=>T(e.target.value)}),Qe?(0,X.jsxs)(`form`,{method:`post`,action:Ze.action,onSubmit:Z,children:[(0,X.jsx)(`input`,{type:`hidden`,name:`manifest`,value:JSON.stringify(Ze.manifest)}),(0,X.jsx)(`button`,{className:`btn primary block`,type:`submit`,children:`Continue to GitHub →`})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:Q===`starting`||Q===`completing`||!i,onClick:()=>x.githubAppManifestStart(se.trim()||void 0),children:Q===`starting`?`Preparing…`:Q===`completing`?`Finishing…`:`Create GitHub App`}),!N&&(0,X.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>le(!0),children:`Connect an existing app instead →`}),N&&(0,X.jsxs)(`div`,{className:`ce-form`,children:[(0,X.jsx)(`label`,{className:`field-label`,children:`App ID`}),(0,X.jsx)(`input`,{className:`picker-search`,value:P,placeholder:`e.g. 123456`,onChange:e=>F(e.target.value)}),(0,X.jsx)(`label`,{className:`field-label`,children:`Private key (.pem)`}),(0,X.jsx)(`input`,{className:`ce-file`,type:`file`,accept:`.pem,application/x-pem-file,text/plain`,onChange:ft}),(0,X.jsx)(`textarea`,{className:`picker-search ce-pem`,value:ue,rows:3,placeholder:`…or paste the PEM here`,onChange:e=>de(e.target.value)}),!e.connection.currentNodeId&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`label`,{className:`field-label`,children:`Installation ID (only needed for apps installed on multiple accounts)`}),(0,X.jsx)(`input`,{className:`picker-search`,value:fe,placeholder:`auto-selected when there is one`,onChange:e=>pe(e.target.value)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!P.trim()||!ue.trim()||Q===`completing`||me,onClick:()=>void lt(),children:Q===`completing`||me?`Connecting…`:e.connection.currentNodeId?`Connect app to this machine`:`Connect app for isolated runs`}),he&&(0,X.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:he}),ge&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`App connected.`}),` This machine now holds the key and can claim GitHub work.`]}),L&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`Hosted App ready.`}),` Set its webhook URL to `,(0,X.jsx)(`code`,{children:L.webhookUrl}),` and secret to `,(0,X.jsx)(`code`,{children:L.webhookSecret}),`.`]})]}),Q===`completing`&&(0,X.jsx)(`p`,{className:`settings-hint`,children:`Finishing on the machine…`}),Q===`done`&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`App ready.`}),` Install it on a repository so it can receive issues.`,` `,(0,X.jsx)(`a`,{href:Ze?.installUrl||`https://github.com/settings/installations`,target:`_blank`,rel:`noreferrer`,children:`Install on GitHub →`})]}),Q===`error`&&(0,X.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:Ze?.error||`GitHub App setup failed.`})]}):(0,X.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[nt.map(t=>(0,X.jsx)(`div`,{className:`wq-app-row`,children:(0,X.jsxs)(`div`,{className:`wq-app-row-main`,children:[(0,X.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,X.jsx)(`strong`,{children:t.name||t.mention||`GitHub App`}),(0,X.jsx)(w,{tone:t.installed?`ok`:`warn`,children:t.installed?`Connected`:t.installed===!1?`Needs install`:`Installation not verified`})]}),t.owner&&(0,X.jsxs)(`span`,{className:`settings-hint`,children:[t.ownerType===`Organization`?`org`:`personal`,` · `,t.owner]}),(0,X.jsxs)(`span`,{className:`settings-hint`,children:[(0,X.jsx)(`strong`,{children:`Mention trigger:`}),` `,t.mention?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`code`,{children:[`@`,t.mention]}),` followed by your instructions`]}):`Handle not available yet — refresh app status.`]}),t.central?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`span`,{className:`settings-hint`,children:[`Hosted Bivy App · `,(t.installations??[]).map(e=>e.githubAccount).filter(Boolean).join(`, `)||`installed`]}),(t.installations??[]).map(e=>(0,X.jsxs)(`a`,{className:`btn sm`,href:Y(e),target:`_blank`,rel:`noreferrer`,children:[`Configure / uninstall · `,e.githubAccount||e.installationId,` ↗`]},e.installationId)),(0,X.jsx)(`span`,{className:`settings-hint`,children:`Change repository access or uninstall on GitHub. Uninstalling stops events for that installation.`}),(0,X.jsx)(`button`,{type:`button`,className:`btn link`,disabled:K,onClick:()=>void st(),children:K?`Opening GitHub…`:`Add another account or organization →`})]}):t.installed===!1?(0,X.jsxs)(`p`,{className:`schedule-hint warn`,children:[`Not installed on any repo yet.`,` `,(0,X.jsx)(`a`,{href:je(t),target:`_blank`,rel:`noreferrer`,children:`Install it now →`})]}):(0,X.jsxs)(`span`,{className:`settings-hint`,children:[`Installed on `,t.installCount??`some`,` `,t.installCount===1?`repo`:`repos`,`.`,` `,(0,X.jsx)(`a`,{href:je(t),target:`_blank`,rel:`noreferrer`,children:`Manage →`})]}),t.central?(0,X.jsx)(`span`,{className:`settings-hint`,children:`Repository access is connected. Runs separately need an online machine or a ready isolated profile.`}):at?(0,X.jsx)(`span`,{className:`settings-hint`,children:`An isolated machine profile is ready to run automations.`}):t.hosted?(0,X.jsx)(`span`,{className:`settings-hint`,children:`Hosted custom app connected; configure an isolated machine profile to run automations.`}):t.servedBy===null?(0,X.jsxs)(`p`,{className:`schedule-hint warn`,children:[`No online machine holds this app's key — queue items won't be claimed.`,` `]}):t.servedBy&&(0,X.jsxs)(`span`,{className:`settings-hint`,children:[`Served by `,(0,X.jsx)(`strong`,{children:t.servedBy.name||t.servedBy.id}),t.servedBy.online?``:` (offline)`,`.`]}),!t.central&&e.connection.currentNodeId&&(0,X.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,X.jsxs)(`div`,{className:`row-actions`,style:{marginTop:6},children:[e.connection.currentNodeId&&(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>dt(t),children:`Connect key on this machine`}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:ye!==null,onClick:()=>void ut(t),children:ye===Ae(t)?`Disconnecting…`:`Disconnect`})]})]})},Ae(t))),(xe||Ce)&&(0,X.jsx)(`p`,{className:`settings-error`,children:xe||Ce}),(0,X.jsxs)(`div`,{className:`settings-field`,style:{marginTop:4},children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`wq-default-node`,children:`Default machine for untagged work`}),(0,X.jsxs)(`select`,{id:`wq-default-node`,className:`picker-search`,value:D,onChange:e=>O(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Shared queue (any online machine)`}),h.map(e=>(0,X.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,X.jsxs)(`div`,{className:`row-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,disabled:k,onClick:()=>void ct(),children:k?`Saving…`:`Save`}),j&&(0,X.jsx)(`span`,{className:`settings-hint`,children:j})]})]}),(0,X.jsx)(ke,{info:s,onChanged:()=>{$(),r?.()}}),H?(0,X.jsxs)(`div`,{ref:W,className:`card wq-status-card`,"data-tone":`muted`,style:{marginTop:4},children:[(0,X.jsx)(`div`,{className:`autom-field-label`,children:ve?`Reconnect ${ve.name||ve.mention||`GitHub App`}`:`Add another app`}),ve?(0,X.jsxs)(`p`,{className:`settings-hint`,children:[`Choose the private key for App ID `,P,` to connect it to this machine.`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`settings-hint`,children:`One app per personal account or organization you want Bivy to cover.`}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`wq-org-2`,children:`Organization (optional)`}),(0,X.jsx)(`input`,{id:`wq-org-2`,className:`picker-search`,value:se,placeholder:`leave blank for your personal account`,disabled:Q===`starting`||Q===`submitting`||Q===`completing`,onChange:e=>T(e.target.value)}),Qe?(0,X.jsxs)(`form`,{method:`post`,action:Ze.action,onSubmit:Z,children:[(0,X.jsx)(`input`,{type:`hidden`,name:`manifest`,value:JSON.stringify(Ze.manifest)}),(0,X.jsx)(`button`,{className:`btn primary block`,type:`submit`,children:`Continue to GitHub →`})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:Q===`starting`||Q===`completing`||!i,onClick:()=>x.githubAppManifestStart(se.trim()||void 0),children:Q===`starting`?`Preparing…`:Q===`completing`?`Finishing…`:`Create GitHub App`}),(0,X.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>dt(),children:`Connect an existing app instead →`})]}),N&&(0,X.jsxs)(`div`,{className:`ce-form`,children:[(0,X.jsx)(`label`,{className:`field-label`,children:`App ID`}),(0,X.jsx)(`input`,{className:`picker-search`,value:P,placeholder:`e.g. 123456`,onChange:e=>F(e.target.value)}),(0,X.jsx)(`label`,{className:`field-label`,children:`Private key (.pem)`}),(0,X.jsx)(`input`,{className:`ce-file`,type:`file`,accept:`.pem,application/x-pem-file,text/plain`,onChange:ft}),(0,X.jsx)(`textarea`,{className:`picker-search ce-pem`,value:ue,rows:3,placeholder:`…or paste the PEM here`,onChange:e=>de(e.target.value)}),!e.connection.currentNodeId&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`label`,{className:`field-label`,children:`Installation ID (only needed for apps installed on multiple accounts)`}),(0,X.jsx)(`input`,{className:`picker-search`,value:fe,placeholder:`auto-selected when there is one`,onChange:e=>pe(e.target.value)})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:!P.trim()||!ue.trim()||Q===`completing`||me,onClick:()=>void lt(),children:Q===`completing`||me?`Connecting…`:e.connection.currentNodeId?`Connect app to this machine`:`Connect app for isolated runs`}),he&&(0,X.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,role:`alert`,children:he}),ge&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`App connected.`}),` This machine now holds the key and can claim GitHub work.`]}),L&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`Hosted App ready.`}),` Set its webhook URL to `,(0,X.jsx)(`code`,{children:L.webhookUrl}),` and secret to `,(0,X.jsx)(`code`,{children:L.webhookSecret}),`.`]})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn link`,onClick:()=>{U(!1),B(null)},children:`Cancel`})]}):(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>{U(!0),le(!1),B(null)},children:`+ Connect another custom GitHub App`}),ot&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`App installed.`}),` Configure and enable an automation to choose its labels, mention events, and instructions.`]})]})]}),et&&(0,X.jsxs)(`div`,{className:`autom-field-block`,children:[(0,X.jsxs)(`div`,{className:`autom-field-label`,children:[(0,X.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Ie,{})}),`Linear`]}),(0,X.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[Pe&&(0,X.jsx)(`p`,{className:`settings-error`,children:Pe}),ze&&y?.enabled&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`Linear is live.`}),` Label an issue `,(0,X.jsx)(`code`,{children:`bivy`}),` (or `,(0,X.jsx)(`code`,{children:`bivy/<machine>`}),`) to enqueue it.`]}),y?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,X.jsx)(`strong`,{children:y.enabled?`Connected`:`Finish connecting`}),(0,X.jsx)(w,{tone:y.enabled?`ok`:`warn`,children:y.enabled?`Live`:`Needs secret`})]}),(0,X.jsxs)(`p`,{className:`settings-hint`,children:[`In `,(0,X.jsx)(`strong`,{children:`Linear → Settings → API → Webhooks`}),`, create an `,(0,X.jsx)(`strong`,{children:`Issue`}),` webhook with this URL:`]}),(0,X.jsxs)(`div`,{className:`reveal-row`,children:[(0,X.jsx)(`code`,{className:`reveal-value`,children:y.endpoint}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void navigator.clipboard?.writeText(y.endpoint),children:`Copy`})]}),(0,X.jsxs)(`ol`,{className:`wq-how-list`,style:{paddingLeft:18},children:[(0,X.jsx)(`li`,{children:`Copy the signing secret Linear generates.`}),(0,X.jsxs)(`li`,{children:[`Paste it below`,y.enabled?` to rotate`:` to finish`,`.`]}),(0,X.jsxs)(`li`,{children:[`Create labels `,(0,X.jsx)(`code`,{children:`bivy`}),` and optionally use the compatibility label `,(0,X.jsx)(`code`,{children:`bivy/node-name`}),` to choose a machine.`]})]}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`lin-secret`,children:y.enabled?`Replace signing secret`:`Linear signing secret`}),(0,X.jsx)(`input`,{id:`lin-secret`,className:`picker-search`,type:`password`,autoComplete:`off`,value:Te,disabled:J,placeholder:`Signing secret from Linear`,onChange:e=>Ee(e.target.value)}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`lin-route-2`,children:`Default machine (optional)`}),(0,X.jsxs)(`select`,{id:`lin-route-2`,className:`picker-search`,value:q,disabled:J,onChange:e=>De(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Shared queue`}),h.map(e=>(0,X.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:J||Te.trim().length<16,onClick:()=>void mt(),children:J?`Saving…`:y.enabled?`Update connection`:`Connect Linear`}),(0,X.jsxs)(`p`,{className:`settings-hint`,children:[`Each trusted workstation also needs `,(0,X.jsx)(`code`,{children:`BIVY_LINEAR_API_KEY`}),` and a default `,(0,X.jsx)(`code`,{children:`BIVY_LINEAR_REPO=owner/repo`}),`.`]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:J,onClick:()=>void ht(),children:`Disconnect Linear`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`settings-hint`,children:`Create a Bivy webhook URL, paste it into Linear, then bring Linear's signing secret back here.`}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`lin-route`,children:`Default machine (optional)`}),(0,X.jsxs)(`select`,{id:`lin-route`,className:`picker-search`,value:q,disabled:J,onChange:e=>De(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Shared queue`}),h.map(e=>(0,X.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:J||!i,onClick:()=>void pt(),children:J?`Creating…`:`Create webhook URL`})]})]})]}),tt&&(0,X.jsxs)(`div`,{className:`autom-field-block`,children:[(0,X.jsxs)(`div`,{className:`autom-field-label`,children:[(0,X.jsx)(`span`,{className:`wq-section-icon`,"aria-hidden":`true`,children:(0,X.jsx)(Le,{})}),`Slack`]}),(0,X.jsxs)(`div`,{className:`card wq-status-card`,"data-tone":`muted`,children:[qe&&(0,X.jsx)(`p`,{className:`settings-error`,children:qe}),Ye&&S?.enabled&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`ok`,role:`status`,children:[(0,X.jsx)(`strong`,{children:`Slack is live.`}),` Paste the Request URL into your slash command, then try`,` `,(0,X.jsx)(`code`,{children:`/bivy fix the failing tests`}),`.`]}),S?.enabled?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`wq-app-title-row`,children:[(0,X.jsx)(`strong`,{children:`Connected`}),(0,X.jsx)(w,{tone:`ok`,children:`Live`})]}),(0,X.jsx)(`p`,{className:`settings-hint`,children:`Use this as your Slack app's slash-command Request URL:`}),(0,X.jsxs)(`div`,{className:`reveal-row`,children:[(0,X.jsx)(`code`,{className:`reveal-value`,children:S.endpoint}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:()=>void navigator.clipboard?.writeText(S.endpoint),children:`Copy`})]}),(0,X.jsx)(`div`,{className:`autom-field-label`,style:{marginTop:4},children:`Commands`}),(0,X.jsx)(`code`,{className:`wq-cmd`,children:`/bivy fix the failing tests`}),(0,X.jsx)(`code`,{className:`wq-cmd`,children:`/bivy on macbook fix the failing tests`}),(0,X.jsx)(`code`,{className:`wq-cmd`,children:`/bivy in owner/repo fix the failing tests`}),(0,X.jsxs)(`p`,{className:`settings-hint`,children:[`Add `,(0,X.jsx)(`code`,{children:`in owner/repo`}),` for an isolated checkout + PR. Add `,(0,X.jsx)(`code`,{children:`on machine-name`}),` to choose a machine.`]}),(0,X.jsx)(`button`,{type:`button`,className:`btn sm danger-ghost`,disabled:Ge,onClick:()=>void _t(),children:`Disconnect Slack`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`ol`,{className:`wq-how-list`,style:{paddingLeft:18},children:[(0,X.jsxs)(`li`,{children:[`Create a Slack app, then open `,(0,X.jsx)(`strong`,{children:`Basic Information`}),`.`]}),(0,X.jsxs)(`li`,{children:[`Copy its `,(0,X.jsx)(`strong`,{children:`Signing Secret`}),` below.`]}),(0,X.jsxs)(`li`,{children:[`After connecting, create a slash command named `,(0,X.jsx)(`code`,{children:`/bivy`}),` and paste the Request URL shown here.`]})]}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`slack-secret`,children:`Slack signing secret`}),(0,X.jsx)(`input`,{id:`slack-secret`,className:`picker-search`,type:`password`,autoComplete:`off`,value:Ve,disabled:Ge,placeholder:`Signing Secret`,onChange:e=>He(e.target.value)}),(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`slack-route`,children:`Default machine (optional)`}),(0,X.jsxs)(`select`,{id:`slack-route`,className:`picker-search`,value:Ue,disabled:Ge,onChange:e=>We(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Shared queue`}),h.map(e=>(0,X.jsx)(`option`,{value:String(e.name||e.id),children:String(e.name||e.id)},e.id))]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:Ge||Ve.trim().length<16||!i,onClick:()=>void gt(),children:Ge?`Connecting…`:`Connect Slack`})]})]})]})]}),(0,X.jsxs)(`div`,{className:`wizard-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn ghost`,"aria-label":`Refresh source status`,disabled:p,onClick:()=>{$(),a.current?.()},children:`Refresh`}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,onClick:o,children:yt})]})]})})}function Fe(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.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 Ie(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,X.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,X.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 Le(){return(0,X.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.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 Re(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 ze(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 Be({mode:e,header:t,secret:n,existing:r,onMode:i,onHeader:a,onSecret:o}){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-mode`,children:`Authentication method`}),(0,X.jsxs)(`select`,{id:`webhook-auth-mode`,className:`picker-search`,value:e,onChange:e=>i(e.target.value),children:[(0,X.jsx)(`option`,{value:`hmac`,children:`HMAC-SHA256 signature (recommended)`}),(0,X.jsx)(`option`,{value:`header`,children:`Static secret header`})]}),(0,X.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,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-header`,children:`Header name`}),(0,X.jsx)(`input`,{id:`webhook-auth-header`,className:`picker-search`,value:t,maxLength:128,spellCheck:!1,onChange:e=>a(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`webhook-auth-secret`,children:e===`hmac`?`Custom signing secret (optional)`:`Custom header value (optional)`}),(0,X.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,X.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 Ve({value:e,error:t,onChange:n}){let r=(0,V.useId)(),i=(t,r)=>n({...e,[t]:r});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`label`,{className:`settings-toggle-row webhook-signing-toggle`,children:[(0,X.jsxs)(`span`,{className:`settings-toggle-text`,children:[(0,X.jsx)(`strong`,{className:`settings-toggle-title`,children:`Filter deliveries with a script`}),(0,X.jsx)(`small`,{className:`muted`,children:`Run a script on the machine first. It decides whether each delivery starts the agent.`})]}),(0,X.jsx)(`input`,{className:`sr-only`,type:`checkbox`,checked:e.enabled,onChange:e=>i(`enabled`,e.target.checked)}),(0,X.jsx)(`span`,{className:`settings-toggle${e.enabled?` on`:``}`,"aria-hidden":`true`,children:(0,X.jsx)(`span`,{className:`settings-toggle-knob`})})]}),e.enabled&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-command`,children:`Command`}),(0,X.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,X.jsxs)(`p`,{className:`settings-hint`,children:[`Runs directly, without a shell. Quote arguments that contain spaces. The script receives `,(0,X.jsx)(`code`,{children:`{"event":{"payload":…}}`}),` on stdin and must print `,(0,X.jsx)(`code`,{children:`{"decision":"accept"}`}),` or `,(0,X.jsx)(`code`,{children:`{"decision":"skip","reason":"…"}`}),`.`]})]}),(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-cwd`,children:`Directory on the machine`}),(0,X.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,X.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,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:`${r}-timeout`,children:`Timeout (seconds)`}),(0,X.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,X.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,X.jsx)(`p`,{className:`schedule-hint warn`,children:t})]})]})}function He(e){return e?{enabled:!0,command:Ge(e.command),cwd:e.cwd,timeoutSeconds:String(e.timeoutSeconds)}:{enabled:!1,command:``,cwd:``,timeoutSeconds:`5`}}function Ue(e){if(!e.enabled)return{};let t=We(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:ye({command:t,cwd:n,timeoutSeconds:r})}}catch(e){return{error:String(e.message||e)}}}function We(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 Ge(e){return e.map(e=>e&&!/[\s'"]/.test(e)?e:`'${e.replaceAll(`'`,`'"'"'`)}'`).join(` `)}function Ke({value:e,onChange:t,github:n}){let r=(0,V.useId)();return(0,X.jsxs)(`div`,{className:`settings-field`,children:[(0,X.jsx)(`label`,{className:`field-label`,htmlFor:r,children:`Limit to these repositories (optional)`}),(0,X.jsx)(`input`,{id:r,className:`picker-search`,value:e,onChange:e=>t(e.target.value),placeholder:`acme/website, acme/api`}),(0,X.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 qe=new Set([`succeeded`,`failed`,`cancelled`,`done`]);function Je(e){return qe.has(e.status)}function Ye(e){let t=T(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,c=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,l=[];return s?.sessionId&&l.push(`open_session`),s?.prUrl?l.push(`view_pull_request`):s?.artifactUrl&&l.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:c,availableActions:l}}var Xe=5;function Ze(e){let t=f(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 Q(e){return e===`github:comment`?`GitHub @-mention`:e===`github:issue`?`GitHub labelled issue`:e===`linear:issue`?`Linear issue`:e}function Qe({queue:e,onRefresh:t,onPick:n,onOpenRun:r,onOpenGithubSettings:i,showHistory:a=!0}){let{sessionIndex:{sessions:s},activeSession:{activeSessionId:c},presentation:{prRefreshAllResult:l},catalogs:{runtimes:u}}=ie(),d=o,p=!x.direct,h=(0,V.useMemo)(()=>[{id:``,label:`Machine default`},...u.map(e=>({id:e.id,label:String(e.displayName||e.name||e.id)}))],[u]),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)([]),[b,S]=(0,V.useState)(null),[C,ee]=(0,V.useState)(`shared`),[te,ne]=(0,V.useState)(``),[re,ae]=(0,V.useState)(``),[oe,se]=(0,V.useState)(!1),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[A,j]=(0,V.useState)(!1),[M,N]=(0,V.useState)(null),[le,P]=(0,V.useState)(!1),[F,R]=(0,V.useState)(null),[he,z]=(0,V.useState)(null),[ge,_e]=(0,V.useState)(!1);(0,V.useEffect)(()=>{ge&&_e(!1)},[l]),(0,V.useEffect)(()=>{if(!l)return;let e=setTimeout(()=>x.store.clearPrRefreshAllResult(),8e3);return()=>clearTimeout(e)},[l]);let ve=async()=>{let e=F;if(e){R(null),N(null),z(e.id);try{await x.cancelAutomationRun(e.id),t()}catch(e){N(String(e?.message||e))}finally{z(null)}}},B=()=>{_e(!0),x.refreshAllPrStatus()},[H,U]=(0,V.useState)(!1),[W,ye]=(0,V.useState)(null),be=(0,V.useRef)(null);(0,V.useEffect)(()=>()=>{be.current&&clearTimeout(be.current)},[]);let xe=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 ce(JSON.stringify(t,null,2))&&(ye(e.id),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>ye(null),1800))};(0,V.useEffect)(()=>{x.listRuntimes()},[]),(0,V.useEffect)(()=>{p&&(x.fetchGithubApp().then(_).catch(()=>_(null)),x.listNodes().then(y).catch(()=>{}))},[p]);let G=(0,V.useMemo)(()=>v.filter(e=>!e.id.startsWith(`eph-`)),[v]),K=(e=>e.startsWith(`node:`)?{kind:`node`,node:e.slice(5)}:{kind:`shared`})(C),Se=K.kind===`node`?K.node:``,Ce=e=>{E(null),S(e.id);let t=e.label&&e.label.startsWith(`bivy/`)?e.label.slice(5):``;ee(t?`node:${t}`:`shared`),ne(e.runtimeId??``),ae(e.model??``)},we=async e=>{E(null),se(!0);try{await x.assignWorkItem(e,{node:K.kind===`node`?K.node:``,runtimeId:te,model:re}),S(null),t()}catch(e){E(String(e?.message||e))}finally{se(!1)}},Te=async e=>{O(e),N(null);try{await x.deleteWorkItem(e),b===e&&S(null),t()}catch(e){N(String(e?.message||e))}finally{O(null)}},Ee=async()=>{j(!0),N(null);try{await x.clearWorkQueue(),S(null),t()}catch(e){N(String(e?.message||e))}finally{j(!1)}},q=(0,V.useMemo)(()=>[...s].filter(e=>m(e.source)).sort((e,t)=>I(t.updatedAt)-I(e.updatedAt)),[s]),De=H?q:q.slice(0,Xe),J=q.length-De.length,Oe=(0,V.useMemo)(()=>{let e=new Set;for(let t of q){let n=f(t.source);n&&e.add(`${n.repo}#${n.issueNumber}`)}return e},[q]),Y=(0,V.useMemo)(()=>e&&e.filter(e=>!(e.status!==`pending`||e.repo&&e.issueNumber!=null&&Oe.has(`${e.repo}#${e.issueNumber}`))),[e,Oe]),ke=(0,V.useMemo)(()=>(e??[]).filter(e=>e.status!==`pending`&&!!e.events?.length).sort((e,t)=>I(t.startedAt??t.claimedAt??t.createdAt)-I(e.startedAt??e.claimedAt??e.createdAt)),[e]),Z=g?.apps??[],Ae=Z.filter(e=>e.servedBy===null);return(0,X.jsxs)(`div`,{className:`settings-form`,children:[p&&g&&Z.length===0&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`neutral`,children:[`Install the hosted Bivy GitHub App, or connect your own app.`,` `,(0,X.jsx)(`button`,{className:`btn link`,onClick:i,children:`Set up GitHub Apps →`})]}),p&&Ae.length>0&&(0,X.jsxs)(`div`,{className:`banner inline`,"data-tone":`warn`,children:[Ae.length===Z.length?`${Z.length===1?`Your GitHub App is`:`Your GitHub Apps are`} set up, but no online machine is running ${Z.length===1?`it`:`them`} — nothing will pick these up.`:`${Ae.length} of your ${Z.length} GitHub Apps (${Ae.map(e=>e.name||e.mention||e.appId).join(`, `)}) aren't running on any machine — work for those won't be picked up.`,` `,(0,X.jsx)(`button`,{className:`btn link`,onClick:i,children:Ae.length===1?`Connect it on a machine →`:`Connect them on a machine →`})]}),a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`queue-head`,children:[(0,X.jsx)(`h4`,{className:`settings-subhead`,children:`Sessions`}),(0,X.jsxs)(`div`,{className:`queue-head-actions`,children:[l&&!ge&&(0,X.jsx)(`span`,{className:`muted`,children:l.error?l.error:`Checked ${l.scanned}, updated ${l.changed}`}),(0,X.jsx)(`button`,{className:`btn link`,onClick:B,disabled:ge,title:`Reconcile every session's PR status against GitHub now`,children:ge?`Refreshing GitHub status…`:`Refresh GitHub status`})]})]}),q.length===0?(0,X.jsxs)(`p`,{className:`muted`,children:[`No GitHub-triggered sessions yet. Label an issue `,(0,X.jsx)(`code`,{children:`bivy`}),` or @-mention your app to see one here.`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`ul`,{className:`queue-session-list`,children:De.map(e=>{let t=Ze(e.source),r=ue(e),i=pe(e.source);return(0,X.jsx)(`li`,{className:`session-row`,children:(0,X.jsx)(`button`,{className:`session-item${e.sessionId===c?` active`:``}`,onClick:()=>n(e.sessionId,e.path,e.nodeId),children:(0,X.jsxs)(`span`,{className:`session-body`,children:[(0,X.jsxs)(`span`,{className:`session-title-row`,children:[(0,X.jsx)(L,{status:de(e),srLabel:`${i.label} · ${r}`}),(0,X.jsx)(`span`,{className:`session-name`,children:e.name}),(0,X.jsx)(me,{prs:e.prs}),fe(e.updatedAt)&&(0,X.jsx)(`span`,{className:`session-age`,title:r,children:fe(e.updatedAt)})]}),t&&(0,X.jsx)(`span`,{className:`session-meta`,children:t})]})})},e.sessionId)})}),q.length>Xe&&(0,X.jsx)(`button`,{className:`btn link`,onClick:()=>U(e=>!e),children:H?`Show less`:`Show more (${J})`})]})]}),p&&(a||!!Y?.length)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`queue-head`,children:[a?(0,X.jsxs)(`h4`,{className:`settings-subhead`,children:[`Waiting to be picked up`,Y&&Y.length>0&&(0,X.jsx)(`span`,{className:`queue-count`,children:Y.length})]}):(0,X.jsx)(`h2`,{className:`session-group-label`,children:`Waiting for a machine`}),(0,X.jsxs)(`div`,{className:`queue-head-actions`,children:[Y&&Y.length>0&&(0,X.jsx)(`button`,{className:a?`btn link danger`:`btn sm`,onClick:()=>P(!0),disabled:A,children:A?`Clearing…`:`Clear queue`}),a&&(0,X.jsx)(`button`,{className:`btn link`,onClick:t,children:`Refresh`})]})]}),le&&(0,X.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:()=>P(!1),onConfirm:()=>{P(!1),Ee()}}),M&&(0,X.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:M}),Y===null?(0,X.jsx)(`p`,{className:`muted`,children:`—`}):Y.length===0?(0,X.jsx)(`p`,{className:`muted`,children:`Nothing waiting right now.`}):(0,X.jsx)(`div`,{className:`queue-list`,children:Y.map(e=>{let t=b===e.id,n=e.title||`${e.repo??``}#${e.issueNumber??``}`,r=`${e.repo??``}${e.issueNumber?` #${e.issueNumber}`:``} · ${Q(e.source)}`;return(0,X.jsxs)(`div`,{className:`card queue-card${t?` open`:``}`,"data-tone":`muted`,children:[(0,X.jsxs)(`div`,{className:`queue-card-row`,children:[e.url?(0,X.jsxs)(`a`,{className:`queue-item-main link`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:n,children:[(0,X.jsxs)(`span`,{className:`queue-item-title`,children:[n,d&&e.ephemeral&&(0,X.jsx)(w,{title:`Dispatched to an ephemeral server`,children:`⚡ ephemeral`})]}),(0,X.jsx)(`span`,{className:`queue-item-meta`,children:r})]}):(0,X.jsxs)(`div`,{className:`queue-item-main`,title:n,children:[(0,X.jsxs)(`span`,{className:`queue-item-title`,children:[n,d&&e.ephemeral&&(0,X.jsx)(w,{title:`Dispatched to an ephemeral server`,children:`⚡ ephemeral`})]}),(0,X.jsx)(`span`,{className:`queue-item-meta`,children:r})]}),(0,X.jsxs)(`div`,{className:`queue-card-actions`,children:[(0,X.jsx)(`button`,{className:`queue-action-btn${t?` active`:``}`,onClick:()=>t?S(null):Ce(e),title:`Dispatch to a machine + agent`,children:t?`Cancel`:`Run…`}),(0,X.jsx)(`button`,{className:`queue-action-btn danger icon`,onClick:()=>Te(e.id),disabled:D===e.id,title:`Remove from queue`,"aria-label":`Remove from queue`,children:D===e.id?`…`:`×`})]})]}),t&&(0,X.jsxs)(`div`,{className:`queue-run`,children:[(0,X.jsxs)(`label`,{className:`queue-run-field`,children:[(0,X.jsx)(`span`,{children:`Machine`}),(0,X.jsxs)(`select`,{value:C,onChange:e=>ee(e.target.value),children:[(0,X.jsx)(`option`,{value:`shared`,children:`Shared queue (any online machine)`}),G.length>0&&(0,X.jsx)(`optgroup`,{label:`Persistent machines`,children:G.map(e=>(0,X.jsxs)(`option`,{value:`node:${e.name||e.id}`,children:[e.name||e.id,e.online?``:` (offline)`]},e.id))}),K.kind===`node`&&!G.some(e=>(e.name||e.id)===Se)&&(0,X.jsx)(`option`,{value:C,children:Se})]})]}),(0,X.jsxs)(`label`,{className:`queue-run-field`,children:[(0,X.jsx)(`span`,{children:`Agent`}),(0,X.jsx)(`select`,{value:te,onChange:e=>ne(e.target.value),children:h.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,X.jsxs)(`label`,{className:`queue-run-field`,children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`input`,{value:re,placeholder:`optional, e.g. claude-sonnet-5`,onChange:e=>ae(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`queue-run-actions`,children:[(0,X.jsx)(`button`,{className:`btn`,disabled:oe,onClick:()=>we(e.id),children:oe?`Dispatching…`:`Run`}),T&&(0,X.jsx)(w,{tone:`danger`,children:T})]})]})]},e.id)})})]}),a&&p&&ke.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`queue-head`,children:(0,X.jsx)(`h4`,{className:`settings-subhead`,children:`Run details`})}),F&&(0,X.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:()=>R(null),onConfirm:()=>void ve()}),(0,X.jsx)(`div`,{className:`evidence-list`,children:ke.map(e=>{let t=Ye(e),n=t.outcome.tone===`danger`?`danger`:t.outcome.tone===`success`?`ok`:t.outcome.tone===`warning`?`warn`:void 0;return(0,X.jsxs)(`details`,{className:`evidence-report`,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsxs)(`span`,{children:[e.repo,e.issueNumber?` #${e.issueNumber}`:``,` · `,Q(e.source)]}),(0,X.jsx)(w,{tone:n,children:t.outcome.label})]}),(0,X.jsxs)(`div`,{className:`evidence-meta`,children:[(0,X.jsxs)(`span`,{children:[`Trigger: `,e.triggerKind??e.source]}),t.attempt>1&&(0,X.jsxs)(`span`,{children:[`Attempt `,t.attempt]}),t.agent&&(0,X.jsxs)(`span`,{children:[`Agent: `,t.agent]}),t.checksSummary&&(0,X.jsxs)(`span`,{children:[`Checks: `,t.checksSummary]}),e.routingReason&&(0,X.jsxs)(`span`,{children:[`Routing: `,e.routingReason]}),e.sandbox&&(0,X.jsxs)(`span`,{children:[`Sandbox: `,e.sandbox]}),e.approvalMode&&(0,X.jsxs)(`span`,{children:[`Approval: `,e.approvalMode]}),e.output?.branch&&(0,X.jsxs)(`span`,{children:[`Branch: `,(0,X.jsx)(`code`,{children:e.output.branch})]}),e.output?.commit&&(0,X.jsxs)(`span`,{children:[`Commit: `,(0,X.jsx)(`code`,{children:e.output.commit.slice(0,12)})]}),e.output?.prUrl&&(0,X.jsx)(`a`,{href:e.output.prUrl,target:`_blank`,rel:`noreferrer`,children:`Pull request`}),e.output?.artifactUrl&&(0,X.jsx)(`a`,{href:e.output.artifactUrl,target:`_blank`,rel:`noreferrer`,children:`Artifact`})]}),t.failure&&(0,X.jsx)(`p`,{className:`muted`,children:t.failure}),(0,X.jsx)(`ol`,{className:`evidence-timeline`,children:e.events.map((e,t)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`time`,{children:new Date(e.at).toLocaleString()}),(0,X.jsx)(`span`,{children:e.summary}),e.attempt!==void 0&&(0,X.jsxs)(`small`,{children:[`Attempt `,e.attempt]})]},`${e.at}-${t}`))}),e.checks&&e.checks.length>0&&(0,X.jsx)(`ul`,{className:`evidence-checks`,children:e.checks.map((e,t)=>(0,X.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,X.jsxs)(`div`,{className:`row-actions`,children:[r&&(0,X.jsx)(`button`,{className:`btn link`,onClick:()=>r(e.id),children:`Open Run details`}),!Je(e)&&(0,X.jsx)(`button`,{className:`btn link danger`,disabled:he===e.id,onClick:()=>{N(null),R(e)},children:he===e.id?`Cancelling…`:`Cancel Run`}),(0,X.jsx)(`button`,{className:`btn link`,onClick:()=>void xe(e),children:W===e.id?`Copied!`:`Copy sanitized Run JSON`})]})]},e.id)})})]}),!p&&(0,X.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 $e=[{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`}],et=[{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.`}],tt=[{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.`}],$={baseMs:2e3,factor:2,capMs:6e4,jitter:.3};function nt(){return{version:1,name:``,appliesTo:[`queue`],rules:[{when:[`transport_error`,`node_offline`],action:`retry`,maxAttempts:3,backoff:{...$}}]}}function rt(e){let t=e.appliesTo.map(e=>tt.find(t=>t.id===e)?.label??e).join(` + `);return`${e.rules.length} rule${e.rules.length===1?``:`s`} · ${t||`no contexts`}`}function it(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 at({state:e}){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null);(0,V.useEffect)(()=>{x.listRulesets()},[]);let p=()=>{u(null),o(!1),i(!0),n(nt())},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,X.jsx)(ot,{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(it)};await x.saveRuleset(e,a),x.listRulesets(),h()}catch(e){u(String(e?.message||e))}finally{c(!1)}}}):(0,X.jsxs)(`div`,{className:`settings-form`,children:[d&&(0,X.jsx)(k,{title:d.title,message:d.message,confirmLabel:`Remove`,danger:!0,onCancel:()=>f(null),onConfirm:()=>{d.action(),f(null)}}),(0,X.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,X.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,X.jsxs)(`div`,{className:`picker-list`,children:[e.settings.rulesets.length===0&&(0,X.jsx)(`div`,{className:`picker-empty`,children:`No rulesets yet.`}),e.settings.rulesets.map(e=>(0,X.jsx)(P,{title:e.name,meta:rt(e),right:(0,X.jsxs)(`span`,{className:`row-actions`,children:[e.active&&(0,X.jsx)(w,{tone:`ok`,children:`Active`}),(0,X.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:()=>{x.removeRuleset(e.name),setTimeout(()=>x.listRulesets(),400)}})},children:`Remove`})]}),onClick:()=>m(e)},e.name))]}),(0,X.jsx)(`button`,{className:`btn primary block`,onClick:p,children:`+ New ruleset`})]})}function ot({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,X.jsxs)(`div`,{className:`settings-form`,children:[(0,X.jsx)(`button`,{className:`btn link`,onClick:s,children:`‹ All rulesets`}),(0,X.jsx)(`h3`,{children:n?`New ruleset`:e.name}),(0,X.jsx)(`label`,{className:`field-label`,children:`Name`}),(0,X.jsx)(`input`,{className:`picker-search`,value:e.name,placeholder:`my-fallback-policy`,disabled:!n,onChange:e=>l({name:e.target.value})}),!n&&(0,X.jsx)(`p`,{className:`muted small`,children:`The name is the identifier and can't be changed — create a new ruleset to rename.`}),(0,X.jsx)(`label`,{className:`field-label`,style:{marginTop:8},children:`Applies to`}),(0,X.jsx)(`div`,{className:`seg-row`,children:tt.map(t=>(0,X.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,X.jsxs)(`div`,{className:`settings-toggle-row`,style:{marginTop:8},children:[(0,X.jsxs)(`div`,{className:`settings-toggle-text`,children:[(0,X.jsx)(`span`,{className:`settings-toggle-title`,children:`Active on this machine`}),(0,X.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,X.jsx)(dt,{checked:r&&m,disabled:!m,onChange:i,label:`Active on this machine`})]}),(0,X.jsx)(`label`,{className:`field-label`,style:{marginTop:8},children:`Rules`}),(0,X.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,X.jsx)(st,{index:n,rule:t,onChange:e=>u(n,e),onRemove:()=>l({rules:e.rules.filter((e,t)=>t!==n)})},n)),(0,X.jsx)(`button`,{className:`btn block`,onClick:()=>l({rules:[...e.rules,{when:[],action:`retry`,maxAttempts:3,backoff:{...$}}]}),children:`+ Add rule`}),(0,X.jsxs)(`div`,{className:`row-actions`,style:{marginTop:12},children:[(0,X.jsx)(`button`,{className:`btn primary`,disabled:!_,onClick:c,children:a?`Saving…`:n?`Create ruleset`:`Save changes`}),(0,X.jsx)(`button`,{className:`btn`,onClick:s,children:`Cancel`})]}),o&&(0,X.jsx)(`div`,{className:`banner inline`,"data-tone":`danger`,children:o})]})}function st({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??$,...e}}),s=t.action===`retry`||t.action===`reroute`;return(0,X.jsxs)(`div`,{className:`card ruleset-rule-card`,"data-tone":`muted`,children:[(0,X.jsxs)(`div`,{className:`ruleset-rule-head`,children:[(0,X.jsxs)(`span`,{className:`settings-toggle-title`,children:[`Rule `,e+1]}),(0,X.jsx)(`button`,{className:`btn danger-ghost sm`,onClick:r,children:`Remove`})]}),(0,X.jsx)(`label`,{className:`field-label`,children:`When any of`}),(0,X.jsx)(`div`,{className:`ruleset-choice-row`,children:$e.map(e=>(0,X.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,X.jsx)(`p`,{className:`muted small`,children:`Pick at least one condition.`}),(0,X.jsx)(`label`,{className:`field-label`,children:`Then`}),(0,X.jsx)(`div`,{className:`seg-row`,children:et.map(e=>(0,X.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,X.jsx)(`p`,{className:`muted small`,children:et.find(e=>e.id===t.action)?.hint}),(0,X.jsxs)(`div`,{className:`ruleset-field-grid`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`field-label`,children:`Max attempts`}),(0,X.jsx)(`input`,{className:`picker-search`,type:`number`,min:1,max:100,value:t.maxAttempts,onChange:e=>i({maxAttempts:lt(e.target.value,1,100,t.maxAttempts)})})]}),s&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`field-label`,children:`When exhausted`}),(0,X.jsxs)(`select`,{className:`picker-search`,value:t.onExhausted??`park`,onChange:e=>i({onExhausted:e.target.value}),children:[(0,X.jsx)(`option`,{value:`park`,children:`Park for a human`}),(0,X.jsx)(`option`,{value:`give_up`,children:`Give up (fail the run)`})]})]})]}),t.action===`reroute`&&(0,X.jsx)(ct,{chain:t.chain??[],onChange:e=>i({chain:e})}),s&&(0,X.jsx)(ft,{label:`Backoff (advanced)`,children:(0,X.jsxs)(`div`,{className:`ruleset-field-grid`,children:[(0,X.jsx)(ut,{label:`Base (ms)`,value:t.backoff?.baseMs??$.baseMs,min:0,onChange:e=>o({baseMs:e})}),(0,X.jsx)(ut,{label:`Factor`,value:t.backoff?.factor??$.factor,min:1,step:.1,onChange:e=>o({factor:e})}),(0,X.jsx)(ut,{label:`Cap (ms)`,value:t.backoff?.capMs??$.capMs,min:0,onChange:e=>o({capMs:e})}),(0,X.jsx)(ut,{label:`Jitter (0–1)`,value:t.backoff?.jitter??$.jitter,min:0,max:1,step:.05,onChange:e=>o({jitter:e})})]})})]})}function ct({chain:e,onChange:t}){let n=(n,r)=>t(e.map((e,t)=>t===n?{...e,...r}:e));return(0,X.jsxs)(`div`,{className:`ruleset-chain`,children:[(0,X.jsx)(`label`,{className:`field-label`,children:`Fallback chain`}),(0,X.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,X.jsxs)(`div`,{className:`ruleset-chain-row`,children:[(0,X.jsxs)(`div`,{className:`ruleset-chain-fields`,children:[(0,X.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`input`,{className:`picker-search`,placeholder:`e.g. claude-sonnet`,value:r.model??``,onChange:e=>n(i,{model:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,X.jsx)(`span`,{children:`Agent`}),(0,X.jsx)(`input`,{className:`picker-search`,placeholder:`e.g. codex`,value:r.runtimeId??``,onChange:e=>n(i,{runtimeId:e.target.value})})]}),(0,X.jsxs)(`label`,{className:`ruleset-chain-field`,children:[(0,X.jsx)(`span`,{children:`Account`}),(0,X.jsx)(`input`,{className:`picker-search`,placeholder:`Keep current`,value:r.account??``,onChange:e=>n(i,{account:e.target.value})})]})]}),(0,X.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,X.jsx)(`button`,{className:`btn sm`,onClick:()=>t([...e,{}]),children:`+ Add candidate`})]})}function lt(e,t,n,r){let i=Math.round(Number(e));return Number.isFinite(i)?Math.min(n,Math.max(t,i)):r}function ut({label:e,value:t,min:n,max:r,step:i,onChange:a}){return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`field-label`,children:e}),(0,X.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 dt({checked:e,onChange:t,disabled:n,label:r}){return(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,className:`settings-toggle${e?` on`:``}`,onClick:()=>t(!e),children:(0,X.jsx)(`span`,{className:`settings-toggle-knob`,"aria-hidden":!0})})}function ft({label:e,children:t}){let[n,r]=(0,V.useState)(!1);return(0,X.jsxs)(`div`,{className:`ruleset-collapsible`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn link`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[n?`▾`:`▸`,` `,e]}),n&&(0,X.jsx)(`div`,{className:`ruleset-collapsible-body`,children:t})]})}function pt({hosted:e,onConfigureCredentials:t}){let[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)([]),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{x.listNodes().then(r).catch(()=>{}),x.getQueueRouting().then(s).catch(()=>s(null)),x.listEphemeralConfigs().then(e=>a(e.filter(e=>e.computeSource===`managed`))).catch(()=>{})},[]);let f=n.filter(e=>!e.id.startsWith(`eph-`)),p=o?.primary.kind===`node`?`node:${o.primary.node}`:o?.primary.kind===`config`?`config:${o.primary.configId}`:`shared`,m=o?.fallback?.kind===`config`?`config:${o.fallback.configId}`:``,h=o?.primary.kind===`node`,g=async(e,t)=>{d(null),l(!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};s(await x.setQueueRouting(r))}catch(e){d(String(e?.message||e))}finally{l(!1)}},_=e=>e?i.find(t=>t.id===e):void 0,v=_(o?.primary.kind===`config`?o.primary.configId:void 0),y=_(o?.fallback?.configId),b=t=>!(!t||!e?.execution.ready||e.execution.configId&&e.execution.configId!==t.id),S=o?.primary.kind===`node`?o.primary.node:``,C=o?.primary.kind===`config`?b(v):o?.primary.kind===`node`?f.some(e=>(e.name||e.id)===S&&e.online)||b(y):f.some(e=>e.online);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`banner routing-status`,"data-tone":C?`ok`:`warn`,role:`status`,children:[(0,X.jsxs)(`div`,{className:`banner-text routing-status-copy`,children:[(0,X.jsx)(`strong`,{children:o===null?`Checking run readiness…`:C?`Ready for unattended runs`:`Setup needs attention`}),(0,X.jsx)(`span`,{children:o===null?`Loading machines, routing, and credential status.`:o.primary.kind===`config`?C?`Each run starts on ${v?.name||`the cloud`}; none of your machines need to be online.`:`Cloud runs need GitHub and model sign-ins that the cloud machine can use while you're away.`:o.primary.kind===`node`?f.some(e=>(e.name||e.id)===S&&e.online)?`Runs go to ${S}.`:C?`${S} is offline, so runs go to ${y?.name||`the cloud`} until it's back.`:`Runs wait until ${S} is online.`:C?`Runs go to whichever of your machines is online.`:`Runs wait until one of your machines is online.`})]}),o!==null&&!C&&t&&(0,X.jsx)(`button`,{type:`button`,className:`btn sm`,onClick:t,children:`Fix setup`})]}),(0,X.jsxs)(`label`,{className:`field-label`,children:[(0,X.jsx)(`span`,{children:`Runs on`}),(0,X.jsxs)(`select`,{className:`picker-search`,value:p,disabled:c,onChange:e=>g(e.target.value,m),children:[(0,X.jsx)(`option`,{value:`shared`,children:`Any of your online machines`}),f.length>0&&(0,X.jsx)(`optgroup`,{label:`Your machines`,children:f.map(e=>(0,X.jsx)(`option`,{value:`node:${e.name||e.id}`,children:e.name||e.id},e.id))}),i.map(e=>(0,X.jsx)(`option`,{value:`config:${e.id}`,children:e.name},e.id))]})]}),h&&i.length>0&&(0,X.jsxs)(`label`,{className:`field-label`,children:[(0,X.jsx)(`span`,{children:`If that machine is offline`}),(0,X.jsxs)(`select`,{className:`picker-search`,value:m,disabled:c,onChange:e=>g(p,e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:`Wait for the machine`}),i.map(e=>(0,X.jsxs)(`option`,{value:`config:${e.id}`,children:[`Run on `,e.name]},e.id))]})]}),u&&(0,X.jsx)(w,{tone:`danger`,children:u})]})}function mt({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,X.jsxs)(`details`,{className:`autom-sources-panel`,children:[(0,X.jsxs)(`summary`,{className:`autom-sources-summary`,children:[(0,X.jsxs)(`span`,{className:`autom-sources-summary-copy`,children:[(0,X.jsx)(`strong`,{children:`Sources`}),(0,X.jsx)(`span`,{children:r})]}),(0,X.jsx)(`span`,{className:`autom-sources-chevron`,children:(0,X.jsx)(A,{})})]}),(0,X.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,X.jsxs)(`button`,{type:`button`,className:`autom-source-row`,onClick:e.onClick,children:[(0,X.jsxs)(`span`,{className:`autom-source-row-copy`,children:[(0,X.jsx)(`strong`,{children:e.name}),(0,X.jsx)(`span`,{children:e.status.label})]}),(0,X.jsx)(`span`,{className:`autom-source-row-cta`,children:t}),(0,X.jsx)(A,{size:16})]},e.name)})})]})}function ht(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 gt(e,t={}){let n=ht(e,t).replace(/^Today/,`today`).replace(/^Tomorrow/,`tomorrow`);return`Next ${n.startsWith(`today`)?n:n.replace(/ at .+$/,``)}`}function _t(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}var vt=new Set([`pending`,`claimed`,`running`,`waiting`]),yt=new Set([`needs_attention`,`failed`]),bt=new Set([`schedule`,`manual`]),xt={success:`ok`,danger:`danger`,warning:`warn`},St=e=>Date.parse(e.createdAt)||0;function Ct(e,t,n=new Date){if(vt.has(e.status))return`In progress`;let r=yt.has(e.status)||!!e.attention,i=bt.has(e.triggerKind)&&t.some(t=>t.definitionId===e.definitionId&&St(t)>St(e));return r&&!i?`Needs attention`:R(e.createdAt,n)}var wt=[`Needs attention`,`In progress`,`Today`,`Yesterday`,`Previous 7 days`,`Older`];function Tt({runs:e,definitions:t,onOpenRun:n,onOpenSession:r,waiting:i,compact:a=!1}){let o=(0,V.useMemo)(()=>{let t=[...e].sort((e,t)=>St(t)-St(e));if(a)return[{label:``,runs:t}];let n=new Map;for(let e of t){let r=Ct(e,t);n.set(r,[...n.get(r)??[],e])}return wt.filter(e=>n.has(e)).map(e=>({label:e,runs:n.get(e)}))},[e,a]),s=+(o[0]?.label===`Needs attention`);return(0,X.jsxs)(`div`,{className:`run-history`,children:[e.length===0&&!i&&(0,X.jsx)(`p`,{className:`settings-hint autom-empty-hint`,children:a?`No runs yet. Run this automation now, or wait for its trigger.`:`No runs yet. Each time an automation fires, its run shows up here.`}),o.map((e,o)=>(0,X.jsxs)(V.Fragment,{children:[o===s&&i,(0,X.jsxs)(`section`,{"aria-label":e.label||`Runs`,children:[e.label&&(0,X.jsx)(`h2`,{className:`session-group-label`,children:e.label}),e.runs.map(i=>{let o=Ye(i),s=t.find(e=>e.id===i.definitionId)?.name,c=e.label===`Needs attention`,l=[!a&&s!==i.title?s:null,ht(i.createdAt)].filter(Boolean).join(` · `),u=se(i).sessionId,d=n?()=>n(i.id):u?()=>r(u):void 0;return(0,X.jsxs)(`button`,{type:`button`,className:`automation-history-row`,disabled:!d,onClick:d,children:[(0,X.jsxs)(`span`,{className:`automation-history-row-copy`,children:[(0,X.jsx)(`strong`,{children:i.title}),(0,X.jsx)(`span`,{className:`settings-hint`,children:l}),c&&o.failure&&(0,X.jsx)(`span`,{className:`settings-hint warn-text run-history-failure`,children:o.failure})]}),(0,X.jsx)(w,{tone:xt[o.outcome.tone],children:o.outcome.label}),d&&(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`›`})]},i.id)})]})]},e.label||`all`)),o.length<=s&&i]})}function Et(e){return e.trigger&&e.trigger!==`schedule`?!0:e.schedule.kind!==`once`}var Dt=[{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{At as e,i as t}from"./useStore-
|
|
1
|
+
import{At as e,i as t}from"./useStore-UrxvGCn8.js";import{M as n,j as r}from"./Sheet-C_l8Qiz6.js";import{t as i}from"./jsx-runtime-NZYk81nU.js";import{t as a}from"./StatusDot-dpbztK53.js";var o={shell:`Ran`,read:`Read`,write:`Created`,edit:`Edited`,search:`Searched`,fetch:`Fetched`,plan:`Planned`,delegation:`Delegated`,unknown:`Tool`};function s(e){return typeof e==`string`?e:e==null?``:String(e)}function c(e,t=120){let n=s(e);return n.length>t?n.slice(0,t-1)+`…`:n}function l(e,t=120){return c(s(e).replace(/\s+/g,` `).trim(),t)}function u(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 d(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 f(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 p(e){let t=String(e??``).replace(/\r\n/g,`
|
|
2
2
|
`);return t===``?[]:t.split(`
|
|
3
3
|
`)}function m(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 h=900;function g(e,t){let n=p(e),r=p(t);if(n.length>h||r.length>h){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=m(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 _(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 v(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 y(e,t){for(let n of t)if(e?.[n]!=null&&e[n]!==``)return s(e[n])}var b=[`oldText`,`oldString`,`old_string`,`old`,`before`],x=[`newText`,`newString`,`new_string`,`new`,`after`];function S(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=y(e,b)??``,i=y(e,x)??``;if(!n&&!i)continue;let{added:a,removed:o}=t?v(g(n,i)):{added:0,removed:0};r.push({oldText:n,newText:i,added:a,removed:o})}return r}function C(e,t,n,r={}){let i=r.diffStats!==!1,a=String(e||``).toLowerCase(),s=t&&typeof t==`object`?t:{},l=d(a),m=y(s,[`path`,`file`,`filePath`,`file_path`,`pathname`]),h=y(s,[`command`,`cmd`,`shell`]),_=c(y(s,[`query`,`q`,`pattern`,`search`]),120),b=y(s,[`output`,`stdout`,`stderr`,`message`,`delta`]),x=y(s,[`stream`]),C=l===`Agent output`,T=C?`Agent output`:h||a.includes(`bash`)||a.includes(`shell`)?`Bash`:l===`Tool`?String(e||`Tool`):d(a),E=[],D;if(n?n.kind===`write`:a.includes(`write`)){let e=y(s,[`content`,`text`,`contents`,`data`,`file_text`])??``;e&&(E=[{oldText:``,newText:e,added:i?p(e.replace(/\r?\n$/,``)).length:0,removed:0,label:`New file`}])}else if(a.includes(`edit`)){let e=S(s,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:l,glyph:f(l,!!h),title:T,path:m,target:m?u(m):void 0,command:h,query:_||void 0,output:b,stream:x,added:O,removed:k,diffs:E,edits:D};if(n&&!C){if(A.verb=o[n.kind]??A.verb,A.glyph=f(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=u(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?v(g(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=c(n.text,120))):n.kind===`delegation`&&(A.title=n.label?`Delegated → ${n.label}`:`Delegated`,n.label&&(A.target=n.label),n.description&&(A.query=c(n.description,120)))}return n?.result&&(w(n)&&(A.isError=!0),typeof n.result.exitCode==`number`&&(A.exitCode=n.result.exitCode),n.result.truncated&&(A.truncated=!0)),A}function w(e){return!!(e?.result?.isError||typeof e?.result?.exitCode==`number`&&e.result.exitCode!==0)}function T(e){return l(e.command||e.path||e.target||e.query||e.output,120)}function E(e){let t=new Set,n=new Set,r=0,i=0,a=0,o=0;for(let s of e){let e=C(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 D=e(),O=i();function k({size:e=`md`,tone:t=`accent`}){return(0,O.jsx)(`span`,{className:`spinner`,"data-size":e,"data-tone":t,"aria-hidden":!0})}var A=28;function j(){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 M(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 N(e){let t=Math.floor(e/1e3),n=Math.floor(t/60),r=t%60;return`${n}:${String(r).padStart(2,`0`)}`}function P({transcribe:e,onResult:t,onCancel:n,onError:i,stop:a=0}){let[o,s]=(0,D.useState)(0),[c,l]=(0,D.useState)(!1);r(()=>S());let u=(0,D.useRef)(null),d=(0,D.useRef)(null),f=(0,D.useRef)([]),p=(0,D.useRef)(null),m=(0,D.useRef)(null),h=(0,D.useRef)([]),g=(0,D.useRef)(!1),_=(0,D.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,D.useEffect)(()=>{let e=!1,t=navigator?.mediaDevices;if(!t?.getUserMedia||globalThis.MediaRecorder===void 0){i(`Voice input isn't supported in this browser.`),n();return}return t.getUserMedia({audio:!0}).then(t=>{if(e){t.getTracks().forEach(e=>e.stop());return}d.current=t;let n=j(),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.`),n()}),()=>{e=!0,g.current=!0;try{u.current&&u.current.state!==`inactive`&&u.current.stop()}catch{}v()}},[]),(0,D.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<A;e++){let t=h.current[e];if(!t)continue;let n=(i[Math.floor(e/A*i.length)]??0)/255;t.style.transform=`scaleY(${Math.max(.12,n)})`}m.current=requestAnimationFrame(a)};m.current=requestAnimationFrame(a)}catch{}}async function b(r,a){l(!0);try{if(!r.size)throw Error(`Nothing was recorded.`);let o=await e(await M(r),a);if(g.current)return;o?t(o):i(`No speech was detected.`),n()}catch(e){i(e instanceof Error?e.message:String(e)),n()}finally{l(!1)}}(0,D.useEffect)(()=>{a&&x()},[a]);function x(){if(c)return;let e=u.current;if(e&&e.state!==`inactive`)try{e.stop()}catch{n()}else S()}function S(){g.current=!0;try{u.current&&u.current.state!==`inactive`&&u.current.stop()}catch{}v(),n()}return(0,O.jsxs)(`div`,{className:`voice-bar`,role:`group`,"aria-label":`Voice recording`,children:[(0,O.jsx)(`button`,{type:`button`,className:`voice-btn cancel`,onClick:S,"aria-label":`Cancel recording`,children:`✕`}),(0,O.jsx)(`div`,{className:`voice-wave`,"aria-hidden":!0,children:Array.from({length:A},(e,t)=>(0,O.jsx)(`span`,{className:`voice-bar-tick`,ref:e=>{h.current[t]=e}},t))}),(0,O.jsx)(`span`,{className:`voice-time`,children:c?`…`:N(o)}),(0,O.jsx)(`button`,{type:`button`,className:`voice-btn confirm`,onClick:x,disabled:c,"aria-label":`Use recording`,children:c?(0,O.jsx)(k,{size:`sm`,tone:`inverse`}):`✓`})]})}function F(){return typeof window<`u`&&!!(window.SpeechRecognition||window.webkitSpeechRecognition)}function I({onResult:e,onCancel:t,onError:n,stop:r=0}){let[i,o]=(0,D.useState)(``),s=(0,D.useRef)(null),c=(0,D.useRef)(``),l=(0,D.useRef)(``),u=(0,D.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,D.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,D.useEffect)(()=>{if(r)try{s.current?.stop()}catch{d(!0)}},[r]),(0,O.jsxs)(`div`,{className:`voice-bar`,role:`group`,"aria-label":`Voice dictation`,children:[(0,O.jsx)(`button`,{type:`button`,className:`voice-btn cancel`,onClick:()=>d(!1),"aria-label":`Cancel dictation`,children:`✕`}),(0,O.jsxs)(`div`,{className:`voice-listening`,children:[(0,O.jsx)(a,{status:`working`}),(0,O.jsx)(`span`,{className:`voice-listening-text`,children:i||`Listening…`})]}),(0,O.jsx)(`button`,{type:`button`,className:`voice-btn confirm`,onClick:()=>{try{s.current?.stop()}catch{d(!0)}},"aria-label":`Use dictation`,children:`✓`})]})}function L(e){return!e||e.providers.some(e=>e.configured)?`server`:F()?`webspeech`:null}var R=`Add a Groq or OpenAI key in Settings → Voice input to use voice input.`;function z({engine:e,stop:n,onResult:r,onCancel:i,onError:a}){return e===`server`?(0,O.jsx)(P,{transcribe:(e,n)=>t.transcribe(e,n),stop:n,onResult:r,onCancel:i,onError:a}):(0,O.jsx)(I,{stop:n,onResult:r,onCancel:i,onError:a})}var B=n(),V={scale:1,x:0,y:0},H=8;function U({src:e,name:t,current:n=0,count:i=1,onNavigate:a,onClose:o}){let s=(0,D.useRef)(null),c=(0,D.useRef)(null),l=(0,D.useRef)(null),[u,d]=(0,D.useState)(V),f=(0,D.useRef)(V),[p,m]=(0,D.useState)(!1),[h,g]=(0,D.useState)(!1),_=(0,D.useRef)(new Map),v=(0,D.useRef)(null);r(o);let y=(0,D.useCallback)(e=>{let t=c.current,n=l.current;if(!t||!n)return;let r=Math.max(1,Math.min(H,e.scale)),i=Math.max(0,(n.clientWidth*r-t.clientWidth)/2),a=Math.max(0,(n.clientHeight*r-t.clientHeight)/2);f.current={scale:r,x:Math.max(-i,Math.min(i,e.x)),y:Math.max(-a,Math.min(a,e.y))},d(f.current)},[]),b=(0,D.useCallback)((e,t={x:0,y:0})=>{let n=f.current,r=Math.max(1,Math.min(H,e))/n.scale;y({scale:n.scale*r,x:t.x-(t.x-n.x)*r,y:t.y-(t.y-n.y)*r})},[y]);return(0,D.useEffect)(()=>{let e=s.current,t=document.activeElement;e.focus();let n=e=>e.stopPropagation(),r=e=>{e.preventDefault(),e.stopPropagation()},i=e=>{r(e);let t=c.current.getBoundingClientRect();if(e.ctrlKey||e.metaKey)b(f.current.scale*Math.exp(-e.deltaY*.01),{x:e.clientX-t.x-t.width/2,y:e.clientY-t.y-t.height/2});else{let n=e.deltaMode===1?16:e.deltaMode===2?t.height:1;y({...f.current,x:f.current.x-e.deltaX*n,y:f.current.y-e.deltaY*n})}};e.addEventListener(`wheel`,i,{passive:!1}),e.addEventListener(`touchmove`,r,{passive:!1});for(let t of[`touchstart`,`touchend`,`touchcancel`])e.addEventListener(t,n);e.addEventListener(`gesturestart`,r),e.addEventListener(`gesturechange`,r);let a=new ResizeObserver(()=>y(f.current));return a.observe(c.current),()=>{e.removeEventListener(`wheel`,i),e.removeEventListener(`touchmove`,r);for(let t of[`touchstart`,`touchend`,`touchcancel`])e.removeEventListener(t,n);e.removeEventListener(`gesturestart`,r),e.removeEventListener(`gesturechange`,r),a.disconnect(),t?.isConnected&&t.focus({preventScroll:!0})}},[y,b]),(0,B.createPortal)((0,O.jsxs)(`div`,{ref:s,className:`image-viewer`,role:`dialog`,"aria-modal":`true`,"aria-label":`${t} — Image ${n+1} of ${i}`,tabIndex:-1,onKeyDown:e=>{if(e.key===`Tab`){let t=[...s.current.querySelectorAll(`button:not(:disabled)`)],n=t.indexOf(document.activeElement);e.preventDefault(),t[n<0?e.shiftKey?t.length-1:0:(n+(e.shiftKey?-1:1)+t.length)%t.length]?.focus();return}[`+`,`=`,`-`,`0`,`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),e.key===`+`||e.key===`=`?b(f.current.scale*1.5):e.key===`-`?b(f.current.scale/1.5):e.key===`0`?y(V):f.current.scale>1?y({...f.current,x:f.current.x+(e.key===`ArrowLeft`?80:e.key===`ArrowRight`?-80:0),y:f.current.y+(e.key===`ArrowUp`?80:e.key===`ArrowDown`?-80:0)}):(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&a?.(e.key===`ArrowLeft`?-1:1))},children:[(0,O.jsxs)(`div`,{ref:c,className:`image-viewer-viewport`,"data-zoomed":u.scale>1,onDoubleClick:e=>{let t=e.currentTarget.getBoundingClientRect();b(f.current.scale>1?1:2,{x:e.clientX-t.x-t.width/2,y:e.clientY-t.y-t.height/2})},onPointerDown:e=>{if(e.button!==0)return;e.currentTarget.setPointerCapture(e.pointerId);let t={x:e.clientX,y:e.clientY};_.current.set(e.pointerId,t),v.current=_.current.size===1&&f.current.scale===1?t:null},onPointerMove:e=>{let t=_.current.get(e.pointerId);if(!t)return;let n={x:e.clientX,y:e.clientY},r=[..._.current.entries()].find(([t])=>t!==e.pointerId)?.[1];if(r){let i=Math.hypot(t.x-r.x,t.y-r.y),a=e.currentTarget.getBoundingClientRect(),o={x:(t.x+r.x)/2-a.x-a.width/2,y:(t.y+r.y)/2-a.y-a.height/2};i>0&&b(f.current.scale*Math.hypot(n.x-r.x,n.y-r.y)/i,o),y({...f.current,x:f.current.x+(n.x-t.x)/2,y:f.current.y+(n.y-t.y)/2})}else f.current.scale>1&&y({...f.current,x:f.current.x+n.x-t.x,y:f.current.y+n.y-t.y});_.current.set(e.pointerId,n)},onPointerUp:e=>{let t=v.current;if(_.current.delete(e.pointerId),v.current=null,!t||f.current.scale!==1)return;let n=e.clientX-t.x,r=e.clientY-t.y;Math.abs(n)>=48&&Math.abs(n)>Math.abs(r)&&a?.(n<0?1:-1)},onPointerCancel:()=>{_.current.clear(),v.current=null},onLostPointerCapture:e=>{_.current.delete(e.pointerId),v.current=null},children:[e&&!h&&(0,O.jsx)(`img`,{ref:l,className:`image-viewer-img`,src:e,alt:t,draggable:!1,onLoad:()=>m(!0),onError:()=>g(!0),style:{transform:`translate(${u.x}px, ${u.y}px) scale(${u.scale})`}}),h?(0,O.jsx)(`p`,{className:`image-viewer-message`,role:`alert`,children:`Unable to load image.`}):!p&&(0,O.jsx)(`span`,{role:`status`,"aria-label":`Loading image`,children:(0,O.jsx)(k,{size:`lg`,tone:`inverse`})})]}),(0,O.jsxs)(`div`,{className:`image-viewer-tools`,role:`group`,"aria-label":`Image zoom`,children:[(0,O.jsx)(`button`,{type:`button`,className:`btn icon`,"aria-label":`Zoom out`,disabled:!p||u.scale<=1,onClick:()=>b(u.scale/1.5),children:`−`}),(0,O.jsxs)(`button`,{type:`button`,className:`btn`,"aria-label":`Fit image`,disabled:!p,onClick:()=>y(V),children:[Math.round(u.scale*100),`%`]}),(0,O.jsx)(`button`,{type:`button`,className:`btn icon`,"aria-label":`Zoom in`,disabled:!p||u.scale>=H,onClick:()=>b(u.scale*1.5),children:`+`})]}),i>1&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`button`,{type:`button`,className:`image-viewer-nav prev`,"aria-label":`Previous image`,onClick:()=>a?.(-1),children:`‹`}),(0,O.jsx)(`button`,{type:`button`,className:`image-viewer-nav next`,"aria-label":`Next image`,onClick:()=>a?.(1),children:`›`}),(0,O.jsxs)(`div`,{className:`image-viewer-count`,children:[n+1,` / `,i]})]}),(0,O.jsx)(`button`,{type:`button`,className:`image-viewer-close`,onClick:o,"aria-label":`Close`,children:`×`})]}),document.body)}function W({added:e,removed:t}){return!e&&!t?null:(0,O.jsxs)(`span`,{className:`tool-stat`,children:[e>0&&(0,O.jsxs)(`span`,{className:`add`,children:[`+`,e]}),t>0&&(0,O.jsxs)(`span`,{className:`del`,children:[`−`,t]})]})}var G=420,K=(0,D.memo)(function({hunks:e,single:t,mode:n=`unified`}){let r=G;return(0,O.jsx)(`div`,{className:`diff-viewer diff-${n}`,children:e.map((i,a)=>{let o=_(g(i.oldText,i.newText)),s=[];for(let e=0;e<o.length;e++){if(r<=0){s.push((0,O.jsxs)(`div`,{className:`diff-line skip`,children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,O.jsx)(`span`,{children:`Diff truncated`})]},`t${a}`));break}let t=o[e];if(t.type===`skip`){s.push(n===`split`?(0,O.jsxs)(`div`,{className:`diff-row skip`,children:[(0,O.jsxs)(`div`,{className:`diff-side`,children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,O.jsxs)(`span`,{children:[t.count,` unchanged`]})]}),(0,O.jsxs)(`div`,{className:`diff-side`,children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,O.jsxs)(`span`,{children:[t.count,` unchanged`]})]})]},e):(0,O.jsxs)(`div`,{className:`diff-line skip`,children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:`⋯`}),(0,O.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,O.jsxs)(`div`,{className:`diff-row`,children:[(0,O.jsx)(`div`,{className:`diff-side ${t.type===`del`?`del`:t.type===`ctx`?``:`empty`}`,children:n!==null&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:t.type===`del`?`−`:` `}),(0,O.jsx)(`span`,{className:`diff-code`,children:n})]})}),(0,O.jsx)(`div`,{className:`diff-side ${t.type===`add`?`add`:t.type===`ctx`?``:`empty`}`,children:r!==null&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:t.type===`add`?`+`:` `}),(0,O.jsx)(`span`,{className:`diff-code`,children:r})]})})]},e));continue}let i=t.type===`add`?`+`:t.type===`del`?`−`:` `;s.push((0,O.jsxs)(`div`,{className:`diff-line ${t.type}`,children:[(0,O.jsx)(`span`,{className:`diff-gutter`,children:i}),(0,O.jsx)(`span`,{className:`diff-code`,children:t.text||` `})]},e))}let c=e.length>1?`Hunk ${a+1}`:i.label||t||`Diff`;return(0,O.jsxs)(`div`,{className:`diff-hunk`,children:[(0,O.jsxs)(`div`,{className:`diff-hunk-title`,children:[(0,O.jsx)(`span`,{children:c}),(0,O.jsx)(W,{added:i.added,removed:i.removed})]}),s]},a)})})});function q(e){let t=[e.added?`+${e.added}`:``,e.removed?`−${e.removed}`:``].filter(Boolean).join(`/`);return`\`${e.path}\` (${e.status}${t?`, ${t}`:``})`}function J(e){return`Review the change to ${q(e)}. Explain why it changed, identify correctness or security risks, and suggest missing tests or follow-up edits.`}function Y(e,t=[]){let n=e.slice(0,30),r=e.length-n.length,i=n.map(e=>`- ${q(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 X={added:`+`,modified:`~`,deleted:`−`};function Z(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 g(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 ee({file:e,mode:n}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!1),{added:s,removed:c}=(0,D.useMemo)(()=>Z(e),[e]);return(0,O.jsxs)(`div`,{className:`changes-file status-${e.status}`,children:[(0,O.jsxs)(`div`,{className:`changes-file-head`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`changes-file-open`,onClick:()=>i(e=>!e),children:[(0,O.jsx)(`span`,{className:`changes-file-glyph`,"aria-hidden":!0,children:X[e.status]}),(0,O.jsx)(`span`,{className:`changes-file-path`,children:e.path}),(s>0||c>0)&&(0,O.jsxs)(`span`,{className:`changes-file-stat`,children:[s>0&&(0,O.jsxs)(`span`,{className:`add`,children:[`+`,s]}),c>0&&(0,O.jsxs)(`span`,{className:`del`,children:[`−`,c]})]})]}),(0,O.jsxs)(`span`,{className:`changes-file-actions`,children:[(0,O.jsx)(`button`,{type:`button`,className:`changes-file-act`,onClick:()=>t.prefillComposer(J({...e,added:s,removed:c})),title:`Ask the agent about this file`,children:`Ask`}),(0,O.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,O.jsx)(K,{hunks:[{oldText:e.oldText,newText:e.newText,added:s,removed:c,label:e.path}],mode:n}),r&&e.binary&&(0,O.jsx)(`div`,{className:`changes-binary`,children:`Binary file — not shown.`})]})}function $({node:e,byPath:t,mode:n,depth:r}){let[i,a]=(0,D.useState)(!0);if(e.type===`file`){let i=t.get(e.path);return i?(0,O.jsx)(`div`,{style:{paddingLeft:r*12},children:(0,O.jsx)(ee,{file:i,mode:n})}):null}return(0,O.jsxs)(`div`,{className:`changes-dir`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`changes-dir-head`,style:{paddingLeft:r*12},onClick:()=>a(e=>!e),children:[(0,O.jsx)(`span`,{className:`changes-chevron`,"aria-hidden":!0,children:i?`▾`:`▸`}),(0,O.jsxs)(`span`,{className:`changes-dir-name`,children:[e.name,`/`]})]}),i&&e.children?.map(e=>(0,O.jsx)($,{node:e,byPath:t,mode:n,depth:r+1},e.path))]})}export{T as _,K as a,R as c,F as d,P as f,w as g,E as h,Y as i,L as l,C as m,Z as n,U as o,k as p,Q as r,z as s,$ as t,I as u};
|