glimmervoid 0.46.2-next.164 → 0.46.2-next.165

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/dist/bin/glimmervoid.js +4 -4
  2. package/dist/chunks/{adapters-BEHP94Wf.js → adapters-Dg2iqDPO.js} +1 -1
  3. package/dist/chunks/{adapters-CeXianY1.js → adapters-Dh1iSH18.js} +1 -1
  4. package/dist/chunks/{agent-setup-cli-CbTPZyK7.js → agent-setup-cli-C7WB5FWK.js} +1 -1
  5. package/dist/chunks/{kimi-VBamp5vp.js → kimi-BjgwP49z.js} +287 -22
  6. package/dist/chunks/{main-CDJ_G4MN.js → main-Dz2d4cFe.js} +26 -2
  7. package/dist/client/assets/{alert-sound-BpSLIB7B.js → alert-sound-CzrfUQrG.js} +1 -1
  8. package/dist/client/assets/alert-sound-CzrfUQrG.js.br +0 -0
  9. package/dist/client/assets/{benchmark-panel-CCGDqJr-.js → benchmark-panel-DYPhj9b3.js} +1 -1
  10. package/dist/client/assets/benchmark-panel-DYPhj9b3.js.br +0 -0
  11. package/dist/client/assets/{celebration-player-CXZ_7pBQ.js → celebration-player-C9Pi0SmP.js} +1 -1
  12. package/dist/client/assets/celebration-player-C9Pi0SmP.js.br +0 -0
  13. package/dist/client/assets/{dialogs-He8NLJ05.js → dialogs-B-EoOxFX.js} +1 -1
  14. package/dist/client/assets/dialogs-B-EoOxFX.js.br +0 -0
  15. package/dist/client/assets/{doc-editor-ui-CTBMbMm-.js → doc-editor-ui-D8j8RJyh.js} +1 -1
  16. package/dist/client/assets/doc-editor-ui-D8j8RJyh.js.br +0 -0
  17. package/dist/client/assets/{feature-hint-5AlbguSC.js → feature-hint-DsIenff-.js} +1 -1
  18. package/dist/client/assets/feature-hint-DsIenff-.js.br +0 -0
  19. package/dist/client/assets/{first-run-checklist-DXRRzQlR.js → first-run-checklist-CyffKgMV.js} +1 -1
  20. package/dist/client/assets/first-run-checklist-CyffKgMV.js.br +0 -0
  21. package/dist/client/assets/{hooks-panel-EroOPQJe.js → hooks-panel-CHIQYARB.js} +1 -1
  22. package/dist/client/assets/hooks-panel-CHIQYARB.js.br +0 -0
  23. package/dist/client/assets/{index-Cb2I6OyB.js → index-DnNiYw2m.js} +5 -5
  24. package/dist/client/assets/index-DnNiYw2m.js.br +0 -0
  25. package/dist/client/assets/{issues-panel-wHP4NQtT.js → issues-panel-CVKUFwlt.js} +1 -1
  26. package/dist/client/assets/issues-panel-CVKUFwlt.js.br +0 -0
  27. package/dist/client/assets/{nyan-cat-CWOvLOgY.js → nyan-cat-B3QguTCY.js} +1 -1
  28. package/dist/client/assets/nyan-cat-B3QguTCY.js.br +0 -0
  29. package/dist/client/assets/{phone-shell-CHGFXoec.js → phone-shell-BYSfe36z.js} +1 -1
  30. package/dist/client/assets/phone-shell-BYSfe36z.js.br +0 -0
  31. package/dist/client/assets/{plan-face-d6GCOLvG.js → plan-face-DitcLz4U.js} +1 -1
  32. package/dist/client/assets/plan-face-DitcLz4U.js.br +0 -0
  33. package/dist/client/assets/{plan-render-Booa3Bo-.js → plan-render-Dc5BL45f.js} +1 -1
  34. package/dist/client/assets/plan-render-Dc5BL45f.js.br +0 -0
  35. package/dist/client/assets/{pr-scope-tabs-ymgl1HSU.js → pr-scope-tabs-pVf6DvP0.js} +1 -1
  36. package/dist/client/assets/pr-scope-tabs-pVf6DvP0.js.br +0 -0
  37. package/dist/client/assets/{radar-panel-zPNaBZ3v.js → radar-panel-Dcs6jJun.js} +1 -1
  38. package/dist/client/assets/radar-panel-Dcs6jJun.js.br +0 -0
  39. package/dist/client/assets/{resume-dialog-DK_3xJpx.js → resume-dialog-qy_CKLp3.js} +1 -1
  40. package/dist/client/assets/resume-dialog-qy_CKLp3.js.br +0 -0
  41. package/dist/client/assets/{review-queue-panel-CwPAHBMr.js → review-queue-panel-8myAgz2U.js} +1 -1
  42. package/dist/client/assets/review-queue-panel-8myAgz2U.js.br +0 -0
  43. package/dist/client/assets/{settings-panel-DzT428RT.js → settings-panel-7Z7fisdK.js} +2 -2
  44. package/dist/client/assets/settings-panel-7Z7fisdK.js.br +0 -0
  45. package/dist/client/assets/{shown-lightbox-uBt09HlZ.js → shown-lightbox-q2P4JDCx.js} +1 -1
  46. package/dist/client/assets/shown-lightbox-q2P4JDCx.js.br +0 -0
  47. package/dist/client/assets/{trace-panel-0V0cammV.js → trace-panel-C0xa0x0u.js} +1 -1
  48. package/dist/client/assets/trace-panel-C0xa0x0u.js.br +0 -0
  49. package/dist/client/assets/{usage-panel-xp0GhpuL.js → usage-panel-BNnuZw5E.js} +1 -1
  50. package/dist/client/assets/usage-panel-BNnuZw5E.js.br +0 -0
  51. package/dist/client/assets/{visions-panel-CMckrSY3.js → visions-panel-FupUvVpT.js} +1 -1
  52. package/dist/client/assets/visions-panel-FupUvVpT.js.br +0 -0
  53. package/dist/client/index.html +1 -1
  54. package/dist/client/index.html.br +0 -0
  55. package/dist/server/index.js +1 -1
  56. package/package.json +1 -1
  57. package/dist/client/assets/alert-sound-BpSLIB7B.js.br +0 -0
  58. package/dist/client/assets/benchmark-panel-CCGDqJr-.js.br +0 -0
  59. package/dist/client/assets/celebration-player-CXZ_7pBQ.js.br +0 -0
  60. package/dist/client/assets/dialogs-He8NLJ05.js.br +0 -0
  61. package/dist/client/assets/doc-editor-ui-CTBMbMm-.js.br +0 -0
  62. package/dist/client/assets/feature-hint-5AlbguSC.js.br +0 -0
  63. package/dist/client/assets/first-run-checklist-DXRRzQlR.js.br +0 -0
  64. package/dist/client/assets/hooks-panel-EroOPQJe.js.br +0 -0
  65. package/dist/client/assets/index-Cb2I6OyB.js.br +0 -0
  66. package/dist/client/assets/issues-panel-wHP4NQtT.js.br +0 -0
  67. package/dist/client/assets/nyan-cat-CWOvLOgY.js.br +0 -0
  68. package/dist/client/assets/phone-shell-CHGFXoec.js.br +0 -0
  69. package/dist/client/assets/plan-face-d6GCOLvG.js.br +0 -0
  70. package/dist/client/assets/plan-render-Booa3Bo-.js.br +0 -0
  71. package/dist/client/assets/pr-scope-tabs-ymgl1HSU.js.br +0 -0
  72. package/dist/client/assets/radar-panel-zPNaBZ3v.js.br +0 -0
  73. package/dist/client/assets/resume-dialog-DK_3xJpx.js.br +0 -0
  74. package/dist/client/assets/review-queue-panel-CwPAHBMr.js.br +0 -0
  75. package/dist/client/assets/settings-panel-DzT428RT.js.br +0 -0
  76. package/dist/client/assets/shown-lightbox-uBt09HlZ.js.br +0 -0
  77. package/dist/client/assets/trace-panel-0V0cammV.js.br +0 -0
  78. package/dist/client/assets/usage-panel-xp0GhpuL.js.br +0 -0
  79. package/dist/client/assets/visions-panel-CMckrSY3.js.br +0 -0
@@ -70,7 +70,7 @@ var OWN_SUBCOMMAND_RUNNERS = [
70
70
  return runPairCli(subcommandArgs);
71
71
  }],
72
72
  ["agent", async (subcommandArgs) => {
73
- const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-CbTPZyK7.js");
73
+ const { runAgentSetupCli } = await import("../chunks/agent-setup-cli-C7WB5FWK.js");
74
74
  return runAgentSetupCli(subcommandArgs);
75
75
  }],
