pi-mega-compact 0.20.29 → 0.20.30

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 (68) hide show
  1. package/dist/config/vector-cortex-vc9d.js +32 -0
  2. package/dist/config/vector-cortex.js +2 -1
  3. package/dist/config.js +1 -1
  4. package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
  5. package/dist/extensions/dashboard-server/routes-setup-detect-cache.js +201 -0
  6. package/dist/extensions/dashboard-server/routes-setup.js +11 -83
  7. package/dist/src/config/vector-cortex-vc9d.js +32 -0
  8. package/dist/src/config/vector-cortex.js +2 -1
  9. package/dist/src/config.js +1 -1
  10. package/extensions/dashboard-client/dist/assets/{AreaChart-DIKsPqLG.js → AreaChart-EL8l2Fcj.js} +2 -2
  11. package/extensions/dashboard-client/dist/assets/{AreaChart-DIKsPqLG.js.map → AreaChart-EL8l2Fcj.js.map} +1 -1
  12. package/extensions/dashboard-client/dist/assets/{BarChart-DeqN74Hn.js → BarChart-TrwfSh0w.js} +2 -2
  13. package/extensions/dashboard-client/dist/assets/{BarChart-DeqN74Hn.js.map → BarChart-TrwfSh0w.js.map} +1 -1
  14. package/extensions/dashboard-client/dist/assets/{CacheTab-x1YU4tYc.js → CacheTab-C3KWDFDm.js} +2 -2
  15. package/extensions/dashboard-client/dist/assets/{CacheTab-x1YU4tYc.js.map → CacheTab-C3KWDFDm.js.map} +1 -1
  16. package/extensions/dashboard-client/dist/assets/{EventsTab-6BuEbd8Y.js → EventsTab-CNrT-b7t.js} +2 -2
  17. package/extensions/dashboard-client/dist/assets/{EventsTab-6BuEbd8Y.js.map → EventsTab-CNrT-b7t.js.map} +1 -1
  18. package/extensions/dashboard-client/dist/assets/{HealthTab-B71Ft1ac.js → HealthTab-CkBCFPk6.js} +2 -2
  19. package/extensions/dashboard-client/dist/assets/{HealthTab-B71Ft1ac.js.map → HealthTab-CkBCFPk6.js.map} +1 -1
  20. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-dysyJtHk.js → MaintenanceTab-CcbKszwx.js} +2 -2
  21. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-dysyJtHk.js.map → MaintenanceTab-CcbKszwx.js.map} +1 -1
  22. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-B3dKRb_4.js → MemoryMapTab-B2LvwScj.js} +2 -2
  23. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-B3dKRb_4.js.map → MemoryMapTab-B2LvwScj.js.map} +1 -1
  24. package/extensions/dashboard-client/dist/assets/{MetricsTab-COn4GoUK.js → MetricsTab-Dv_xZtOG.js} +2 -2
  25. package/extensions/dashboard-client/dist/assets/{MetricsTab-COn4GoUK.js.map → MetricsTab-Dv_xZtOG.js.map} +1 -1
  26. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cd9qAEB3.js → OverviewTab-D7xwhpOl.js} +2 -2
  27. package/extensions/dashboard-client/dist/assets/{OverviewTab-Cd9qAEB3.js.map → OverviewTab-D7xwhpOl.js.map} +1 -1
  28. package/extensions/dashboard-client/dist/assets/{ReposTab-DpiP1-Vv.js → ReposTab-BfhiPXdA.js} +2 -2
  29. package/extensions/dashboard-client/dist/assets/{ReposTab-DpiP1-Vv.js.map → ReposTab-BfhiPXdA.js.map} +1 -1
  30. package/extensions/dashboard-client/dist/assets/{SessionsTab-BwRUeGZM.js → SessionsTab-tQM0TQLp.js} +2 -2
  31. package/extensions/dashboard-client/dist/assets/{SessionsTab-BwRUeGZM.js.map → SessionsTab-tQM0TQLp.js.map} +1 -1
  32. package/extensions/dashboard-client/dist/assets/SetupTab-G-MkdQiR.js +3 -0
  33. package/extensions/dashboard-client/dist/assets/SetupTab-G-MkdQiR.js.map +1 -0
  34. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-_XsdjQ7Z.js → TimeSavedCard-CYltysD3.js} +2 -2
  35. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-_XsdjQ7Z.js.map → TimeSavedCard-CYltysD3.js.map} +1 -1
  36. package/extensions/dashboard-client/dist/assets/{TurnsTab-CWPscPLL.js → TurnsTab-1Y_Lpxx-.js} +2 -2
  37. package/extensions/dashboard-client/dist/assets/{TurnsTab-CWPscPLL.js.map → TurnsTab-1Y_Lpxx-.js.map} +1 -1
  38. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-Cx56rAIM.js → VcStatusBadge-BNHVeTG7.js} +2 -2
  39. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-Cx56rAIM.js.map → VcStatusBadge-BNHVeTG7.js.map} +1 -1
  40. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-B5ElUM7S.js → VectorCortexTab-goacPxL1.js} +2 -2
  41. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-B5ElUM7S.js.map → VectorCortexTab-goacPxL1.js.map} +1 -1
  42. package/extensions/dashboard-client/dist/assets/{WikiTab-uZ5Mq3XG.js → WikiTab-DTOemYtE.js} +2 -2
  43. package/extensions/dashboard-client/dist/assets/{WikiTab-uZ5Mq3XG.js.map → WikiTab-DTOemYtE.js.map} +1 -1
  44. package/extensions/dashboard-client/dist/assets/{button-Kc18bYFz.js → button-B_4j_PVR.js} +2 -2
  45. package/extensions/dashboard-client/dist/assets/{button-Kc18bYFz.js.map → button-B_4j_PVR.js.map} +1 -1
  46. package/extensions/dashboard-client/dist/assets/{card-COJZoG08.js → card-Ce58rSXG.js} +2 -2
  47. package/extensions/dashboard-client/dist/assets/{card-COJZoG08.js.map → card-Ce58rSXG.js.map} +1 -1
  48. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-ChEYo017.js → generateCategoricalChart-DtNoJ6fZ.js} +2 -2
  49. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-ChEYo017.js.map → generateCategoricalChart-DtNoJ6fZ.js.map} +1 -1
  50. package/extensions/dashboard-client/dist/assets/{index-CB7Rn5FP.js → index-eoCm0uxj.js} +3 -3
  51. package/extensions/dashboard-client/dist/assets/{index-CB7Rn5FP.js.map → index-eoCm0uxj.js.map} +1 -1
  52. package/extensions/dashboard-client/dist/assets/{switch-BFhl_tNh.js → switch-B9kM0N7R.js} +2 -2
  53. package/extensions/dashboard-client/dist/assets/{switch-BFhl_tNh.js.map → switch-B9kM0N7R.js.map} +1 -1
  54. package/extensions/dashboard-client/dist/assets/{toggle-DJ68kATc.js → toggle-BwoHYpMa.js} +2 -2
  55. package/extensions/dashboard-client/dist/assets/{toggle-DJ68kATc.js.map → toggle-BwoHYpMa.js.map} +1 -1
  56. package/extensions/dashboard-client/dist/assets/{useSSE-CXWh42xX.js → useSSE-DohG5AGv.js} +2 -2
  57. package/extensions/dashboard-client/dist/assets/{useSSE-CXWh42xX.js.map → useSSE-DohG5AGv.js.map} +1 -1
  58. package/extensions/dashboard-client/dist/index.html +1 -1
  59. package/extensions/dashboard-client/src/tabs/SetupTab/EmbedderSetup.tsx +14 -2
  60. package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
  61. package/extensions/dashboard-server/routes-setup-detect-cache.ts +224 -0
  62. package/extensions/dashboard-server/routes-setup.ts +19 -79
  63. package/package.json +1 -1
  64. package/src/config/vector-cortex-vc9d.ts +34 -0
  65. package/src/config/vector-cortex.ts +2 -1
  66. package/src/config.ts +1 -0
  67. package/extensions/dashboard-client/dist/assets/SetupTab-CJFDD2_v.js +0 -3
  68. package/extensions/dashboard-client/dist/assets/SetupTab-CJFDD2_v.js.map +0 -1
