@superblocksteam/sdk 2.0.118-next.0 → 2.0.118

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/cli-replacement/dev.d.mts +0 -6
  3. package/dist/cli-replacement/dev.d.mts.map +1 -1
  4. package/dist/cli-replacement/dev.mjs +0 -1
  5. package/dist/cli-replacement/dev.mjs.map +1 -1
  6. package/dist/client.d.ts +6 -67
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +0 -94
  9. package/dist/client.js.map +1 -1
  10. package/dist/dev-utils/dev-server-persist.test.mjs +17 -117
  11. package/dist/dev-utils/dev-server-persist.test.mjs.map +1 -1
  12. package/dist/dev-utils/dev-server.d.mts +1 -19
  13. package/dist/dev-utils/dev-server.d.mts.map +1 -1
  14. package/dist/dev-utils/dev-server.mjs +28 -296
  15. package/dist/dev-utils/dev-server.mjs.map +1 -1
  16. package/dist/flag.d.ts +1 -1
  17. package/dist/flag.d.ts.map +1 -1
  18. package/dist/flag.js +3 -3
  19. package/dist/flag.js.map +1 -1
  20. package/dist/index.d.ts +3 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/sdk.d.ts +1 -8
  25. package/dist/sdk.d.ts.map +1 -1
  26. package/dist/sdk.js +1 -24
  27. package/dist/sdk.js.map +1 -1
  28. package/dist/sdk.test.js +1 -102
  29. package/dist/sdk.test.js.map +1 -1
  30. package/dist/telemetry/index.d.ts +1 -2
  31. package/dist/telemetry/index.d.ts.map +1 -1
  32. package/dist/telemetry/index.js +1 -8
  33. package/dist/telemetry/index.js.map +1 -1
  34. package/dist/telemetry/logging.d.ts +2 -1
  35. package/dist/telemetry/logging.d.ts.map +1 -1
  36. package/dist/telemetry/logging.js +1 -1
  37. package/dist/telemetry/logging.js.map +1 -1
  38. package/dist/types/common.d.ts +1 -1
  39. package/dist/types/common.d.ts.map +1 -1
  40. package/dist/version-control.d.mts.map +1 -1
  41. package/dist/version-control.mjs +19 -14
  42. package/dist/version-control.mjs.map +1 -1
  43. package/eslint.config.js +0 -6
  44. package/package.json +8 -8
  45. package/src/cli-replacement/dev.mts +0 -8
  46. package/src/client.ts +6 -189
  47. package/src/dev-utils/dev-server-persist.test.mts +19 -170
  48. package/src/dev-utils/dev-server.mts +32 -366
  49. package/src/flag.ts +4 -4
  50. package/src/index.ts +1 -19
  51. package/src/sdk.test.ts +6 -145
  52. package/src/sdk.ts +0 -36
  53. package/src/telemetry/index.ts +1 -9
  54. package/src/telemetry/logging.ts +2 -2
  55. package/src/types/common.ts +1 -1
  56. package/src/version-control.mts +30 -11
  57. package/test/version-control.test.mts +2 -0
  58. package/tsconfig.tsbuildinfo +1 -1
  59. package/turbo.json +0 -1
  60. package/dist/dev-utils/dedupe-async.d.ts +0 -16
  61. package/dist/dev-utils/dedupe-async.d.ts.map +0 -1
  62. package/dist/dev-utils/dedupe-async.js +0 -27
  63. package/dist/dev-utils/dedupe-async.js.map +0 -1
  64. package/dist/dev-utils/dedupe-async.test.d.ts +0 -2
  65. package/dist/dev-utils/dedupe-async.test.d.ts.map +0 -1
  66. package/dist/dev-utils/dedupe-async.test.js +0 -120
  67. package/dist/dev-utils/dedupe-async.test.js.map +0 -1
  68. package/dist/dev-utils/dev-server-metrics.d.mts +0 -95
  69. package/dist/dev-utils/dev-server-metrics.d.mts.map +0 -1
  70. package/dist/dev-utils/dev-server-metrics.mjs +0 -193
  71. package/dist/dev-utils/dev-server-metrics.mjs.map +0 -1
  72. package/dist/telemetry/memory-metrics.d.ts +0 -3
  73. package/dist/telemetry/memory-metrics.d.ts.map +0 -1
  74. package/dist/telemetry/memory-metrics.js +0 -59
  75. package/dist/telemetry/memory-metrics.js.map +0 -1
  76. package/src/dev-utils/dedupe-async.test.ts +0 -151
  77. package/src/dev-utils/dedupe-async.ts +0 -45
  78. package/src/dev-utils/dev-server-metrics.mts +0 -252
  79. package/src/telemetry/memory-metrics.ts +0 -90
