@superblocksteam/sdk 2.0.83 → 2.0.84-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/cli-replacement/automatic-upgrades.d.ts +0 -6
  3. package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
  4. package/dist/cli-replacement/automatic-upgrades.js +5 -27
  5. package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
  6. package/dist/cli-replacement/dev.d.mts.map +1 -1
  7. package/dist/cli-replacement/dev.mjs +260 -217
  8. package/dist/cli-replacement/dev.mjs.map +1 -1
  9. package/dist/cli-replacement/version-detection.d.ts +71 -0
  10. package/dist/cli-replacement/version-detection.d.ts.map +1 -0
  11. package/dist/cli-replacement/version-detection.js +186 -0
  12. package/dist/cli-replacement/version-detection.js.map +1 -0
  13. package/dist/cli-replacement/version-detection.test.d.ts +5 -0
  14. package/dist/cli-replacement/version-detection.test.d.ts.map +1 -0
  15. package/dist/cli-replacement/version-detection.test.js +257 -0
  16. package/dist/cli-replacement/version-detection.test.js.map +1 -0
  17. package/dist/dev-utils/dev-server.mjs +133 -115
  18. package/dist/dev-utils/dev-server.mjs.map +1 -1
  19. package/dist/telemetry/index.d.ts +4 -4
  20. package/dist/telemetry/index.d.ts.map +1 -1
  21. package/dist/telemetry/index.js +92 -64
  22. package/dist/telemetry/index.js.map +1 -1
  23. package/dist/telemetry/index.test.d.ts +2 -0
  24. package/dist/telemetry/index.test.d.ts.map +1 -0
  25. package/dist/telemetry/index.test.js +93 -0
  26. package/dist/telemetry/index.test.js.map +1 -0
  27. package/dist/telemetry/local-obs.d.ts +73 -0
  28. package/dist/telemetry/local-obs.d.ts.map +1 -0
  29. package/dist/telemetry/local-obs.js +107 -0
  30. package/dist/telemetry/local-obs.js.map +1 -0
  31. package/dist/telemetry/util.d.ts +1 -2
  32. package/dist/telemetry/util.d.ts.map +1 -1
  33. package/dist/telemetry/util.js +26 -4
  34. package/dist/telemetry/util.js.map +1 -1
  35. package/package.json +6 -5
  36. package/src/cli-replacement/automatic-upgrades.ts +10 -42
  37. package/src/cli-replacement/dev.mts +336 -281
  38. package/src/cli-replacement/version-detection.test.ts +336 -0
  39. package/src/cli-replacement/version-detection.ts +220 -0
  40. package/src/dev-utils/dev-server.mts +149 -127
  41. package/src/telemetry/index.test.ts +130 -0
  42. package/src/telemetry/index.ts +105 -83
  43. package/src/telemetry/local-obs.ts +138 -0
  44. package/src/telemetry/util.ts +27 -4
  45. package/tsconfig.tsbuildinfo +1 -1
  46. package/turbo.json +20 -2