@@ -0,0 +1,32 @@
1
+ /**
2
+ * config/vector-cortex-vc9d.ts — VC9D embedder-detect consolidation sprint flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-vc9a.ts..vector-cortex-vc9c.ts
6
+ * were. This is the SETUP-DASHBOARD consolidation flag (the embedder-detect
7
+ * memoization + the shared 5s embedder poll). vector-cortex.ts re-exports it
8
+ * below and root src/config.ts re-exports it, so no consumer import path
9
+ * changes.
10
+ *
11
+ * The split is purely mechanical: VC9D_ENABLED is byte-identical in name,
12
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
13
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
14
+ * keeps resolving unchanged.
15
+ *
16
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
17
+ */
18
+ import { sprintFlag } from "./vector-cortex-flag.js";
19
+ /**
20
+ * VC9D — embedder detect consolidation + conformance roll-up. Default ON.
21
+ * `MEGACOMPACT_VC9D=0` disables and is byte-identical to the predecessor
22
+ * (VC9C-era): /api/setup-detect spawns its detectors fresh per request (no
23
+ * memoization) and the embedder sub-tab keeps its previous poll cadence. When
24
+ * ON, the detect path is memoized against the mutable input (resolved binary
25
+ * path + mtime) so consecutive requests reuse the result without re-spawning,
26
+ * and the embedder + cortex sub-tabs share the 5s poll contract. Detection is
27
+ * READ-ONLY — local binary spawns + filesystem stat only, no network
28
+ * (PREVENT-PI-004), never payload bytes/prompts/ledger (EVAL-REDACT-002). This
29
+ * flag MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
30
+ * EXCLUDED_SETTINGS), mirroring VC9A/VC9B/VC9C.
31
+ */
32
+ export const VC9D_ENABLED = () => sprintFlag("MEGACOMPACT_VC9D");
@@ -244,10 +244,11 @@ export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
244
244
  // Re-exported here so every existing `from "./config/vector-cortex.js"`