76
76
  ["settings", async (subcommandArgs) => {
@@ -235,7 +235,7 @@ async function runDoctor() {
235
235
  }
236
236
  switchSection("Agents");
237
237
  try {
238
- const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-CeXianY1.js");
238
+ const { listAgentIds, describeAgentResolvability, setCustomAgents } = await import("../chunks/adapters-Dh1iSH18.js");
239
239
  const declaredCustomAgents = await readDeclaredCustomAgents();
240
240
  if (declaredCustomAgents.error) line("config", declaredCustomAgents.error);
241
241
  setCustomAgents(declaredCustomAgents.declared);
@@ -243,7 +243,7 @@ async function runDoctor() {
243
243
  const { label, path: resolvedPath } = describeAgentResolvability(id);
244
244
  line(`${id} (${label})`, resolvedPath ?? missingAgentText(id));
245
245
  }
246
- const { inspectGrokAgentSetup, inspectKimiAgentSetup } = await import("../chunks/agent-setup-cli-CbTPZyK7.js");
246
+ const { inspectGrokAgentSetup, inspectKimiAgentSetup } = await import("../chunks/agent-setup-cli-C7WB5FWK.js");
247
247
  const grokSetup = inspectGrokAgentSetup();
248
248
  line("grok hook setup", `${grokSetup.classification}: ${grokSetup.filePath}`);
249
249
  const kimiSetup = inspectKimiAgentSetup();
@@ -262,7 +262,7 @@ async function runDoctor() {
262
262
  try {
263
263
  const { resolvePackageBin } = await import("../chunks/runtime-paths-Cc0_ZR6V.js");
264
264
  const { execFileSync } = await import("../chunks/child-process-safe-CjVtRjDD.js");
265
- const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-CbTPZyK7.js");
265
+ const { inspectGrokAgentSetup } = await import("../chunks/agent-setup-cli-C7WB5FWK.js");
266
266
  const binPath = resolvePackageBin("cc-safety-net", "cc-safety-net");
267
267
  line("Sane YOLO", binPath || "not installed");
268
268
  if (binPath) line("cc-safety-net version", execFileSync(process.execPath, [binPath, "--version"], {
@@ -7,7 +7,7 @@ import { c as textOr, i as numberOr, s as rawTextOr } from "./coerce-NSst8oRP.js
7
7
  import { n as resolveAgentCommand, t as buildAgentSpawnCommand } from "./spawn-command-Cc40FiZI.js";
8
8
  import { n as parseJsonRecord } from "./json-core-dfa_7Fak.js";
9
9
  import { r as nextBackoffMs } from "./backoff-DjVpfHk7.js";
10
- import { a as classifyAgentTitle, i as grok, o as isBrailleChar, s as isSpinnerChar, t as kimi, u as buildAgentEnv } from "./kimi-VBamp5vp.js";
10
+ import { a as classifyAgentTitle, i as grok, o as isBrailleChar, s as isSpinnerChar, t as kimi, u as buildAgentEnv } from "./kimi-BjgwP49z.js";
11
11
  import { t as buildHookCommand } from "./hook-command-core-qTNK-xMF.js";
12
12
  import { n as isExperimentalBuild, t as compareReleaseVersions } from "./build-channel-DqsP-nkH.js";
13
13
  import { n as mergeCodexPreToolUse, t as HOOK_TOOLS } from "./hook-tools-Cr97Vdap.js";
@@ -1 +1 @@
1
- export { a as describeAgentResolvability, l as listAgentIds, f as setCustomAgents } from "./adapters-BEHP94Wf.js";
1
+ export { a as describeAgentResolvability, l as listAgentIds, f as setCustomAgents } from "./adapters-Dg2iqDPO.js";
@@ -1,5 +1,5 @@
1
1
  import { a as isMissingFileError, r as errorMessage } from "./text-DoirglWV.js";
2
- import { c as classifyGrokHooksFile, i as grok, l as renderGrokHooksFile, n as classifyKimiConfig, r as spliceKimiHooksBlock, t as kimi } from "./kimi-VBamp5vp.js";
2
+ import { c as classifyGrokHooksFile, i as grok, l as renderGrokHooksFile, n as classifyKimiConfig, r as spliceKimiHooksBlock, t as kimi } from "./kimi-BjgwP49z.js";
3
3
  import { p as writeTextAtomicSync } from "./json-file-BjFK_eSH.js";
4
4
  import fs from "node:fs";
5
5
  import path from "node:path";
@@ -1,5 +1,6 @@
1
- import { r as errorMessage } from "./text-DoirglWV.js";
1
+ import { a as isMissingFileError, r as errorMessage } from "./text-DoirglWV.js";
2
2
  import { s as relayPath } from "./runtime-paths-ghcH9CeW.js";
3
+ import { n as glimmervoidHomeDir } from "./config-path-core-DUWk0Lui.js";
3
4
  import { O as SIGN_URL_ENV, n as AGENT_URL_ENV, r as ASK_USER_QUESTION_TOOL_NAME } from "./session-B2Wieg0a.js";
4
5
  import { r as execFileSync } from "./child-process-safe-D4hyVIXj.js";
5
6
  import { n as isRecord } from "./coerce-NSst8oRP.js";
@@ -7,6 +8,7 @@ import { n as resolveAgentCommand, t as buildAgentSpawnCommand } from "./spawn-c
7
8
  import { t as HOOK_URL_ENV } from "./hook-relay-core-DA_bz2KA.js";
8
9
  import { a as KIMI_SANE_YOLO_FLAVOR, o as SANE_YOLO_PATH_ENV, r as RTK_PATH_ENV, s as saneYoloEnv } from "./rtk-hook-core-23_GM8RQ.js";
9
10
  import { t as buildHookCommand } from "./hook-command-core-qTNK-xMF.js";
11
+ import { p as writeTextAtomicSync } from "./json-file-BjFK_eSH.js";
10
12
  import fs from "node:fs";
11
13
  import path from "node:path";
12
14
  import os from "node:os";
@@ -557,11 +559,281 @@ function spliceKimiHooksBlock(configText, block) {
557
559
  changed: true
558
560
  };
559
561
  }
562
+ var KIMI_CONFIG_NAME = "config.toml";
563
+ var KIMI_SOURCES_NAME = ".glimmervoid-sources.json";
564
+ var GENERATED_ONLY_NAMES = /* @__PURE__ */ new Set([KIMI_CONFIG_NAME, KIMI_SOURCES_NAME]);
565
+ function generatedKimiConfig(realConfigText, hooksBlock) {
566
+ const configText = realConfigText ?? "";
567
+ const span = locateBlock(configText);
568
+ if (span === "foreign") return { refusal: "its Glimmervoid hooks block markers are unbalanced" };
569
+ const operatorText = span === "absent" ? configText : `${configText.slice(0, span.start)}${configText.slice(span.end)}`;
570
+ if (definesHooksOutsideArrayTables(operatorText)) return { refusal: "it defines hooks as a key or [hooks] table, which a [[hooks]] block cannot extend" };
571
+ const spliced = spliceKimiHooksBlock(operatorText, hooksBlock);
572
+ if ("refused" in spliced) return { refusal: `its hooks are ${spliced.refused}` };
573
+ return {
574
+ text: spliced.contents,
575
+ hadBlock: span !== "absent"
576
+ };
577
+ }
578
+ function configSourceStamp(realConfigText, hooksBlock) {
579
+ return createHash("sha256").update(realConfigText ?? "").update("\0").update(hooksBlock).digest("hex");
580
+ }
581
+ function linkKindFor(kind, platform) {
582
+ if (platform !== "win32") return "symlink";
583
+ return kind === "folder" ? "junction" : "hardlink";
584
+ }
585
+ function planEntryLink(real, generated, realHome, platform) {
586
+ const target = path.join(realHome, real.name);
587
+ const link = {
588
+ kind: "link",
589
+ name: real.name,
590
+ target,
591
+ linkKind: linkKindFor(real.kind, platform)
592
+ };
593
+ if (!generated) return [link];
594
+ if (generated.kind !== "link") return "private";
595
+ if (generated.linkTarget === target) return [];
596
+ return [{
597
+ kind: "unlink",
598
+ name: real.name
599
+ }, link];
600
+ }
601
+ function planKimiHome(inputs) {
602
+ const config = generatedKimiConfig(inputs.realConfigText, inputs.hooksBlock);
603
+ if ("refusal" in config) return {
604
+ kind: "refused",
605
+ reason: `the real ${KIMI_CONFIG_NAME} cannot take the hooks block: ${config.refusal}`
606
+ };
607
+ const steps = [];
608
+ const configStamp = configSourceStamp(inputs.realConfigText, inputs.hooksBlock);
609
+ if (!(inputs.generatedConfigText !== null && inputs.sourceStamps["config.toml"] === configStamp && classifyKimiConfig(inputs.generatedConfigText, inputs.hooksBlock) === "current")) steps.push({
610
+ kind: "write-config",
611
+ text: config.text
612
+ });
613
+ const generatedByName = new Map(inputs.generatedEntries.map((entry) => [entry.name, entry]));
614
+ const realNames = /* @__PURE__ */ new Set();
615
+ const privateNames = [];
616
+ for (const real of inputs.realEntries) {
617
+ if (GENERATED_ONLY_NAMES.has(real.name)) continue;
618
+ realNames.add(real.name);
619
+ const entrySteps = planEntryLink(real, generatedByName.get(real.name), inputs.realHome, inputs.platform);
620
+ if (entrySteps === "private") {
621
+ privateNames.push(real.name);
622
+ continue;
623
+ }
624
+ steps.push(...entrySteps);
625
+ }
626
+ for (const generated of inputs.generatedEntries) if (generated.kind === "link" && !realNames.has(generated.name)) steps.push({
627
+ kind: "unlink",
628
+ name: generated.name
629
+ });
630
+ return {
631
+ kind: "ready",
632
+ steps,
633
+ sourceStamps: {
634
+ ...inputs.sourceStamps,
635
+ [KIMI_CONFIG_NAME]: configStamp
636
+ },
637
+ privateNames,
638
+ hasStaleBlockInRealConfig: config.hadBlock
639
+ };
640
+ }
641
+ //#endregion
642
+ //#region session/kimi-home.ts
643
+ var GENERATED_HOME_MODE = 448;
644
+ var GENERATED_FILE_MODE = 384;
645
+ function realKimiHome(env = process.env, homeDir = os.homedir()) {
646
+ const configuredHome = typeof env.KIMI_CODE_HOME === "string" ? env.KIMI_CODE_HOME.trim() : "";
647
+ if (configuredHome) return path.resolve(configuredHome);
648
+ return path.join(homeDir, ".kimi-code");
649
+ }
650
+ function generatedKimiHomePath(env = process.env, homeDir = os.homedir()) {
651
+ return path.join(glimmervoidHomeDir(homeDir, env), "agent-homes", "kimi");
652
+ }
653
+ function listFolder(folder) {
654
+ try {
655
+ return fs.readdirSync(folder, { withFileTypes: true });
656
+ } catch (error) {
657
+ if (isMissingFileError(error)) return [];
658
+ throw error;
659
+ }
660
+ }
661
+ function realEntryKind(entryPath) {
662
+ try {
663
+ return fs.statSync(entryPath).isDirectory() ? "folder" : "file";
664
+ } catch {
665
+ return null;
666
+ }
667
+ }
668
+ function listRealEntries(realHome) {
669
+ const entries = [];
670
+ for (const dirent of listFolder(realHome)) {
671
+ const kind = realEntryKind(path.join(realHome, dirent.name));
672
+ if (kind) entries.push({
673
+ name: dirent.name,
674
+ kind
675
+ });
676
+ }
677
+ return entries;
678
+ }
679
+ function isSameFile(first, second) {
680
+ return first.dev === second.dev && first.ino === second.ino;
681
+ }
682
+ function hardLinkTarget(entryStat, realHome, name) {
683
+ if (entryStat.nlink < 2) return null;
684
+ const realPath = path.join(realHome, name);
685
+ try {
686
+ return isSameFile(entryStat, fs.statSync(realPath)) ? realPath : null;
687
+ } catch {
688
+ return null;
689
+ }
690
+ }
691
+ function describeGeneratedEntry(generatedHome, realHome, name) {
692
+ const entryPath = path.join(generatedHome, name);
693
+ const entryStat = fs.lstatSync(entryPath);
694
+ if (entryStat.isSymbolicLink()) return {
695
+ name,
696
+ kind: "link",
697
+ linkTarget: path.resolve(generatedHome, fs.readlinkSync(entryPath))
698
+ };
699
+ if (entryStat.isDirectory()) return {
700
+ name,
701
+ kind: "folder",
702
+ linkTarget: null
703
+ };
704
+ const hardLinkedTo = hardLinkTarget(entryStat, realHome, name);
705
+ if (hardLinkedTo) return {
706
+ name,
707
+ kind: "link",
708
+ linkTarget: hardLinkedTo
709
+ };
710
+ return {
711
+ name,
712
+ kind: "file",
713
+ linkTarget: null
714
+ };
715
+ }
716
+ function readOptionalText(filePath) {
717
+ try {
718
+ return fs.readFileSync(filePath, "utf8");
719
+ } catch (error) {
720
+ if (isMissingFileError(error)) return null;
721
+ throw error;
722
+ }
723
+ }
724
+ function readRealConfig(realHome) {
725
+ const configPath = path.join(realHome, KIMI_CONFIG_NAME);
726
+ try {
727
+ return { text: fs.readFileSync(configPath, "utf8") };
728
+ } catch (error) {
729
+ if (isMissingFileError(error)) return { text: null };
730
+ return { refusal: `the real ${configPath} cannot be read: ${errorMessage(error)}` };
731
+ }
732
+ }
733
+ function readSourceStamps(generatedHome) {
734
+ try {
735
+ const parsed = JSON.parse(fs.readFileSync(path.join(generatedHome, KIMI_SOURCES_NAME), "utf8"));
736
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
737
+ return Object.fromEntries(Object.entries(parsed).filter((entry) => typeof entry[1] === "string"));
738
+ } catch {
739
+ return {};
740
+ }
741
+ }
742
+ function inspectKimiHome(options) {
743
+ const realHome = realKimiHome(options.env, options.homeDir);
744
+ const generatedHome = generatedKimiHomePath(options.env, options.homeDir);
745
+ try {
746
+ return {
747
+ generatedHome,
748
+ realHome,
749
+ plan: planFromDisk(options, realHome, generatedHome)
750
+ };
751
+ } catch (error) {
752
+ return {
753
+ generatedHome,
754
+ realHome,
755
+ plan: {
756
+ kind: "refused",
757
+ reason: `${realHome} or ${generatedHome} cannot be listed: ${errorMessage(error)}`
758
+ }
759
+ };
760
+ }
761
+ }
762
+ function planFromDisk({ hooksBlock, platform = process.platform }, realHome, generatedHome) {
763
+ const realConfig = readRealConfig(realHome);
764
+ if ("refusal" in realConfig) return {
765
+ kind: "refused",
766
+ reason: realConfig.refusal
767
+ };
768
+ const generatedNames = listFolder(generatedHome).map((dirent) => dirent.name);
769
+ return planKimiHome({
770
+ realHome,
771
+ realEntries: listRealEntries(realHome),
772
+ generatedEntries: generatedNames.map((name) => describeGeneratedEntry(generatedHome, realHome, name)),
773
+ realConfigText: realConfig.text,
774
+ generatedConfigText: readOptionalText(path.join(generatedHome, KIMI_CONFIG_NAME)),
775
+ hooksBlock,
776
+ sourceStamps: readSourceStamps(generatedHome),
777
+ platform
778
+ });
779
+ }
780
+ function stepEntryPath(generatedHome, step) {
781
+ return path.join(generatedHome, step.kind === "write-config" ? KIMI_CONFIG_NAME : step.name);
782
+ }
783
+ function applyStep(generatedHome, step) {
784
+ const entryPath = stepEntryPath(generatedHome, step);
785
+ if (step.kind === "write-config") {
786
+ writeTextAtomicSync(entryPath, step.text, {
787
+ mode: GENERATED_FILE_MODE,
788
+ enforceMode: true
789
+ });
790
+ return;
791
+ }
792
+ if (step.kind === "unlink") {
793
+ fs.unlinkSync(entryPath);
794
+ return;
795
+ }
796
+ if (step.linkKind === "hardlink") {
797
+ fs.linkSync(step.target, entryPath);
798
+ return;
799
+ }
800
+ fs.symlinkSync(step.target, entryPath, step.linkKind === "junction" ? "junction" : void 0);
801
+ }
802
+ function stepFailure(generatedHome, step, error) {
803
+ const entryPath = stepEntryPath(generatedHome, step);
804
+ if (step.kind === "link") return `${entryPath} cannot be linked to ${step.target}: ${errorMessage(error)}`;
805
+ return `${entryPath} cannot be written: ${errorMessage(error)}`;
806
+ }
807
+ function prepareKimiHome(options) {
808
+ const generatedHome = generatedKimiHomePath(options.env, options.homeDir);
809
+ try {
810
+ fs.mkdirSync(generatedHome, {
811
+ recursive: true,
812
+ mode: GENERATED_HOME_MODE
813
+ });
814
+ fs.chmodSync(generatedHome, GENERATED_HOME_MODE);
815
+ } catch (error) {
816
+ return { refusal: `${generatedHome} cannot be created: ${errorMessage(error)}` };
817
+ }
818
+ const { plan } = inspectKimiHome(options);
819
+ if (plan.kind === "refused") return { refusal: plan.reason };
820
+ for (const step of plan.steps) try {
821
+ applyStep(generatedHome, step);
822
+ } catch (error) {
823
+ return { refusal: stepFailure(generatedHome, step, error) };
824
+ }
825
+ try {
826
+ writeTextAtomicSync(path.join(generatedHome, KIMI_SOURCES_NAME), `${JSON.stringify(plan.sourceStamps, null, 2)}\n`, { mode: GENERATED_FILE_MODE });
827
+ } catch (error) {
828
+ return { refusal: `${path.join(generatedHome, KIMI_SOURCES_NAME)} cannot be written: ${errorMessage(error)}` };
829
+ }
830
+ return { home: generatedHome };
831
+ }
560
832
  //#endregion
561
833
  //#region session/adapters/kimi.ts
562
834
  var ID = "kimi";
563
835
  var COMMAND_NAME = "kimi";
564
- var SETUP_COMMAND = "glimmervoid agent setup kimi";
836
+ var HOME_ENV_NAME = "KIMI_CODE_HOME";
565
837
  var RELAY_PATH = relayPath("hook-relay");
566
838
  var HOOK_TOOL_RELAY_PATH = relayPath("hook-tool-relay");
567
839
  var HOOK_EVENTS = Object.freeze([
@@ -655,13 +927,8 @@ var titleProfile = {
655
927
  agentSuffix: null
656
928
  }
657
929
  };
658
- function kimiHome(env = process.env, homedir = os.homedir()) {
659
- const configuredHome = typeof env.KIMI_CODE_HOME === "string" ? env.KIMI_CODE_HOME.trim() : "";
660
- if (configuredHome) return path.resolve(configuredHome);
661
- return path.join(homedir, ".kimi-code");
662
- }
663
- function configFilePath(env = process.env, homedir = os.homedir()) {
664
- return path.join(kimiHome(env, homedir), "config.toml");
930
+ function configFilePath(env = process.env, homedir) {
931
+ return path.join(realKimiHome(env, homedir), "config.toml");
665
932
  }
666
933
  function expectedHooksBlock() {
667
934
  return renderKimiHooksBlock({
@@ -676,10 +943,13 @@ function expectedHooksBlock() {
676
943
  }
677
944
  });
678
945
  }
679
- function classifyConfigContents(contents) {
680
- const expectedBlock = expectedHooksBlock();
681
- if (expectedBlock === null) return "unrenderable";
682
- return classifyKimiConfig(contents, expectedBlock);
946
+ function prepareHome(env) {
947
+ const hooksBlock = expectedHooksBlock();
948
+ if (hooksBlock === null) return { refusal: "the hook relay path cannot be written into a kimi hooks block" };
949
+ return prepareKimiHome({
950
+ env,
951
+ hooksBlock
952
+ });
683
953
  }
684
954
  var WINDOWS_SHAPED_ROOT = /^(?:[A-Za-z]:\/|\/\/)/;
685
955
  var MAX_WORKSPACE_SLUG_LENGTH = 40;
@@ -703,7 +973,7 @@ function physicalPathOf(cwd) {
703
973
  function isWorkspaceTrusted(cwd, env = process.env) {
704
974
  const physicalCwd = physicalPathOf(cwd);
705
975
  if (physicalCwd === null) return false;
706
- return fs.existsSync(path.join(kimiHome(env), "workspace-trust", workspaceTrustKey(physicalCwd)));
976
+ return fs.existsSync(path.join(realKimiHome(env), "workspace-trust", workspaceTrustKey(physicalCwd)));
707
977
  }
708
978
  function resolveCommand({ platform, execFile = execFileSync, pathExists = fs.existsSync } = {}) {
709
979
  return resolveAgentCommand({
@@ -743,14 +1013,9 @@ var kimi = {
743
1013
  mapPromptKind: mapHookPromptKind,
744
1014
  mapPayload: mapHookPayload,
745
1015
  injection: {
746
- kind: "home-hooks-file",
747
- setupCommand: SETUP_COMMAND,
748
- filePath: configFilePath,
749
- classifyContents: classifyConfigContents,
750
- isSaneYoloReady: (contents) => classifyConfigContents(contents) === "current",
751
- projectConfigCandidates: [],
752
- userConfigFolders: () => [],
753
- mayContributeHooks: () => false
1016
+ kind: "generated-home",
1017
+ homeEnvName: HOME_ENV_NAME,
1018
+ prepareHome
754
1019
  }
755
1020
  },
756
1021
  resolveCommand,
@@ -20,12 +20,12 @@ import { _ as lineStartOffsets, a as projectForUri, b as replacedSpanOfWholeText
20
20
  import { n as DEFAULT_MAX_MS, r as nextBackoffMs, t as DEFAULT_BASE_MS } from "./backoff-DjVpfHk7.js";
21
21
  import { n as unrefTimer, t as DEFAULT_TIMER_FNS } from "./timer-deps-u2DAQLok.js";
22
22
  import { a as readPageTitle, i as filesAfterRetention, n as decideShownKind, o as shownMimeForFilename, r as describeOverCap, t as SHOWN_SNIFF_BYTES } from "./shown-files-core-C7ER2sw2.js";
23
- import { t as kimi } from "./kimi-VBamp5vp.js";
23
+ import { t as kimi } from "./kimi-BjgwP49z.js";
24
24
  import { n as shellQuote } from "./hook-command-core-qTNK-xMF.js";
25
25
  import { C as parseCgroupBytes, S as memoryReserveBytes, T as parseMemAvailableBytes, _ as createSpawnGate, a as jsonStateLoadError, b as cgroupLimitBytes, c as loadedJsonValue, d as writeJsonAtomicSync, f as writeTextAtomic, g as createSerialQueue, h as createMemoryAdmission, i as createJsonStateWriter, m as createKeyedSerialQueue, n as appendJsonLines, o as loadJsonStateFile, p as writeTextAtomicSync, r as createJsonStateStore, s as loadJsonStateFileSync, t as appendJsonLine, u as writeJsonAtomic, v as isQueueAdmissionTimeout, w as parseCgroupV2Path, x as headroomFromReadings, y as cgroupAncestorPaths } from "./json-file-BjFK_eSH.js";
26
26
  import { $ as resolveProjectToken, B as buildAiGenerationEvents, G as claudeAccountUuidOf, H as buildExceptionProperties, I as FIRST_RUN_NOTICE, J as decideRemoteTelemetryState, K as codexUserIdOf, L as TELEMETRY_BATCH_URL, Q as parsePosthogReleaseId, R as TELEMETRY_FLAGS_URL, S as validateSettingsBlock, U as buildPersonProperties, V as buildBrowserExceptionProperties, W as classifySessionExit, X as exceptionFingerprint, Y as decideTelemetryConsent, Z as nodeMajorVersion, _ as isRtkBinaryName, a as ensureProjectIds, at as matchedPrefix, b as mergeSettingsBlock, ct as sessionIdFromBranch, dt as canonicalizePath, ft as comparableDirectoryPath, g as installTargetPath, h as findEscapingArchiveMember, i as createConfigStore, it as DEFAULT_BRANCH_GC_PREFIXES, lt as usablePrefixes, m as decideRtkInstall, n as DEFAULT_CONFIG, nt as stableConfigKey, o as generateProjectId, ot as planBranchGc, p as assetForPlatform, pt as isSameDirectoryPath, q as decideIsDevInstall, s as glimmervoidHomeDir$1, st as planWorktreeGc, t as ABORT_CONFIG_SAVE, ut as worktreeIntegrationTips, v as verifyDigest, x as settingsBlockSpecFor, z as adapterBucket } from "./config-store-B6tDGKyB.js";
27
27
  import { _ as TelemetryState, a as DEEP_HISTORY_SCROLLBACK_LINES, c as describeDataAttach, d as DashboardTelemetryReport, h as TELEMETRY_EVENT_SCHEMAS, i as HookEnvelope, l as parseDataAttach, m as PendingCrashReport, r as HTTP_URL_RE, s as LOGGED_FAST_CLOSE_COUNTS, u as parseDataClientMessage } from "./build-channel-DqsP-nkH.js";
28
- import { $ as identityFromRelPath, A as decideFileRead, B as sessionsRootCandidates, C as pickNewestPublished, D as codexRootCandidates, E as codexHomes, F as kimiHomes, G as kimiSessionIdFromPath, H as shouldPersistWarehouse, I as passOutcome, J as dedupKeys, K as parseKimiUsageLine, L as projectDirCandidates, M as expandTilde, N as grokHomes, O as codexSessionIdFromPath, P as isUsageFile, Q as foldReplacementIntoGenerationRollup, R as resolveProjectsDirs, S as parseResolvedSha, T as codexFallbackRoots, U as splitLines$1, V as shouldEvaluateDespiteIoFailures, W as kimiDedupIdentity, X as expandAdvisorIterations, Y as emptyTotals, Z as foldEntryIntoGenerationRollup, _ as isCheckFresh, a as describeAgentResolvability, at as totalTokensOf$1, b as parseRegistryDeprecation, c as isKnownAgentId, d as resolveAdapter, et as isWithinGenerationRecencyWindow, f as setCustomAgents, g as decideUpdateStatus, h as decideInstallFlavor, i as customAgentFingerprint, it as shouldReplace, j as dedupeCodexFiles, k as continuationDelayMs, l as listAgentIds, m as readHostCodexVersion, n as cachedAgentResolvability, nt as parseJsonLine, o as getAdapter, ot as vendorUsageEntry, p as codex, q as addEntryToTotals, r as commandFor, rt as parseUsageLine, s as hookProfileOf, st as claudeCode, t as DEFAULT_AGENT_ID, tt as mergeGenerationRollups, u as resetCommandCache, v as normalizeSha, w as shortSha$1, x as parseRegistryLatest, y as normalizeUpdateChannel, z as scopedClaudeRoots } from "./adapters-BEHP94Wf.js";
28
+ import { $ as identityFromRelPath, A as decideFileRead, B as sessionsRootCandidates, C as pickNewestPublished, D as codexRootCandidates, E as codexHomes, F as kimiHomes, G as kimiSessionIdFromPath, H as shouldPersistWarehouse, I as passOutcome, J as dedupKeys, K as parseKimiUsageLine, L as projectDirCandidates, M as expandTilde, N as grokHomes, O as codexSessionIdFromPath, P as isUsageFile, Q as foldReplacementIntoGenerationRollup, R as resolveProjectsDirs, S as parseResolvedSha, T as codexFallbackRoots, U as splitLines$1, V as shouldEvaluateDespiteIoFailures, W as kimiDedupIdentity, X as expandAdvisorIterations, Y as emptyTotals, Z as foldEntryIntoGenerationRollup, _ as isCheckFresh, a as describeAgentResolvability, at as totalTokensOf$1, b as parseRegistryDeprecation, c as isKnownAgentId, d as resolveAdapter, et as isWithinGenerationRecencyWindow, f as setCustomAgents, g as decideUpdateStatus, h as decideInstallFlavor, i as customAgentFingerprint, it as shouldReplace, j as dedupeCodexFiles, k as continuationDelayMs, l as listAgentIds, m as readHostCodexVersion, n as cachedAgentResolvability, nt as parseJsonLine, o as getAdapter, ot as vendorUsageEntry, p as codex, q as addEntryToTotals, r as commandFor, rt as parseUsageLine, s as hookProfileOf, st as claudeCode, t as DEFAULT_AGENT_ID, tt as mergeGenerationRollups, u as resetCommandCache, v as normalizeSha, w as shortSha$1, x as parseRegistryLatest, y as normalizeUpdateChannel, z as scopedClaudeRoots } from "./adapters-Dg2iqDPO.js";
29
29
  import { t as HOOK_TOOLS } from "./hook-tools-Cr97Vdap.js";
30
30
  import { a as formatSshPublicKey, c as orderAgentSockets, i as commitSigningShimText, l as parseSshPublicKey, n as NO_AGENT_HOLDS_KEY, o as isForwardedAgentDirName, r as agentListsKey, s as isSignableGitObject, t as COMMIT_SIGNING_SHIM_NAME } from "./ssh-signing-core-CRhVVWNW.js";
31
31
  import { a as configSiblingPath, c as defaultPairingsPath, d as decideDeviceAuth, f as deviceNameFromUserAgent, l as defaultSeenPath, n as normalizeRemoteConfig, o as createPairingsStore, p as hashSecret, r as validateRemoteConfig, s as createSeenStore, t as decideBindHost, u as DEFAULT_DEVICE_MAX_AGE_MS } from "./remote-config-DKXELcNh.js";
@@ -16662,6 +16662,25 @@ function createSessionHookLifecycle(options) {
16662
16662
  const isSaneYoloHookInFile = injection.isSaneYoloReady(contents);
16663
16663
  return registerRelayHooks(port, [], saneYoloTool() !== void 0 && isSaneYoloHookInFile);
16664
16664
  }
16665
+ function injectGeneratedHomeHooks(port, injection) {
16666
+ const prepared = injection.prepareHome(process.env);
16667
+ if ("refusal" in prepared) return {
16668
+ ...NO_HOOK_INJECTION,
16669
+ refusal: `${options.agentId} cannot start: ${prepared.refusal}`
16670
+ };
16671
+ const relayHooks = registerRelayHooks(port, [], saneYoloTool() !== void 0);
16672
+ if (relayHooks === NO_HOOK_INJECTION) return {
16673
+ ...NO_HOOK_INJECTION,
16674
+ refusal: `${options.agentId} cannot start: its hooks could not be registered`
16675
+ };
16676
+ return {
16677
+ ...relayHooks,
16678
+ env: {
16679
+ ...relayHooks.env,
16680
+ [injection.homeEnvName]: prepared.home
16681
+ }
16682
+ };
16683
+ }
16665
16684
  function resolveListenerPort() {
16666
16685
  if (!options.getHookPort) return null;
16667
16686
  try {
@@ -16681,6 +16700,7 @@ function createSessionHookLifecycle(options) {
16681
16700
  const injection = hookProfile.injection;
16682
16701
  if (injection?.kind === "argv-config") return injectRelayHooks(port, injection);
16683
16702
  if (injection?.kind === "home-hooks-file") return injectHomeRelayHooks(port, injection);
16703
+ if (injection?.kind === "generated-home") return injectGeneratedHomeHooks(port, injection);
16684
16704
  try {
16685
16705
  const buildSettingsArgs = options.adapter.settingsArgs;
16686
16706
  if (typeof buildSettingsArgs !== "function") throw new TypeError(`agent ${options.agentId} carries no settings-file argv`);
@@ -20372,6 +20392,10 @@ var Session = class extends EventEmitter {
20372
20392
  }
20373
20393
  const isRemoteCodex = remoteLaunch !== null && this.agentId === "codex";
20374
20394
  const hookInjection = this._hooks.inject();
20395
+ if (hookInjection.refusal) {
20396
+ this._abandonSpawn(new Error(hookInjection.refusal));
20397
+ return;
20398
+ }
20375
20399
  this._isSaneYoloActive = remoteLaunch === null && hookInjection.isSaneYoloActive;
20376
20400
  if (this._hooks.isRequiredGuardrailsMissing()) {
20377
20401
  this._abandonSpawn(/* @__PURE__ */ new Error(GUARDRAILS_UNAPPLIED_ERROR));
@@ -1 +1 @@
1
- import{Gi as e,Hi as t,Ji as n,Ki as r,Ui as i,Wi as a,Yi as o,qi as s}from"./index-Cb2I6OyB.js";var c=.3,l=null;function u(){return o(l)}function d(e){return n(e,l)}async function f(){try{let e=await fetch(t,{credentials:`same-origin`,cache:`no-store`});e.ok&&(l=s(await e.json()))}catch{}}function p(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function m(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function h(e){g(a[e]??a.chime)}function g(e){let t=p(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}m(t,i)}async function _(e){try{let t=await fetch(r(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function v(e){let t=await _(e);if(!t)return!1;let n=p();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=c,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),m(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var y=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function b(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<y.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=y[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+y.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function x(){try{h(i)}catch{}}function S(t){try{let n=d(t),r=e(n);if(!r){h(n);return}v(r).then(e=>{e||x()})}catch{}}export{f as loadCustomSounds,S as playAlertSound,b as playNyanJingle,g as playToneSequence,d as resolveSoundId,u as soundOptions};
1
+ import{Gi as e,Hi as t,Ji as n,Ki as r,Ui as i,Wi as a,Yi as o,qi as s}from"./index-DnNiYw2m.js";var c=.3,l=null;function u(){return o(l)}function d(e){return n(e,l)}async function f(){try{let e=await fetch(t,{credentials:`same-origin`,cache:`no-store`});e.ok&&(l=s(await e.json()))}catch{}}function p(){let e=new AudioContext;return e.state===`suspended`&&e.resume(),e}function m(e,t){setTimeout(()=>e.close().catch(()=>{}),(t+.1)*1e3)}function h(e){g(a[e]??a.chime)}function g(e){let t=p(),n=t.createGain();n.gain.value=e.peakGain,n.connect(t.destination);let r=t.currentTime,i=0;for(let a of e.tones){let e=r+a.startSeconds,o=e+a.durationSeconds,s=t.createOscillator(),c=t.createGain();s.type=a.waveform,s.frequency.setValueAtTime(a.frequency,e),a.endFrequency&&s.frequency.exponentialRampToValueAtTime(a.endFrequency,o),c.gain.setValueAtTime(.001,e),c.gain.exponentialRampToValueAtTime(a.gain??1,e+.01),c.gain.exponentialRampToValueAtTime(.001,o),s.connect(c),c.connect(n),s.start(e),s.stop(o),i=Math.max(i,a.startSeconds+a.durationSeconds)}m(t,i)}async function _(e){try{let t=await fetch(r(e),{credentials:`same-origin`});return t.ok?await t.arrayBuffer():null}catch{return null}}async function v(e){let t=await _(e);if(!t)return!1;let n=p();try{let e=await n.decodeAudioData(t),r=n.createGain();r.gain.value=c,r.connect(n.destination);let i=n.createBufferSource();return i.buffer=e,i.connect(r),i.start(),m(n,e.duration),!0}catch{return n.close().catch(()=>{}),!1}}var y=[659.25,830.61,987.77,1108.73,987.77,830.61,739.99,659.25,739.99,830.61,987.77,1108.73,987.77,830.61];function b(){try{let e=new AudioContext;if(e.state===`suspended`&&e.resume(),e.state===`suspended`)return;let t=e.createGain();t.gain.value=.05,t.connect(e.destination);let n=.125,r=e.currentTime;for(let i=0;i<y.length;i++){let a=r+i*n,o=e.createOscillator(),s=e.createGain();o.type=`square`,o.frequency.value=y[i],s.gain.setValueAtTime(.001,a),s.gain.exponentialRampToValueAtTime(1,a+.01),s.gain.exponentialRampToValueAtTime(.001,a+n*.9),o.connect(s),s.connect(t),o.start(a),o.stop(a+n)}let i=r+y.length*n;t.gain.setValueAtTime(.05,i-.05),t.gain.exponentialRampToValueAtTime(.001,i),setTimeout(()=>e.close().catch(()=>{}),(i-r+.1)*1e3)}catch{}}function x(){try{h(i)}catch{}}function S(t){try{let n=d(t),r=e(n);if(!r){h(n);return}v(r).then(e=>{e||x()})}catch{}}export{f as loadCustomSounds,S as playAlertSound,b as playNyanJingle,g as playToneSequence,d as resolveSoundId,u as soundOptions};
@@ -1 +1 @@
1
- import"./updates-view-core-D1HrhoS5.js";import{n as e,o as t,r as n}from"./dom-helpers-C7P3_59O.js";import{J as r,Y as i,q as a}from"./index-Cb2I6OyB.js";var o={mine:`Mine`,run:`Run`,cancel:`Cancel`},s=null;function c(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function l(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function u(e,n,i){let a=t(`button`,`bench-action-button`,o[n]);return a.type=`button`,a.disabled=i,a.addEventListener(`click`,()=>r(e.id,n)),a}function d(e,t){let n=e.inFlight;if(!n||n.suiteId!==t.id)return``;let r=n.caseId?`case ${n.caseId}, `:``;return`Cell ${n.cellIndex+1} of ${n.cellCount}: ${r}arm ${n.armId}, trial ${n.trial}, ${n.phase}.`}function f(e){let n=t(`td`,`bench-score`,c(e?.recall??null));return e&&e.invalid>0&&(n.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(n.dataset.degraded=`true`),n}function p(e){let n=e.armIds.filter(t=>t!==e.baselineArm),r=t(`table`,`bench-table`),i=t(`tr`);i.append(t(`th`,null,`Case`),...e.armIds.map(n=>t(`th`,null,n===e.baselineArm?`${n} (baseline)`:n))),i.append(...n.map(e=>t(`th`,null,`${e} vs baseline`))),r.append(i);for(let i of e.rows){let a=t(`tr`);a.append(t(`td`,`bench-case`,i.caseId),...e.armIds.map(e=>f(i.arms[e]))),a.append(...n.map(e=>t(`td`,`bench-delta`,l(i.deltaVsBaseline[e]??null)))),r.append(a)}let a=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),o=t(`tr`,`bench-total`);o.append(t(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>f(e.totals[t]))),r.append(o);for(let n of a){let i=t(`tr`,`bench-total`);i.append(t(`td`,`bench-case`,`Recall, ${n}`),...e.armIds.map(r=>t(`td`,`bench-score`,c(e.totals[r]?.recallByTag[n]??null)))),r.append(i)}return r}function m(e,r){let{isServerConnected:i,pendingActionBySuite:o,outcomeBySuite:s}=a(),c=t(`div`,`bench-suite`),l=e.inFlight?.suiteId===r.id,f=!!e.inFlight&&!l,m=o.has(r.id)||!i,h=t(`div`,`bench-summary`);h.append(t(`span`,`bench-suite-title`,r.title),n(`bench`,r.caseCount===1?`case`:`cases`,String(r.caseCount)),n(`bench`,r.candidateCount===1?`candidate`:`candidates`,String(r.candidateCount)),n(`bench`,`arms`,String(r.armIds.length))),c.append(h);let g=t(`div`,`bench-controls`),_=e.configured===!0&&r.error===null;g.append(u(r,`mine`,!_||m||l),u(r,`run`,!_||m||l||f||r.caseCount===0),u(r,`cancel`,m||!l));let v=t(`span`,`bench-status`,(i?``:`Not connected to the server. Reconnecting.`)||d(e,r)||s.get(r.id)||``);if(v.setAttribute(`role`,`status`),g.append(v),c.append(g),r.error)return c.append(t(`p`,`bench-error`,r.error)),c;let y=r.latestReport;return y?(c.append(t(`p`,`bench-run-line`,`Latest run ${y.runId}: ${y.status}. Only cases every arm scored count toward paired recall.`)),y.rows.length>0&&c.append(p(y)),c):(c.append(t(`p`,`bench-empty`,r.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),c)}function h(){if(!s)return;s.textContent=``;let{status:n}=a(),r=e(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(s.append(r),!n)s.append(t(`p`,`bench-empty`,`Waiting for the server.`));else if(!n.configured)s.append(t(`p`,`bench-empty`,n.reason||`Benchmarks are off.`));else if(n.suites.length===0)s.append(t(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let e of n.suites)s.append(m(n,e))}function g(e){s||(s=t(`div`,`bench-content`),e.append(s),i(h),h())}var _={mount:g};export{_ as view};
1
+ import"./updates-view-core-D1HrhoS5.js";import{n as e,o as t,r as n}from"./dom-helpers-C7P3_59O.js";import{J as r,Y as i,q as a}from"./index-DnNiYw2m.js";var o={mine:`Mine`,run:`Run`,cancel:`Cancel`},s=null;function c(e){return e===null?`n/a`:`${Math.round(e*100)}%`}function l(e){if(e===null)return`n/a`;let t=Math.round(e*100);return t>0?`+${t}`:String(t)}function u(e,n,i){let a=t(`button`,`bench-action-button`,o[n]);return a.type=`button`,a.disabled=i,a.addEventListener(`click`,()=>r(e.id,n)),a}function d(e,t){let n=e.inFlight;if(!n||n.suiteId!==t.id)return``;let r=n.caseId?`case ${n.caseId}, `:``;return`Cell ${n.cellIndex+1} of ${n.cellCount}: ${r}arm ${n.armId}, trial ${n.trial}, ${n.phase}.`}function f(e){let n=t(`td`,`bench-score`,c(e?.recall??null));return e&&e.invalid>0&&(n.title=`${e.invalid} invalid or failed cell(s)`),e&&e.degraded>0&&(n.dataset.degraded=`true`),n}function p(e){let n=e.armIds.filter(t=>t!==e.baselineArm),r=t(`table`,`bench-table`),i=t(`tr`);i.append(t(`th`,null,`Case`),...e.armIds.map(n=>t(`th`,null,n===e.baselineArm?`${n} (baseline)`:n))),i.append(...n.map(e=>t(`th`,null,`${e} vs baseline`))),r.append(i);for(let i of e.rows){let a=t(`tr`);a.append(t(`td`,`bench-case`,i.caseId),...e.armIds.map(e=>f(i.arms[e]))),a.append(...n.map(e=>t(`td`,`bench-delta`,l(i.deltaVsBaseline[e]??null)))),r.append(a)}let a=[...new Set(e.armIds.flatMap(t=>Object.keys(e.totals[t]?.recallByTag??{})))].sort(),o=t(`tr`,`bench-total`);o.append(t(`td`,`bench-case`,`Paired recall`),...e.armIds.map(t=>f(e.totals[t]))),r.append(o);for(let n of a){let i=t(`tr`,`bench-total`);i.append(t(`td`,`bench-case`,`Recall, ${n}`),...e.armIds.map(r=>t(`td`,`bench-score`,c(e.totals[r]?.recallByTag[n]??null)))),r.append(i)}return r}function m(e,r){let{isServerConnected:i,pendingActionBySuite:o,outcomeBySuite:s}=a(),c=t(`div`,`bench-suite`),l=e.inFlight?.suiteId===r.id,f=!!e.inFlight&&!l,m=o.has(r.id)||!i,h=t(`div`,`bench-summary`);h.append(t(`span`,`bench-suite-title`,r.title),n(`bench`,r.caseCount===1?`case`:`cases`,String(r.caseCount)),n(`bench`,r.candidateCount===1?`candidate`:`candidates`,String(r.candidateCount)),n(`bench`,`arms`,String(r.armIds.length))),c.append(h);let g=t(`div`,`bench-controls`),_=e.configured===!0&&r.error===null;g.append(u(r,`mine`,!_||m||l),u(r,`run`,!_||m||l||f||r.caseCount===0),u(r,`cancel`,m||!l));let v=t(`span`,`bench-status`,(i?``:`Not connected to the server. Reconnecting.`)||d(e,r)||s.get(r.id)||``);if(v.setAttribute(`role`,`status`),g.append(v),c.append(g),r.error)return c.append(t(`p`,`bench-error`,r.error)),c;let y=r.latestReport;return y?(c.append(t(`p`,`bench-run-line`,`Latest run ${y.runId}: ${y.status}. Only cases every arm scored count toward paired recall.`)),y.rows.length>0&&c.append(p(y)),c):(c.append(t(`p`,`bench-empty`,r.caseCount===0?`Move approved candidates into the cases folder, then choose Run.`:`No run yet.`)),c)}function h(){if(!s)return;s.textContent=``;let{status:n}=a(),r=e(`bench`,`Benchmarks`,`Suites from the benchmarks folder of the Glimmervoid home, one run at a time.`);if(s.append(r),!n)s.append(t(`p`,`bench-empty`,`Waiting for the server.`));else if(!n.configured)s.append(t(`p`,`bench-empty`,n.reason||`Benchmarks are off.`));else if(n.suites.length===0)s.append(t(`p`,`bench-empty`,`No suites yet. Create a folder holding suite.json under benchmarks in the Glimmervoid home.`));else for(let e of n.suites)s.append(m(n,e))}function g(e){s||(s=t(`div`,`bench-content`),e.append(s),i(h),h())}var _={mount:g};export{_ as view};
@@ -1 +1 @@
1
- import{_ as e,o as t,s as n}from"./dom-helpers-C7P3_59O.js";import{ta as r,yi as i}from"./index-Cb2I6OyB.js";import{playToneSequence as a}from"./alert-sound-BpSLIB7B.js";var o=1.2,s=1.55,c=.12,l=523.25,u=2,d=8,f=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),p={melody:[f(7,4,.5),f(11,4.5,.5),f(12,5,3)],bass:[f(-5,4,1),f(-12,5,3)]},m=[{melody:[f(0,0,1),f(4,1,1),f(7,2,1),f(9,3,1)],bass:[f(-12,0,2),f(-8,2,2)]},{melody:[f(7,0,.67),f(7,.67,.67),f(7,1.33,.67),f(9,2,1),f(5,3,1)],bass:[f(-12,0,2),f(-7,2,2)]},{melody:[f(5,0,1),f(9,1,1),f(7,2,1),f(4,3,1)],bass:[f(-7,0,2),f(-12,2,2)]},{melody:[f(12,0,.5),f(7,.5,.5),f(12,1,.5),f(16,1.5,.5),f(16,2,1),f(14,3,1)],bass:[f(-12,0,2),f(-3,2,2)]},{melody:[f(4,0,1),f(7,1,1),f(4,2,.5),f(5,2.5,.5),f(7,3,.5),f(4,3.5,.5)],bass:[f(-8,0,2),f(-12,2,2)]}].map(e=>({melody:[...e.melody,...p.melody],bass:[...e.bass,...p.bass]}));function h(e,t){return l*2**((e+t)/12)}function g(e,t){let n=(e,n,r)=>e.map(e=>({frequency:h(e.semitone,t),startSeconds:s+e.startBeat*c,durationSeconds:e.beats*c,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var ee=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:o,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:o,durationSeconds:.06,waveform:`square`,gain:.12}];function te(e){let t=m[e%m.length],n=Math.min(e*u,d);return{peakGain:.1,tones:[...ee,...g(t,n)]}}function _(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function v(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function y(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var ne=.6,re=.25,ie=1.6;function ae(e){return Math.min(ne+e*re,ie)}var b=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function oe(e,t=Math.random){let n=v(320,520,t),r=v(1800,2800,t);return[[`--confetti-start-x`,`${v(4,96,t)}%`],[`--confetti-x`,`${v(-140,140,t)}px`],[`--confetti-rise`,`${-v(20,55,t)}px`],[`--confetti-fall`,`${v(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${v(0,180,t)}deg`],[`--confetti-spin`,`${v(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${v(160,340,t)}ms`],[`--confetti-delay`,`${v(0,160,t)}ms`],[`--confetti-color`,b[e%b.length]]]}var se=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,ce=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function le(){let e=n(`div`,`merge-bullseye-target`,se);return e.append(t(`span`,`merge-bullseye-ripple`)),e}function ue(){let e=t(`div`,`merge-bullseye-dart-drift`),r=t(`div`,`merge-bullseye-dart-arc`),i=t(`div`,`merge-bullseye-dart-aim`);return i.append(n(`div`,`merge-bullseye-dart`,ce)),r.append(i),e.append(r),e}function de(){let e=t(`div`,`merge-bullseye-range`),n=t(`div`,`merge-bullseye-track`);return n.append(ue()),e.append(le(),n),e}var fe={title:`BULLSEYE!`,buildScene:de},pe=6,x=30,S=-14,C=16;function w(e=Math.random){return[[`--crosshair-start-left`,`${v(pe,x,e)}%`],[`--crosshair-start-offset-y`,`${v(S,C,e)}px`]]}var T=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,E=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,D=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function O(){let r=t(`div`,`merge-headshot-sweep`);e(r,w());let i=t(`div`,`merge-headshot-aim`);i.append(n(`div`,`merge-headshot-crosshair`,E));let a=t(`div`,`merge-headshot-bob`);return a.append(i,n(`div`,`merge-headshot-hitmarker`,D)),r.append(a),r}function k(){let e=t(`div`,`merge-headshot-range`),r=t(`div`,`merge-headshot-track`);return r.append(O()),e.append(n(`div`,`merge-headshot-target`,T),r),e}var A={title:`HEADSHOT!`,buildScene:k},j=[`10`,`J`,`Q`,`K`,`A`],M=160,N=19,P=5,F=9,I=780,L=70,R=70,z=35;function B(e){let t=j.length-1,n=e-t/2;return{offsetPx:n*N,titleSpreadFraction:n/t,tiltDegrees:n*P,bottomPx:F-n**2,dealLeadMs:I-e*L,flipLeadMs:M+(t-e)*R,waveDelayMs:e*z}}function me(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function he(){return[[`--card-flip-ms`,`${M}ms`]]}var ge=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function _e(n,r){let i=t(`div`,`merge-flush-deal`);e(i,me(B(r)));let a=t(`div`,`merge-flush-hop`),o=t(`div`,`merge-flush-card`),s=t(`div`,`merge-flush-face`);return s.append(t(`span`,`merge-flush-rank`,n)),s.insertAdjacentHTML(`beforeend`,ge),o.append(t(`div`,`merge-flush-back`),s),a.append(o),i.append(a),i}function ve(){let n=t(`div`,`merge-flush-table`);return e(n,he()),n.append(...j.map(_e)),n}var ye={title:`ROYAL FLUSH!`,buildScene:ve},be=[1,2,3,4],xe=14,Se=3,Ce=3,V=10,we=20,Te=2,H=28,U=18,Ee=.01,De=1.5,Oe=2200,ke=1,W=120,G=.35,Ae=15,je=105,Me=4,Ne=65,Pe=145;function Fe(e){return Math.round(e/(Math.PI*U)*360)}function K(e){return we-e*Te}function q(e){return e.rowIndex*xe+e.depthIndex*Se}function J(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function Y(){return be.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function Ie(e,t){let n=y(J(Ae,je,e),t),r=y(J(Ne,Pe,e),t);return n.map((e,n)=>({angleDegrees:e+v(-4,Me,t),depthScalePercent:Math.round(r[n])}))}function Le(e,t,n){let r=v(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=v(15,45,n),c=_(o),l=_(o+s),u=c+l,d=v(540,1080,n),f=a>=0?1:-1,p=q(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:K(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/G)}}function Re(e=Math.random){let t=Y(),n=Ie(t.length,e);return t.map((t,r)=>Le(t,n[r],e))}function ze(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*Ce}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function Be(){return K(De)}function Ve(){return Math.max(...Y().map(q))+V}function He(){let e=Ve(),t=H+e+U-ke;return[[`--ball-follow-px`,`${W}px`],[`--ball-follow-ms`,`${Math.round(W/G)}ms`],[`--ball-follow-spin`,`${Fe(W)}deg`],[`--ball-size`,`${U}px`],[`--ball-approach-spin`,`${Oe}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(Be())],[`--rack-right`,`${H}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${V}px`]]}function Ue(e=Math.random){return e()>=Ee?null:r[Math.floor(e()*r.length)].sprite}var We=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function Ge(r){let i=t(`span`,`merge-strike-pin`);return i.append(n(`span`,`merge-strike-pin-arc`,We)),e(i,ze(r)),i}function Ke(){let e=Ue();if(!e)return t(`span`,`merge-strike-ball`);let n=t(`span`,`merge-strike-ball is-animal`);return n.append(t(`span`,`nyan-sprite ${e}`)),n}function qe(){let n=t(`div`,`merge-strike-lane`);e(n,He());let r=t(`div`,`merge-strike-rack`);r.append(...Re().map(Ge));let i=t(`div`,`merge-strike-track`);return i.append(Ke()),n.append(r,i),n}var Je={title:`STRIKE!`,buildScene:qe},Ye=20,Xe=92,Ze=23,Qe=7,$e=-40;function et(){let e=_(72),t=_(69),n=780*t/1e3;return{launchHeightPx:Ye,peakHeightPx:Xe,heightThroughRimPx:Ze,heightLeavingNetPx:Qe,heightOutOfCardPx:$e,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:_(47)}}function tt(e=et()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var nt=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,rt=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function it(){let e=t(`div`,`merge-swish-ball-drift`),n=t(`div`,`merge-swish-ball-arc`);return n.append(t(`span`,`merge-swish-ball`)),e.append(n),e}function X(){let r=t(`div`,`merge-swish-court`);e(r,tt());let i=t(`div`,`merge-swish-track`);return i.append(it()),r.append(n(`div`,`merge-swish-hoop-back`,nt),i,n(`div`,`merge-swish-hoop-front`,rt)),r}var Z=[Je,{title:`SWISH!`,buildScene:X},fe,A,ye],at=48,Q=5600,$=null;function ot(n){let r=t(`span`,`merge-confetti-piece`),i=t(`span`,`merge-confetti-arc`);return i.append(t(`span`,`merge-confetti-paper`)),r.append(i),e(r,oe(n)),r}function st(e){let n=t(`p`,`merge-celebration-title`);return n.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,r)=>{let i=t(`span`,`merge-celebration-letter`,e);i.style.setProperty(`--letter-delay`,`${r*45}ms`),n.append(i)}),n}function ct(e,t,n){let r=t.firstElementChild,i=t.lastElementChild;r instanceof HTMLElement&&i instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${i.offsetLeft+i.offsetWidth-r.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2-n.offsetTop}px`))}function lt(e){let n=t(`div`,`merge-celebration-scene`);return n.setAttribute(`aria-hidden`,`true`),n.append(e.buildScene()),n}function ut(){return Z[Math.floor(Math.random()*Z.length)]}function dt(e){if(i())try{a(te(e))}catch{}}function ft(e){let n=t(`ul`,`merge-celebration-details`);for(let r of e)n.append(t(`li`,`merge-celebration-detail`,r));return n}function pt(e,n){let r=ut();$?.remove(),dt(n);let i=t(`div`,`merge-celebration`);i.setAttribute(`role`,`status`);let a=t(`div`,`merge-celebration-card`),o=t(`div`,`merge-celebration-stage`),s=st(r.title),c=lt(r);o.append(s,t(`p`,`merge-celebration-message`,e.message),ft(e.detailLines),c);let l=t(`div`,`merge-confetti`);l.style.setProperty(`--confetti-scale`,String(ae(n)));for(let e=0;e<at;e+=1)l.append(ot(e));a.append(l,o),i.append(a),document.body.append(i),ct(o,s,c),$=i,window.setTimeout(()=>{i.remove(),$===i&&($=null)},Q)}export{Q as CELEBRATION_DURATION_MS,pt as playCelebration};
1
+ import{_ as e,o as t,s as n}from"./dom-helpers-C7P3_59O.js";import{ta as r,yi as i}from"./index-DnNiYw2m.js";import{playToneSequence as a}from"./alert-sound-CzrfUQrG.js";var o=1.2,s=1.55,c=.12,l=523.25,u=2,d=8,f=(e,t,n)=>({semitone:e,startBeat:t,beats:n}),p={melody:[f(7,4,.5),f(11,4.5,.5),f(12,5,3)],bass:[f(-5,4,1),f(-12,5,3)]},m=[{melody:[f(0,0,1),f(4,1,1),f(7,2,1),f(9,3,1)],bass:[f(-12,0,2),f(-8,2,2)]},{melody:[f(7,0,.67),f(7,.67,.67),f(7,1.33,.67),f(9,2,1),f(5,3,1)],bass:[f(-12,0,2),f(-7,2,2)]},{melody:[f(5,0,1),f(9,1,1),f(7,2,1),f(4,3,1)],bass:[f(-7,0,2),f(-12,2,2)]},{melody:[f(12,0,.5),f(7,.5,.5),f(12,1,.5),f(16,1.5,.5),f(16,2,1),f(14,3,1)],bass:[f(-12,0,2),f(-3,2,2)]},{melody:[f(4,0,1),f(7,1,1),f(4,2,.5),f(5,2.5,.5),f(7,3,.5),f(4,3.5,.5)],bass:[f(-8,0,2),f(-12,2,2)]}].map(e=>({melody:[...e.melody,...p.melody],bass:[...e.bass,...p.bass]}));function h(e,t){return l*2**((e+t)/12)}function g(e,t){let n=(e,n,r)=>e.map(e=>({frequency:h(e.semitone,t),startSeconds:s+e.startBeat*c,durationSeconds:e.beats*c,waveform:n,gain:r}));return[...n(e.melody,`square`,.2),...n(e.melody,`triangle`,.5),...n(e.bass,`triangle`,.6)]}var ee=[{frequency:220,endFrequency:880,startSeconds:0,durationSeconds:.32,waveform:`triangle`,gain:.25},{frequency:160,endFrequency:45,startSeconds:o,durationSeconds:.28,waveform:`sine`,gain:1},{frequency:1400,endFrequency:380,startSeconds:o,durationSeconds:.06,waveform:`square`,gain:.12}];function te(e){let t=m[e%m.length],n=Math.min(e*u,d);return{peakGain:.1,tones:[...ee,...g(t,n)]}}function _(e){return Math.round(Math.sqrt(2*e/780)*1e3)}function v(e,t,n=Math.random){return Math.round(e+n()*(t-e))}function y(e,t=Math.random){let n=[...e];for(let e=n.length-1;e>0;--e){let r=Math.floor(t()*(e+1));[n[e],n[r]]=[n[r],n[e]]}return n}var ne=.6,re=.25,ie=1.6;function ae(e){return Math.min(ne+e*re,ie)}var b=[`var(--accent)`,`var(--state-running)`,`var(--state-idle)`,`var(--state-waiting)`,`var(--state-failed)`];function oe(e,t=Math.random){let n=v(320,520,t),r=v(1800,2800,t);return[[`--confetti-start-x`,`${v(4,96,t)}%`],[`--confetti-x`,`${v(-140,140,t)}px`],[`--confetti-rise`,`${-v(20,55,t)}px`],[`--confetti-fall`,`${v(45,70,t)}vh`],[`--confetti-rise-ms`,`${n}ms`],[`--confetti-fall-ms`,`${r}ms`],[`--confetti-flight-ms`,`${n+r}ms`],[`--confetti-tilt`,`${v(0,180,t)}deg`],[`--confetti-spin`,`${v(-360,360,t)}deg`],[`--confetti-flutter-ms`,`${v(160,340,t)}ms`],[`--confetti-delay`,`${v(0,160,t)}ms`],[`--confetti-color`,b[e%b.length]]]}var se=`<svg viewBox="0 0 36 36" aria-hidden="true"><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="17"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="13"/><circle class="merge-bullseye-ring-light" cx="18" cy="18" r="9"/><circle class="merge-bullseye-ring-red" cx="18" cy="18" r="5"/></svg>`,ce=`<svg viewBox="0 0 26 8" aria-hidden="true"><path class="merge-bullseye-dart-flight" d="M0 0L7 3V5L0 8L2 4Z"/><rect class="merge-bullseye-dart-shaft" x="6" y="3.3" width="8" height="1.4"/><rect class="merge-bullseye-dart-barrel" x="13" y="2.5" width="7" height="3" rx="1"/><path class="merge-bullseye-dart-tip" d="M20 3L26 4L20 5Z"/></svg>`;function le(){let e=n(`div`,`merge-bullseye-target`,se);return e.append(t(`span`,`merge-bullseye-ripple`)),e}function ue(){let e=t(`div`,`merge-bullseye-dart-drift`),r=t(`div`,`merge-bullseye-dart-arc`),i=t(`div`,`merge-bullseye-dart-aim`);return i.append(n(`div`,`merge-bullseye-dart`,ce)),r.append(i),e.append(r),e}function de(){let e=t(`div`,`merge-bullseye-range`),n=t(`div`,`merge-bullseye-track`);return n.append(ue()),e.append(le(),n),e}var fe={title:`BULLSEYE!`,buildScene:de},pe=6,x=30,S=-14,C=16;function w(e=Math.random){return[[`--crosshair-start-left`,`${v(pe,x,e)}%`],[`--crosshair-start-offset-y`,`${v(S,C,e)}px`]]}var T=`<svg viewBox="0 0 26 40" aria-hidden="true"><path class="merge-headshot-target-body" d="M9 13H17L18 16Q25 18 25 24V40H1V24Q1 18 8 16Z"/><circle class="merge-headshot-target-head" cx="13" cy="7" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="7" r="3"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="6"/><circle class="merge-headshot-target-ring" cx="13" cy="27" r="2.5"/></svg>`,E=`<svg viewBox="0 0 22 22" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M11 0V5M11 17V22M0 11H5M17 11H22"/><circle class="merge-headshot-crosshair-dot" cx="11" cy="11" r="1"/></svg>`,D=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 3L8 8M21 3L16 8M3 21L8 16M21 21L16 16"/></svg>`;function O(){let r=t(`div`,`merge-headshot-sweep`);e(r,w());let i=t(`div`,`merge-headshot-aim`);i.append(n(`div`,`merge-headshot-crosshair`,E));let a=t(`div`,`merge-headshot-bob`);return a.append(i,n(`div`,`merge-headshot-hitmarker`,D)),r.append(a),r}function k(){let e=t(`div`,`merge-headshot-range`),r=t(`div`,`merge-headshot-track`);return r.append(O()),e.append(n(`div`,`merge-headshot-target`,T),r),e}var A={title:`HEADSHOT!`,buildScene:k},j=[`10`,`J`,`Q`,`K`,`A`],M=160,N=19,P=5,F=9,I=780,L=70,R=70,z=35;function B(e){let t=j.length-1,n=e-t/2;return{offsetPx:n*N,titleSpreadFraction:n/t,tiltDegrees:n*P,bottomPx:F-n**2,dealLeadMs:I-e*L,flipLeadMs:M+(t-e)*R,waveDelayMs:e*z}}function me(e){return[[`--card-offset`,`${e.offsetPx}px`],[`--card-title-spread`,String(e.titleSpreadFraction)],[`--card-tilt`,`${e.tiltDegrees}deg`],[`--card-bottom`,`${e.bottomPx}px`],[`--card-deal-lead-ms`,`${e.dealLeadMs}ms`],[`--card-flip-lead-ms`,`${e.flipLeadMs}ms`],[`--card-wave-delay-ms`,`${e.waveDelayMs}ms`]]}function he(){return[[`--card-flip-ms`,`${M}ms`]]}var ge=`<svg viewBox="0 0 10 9" aria-hidden="true"><path d="M5 8.5C5 8.5 0 5.3 0 2.6C0 1.1 1.2 0 2.6 0C3.6 0 4.5 .6 5 1.4C5.5 .6 6.4 0 7.4 0C8.8 0 10 1.1 10 2.6C10 5.3 5 8.5 5 8.5Z"/></svg>`;function _e(n,r){let i=t(`div`,`merge-flush-deal`);e(i,me(B(r)));let a=t(`div`,`merge-flush-hop`),o=t(`div`,`merge-flush-card`),s=t(`div`,`merge-flush-face`);return s.append(t(`span`,`merge-flush-rank`,n)),s.insertAdjacentHTML(`beforeend`,ge),o.append(t(`div`,`merge-flush-back`),s),a.append(o),i.append(a),i}function ve(){let n=t(`div`,`merge-flush-table`);return e(n,he()),n.append(...j.map(_e)),n}var ye={title:`ROYAL FLUSH!`,buildScene:ve},be=[1,2,3,4],xe=14,Se=3,Ce=3,V=10,we=20,Te=2,H=28,U=18,Ee=.01,De=1.5,Oe=2200,ke=1,W=120,G=.35,Ae=15,je=105,Me=4,Ne=65,Pe=145;function Fe(e){return Math.round(e/(Math.PI*U)*360)}function K(e){return we-e*Te}function q(e){return e.rowIndex*xe+e.depthIndex*Se}function J(e,t,n){return Array.from({length:n},(r,i)=>e+(t-e)*i/(n-1))}function Y(){return be.flatMap((e,t)=>Array.from({length:e},(n,r)=>({rowIndex:t,depthIndex:e-1-r})))}function Ie(e,t){let n=y(J(Ae,je,e),t),r=y(J(Ne,Pe,e),t);return n.map((e,n)=>({angleDegrees:e+v(-4,Me,t),depthScalePercent:Math.round(r[n])}))}function Le(e,t,n){let r=v(240,380,n),i=t.angleDegrees*Math.PI/180,a=r*Math.cos(i),o=(r*Math.sin(i))**2/1560,s=v(15,45,n),c=_(o),l=_(o+s),u=c+l,d=v(540,1080,n),f=a>=0?1:-1,p=q(e);return{depthIndex:e.depthIndex,launchAngleDegrees:t.angleDegrees,distanceFromHeadPinPx:p,layer:K(e.depthIndex),flyXPx:Math.round(a*u/1e3),peakRisePx:Math.round(o),landingDropPx:s,riseMs:c,fallMs:l,flightMs:u,spinDegrees:Math.round(f*d*u/1e3),glintMs:Math.round(180/d*1e3),depthScalePercent:t.depthScalePercent,delayMs:Math.round(p/G)}}function Re(e=Math.random){let t=Y(),n=Ie(t.length,e);return t.map((t,r)=>Le(t,n[r],e))}function ze(e){return[[`--pin-left`,`${e.distanceFromHeadPinPx}px`],[`--pin-raise`,`${e.depthIndex*Ce}px`],[`--pin-shade`,`${100-e.depthIndex*12}%`],[`--pin-fly-x`,`${e.flyXPx}px`],[`--pin-peak-y`,`${-e.peakRisePx}px`],[`--pin-land-y`,`${e.landingDropPx}px`],[`--pin-rise-ms`,`${e.riseMs}ms`],[`--pin-fall-ms`,`${e.fallMs}ms`],[`--pin-flight-ms`,`${e.flightMs}ms`],[`--pin-spin`,`${e.spinDegrees}deg`],[`--pin-glint-ms`,`${e.glintMs}ms`],[`--pin-depth-scale`,`${e.depthScalePercent}%`],[`--pin-depth-shade`,`${e.depthScalePercent-10}%`],[`--pin-delay`,`${e.delayMs}ms`],[`--pin-layer`,String(e.layer)]]}function Be(){return K(De)}function Ve(){return Math.max(...Y().map(q))+V}function He(){let e=Ve(),t=H+e+U-ke;return[[`--ball-follow-px`,`${W}px`],[`--ball-follow-ms`,`${Math.round(W/G)}ms`],[`--ball-follow-spin`,`${Fe(W)}deg`],[`--ball-size`,`${U}px`],[`--ball-approach-spin`,`${Oe}deg`],[`--ball-impact-inset`,`${t}px`],[`--ball-layer`,String(Be())],[`--rack-right`,`${H}px`],[`--rack-width`,`${e}px`],[`--pin-width`,`${V}px`]]}function Ue(e=Math.random){return e()>=Ee?null:r[Math.floor(e()*r.length)].sprite}var We=`<svg viewBox="0 0 10 24" aria-hidden="true"><path class="merge-strike-pin-body" d="M5 0C7 0 7.6 2 7.2 4C6.9 5.6 6.3 6.6 6.4 8C6.6 10 9.6 12 9.6 16C9.6 19.5 8.4 22 7.6 24H2.4C1.6 22 .4 19.5 .4 16C.4 12 3.4 10 3.6 8C3.7 6.6 3.1 5.6 2.8 4C2.4 2 3 0 5 0Z"/><path class="merge-strike-pin-stripe" d="M3.1 5.2H6.9V6.2H3.1ZM3.4 7H6.6V8H3.4Z"/></svg>`;function Ge(r){let i=t(`span`,`merge-strike-pin`);return i.append(n(`span`,`merge-strike-pin-arc`,We)),e(i,ze(r)),i}function Ke(){let e=Ue();if(!e)return t(`span`,`merge-strike-ball`);let n=t(`span`,`merge-strike-ball is-animal`);return n.append(t(`span`,`nyan-sprite ${e}`)),n}function qe(){let n=t(`div`,`merge-strike-lane`);e(n,He());let r=t(`div`,`merge-strike-rack`);r.append(...Re().map(Ge));let i=t(`div`,`merge-strike-track`);return i.append(Ke()),n.append(r,i),n}var Je={title:`STRIKE!`,buildScene:qe},Ye=20,Xe=92,Ze=23,Qe=7,$e=-40;function et(){let e=_(72),t=_(69),n=780*t/1e3;return{launchHeightPx:Ye,peakHeightPx:Xe,heightThroughRimPx:Ze,heightLeavingNetPx:Qe,heightOutOfCardPx:$e,riseMs:e,fallToRimMs:t,speedThroughRimPxPerSecond:n,netCatchMs:Math.round(32/n*1e3),dropMs:_(47)}}function tt(e=et()){return[[`--ball-launch-y`,`${-e.launchHeightPx}px`],[`--ball-peak-y`,`${-e.peakHeightPx}px`],[`--ball-rim-y`,`${-e.heightThroughRimPx}px`],[`--ball-net-exit-y`,`${-e.heightLeavingNetPx}px`],[`--ball-drop-out-y`,`${-e.heightOutOfCardPx}px`],[`--ball-rise-ms`,`${e.riseMs}ms`],[`--ball-fall-to-rim-ms`,`${e.fallToRimMs}ms`],[`--ball-to-rim-ms`,`${e.riseMs+e.fallToRimMs}ms`],[`--ball-net-catch-ms`,`${e.netCatchMs}ms`],[`--ball-drop-ms`,`${e.dropMs}ms`]]}var nt=`<svg viewBox="0 0 40 48" aria-hidden="true"><rect class="merge-swish-pole" x="36" y="28" width="2" height="20"/><rect class="merge-swish-backboard" x="35" y="2" width="3" height="26" rx="1"/><path class="merge-swish-rim" d="M31 18H35M7 18A12 2.5 0 0 1 31 18"/></svg>`,rt=`<svg viewBox="0 0 40 48" aria-hidden="true"><g class="merge-swish-net"><path d="M8 18L12 32M13.5 18L15.5 32M19 18V32M24.5 18L22.5 32M30 18L26 32M9.5 23Q19 25 28.5 23M11 28Q19 29.5 27 28"/></g><path class="merge-swish-rim" d="M7 18A12 2.5 0 0 0 31 18"/></svg>`;function it(){let e=t(`div`,`merge-swish-ball-drift`),n=t(`div`,`merge-swish-ball-arc`);return n.append(t(`span`,`merge-swish-ball`)),e.append(n),e}function X(){let r=t(`div`,`merge-swish-court`);e(r,tt());let i=t(`div`,`merge-swish-track`);return i.append(it()),r.append(n(`div`,`merge-swish-hoop-back`,nt),i,n(`div`,`merge-swish-hoop-front`,rt)),r}var Z=[Je,{title:`SWISH!`,buildScene:X},fe,A,ye],at=48,Q=5600,$=null;function ot(n){let r=t(`span`,`merge-confetti-piece`),i=t(`span`,`merge-confetti-arc`);return i.append(t(`span`,`merge-confetti-paper`)),r.append(i),e(r,oe(n)),r}function st(e){let n=t(`p`,`merge-celebration-title`);return n.setAttribute(`aria-hidden`,`true`),Array.from(e).forEach((e,r)=>{let i=t(`span`,`merge-celebration-letter`,e);i.style.setProperty(`--letter-delay`,`${r*45}ms`),n.append(i)}),n}function ct(e,t,n){let r=t.firstElementChild,i=t.lastElementChild;r instanceof HTMLElement&&i instanceof HTMLElement&&(e.style.setProperty(`--celebration-title-width`,`${i.offsetLeft+i.offsetWidth-r.offsetLeft}px`),e.style.setProperty(`--celebration-title-center-y`,`${t.offsetTop+t.offsetHeight/2-n.offsetTop}px`))}function lt(e){let n=t(`div`,`merge-celebration-scene`);return n.setAttribute(`aria-hidden`,`true`),n.append(e.buildScene()),n}function ut(){return Z[Math.floor(Math.random()*Z.length)]}function dt(e){if(i())try{a(te(e))}catch{}}function ft(e){let n=t(`ul`,`merge-celebration-details`);for(let r of e)n.append(t(`li`,`merge-celebration-detail`,r));return n}function pt(e,n){let r=ut();$?.remove(),dt(n);let i=t(`div`,`merge-celebration`);i.setAttribute(`role`,`status`);let a=t(`div`,`merge-celebration-card`),o=t(`div`,`merge-celebration-stage`),s=st(r.title),c=lt(r);o.append(s,t(`p`,`merge-celebration-message`,e.message),ft(e.detailLines),c);let l=t(`div`,`merge-confetti`);l.style.setProperty(`--confetti-scale`,String(ae(n)));for(let e=0;e<at;e+=1)l.append(ot(e));a.append(l,o),i.append(a),document.body.append(i),ct(o,s,c),$=i,window.setTimeout(()=>{i.remove(),$===i&&($=null)},Q)}export{Q as CELEBRATION_DURATION_MS,pt as playCelebration};
@@ -1,4 +1,4 @@
1
- import{G as e,U as t,W as n,dt as r,ft as i,x as a}from"./updates-view-core-D1HrhoS5.js";import{h as o,m as s,o as c}from"./dom-helpers-C7P3_59O.js";import{d as l}from"./control-ws-H2e01_5q.js";import{n as u,r as d,t as f}from"./modal-Bh-cVr-I.js";import{n as p}from"./session-tick-D3Nw7wV5.js";import{Br as m,Lr as h,Rr as g,Tn as _,ii as v,m as y,ni as b,ri as x,ur as S,vr as C,yr as w}from"./index-Cb2I6OyB.js";import{d as T,l as E,t as D,u as ee}from"./repo-roots-adder-Blxoifau.js";import{t as O}from"./sandboxed-frame-C5WnwN5w.js";var te=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
1
+ import{G as e,U as t,W as n,dt as r,ft as i,x as a}from"./updates-view-core-D1HrhoS5.js";import{h as o,m as s,o as c}from"./dom-helpers-C7P3_59O.js";import{d as l}from"./control-ws-H2e01_5q.js";import{n as u,r as d,t as f}from"./modal-Bh-cVr-I.js";import{n as p}from"./session-tick-D3Nw7wV5.js";import{Br as m,Lr as h,Rr as g,Tn as _,ii as v,m as y,ni as b,ri as x,ur as S,vr as C,yr as w}from"./index-DnNiYw2m.js";import{d as T,l as E,t as D,u as ee}from"./repo-roots-adder-Blxoifau.js";import{t as O}from"./sandboxed-frame-C5WnwN5w.js";var te=`<h2 class="dialog-title" id="add-session-title">Add Session</h2>
2
2
  <fieldset class="dialog-mode-controls" aria-label="Session kind">
3
3
  <button type="button" class="dialog-mode-button" id="add-session-single-mode" aria-pressed="true">Single repo</button>
4
4
  <button type="button" class="dialog-mode-button" id="add-session-workspace-mode" aria-pressed="false">Workspace</button>
@@ -1 +1 @@
1
- import{o as e}from"./dom-helpers-C7P3_59O.js";import{d as t}from"./control-ws-H2e01_5q.js";import{a as n,r,t as i}from"./modal-Bh-cVr-I.js";import{Br as a,Lr as o,ei as s,pn as c}from"./index-Cb2I6OyB.js";import{i as l,t as u}from"./plan-render-Booa3Bo-.js";var d=null;function f(t){let n=s(t.sessionId);t.select.replaceChildren(...n.map(n=>{let r=e(`option`,null,n.name);return r.value=n.path,r.selected=n.path===t.docPath,r})),t.select.hidden=n.length<2,t.title.textContent=n.find(e=>e.path===t.docPath)?.name??t.title.textContent}function p(e){let t=s(e.sessionId).some(t=>t.path===e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges}function m(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function h(e){e.preview.replaceChildren(u(l(e.textarea.value)))}function g(e,t){n({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function _(e,t,n){e.hasUnsavedChanges?g(t,n):n()}async function v(e,n){try{return{reply:await t(e,n,{timeoutMs:o}),failureText:null}}catch(e){return{reply:null,failureText:a(e,o)}}}async function y(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,f(e),m(e,`Loading`),p(e);let{reply:n,failureText:r}=await v(`session-doc-read`,{id:e.sessionId,path:t});if(d!==e||e.docPath!==t)return;e.isBusy=!1,e.textarea.readOnly=!1;let i=n?.type===`session-doc-response`?n:null;!i?.ok||i.text===void 0||i.hash===void 0?(m(e,i?.error||r||`Could not open this doc`,`warn`),p(e)):(e.textarea.value=i.text,e.baseHash=i.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&h(e),m(e,``),p(e))}async function b(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,m(e,`Saving`),p(e);let t=e.docPath,n=e.textarea.value,{reply:r,failureText:i}=await v(`session-doc-save`,{id:e.sessionId,path:t,text:n,baseHash:e.baseHash});if(d!==e||e.docPath!==t)return;e.isBusy=!1;let a=r?.type===`session-doc-save-result`?r:null;!a?.ok||a.hash===void 0?(m(e,a?.conflict?`The agent changed this file since you opened it. Reload to see its version.`:a?.error||i||`Save failed`,`warn`),p(e)):(e.baseHash=a.hash,e.hasUnsavedChanges=e.textarea.value!==n,m(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),p(e))}function x(e,t){e.mode=t,t===`preview`&&h(e),p(e),t===`edit`&&e.textarea.focus()}function S(t,n){let r=e(`button`,`plan-control ${n}`,t);return r.type=`button`,r}function C(t){let n=s(t)[0];if(!n||d)return;let a=()=>_(M,`Close this doc?`,()=>M.close()),o=r({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:a}),l=`doc-editor-title-${t}`,u=e(`h3`,`doc-editor-title`,n.name);u.id=l;let f=e(`select`,`plan-control doc-editor-picker`);f.setAttribute(`aria-label`,`Doc`);let h=e(`span`,`doc-editor-status`);h.setAttribute(`role`,`status`);let g=S(`Edit`,`doc-editor-mode`),v=S(`Preview`,`doc-editor-mode`),C=S(`Reload`,`doc-editor-reload`),w=S(`Save`,`doc-editor-save`),T=S(`Close`,`doc-editor-close`),E=e(`div`,`doc-editor-modes`);E.append(g,v);let D=e(`div`,`doc-editor-actions`);D.append(h,C,w,T);let O=e(`div`,`doc-editor-header`);O.append(u,f,E,D);let k=e(`textarea`,`plan-editor doc-editor-text`);k.spellcheck=!0,k.setAttribute(`aria-labelledby`,l);let A=e(`div`,`doc-editor-preview`),j=e(`div`,`doc-editor-body`);j.append(k,A),o.dialog.append(O,j),i(o.dialog,l);let M={sessionId:t,docPath:n.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:c()?`preview`:`edit`,title:u,select:f,textarea:k,preview:A,status:h,btnEdit:g,btnPreview:v,btnReload:C,btnSave:w,close:()=>{d=null,o.close()}};d=M,k.addEventListener(`input`,()=>{M.hasUnsavedChanges||(M.hasUnsavedChanges=!0,m(M,`Unsaved changes`),p(M))}),k.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),b(M))}),f.addEventListener(`change`,()=>{let e=f.value;f.value=M.docPath,_(M,`Open another doc?`,()=>{y(M,e)})}),g.addEventListener(`click`,()=>x(M,`edit`)),v.addEventListener(`click`,()=>x(M,`preview`)),C.addEventListener(`click`,()=>{_(M,`Reload this doc?`,()=>{y(M,M.docPath)})}),w.addEventListener(`click`,()=>{b(M)}),T.addEventListener(`click`,a),y(M,n.path),M.mode===`edit`&&k.focus()}function w(e){d&&d.sessionId===e&&(f(d),p(d),!s(e).some(e=>e.path===d?.docPath)&&m(d,`This doc is no longer surfaced, so it cannot be saved.`,`warn`))}export{w as applyDocsToOpenEditor,C as openDocEditor};
1
+ import{o as e}from"./dom-helpers-C7P3_59O.js";import{d as t}from"./control-ws-H2e01_5q.js";import{a as n,r,t as i}from"./modal-Bh-cVr-I.js";import{Br as a,Lr as o,ei as s,pn as c}from"./index-DnNiYw2m.js";import{i as l,t as u}from"./plan-render-Dc5BL45f.js";var d=null;function f(t){let n=s(t.sessionId);t.select.replaceChildren(...n.map(n=>{let r=e(`option`,null,n.name);return r.value=n.path,r.selected=n.path===t.docPath,r})),t.select.hidden=n.length<2,t.title.textContent=n.find(e=>e.path===t.docPath)?.name??t.title.textContent}function p(e){let t=s(e.sessionId).some(t=>t.path===e.docPath);e.btnEdit.setAttribute(`aria-pressed`,String(e.mode===`edit`)),e.btnPreview.setAttribute(`aria-pressed`,String(e.mode===`preview`)),e.textarea.hidden=e.mode!==`edit`,e.preview.hidden=e.mode!==`preview`,e.select.disabled=e.isBusy,e.btnReload.disabled=e.isBusy||!t,e.btnSave.disabled=e.isBusy||!t||e.baseHash===null||!e.hasUnsavedChanges}function m(e,t,n=`quiet`){e.status.textContent=t,e.status.dataset.tone=n}function h(e){e.preview.replaceChildren(u(l(e.textarea.value)))}function g(e,t){n({title:e,message:`Your unsaved edits will be lost.`,confirmLabel:`Discard`,danger:!0,onConfirm:t})}function _(e,t,n){e.hasUnsavedChanges?g(t,n):n()}async function v(e,n){try{return{reply:await t(e,n,{timeoutMs:o}),failureText:null}}catch(e){return{reply:null,failureText:a(e,o)}}}async function y(e,t){e.docPath=t,e.isBusy=!0,e.baseHash=null,e.textarea.readOnly=!0,f(e),m(e,`Loading`),p(e);let{reply:n,failureText:r}=await v(`session-doc-read`,{id:e.sessionId,path:t});if(d!==e||e.docPath!==t)return;e.isBusy=!1,e.textarea.readOnly=!1;let i=n?.type===`session-doc-response`?n:null;!i?.ok||i.text===void 0||i.hash===void 0?(m(e,i?.error||r||`Could not open this doc`,`warn`),p(e)):(e.textarea.value=i.text,e.baseHash=i.hash,e.hasUnsavedChanges=!1,e.mode===`preview`&&h(e),m(e,``),p(e))}async function b(e){if(e.btnSave.disabled||e.baseHash===null)return;e.isBusy=!0,m(e,`Saving`),p(e);let t=e.docPath,n=e.textarea.value,{reply:r,failureText:i}=await v(`session-doc-save`,{id:e.sessionId,path:t,text:n,baseHash:e.baseHash});if(d!==e||e.docPath!==t)return;e.isBusy=!1;let a=r?.type===`session-doc-save-result`?r:null;!a?.ok||a.hash===void 0?(m(e,a?.conflict?`The agent changed this file since you opened it. Reload to see its version.`:a?.error||i||`Save failed`,`warn`),p(e)):(e.baseHash=a.hash,e.hasUnsavedChanges=e.textarea.value!==n,m(e,e.hasUnsavedChanges?`Unsaved changes`:`Saved`),p(e))}function x(e,t){e.mode=t,t===`preview`&&h(e),p(e),t===`edit`&&e.textarea.focus()}function S(t,n){let r=e(`button`,`plan-control ${n}`,t);return r.type=`button`,r}function C(t){let n=s(t)[0];if(!n||d)return;let a=()=>_(M,`Close this doc?`,()=>M.close()),o=r({dialogClass:`doc-editor`,closeOnBackdrop:!1,onEscape:a}),l=`doc-editor-title-${t}`,u=e(`h3`,`doc-editor-title`,n.name);u.id=l;let f=e(`select`,`plan-control doc-editor-picker`);f.setAttribute(`aria-label`,`Doc`);let h=e(`span`,`doc-editor-status`);h.setAttribute(`role`,`status`);let g=S(`Edit`,`doc-editor-mode`),v=S(`Preview`,`doc-editor-mode`),C=S(`Reload`,`doc-editor-reload`),w=S(`Save`,`doc-editor-save`),T=S(`Close`,`doc-editor-close`),E=e(`div`,`doc-editor-modes`);E.append(g,v);let D=e(`div`,`doc-editor-actions`);D.append(h,C,w,T);let O=e(`div`,`doc-editor-header`);O.append(u,f,E,D);let k=e(`textarea`,`plan-editor doc-editor-text`);k.spellcheck=!0,k.setAttribute(`aria-labelledby`,l);let A=e(`div`,`doc-editor-preview`),j=e(`div`,`doc-editor-body`);j.append(k,A),o.dialog.append(O,j),i(o.dialog,l);let M={sessionId:t,docPath:n.path,baseHash:null,hasUnsavedChanges:!1,isBusy:!1,mode:c()?`preview`:`edit`,title:u,select:f,textarea:k,preview:A,status:h,btnEdit:g,btnPreview:v,btnReload:C,btnSave:w,close:()=>{d=null,o.close()}};d=M,k.addEventListener(`input`,()=>{M.hasUnsavedChanges||(M.hasUnsavedChanges=!0,m(M,`Unsaved changes`),p(M))}),k.addEventListener(`keydown`,e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),b(M))}),f.addEventListener(`change`,()=>{let e=f.value;f.value=M.docPath,_(M,`Open another doc?`,()=>{y(M,e)})}),g.addEventListener(`click`,()=>x(M,`edit`)),v.addEventListener(`click`,()=>x(M,`preview`)),C.addEventListener(`click`,()=>{_(M,`Reload this doc?`,()=>{y(M,M.docPath)})}),w.addEventListener(`click`,()=>{b(M)}),T.addEventListener(`click`,a),y(M,n.path),M.mode===`edit`&&k.focus()}function w(e){d&&d.sessionId===e&&(f(d),p(d),!s(e).some(e=>e.path===d?.docPath)&&m(d,`This doc is no longer surfaced, so it cannot be saved.`,`warn`))}export{w as applyDocsToOpenEditor,C as openDocEditor};