@@ -0,0 +1,93 @@
1
+ import { describe, it, expect, vi, beforeAll, afterAll, beforeEach, } from "vitest";
2
+ // Set environment variables before any imports
3
+ process.env.OTEL_SDK_DISABLED = "true";
4
+ process.env.SUPERBLOCKS_DEPLOYMENT_TYPE = "";
5
+ // Mock dd-trace before importing the module under test
6
+ vi.mock("dd-trace", () => ({
7
+ default: {
8
+ init: vi.fn(),
9
+ llmobs: { enabled: false },
10
+ },
11
+ }));
12
+ // Mock getConfiguration to avoid needing real credentials
13
+ vi.mock("./util.js", () => ({
14
+ SERVICE_NAME: "sdk-dev-server",
15
+ getConfiguration: vi.fn().mockResolvedValue({
16
+ superblocksBaseUrl: new URL("https://app.superblocks.com"),
17
+ otlpBaseUrl: "https://app.superblocks.com/api",
18
+ superblocksHostname: "app.superblocks.com",
19
+ serviceName: "sdk-dev-server",
20
+ token: "test1234",
21
+ }),
22
+ }));
23
+ // Mock the logging module
24
+ vi.mock("./logging.js", () => ({
25
+ getLogger: vi.fn().mockReturnValue({
26
+ info: vi.fn(),
27
+ debug: vi.fn(),
28
+ warn: vi.fn(),
29
+ error: vi.fn(),
30
+ }),
31
+ }));
32
+ describe("CLI SDK Telemetry Integration", () => {
33
+ let telemetryModule;
34
+ beforeAll(async () => {
35
+ // Dynamic import after mocks are set up
36
+ telemetryModule = await import("./index.js");
37
+ });
38
+ afterAll(async () => {
39
+ // Clean up telemetry
40
+ const { resetTelemetry, isTelemetryInitialized, getTelemetryInstance } = await import("@superblocksteam/telemetry");
41
+ if (isTelemetryInitialized()) {
42
+ await getTelemetryInstance().shutdown();
43
+ resetTelemetry();
44
+ }
45
+ });
46
+ beforeEach(() => {
47
+ vi.clearAllMocks();
48
+ });
49
+ describe("configureTelemetry", () => {
50
+ it("successfully initializes telemetry", async () => {
51
+ const { isTelemetryInitialized } = await import("@superblocksteam/telemetry");
52
+ await telemetryModule.configureTelemetry();
53
+ expect(isTelemetryInitialized()).toBe(true);
54
+ });
55
+ it("initializes dd-trace for LLMObs", async () => {
56
+ const ddTrace = await import("dd-trace");
57
+ await telemetryModule.configureTelemetry();
58
+ expect(ddTrace.default.init).toHaveBeenCalled();
59
+ });
60
+ });
61
+ describe("getTracer", () => {
62
+ it("returns working tracer after initialization", async () => {
63
+ await telemetryModule.configureTelemetry();
64
+ const tracer = telemetryModule.getTracer();
65
+ expect(tracer).toBeDefined();
66
+ expect(typeof tracer.startSpan).toBe("function");
67
+ });
68
+ it("can create spans", async () => {
69
+ await telemetryModule.configureTelemetry();
70
+ const tracer = telemetryModule.getTracer();
71
+ const span = tracer.startSpan("test-span");
72
+ expect(span).toBeDefined();
73
+ span.end();
74
+ });
75
+ });
76
+ describe("getLogger", () => {
77
+ it("returns working logger after initialization", async () => {
78
+ await telemetryModule.configureTelemetry();
79
+ const logger = telemetryModule.getLogger();
80
+ expect(logger).toBeDefined();
81
+ expect(typeof logger.emit).toBe("function");
82
+ });
83
+ });
84
+ describe("deploymentType", () => {
85
+ it("exports deploymentType constant", () => {
86
+ expect(telemetryModule.deploymentType).toBeDefined();
87
+ });
88
+ it("exports isCloudPrem constant", () => {
89
+ expect(typeof telemetryModule.isCloudPrem).toBe("boolean");
90
+ });
91
+ });
92
+ });
93
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/telemetry/index.test.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AAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;YACtC,MAAM,CAAC,OAAO,eAAe,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Local Observability Configuration
3
+ *
4
+ * Provides a single toggle (SUPERBLOCKS_LOCAL_OBS=true) that auto-configures
5
+ * all environment variables needed for local observability testing with the
6
+ * LGTM stack (Loki, Grafana, Tempo, Mimir).
7
+ *
8
+ * This eliminates the need to manually set 9+ environment variables:
9
+ * - SUPERBLOCKS_DEPLOYMENT_TYPE
10
+ * - SUPERBLOCKS_LLMOBS_ENABLED
11
+ * - OTEL_EXPORTER_OTLP_ENDPOINT
12
+ * - SUPERBLOCKS_OTEL_COLLECTOR_URL
13
+ * - DD_LLMOBS_ENABLED
14
+ * - DD_LLMOBS_ML_APP
15
+ * - DD_LLMOBS_AGENTLESS_ENABLED
16
+ * - DD_SITE
17
+ * - DD_API_KEY
18
+ *
19
+ * Usage:
20
+ * SUPERBLOCKS_LOCAL_OBS=true pnpm start:all
21
+ *
22
+ * Or with custom OTEL endpoint:
23
+ * SUPERBLOCKS_LOCAL_OBS=true OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 pnpm start:all
24
+ */
25
+ import { DeploymentTypeEnum } from "@superblocksteam/shared";
26
+ export interface LocalObsConfig {
27
+ /** Whether local observability mode is enabled */
28
+ enabled: boolean;
29
+ /** OTEL endpoint for traces, metrics, logs */
30
+ otelEndpoint: string;
31
+ /** Deployment type (cloud-prem for local obs) */
32
+ deploymentType: DeploymentTypeEnum.CLOUD_PREM;
33
+ /** LLMObs configuration */
34
+ llmobs: {
35
+ enabled: true;
36
+ mlApp: string;
37
+ agentlessEnabled: true;
38
+ };
39
+ /** Datadog configuration for dd-trace */
40
+ datadog: {
41
+ site: string;
42
+ apiKey: string;
43
+ };
44
+ }
45
+ /**
46
+ * Checks if local observability mode is enabled.
47
+ *
48
+ * Returns true if:
49
+ * - SUPERBLOCKS_LOCAL_OBS=true (primary toggle)
50
+ * - OR all required env vars are manually configured (legacy mode)
51
+ */
52
+ export declare function isLocalObsEnabled(): boolean;
53
+ /**
54
+ * Gets the local observability configuration.
55
+ *
56
+ * When SUPERBLOCKS_LOCAL_OBS=true, this returns a complete configuration
57
+ * with sensible defaults for local development. Individual values can still
58
+ * be overridden via environment variables.
59
+ *
60
+ * @returns LocalObsConfig if local obs is enabled, null otherwise
61
+ */
62
+ export declare function getLocalObsConfig(): LocalObsConfig | null;
63
+ /**
64
+ * Applies local observability configuration to process.env.
65
+ *
66
+ * This ensures that all downstream code that reads env vars directly
67
+ * (like dd-trace auto-initialization) gets the correct values.
68
+ *
69
+ * Should be called early in the application lifecycle, before any
70
+ * telemetry initialization occurs.
71
+ */
72
+ export declare function applyLocalObsEnvVars(): void;
73
+ //# sourceMappingURL=local-obs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-obs.d.ts","sourceRoot":"","sources":["../../src/telemetry/local-obs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAK7D,MAAM,WAAW,cAAc;IAC7B,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,cAAc,EAAE,kBAAkB,CAAC,UAAU,CAAC;IAC9C,2BAA2B;IAC3B,MAAM,EAAE;QACN,OAAO,EAAE,IAAI,CAAC;QACd,KAAK,EAAE,MAAM,CAAC;QACd,gBAAgB,EAAE,IAAI,CAAC;KACxB,CAAC;IACF,yCAAyC;IACzC,OAAO,EAAE;QACP,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAa3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,GAAG,IAAI,CAqBzD;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAwB3C"}
@@ -0,0 +1,107 @@
1
+ /**
2
+ * Local Observability Configuration
3
+ *
4
+ * Provides a single toggle (SUPERBLOCKS_LOCAL_OBS=true) that auto-configures
5
+ * all environment variables needed for local observability testing with the
6
+ * LGTM stack (Loki, Grafana, Tempo, Mimir).
7
+ *
8
+ * This eliminates the need to manually set 9+ environment variables:
9
+ * - SUPERBLOCKS_DEPLOYMENT_TYPE
10
+ * - SUPERBLOCKS_LLMOBS_ENABLED
11
+ * - OTEL_EXPORTER_OTLP_ENDPOINT
12
+ * - SUPERBLOCKS_OTEL_COLLECTOR_URL
13
+ * - DD_LLMOBS_ENABLED
14
+ * - DD_LLMOBS_ML_APP
15
+ * - DD_LLMOBS_AGENTLESS_ENABLED
16
+ * - DD_SITE
17
+ * - DD_API_KEY
18
+ *
19
+ * Usage:
20
+ * SUPERBLOCKS_LOCAL_OBS=true pnpm start:all
21
+ *
22
+ * Or with custom OTEL endpoint:
23
+ * SUPERBLOCKS_LOCAL_OBS=true OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318 pnpm start:all
24
+ */
25
+ import { DeploymentTypeEnum } from "@superblocksteam/shared";
26
+ const DEFAULT_LOCAL_OTEL_ENDPOINT = "http://localhost:24318";
27
+ const DEFAULT_ML_APP_NAME = "superblocks-ai-code-gen";
28
+ /**
29
+ * Checks if local observability mode is enabled.
30
+ *
31
+ * Returns true if:
32
+ * - SUPERBLOCKS_LOCAL_OBS=true (primary toggle)
33
+ * - OR all required env vars are manually configured (legacy mode)
34
+ */
35
+ export function isLocalObsEnabled() {
36
+ // Primary toggle
37
+ if (process.env.SUPERBLOCKS_LOCAL_OBS === "true") {
38
+ return true;
39
+ }
40
+ // Legacy mode: all env vars manually configured
41
+ const hasLegacyConfig = process.env.SUPERBLOCKS_DEPLOYMENT_TYPE === DeploymentTypeEnum.CLOUD_PREM &&
42
+ process.env.SUPERBLOCKS_LLMOBS_ENABLED === "true" &&
43
+ !!process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
44
+ return hasLegacyConfig;
45
+ }
46
+ /**
47
+ * Gets the local observability configuration.
48
+ *
49
+ * When SUPERBLOCKS_LOCAL_OBS=true, this returns a complete configuration
50
+ * with sensible defaults for local development. Individual values can still
51
+ * be overridden via environment variables.
52
+ *
53
+ * @returns LocalObsConfig if local obs is enabled, null otherwise
54
+ */
55
+ export function getLocalObsConfig() {
56
+ if (!isLocalObsEnabled()) {
57
+ return null;
58
+ }
59
+ return {
60
+ enabled: true,
61
+ otelEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || DEFAULT_LOCAL_OTEL_ENDPOINT,
62
+ deploymentType: DeploymentTypeEnum.CLOUD_PREM,
63
+ llmobs: {
64
+ enabled: true,
65
+ mlApp: process.env.DD_LLMOBS_ML_APP || DEFAULT_ML_APP_NAME,
66
+ agentlessEnabled: true,
67
+ },
68
+ datadog: {
69
+ site: process.env.DD_SITE || "datadoghq.com",
70
+ // Dummy key for agentless mode - not used when exporting to local OTEL
71
+ apiKey: process.env.DD_API_KEY || "local-dev-dummy-key",
72
+ },
73
+ };
74
+ }
75
+ /**
76
+ * Applies local observability configuration to process.env.
77
+ *
78
+ * This ensures that all downstream code that reads env vars directly
79
+ * (like dd-trace auto-initialization) gets the correct values.
80
+ *
81
+ * Should be called early in the application lifecycle, before any
82
+ * telemetry initialization occurs.
83
+ */
84
+ export function applyLocalObsEnvVars() {
85
+ const config = getLocalObsConfig();
86
+ if (!config) {
87
+ return;
88
+ }
89
+ // Apply env vars if not already set (allow explicit overrides)
90
+ const envDefaults = {
91
+ SUPERBLOCKS_DEPLOYMENT_TYPE: config.deploymentType,
92
+ SUPERBLOCKS_LLMOBS_ENABLED: "true",
93
+ OTEL_EXPORTER_OTLP_ENDPOINT: config.otelEndpoint,
94
+ SUPERBLOCKS_OTEL_COLLECTOR_URL: config.otelEndpoint,
95
+ DD_LLMOBS_ENABLED: "1",
96
+ DD_LLMOBS_ML_APP: config.llmobs.mlApp,
97
+ DD_LLMOBS_AGENTLESS_ENABLED: "1",
98
+ DD_SITE: config.datadog.site,
99
+ DD_API_KEY: config.datadog.apiKey,
100
+ };
101
+ for (const [key, value] of Object.entries(envDefaults)) {
102
+ if (!process.env[key]) {
103
+ process.env[key] = value;
104
+ }
105
+ }
106
+ }
107
+ //# sourceMappingURL=local-obs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"local-obs.js","sourceRoot":"","sources":["../../src/telemetry/local-obs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAE7D,MAAM,2BAA2B,GAAG,wBAAwB,CAAC;AAC7D,MAAM,mBAAmB,GAAG,yBAAyB,CAAC;AAsBtD;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB;IAC/B,iBAAiB;IACjB,IAAI,OAAO,CAAC,GAAG,CAAC,qBAAqB,KAAK,MAAM,EAAE,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gDAAgD;IAChD,MAAM,eAAe,GACnB,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,kBAAkB,CAAC,UAAU;QACzE,OAAO,CAAC,GAAG,CAAC,0BAA0B,KAAK,MAAM;QACjD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;IAE5C,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,OAAO,EAAE,IAAI;QACb,YAAY,EACV,O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@@
1
1
  export declare const SERVICE_NAME = "sdk-dev-server";