245
245
  // import keeps resolving unchanged.
246
246
  export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
247
- // VC9A/VC9B/VC9C split to vector-cortex-vc9{a,b,c}.ts to stay under the 300-line soft limit.
247
+ // VC9A/VC9B/VC9C/VC9D split to vector-cortex-vc9{a,b,c,d}.ts to stay under the 300-line soft limit.
248
248
  export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
249
249
  export { VC9B_ENABLED } from "./vector-cortex-vc9b.js";
250
250
  export { VC9C_ENABLED } from "./vector-cortex-vc9c.js";
251
+ export { VC9D_ENABLED } from "./vector-cortex-vc9d.js";
251
252
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
252
253
  // vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
253
254
  export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";
package/dist/config.js CHANGED
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
114
114
  // default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
115
115
  // so root consumers share one source of truth.
116
116
  // ---------------------------------------------------------------------------
117
- export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
117
+ export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
@@ -51,5 +51,6 @@ export const VECTOR_CORTEX_SETTINGS = {
51
51
  boolDirect("MEGACOMPACT_VC9A", "VC9A Setup Cortex Status", "Reader-only Setup Cortex status read path (GET /api/setup-cortex-status): surfaces the vector-cortex encoder gate — mode A/B/C, qualification verdict, open blockers, encoder health — to the dashboard Setup tab without closing the ML gate. OFF = byte-identical predecessor (VC8C-era): returns enabled:false / mode:C / status:off.", true),
52
52
  boolDirect("MEGACOMPACT_VC9B", "VC9B Setup Cortex Actions", "Setup Cortex action drivers (POST /api/setup-cortex-action + GET /api/setup-cortex-action-log): confirmation-gated wrappers that fetch-model / bench / verify-asset by spawning only the committed local scripts (scripts/vc2-model-prep/fetch-model.sh, bench-onnx.mjs) or re-reading the committed encoder assets — never payload bytes, no network. Actions gated by an OPEN hard-gate item (HG-1/HG-3) return action_blocked_by_open_item and do NOT spawn. OFF = byte-identical predecessor (VC9A-era): the action POST returns a disabled/404 shape and flag-off bytes are unchanged.", true),
53
53
  boolDirect("MEGACOMPACT_VC9C", "VC9C SetupTab Cortex Sub-tab", "SetupTab Cortex sub-tab (client UI): a Cortex sub-tab inside SetupTab that consumes the VC9A status endpoint (GET /api/setup-cortex-status) + the VC9B action endpoints. It surfaces the encoder mode A/B/C, asset digest prefix, qualification verdict + threshold failures, the open hard-gate blockers, and the confirmation-gated fetch/bench/verify actions. OFF = byte-identical predecessor (VC9B-era): the Cortex sub-tab is filtered from SUB_TABS and the Setup tab renders exactly as before.", true),
54
+ boolDirect("MEGACOMPACT_VC9D", "VC9D Embedder Detect Consolidation", "Embedder-detect consolidation + VC9 workstream roll-up: memoizes /api/setup-detect against the mutable input (resolved binary path + mtime) so consecutive requests reuse the result without re-spawning, and unifies the embedder + cortex sub-tabs' 5s poll contract. OFF = byte-identical predecessor (VC9C-era): detect spawns fresh per request and the embedder poll keeps its previous cadence.", true),
54
55
  ],