package/turbo.json CHANGED
@@ -16,7 +16,6 @@
16
16
  "SUPERBLOCKS_IS_CSB",
17
17
  "SUPERBLOCKS_SDK_LOG_LEVEL",
18
18
  "SUPERBLOCKS_LLMOBS_ENABLED",
19
- "SUPERBLOCKS_DEV_SERVER_MEMORY_METRICS_ENABLED",
20
19
  "SUPERBLOCKS_LOCAL_OBS",
21
20
  "SUPERBLOCKS_OTEL_COLLECTOR_URL",
22
21
  "SUPERBLOCKS_PROFILE",
@@ -1,16 +0,0 @@
1
- export interface DedupeAsyncOptions<TArgs extends unknown[]> {
2
- /**
3
- * Optional callback invoked when a duplicate call is detected. The first
4
- * caller's invocation runs normally; this fires for the 2nd, 3rd, …
5
- * Useful for logging "shutdown already in progress; ignoring duplicate
6
- * signal".
7
- *
8
- * Receives the *duplicate* call's args (not the first call's). The first
9
- * call's args are what the wrapped function actually ran with — duplicates
10
- * are intentionally short-circuited and their args are dropped from
11
- * execution but surfaced here for logging.
12
- */
13
- onDuplicate?: (...args: TArgs) => void;
14
- }
15
- export declare function dedupeAsync<TArgs extends unknown[], TResult>(fn: (...args: TArgs) => Promise<TResult>, options?: DedupeAsyncOptions<TArgs>): (...args: TArgs) => Promise<TResult>;
16
- //# sourceMappingURL=dedupe-async.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dedupe-async.d.ts","sourceRoot":"","sources":["../../src/dev-utils/dedupe-async.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,kBAAkB,CAAC,KAAK,SAAS,OAAO,EAAE;IACzD;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,IAAI,CAAC;CACxC;AAED,wBAAgB,WAAW,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,OAAO,EAC1D,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,EACxC,OAAO,GAAE,kBAAkB,CAAC,KAAK,CAAM,GACtC,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,CAAC,OAAO,CAAC,CAUtC"}
@@ -1,27 +0,0 @@
1
- // In-flight call deduper. Wraps an async function so that concurrent invocations
2
- // share the same promise — subsequent callers get the original in-flight result
3
- // instead of triggering another execution.
4
- //
5
- // After the wrapped function settles (resolves OR rejects) the cached promise is
6
- // retained so all post-settle callers receive the same outcome. There is no
7
- // reset path: callers that want to "run again later" should use a fresh
8
- // `dedupeAsync` instance.
9
- //
10
- // Used by the dev-server graceful shutdown path (hq-o55a). Multiple signals
11
- // (SIGINT, SIGTERM, SIGABRT, uncaughtException) can fire in rapid succession
12
- // during shutdown. Without a dedupe, every handler re-runs lockService /
13
- // vite / httpServer cleanup against already-freed native state, which surfaces
14
- // as `double free or corruption (fasttop)` from glibc and SIGABRT killing the
15
- // process before it can exit cleanly.
16
- export function dedupeAsync(fn, options = {}) {
17
- let inFlight = null;
18
- return (...args) => {
19
- if (inFlight) {
20
- options.onDuplicate?.(...args);
21
- return inFlight;
22
- }
23
- inFlight = fn(...args);
24
- return inFlight;
25
- };
26
- }
27
- //# sourceMappingURL=dedupe-async.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dedupe-async.js","sourceRoot":"","sources":["../../src/dev-utils/dedupe-async.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,gFAAgF;AAChF,2CAA2C;AAC3C,EAAE;AACF,iFAAiF;AACjF,4EAA4E;AAC5E,wEAAwE;AACxE,0BAA0B;AAC1B,EAAE;AACF,4EAA4E;AAC5E,6EAA6E;AAC7E,yEAAyE;AACzE,+EAA+E;AAC/E,8EAA8E;AAC9E,sCAAsC;AAiBtC,MAAM,UAAU,WAAW,CACzB,EAAwC,EACxC,UAAqC,EAAE;IAEvC,IAAI,QAAQ,GAA4B,IAAI,CAAC;IAC7C,OAAO,CAAC,GAAG,IAAW,EAAE,EAAE;QACxB,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YAC/B,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,QAAQ,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACvB,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=dedupe-async.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dedupe-async.test.d.ts","sourceRoot":"","sources":["../../src/dev-utils/dedupe-async.test.ts"],"names":[],"mappings":""}
@@ -1,120 +0,0 @@
1
- // Regression tests for the in-flight dedupe used by the dev-server graceful
2
- // shutdown path (hq-o55a). The bug being guarded against: multiple signals
3
- // (SIGINT, SIGTERM, SIGABRT, uncaughtException) fire in rapid succession during
4
- // shutdown and each handler re-runs cleanup against already-freed native state,
5
- // surfacing as `double free or corruption (fasttop)` from glibc.
6
- import { describe, expect, it, vi } from "vitest";
7
- import { dedupeAsync } from "./dedupe-async.js";
8
- describe("dedupeAsync", () => {
9
- it("invokes the wrapped function exactly once across concurrent calls", async () => {
10
- const inner = vi.fn(async () => "ok");
11
- const wrapped = dedupeAsync(inner);
12
- const results = await Promise.all([
13
- wrapped(),
14
- wrapped(),
15
- wrapped(),
16
- wrapped(),
17
- ]);
18
- expect(inner).toHaveBeenCalledTimes(1);
19
- expect(results).toEqual(["ok", "ok", "ok", "ok"]);
20
- });
21
- it("returns the same promise instance to all concurrent callers", () => {
22
- const inner = vi.fn(async () => 42);
23
- const wrapped = dedupeAsync(inner);
24
- const p1 = wrapped();
25
- const p2 = wrapped();
26
- expect(p1).toBe(p2);
27
- });
28
- it("invokes onDuplicate for each call after the first", async () => {
29
- let resolveInner = () => { };
30
- const inner = vi.fn(() => new Promise((resolve) => {
31
- resolveInner = resolve;
32
- }));
33
- const onDuplicate = vi.fn();
34
- const wrapped = dedupeAsync(inner, { onDuplicate });
35
- const p1 = wrapped();
36
- wrapped();
37
- wrapped();
38
- wrapped();
39
- expect(onDuplicate).toHaveBeenCalledTimes(3);
40
- expect(inner).toHaveBeenCalledTimes(1);
41
- resolveInner("done");
42
- await expect(p1).resolves.toBe("done");
43
- });
44
- it("retains the cached promise after the inner call settles — post-settle callers get the same outcome", async () => {
45
- const inner = vi.fn(async () => "shutdown-complete");
46
- const wrapped = dedupeAsync(inner);
47
- await expect(wrapped()).resolves.toBe("shutdown-complete");
48
- // Second invocation AFTER the first settled — must NOT re-trigger.
49
- await expect(wrapped()).resolves.toBe("shutdown-complete");
50
- expect(inner).toHaveBeenCalledTimes(1);
51
- });
52
- it("propagates rejection to all callers without re-running the inner function", async () => {
53
- const inner = vi.fn(async () => {
54
- throw new Error("boom");
55
- });
56
- const wrapped = dedupeAsync(inner);
57
- const p1 = wrapped();
58
- const p2 = wrapped();
59
- const p3 = wrapped();
60
- await expect(p1).rejects.toThrow(/boom/);
61
- await expect(p2).rejects.toThrow(/boom/);
62
- await expect(p3).rejects.toThrow(/boom/);
63
- expect(inner).toHaveBeenCalledTimes(1);
64
- });
65
- it("retains the cached rejection after the inner call settles — post-settle callers get the same rejection without re-run", async () => {
66
- // Guards against a future change that resets `inFlight = null` on
67
- // rejection (a plausible "retry on failure" tweak). The shutdown
68
- // contract is that BOTH outcomes are sticky — resolve and reject —
69
- // because re-entering cleanup after a failed first attempt is what
70
- // caused the original double-free. A passing test for the resolve path
71
- // alone would let that regression slip through.
72
- const inner = vi.fn(async () => {
73
- throw new Error("boom");
74
- });
75
- const wrapped = dedupeAsync(inner);
76
- await expect(wrapped()).rejects.toThrow(/boom/);
77
- // Second invocation AFTER the first rejection settled — must NOT
78
- // re-trigger and must surface the same rejection.
79
- await expect(wrapped()).rejects.toThrow(/boom/);
80
- expect(inner).toHaveBeenCalledTimes(1);
81
- });
82
- it("forwards args to the inner function on the first call only", async () => {
83
- const inner = vi.fn(async (a, b) => `${a}-${b}`);
84
- const wrapped = dedupeAsync(inner);
85
- const p1 = wrapped(1, "first");
86
- // Second call passes different args, but is short-circuited — inner
87
- // should NOT be invoked again. The dedupe is intentionally
88
- // input-agnostic: shutdown semantics don't depend on the second
89
- // signal's arguments.
90
- const p2 = wrapped(2, "second");
91
- await expect(p1).resolves.toBe("1-first");
92
- await expect(p2).resolves.toBe("1-first");
93
- expect(inner).toHaveBeenCalledTimes(1);
94
- expect(inner).toHaveBeenCalledWith(1, "first");
95
- });
96
- it("passes the duplicate caller's args to onDuplicate (for source-tagged logging)", async () => {
97
- // The dev-server graceful shutdown threads a `source` field through
98
- // (signal name, "uncaughtException", "/_sb_disconnect") so the
99
- // duplicate-suppression log can tell apart "4 OS signals fired" from
100
- // "1 signal fired and cleanup panicked 3 times". The dedupe must
101
- // forward each duplicate's own args, not the first caller's.
102
- let resolveInner = () => { };
103
- const inner = vi.fn((arg) => new Promise((resolve) => {
104
- resolveInner = () => resolve(arg);
105
- }));
106
- const onDuplicate = vi.fn();
107
- const wrapped = dedupeAsync(inner, { onDuplicate });
108
- const p1 = wrapped({ source: "SIGTERM" });
109
- wrapped({ source: "SIGINT" });
110
- wrapped({ source: "SIGABRT" });
111
- expect(onDuplicate).toHaveBeenCalledTimes(2);
112
- expect(onDuplicate).toHaveBeenNthCalledWith(1, { source: "SIGINT" });
113
- expect(onDuplicate).toHaveBeenNthCalledWith(2, { source: "SIGABRT" });
114
- expect(inner).toHaveBeenCalledTimes(1);
115
- expect(inner).toHaveBeenCalledWith({ source: "SIGTERM" });
116
- resolveInner();
117
- await p1;
118
- });
119
- });
120
- //# sourceMappingURL=dedupe-async.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dedupe-async.test.js","sourceRoot":"","sources":["../../src/dev-utils/dedupe-async.test.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,iEAAiE;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,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O,GAAG,WAAW,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC;QAEpD,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9B,OAAO,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAE/B,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrE,MAAM,CAAC,WAAW,CAAC,CAAC,uBAAuB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QACvC,MAAM,CAAC,KAAK,CAAC,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;QAE1D,YAAY,EAAE,CAAC;QACf,MAAM,EAAE,CAAC;IACX,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,95 +0,0 @@
1
- /**
2
- * Dev-server connection-phase metrics.
3
- *
4
- * Records counters and histograms for the dev-server endpoints that the editor
5
- * and SABS hit during a live-edit connection: `/_sb_health`, `/_sb_connect`,
6
- * `/_sb_activate`, `/_sb_disconnect`, `/_sb_status`, `/_sb_activity`, plus
7
- * WebSocket upgrades, Vite eager-init, and warm-standby activation.
8
- *
9
- * Metrics are scoped to the dev-server's existing OTel pipeline. When telemetry
10
- * has not yet initialized (warm-standby pre-activation), record calls are
11
- * buffered and replayed by `flush()` once `configureTelemetry` completes, so
12
- * warm-standby observations are not silently dropped into the no-op meter.
13
- */
14
- /** Dev-server endpoints that produce per-request metrics. */
15
- export type DevServerEndpoint = "_sb_health" | "_sb_connect" | "_sb_activate" | "_sb_disconnect" | "_sb_status" | "_sb_activity" | "_sb_persist" | "_sb_ready";
16
- /**
17
- * Coarse failure type for dev-server endpoint outcomes. Distinct from raw HTTP
18
- * status so dashboards can filter by reason without high-cardinality labels.
19
- */
20
- export type DevServerFailureType = "none" | "auth" | "validation" | "branch_mismatch" | "vite_init" | "internal";
21
- /**
22
- * Outcome of the warm-standby activation handshake.
23
- *
24
- * accepted - 200 OK, transitioning to full server
25
- * rejected - 400/413 (validation, body too large)
26
- * error - JSON parse / unexpected exception
27
- */
28
- export type WarmActivationOutcome = "accepted" | "rejected" | "error";
29
- /**
30
- * Records dev-server connection-phase metrics.
31
- *
32
- * Calls made before `configureTelemetry` completes are queued and replayed by
33
- * `flush()` once telemetry is online. Without this, warm-standby observations
34
- * are routed through `getMeter()`'s no-op fallback meter and silently dropped
35
- * — defeating the metric's purpose, since warm activation is exactly the path
36
- * we want to observe. The buffer is bounded to bound memory; instruments are
37
- * still NOT cached, so each replayed call resolves a fresh meter.
38
- */
39
- declare class DevServerMetrics {
40
- /**
41
- * Pre-init replay queue. Entries are bound `() => void` recorders that close
42
- * over their args at call time, so labels are captured even if the buffer is
43
- * drained much later.
44
- */
45
- private bufferedRecorders;
46
- /**
47
- * Routes a recorder to the live OTel meter when telemetry is up, or buffers
48
- * it for replay when telemetry has not yet initialized.
49
- */
50
- private record;
51
- /**
52
- * Replays buffered recorders against the (now-initialized) meter and clears
53
- * the queue. Idempotent — safe to call multiple times. Callers should invoke
54
- * this immediately after `configureTelemetry()` resolves.
55
- *
56
- * No-ops if telemetry did not actually come up (e.g., `configureTelemetry`
57
- * returned `false` due to a missing config or an internal init failure).
58
- * Draining the buffer through a still-no-op meter would silently lose every
59
- * observation AND clear the queue, so a later successful re-init via
60
- * `onTokenReceived` could not recover them. Keeping the buffer intact lets
61
- * a subsequent `flush()` call replay them once telemetry is genuinely live.
62
- */
63
- flush(): void;
64
- /**
65
- * Records the outcome of a dev-server HTTP endpoint request.
66
- */
67
- recordEndpoint(endpoint: DevServerEndpoint, method: string, status: number, durationMs: number, failureType?: DevServerFailureType): void;
68
- /**
69
- * Records a WebSocket upgrade attempt against the dev-server's HTTP socket.
70
- */
71
- recordSocketUpgrade(outcome: "accepted" | "rejected"): void;
72
- /**
73
- * Records the duration and outcome of Vite eager-init (the call that creates
74
- * the user-facing Vite server during /_sb_connect ramp-up).
75
- */
76
- recordViteEagerInit(durationMs: number, outcome: "success" | "error"): void;
77
- /**
78
- * Records the duration and outcome of warm-pod Vite dep-cache pre-warm.
79
- */
80
- recordWarmPrewarm(durationMs: number, outcome: "success" | "error"): void;
81
- /**
82
- * Records a warm-standby activation request outcome.
83
- */
84
- recordWarmActivation(outcome: WarmActivationOutcome): void;
85
- /**
86
- * Records the time from receiving a successful /_sb_activate POST to the
87
- * full Express dev-server being attached to the warm HTTP server (the
88
- * "no-port-gap" handoff window — gateways see 502s if this stretches).
89
- */
90
- recordWarmHandoff(durationMs: number): void;
91
- }
92
- /** Process-wide dev-server metrics singleton. */
93
- export declare const devServerMetrics: DevServerMetrics;
94
- export {};
95
- //# sourceMappingURL=dev-server-metrics.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-server-metrics.d.mts","sourceRoot":"","sources":["../../src/dev-utils/dev-server-metrics.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH,6DAA6D;AAC7D,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,aAAa,GACb,cAAc,GACd,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,aAAa,GACb,WAAW,CAAC;AAsBhB;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,MAAM,GACN,YAAY,GACZ,iBAAiB,GACjB,WAAW,GACX,UAAU,CAAC;AAEf;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAUtE;;;;;;;;;GASG;AACH,cAAM,gBAAgB;IACpB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB,CAAyB;IAElD;;;OAGG;IACH,OAAO,CAAC,MAAM;IAad;;;;;;;;;;;OAWG;IACH,KAAK,IAAI,IAAI;IAcb;;OAEG;IACH,cAAc,CACZ,QAAQ,EAAE,iBAAiB,EAC3B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,WAAW,GAAE,oBAA6B,GACzC,IAAI;IAyBP;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI;IAW3D;;;OAGG;IACH,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI;IAY3E;;OAEG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,IAAI;IAYzE;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI;IAW1D;;;;OAIG;IACH,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;CAW5C;AAED,iDAAiD;AACjD,eAAO,MAAM,gBAAgB,kBAAyB,CAAC"}
@@ -1,193 +0,0 @@
1
- /**
2
- * Dev-server connection-phase metrics.
3
- *
4
- * Records counters and histograms for the dev-server endpoints that the editor
5
- * and SABS hit during a live-edit connection: `/_sb_health`, `/_sb_connect`,
6
- * `/_sb_activate`, `/_sb_disconnect`, `/_sb_status`, `/_sb_activity`, plus
7
- * WebSocket upgrades, Vite eager-init, and warm-standby activation.
8
- *
9
- * Metrics are scoped to the dev-server's existing OTel pipeline. When telemetry
10
- * has not yet initialized (warm-standby pre-activation), record calls are
11
- * buffered and replayed by `flush()` once `configureTelemetry` completes, so
12
- * warm-standby observations are not silently dropped into the no-op meter.
13
- */
14
- import { isTelemetryInitialized } from "@superblocksteam/telemetry";
15
- import { getMeter } from "../telemetry/index.js";
16
- /**
17
- * Allowlisted HTTP methods recorded as the `method` metric label. Anything
18
- * outside this set — `req.method` is client-controlled, and `/_sb_health` is
19
- * unauthenticated — is bucketed as `'OTHER'` to keep label cardinality bounded.
20
- */
21
- const ALLOWED_METHODS = new Set([
22
- "GET",
23
- "HEAD",
24
- "POST",
25
- "PUT",
26
- "PATCH",
27
- "DELETE",
28
- "OPTIONS",
29
- ]);
30
- function sanitizeMethod(method) {
31
- const upper = method.toUpperCase();
32
- return ALLOWED_METHODS.has(upper) ? upper : "OTHER";
33
- }
34
- /**
35
- * Soft cap on buffered pre-init events. Warm-standby reasonably emits ~1
36
- * `recordWarmPrewarm` + ~1 `recordWarmActivation` before activation, so the
37
- * cap is generously above the expected load — it exists only to bound memory
38
- * if `flush()` is somehow never called.
39
- */
40
- const MAX_BUFFERED_EVENTS = 256;
41
- /**
42
- * Records dev-server connection-phase metrics.
43
- *
44
- * Calls made before `configureTelemetry` completes are queued and replayed by
45
- * `flush()` once telemetry is online. Without this, warm-standby observations
46
- * are routed through `getMeter()`'s no-op fallback meter and silently dropped
47
- * — defeating the metric's purpose, since warm activation is exactly the path
48
- * we want to observe. The buffer is bounded to bound memory; instruments are
49
- * still NOT cached, so each replayed call resolves a fresh meter.
50
- */
51
- class DevServerMetrics {
52
- /**
53
- * Pre-init replay queue. Entries are bound `() => void` recorders that close
54
- * over their args at call time, so labels are captured even if the buffer is
55
- * drained much later.
56
- */
57
- bufferedRecorders = [];
58
- /**
59
- * Routes a recorder to the live OTel meter when telemetry is up, or buffers
60
- * it for replay when telemetry has not yet initialized.
61
- */
62
- record(recorder) {
63
- if (isTelemetryInitialized()) {
64
- recorder();
65
- return;
66
- }
67
- if (this.bufferedRecorders.length >= MAX_BUFFERED_EVENTS) {
68
- // Drop the oldest event rather than the new one — the most recent
69
- // observations are typically the most informative for an investigator.
70
- this.bufferedRecorders.shift();
71
- }
72
- this.bufferedRecorders.push(recorder);
73
- }
74
- /**
75
- * Replays buffered recorders against the (now-initialized) meter and clears
76
- * the queue. Idempotent — safe to call multiple times. Callers should invoke
77
- * this immediately after `configureTelemetry()` resolves.
78
- *
79
- * No-ops if telemetry did not actually come up (e.g., `configureTelemetry`
80
- * returned `false` due to a missing config or an internal init failure).
81
- * Draining the buffer through a still-no-op meter would silently lose every
82
- * observation AND clear the queue, so a later successful re-init via
83
- * `onTokenReceived` could not recover them. Keeping the buffer intact lets
84
- * a subsequent `flush()` call replay them once telemetry is genuinely live.
85
- */
86
- flush() {
87
- if (!isTelemetryInitialized()) {
88
- return;
89
- }
90
- if (this.bufferedRecorders.length === 0) {
91
- return;
92
- }
93
- const events = this.bufferedRecorders;
94
- this.bufferedRecorders = [];
95
- for (const e of events) {
96
- e();
97
- }
98
- }
99
- /**
100
- * Records the outcome of a dev-server HTTP endpoint request.
101
- */
102
- recordEndpoint(endpoint, method, status, durationMs, failureType = "none") {
103
- const labels = {
104
- endpoint,
105
- method: sanitizeMethod(method),
106
- status: String(status),
107
- failure_type: failureType,
108
- };
109
- this.record(() => {
110
- const meter = getMeter();
111
- meter
112
- .createCounter("dev_server_endpoint_requests_total", {
113
- description: "Count of dev-server endpoint requests by endpoint, status, and failure type.",
114
- })
115
- .add(1, labels);
116
- meter
117
- .createHistogram("dev_server_endpoint_duration_ms", {
118
- description: "Latency of dev-server endpoint requests in milliseconds.",
119
- unit: "ms",
120
- })
121
- .record(durationMs, labels);
122
- });
123
- }
124
- /**
125
- * Records a WebSocket upgrade attempt against the dev-server's HTTP socket.
126
- */
127
- recordSocketUpgrade(outcome) {
128
- this.record(() => {
129
- getMeter()
130
- .createCounter("dev_server_socket_upgrade_total", {
131
- description: "Count of WebSocket upgrade attempts against the dev-server HTTP socket.",
132
- })
133
- .add(1, { outcome });
134
- });
135
- }
136
- /**
137
- * Records the duration and outcome of Vite eager-init (the call that creates
138
- * the user-facing Vite server during /_sb_connect ramp-up).
139
- */
140
- recordViteEagerInit(durationMs, outcome) {
141
- this.record(() => {
142
- getMeter()
143
- .createHistogram("dev_server_vite_eager_init_duration_ms", {
144
- description: "Duration of eager Vite server initialization in milliseconds.",
145
- unit: "ms",
146
- })
147
- .record(durationMs, { outcome });
148
- });
149
- }
150
- /**
151
- * Records the duration and outcome of warm-pod Vite dep-cache pre-warm.
152
- */
153
- recordWarmPrewarm(durationMs, outcome) {
154
- this.record(() => {
155
- getMeter()
156
- .createHistogram("dev_server_warm_prewarm_duration_ms", {
157
- description: "Duration of warm-standby Vite dep-cache pre-warm in milliseconds.",
158
- unit: "ms",
159
- })
160
- .record(durationMs, { outcome });
161
- });
162
- }
163
- /**
164
- * Records a warm-standby activation request outcome.
165
- */
166
- recordWarmActivation(outcome) {
167
- this.record(() => {
168
- getMeter()
169
- .createCounter("dev_server_warm_activation_total", {
170
- description: "Count of warm-standby /_sb_activate requests by outcome.",
171
- })
172
- .add(1, { outcome });
173
- });
174
- }
175
- /**
176
- * Records the time from receiving a successful /_sb_activate POST to the
177
- * full Express dev-server being attached to the warm HTTP server (the
178
- * "no-port-gap" handoff window — gateways see 502s if this stretches).
179
- */
180
- recordWarmHandoff(durationMs) {
181
- this.record(() => {
182
- getMeter()
183
- .createHistogram("dev_server_warm_activation_handoff_duration_ms", {
184
- description: "Time from /_sb_activate acceptance to full dev server attached, in milliseconds.",
185
- unit: "ms",
186
- })
187
- .record(durationMs);
188
- });
189
- }
190
- }
191
- /** Process-wide dev-server metrics singleton. */
192
- export const devServerMetrics = new DevServerMetrics();
193
- //# sourceMappingURL=dev-server-metrics.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-server-metrics.mjs","sourceRoot":"","sources":["../../src/dev-utils/dev-server-metrics.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAajD;;;;GAIG;AACH,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC;IACn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CAAC,MAAM,CAAC,GAAG,EAAE;YACf,QAAQ,EAAE;iBACP,eAAe,CAAC,qCAAqC,EAAE;gBACtD,WAAW,EACT,mEAAmE;gBACrE,IAAI,EAAE,IAAI;aACX,CAAC;iBACD,MAAM,CAAC,UAAU,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,oBAAoB,CAAC,OAA8B;QACjD,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,QAAQ,EAAE;iBACP,aAAa,CAAC,kCAAkC,EAAE;gBACjD,WAAW,EACT,0DAA0D;aAC7D,CAAC;iBACD,GAAG,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,iBAAiB,CAAC,UAAkB;QAClC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,QAAQ,EAAE;iBACP,eAAe,CAAC,gDAAgD,EAAE;gBACjE,WAAW,EACT,kFAAkF;gBACpF,IAAI,EAAE,IAAI;aACX,CAAC;iBACD,MAAM,CAAC,UAAU,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function startMemoryMetrics(): void;
2
- export declare function stopMemoryMetrics(): void;
3
- //# sourceMappingURL=memory-metrics.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-metrics.d.ts","sourceRoot":"","sources":["../../src/telemetry/memory-metrics.ts"],"names":[],"mappings":"AAWA,wBAAgB,kBAAkB,IAAI,IAAI,CAuEzC;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC"}
@@ -1,59 +0,0 @@
1
- import { PerformanceObserver, } from "node:perf_hooks";
2
- import { getMeter } from "./index.js";
3
- let cleanupFn;
4
- export function startMemoryMetrics() {
5
- if (cleanupFn) {
6
- return;
7
- }
8
- const meter = getMeter();
9
- const heapUsedGauge = meter.createObservableGauge("nodejs.memory.heap_used_bytes", { description: "V8 heap memory used (bytes)", unit: "By" });
10
- const heapTotalGauge = meter.createObservableGauge("nodejs.memory.heap_total_bytes", { description: "V8 heap memory allocated (bytes)", unit: "By" });
11
- const rssGauge = meter.createObservableGauge("nodejs.memory.rss_bytes", {
12
- description: "Resident Set Size - total memory allocated for the process",
13
- unit: "By",
14
- });
15
- const externalGauge = meter.createObservableGauge("nodejs.memory.external_bytes", {
16
- description: "Memory used by C++ objects bound to JavaScript objects",
17
- unit: "By",
18
- });
19
- const arrayBuffersGauge = meter.createObservableGauge("nodejs.memory.array_buffers_bytes", {
20
- description: "Memory allocated for ArrayBuffers and SharedArrayBuffers (also included in external)",
21
- unit: "By",
22
- });
23
- const gcCountCounter = meter.createCounter("nodejs.gc.count", {
24
- description: "Number of garbage collection events",
25
- unit: "{event}",
26
- });
27
- const gauges = [
28
- heapUsedGauge,
29
- heapTotalGauge,
30
- rssGauge,
31
- externalGauge,
32
- arrayBuffersGauge,
33
- ];
34
- // Single memoryUsage() call per export interval for all 5 gauges (idiomatic OTEL batch pattern).
35
- const batchCb = (result) => {
36
- const mem = process.memoryUsage();
37
- result.observe(heapUsedGauge, mem.heapUsed);
38
- result.observe(heapTotalGauge, mem.heapTotal);
39
- result.observe(rssGauge, mem.rss);
40
- result.observe(externalGauge, mem.external);
41
- result.observe(arrayBuffersGauge, mem.arrayBuffers);
42
- };
43
- meter.addBatchObservableCallback(batchCb, gauges);
44
- const gcObserver = new PerformanceObserver((list) => {
45
- gcCountCounter.add(list.getEntries().length);
46
- });
47
- gcObserver.observe({ entryTypes: ["gc"], buffered: false });
48
- cleanupFn = () => {
49
- gcObserver.disconnect();
50
- meter.removeBatchObservableCallback(batchCb, gauges);
51
- };
52
- }
53
- export function stopMemoryMetrics() {
54
- if (cleanupFn) {
55
- cleanupFn();
56
- cleanupFn = undefined;
57
- }
58
- }
59
- //# sourceMappingURL=memory-metrics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"memory-metrics.js","sourceRoot":"","sources":["../../src/telemetry/memory-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAEpB,MAAM,iBAAiB,CAAC;AAIzB,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,IAAI,SAAmC,CAAC;AAExC,MAAM,UAAU,kBAAkB;IAChC,IAAI,SAAS,EAAE,CAAC;QACd,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IAEzB,MAAM,aAAa,GAAG,KAAK,CAAC,qBAAqB,CAC/C,+BAA+B,EAC/B,EAAE,WAAW,EAAE,6BAA6B,EAAE,IAAI,EAAE,IAAI,EAAE,CAC3D,CAAC;IACF,MAAM,cAAc,GAAG,KAAK,CAAC,qBAAqB,CAChD,gCAAgC,EAChC,EAAE,WAAW,EAAE,kCAAkC,EAAE,IAAI,EAAE,IAAI,EAAE,CAChE,CAAC;IACF,MAAM,QAAQ,GAAG,KAAK,CAAC,qBAAqB,CAAC,yBAAyB,EAAE;QACtE,WAAW,EAAE,4DAA4D;QACzE,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,KAAK,CAAC,qBAAqB,CAC/C,8BAA8B,EAC9B;QACE,WAAW,EAAE,wDAAwD;QACrE,IAAI,EAAE,IAAI;KACX,CACF,CAAC;IACF,MAAM,iBAAiB,GAAG,KAAK,CAAC,qBAAqB,CACnD,mCAAmC,EACnC;QACE,WAAW,EACT,sFAAsF;QACxF,IAAI,EAAE,IAAI;KACX,CACF,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,aAAa,CAAC,iBAAiB,EAAE;QAC5D,WAAW,EAAE,qCAAqC;QAClD,IAAI,EAAE,SAAS;KAChB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG;QACb,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