@yorz/cli 0.5.1 → 0.6.0

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 (73) hide show
  1. package/dist/cli/index.js +312 -26
  2. package/dist/gui/assets/{abnfDiagram-VRR7QNED-1dYBKtgk.js → abnfDiagram-VRR7QNED-CpQSXKD3.js} +1 -1
  3. package/dist/gui/assets/{arc-OAvgDu2T.js → arc-BFSj3oux.js} +1 -1
  4. package/dist/gui/assets/{architectureDiagram-ZJ3FMSHR-DjLIXpVy.js → architectureDiagram-ZJ3FMSHR-DUUbTneR.js} +1 -1
  5. package/dist/gui/assets/{blockDiagram-677ZJIJ3-vDgSpIYO.js → blockDiagram-677ZJIJ3-b_cB7_jE.js} +1 -1
  6. package/dist/gui/assets/{c4Diagram-LMCZKHZV-CfqG7l8_.js → c4Diagram-LMCZKHZV-BW2WDVS6.js} +1 -1
  7. package/dist/gui/assets/channel-ChMv_4IC.js +1 -0
  8. package/dist/gui/assets/{chunk-2Q5K7J3B-BYR_jfQf.js → chunk-2Q5K7J3B-DBPdFkwf.js} +1 -1
  9. package/dist/gui/assets/{chunk-32BRIVSS-DCFUKQRk.js → chunk-32BRIVSS-DIbss3Mf.js} +1 -1
  10. package/dist/gui/assets/{chunk-5VM5RSS4-DrMq6ZH_.js → chunk-5VM5RSS4-iGPM2FiL.js} +1 -1
  11. package/dist/gui/assets/{chunk-EX3LRPZG-n95iKZ_F.js → chunk-EX3LRPZG-CFO6icXh.js} +1 -1
  12. package/dist/gui/assets/{chunk-JWPE2WC7-7X3iMA5d.js → chunk-JWPE2WC7-BoSzxOe1.js} +1 -1
  13. package/dist/gui/assets/{chunk-MOJQB5TN-BfJ7bYKG.js → chunk-MOJQB5TN-DenA9g0A.js} +1 -1
  14. package/dist/gui/assets/{chunk-RYQCIY6F-DMrZx7LT.js → chunk-RYQCIY6F-6OVqI5Jh.js} +1 -1
  15. package/dist/gui/assets/{chunk-V7JOEXUC-DEQ2ipfO.js → chunk-V7JOEXUC-CwTJoQCL.js} +1 -1
  16. package/dist/gui/assets/{chunk-VR4S4FIN-CEv2d05O.js → chunk-VR4S4FIN-D1Hv1RW-.js} +1 -1
  17. package/dist/gui/assets/{chunk-XXDRQBXY-B4TFXQyu.js → chunk-XXDRQBXY-5jwTXqEl.js} +1 -1
  18. package/dist/gui/assets/classDiagram-OUVF2IWQ-YMNyCLvX.js +1 -0
  19. package/dist/gui/assets/classDiagram-v2-EOCWNBFH-YMNyCLvX.js +1 -0
  20. package/dist/gui/assets/{cose-bilkent-JH36ORCC-BvtDQXS8.js → cose-bilkent-JH36ORCC-Cc8VWY9x.js} +1 -1
  21. package/dist/gui/assets/{cynefin-VYW2F7L2-CACe6Hnx.js → cynefin-VYW2F7L2-BXFPytZ_.js} +1 -1
  22. package/dist/gui/assets/{cynefinDiagram-TSTJHNR4-CYwNcXDx.js → cynefinDiagram-TSTJHNR4-WZDfGA2i.js} +1 -1
  23. package/dist/gui/assets/{dagre-VKFMJZFB-CM67mFp0.js → dagre-VKFMJZFB-Dip6iJOF.js} +1 -1
  24. package/dist/gui/assets/{diagram-FQU43EPY-DhY2YJ4E.js → diagram-FQU43EPY-CFLYoHwF.js} +1 -1
  25. package/dist/gui/assets/{diagram-G47NLZAW-SnGssRZe.js → diagram-G47NLZAW-BswWoT3h.js} +1 -1
  26. package/dist/gui/assets/{diagram-NH7WQ7WH-Bg3XxHtm.js → diagram-NH7WQ7WH-BizhF8Pc.js} +1 -1
  27. package/dist/gui/assets/{diagram-OA4YK3LP-C90tCphz.js → diagram-OA4YK3LP-BckN9mPI.js} +1 -1
  28. package/dist/gui/assets/{diagram-WEI45ONY-C_rdqlGR.js → diagram-WEI45ONY-ht6wkF4x.js} +1 -1
  29. package/dist/gui/assets/{ebnfDiagram-CCIWWBDH-C8tetpau.js → ebnfDiagram-CCIWWBDH-DyVIzHp5.js} +1 -1
  30. package/dist/gui/assets/{erDiagram-Q63AITRT-DeBf62pI.js → erDiagram-Q63AITRT-DRFWvAAm.js} +1 -1
  31. package/dist/gui/assets/{flowDiagram-23GEKE2U-ONut2CN0.js → flowDiagram-23GEKE2U-CiBwda7G.js} +1 -1
  32. package/dist/gui/assets/{ganttDiagram-NO4QXBWP-R0S1U9l5.js → ganttDiagram-NO4QXBWP-vRQNKo6Y.js} +1 -1
  33. package/dist/gui/assets/{gitGraphDiagram-IHSO6WYX-1dBOeSWA.js → gitGraphDiagram-IHSO6WYX-BYCaD1Fo.js} +1 -1
  34. package/dist/gui/assets/index-Dwx7eFhj.css +1 -0
  35. package/dist/gui/assets/index-DzV2HQw-.js +36 -0
  36. package/dist/gui/assets/{infoDiagram-FWYZ7A6U-Bizux-u4.js → infoDiagram-FWYZ7A6U-1Y32iWPH.js} +1 -1
  37. package/dist/gui/assets/{ishikawaDiagram-FXEZZL3T-BQn9HrOR.js → ishikawaDiagram-FXEZZL3T-BQDQ7prq.js} +1 -1
  38. package/dist/gui/assets/jetbrains-mono-latin-400-normal-6-qcROiO.woff +0 -0
  39. package/dist/gui/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
  40. package/dist/gui/assets/jetbrains-mono-latin-500-normal-BWZEU5yA.woff2 +0 -0
  41. package/dist/gui/assets/jetbrains-mono-latin-500-normal-CJOVTJB7.woff +0 -0
  42. package/dist/gui/assets/jetbrains-mono-latin-700-normal-BYuf6tUa.woff2 +0 -0
  43. package/dist/gui/assets/jetbrains-mono-latin-700-normal-D3wTyLJW.woff +0 -0
  44. package/dist/gui/assets/{journeyDiagram-5HDEW3XC-omxxk4CD.js → journeyDiagram-5HDEW3XC-DSWI24Bt.js} +1 -1
  45. package/dist/gui/assets/{kanban-definition-HUTT4EX6-ZSvya-tv.js → kanban-definition-HUTT4EX6-fiE0W_uC.js} +1 -1
  46. package/dist/gui/assets/{linear-DTfQvMfL.js → linear-DqWevqMh.js} +1 -1
  47. package/dist/gui/assets/{mermaid.core-D2k98UhU.js → mermaid.core-bsNbTKFB.js} +4 -4
  48. package/dist/gui/assets/{mindmap-definition-LN4V7U3C-qF0S5c0K.js → mindmap-definition-LN4V7U3C-DnUeh13j.js} +1 -1
  49. package/dist/gui/assets/{pegDiagram-2B236MQR-C6QhP9Ha.js → pegDiagram-2B236MQR-DE_8gOxy.js} +1 -1
  50. package/dist/gui/assets/{pieDiagram-ENE6RG2P-Cq_W5lD8.js → pieDiagram-ENE6RG2P-Wf_jl50X.js} +1 -1
  51. package/dist/gui/assets/{quadrantDiagram-ABIIQ3AL-eKua4eTN.js → quadrantDiagram-ABIIQ3AL-Dt-Yn4ZI.js} +1 -1
  52. package/dist/gui/assets/{railroadDiagram-RFXS5EU6-C6BzISnO.js → railroadDiagram-RFXS5EU6-0I6kqmlH.js} +1 -1
  53. package/dist/gui/assets/{requirementDiagram-TGXJPOKE-Bb6d91xE.js → requirementDiagram-TGXJPOKE-Dozq39w_.js} +1 -1
  54. package/dist/gui/assets/{sankeyDiagram-HTMAVEWB-D9QeyLBf.js → sankeyDiagram-HTMAVEWB-Cs7yO0KJ.js} +1 -1
  55. package/dist/gui/assets/{sequenceDiagram-DBY2YBRQ-CM4PvotC.js → sequenceDiagram-DBY2YBRQ-EQLpVCpV.js} +1 -1
  56. package/dist/gui/assets/{sizeCapture-X5ZJPWSS-BpbgtMCY.js → sizeCapture-X5ZJPWSS-BXUb6X9N.js} +1 -1
  57. package/dist/gui/assets/{stateDiagram-2N3HPSRC-KJiPWD0D.js → stateDiagram-2N3HPSRC-CYHgCnOc.js} +1 -1
  58. package/dist/gui/assets/stateDiagram-v2-6OUMAXLB-CqWHqtRs.js +1 -0
  59. package/dist/gui/assets/{swimlanes-5IMT3BWC-Pwo1O0dM.js → swimlanes-5IMT3BWC-BgsUQUHx.js} +2 -2
  60. package/dist/gui/assets/swimlanesDiagram-G3AALYLV-CoZVjlW6.js +8 -0
  61. package/dist/gui/assets/{timeline-definition-FHXFAJF6-CnQl8hPb.js → timeline-definition-FHXFAJF6-CQJufImP.js} +1 -1
  62. package/dist/gui/assets/{vennDiagram-L72KCM5P-CRw4PEIG.js → vennDiagram-L72KCM5P-L-2iYmD5.js} +1 -1
  63. package/dist/gui/assets/{wardleyDiagram-EHGQE667-DN0P5gP_.js → wardleyDiagram-EHGQE667-BamRRrE7.js} +1 -1
  64. package/dist/gui/assets/{xychartDiagram-FW5EYKEG-BpfpKwUH.js → xychartDiagram-FW5EYKEG-itKwurP4.js} +1 -1
  65. package/dist/gui/index.html +26 -3
  66. package/package.json +3 -2
  67. package/dist/gui/assets/channel-BEkoHvmA.js +0 -1
  68. package/dist/gui/assets/classDiagram-OUVF2IWQ-BholqSXk.js +0 -1
  69. package/dist/gui/assets/classDiagram-v2-EOCWNBFH-BholqSXk.js +0 -1
  70. package/dist/gui/assets/index-CPS7XVHi.js +0 -36
  71. package/dist/gui/assets/index-CWpwy2sQ.css +0 -1
  72. package/dist/gui/assets/stateDiagram-v2-6OUMAXLB-eLHi55Yt.js +0 -1
  73. package/dist/gui/assets/swimlanesDiagram-G3AALYLV-BI7926G2.js +0 -8