55
56
  };
@@ -0,0 +1,201 @@
1
+ /**
2
+ * dashboard-server/routes-setup-detect-cache.ts — memoized embedder-barrier
3
+ * detection (VC9D).
4
+ *
5
+ * The three raw fresh detectors (`detectOllama` / `detectLlamaCpp` /
6
+ * `detectOnnx`) moved verbatim out of routes-setup.ts — they are the source of
7
+ * truth for "is this embedder backend present". Each also has a memoized
8
+ * sibling (`memoizedDetectOllama` / `memoizedDetectLlamaCpp` /
9
+ * `memoizedDetectOnnx`) that runs the expensive spawn ONLY when its mutable
10
+ * input changes, matching the `healthFactCacheKey` invalidation semantics from
11
+ * routes-vector-cortex-health.ts:71-122: the cache key is the resolved binary
12
+ * path + its size/mtime (onnx: resolved module path + package mtime), so an
13
+ * install/upgrade on PATH or in node_modules naturally invalidates the entry,
14
+ * while a steady environment reuses the result instead of re-spawning.
15
+ *
16
+ * A single module-level slot per target is shared across every
17
+ * /api/setup-detect request, so consecutive polls reuse the result.
18
+ *
19
+ * Guardrails: PREVENT-PI-004 (local subprocess + filesystem reads only, no
20
+ * network), PREVENT-011 (no `any`). Each decoration line carries a
21
+ * guardrails-allow annotation.
22
+ */
23
+ import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: local subprocess detection only
24
+ import { createRequire } from "node:module";
25
+ import { statSync } from "node:fs";
26
+ // ---------------------------------------------------------------------------
27
+ // Raw fresh detectors (moved verbatim from routes-setup.ts — single source).
28
+ // ---------------------------------------------------------------------------
29
+ export function detectOllama() {
30
+ try {
31
+ const version = spawnSync("ollama", ["--version"], {
32
+ timeout: 5000,
33
+ encoding: "utf-8",
34
+ stdio: ["ignore", "pipe", "pipe"],
35
+ });
36
+ if (version.status !== 0) {
37
+ return { installed: false, models: [], running: false, detail: version.stderr?.trim() || "not found" };
38
+ }
39
+ // Check for running server
40
+ let running = false;
41
+ let models = [];
42
+ try {
43
+ const listResult = spawnSync("ollama", ["list"], {
44
+ timeout: 5000,
45
+ encoding: "utf-8",
46
+ stdio: ["ignore", "pipe", "pipe"],
47
+ });
48
+ if (listResult.status === 0) {
49
+ running = true;
50
+ // Parse lines: NAME ID SIZE MODIFIED
51
+ const lines = listResult.stdout?.split("\n") ?? [];
52
+ for (const line of lines) {
53
+ const name = line.split(/\s+/)[0];
54
+ if (name && name !== "NAME")
55
+ models.push(name);
56
+ }
57
+ }
58
+ }
59
+ catch {
60
+ // ollama list failed — server may not be running
61
+ running = false;
62
+ }
63
+ return {
64
+ installed: true,
65
+ models,
66
+ running,
67
+ detail: version.stdout?.trim() || null,
68
+ };
69
+ }
70
+ catch {
71
+ return { installed: false, models: [], running: false, detail: "detection error" };
72
+ }
73
+ }
74
+ export function detectLlamaCpp() {
75
+ try {
76
+ const which = spawnSync("which", ["llama-server", "llama.cpp"], {
77
+ timeout: 3000,
78
+ encoding: "utf-8",
79
+ stdio: ["ignore", "pipe", "pipe"],
80
+ });
81
+ const installed = which.status === 0 && which.stdout.trim().length > 0;
82
+ return {
83
+ installed,
84
+ detail: installed ? which.stdout.trim() : null,
85
+ };
86
+ }
87
+ catch {
88
+ return { installed: false, detail: "detection error" };
89
+ }
90
+ }
91
+ export function detectOnnx() {
92
+ try {
93
+ // Check for onnxruntime-node in a parent node_modules
94
+ const req = createRequire(import.meta.url);
95
+ try {
96
+ req.resolve("onnxruntime-node");
97
+ return { installed: true, detail: "onnxruntime-node found in node_modules" };
98
+ }
99
+ catch {
100
+ return { installed: false, detail: "onnxruntime-node not found in node_modules" };
101
+ }
102
+ }
103
+ catch {
104
+ return { installed: false, detail: "detection error" };
105
+ }
106
+ }
107
+ /** A single memo slot. `value` is never null for a detect result (objects only). */
108
+ export function createDetectMemo() {
109
+ let key = null;
110
+ let value = null;
111
+ return {
112
+ get(k) {
113
+ return key !== null && key === k ? value : null;
114
+ },
115
+ set(k, v) {
116
+ key = k;
117
+ value = v;
118
+ },
119
+ clear() {
120
+ key = null;
121
+ value = null;
122
+ },
123
+ };
124
+ }
125
+ /**
126
+ * Run `compute` only when the derived key changes; a null key (inputs not
127
+ * resolvable — e.g. the binary is absent) is never cached, so every call runs
128
+ * the (cheap, fast-failing) detect fresh. This ordering is what the
129
+ * SETUP-CORTEX-030/031 fixtures pin: an unchanged key returns the stored value
130
+ * without re-running compute; a key mutation forces a recompute.
131
+ */
132
+ export function withDetectMemo(slot, deriveKey, compute) {
133
+ const key = deriveKey();
134
+ const cached = key !== null ? slot.get(key) : null;
135
+ if (cached !== null)
136
+ return cached;
137
+ const value = compute();
138
+ if (key !== null)
139
+ slot.set(key, value);
140
+ return value;
141
+ }
142
+ // ---------------------------------------------------------------------------
143
+ // Mutable-input cache-key derivations.
144
+ // ---------------------------------------------------------------------------
145
+ /** Resolve the first PATH entry for a binary, or null when absent. */
146
+ function whichBin(bin) {
147
+ const r = spawnSync("which", [bin], {
148
+ timeout: 3000,
149
+ encoding: "utf-8",
150
+ // guardrails-allow PREVENT-PI-004: local which lookup only
151
+ stdio: ["ignore", "pipe", "pipe"],
152
+ });
153
+ if (r.status !== 0 || !r.stdout)
154
+ return null;
155
+ const first = r.stdout.trim().split("\n")[0]?.trim();
156
+ return first && first.length > 0 ? first : null;
157
+ }
158
+ /** Key = resolved path + size + mtimeMs, so an install/upgrade invalidates. */
159
+ function fileKey(p) {
160
+ if (p === null || p.length === 0)
161
+ return null;
162
+ try {
163
+ const s = statSync(p);
164
+ return `${p}:${s.size}:${s.mtimeMs}`;
165
+ }
166
+ catch {
167
+ return null;
168
+ }
169
+ }
170
+ /** Key = resolved module path + its package.json mtime (node_modules rebuild). */
171
+ function moduleKey(packageName) {
172
+ try {
173
+ const req = createRequire(import.meta.url);
174
+ const resolved = req.resolve(packageName + "/package.json");
175
+ return fileKey(resolved);
176
+ }
177
+ catch {
178
+ return null;
179
+ }
180
+ }
181
+ // ---------------------------------------------------------------------------
182
+ // Memoized wrappers (shared module-level slots across requests).
183
+ // ---------------------------------------------------------------------------
184
+ const ollamaSlot = createDetectMemo();
185
+ const llamaSlot = createDetectMemo();
186
+ const onnxSlot = createDetectMemo();
187
+ const ollamaKey = () => fileKey(whichBin("ollama"));
188
+ const llamaKey = () => fileKey(whichBin("llama-server") ?? whichBin("llama.cpp"));
189
+ const onnxKey = () => moduleKey("onnxruntime-node");
190
+ export function memoizedDetectOllama() {
191
+ // guardrails-allow PREVENT-PI-004: local subprocess detection only
192
+ return withDetectMemo(ollamaSlot, ollamaKey, detectOllama);
193
+ }
194
+ export function memoizedDetectLlamaCpp() {
195
+ // guardrails-allow PREVENT-PI-004: local subprocess detection only
196
+ return withDetectMemo(llamaSlot, llamaKey, detectLlamaCpp);
197
+ }
198
+ export function memoizedDetectOnnx() {
199
+ // guardrails-allow PREVENT-PI-004: local module resolution only
200
+ return withDetectMemo(onnxSlot, onnxKey, detectOnnx);
201
+ }
@@ -8,10 +8,10 @@
8
8
  * The detection commands run local subprocesses via spawnSync, NOT network calls.