2
2
  export declare function getConfiguration(): Promise<{
3
3
  superblocksBaseUrl: import("url").URL;
4
- superblocksTracesUrl: string;
5
- superblocksLogsUrl: string;
4
+ otlpBaseUrl: string;
6
5
  superblocksHostname: string;
7
6
  serviceName: string;
8
7
  token: string;
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/telemetry/util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAE7C,wBAAsB,gBAAgB;;;;;;;GA0BrC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/telemetry/util.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,mBAAmB,CAAC;AA2B7C,wBAAsB,gBAAgB;;;;;;GAwBrC"}
@@ -1,11 +1,34 @@
1
1
  import { getLocalTokenWithUrl } from "@superblocksteam/util";
2
2
  export const SERVICE_NAME = "sdk-dev-server";
3
+ /**
4
+ * Get the OTLP base URL for telemetry export.
5
+ *
6
+ * Priority:
7
+ * 1. SUPERBLOCKS_OTEL_COLLECTOR_URL env var (for local obs mode)
8
+ * 2. Superblocks API endpoint derived from base URL
9
+ *
10
+ * When SUPERBLOCKS_OTEL_COLLECTOR_URL is set (e.g., http://localhost:24318),
11
+ * telemetry is sent directly to the local OTEL collector.
12
+ *
13
+ * Note: This returns the BASE URL. The telemetry library appends /v1/traces,
14
+ * /v1/metrics, /v1/logs to this URL.
15
+ */
16
+ function getOtlpBaseUrl(superblocksBaseUrl) {
17
+ const localOtelUrl = process.env.SUPERBLOCKS_OTEL_COLLECTOR_URL;
18
+ if (localOtelUrl) {
19
+ // Remove trailing /v1/traces etc. if present (just use base URL)
20
+ return localOtelUrl.replace(/\/v1\/(traces|metrics|logs)$/, "");
21
+ }
22
+ // Default: Superblocks API proxies OTLP requests
23
+ // The server expects /api/v1/traces but the telemetry lib adds /v1/traces,
24
+ // so we return /api and let telemetry lib append /v1/traces
25
+ return superblocksBaseUrl.origin + "/api";
26
+ }
3
27
  export async function getConfiguration() {
4
28
  try {
5
29
  const tokenWithUrl = await getLocalTokenWithUrl();
6
30
  const superblocksBaseUrl = new URL(tokenWithUrl.superblocksBaseUrl);
7
- const superblocksTracesUrl = superblocksBaseUrl.origin + "/api/v1/traces";
8
- const superblocksLogsUrl = superblocksBaseUrl.origin + "/api/v1/logs";
31
+ const otlpBaseUrl = getOtlpBaseUrl(superblocksBaseUrl);
9
32
  const superblocksHostname = superblocksBaseUrl.hostname;
10
33
  let token = "";
11
34
  if ("token" in tokenWithUrl) {
@@ -13,8 +36,7 @@ export async function getConfiguration() {
13
36
  }
14
37
  return {
15
38
  superblocksBaseUrl,
16
- superblocksTracesUrl,
17
- superblocksLogsUrl,
39
+ otlpBaseUrl,
18
40
  superblocksHostname,
19
41
  serviceName: SERVICE_NAME,
20
42
  token,
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/telemetry/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAClD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACpE,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,MAAM,GAAG,gBAAgB,CAAC;QAC1E,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,MAAM,GAAG,cAAc,CAAC;QACtE,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,CAAC;QACxD,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;YAC5B,KAAK,GAAG,YAAY,CAAC,KAAK,C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K,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO;YACL,kBAAkB;YAClB,WAAW;YACX,mBAAmB;YACnB,WAAW,EAAE,YAAY;YACzB,KAAK;SACN,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACX,4FAA4F,EAC5F,CAAC,CACF,CAAC;QACF,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superblocksteam/sdk",
3
- "version": "2.0.83",
3
+ "version": "2.0.84-next.0",
4
4
  "type": "module",
5
5
  "description": "Superblocks JS SDK",
6
6
  "homepage": "https://www.superblocks.com",
@@ -53,10 +53,11 @@
53
53
  "vite-tsconfig-paths": "^6.0.4",
54
54
  "winston": "^3.17.0",
55
55
  "yaml": "^2.7.1",
56
- "@superblocksteam/library-shared": "2.0.83",
57
- "@superblocksteam/shared": "0.9562.5",
58
- "@superblocksteam/util": "2.0.83",
59
- "@superblocksteam/vite-plugin-file-sync": "2.0.83"
56
+ "@superblocksteam/library-shared": "2.0.84-next.0",
57
+ "@superblocksteam/shared": "0.9563.1",
58
+ "@superblocksteam/telemetry": "2.0.84-next.0",
59
+ "@superblocksteam/vite-plugin-file-sync": "2.0.84-next.0",
60
+ "@superblocksteam/util": "2.0.84-next.0"
60
61
  },
61
62
  "optionalDependencies": {
62
63
  "@rollup/rollup-darwin-arm64": "^4.34.9",
@@ -10,6 +10,10 @@ import gt from "semver/functions/gt.js";
10
10
  import valid from "semver/functions/valid.js";
11
11
  import { getTracer } from "../telemetry/index.js";
12
12
  import { getErrorMeta, getLogger } from "../telemetry/logging.js";
13
+ import {
14
+ getCurrentCliVersion,
15
+ clearCliVersionCache,
16
+ } from "./version-detection.js";
13
17
  import type { ResponseMeta } from "../socket/handlers.js";
14
18
  import type { ApplicationConfigWithTokenConfigAndUserInfo } from "../types/common.js";
15
19
  import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
@@ -24,11 +28,6 @@ interface Versions {
24
28
  [pkg: string]: string;
25
29
  }
26
30
 
27
- interface PackageVersionInfo {
28
- version: string;
29
- alias?: string;
30
- }
31
-
32
31
  interface CheckVersionsErrorResponse {
33
32
  responseMeta: ResponseMeta;
34
33
  }
@@ -73,43 +72,6 @@ async function getRemoteVersions(
73
72
  }
74
73
  }
75
74
 
76
- export async function getCurrentCliVersion(): Promise<
77
- PackageVersionInfo | undefined
78
- > {
79
- try {
80
- const command = process.platform === "win32" ? "where" : "which";
81
- const { stdout } = await exec(`${command} superblocks`);
82
- const superblocksPath = stdout.trim();
83
-
84
- if (!superblocksPath) return undefined;
85
-
86
- const { stdout: versionOutput } = await exec(
87
- `${superblocksPath} version --json`,
88
- );
89
- const json = JSON.parse(versionOutput) as Record<string, string>;
90
- // Extract version from string like "@superblocksteam/cli/2.0.0-next.1" or "@superblocksteam/cli-ephemeral/2.0.0-SNAPSHOT.ebd2b86d643331f5"
91
- const version = json.cliVersion?.replace(
92
- /@superblocksteam\/cli(-ephemeral)?\//,
93
- "",
94
- );
95
-
96
- const aliasMatch = json.cliVersion?.match(/@superblocksteam\/([^\/]+)/);
97
- if (aliasMatch && aliasMatch[1] !== "cli") {
98
- return {
99
- version: version,
100
- alias: `@superblocksteam/${aliasMatch[1]}`,
101
- };
102
- }
103
-
104
- return { version };
105
- } catch (error) {
106
- if (isNativeError(error)) {
107
- logger.error(`Error getting CLI version: ${error.message}`);
108
- }
109
- return undefined;
110
- }
111
- }
112
-
113
75
  async function upgradeCliWithOclif(targetVersion: string): Promise<boolean> {
114
76
  try {
115
77
  const command = process.platform === "win32" ? "where" : "which";
@@ -185,6 +147,9 @@ async function upgradeCliWithPackageManager(
185
147
  // Wait for the install to complete, then validate the version
186
148
  await promise;
187
149
 
150
+ // Clear cache to force actual version detection (not just returning cached value)
151
+ clearCliVersionCache();
152
+
188
153
  const currentCliInfo = await getCurrentCliVersion();
189
154
  if (!currentCliInfo) {
190
155
  throw new Error("Could not get validate CLI version post-install");
@@ -196,6 +161,9 @@ async function upgradeCliWithPackageManager(
196
161
  );
197
162
  }
198
163
 
164
+ // Now that we've validated, cache the correct version (avoids re-detection on next call)
165
+ clearCliVersionCache({ version: targetVersion, alias });
166
+
199
167
  // This log line is used to end the upgrade spinner
200
168
  logger.info(`Successfully upgraded packages to ${targetVersion}`);
201
169
  }