package/dist/cli/index.js CHANGED
@@ -6,9 +6,9 @@ import { join, isAbsolute, resolve, basename as basename$1, dirname, extname, se
6
6
  import { createHash, randomUUID, randomBytes } from "node:crypto";
7
7
  import { existsSync, openSync, closeSync, statSync, readSync, mkdirSync, watch, createReadStream } from "node:fs";
8
8
  import { spawn, execFile } from "node:child_process";
9
+ import { promisify } from "node:util";
9
10
  import { serve } from "@hono/node-server";
10
11
  import { Hono } from "hono";
11
- import { promisify } from "node:util";
12
12
  import { streamSSE } from "hono/streaming";
13
13
  import { fileURLToPath } from "node:url";
14
14
  import trash from "trash";
@@ -22,7 +22,7 @@ import { createOpencode } from "@opencode-ai/sdk";
22
22
  import { createInterface as createInterface$1 } from "node:readline/promises";
23
23
  import MarkdownIt from "markdown-it";
24
24
  const name = "@yorz/cli";
25
- const version = "0.5.1";
25
+ const version = "0.6.0";
26
26
  const type = "module";
27
27
  const description = "";
28
28
  const bin = { "yorz": "./dist/cli/index.js" };
@@ -33,9 +33,9 @@ const license = "LGPL-3.0-or-later";
33
33
  const repository = { "type": "git", "url": "git+https://github.com/hughfenghen/YorZ.git" };
34
34
  const homepage = "https://github.com/hughfenghen/YorZ#readme";
35
35
  const publishConfig = { "access": "public" };
36
- const scripts = { "build": "pnpm run build:cli && pnpm run build:gui", "build:cli": "vite build", "build:gui": "vite build --config vite.gui.config.ts", "dev:cli": "pnpm run build:cli && node dist/cli/index.js serve --port 7424 --foreground", "dev:gui": "vite --config vite.gui.config.ts", "typecheck": "tsc -b", "test": "vitest run", "test:agent": "node scripts/test-agent.mjs", "test:e2e": "playwright test", "format": 'prettier --write "src/**/*.{ts,tsx,md,css}"', "prepublishOnly": "pnpm run build" };
36
+ const scripts = { "build": "pnpm run build:cli && pnpm run build:gui", "build:cli": "vite build", "build:gui": "vite build --config vite.gui.config.ts", "dev:cli": "pnpm run build:cli && node dist/cli/index.js serve --port 7424 --foreground", "dev:gui": "vite --config vite.gui.config.ts", "typecheck": "tsc -b", "test": "vitest run", "test:agent": "node scripts/test-agent.mjs", "test:e2e": "pnpm run build && playwright test", "format": 'prettier --write "src/**/*.{ts,tsx,md,css}"', "prepublishOnly": "pnpm run build" };
37
37
  const dependencies = { "@anthropic-ai/claude-agent-sdk": "^0.3.207", "@hono/node-server": "^2.0.4", "@openai/codex-sdk": "^0.144.1", "@opencode-ai/sdk": "^1.17.18", "chokidar": "^5.0.0", "commander": "^12.1.0", "gray-matter": "^4.0.3", "hono": "^4.12.25", "jsdom": "^25.0.1", "markdown-it": "^14.2.0", "mermaid": "^11.0.0", "morphdom": "^2.7.8", "timeago.js": "^4.0.2", "trash": "^10.1.1" };
38
- const devDependencies = { "@kobalte/core": "^0.13.12", "@playwright/test": "^1.61.0", "@solidjs/router": "^0.16.1", "@types/jsdom": "^21.1.7", "@types/markdown-it": "^14.1.2", "@types/node": "^22.10.0", "autoprefixer": "^10.5.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "concurrently": "^9.1.0", "highlight.js": "^11.11.1", "i18next": "^26.3.6", "i18next-browser-languagedetector": "^8.2.1", "lucide-solid": "^1.24.0", "markdown-it-task-lists": "^2.1.1", "postcss": "^8.5.16", "prettier": "^3.4.0", "solid-js": "^1.9.13", "tailwind-merge": "^3.6.0", "tailwindcss": "^3.4.19", "tailwindcss-animate": "^1.0.7", "typescript": "^5.7.0", "vite": "^6.0.0", "vite-plugin-solid": "^2.11.12", "vitest": "^2.1.0" };
38
+ const devDependencies = { "@fontsource/jetbrains-mono": "^5.3.0", "@kobalte/core": "^0.13.12", "@playwright/test": "^1.61.0", "@solidjs/router": "^0.16.1", "@types/jsdom": "^21.1.7", "@types/markdown-it": "^14.1.2", "@types/node": "^22.10.0", "autoprefixer": "^10.5.2", "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "concurrently": "^9.1.0", "highlight.js": "^11.11.1", "i18next": "^26.3.6", "i18next-browser-languagedetector": "^8.2.1", "lucide-solid": "^1.24.0", "markdown-it-task-lists": "^2.1.1", "postcss": "^8.5.16", "prettier": "^3.4.0", "solid-js": "^1.9.13", "tailwind-merge": "^3.6.0", "tailwindcss": "^3.4.19", "tailwindcss-animate": "^1.0.7", "typescript": "^5.7.0", "vite": "^6.0.0", "vite-plugin-solid": "^2.11.12", "vitest": "^2.1.0" };
39
39
  const pkg = {
40
40
  name,
41
41
  version,
@@ -58,6 +58,9 @@ const DEFAULT_GLOBAL_AGENT = { defaultKind: "claude" };
58
58
  const DEFAULT_NOTIFICATIONS = {
59
59
  sessionEnd: { banner: false, sound: false }
60
60
  };
61
+ const DEFAULT_POWER = {
62
+ inhibitWhenRunning: "system-default"
63
+ };
61
64
  const SHORTCUT_ACTION_IDS = [
62
65
  "newSpec",
63
66
  "toggleSpecDetailFullscreen",
@@ -129,7 +132,8 @@ function normalizeConfig$1(value) {
129
132
  projects,
130
133
  agent: normalizeAgent$1(obj.agent),
131
134
  notifications: normalizeNotifications(obj.notifications),
132
- shortcuts: normalizeShortcuts(obj.shortcuts)
135
+ shortcuts: normalizeShortcuts(obj.shortcuts),
136
+ power: normalizePower(obj.power)
133
137
  };
134
138
  }
135
139
  function defaultGlobalConfig() {
@@ -143,7 +147,10 @@ function defaultGlobalConfig() {
143
147
  sound: DEFAULT_NOTIFICATIONS.sessionEnd.sound
144
148
  }
145
149
  },
146
- shortcuts: {}
150
+ shortcuts: {},
151
+ power: {
152
+ inhibitWhenRunning: DEFAULT_POWER.inhibitWhenRunning
153
+ }
147
154
  };
148
155
  }
149
156
  function normalizeAgent$1(value) {
@@ -183,6 +190,17 @@ function normalizeShortcuts(value) {
183
190
  }
184
191
  return shortcuts;
185
192
  }
193
+ function normalizePower(value) {
194
+ if (!value || typeof value !== "object") {
195
+ return { inhibitWhenRunning: DEFAULT_POWER.inhibitWhenRunning };
196
+ }
197
+ const obj = value;
198
+ const mode = obj.inhibitWhenRunning;
199
+ if (mode === "prevent-display-sleep" || mode === "keep-system-awake" || mode === "system-default") {
200
+ return { inhibitWhenRunning: mode };
201
+ }
202
+ return { inhibitWhenRunning: DEFAULT_POWER.inhibitWhenRunning };
203
+ }
186
204
  function normalizeShortcutBinding(value) {
187
205
  const parts = value.split("+").map((part) => part.trim()).filter(Boolean);
188
206
  let key = "";
@@ -2622,11 +2640,152 @@ function parseSpecsDir(value) {
2622
2640
  }
2623
2641
  return { value: trimmed };
2624
2642
  }
2625
- function createGlobalConfigRoutes(globalConfigPath) {
2643
+ const powerLog = () => getLogger().child("power");
2644
+ const controllers = /* @__PURE__ */ new Map();
2645
+ class PowerInhibitController {
2646
+ globalConfigPath;
2647
+ platform;
2648
+ spawnCommand;
2649
+ runningSessions = /* @__PURE__ */ new Set();
2650
+ currentMode = "system-default";
2651
+ process = null;
2652
+ refreshPromise = Promise.resolve();
2653
+ constructor(opts = {}) {
2654
+ this.globalConfigPath = opts.globalConfigPath;
2655
+ this.platform = opts.platform ?? platform();
2656
+ this.spawnCommand = opts.spawnCommand ?? ((command, args, options) => spawn(command, args, options));
2657
+ }
2658
+ setSessionRunning(sessionId, running) {
2659
+ if (running) this.runningSessions.add(sessionId);
2660
+ else this.runningSessions.delete(sessionId);
2661
+ this.scheduleRefresh();
2662
+ }
2663
+ async refresh() {
2664
+ const cfg = await loadGlobalConfig(this.globalConfigPath);
2665
+ const mode = this.runningSessions.size > 0 ? cfg.power.inhibitWhenRunning : "system-default";
2666
+ this.applyMode(mode);
2667
+ }
2668
+ dispose() {
2669
+ this.runningSessions.clear();
2670
+ this.applyMode("system-default");
2671
+ }
2672
+ scheduleRefresh() {
2673
+ this.refreshPromise = this.refreshPromise.catch(() => {
2674
+ }).then(() => this.refresh()).catch((err) => {
2675
+ powerLog().warn("failed to refresh power inhibit state", {
2676
+ message: err instanceof Error ? err.message : String(err)
2677
+ });
2678
+ });
2679
+ }
2680
+ applyMode(mode) {
2681
+ if (mode === this.currentMode) return;
2682
+ this.stopCurrent();
2683
+ this.currentMode = mode;
2684
+ if (mode === "system-default") return;
2685
+ const command = this.commandFor(mode);
2686
+ if (!command) {
2687
+ powerLog().debug("power inhibit mode ignored on unsupported platform", {
2688
+ mode,
2689
+ platform: this.platform
2690
+ });
2691
+ return;
2692
+ }
2693
+ const child = this.spawnCommand(command.command, command.args, { stdio: "ignore" });
2694
+ child.on?.("error", (err) => {
2695
+ if (this.process === child) {
2696
+ this.process = null;
2697
+ this.currentMode = "system-default";
2698
+ }
2699
+ powerLog().warn("power inhibit process failed", { message: err.message });
2700
+ });
2701
+ child.on?.("exit", () => {
2702
+ if (this.process === child) {
2703
+ this.process = null;
2704
+ this.currentMode = "system-default";
2705
+ }
2706
+ });
2707
+ child.unref?.();
2708
+ this.process = child;
2709
+ powerLog().debug("started power inhibit process", {
2710
+ mode,
2711
+ command: command.command,
2712
+ args: command.args
2713
+ });
2714
+ }
2715
+ commandFor(mode) {
2716
+ if (this.platform === "darwin") {
2717
+ return {
2718
+ command: "caffeinate",
2719
+ args: mode === "prevent-display-sleep" ? ["-d"] : ["-i"]
2720
+ };
2721
+ }
2722
+ if (this.platform === "linux") {
2723
+ return {
2724
+ command: "systemd-inhibit",
2725
+ args: [
2726
+ `--what=${mode === "prevent-display-sleep" ? "idle" : "idle:sleep"}`,
2727
+ "--why=YorZ agent task running",
2728
+ "sleep",
2729
+ "infinity"
2730
+ ]
2731
+ };
2732
+ }
2733
+ if (this.platform === "win32") {
2734
+ const flags = mode === "prevent-display-sleep" ? "0x80000002" : "0x80000001";
2735
+ return {
2736
+ command: "powershell.exe",
2737
+ args: [
2738
+ "-NoProfile",
2739
+ "-ExecutionPolicy",
2740
+ "Bypass",
2741
+ "-Command",
2742
+ windowsExecutionStateScript(flags)
2743
+ ]
2744
+ };
2745
+ }
2746
+ return null;
2747
+ }
2748
+ stopCurrent() {
2749
+ if (!this.process) return;
2750
+ try {
2751
+ this.process.kill();
2752
+ } catch {
2753
+ } finally {
2754
+ this.process = null;
2755
+ }
2756
+ }
2757
+ }
2758
+ function windowsExecutionStateScript(flags) {
2759
+ return [
2760
+ `$signature = '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);';`,
2761
+ "$native = Add-Type -MemberDefinition $signature -Name YorZPowerInhibit -Namespace YorZ -PassThru;",
2762
+ "try {",
2763
+ ` [void]$native::SetThreadExecutionState(${flags});`,
2764
+ " while ($true) { Start-Sleep -Seconds 3600; }",
2765
+ "} finally {",
2766
+ " [void]$native::SetThreadExecutionState(0x80000000);",
2767
+ "}"
2768
+ ].join(" ");
2769
+ }
2770
+ function getPowerInhibitController(globalConfigPath) {
2771
+ const key = globalConfigPath ?? resolveGlobalConfigPath();
2772
+ let controller = controllers.get(key);
2773
+ if (!controller) {
2774
+ controller = new PowerInhibitController({ globalConfigPath });
2775
+ controllers.set(key, controller);
2776
+ }
2777
+ return controller;
2778
+ }
2779
+ function createGlobalConfigRoutes(globalConfigPath, powerController = getPowerInhibitController(globalConfigPath)) {
2626
2780
  const app = new Hono();
2627
2781
  app.get("/global-config", async (c) => {
2628
2782
  const cfg = await loadGlobalConfig(globalConfigPath);
2629
- return c.json({ agent: cfg.agent, notifications: cfg.notifications, shortcuts: cfg.shortcuts });
2783
+ return c.json({
2784
+ agent: cfg.agent,
2785
+ notifications: cfg.notifications,
2786
+ shortcuts: cfg.shortcuts,
2787
+ power: cfg.power
2788
+ });
2630
2789
  });
2631
2790
  app.put("/global-config", async (c) => {
2632
2791
  let raw;
@@ -2641,10 +2800,17 @@ function createGlobalConfigRoutes(globalConfigPath) {
2641
2800
  cfg.agent = parsed.agent;
2642
2801
  cfg.notifications = parsed.notifications;
2643
2802
  cfg.shortcuts = parsed.shortcuts;
2803
+ cfg.power = parsed.power;
2644
2804
  await saveGlobalConfig(cfg, globalConfigPath);
2805
+ await powerController.refresh();
2645
2806
  return c.json({
2646
2807
  ok: true,
2647
- config: { agent: cfg.agent, notifications: cfg.notifications, shortcuts: cfg.shortcuts }
2808
+ config: {
2809
+ agent: cfg.agent,
2810
+ notifications: cfg.notifications,
2811
+ shortcuts: cfg.shortcuts,
2812
+ power: cfg.power
2813
+ }
2648
2814
  });
2649
2815
  });
2650
2816
  return app;
@@ -2694,10 +2860,20 @@ function parseBody(value) {
2694
2860
  return { error: `shortcuts.${key} is not a valid shortcut binding` };
2695
2861
  }
2696
2862
  }
2863
+ const powerRaw = obj.power ?? DEFAULT_POWER;
2864
+ if (!powerRaw || typeof powerRaw !== "object") return { error: "power must be an object" };
2865
+ const p = powerRaw;
2866
+ const inhibitWhenRunning = p.inhibitWhenRunning;
2867
+ if (inhibitWhenRunning !== "system-default" && inhibitWhenRunning !== "prevent-display-sleep" && inhibitWhenRunning !== "keep-system-awake") {
2868
+ return {
2869
+ error: "power.inhibitWhenRunning must be system-default | prevent-display-sleep | keep-system-awake"
2870
+ };
2871
+ }
2697
2872
  return {
2698
2873
  agent: { defaultKind },
2699
2874
  notifications: { sessionEnd: { banner: s.banner, sound: s.sound } },
2700
- shortcuts: normalizeShortcuts(shortcutObj)
2875
+ shortcuts: normalizeShortcuts(shortcutObj),
2876
+ power: { inhibitWhenRunning }
2701
2877
  };
2702
2878
  }
2703
2879
  function createSpecDraftsRoutes(resolveProject) {
@@ -5695,7 +5871,15 @@ class SessionManager {
5695
5871
  setRunning(sid, running) {
5696
5872
  if (running) this.running.add(sid);
5697
5873
  else this.running.delete(sid);
5698
- this.statusEmitter.emit("status", { sessionId: sid, running });
5874
+ const event = { sessionId: sid, running };
5875
+ this.statusEmitter.emit("status", event);
5876
+ void Promise.resolve(this.opts.onSessionStatusChange?.(event)).catch((err) => {
5877
+ agentLog().warn("session status callback failed", {
5878
+ sessionId: sid,
5879
+ running,
5880
+ message: err instanceof Error ? err.message : String(err)
5881
+ });
5882
+ });
5699
5883
  }
5700
5884
  async maybeUpdateTitleFromPrompt(sid, prompt) {
5701
5885
  const indexed = await this.store.get(sid);
@@ -6018,9 +6202,13 @@ class ProjectRegistry {
6018
6202
  globalConfigPath: this.globalConfigPath,
6019
6203
  projectName: basename(input.path)
6020
6204
  });
6205
+ const powerInhibit = getPowerInhibitController(this.globalConfigPath);
6021
6206
  const defaultKind = resolveProjectAgentKind(cfg.agent, globalCfg.agent.defaultKind);
6022
6207
  const sessions = new SessionManager(input.path, defaultKind, sessionStore, {
6023
- onSessionEnd: notifySessionEnded
6208
+ onSessionEnd: notifySessionEnded,
6209
+ onSessionStatusChange: (ev) => {
6210
+ powerInhibit.setSessionRunning(`${input.id}:${ev.sessionId}`, ev.running);
6211
+ }
6024
6212
  });
6025
6213
  const commands = getCommandManager(input.path);
6026
6214
  const stopChatDebugCleanup = scheduleChatDebugCleanup(input.path);
@@ -6113,6 +6301,7 @@ class SystemNotificationCenter {
6113
6301
  upsertVersionUpdate(info) {
6114
6302
  const now = Date.now();
6115
6303
  const current = this.items.get(VERSION_NOTIFICATION_ID);
6304
+ const sameLatest = current?.metadata?.latestVersion === info.latest;
6116
6305
  const next = {
6117
6306
  id: VERSION_NOTIFICATION_ID,
6118
6307
  kind: "version-update",
@@ -6120,7 +6309,7 @@ class SystemNotificationCenter {
6120
6309
  message: `YorZ ${info.latest} is available. Current version: ${info.current}.`,
6121
6310
  createdAt: current?.createdAt ?? now,
6122
6311
  updatedAt: now,
6123
- action: current?.action === "restart-ready" ? "restart-ready" : "update-available",
6312
+ action: current?.action === "restart-ready" && sameLatest ? "restart-ready" : "update-available",
6124
6313
  metadata: { currentVersion: info.current, latestVersion: info.latest }
6125
6314
  };
6126
6315
  this.items.set(next.id, next);
@@ -6214,9 +6403,9 @@ function compareVersions(a, b) {
6214
6403
  }
6215
6404
  return 0;
6216
6405
  }
6217
- function resolveGlobalInstallCommand(env = process.env) {
6218
- const source = `${env.npm_config_user_agent ?? ""} ${env.npm_execpath ?? ""}`.toLowerCase();
6219
- const manager = source.includes("pnpm") ? "pnpm" : source.includes("bun") ? "bun" : source.includes("yarn") ? "yarn" : "npm";
6406
+ function resolveGlobalInstallCommand(env = process.env, argv = process.argv) {
6407
+ const envManager = detectPackageManager([env.npm_config_user_agent, env.npm_execpath]);
6408
+ const manager = envManager ?? detectPackageManager([env.NODE_PATH, ...argv]) ?? "npm";
6220
6409
  switch (manager) {
6221
6410
  case "pnpm":
6222
6411
  return { cmd: "pnpm", args: ["add", "-g", "@yorz/cli@latest"] };
@@ -6228,6 +6417,13 @@ function resolveGlobalInstallCommand(env = process.env) {
6228
6417
  return { cmd: "npm", args: ["install", "-g", "@yorz/cli@latest"] };
6229
6418
  }
6230
6419
  }
6420
+ function detectPackageManager(values) {
6421
+ const source = values.filter(Boolean).join(" ").toLowerCase();
6422
+ if (source.includes("pnpm")) return "pnpm";
6423
+ if (source.includes("bun")) return "bun";
6424
+ if (source.includes("yarn")) return "yarn";
6425
+ return null;
6426
+ }
6231
6427
  function parseVersion(value) {
6232
6428
  const m = /^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(value.trim());
6233
6429
  if (!m) return null;
@@ -6407,6 +6603,7 @@ function installGlobalErrorHandlers() {
6407
6603
  });
6408
6604
  }
6409
6605
  const log = () => getLogger().child("serve");
6606
+ const execFileAsync = promisify(execFile);
6410
6607
  function silenceConsoleMirror() {
6411
6608
  configureLogger({ mirrorConsole: false });
6412
6609
  }
@@ -6441,11 +6638,15 @@ async function runServe(opts) {
6441
6638
  noRegisterCwd: opts.noRegisterCwd
6442
6639
  });
6443
6640
  if (opts.recordRuntime) {
6641
+ const snapshot = await readProcessSnapshot(process.pid);
6444
6642
  await upsertProcess({
6445
6643
  pid: process.pid,
6446
6644
  port: handle.port,
6447
6645
  url: handle.url,
6448
- startedAt: (/* @__PURE__ */ new Date()).toISOString()
6646
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
6647
+ execPath: process.execPath,
6648
+ argv: process.argv,
6649
+ processStartedAt: snapshot?.processStartedAt
6449
6650
  });
6450
6651
  console.log(`Stop with: yorz serve stop`);
6451
6652
  } else {
@@ -6581,12 +6782,19 @@ async function runStopServe() {
6581
6782
  message: "YorZ Service is not running."
6582
6783
  };
6583
6784
  }
6584
- const alive = all.filter((p) => isProcessAlive(p.pid));
6585
- const dead = all.filter((p) => !isProcessAlive(p.pid));
6785
+ const checks = await Promise.all(
6786
+ all.map(async (proc) => ({ proc, snapshot: await readProcessSnapshot(proc.pid) }))
6787
+ );
6788
+ const alive = checks.filter(
6789
+ (check) => check.snapshot && isStoppableYorzProcess(check.proc, check.snapshot)
6790
+ );
6791
+ const dead = checks.filter(
6792
+ (check) => !check.snapshot || !isStoppableYorzProcess(check.proc, check.snapshot)
6793
+ );
6586
6794
  if (alive.length === 0) {
6587
6795
  await removeRuntime();
6588
- log().warn("cleared stale runtime records", { pids: dead.map((p) => p.pid) });
6589
- const deadPidList = dead.map((p) => `pid=${p.pid}`).join(", ");
6796
+ log().warn("cleared stale runtime records", { pids: dead.map((p) => p.proc.pid) });
6797
+ const deadPidList = dead.map((p) => `pid=${p.proc.pid}`).join(", ");
6590
6798
  return {
6591
6799
  stopped: false,
6592
6800
  stoppedPids: [],
@@ -6597,7 +6805,7 @@ async function runStopServe() {
6597
6805
  const stoppedPids = [];
6598
6806
  const stoppedUrls = [];
6599
6807
  const failedPids = [];
6600
- for (const proc of alive) {
6808
+ for (const { proc } of alive) {
6601
6809
  try {
6602
6810
  process.kill(proc.pid, "SIGTERM");
6603
6811
  log().info("sent SIGTERM", { pid: proc.pid, url: proc.url });
@@ -6692,8 +6900,13 @@ async function waitForRuntime(pid, timeoutMs) {
6692
6900
  async function readLiveProcesses() {
6693
6901
  const all = await readAllProcesses();
6694
6902
  if (all.length === 0) return [];
6695
- const alive = all.filter((p) => isProcessAlive(p.pid));
6696
- const dead = all.filter((p) => !isProcessAlive(p.pid));
6903
+ const checks = await Promise.all(
6904
+ all.map(async (proc) => ({ proc, snapshot: await readProcessSnapshot(proc.pid) }))
6905
+ );
6906
+ const alive = checks.filter((check) => check.snapshot && isStoppableYorzProcess(check.proc, check.snapshot)).map((check) => check.proc);
6907
+ const dead = checks.filter(
6908
+ (check) => !check.snapshot || !isStoppableYorzProcess(check.proc, check.snapshot)
6909
+ );
6697
6910
  if (dead.length > 0) {
6698
6911
  if (alive.length === 0) {
6699
6912
  await removeRuntime();
@@ -6731,7 +6944,10 @@ function toProcessEntry(obj) {
6731
6944
  pid: obj.pid,
6732
6945
  port: obj.port,
6733
6946
  url: obj.url,
6734
- startedAt: obj.startedAt
6947
+ startedAt: obj.startedAt,
6948
+ execPath: typeof obj.execPath === "string" ? obj.execPath : void 0,
6949
+ argv: Array.isArray(obj.argv) && obj.argv.every((v) => typeof v === "string") ? obj.argv : void 0,
6950
+ processStartedAt: typeof obj.processStartedAt === "string" ? obj.processStartedAt : void 0
6735
6951
  };
6736
6952
  }
6737
6953
  function tryV1Entry(parsed) {
@@ -6742,7 +6958,10 @@ function tryV1Entry(parsed) {
6742
6958
  pid: parsed.pid,
6743
6959
  port: parsed.port,
6744
6960
  url: parsed.url,
6745
- startedAt: parsed.startedAt
6961
+ startedAt: parsed.startedAt,
6962
+ execPath: typeof parsed.execPath === "string" ? parsed.execPath : void 0,
6963
+ argv: Array.isArray(parsed.argv) && parsed.argv.every((v) => typeof v === "string") ? parsed.argv : void 0,
6964
+ processStartedAt: typeof parsed.processStartedAt === "string" ? parsed.processStartedAt : void 0
6746
6965
  };
6747
6966
  }
6748
6967
  async function upsertProcess(entry) {
@@ -6779,6 +6998,73 @@ function isProcessAlive(pid) {
6779
6998
  return false;
6780
6999
  }
6781
7000
  }
7001
+ function isStoppableYorzProcess(entry, snapshot) {
7002
+ if (!hasRuntimeIdentity(entry)) return true;
7003
+ return isTrustedYorzProcess(entry, snapshot);
7004
+ }
7005
+ function hasRuntimeIdentity(entry) {
7006
+ return Boolean(entry.execPath || entry.argv || entry.processStartedAt);
7007
+ }
7008
+ function isTrustedYorzProcess(entry, snapshot) {
7009
+ if (!entry.processStartedAt || snapshot.processStartedAt !== entry.processStartedAt) return false;
7010
+ if (!entry.execPath || !entry.argv) return false;
7011
+ const required = [
7012
+ entry.execPath,
7013
+ entry.argv[1],
7014
+ "serve",
7015
+ "--foreground",
7016
+ "--record-runtime"
7017
+ ].filter((arg) => typeof arg === "string" && arg.length > 0);
7018
+ const commandMatches = required.every((arg) => snapshot.commandLine.includes(arg));
7019
+ return commandMatches;
7020
+ }
7021
+ async function readProcessSnapshot(pid) {
7022
+ if (!isProcessAlive(pid)) return null;
7023
+ if (process.platform === "win32") return readWindowsProcessSnapshot(pid);
7024
+ return readPosixProcessSnapshot(pid);
7025
+ }
7026
+ async function readPosixProcessSnapshot(pid) {
7027
+ try {
7028
+ const { stdout } = await execFileAsync("ps", [
7029
+ "-ww",
7030
+ "-p",
7031
+ String(pid),
7032
+ "-o",
7033
+ "lstart=",
7034
+ "-o",
7035
+ "command="
7036
+ ]);
7037
+ const line = stdout.trim();
7038
+ if (!line) return null;
7039
+ const parts = line.match(/^(\S+\s+\S+\s+\d+\s+\d+:\d+:\d+\s+\d+)\s+([\s\S]+)$/);
7040
+ if (!parts) return { commandLine: line };
7041
+ return { processStartedAt: parts[1], commandLine: parts[2] };
7042
+ } catch {
7043
+ return null;
7044
+ }
7045
+ }
7046
+ async function readWindowsProcessSnapshot(pid) {
7047
+ try {
7048
+ const script = [
7049
+ `$p = Get-CimInstance Win32_Process -Filter "ProcessId = ${pid}"`,
7050
+ "if ($null -eq $p) { exit 1 }",
7051
+ "$p | Select-Object CommandLine,CreationDate | ConvertTo-Json -Compress"
7052
+ ].join("; ");
7053
+ const { stdout } = await execFileAsync("powershell.exe", [
7054
+ "-NoProfile",
7055
+ "-NonInteractive",
7056
+ "-Command",
7057
+ script
7058
+ ]);
7059
+ const parsed = JSON.parse(stdout.trim());
7060
+ const commandLine = typeof parsed.CommandLine === "string" ? parsed.CommandLine : "";
7061
+ const processStartedAt = typeof parsed.CreationDate === "string" ? parsed.CreationDate : void 0;
7062
+ if (!commandLine) return null;
7063
+ return { commandLine, processStartedAt };
7064
+ } catch {
7065
+ return null;
7066
+ }
7067
+ }
6782
7068
  async function waitForProcessExit(pid, timeoutMs) {
6783
7069
  const until = Date.now() + timeoutMs;
6784
7070
  while (Date.now() < until) {
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-BfJ7bYKG.js";import{p as f}from"./chunk-JWPE2WC7-7X3iMA5d.js";import{_ as n,l as o}from"./mermaid.core-D2k98UhU.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-CACe6Hnx.js";import"./index-CPS7XVHi.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-MOJQB5TN-DenA9g0A.js";import{p as f}from"./chunk-JWPE2WC7-BoSzxOe1.js";import{_ as n,l as o}from"./mermaid.core-bsNbTKFB.js";import{M as c,b as d}from"./cynefin-VYW2F7L2-BXFPytZ_.js";import"./index-DzV2HQw-.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-D2k98UhU.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{Y as ln,$ as an,a0 as F,a1 as q,a2 as j,a3 as un,a4 as y,a5 as tn,a6 as J,a7 as _,a8 as rn,a9 as o,aa as on,ab as sn,ac as fn}from"./mermaid.core-bsNbTKFB.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,I,D,v,A,z,a){var O=I-l,i=D-h,n=z-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function U(l,h,I,D,v,A,z){var a=l-I,O=h-D,i=(z?A:-A)/J(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,B=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,S=(g<0?-1:1)*J(on(0,T*T*R-P*P)),Y=(P*g-m*S)/R,$=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=Y-B,e=$-t,r=w-B,C=p-t;return x*x+e*e>r*r+C*C&&(Y=w,$=p),{cx:Y,cy:$,x01:-n,y01:-d,x11:Y*(v/T-1),y11:$*(v/T-1)}}function hn(){var l=cn,h=yn,I=j(0),D=null,v=gn,A=dn,z=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,B=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(B>tn-y)a.moveTo(s*F(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*F(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=B,S=B,Y=z.apply(this,arguments)/2,$=Y>y&&(D?+D.apply(this,arguments):J(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if($>y){var C=sn($/u*q(Y)),K=sn($/s*q(Y));(P-=C*2)>y?(C*=t?1:-1,R+=C,T-=C):(P=0,R=T=(f+c)/2),(S-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(S=0,m=g=(f+c)/2)}var G=s*F(m),H=s*q(m),L=u*F(T),M=u*q(T);if(w>y){var N=s*F(g),Q=s*q(g),V=u*F(R),W=u*q(R),E;if(B<an)if(E=pn(G,H,V,W,N,Q,L,M)){var X=G-E[0],Z=H-E[1],b=N-E[0],k=Q-E[1],nn=1/q(fn((X*b+Z*k)/(J(X*X+Z*Z)*J(b*b+k*k)))/2),en=J(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=U(V,W,G,H,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(G,H),a.arc(0,0,s,m,g,!t)):a.moveTo(G,H),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(G,H,V,W,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[F(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:j(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:j(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:j(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:j(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:j(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:j(+n),i):A},i.padAngle=function(n){return arguments.length?(z=typeof n=="function"?n:j(+n),i):z},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};