9
9
  * Each decoration line carries a guardrails-allow annotation.
10
10
  */
11
- import { spawnSync } from "node:child_process"; // guardrails-allow PREVENT-PI-004: local subprocess detection only
12
- import { createRequire } from "node:module";
13
11
  import { writeFileSync, mkdirSync, readFileSync, existsSync } from "node:fs";
14
12
  import { join } from "node:path";
13
+ import { VC9D_ENABLED } from "../../src/config.js";
14
+ import { detectOllama, detectLlamaCpp, detectOnnx, memoizedDetectOllama, memoizedDetectLlamaCpp, memoizedDetectOnnx, } from "./routes-setup-detect-cache.js";
15
15
  // ---------------------------------------------------------------------------
16
16
  // handleSetupStatus — "/api/setup-status"
17
17
  // ---------------------------------------------------------------------------
@@ -73,84 +73,10 @@ export function handleSetupStatus(req, res, ctx) {
73
73
  // ---------------------------------------------------------------------------
74
74
  // handleSetupDetect — "/api/setup-detect"
75
75
  // ---------------------------------------------------------------------------
76
- function detectOllama() {
77
- try {
78
- const version = spawnSync("ollama", ["--version"], {
79
- timeout: 5000,
80
- encoding: "utf-8",
81
- stdio: ["ignore", "pipe", "pipe"],
82
- });
83
- if (version.status !== 0) {
84
- return { installed: false, models: [], running: false, detail: version.stderr?.trim() || "not found" };
85
- }
86
- // Check for running server
87
- let running = false;
88
- let models = [];
89
- try {
90
- const listResult = spawnSync("ollama", ["list"], {
91
- timeout: 5000,
92
- encoding: "utf-8",
93
- stdio: ["ignore", "pipe", "pipe"],
94
- });
95
- if (listResult.status === 0) {
96
- running = true;
97
- // Parse lines: NAME ID SIZE MODIFIED
98
- const lines = listResult.stdout?.split("\n") ?? [];
99
- for (const line of lines) {
100
- const name = line.split(/\s+/)[0];
101
- if (name && name !== "NAME")
102
- models.push(name);
103
- }
104
- }
105
- }
106
- catch {
107
- // ollama list failed — server may not be running
108
- running = false;
109
- }
110
- return {
111
- installed: true,
112
- models,
113
- running,
114
- detail: version.stdout?.trim() || null,
115
- };
116
- }
117
- catch {
118
- return { installed: false, models: [], running: false, detail: "detection error" };
119
- }
120
- }
121
- function detectLlamaCpp() {
122
- try {
123
- const which = spawnSync("which", ["llama-server", "llama.cpp"], {
124
- timeout: 3000,
125
- encoding: "utf-8",
126
- stdio: ["ignore", "pipe", "pipe"],
127
- });
128
- const installed = which.status === 0 && which.stdout.trim().length > 0;
129
- return {
130
- installed,
131
- detail: installed ? which.stdout.trim() : null,
132
- };
133
- }
134
- catch {
135
- return { installed: false, detail: "detection error" };
136
- }
137
- }
138
- function detectOnnx() {
139
- try {
140
- // Check for onnxruntime-node in a parent node_modules
141
- const req = createRequire(import.meta.url);
142
- try {
143
- req.resolve("onnxruntime-node");
144
- return { installed: true, detail: "onnxruntime-node found in node_modules" };
145
- }
146
- catch {
147
- return { installed: false, detail: "onnxruntime-node not found in node_modules" };
148
- }
149
- }
150
- catch {
151
- return { installed: false, detail: "detection error" };
152
- }
153
- }
76
+ // Detection bodies live in routes-setup-detect-cache.ts (single source). When
77
+ // MEGACOMPACT_VC9D is ON the memoized wrappers reuse the result across requests
78
+ // (keyed by the mutable input: resolved binary path + mtime); when OFF we call
79
+ // the raw fresh detectors — byte-identical to the VC9C-era per-request spawn.
154
80
  export function handleSetupDetect(req, res, _ctx) {
155
81
  if (req.url !== "/api/setup-detect")
156
82
  return false;
@@ -164,20 +90,22 @@ export function handleSetupDetect(req, res, _ctx) {
164
90
  let ollama = null;
165
91
  let llamaCpp = null;
166
92
  let onnx = null;
93
+ // guardrails-allow PREVENT-PI-004: local subprocess detection only (memoized or fresh)
94
+ const cached = VC9D_ENABLED();
167
95
  try {
168
- ollama = detectOllama();
96
+ ollama = cached ? memoizedDetectOllama() : detectOllama();
169
97
  }
170
98
  catch (e) {
171
99
  error = `ollama detection failed: ${e instanceof Error ? e.message : String(e)}`;
172
100
  }
173
101
  try {
174
- llamaCpp = detectLlamaCpp();
102
+ llamaCpp = cached ? memoizedDetectLlamaCpp() : detectLlamaCpp();
175
103
  }
176
104
  catch (e) {
177
105
  error = error ?? `llama.cpp detection failed: ${e instanceof Error ? e.message : String(e)}`;
178
106
  }
179
107
  try {
180
- onnx = detectOnnx();
108
+ onnx = cached ? memoizedDetectOnnx() : detectOnnx();
181
109
  }
182
110
  catch (e) {
183
111
  error = error ?? `onnx detection failed: ${e instanceof Error ? e.message : String(e)}`;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * config/vector-cortex-vc9d.ts — VC9D embedder-detect consolidation sprint flag.
3
+ *
4
+ * Extracted from vector-cortex.ts so that file stays under the 300-line soft
5
+ * limit (soft-as-hard gate), exactly as vector-cortex-vc9a.ts..vector-cortex-vc9c.ts
6
+ * were. This is the SETUP-DASHBOARD consolidation flag (the embedder-detect
7
+ * memoization + the shared 5s embedder poll). vector-cortex.ts re-exports it
8
+ * below and root src/config.ts re-exports it, so no consumer import path
9
+ * changes.
10
+ *
11
+ * The split is purely mechanical: VC9D_ENABLED is byte-identical in name,
12
+ * semantics, and default to the definition it replaces, and vector-cortex.ts
13
+ * re-exports it so every existing `from "./config/vector-cortex.js"` import
14
+ * keeps resolving unchanged.
15
+ *
16
+ * Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
17
+ */
18
+ import { sprintFlag } from "./vector-cortex-flag.js";
19
+ /**
20
+ * VC9D — embedder detect consolidation + conformance roll-up. Default ON.
21
+ * `MEGACOMPACT_VC9D=0` disables and is byte-identical to the predecessor
22
+ * (VC9C-era): /api/setup-detect spawns its detectors fresh per request (no
23
+ * memoization) and the embedder sub-tab keeps its previous poll cadence. When
24
+ * ON, the detect path is memoized against the mutable input (resolved binary
25
+ * path + mtime) so consecutive requests reuse the result without re-spawning,
26
+ * and the embedder + cortex sub-tabs share the 5s poll contract. Detection is
27
+ * READ-ONLY — local binary spawns + filesystem stat only, no network
28
+ * (PREVENT-PI-004), never payload bytes/prompts/ledger (EVAL-REDACT-002). This
29
+ * flag MUST also be a dashboard SETTINGS toggle (visible in config UI, never in
30
+ * EXCLUDED_SETTINGS), mirroring VC9A/VC9B/VC9C.
31
+ */
32
+ export const VC9D_ENABLED = () => sprintFlag("MEGACOMPACT_VC9D");
@@ -244,10 +244,11 @@ export const VC8B_ENABLED = () => sprintFlag("MEGACOMPACT_VC8B");
244
244
  // Re-exported here so every existing `from "./config/vector-cortex.js"`
245
245
  // import keeps resolving unchanged.
246
246
  export { VC8C_ENABLED } from "./vector-cortex-vc8c.js";
247
- // VC9A/VC9B/VC9C split to vector-cortex-vc9{a,b,c}.ts to stay under the 300-line soft limit.
247
+ // VC9A/VC9B/VC9C/VC9D split to vector-cortex-vc9{a,b,c,d}.ts to stay under the 300-line soft limit.
248
248
  export { VC9A_ENABLED } from "./vector-cortex-vc9a.js";
249
249
  export { VC9B_ENABLED } from "./vector-cortex-vc9b.js";
250
250
  export { VC9C_ENABLED } from "./vector-cortex-vc9c.js";
251
+ export { VC9D_ENABLED } from "./vector-cortex-vc9d.js";
251
252
  // Breaker state machine constants (TRIAD_RESILIENCE.md §breaker) extracted to
252
253
  // vector-cortex-breakers.ts to keep this file under the 300-line soft limit.
253
254
  export { BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./vector-cortex-breakers.js";
@@ -114,4 +114,4 @@ export const NEW_UI = () => ragEnabled("MEGACOMPACT_NEW_UI");
114
114
  // default ON, `=0`/`_DISABLED` off. Re-exported from src/config/vector-cortex.ts
115
115
  // so root consumers share one source of truth.
116
116
  // ---------------------------------------------------------------------------
117
- export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
117
+ export { VC0A_ENABLED, VC0B_ENABLED, VC1A_ENABLED, VC0C_ENABLED, VC1B_ENABLED, VC1C_ENABLED, VC2A_ENABLED, VC2B_ENABLED, VC2C_ENABLED, VC3A_ENABLED, VC3B_ENABLED, VC3C_ENABLED, VC4A_ENABLED, VC4B_ENABLED, VC4C_ENABLED, VC5A_ENABLED, VC5B_ENABLED, VC5C_ENABLED, VC6A_ENABLED, VC6B_ENABLED, VC6C_ENABLED, VC7A_ENABLED, VC7B_ENABLED, VC7C_ENABLED, VC8A_ENABLED, VC8B_ENABLED, VC8C_ENABLED, VC9A_ENABLED, VC9B_ENABLED, VC9C_ENABLED, VC9D_ENABLED, BREAKER_WINDOW_MS, BREAKER_MIN_ATTEMPTS, BREAKER_PERF_FAILURES, BREAKER_PERF_FAILURE_RATE, BREAKER_CORRECTNESS_FAILURES, BREAKER_COOLDOWN_MS, BREAKER_PROBE_COUNT, BREAKER_RETRY_BASE_MS, BREAKER_RETRY_CAP_MS, BREAKER_RETRY_JITTER, BREAKER_HYSTERESIS_FAILURE_RATE, BREAKER_HYSTERESIS_BUDGET_P95_MS, BREAKER_MIN_HEALTHY_RESIDENCE_MS, } from "./config/vector-cortex.js";
@@ -1,2 +1,2 @@
1
- import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-ChEYo017.js";import{R as p,F as ee,r as ve}from"./index-CB7Rn5FP.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
- //# sourceMappingURL=AreaChart-DIKsPqLG.js.map
1
+ import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-DtNoJ6fZ.js";import{R as p,F as ee,r as ve}from"./index-eoCm0uxj.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
+ //# sourceMappingURL=AreaChart-EL8l2Fcj.js.map