pi-mega-compact 0.20.64 → 0.20.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/config/vector-cortex-enc2b.js +36 -0
- package/dist/config/vector-cortex.js +2 -0
- package/dist/config.js +1 -1
- package/dist/extensions/dashboard-server/routes-rag-settings-vector-cortex.js +1 -0
- package/dist/extensions/dashboard-server/routes-setup-enc2b.js +77 -0
- package/dist/extensions/dashboard-server/routes-setup.js +39 -3
- package/dist/extensions/mega-compact-s38.test/_helpers.js +2 -1
- package/dist/extensions/mega-compact.test/_helpers.js +4 -1
- package/dist/extensions/mega-events/agent-handlers/agentEndHandler.js +2 -2
- package/dist/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry-transient.js +131 -0
- package/dist/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry.js +13 -137
- package/dist/extensions/mega-events/compact-handlers.js +3 -3
- package/dist/extensions/mega-events/outage-advisor.js +5 -5
- package/dist/extensions/mega-events/send-safe.js +16 -0
- package/dist/src/config/vector-cortex-enc2b.js +36 -0
- package/dist/src/config/vector-cortex.js +2 -0
- package/dist/src/config.js +1 -1
- package/dist/src/vector-cortex/encoder/native-qualify-retest.js +225 -0
- package/dist/vector-cortex/encoder/native-qualify-retest.js +225 -0
- package/extensions/dashboard-client/dist/assets/{AdminTab-sjV8P5A4.js → AdminTab-B31efZ_R.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AdminTab-sjV8P5A4.js.map → AdminTab-B31efZ_R.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{AreaChart-C03yuld4.js → AreaChart-BpjHNUZm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{AreaChart-C03yuld4.js.map → AreaChart-BpjHNUZm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{BarChart-B9jtJ7ud.js → BarChart-CY2FndXC.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{BarChart-B9jtJ7ud.js.map → BarChart-CY2FndXC.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{CacheTab-B7Eh3qfp.js → CacheTab-kMSrMD3e.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{CacheTab-B7Eh3qfp.js.map → CacheTab-kMSrMD3e.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ConfigTab-DDTqosv2.js → ConfigTab-BrKpv2YG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ConfigTab-DDTqosv2.js.map → ConfigTab-BrKpv2YG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{EventsTab-BmyQGmUa.js → EventsTab-DaClreCm.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{EventsTab-BmyQGmUa.js.map → EventsTab-DaClreCm.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{HealthTab-DzPqNqpm.js → HealthTab-CxKQDqF3.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{HealthTab-DzPqNqpm.js.map → HealthTab-CxKQDqF3.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-6g3d-M1p.js → MaintenanceTab-BKSlSjv0.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MaintenanceTab-6g3d-M1p.js.map → MaintenanceTab-BKSlSjv0.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Nk2yYPMS.js → MemoryMapTab-C2goWDt8.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MemoryMapTab-Nk2yYPMS.js.map → MemoryMapTab-C2goWDt8.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{MetricsCards-BlIiuZp5.js → MetricsCards-DCPuCnrw.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{MetricsCards-BlIiuZp5.js.map → MetricsCards-DCPuCnrw.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/MetricsTab-Bz0Mdyb_.js +2 -0
- package/extensions/dashboard-client/dist/assets/{MetricsTab-DfRDIAEU.js.map → MetricsTab-Bz0Mdyb_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{OverviewTab-xkuFE5GV.js → OverviewTab-B-eZ-eDR.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{OverviewTab-xkuFE5GV.js.map → OverviewTab-B-eZ-eDR.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{ReposTab-C6qZmmgQ.js → ReposTab-W_NKRWpk.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{ReposTab-C6qZmmgQ.js.map → ReposTab-W_NKRWpk.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{SessionsTab-Bkd_In3n.js → SessionsTab-GYrtNt4_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{SessionsTab-Bkd_In3n.js.map → SessionsTab-GYrtNt4_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/SetupTab-_1xa6eTJ.js +3 -0
- package/extensions/dashboard-client/dist/assets/SetupTab-_1xa6eTJ.js.map +1 -0
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dr0KNUed.js → TimeSavedCard-Ciu8anVG.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TimeSavedCard-Dr0KNUed.js.map → TimeSavedCard-Ciu8anVG.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-CjmSiRQ_.js → TurnMemoryView-BhXLIjWr.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{TurnMemoryView-CjmSiRQ_.js.map → TurnMemoryView-BhXLIjWr.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-C-f3DggL.js +2 -0
- package/extensions/dashboard-client/dist/assets/{TurnsTab-JsDstDDA.js.map → TurnsTab-C-f3DggL.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-C96wfemg.js → VcStatusBadge-D97V04WE.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VcStatusBadge-C96wfemg.js.map → VcStatusBadge-D97V04WE.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-DGV3kA7X.js → VectorCortexTab-cyDJPAPB.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{VectorCortexTab-DGV3kA7X.js.map → VectorCortexTab-cyDJPAPB.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{WikiTab-EFfy5v-D.js → WikiTab-dQ96DyjP.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{WikiTab-EFfy5v-D.js.map → WikiTab-dQ96DyjP.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{button-CvaPx9Bu.js → button-B1beLEiV.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{button-CvaPx9Bu.js.map → button-B1beLEiV.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{card-Crs5SwRQ.js → card-CK9KH_ob.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{card-Crs5SwRQ.js.map → card-CK9KH_ob.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{client-extra-Bd27WKSo.js → client-extra-gN7xjggX.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{client-extra-Bd27WKSo.js.map → client-extra-gN7xjggX.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-qnHql9Es.js → generateCategoricalChart-MB2_0u55.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-qnHql9Es.js.map → generateCategoricalChart-MB2_0u55.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{index-B4twCFnn.js → index-CKVd_Ym_.js} +3 -3
- package/extensions/dashboard-client/dist/assets/{index-B4twCFnn.js.map → index-CKVd_Ym_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{switch-BXutQI5d.js → switch-CswmYrO_.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{switch-BXutQI5d.js.map → switch-CswmYrO_.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{toggle-uE-OSaba.js → toggle-CMepFsf0.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{toggle-uE-OSaba.js.map → toggle-CMepFsf0.js.map} +1 -1
- package/extensions/dashboard-client/dist/assets/{useSSE-BRgPAqeS.js → useSSE-Bl55LQFZ.js} +2 -2
- package/extensions/dashboard-client/dist/assets/{useSSE-BRgPAqeS.js.map → useSSE-Bl55LQFZ.js.map} +1 -1
- package/extensions/dashboard-client/dist/index.html +1 -1
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexRetestCard.tsx +104 -0
- package/extensions/dashboard-client/src/tabs/SetupTab/CortexSetup.tsx +2 -0
- package/extensions/dashboard-server/api-contracts/setup.ts +30 -0
- package/extensions/dashboard-server/routes-rag-settings-vector-cortex.ts +6 -0
- package/extensions/dashboard-server/routes-setup-enc2b.ts +82 -0
- package/extensions/dashboard-server/routes-setup.ts +39 -3
- package/extensions/mega-compact-s38.test/_helpers.ts +1 -1
- package/extensions/mega-compact.test/_helpers.ts +3 -1
- package/extensions/mega-events/agent-handlers/agentEndHandler.ts +2 -2
- package/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry-transient.ts +170 -0
- package/extensions/mega-events/agent-handlers/turnEndHandler/errorRetry.ts +12 -147
- package/extensions/mega-events/compact-handlers.ts +3 -3
- package/extensions/mega-events/outage-advisor.ts +5 -5
- package/extensions/mega-events/send-safe.ts +35 -4
- package/package.json +1 -1
- package/src/config/vector-cortex-enc2b.ts +38 -0
- package/src/config/vector-cortex.ts +2 -0
- package/src/config.ts +1 -0
- package/src/vector-cortex/encoder/native-qualify-retest.ts +264 -0
- package/extensions/dashboard-client/dist/assets/MetricsTab-DfRDIAEU.js +0 -2
- package/extensions/dashboard-client/dist/assets/SetupTab-CEXL71VP.js +0 -3
- package/extensions/dashboard-client/dist/assets/SetupTab-CEXL71VP.js.map +0 -1
- package/extensions/dashboard-client/dist/assets/TurnsTab-JsDstDDA.js +0 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* safeSendUserMessage — await + catch-guard + queue-safe wrapper for
|
|
3
3
|
* pi.sendUserMessage. Never throws; never produces an unhandled rejection.
|
|
4
|
+
* The message IS visible in the conversation UI ("Follow-up:").
|
|
4
5
|
*/
|
|
5
6
|
export async function safeSendUserMessage(pi, content) {
|
|
6
7
|
try {
|
|
@@ -10,3 +11,18 @@ export async function safeSendUserMessage(pi, content) {
|
|
|
10
11
|
/* non-fatal: a failed/queued nudge never blocks the agent loop */
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* safeSendInvisibleMessage — like safeSendUserMessage but uses pi.sendMessage
|
|
16
|
+
* with `display: false` so the retry trigger is delivered to the agent WITHOUT
|
|
17
|
+
* rendering in the conversation UI. Fixes the "Follow-up: [mega-compact] ..."
|
|
18
|
+
* pile-up when the API retries repeatedly — the retry mechanism still fires,
|
|
19
|
+
* the user just doesn't see the queued messages.
|
|
20
|
+
*/
|
|
21
|
+
export async function safeSendInvisibleMessage(pi, content) {
|
|
22
|
+
try {
|
|
23
|
+
await pi.sendMessage({ customType: "mega-compact-retry", content, display: false }, { deliverAs: "followUp" });
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
/* non-fatal: a failed/queued nudge never blocks the agent loop */
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* config/vector-cortex-enc2b.ts — ENC-2b native onnxruntime qualification
|
|
3
|
+
* retest flag.
|
|
4
|
+
*
|
|
5
|
+
* Sibling of vector-cortex-enc2a.ts / vector-cortex-enc2budget.ts so
|
|
6
|
+
* vector-cortex.ts stays under the 300-line soft limit (soft-as-hard gate).
|
|
7
|
+
* vector-cortex.ts re-exports the flag below and root src/config.ts re-exports
|
|
8
|
+
* it, so no consumer import path changes.
|
|
9
|
+
*
|
|
10
|
+
* ENC-2b re-probes and re-qualifies the installed native onnxruntime binding
|
|
11
|
+
* (`onnxruntime-node` in `~/.pi/mega-compact/native-ort/`, operator-installed
|
|
12
|
+
* via the ENC-2a guide). When the operator installs the binding the read path
|
|
13
|
+
* does not automatically re-evaluate the qualification verdict; this sprint
|
|
14
|
+
* delivers a reader-only retest that loads the LOCAL on-disk binding, runs a
|
|
15
|
+
* bounded warmup + p95 probe against it, measures RSS, computes a fresh
|
|
16
|
+
* qualification verdict against the ENC-0f p95 budget + the operator
|
|
17
|
+
* install-budget, and surfaces it on the Setup Cortex sub-tab and the GET
|
|
18
|
+
* `/api/setup-status` response.
|
|
19
|
+
*
|
|
20
|
+
* `MEGACOMPACT_ENC_2B=0` disables: the GET omits both new retest fields, the
|
|
21
|
+
* POST ignores the retest-request key, the Cortex sub-tab renders no retest
|
|
22
|
+
* card — byte-identical to the ENC-2a predecessor. The flag MUST also be a
|
|
23
|
+
* dashboard SETTINGS toggle (visible in config UI, never in EXCLUDED_SETTINGS
|
|
24
|
+
* — see `feedback_dashboard-flags-toggleable` memory).
|
|
25
|
+
*
|
|
26
|
+
* Pi-agnostic, dependency-free (PREVENT-PI-004 / PREVENT-011).
|
|
27
|
+
*/
|
|
28
|
+
import { sprintFlag } from "./vector-cortex-flag.js";
|
|
29
|
+
/**
|
|
30
|
+
* ENC-2b — native onnxruntime qualification retest (detect installed binding,
|
|
31
|
+
* re-probe p95/RSS, re-qualify). Default ON. `MEGACOMPACT_ENC_2B=0` disables and
|
|
32
|
+
* is byte-identical to the ENC-2a predecessor: no retest GET fields, no retest
|
|
33
|
+
* POST branch, no retest card. This flag MUST also be a dashboard SETTINGS
|
|
34
|
+
* toggle (visible in config UI, never in EXCLUDED_SETTINGS).
|
|
35
|
+
*/
|
|
36
|
+
export const ENC_2B_ENABLED = () => sprintFlag("MEGACOMPACT_ENC_2B");
|
|
@@ -52,5 +52,7 @@ export { ENC_1B_ENABLED, ENC_1B_MAX_EMBEDDING_DIM, ENC_1B_EMBEDDING_DIM_ENV, ENC
|
|
|
52
52
|
export { ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, } from "./vector-cortex-enc2budget.js";
|
|
53
53
|
// ENC-2a native onnxruntime install-guide flag extracted to vector-cortex-enc2a.ts.
|
|
54
54
|
export { ENC_2A_ENABLED } from "./vector-cortex-enc2a.js";
|
|
55
|
+
// ENC-2b native onnxruntime qualification-retest flag extracted to vector-cortex-enc2b.ts.
|
|
56
|
+
export { ENC_2B_ENABLED } from "./vector-cortex-enc2b.js";
|
|
55
57
|
// Breaker constants (TRIAD_RESILIENCE.md §breaker) extracted to vector-cortex-breakers.ts.
|
|
56
58
|
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/src/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, VC9D_ENABLED, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, ENC_2A_ENABLED, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_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, PCC_ENABLED, ML5A_ENABLED, ML5B_ENABLED, ML5C_ENABLED, ML5D_ENABLED, ML5E_ENABLED, DEDUP_ATTR_ENABLED, ENC_0A_ENABLED, ENC_0B_ENABLED, ENC_0C_ENABLED, ENC_0D_ENABLED, ENC_0E_ENABLED, ENC_0F_ENABLED, ENC_0G_ENABLED, ENC_1A_ENABLED, ENC_1B_ENABLED, ENC_2BUDGET_ENABLED, ENC_2BUDGET_NATIVE_ORT_BUDGET_ENV, ENC_2BUDGET_MAX_MIB, ENC_2BUDGET_DEFAULT_MIB, ENC_2A_ENABLED, ENC_2B_ENABLED, COSINE_FP_BENCH_ENABLED, COSINE_FP_REAL_ENABLED, REPO_CORPUS_ENABLED, DASH_0A_ENABLED, DASH_0B_ENABLED, DASH_0C_ENABLED, DASH_0D_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";
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/native-qualify-retest.ts — ENC-2b native onnxruntime
|
|
3
|
+
* qualification retest (reader-only probe).
|
|
4
|
+
*
|
|
5
|
+
* When an operator installs onnxruntime-node via the ENC-2a guide, the encoder
|
|
6
|
+
* read path does not automatically re-evaluate the qualification verdict — the
|
|
7
|
+
* encoder still reports encoderBackend "wasm" until a retest runs. This module
|
|
8
|
+
* is that retest: a pure, bounded, reader-only probe that
|
|
9
|
+
*
|
|
10
|
+
* (a) resolves the installed binding `<native-ort>/node_modules/onnxruntime-node/`;
|
|
11
|
+
* (b) reads its `package.json` version;
|
|
12
|
+
* (c) dynamic-imports the binding;
|
|
13
|
+
* (d) finds a LOCAL onnx model to probe against (under `~/.pi/mega-compact/`);
|
|
14
|
+
* (e) runs a bounded warmup (3 passes) + 10 timed inference passes on a fixed
|
|
15
|
+
* 512-token synthetic input (the bench-onnx.mjs harness shape, in-process);
|
|
16
|
+
* (f) measures p95 (sorted index) and RSS (`process.memoryUsage().rss`);
|
|
17
|
+
* (g) computes a fresh qualification verdict against the ENC-0f p95 budget
|
|
18
|
+
* (`ENCODER_LATENCY_P95_MS`) and the operator install-budget
|
|
19
|
+
* (`installBudgetMib()` as the RSS ceiling — the ENC-2budget derivative).
|
|
20
|
+
*
|
|
21
|
+
* Results: `{platform, version, verdict: "qualified"|"degraded"|"failed",
|
|
22
|
+
* p95Ms, rssMiB, testedAt}` or `null` when no binding is installed. It NEVER
|
|
23
|
+
* throws into the route layer: every binding-load/session/model failure is
|
|
24
|
+
* caught and reported as a `failed` verdict with the error message surfaced in
|
|
25
|
+
* the engine, never raised. NO network (PREVENT-PI-004 — the binding + model
|
|
26
|
+
* are on disk from the operator's ENC-2a install), NO training (HG-1 unchanged).
|
|
27
|
+
*
|
|
28
|
+
* Pi-agnostic, dependency-free. No `any` (PREVENT-011).
|
|
29
|
+
*/
|
|
30
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
import { ENCODER_LATENCY_P95_MS, ENCODER_MAX_TOKENS } from "./types.js";
|
|
33
|
+
import { installBudgetMib } from "./decision.js";
|
|
34
|
+
import { detectPlatform } from "./asset.js";
|
|
35
|
+
import { NATIVE_ORT_PACKAGE } from "./native-install-artifacts.js";
|
|
36
|
+
/** Candidate ONNX runtime native-ort prefixes. The ENC-2a guide installs to
|
|
37
|
+
* the global `~/.pi/mega-compact/native-ort/`; `stateDir` (per-repo) is a
|
|
38
|
+
* secondary probe root so the retest resolves either install location. */
|
|
39
|
+
function nativeOrtRootCandidates(stateDir) {
|
|
40
|
+
return [
|
|
41
|
+
join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort"),
|
|
42
|
+
join(stateDir, "native-ort"),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
/** A single bounded inference pass on the fixed 512-token synthetic input;
|
|
46
|
+
* returns latency ms, or null when the session cannot run (caller reports
|
|
47
|
+
* failed). The input mirrors bench-onnx.mjs: batch 1, 512 int64 ids. */
|
|
48
|
+
async function timedPass(ort, session, ids, mask, types) {
|
|
49
|
+
try {
|
|
50
|
+
const dims = [1, ENCODER_MAX_TOKENS];
|
|
51
|
+
const o = ort;
|
|
52
|
+
const s = session;
|
|
53
|
+
const feeds = {};
|
|
54
|
+
if (s.inputNames.includes("input_ids")) {
|
|
55
|
+
feeds.input_ids = new o.Tensor("int64", ids, dims);
|
|
56
|
+
}
|
|
57
|
+
if (s.inputNames.includes("attention_mask")) {
|
|
58
|
+
feeds.attention_mask = new o.Tensor("int64", mask, dims);
|
|
59
|
+
}
|
|
60
|
+
if (s.inputNames.includes("token_type_ids")) {
|
|
61
|
+
feeds.token_type_ids = new o.Tensor("int64", types, dims);
|
|
62
|
+
}
|
|
63
|
+
const t = process.hrtime.bigint();
|
|
64
|
+
await s.run(feeds);
|
|
65
|
+
return Number(process.hrtime.bigint() - t) / 1e6;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Resolve the first existing installed-binding package root, or the first
|
|
72
|
+
* candidate's path (for a missing-binding probe) when none exists. */
|
|
73
|
+
function bindingRootDir(stateDir) {
|
|
74
|
+
for (const root of nativeOrtRootCandidates(stateDir)) {
|
|
75
|
+
const pkg = join(root, "node_modules", NATIVE_ORT_PACKAGE);
|
|
76
|
+
if (existsSync(pkg))
|
|
77
|
+
return pkg;
|
|
78
|
+
}
|
|
79
|
+
return join(nativeOrtRootCandidates(stateDir)[0], "node_modules", NATIVE_ORT_PACKAGE);
|
|
80
|
+
}
|
|
81
|
+
/** Read the installed binding version from its package.json; null when absent. */
|
|
82
|
+
function readInstalledVersion(pkgJsonPath) {
|
|
83
|
+
try {
|
|
84
|
+
const raw = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
85
|
+
if (typeof raw === "object" &&
|
|
86
|
+
raw !== null &&
|
|
87
|
+
typeof raw.version === "string") {
|
|
88
|
+
return raw.version;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Locate a LOCAL onnx model to probe against, under the native-ort roots.
|
|
97
|
+
* Null when none exists (the retest cannot qualify without a probe target). */
|
|
98
|
+
function findLocalModel(stateDir) {
|
|
99
|
+
const candidates = [
|
|
100
|
+
join(nativeOrtRootCandidates(stateDir)[0], "model.onnx"),
|
|
101
|
+
join(stateDir, "model.onnx"),
|
|
102
|
+
];
|
|
103
|
+
for (const c of candidates) {
|
|
104
|
+
if (existsSync(c))
|
|
105
|
+
return c;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
/** p95 of sorted latencies (sorted-index percentile, bench-onnx idiom). */
|
|
110
|
+
function p95Of(sorted) {
|
|
111
|
+
if (sorted.length === 0)
|
|
112
|
+
return 0;
|
|
113
|
+
const idx = Math.min(sorted.length - 1, Math.floor(sorted.length * 0.95));
|
|
114
|
+
return +sorted[idx].toFixed(2);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Run the native onnxruntime qualification retest. Returns `RetestResult` on a
|
|
118
|
+
* completed (pass/fail/degrade) probe, or `null` when no binding is installed.
|
|
119
|
+
* Never throws: binding-load / session / model failures produce a `failed`
|
|
120
|
+
* verdict with the message on the result, and the `testedAt`/RSS are filled.
|
|
121
|
+
*/
|
|
122
|
+
export async function runNativeRetest(stateDir) {
|
|
123
|
+
const rootDir = bindingRootDir(stateDir);
|
|
124
|
+
const pkgJsonPath = join(rootDir, "package.json");
|
|
125
|
+
if (!existsSync(pkgJsonPath))
|
|
126
|
+
return null;
|
|
127
|
+
const version = readInstalledVersion(pkgJsonPath);
|
|
128
|
+
const platform = detectPlatform();
|
|
129
|
+
const platformStr = platform ?? `${process.platform}-${process.arch}`;
|
|
130
|
+
const testedAt = new Date().toISOString();
|
|
131
|
+
const rssMiB = +((process.memoryUsage().rss / 1048576).toFixed(1));
|
|
132
|
+
// Binding present but version unreadable — report failed (never throw).
|
|
133
|
+
if (version === null) {
|
|
134
|
+
return {
|
|
135
|
+
platform: platformStr,
|
|
136
|
+
version: "unknown",
|
|
137
|
+
verdict: "failed",
|
|
138
|
+
p95Ms: 0,
|
|
139
|
+
rssMiB,
|
|
140
|
+
testedAt,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Load the LOCAL binding via dynamic import. Load failure -> failed verdict.
|
|
144
|
+
let ort;
|
|
145
|
+
try {
|
|
146
|
+
ort = await import(join(rootDir, "lib", "index.js"));
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
try {
|
|
150
|
+
ort = await import(join(rootDir, "dist", "ort.node.mjs"));
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return {
|
|
154
|
+
platform: platformStr,
|
|
155
|
+
version,
|
|
156
|
+
verdict: "failed",
|
|
157
|
+
p95Ms: 0,
|
|
158
|
+
rssMiB,
|
|
159
|
+
testedAt,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Find a local probe model; without one the binding cannot be qualified.
|
|
164
|
+
const modelPath = findLocalModel(stateDir);
|
|
165
|
+
if (modelPath === null) {
|
|
166
|
+
return {
|
|
167
|
+
platform: platformStr,
|
|
168
|
+
version,
|
|
169
|
+
verdict: "failed",
|
|
170
|
+
p95Ms: 0,
|
|
171
|
+
rssMiB,
|
|
172
|
+
testedAt,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Create the session (bounded); failure -> failed.
|
|
176
|
+
try {
|
|
177
|
+
const factory = ort;
|
|
178
|
+
const session = await factory.InferenceSession.create(modelPath, {
|
|
179
|
+
executionProviders: ["cpu"],
|
|
180
|
+
intraOpNumThreads: 4,
|
|
181
|
+
graphOptimizationLevel: "all",
|
|
182
|
+
});
|
|
183
|
+
const n = ENCODER_MAX_TOKENS;
|
|
184
|
+
const ids = BigInt64Array.from({ length: n }, (_, i) => BigInt(i === 0 ? 101 : i === n - 1 ? 102 : 2000 + (i % 500)));
|
|
185
|
+
const mask = BigInt64Array.from({ length: n }, () => 1n);
|
|
186
|
+
const types = new BigInt64Array(n);
|
|
187
|
+
// Bounded warmup (3 passes) + 10 timed passes.
|
|
188
|
+
for (let i = 0; i < 3; i++)
|
|
189
|
+
await timedPass(ort, session, ids, mask, types);
|
|
190
|
+
const lat = [];
|
|
191
|
+
for (let i = 0; i < 10; i++) {
|
|
192
|
+
const ms = await timedPass(ort, session, ids, mask, types);
|
|
193
|
+
if (ms === null)
|
|
194
|
+
break;
|
|
195
|
+
lat.push(ms);
|
|
196
|
+
}
|
|
197
|
+
if (lat.length === 0) {
|
|
198
|
+
return {
|
|
199
|
+
platform: platformStr,
|
|
200
|
+
version,
|
|
201
|
+
verdict: "failed",
|
|
202
|
+
p95Ms: 0,
|
|
203
|
+
rssMiB,
|
|
204
|
+
testedAt,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
lat.sort((a, b) => a - b);
|
|
208
|
+
const p95Ms = p95Of(lat);
|
|
209
|
+
const rssBudgetMib = installBudgetMib();
|
|
210
|
+
const verdict = p95Ms <= ENCODER_LATENCY_P95_MS && rssMiB <= rssBudgetMib
|
|
211
|
+
? "qualified"
|
|
212
|
+
: "degraded";
|
|
213
|
+
return { platform: platformStr, version, verdict, p95Ms, rssMiB, testedAt };
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return {
|
|
217
|
+
platform: platformStr,
|
|
218
|
+
version,
|
|
219
|
+
verdict: "failed",
|
|
220
|
+
p95Ms: 0,
|
|
221
|
+
rssMiB,
|
|
222
|
+
testedAt,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vector-cortex/encoder/native-qualify-retest.ts — ENC-2b native onnxruntime
|
|
3
|
+
* qualification retest (reader-only probe).
|
|
4
|
+
*
|
|
5
|
+
* When an operator installs onnxruntime-node via the ENC-2a guide, the encoder
|
|
6
|
+
* read path does not automatically re-evaluate the qualification verdict — the
|
|
7
|
+
* encoder still reports encoderBackend "wasm" until a retest runs. This module
|
|
8
|
+
* is that retest: a pure, bounded, reader-only probe that
|
|
9
|
+
*
|
|
10
|
+
* (a) resolves the installed binding `<native-ort>/node_modules/onnxruntime-node/`;
|
|
11
|
+
* (b) reads its `package.json` version;
|
|
12
|
+
* (c) dynamic-imports the binding;
|
|
13
|
+
* (d) finds a LOCAL onnx model to probe against (under `~/.pi/mega-compact/`);
|
|
14
|
+
* (e) runs a bounded warmup (3 passes) + 10 timed inference passes on a fixed
|
|
15
|
+
* 512-token synthetic input (the bench-onnx.mjs harness shape, in-process);
|
|
16
|
+
* (f) measures p95 (sorted index) and RSS (`process.memoryUsage().rss`);
|
|
17
|
+
* (g) computes a fresh qualification verdict against the ENC-0f p95 budget
|
|
18
|
+
* (`ENCODER_LATENCY_P95_MS`) and the operator install-budget
|
|
19
|
+
* (`installBudgetMib()` as the RSS ceiling — the ENC-2budget derivative).
|
|
20
|
+
*
|
|
21
|
+
* Results: `{platform, version, verdict: "qualified"|"degraded"|"failed",
|
|
22
|
+
* p95Ms, rssMiB, testedAt}` or `null` when no binding is installed. It NEVER
|
|
23
|
+
* throws into the route layer: every binding-load/session/model failure is
|
|
24
|
+
* caught and reported as a `failed` verdict with the error message surfaced in
|
|
25
|
+
* the engine, never raised. NO network (PREVENT-PI-004 — the binding + model
|
|
26
|
+
* are on disk from the operator's ENC-2a install), NO training (HG-1 unchanged).
|
|
27
|
+
*
|
|
28
|
+
* Pi-agnostic, dependency-free. No `any` (PREVENT-011).
|
|
29
|
+
*/
|
|
30
|
+
import { readFileSync, existsSync } from "node:fs";
|
|
31
|
+
import { join } from "node:path";
|
|
32
|
+
import { ENCODER_LATENCY_P95_MS, ENCODER_MAX_TOKENS } from "./types.js";
|
|
33
|
+
import { installBudgetMib } from "./decision.js";
|
|
34
|
+
import { detectPlatform } from "./asset.js";
|
|
35
|
+
import { NATIVE_ORT_PACKAGE } from "./native-install-artifacts.js";
|
|
36
|
+
/** Candidate ONNX runtime native-ort prefixes. The ENC-2a guide installs to
|
|
37
|
+
* the global `~/.pi/mega-compact/native-ort/`; `stateDir` (per-repo) is a
|
|
38
|
+
* secondary probe root so the retest resolves either install location. */
|
|
39
|
+
function nativeOrtRootCandidates(stateDir) {
|
|
40
|
+
return [
|
|
41
|
+
join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort"),
|
|
42
|
+
join(stateDir, "native-ort"),
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
/** A single bounded inference pass on the fixed 512-token synthetic input;
|
|
46
|
+
* returns latency ms, or null when the session cannot run (caller reports
|
|
47
|
+
* failed). The input mirrors bench-onnx.mjs: batch 1, 512 int64 ids. */
|
|
48
|
+
async function timedPass(ort, session, ids, mask, types) {
|
|
49
|
+
try {
|
|
50
|
+
const dims = [1, ENCODER_MAX_TOKENS];
|
|
51
|
+
const o = ort;
|
|
52
|
+
const s = session;
|
|
53
|
+
const feeds = {};
|
|
54
|
+
if (s.inputNames.includes("input_ids")) {
|
|
55
|
+
feeds.input_ids = new o.Tensor("int64", ids, dims);
|
|
56
|
+
}
|
|
57
|
+
if (s.inputNames.includes("attention_mask")) {
|
|
58
|
+
feeds.attention_mask = new o.Tensor("int64", mask, dims);
|
|
59
|
+
}
|
|
60
|
+
if (s.inputNames.includes("token_type_ids")) {
|
|
61
|
+
feeds.token_type_ids = new o.Tensor("int64", types, dims);
|
|
62
|
+
}
|
|
63
|
+
const t = process.hrtime.bigint();
|
|
64
|
+
await s.run(feeds);
|
|
65
|
+
return Number(process.hrtime.bigint() - t) / 1e6;
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Resolve the first existing installed-binding package root, or the first
|
|
72
|
+
* candidate's path (for a missing-binding probe) when none exists. */
|
|
73
|
+
function bindingRootDir(stateDir) {
|
|
74
|
+
for (const root of nativeOrtRootCandidates(stateDir)) {
|
|
75
|
+
const pkg = join(root, "node_modules", NATIVE_ORT_PACKAGE);
|
|
76
|
+
if (existsSync(pkg))
|
|
77
|
+
return pkg;
|
|
78
|
+
}
|
|
79
|
+
return join(nativeOrtRootCandidates(stateDir)[0], "node_modules", NATIVE_ORT_PACKAGE);
|
|
80
|
+
}
|
|
81
|
+
/** Read the installed binding version from its package.json; null when absent. */
|
|
82
|
+
function readInstalledVersion(pkgJsonPath) {
|
|
83
|
+
try {
|
|
84
|
+
const raw = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
85
|
+
if (typeof raw === "object" &&
|
|
86
|
+
raw !== null &&
|
|
87
|
+
typeof raw.version === "string") {
|
|
88
|
+
return raw.version;
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** Locate a LOCAL onnx model to probe against, under the native-ort roots.
|
|
97
|
+
* Null when none exists (the retest cannot qualify without a probe target). */
|
|
98
|
+
function findLocalModel(stateDir) {
|
|
99
|
+
const candidates = [
|
|
100
|
+
join(nativeOrtRootCandidates(stateDir)[0], "model.onnx"),
|
|
101
|
+
join(stateDir, "model.onnx"),
|
|
102
|
+
];
|
|
103
|
+
for (const c of candidates) {
|
|
104
|
+
if (existsSync(c))
|
|
105
|
+
return c;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
/** p95 of sorted latencies (sorted-index percentile, bench-onnx idiom). */
|
|
110
|
+
function p95Of(sorted) {
|
|
111
|
+
if (sorted.length === 0)
|
|
112
|
+
return 0;
|
|
113
|
+
const idx = Math.min(sorted.length - 1, Math.floor(sorted.length * 0.95));
|
|
114
|
+
return +sorted[idx].toFixed(2);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Run the native onnxruntime qualification retest. Returns `RetestResult` on a
|
|
118
|
+
* completed (pass/fail/degrade) probe, or `null` when no binding is installed.
|
|
119
|
+
* Never throws: binding-load / session / model failures produce a `failed`
|
|
120
|
+
* verdict with the message on the result, and the `testedAt`/RSS are filled.
|
|
121
|
+
*/
|
|
122
|
+
export async function runNativeRetest(stateDir) {
|
|
123
|
+
const rootDir = bindingRootDir(stateDir);
|
|
124
|
+
const pkgJsonPath = join(rootDir, "package.json");
|
|
125
|
+
if (!existsSync(pkgJsonPath))
|
|
126
|
+
return null;
|
|
127
|
+
const version = readInstalledVersion(pkgJsonPath);
|
|
128
|
+
const platform = detectPlatform();
|
|
129
|
+
const platformStr = platform ?? `${process.platform}-${process.arch}`;
|
|
130
|
+
const testedAt = new Date().toISOString();
|
|
131
|
+
const rssMiB = +((process.memoryUsage().rss / 1048576).toFixed(1));
|
|
132
|
+
// Binding present but version unreadable — report failed (never throw).
|
|
133
|
+
if (version === null) {
|
|
134
|
+
return {
|
|
135
|
+
platform: platformStr,
|
|
136
|
+
version: "unknown",
|
|
137
|
+
verdict: "failed",
|
|
138
|
+
p95Ms: 0,
|
|
139
|
+
rssMiB,
|
|
140
|
+
testedAt,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
// Load the LOCAL binding via dynamic import. Load failure -> failed verdict.
|
|
144
|
+
let ort;
|
|
145
|
+
try {
|
|
146
|
+
ort = await import(join(rootDir, "lib", "index.js"));
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
try {
|
|
150
|
+
ort = await import(join(rootDir, "dist", "ort.node.mjs"));
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
return {
|
|
154
|
+
platform: platformStr,
|
|
155
|
+
version,
|
|
156
|
+
verdict: "failed",
|
|
157
|
+
p95Ms: 0,
|
|
158
|
+
rssMiB,
|
|
159
|
+
testedAt,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Find a local probe model; without one the binding cannot be qualified.
|
|
164
|
+
const modelPath = findLocalModel(stateDir);
|
|
165
|
+
if (modelPath === null) {
|
|
166
|
+
return {
|
|
167
|
+
platform: platformStr,
|
|
168
|
+
version,
|
|
169
|
+
verdict: "failed",
|
|
170
|
+
p95Ms: 0,
|
|
171
|
+
rssMiB,
|
|
172
|
+
testedAt,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
// Create the session (bounded); failure -> failed.
|
|
176
|
+
try {
|
|
177
|
+
const factory = ort;
|
|
178
|
+
const session = await factory.InferenceSession.create(modelPath, {
|
|
179
|
+
executionProviders: ["cpu"],
|
|
180
|
+
intraOpNumThreads: 4,
|
|
181
|
+
graphOptimizationLevel: "all",
|
|
182
|
+
});
|
|
183
|
+
const n = ENCODER_MAX_TOKENS;
|
|
184
|
+
const ids = BigInt64Array.from({ length: n }, (_, i) => BigInt(i === 0 ? 101 : i === n - 1 ? 102 : 2000 + (i % 500)));
|
|
185
|
+
const mask = BigInt64Array.from({ length: n }, () => 1n);
|
|
186
|
+
const types = new BigInt64Array(n);
|
|
187
|
+
// Bounded warmup (3 passes) + 10 timed passes.
|
|
188
|
+
for (let i = 0; i < 3; i++)
|
|
189
|
+
await timedPass(ort, session, ids, mask, types);
|
|
190
|
+
const lat = [];
|
|
191
|
+
for (let i = 0; i < 10; i++) {
|
|
192
|
+
const ms = await timedPass(ort, session, ids, mask, types);
|
|
193
|
+
if (ms === null)
|
|
194
|
+
break;
|
|
195
|
+
lat.push(ms);
|
|
196
|
+
}
|
|
197
|
+
if (lat.length === 0) {
|
|
198
|
+
return {
|
|
199
|
+
platform: platformStr,
|
|
200
|
+
version,
|
|
201
|
+
verdict: "failed",
|
|
202
|
+
p95Ms: 0,
|
|
203
|
+
rssMiB,
|
|
204
|
+
testedAt,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
lat.sort((a, b) => a - b);
|
|
208
|
+
const p95Ms = p95Of(lat);
|
|
209
|
+
const rssBudgetMib = installBudgetMib();
|
|
210
|
+
const verdict = p95Ms <= ENCODER_LATENCY_P95_MS && rssMiB <= rssBudgetMib
|
|
211
|
+
? "qualified"
|
|
212
|
+
: "degraded";
|
|
213
|
+
return { platform: platformStr, version, verdict, p95Ms, rssMiB, testedAt };
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
return {
|
|
217
|
+
platform: platformStr,
|
|
218
|
+
version,
|
|
219
|
+
verdict: "failed",
|
|
220
|
+
p95Ms: 0,
|
|
221
|
+
rssMiB,
|
|
222
|
+
testedAt,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
package/extensions/dashboard-client/dist/assets/{AdminTab-sjV8P5A4.js → AdminTab-B31efZ_R.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as s,u as o,e as c,j as e}from"./index-
|
|
2
|
-
//# sourceMappingURL=AdminTab-
|
|
1
|
+
import{r as s,u as o,e as c,j as e}from"./index-CKVd_Ym_.js";import{T as i}from"./toggle-CMepFsf0.js";import r from"./MaintenanceTab-BKSlSjv0.js";import{C as l}from"./ConfigTab-BrKpv2YG.js";import"./card-CK9KH_ob.js";import"./button-B1beLEiV.js";import"./switch-CswmYrO_.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
|
|
2
|
+
//# sourceMappingURL=AdminTab-B31efZ_R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminTab-
|
|
1
|
+
{"version":3,"file":"AdminTab-B31efZ_R.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
|
package/extensions/dashboard-client/dist/assets/{AreaChart-C03yuld4.js → AreaChart-BpjHNUZm.js}
RENAMED
|
@@ -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-qnHql9Es.js";import{R as p,J as ee,r as ve}from"./index-B4twCFnn.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-
|
|
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-MB2_0u55.js";import{R as p,J as ee,r as ve}from"./index-CKVd_Ym_.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-BpjHNUZm.js.map
|