Skip to content

Write HTML. Render video. Built for agents.

fix(cli): load telemetry without the core and engine barrels, and stop the history test racing (#5153)

Miguel Ángel9fbec2259603
diff --git a/packages/cli/src/commands/history.test.ts b/packages/cli/src/commands/history.test.ts
index 4cbcc500cf..e254f680e5 100644
--- a/packages/cli/src/commands/history.test.ts
+++ b/packages/cli/src/commands/history.test.ts
@@ -8,6 +8,7 @@ import {
renameSync,
rmSync,
utimesSync,
+ watch,
writeFileSync,
} from "node:fs";
import type { AddressInfo } from "node:net";
@@ -429,6 +430,15 @@ describe("hyperframes history, one owner", () => {
const home = tempDir("hf-history-cli-home-");
const historyRoot = join(home, ".cache", "hyperframes", "history");
const held = await openProjectHistory({ projectDir: dir, historyRoot });
+ // The CLI's first try at the lock leaves a claim draft beside owner.pid: proof it found the history held.
+ const triedLock = new Promise<void>((tried) => {
+ const watcher = watch(join(historyRoot, held.projectId), (_event, name) => {
+ if (!name?.startsWith("owner.pid-")) return;
+ watcher.close();
+ tried();
+ });
+ onTestFinished(() => watcher.close());
+ });
write("index.html", "A2");
const cli = resolve(fileURLToPath(import.meta.url), "..", "..", "cli.ts");
const child = spawn("bun", ["run", cli, "history", "--dir", dir], {
@@ -440,9 +450,15 @@ describe("hyperframes history, one owner", () => {
HYPERFRAMES_NO_TELEMETRY: "1",
},
});
+ onTestFinished(() => void child.kill());
const exited = new Promise<number | null>((done) => child.on("exit", done));
const logFile = join(historyRoot, held.projectId, "log.jsonl");
- await new Promise((settle) => setTimeout(settle, 1500));
+ await Promise.race([
+ triedLock,
+ exited.then((code) => {
+ throw new Error(`the CLI exited (${code}) before trying the held lock`);
+ }),
+ ]);
expect(
readFileSync(logFile, "utf-8").trim().split("\n"),
"nothing written while held",
diff --git a/packages/cli/src/commands/history.ts b/packages/cli/src/commands/history.ts
index f8ccce3dc1..e0e0c24c7a 100644
--- a/packages/cli/src/commands/history.ts
+++ b/packages/cli/src/commands/history.ts
@@ -11,7 +11,7 @@ import {
type HistoryListItem,
type HistoryResult,
type HistoryWho,
-} from "@hyperframes/studio-server";
+} from "@hyperframes/studio-server/history";
import type { Example } from "./_examples.js";
import { trackHistoryAction } from "../telemetry/events.js";
import { setCommandExitCode } from "../utils/commandResult.js";
diff --git a/packages/cli/src/telemetry/events.ts b/packages/cli/src/telemetry/events.ts
index d8c42e6ec0..685014a8bd 100644
--- a/packages/cli/src/telemetry/events.ts
+++ b/packages/cli/src/telemetry/events.ts
@@ -1,5 +1,6 @@
import type { BrowserInstallFacts } from "../browser/installFacts.js";
-import { redactTelemetryString, type OutputResolutionIssueKind } from "@hyperframes/core";
+import type { OutputResolutionIssueKind } from "@hyperframes/core";
+import { redactTelemetryString } from "@hyperframes/core/telemetry-redaction";
import type { SubTimelineWaitOutcome } from "@hyperframes/engine";
import { FEEDBACK_RATING_SCALE } from "../utils/feedbackRating.js";
import type { CatalogUsage } from "../utils/catalogUsage.js";
diff --git a/packages/cli/src/telemetry/system.ts b/packages/cli/src/telemetry/system.ts
index 4cc32bed96..fbc8395fad 100644
--- a/packages/cli/src/telemetry/system.ts
+++ b/packages/cli/src/telemetry/system.ts
@@ -1,7 +1,7 @@
import { cpus, freemem, platform, release } from "node:os";
import { existsSync, readFileSync, statfsSync } from "node:fs";
import { execSync } from "node:child_process";
-import { getSystemTotalMb } from "@hyperframes/engine";
+import { getSystemTotalMb } from "@hyperframes/engine/system-memory";
import {
detectAgentRuntime,
detectAgentHints,
diff --git a/packages/cli/src/utils/historyOwner.ts b/packages/cli/src/utils/historyOwner.ts
index e9204c81bf..b4e5cc575e 100644
--- a/packages/cli/src/utils/historyOwner.ts
+++ b/packages/cli/src/utils/historyOwner.ts
@@ -10,7 +10,7 @@ import {
type HistoryResult,
type HistoryWho,
type UndoMode,
-} from "@hyperframes/studio-server";
+} from "@hyperframes/studio-server/history";
import { resolveProject } from "./project.js";
import { findPreviewServerForProject, studioApiUrl } from "./studioSelectionClient.js";
diff --git a/packages/cli/tsup.config.ts b/packages/cli/tsup.config.ts
index 118c34d9c2..1ef0b49ae6 100644
--- a/packages/cli/tsup.config.ts
+++ b/packages/cli/tsup.config.ts
@@ -97,6 +97,7 @@ var __dirname = __hf_dirname(__filename);`,
".",
"./chrome-host-ceiling",
"./shader-transitions",
+ "./system-memory",
]),
};
options.loader = { ...options.loader, ".browser.js": "text" };
diff --git a/packages/core/package-subpaths.json b/packages/core/package-subpaths.json
index 9f6200942a..82f694b022 100644
--- a/packages/core/package-subpaths.json
+++ b/packages/core/package-subpaths.json
@@ -26,6 +26,12 @@
"types": "./dist/canaryRegistry.d.ts",
"environments": ["browser", "bun", "node"]
},
+ "./telemetry-redaction": {
+ "source": "./src/telemetryRedaction.ts",
+ "runtime": "./dist/telemetryRedaction.js",
+ "types": "./dist/telemetryRedaction.d.ts",
+ "environments": ["browser", "bun", "node"]
+ },
"./beats": {
"source": "./src/beats/index.ts",
"runtime": "./dist/beats/index.js",
diff --git a/packages/core/package.json b/packages/core/package.json
index a97820354f..8bc6a89ae4 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -40,6 +40,12 @@
"import": "./src/canaryRegistry.ts",
"types": "./src/canaryRegistry.ts"
},
+ "./telemetry-redaction": {
+ "bun": "./src/telemetryRedaction.ts",
+ "node": "./dist/telemetryRedaction.js",
+ "import": "./src/telemetryRedaction.ts",
+ "types": "./src/telemetryRedaction.ts"
+ },
"./beats": {
"bun": "./src/beats/index.ts",
"node": "./dist/beats/index.js",
@@ -528,6 +534,10 @@
"import": "./dist/canaryRegistry.js",
"types": "./dist/canaryRegistry.d.ts"
},
+ "./telemetry-redaction": {
+ "import": "./dist/telemetryRedaction.js",
+ "types": "./dist/telemetryRedaction.d.ts"
+ },
"./beats": {
"import": "./dist/beats/index.js",
"types": "./dist/beats/index.d.ts"
diff --git a/packages/engine/package-subpaths.json b/packages/engine/package-subpaths.json
index 6c3390f6be..7fab5f1b3f 100644
--- a/packages/engine/package-subpaths.json
+++ b/packages/engine/package-subpaths.json
@@ -19,6 +19,12 @@
"types": "./dist/services/chromeHostCeiling.d.ts",
"environments": ["bun", "node"]
},
+ "./system-memory": {
+ "source": "./src/services/systemMemory.ts",
+ "runtime": "./dist/services/systemMemory.js",
+ "types": "./dist/services/systemMemory.d.ts",
+ "environments": ["bun", "node"]
+ },
"./shader-transitions": {
"source": "./src/utils/shaderTransitions.ts",
"runtime": "./dist/utils/shaderTransitions.js",
diff --git a/packages/engine/package.json b/packages/engine/package.json
index 27b5e4f57f..d43990b88e 100644
--- a/packages/engine/package.json
+++ b/packages/engine/package.json
@@ -30,6 +30,11 @@
"import": "./src/services/chromeHostCeiling.ts",
"types": "./src/services/chromeHostCeiling.ts"
},
+ "./system-memory": {
+ "bun": "./src/services/systemMemory.ts",
+ "import": "./src/services/systemMemory.ts",
+ "types": "./src/services/systemMemory.ts"
+ },
"./shader-transitions": {
"bun": "./src/utils/shaderTransitions.ts",
"import": "./src/utils/shaderTransitions.ts",
@@ -52,6 +57,10 @@
"import": "./dist/services/chromeHostCeiling.js",
"types": "./dist/services/chromeHostCeiling.d.ts"
},
+ "./system-memory": {
+ "import": "./dist/services/systemMemory.js",
+ "types": "./dist/services/systemMemory.d.ts"
+ },
"./shader-transitions": {
"import": "./dist/utils/shaderTransitions.js",
"types": "./dist/utils/shaderTransitions.d.ts"