Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

remove analytics functionality and associated command from the CLI

0xken1546b11f268fd9
diff --git a/cli/src/backendSocket.ts b/cli/src/backendSocket.ts
index 441b54c25..4fb510fd2 100644
--- a/cli/src/backendSocket.ts
+++ b/cli/src/backendSocket.ts
@@ -471,8 +471,7 @@ export class BackendSocket {
this.testToken = auth ? undefined : machineId
// `?label=<hostname>` lets the backend record which machine connected (shown on the machine card);
// `?computer=<stable id>` enforces one-computer-per-computer (a 2nd computer is rejected with HTTP 409);
- // `?v=<VERSION>` is our own version, which the backend stores on the machine at every connect (the
- // analytics report also carries it, but that path is opt-in, so this is the reliable one).
+ // `?v=<VERSION>` is our own version, which the backend stores on the machine at every connect.
const base = `${env.BACKEND_WS_URL.replace(/\/$/, '')}/api/adapter-ws?label=${encodeURIComponent(hostname())}&v=${encodeURIComponent(VERSION)}&autonomousEnv=${encodeURIComponent(autonomousEnv)}`
// `?machine=<id>` is the machine this daemon still believes it is. The backend uses it to tell a
// REVOKED daemon — one whose machine was deleted while it was offline — apart from a first-time
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index b792e9e71..93de8cca6 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -101,8 +101,6 @@ import { createWindowRouter } from './cable/windowRoute.js'
import { RemoteRelayPool } from './lib/remoteRelay.js'
import { TERMINAL_BINARY_VERSION } from './lib/terminalBinary.js'
import { foldTranscript, lastTurnTextFromRawLines, lineToEvents, newTurnState, type LiveEvent, type TurnState } from './lib/normalize.js'
-import { AnalyticsCollector } from './lib/analytics/collector.js'
-import { runAnalyticsCommand } from './lib/analytics/command.js'
import { AskQuestionController, pollsQuestions, QuestionWatcher } from './lib/askQuestion.js'
import { CommanderMirror } from './lib/commander.js'
import {
@@ -1370,20 +1368,6 @@ async function runForeground(session: AuthSession): Promise<void> {
const devinReaders = new Map<string, DevinReader>()
const commandcodeNormalizers = new Map<string, CommandCodeNormalizer>()
const watcher = new Watcher()
- /**
- * Harness Analytics (autonomous-code docs/design/harness-analytics.md).
- *
- * Collection starts now; NOTHING is uploaded until the account owner has acknowledged the field
- * list — the backend answers `consent: "unacknowledged"` until then and the snapshot simply waits.
- * That hold is what lets the CLI be on by default while running headless, where there is no screen
- * to show a preview on.
- */
- const analytics = new AnalyticsCollector({
- token: () => readAuthSession()?.accessToken ?? null,
- enginesPresent: () => [...new Set(registry.list().map((entry) => entry.engine))],
- collectorVersion: VERSION,
- })
- analytics.start()
const queuedSessionEvents: Array<{
sessionId: string
events: ReturnType<CursorNormalizer['ingest']>
@@ -2003,14 +1987,6 @@ async function runForeground(session: AuthSession): Promise<void> {
backend.send(correlateAgentEvent(event, sessionId, agentId))
if (event.type === 'turn_started') {
turnStartedAt.set(sessionId, Date.now())
- // Analytics: count HERE, inside the one funnel every engine's normalizer feeds and BEFORE
- // backend.send seals the frame. The relay only ever sees ciphertext, so this is the only
- // layer that can tell a real instruction from a duplicated control frame.
- analytics.sessionTurnStarted(
- sessionId,
- registry.bySession(sessionId)?.engine ?? 'claude',
- agentIdFor(sessionId),
- )
console.log(`[turn] ${sid(sessionId)} started · engine=${registry.bySession(sessionId)?.engine ?? 'claude'} · bytes=${Buffer.byteLength(event.payload.userMessage, 'utf8')}`)
input.onTurnStarted(agentIdFor(sessionId), event.payload.userMessage)
autonomousDeviceService?.turnStarted(agentId)
@@ -2021,7 +1997,6 @@ async function runForeground(session: AuthSession): Promise<void> {
} else if (event.type === 'turn_ended') {
const startedAt = turnStartedAt.get(sessionId)
turnStartedAt.delete(sessionId)
- analytics.sessionTurnEnded(sessionId, event.payload.aborted === true)
// Say when a turn was KILLED. The log previously showed an interrupt as a fresh `[turn] started
// "[Request interrupted by user]"`, which read like a new prompt and hid the bug for weeks.
console.log(
@@ -2088,7 +2063,6 @@ async function runForeground(session: AuthSession): Promise<void> {
syncRecapPool()
turnStates.delete(sessionId)
turnStartedAt.delete(sessionId)
- analytics.sessionClosed(sessionId) // an open turn here died with the session; count it as failed
codexNormalizers.delete(sessionId)
cursorNormalizers.delete(sessionId)
opencodeReaders.get(sessionId)?.stop()
@@ -5141,12 +5115,6 @@ switch (cmd) {
case 'reset':
resetCommand().catch(onError)
break
- case 'analytics':
- // Local half of the consent contract: see exactly what would leave this computer, and stop it.
- // Runs without the daemon — it reads the persisted snapshot, so it works on a computer that has
- // never uploaded anything.
- console.log(runAnalyticsCommand(process.argv[3]))
- break
case 'status':
status().catch(onError)
break
diff --git a/cli/src/cliCommand.spec.ts b/cli/src/cliCommand.spec.ts
index 0f63c99a6..268bfdd4c 100644
--- a/cli/src/cliCommand.spec.ts
+++ b/cli/src/cliCommand.spec.ts
@@ -47,6 +47,13 @@ describe('CLI login/start command contract', () => {
expect(result.stderr).toContain('`harness login`, then `harness start`')
})
+ it('no longer has an analytics command (usage metering upload was removed)', () => {
+ const result = run('analytics')
+
+ expect(result.status).toBe(1)
+ expect(result.stderr).toContain('Unknown command: analytics')
+ })
+
it('returns a nonzero status for an unknown command', () => {
const result = run('not-a-command')
diff --git a/cli/src/config/env.ts b/cli/src/config/env.ts
index bab9cec15..15c1af34a 100644
--- a/cli/src/config/env.ts
+++ b/cli/src/config/env.ts
@@ -237,15 +237,6 @@ const envSchema = z.object({
// you to the file's id. Any 16-64 hex (dashes allowed, the backend de-dashes).
ADAPTER_COMPUTER_ID: z.string().optional(),
ADAPTER_COMPUTER_ID_FILE: z.string().default(computerIdFile),
- // ---- Harness Analytics (see autonomous-code docs/design/harness-analytics.md) ----
- // Collection is ON by default, but this computer uploads NOTHING until the account owner has
- // acknowledged the field list — the backend answers `consent: "unacknowledged"` until then. This
- // flag exists to switch the collector off entirely (tests, air-gapped installs).
- ANALYTICS_ENABLED: z.string().default('true').transform((v) => v !== 'false'),
- // Defaults to BACKEND_WS_URL over https — the ingest endpoint is the same host, and deliberately
- // NOT the adapter socket: analytics must not share a pipe with the E2EE content channel.
- ANALYTICS_BACKEND_URL: z.string().optional(),
- ANALYTICS_FLUSH_INTERVAL_MS: z.string().default('60000').transform(Number),
// Set to 'true' to skip auto-installing lifecycle hooks for every supported engine.
DISABLE_HOOK_INSTALL: z.string().default('false').transform((v) => v === 'true'),
// Additive terminal capability. Order controls deterministic primary-route tie breaking.
diff --git a/cli/src/engines/types.ts b/cli/src/engines/types.ts
index 6986b2baa..da7ff8f12 100644
--- a/cli/src/engines/types.ts
+++ b/cli/src/engines/types.ts
@@ -4,9 +4,9 @@ import type { RegisteredSession } from '../lib/registry.js'
/**
* Every engine this CLI integrates, as a value.
*
- * `AgentEngine` alone cannot be iterated, and analytics has to report exactly what it instruments —
- * so the list lives here once and both forms are derived from it. A new engine added to the union
- * without being added here fails to compile.
+ * `AgentEngine` alone cannot be iterated, and several places (discovery, hooks, probes) need to walk
+ * every engine — so the list lives here once and both forms are derived from it. A new engine added
+ * to the union without being added here fails to compile.
*/
export const ENGINES = [
'claude', 'codex', 'cursor', 'opencode', 'pi', 'hermes',