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.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Store installs that fail say why; Windows names its missing git and shell (#2026)
0xken153633a6dc5d5c
diff --git a/backend/src/types/productUsage.ts b/backend/src/types/productUsage.tsindex 766b589f2..9bbf5fb88 100644--- a/backend/src/types/productUsage.ts+++ b/backend/src/types/productUsage.ts@@ -193,8 +193,20 @@ export const PRODUCT_USAGE_LAUNCH_ENGINES = ['opencode', 'claude', 'codex', 'othexport type ProductUsageLaunchEngine = typeof PRODUCT_USAGE_LAUNCH_ENGINES[number]/** Whether that engine had a credential on this computer, by presence only (cli/src/lib/engineAccount.ts). */export const PRODUCT_USAGE_ENGINE_ACCOUNTS = ['signed_in', 'signed_out', 'unknown'] as const+/** A Store install's or update's refusal by its code (dsh/install.ts, dsh/update.ts, dsh/lock.ts, services/store.ts, and+ * the core's answers for a service, core/serviceLinks.ts): the 11 Windows installs of 2026-10-28 were all `other`, with+ * nothing to say which. Every refusal is counted, so each family adds up to its `_failed`. A list of its own: these+ * never answer a launch, and in the launch list each would have joined all twelve launch families. Codes only. */+export const STORE_ERROR_CODES = ['invalid_dsh', 'dsh_busy', 'setup_failed', 'doctor_failed', 'git_unavailable',+ 'shell_unavailable', 'clone_failed', 'invalid_manifest', 'invalid_source', 'source_not_found', 'package_id_mismatch',+ 'package_kind_mismatch', 'viewer_unavailable', 'linked_install', 'not_installed', 'update_failed', 'bundled_package',+ 'remove_failed', 'internal', 'service_failed', 'service_unavailable', 'owner_required', 'unsupported',+ 'unsupported_on_remote', 'unlisted', 'none'] as const+export type StoreErrorCode = typeof STORE_ERROR_CODES[number]+export const STORE_ERROR_FAMILIES = ['store_install_error_code', 'store_update_error_code'] as constexport const PRODUCT_USAGE_LAUNCH_METRICS = [...LAUNCH_ERROR_FAMILIES.flatMap(family => LAUNCH_ERROR_CODES.map(code => `${family}_${code}` as const)),+ ...STORE_ERROR_FAMILIES.flatMap(family => STORE_ERROR_CODES.map(code => `${family}_${code}` as const)),...PRODUCT_USAGE_LAUNCH_ENGINES.map(engine => `first_launch_engine_${engine}` as const),...(['claude', 'codex'] as const).flatMap(engine => PRODUCT_USAGE_ENGINE_ACCOUNTS.map(account => `first_launch_${engine}_${account}` as const)),] as constdiff --git a/cli/src/dsh/install.spec.ts b/cli/src/dsh/install.spec.tsindex 2a0d62a48..d20fa5eb0 100644--- a/cli/src/dsh/install.spec.ts+++ b/cli/src/dsh/install.spec.ts@@ -359,13 +359,20 @@ describe('installDsh, every way it can go', () => {expect(await installDsh({ source: 'https://example.com/thing.git' })).toEqual({ ok: false, error: 'CLONE_FAILED', detail: 'git clone exited 1: Receiving objects: 20%' })})- it('no git at all is a failed clone that says so', async () => {+ it('no git at all is its own refusal, said in words, whichever way the package is fetched', async () => {+ // The Windows installer does not install Git: 7 of the 11 Windows installs of 2026-10-28 failed in under a+ // second as a bare `spawn git ENOENT` clone failure.const empty = join(root, 'empty-bin')mkdirSync(empty)process.env.PATH = empty- const result = await installDsh({ source: 'https://example.com/thing.git' })- expect(result).toMatchObject({ ok: false, error: 'CLONE_FAILED' })- expect(!result.ok && result.detail).toContain('ENOENT')+ const detail = 'Git is not installed on this computer, and installing a harness needs it. Install Git, then try again.'+ for (const [ref, path] of [[undefined, undefined], ['a'.repeat(40), undefined], [undefined, 'store/agents/thing']] as const) {+ const frames: DshInstallProgress[] = []+ const result = await installDsh({ source: 'https://example.com/thing.git', ref, path, onProgress: (p) => frames.push(p) })+ expect(result, `${ref} ${path}`).toEqual({ ok: false, error: 'GIT_UNAVAILABLE', detail })+ expect(frames.at(-1)).toEqual({ id: null, phase: 'failed', error: 'GIT_UNAVAILABLE', detail })+ }+ expect(leftovers()).toEqual([])})it('a clone still running after ten minutes is stopped, and said to have been', async () => {@@ -461,6 +468,36 @@ describe('installDsh, every way it can go', () => {})describe('setup, the used viewer, and the doctor', () => {+ describe('on a computer with no shell for them (Windows)', () => {+ const platform = Object.getOwnPropertyDescriptor(process, 'platform')!+ // Only the check reads the platform here: the fixture's clone and its harness folder are the real ones.+ beforeEach(() => { Object.defineProperty(process, 'platform', { ...platform, value: 'win32' }) })+ afterEach(() => { Object.defineProperty(process, 'platform', platform) })++ it('a harness with a setup or a doctor is refused before either runs, said in words, and not recorded', async () => {+ // 2026-10-28: every Store install on Windows failed; their setup and doctor ran through a /bin/sh Windows lacks.+ const detail = 'This harness runs a setup or check script, and Harness cannot run those on Windows yet.'+ for (const toolchain of [{ setup: 'setup.sh' }, { doctor: 'doctor.sh' }]) {+ rmSync(join(root, 'src'), { recursive: true, force: true })+ const repo = thing({ toolchain }, { 'setup.sh': '#!/bin/sh\ntouch set-up\n', 'doctor.sh': '#!/bin/sh\ntouch checked\n' })+ const frames: DshInstallProgress[] = []+ const result = await installDsh({ source: repo, onProgress: (p) => frames.push(p) })+ expect(result, JSON.stringify(toolchain)).toEqual({ ok: false, error: 'SHELL_UNAVAILABLE', detail })+ expect(frames.at(-1)).toEqual({ id: 'acme/thing', phase: 'failed', error: 'SHELL_UNAVAILABLE', detail })+ expect(frames.map((f) => f.phase)).toEqual(['clone', 'failed'])+ expect(existsSync(join(dshInstallDir('acme/thing'), 'set-up'))).toBe(false)+ expect(existsSync(join(dshInstallDir('acme/thing'), 'checked'))).toBe(false)+ expect(readInstalledIndex()).toEqual([])+ }+ })++ it('a harness with neither installs as before', async () => {+ const result = await installDsh({ source: thing() })+ expect(result.ok, JSON.stringify(result)).toBe(true)+ expect(readInstalledIndex().map((record) => record.id)).toEqual(['acme/thing'])+ })+ })+it('a bare script name is the harness\'s own script, as `harness dsh check` reads it, not a PATH lookup', async () => {// Found by this spec: `"setup": "setup.sh"` (the shape spec/README.md shows for a viewer package)// passed the check, which looks for the file, and then failed install with "command not found".diff --git a/cli/src/dsh/install.ts b/cli/src/dsh/install.tsindex e6e62e6a1..9be8a197d 100644--- a/cli/src/dsh/install.ts+++ b/cli/src/dsh/install.ts@@ -21,7 +21,7 @@ import { readDshManifest, viewerUse, type DshManifest } from './manifest.js'import { PACKAGE_PATH_RE, type DshRegistryEntry } from './registry.js'import { catalogEntry, refreshDshRegistry } from './catalog.js'import { resolveDshCommand } from './materialize.js'-import { runDshCommand } from './shell.js'+import { dshShellAvailable, runDshCommand } from './shell.js'import { lockDsh, dshBusy } from './lock.js'import { insideGitCheckout } from '../lib/gitProject.js'@@ -188,7 +188,7 @@ async function cloneOnce(// `--progress` because stderr is not a tty here and git would otherwise stay silent until the end;// streamed, not collected, so "Receiving objects: 39%" reaches the dialog while it is true.const clone = await cloneRepo(source, ref, tmpDir, false, onLine)- if (!clone.ok) return fail('CLONE_FAILED', clone.detail)+ if (!clone.ok) return fail(clone.noGit ? 'GIT_UNAVAILABLE' : 'CLONE_FAILED', clone.noGit ? NO_GIT : clone.detail)commit = await gitHead(tmpDir)revision = await gitHead(tmpDir, 'HEAD^{tree}')} else {@@ -199,7 +199,7 @@ async function cloneOnce(// whole-repo one (the manifest at its root) and nothing else of the monorepo lands on the machine.const repoDir = join(root, `.tmp-${randomUUID()}`)const clone = await cloneRepo(source, ref, repoDir, true, onLine)- if (!clone.ok) return fail('CLONE_FAILED', clone.detail, repoDir)+ if (!clone.ok) return fail(clone.noGit ? 'GIT_UNAVAILABLE' : 'CLONE_FAILED', clone.noGit ? NO_GIT : clone.detail, repoDir)const sparse = await streamGit(['-C', repoDir, 'sparse-checkout', 'set', '--', path], onLine)if (!sparse.ok) return fail('CLONE_FAILED', sparse.detail, repoDir)const folder = join(repoDir, ...path.split('/'))@@ -231,8 +231,14 @@ const GIT_ENV: NodeJS.ProcessEnv = {GIT_TERMINAL_PROMPT: '0',}+/**+ * A computer with no git at all. The Windows installer does not install Git, and 7 of the 11 Windows installs of+ * 2026-10-28 failed in under a second as `spawn git ENOENT` under a clone failure: said as what it is instead.+ */+const NO_GIT = 'Git is not installed on this computer, and installing a harness needs it. Install Git, then try again.'+/** Catalogs pin built-ins to the commit they describe; `git clone --branch` cannot take a SHA. */-async function cloneRepo(source: string, ref: string | undefined, dir: string, sparse: boolean, onLine: DshInstallOptions['onLine']): Promise<{ ok: true } | { ok: false; detail: string }> {+async function cloneRepo(source: string, ref: string | undefined, dir: string, sparse: boolean, onLine: DshInstallOptions['onLine']): Promise<GitResult> {if (!ref || !/^[a-f0-9]{40}$/i.test(ref)) {return streamGit(['clone', '--depth', '1', ...(sparse ? ['--filter=blob:none', '--sparse'] : []), '--progress', ...(ref ? ['--branch', ref] : []), '--', source, dir], onLine)}@@ -251,7 +257,9 @@ async function cloneRepo(source: string, ref: string | undefined, dir: string, s}/** Run git, handing each stderr line (and each carriage-return progress segment) to `onLine` as it lands. */-function streamGit(args: string[], onLine: ((line: string) => void) | undefined): Promise<{ ok: true } | { ok: false; detail: string }> {+type GitResult = { ok: true } | { ok: false; detail: string; noGit?: true }++function streamGit(args: string[], onLine: ((line: string) => void) | undefined): Promise<GitResult> {return new Promise((resolve) => {const child = spawn('git', args, { stdio: ['ignore', 'ignore', 'pipe'], env: { ...process.env, ...GIT_ENV } })const tail: string[] = []@@ -270,7 +278,10 @@ function streamGit(args: string[], onLine: ((line: string) => void) | undefined)if (tail.length > 20) tail.shift()}})- child.on('error', (error) => { clearTimeout(timer); resolve({ ok: false, detail: error.message }) })+ child.on('error', (error: NodeJS.ErrnoException) => {+ clearTimeout(timer)+ resolve({ ok: false, detail: error.message, ...(error.code === 'ENOENT' ? { noGit: true as const } : {}) })+ })// Exit may precede the last stderr data. Classify the failure only once// the pipe closes, so a retryable Git error cannot become an empty one.child.on('close', (code, signal) => {@@ -395,6 +406,13 @@ export async function finishInstall(resolved: InstalledDsh, opts: DshInstallOpticonst { manifest, realDir } = resolvedconst progress = (p: DshInstallProgress): void => opts.onProgress?.(p)+ // Refused before anything runs, rather than as a setup or doctor that could not start (`spawn /bin/sh ENOENT`).+ if ((manifest.toolchain?.setup || manifest.toolchain?.doctor) && !dshShellAvailable()) {+ const detail = 'This harness runs a setup or check script, and Harness cannot run those on Windows yet.'+ progress({ id: manifest.id, phase: 'failed', detail, error: 'SHELL_UNAVAILABLE' })+ return { ok: false, error: 'SHELL_UNAVAILABLE', detail }+ }+const setupLines: string[] = []if (manifest.toolchain?.setup) {progress({ id: manifest.id, phase: 'setup', detail: manifest.toolchain.setup })diff --git a/cli/src/dsh/shell.ts b/cli/src/dsh/shell.tsindex 628d7c0b3..5446e7ea5 100644--- a/cli/src/dsh/shell.ts+++ b/cli/src/dsh/shell.ts@@ -69,6 +69,15 @@ export function dshShellArgv(script: string): { path: string; args: string[] } {return { path: '/bin/sh', args: ['-c', body] }}+/**+ * Whether this computer has a shell for a DSH's commands. Windows has none yet: interactiveEngineShell gives it no+ * shell, and the `/bin/sh` fallback is not there, so every Store install on Windows failed in its setup or doctor+ * (2026-10-28: 0 of 25 since 10-26). Running them under Git Bash there is its own change, which turns this on.+ */+export function dshShellAvailable(): boolean {+ return process.platform !== 'win32'+}+/*** The line run before a DSH's command: when the login shell's PATH has no `node`, the Node this* daemon runs on joins the END of it. Since the product moved to a private runtime, a machine with nodiff --git a/cli/src/lib/productUsageContract.ts b/cli/src/lib/productUsageContract.tsindex 766b589f2..9bbf5fb88 100644--- a/cli/src/lib/productUsageContract.ts+++ b/cli/src/lib/productUsageContract.ts@@ -193,8 +193,20 @@ export const PRODUCT_USAGE_LAUNCH_ENGINES = ['opencode', 'claude', 'codex', 'othexport type ProductUsageLaunchEngine = typeof PRODUCT_USAGE_LAUNCH_ENGINES[number]/** Whether that engine had a credential on this computer, by presence only (cli/src/lib/engineAccount.ts). */export const PRODUCT_USAGE_ENGINE_ACCOUNTS = ['signed_in', 'signed_out', 'unknown'] as const+/** A Store install's or update's refusal by its code (dsh/install.ts, dsh/update.ts, dsh/lock.ts, services/store.ts, and+ * the core's answers for a service, core/serviceLinks.ts): the 11 Windows installs of 2026-10-28 were all `other`, with+ * nothing to say which. Every refusal is counted, so each family adds up to its `_failed`. A list of its own: these+ * never answer a launch, and in the launch list each would have joined all twelve launch families. Codes only. */+export const STORE_ERROR_CODES = ['invalid_dsh', 'dsh_busy', 'setup_failed', 'doctor_failed', 'git_unavailable',+ 'shell_unavailable', 'clone_failed', 'invalid_manifest', 'invalid_source', 'source_not_found', 'package_id_mismatch',+ 'package_kind_mismatch', 'viewer_unavailable', 'linked_install', 'not_installed', 'update_failed', 'bundled_package',+ 'remove_failed', 'internal', 'service_failed', 'service_unavailable', 'owner_required', 'unsupported',+ 'unsupported_on_remote', 'unlisted', 'none'] as const+export type StoreErrorCode = typeof STORE_ERROR_CODES[number]+export const STORE_ERROR_FAMILIES = ['store_install_error_code', 'store_update_error_code'] as constexport const PRODUCT_USAGE_LAUNCH_METRICS = [...LAUNCH_ERROR_FAMILIES.flatMap(family => LAUNCH_ERROR_CODES.map(code => `${family}_${code}` as const)),+ ...STORE_ERROR_FAMILIES.flatMap(family => STORE_ERROR_CODES.map(code => `${family}_${code}` as const)),...PRODUCT_USAGE_LAUNCH_ENGINES.map(engine => `first_launch_engine_${engine}` as const),...(['claude', 'codex'] as const).flatMap(engine => PRODUCT_USAGE_ENGINE_ACCOUNTS.map(account => `first_launch_${engine}_${account}` as const)),] as constdiff --git a/cli/src/lib/productUsageSignals.spec.ts b/cli/src/lib/productUsageSignals.spec.tsindex 64f3ae266..b6f63fc9d 100644--- a/cli/src/lib/productUsageSignals.spec.ts+++ b/cli/src/lib/productUsageSignals.spec.ts@@ -2,7 +2,7 @@ import { readdirSync, readFileSync } from 'node:fs'import { join } from 'node:path'import { fileURLToPath } from 'node:url'import { expect, it, vi } from 'vitest'-import { failureKind, launchErrorCode, messageReceipt, productObservation, productUsageIntent, productUsageLaunch, productUsageRequest, productUsageSource } from './productUsageSignals.js'+import { failureKind, launchErrorCode, messageReceipt, storeErrorCode, productObservation, productUsageIntent, productUsageLaunch, productUsageRequest, productUsageSource } from './productUsageSignals.js'import type { MessageOutcome } from './sessionInput.js'import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_AUTOMATIC_ACTIONS, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_METRICS, PRODUCT_USAGE_SETUP_METRICS } from './productUsageContract.js'import { AUTOMATIC_POLL_ACTIONS, HEALTH_MEASURES } from './productHealthContract.js'@@ -343,6 +343,64 @@ it('observes Store, search and model operations without their arguments and rejeexpect(clock).not.toHaveBeenCalled()})+it.each([+ // A prerequisite this machine lacks, or the harness's own setup or doctor failing on it.+ ['SETUP_FAILED', 'setup'], ['DOCTOR_FAILED', 'setup'], ['GIT_UNAVAILABLE', 'setup'], ['SHELL_UNAVAILABLE', 'setup'],+ // The package's source could not be reached, or a viewer it needs could not be installed.+ ['CLONE_FAILED', 'unavailable'], ['VIEWER_UNAVAILABLE', 'unavailable'],+ // The package itself, or what was asked of it, is wrong.+ ['INVALID_MANIFEST', 'invalid'], ['INVALID_SOURCE', 'invalid'], ['SOURCE_NOT_FOUND', 'invalid'],+ ['PACKAGE_ID_MISMATCH', 'invalid'], ['PACKAGE_KIND_MISMATCH', 'invalid'], ['LINKED_INSTALL', 'invalid'],+ ['BUNDLED_PACKAGE', 'invalid'], ['DSH_BUSY', 'conflict'], ['NOT_INSTALLED', 'not_found'],+])('gives a Store install or update refused with %s the kind %s, not `other`', (code, kind) => {+ const emit = vi.fn()+ productUsageRequest('dsh_install', emit, () => 0, 'app')(code, undefined, false)+ productUsageRequest('dsh_update', emit, () => 0, 'app')(code, undefined, false)+ const names: string[] = emit.mock.calls.flat()+ expect(names).toContain(`request_app_store_install_error_${kind}`)+ expect(names).toContain(`request_app_store_update_error_${kind}`)+ // The detailed counters the prod watch reads; the action totals have five kinds only, `other` among them.+ expect(names.filter(name => name.startsWith('request_') && name.endsWith('_error_other'))).toEqual([])+})++it('keeps every refusal a Store install or update can answer in the code list', () => {+ const codes = new Set<string>()+ for (const path of ['../dsh/install.ts', '../dsh/update.ts', '../dsh/lock.ts', '../dsh/service.ts', '../services/store.ts']) {+ const source = readFileSync(new URL(path, import.meta.url), 'utf8')+ for (const match of source.matchAll(/(?:error: |fail\(|code: )'([A-Z][A-Z0-9_]*)'/g)) codes.add(match[1])+ }+ expect(codes.size).toBeGreaterThan(12)+ expect([...codes].filter(code => storeErrorCode(code) === 'unlisted'),+ 'add each to STORE_ERROR_CODES (lib/productUsageContract.ts and its backend copy)').toEqual([])+ // A list of its own: in the launch code list, each would have joined all twelve launch families, where it never+ // occurs (+504 names, which pushed the whole-vocabulary report past its test's time).+ expect(PRODUCT_USAGE_METRICS).toContain('store_install_error_code_shell_unavailable')+ expect(PRODUCT_USAGE_METRICS).not.toContain('create_error_code_shell_unavailable')+})++it('counts every Store install or update refusal by its code, so the family adds up to `_failed`', () => {+ // 2026-10-28: 11 Windows installs failed as `other` and the counters could not say which refusal they were.+ const emit = vi.fn()+ productUsageRequest('dsh_install', emit, () => 0, 'app')('GIT_UNAVAILABLE', undefined, false)+ productUsageRequest('dsh_install', emit, () => 0, 'app')('SHELL_UNAVAILABLE', undefined, false)+ productUsageRequest('dsh_install', emit, () => 0, 'app')('INTERNAL', undefined, false)+ productUsageRequest('dsh_install', emit, () => 0, 'phone')('PRIVATE_ERROR_WITH_PATH', undefined, false)+ productUsageRequest('dsh_install', emit, () => 0, 'app')(undefined, undefined, false, false)+ productUsageRequest('dsh_update', emit, () => 0, 'app')('UPDATE_FAILED', undefined, false)+ // Answered without a refusal: no code.+ productUsageRequest('dsh_install', emit, () => 0, 'app')(undefined, undefined, false, true)+ productUsageRequest('dsh_remove', emit, () => 0, 'app')('REMOVE_FAILED', undefined, false)+ const names: string[] = emit.mock.calls.flat()+ const family = (prefix: string) => names.filter(name => name.startsWith(prefix)).sort()+ expect(family('store_install_error_code_')).toEqual(['store_install_error_code_git_unavailable', 'store_install_error_code_internal',+ 'store_install_error_code_none', 'store_install_error_code_shell_unavailable', 'store_install_error_code_unlisted'])+ expect(names.filter(name => name === 'store_install_failed')).toHaveLength(5)+ expect(family('store_update_error_code_')).toEqual(['store_update_error_code_update_failed'])+ expect(family('store_remove_error_code_')).toEqual([])+ for (const name of names.filter(name => name.includes('error_code_'))) expect(PRODUCT_USAGE_METRICS).toContain(name)+ expect(JSON.stringify(emit.mock.calls)).not.toContain('PRIVATE')+})+it('marks a Store or model list a person opened, and only those', () => {const emit = vi.fn()productUsageRequest('dsh_list', emit, Date.now, 'app', true)(undefined, undefined, false)diff --git a/cli/src/lib/productUsageSignals.ts b/cli/src/lib/productUsageSignals.tsindex 2469ffb90..b1b902990 100644--- a/cli/src/lib/productUsageSignals.ts+++ b/cli/src/lib/productUsageSignals.ts@@ -1,7 +1,7 @@import { AUTOMATIC_POLL_ACTIONS, HEALTH_FAILURES, HEALTH_MEASURES, RESUME_PREPARATION_KINDS, type HealthSource, type ResumeReason } from './productHealthContract.js'import type { MessageOutcome, MessageReceipt } from './sessionInput.js'-import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_LAUNCH_ENGINES, PRODUCT_USAGE_USER_OPENED_ACTIONS,- type LaunchErrorCode, type ProductUsageLaunchEngine, type ProductUsageMetric } from './productUsageContract.js'+import { LAUNCH_ERROR_CODES, PRODUCT_USAGE_FLOWS, PRODUCT_USAGE_LAUNCH_ENGINES, PRODUCT_USAGE_USER_OPENED_ACTIONS, STORE_ERROR_CODES,+ type LaunchErrorCode, type ProductUsageLaunchEngine, type ProductUsageMetric, type StoreErrorCode } from './productUsageContract.js'const actions = { agent_create: 'create', agent_resume: 'resume', agent_restart: 'restart',agent_retarget: 'model_change', agent_recent: 'history',@@ -20,6 +20,16 @@ const unavailable = new Set(['SERVICE_UNAVAILABLE', 'SERVICE_FAILED', 'GRID_UNAV'UNSUPPORTED', 'UNSUPPORTED_ON_REMOTE', 'TIMEOUT', 'NATIVE_UNAVAILABLE'])const invalid = new Set(['INVALID_ENGINE', 'INVALID_CWD', 'CWD_NOT_FOUND', 'INVALID_GRID', 'INVALID_DSH', 'INVALID_SWARM_ROLE','INVALID_MODEL', 'INVALID_PERMISSION_MODE', 'INVALID_CREATION_ID', 'INVALID_PROJECT_SOURCE', 'WORKTREE_BUSY'])+/** A Store install's or update's own refusals (dsh/install.ts, dsh/update.ts), by kind. Until 2026-10-28 every one was+ * `other`: that day's 11 failed installs, all on Windows, said nothing of why. For the Store's requests only, so a+ * create's or a resume's totals keep their meaning. Its busy and not-installed refusals are named with the others'. */+const storeFailures = new Map<string, Failure>([+ ['SETUP_FAILED', 'setup'], ['DOCTOR_FAILED', 'setup'], ['GIT_UNAVAILABLE', 'setup'], ['SHELL_UNAVAILABLE', 'setup'],+ ['CLONE_FAILED', 'unavailable'], ['VIEWER_UNAVAILABLE', 'unavailable'],+ ['INVALID_MANIFEST', 'invalid'], ['INVALID_SOURCE', 'invalid'], ['SOURCE_NOT_FOUND', 'invalid'],+ ['PACKAGE_ID_MISMATCH', 'invalid'], ['PACKAGE_KIND_MISMATCH', 'invalid'], ['LINKED_INSTALL', 'invalid'],+ ['BUNDLED_PACKAGE', 'invalid'],+])const resumeReasons = new Map<string, ResumeReason>([['TMUX_UNAVAILABLE', 'runtime_unavailable'], ['NATIVE_LAUNCH_HELD', 'runtime_unavailable'],['ENGINE_UNAVAILABLE', 'runtime_unavailable'],@@ -51,6 +61,14 @@ export function launchErrorCode(error: unknown): LaunchErrorCode {const code = error.length <= 64 ? error.toLowerCase() : ''return listedCodes.has(code) ? code as LaunchErrorCode : 'unlisted'}+const storeCodes = new Set<string>(STORE_ERROR_CODES.filter(code => code !== 'unlisted' && code !== 'none'))+/** Which listed code a Store install's or update's refusal had (`STORE_ERROR_CODES`), as `launchErrorCode` names a+ * launch's: the code lower-cased, `unlisted` for any other string and `none` for no code. Nothing else leaves here. */+export function storeErrorCode(error: unknown): StoreErrorCode {+ if (typeof error !== 'string') return 'none'+ const code = error.length <= 64 ? error.toLowerCase() : ''+ return storeCodes.has(code) ? code as StoreErrorCode : 'unlisted'+}/** The engine a launch asked for, as one of the fixed names. */export function launchEngine(engine: unknown): ProductUsageLaunchEngine {return (PRODUCT_USAGE_LAUNCH_ENGINES as readonly unknown[]).includes(engine) ? engine as ProductUsageLaunchEngine : 'other'@@ -170,7 +188,8 @@ export function productUsageRequest(type: string, emit: (metric: ProductUsageMetcount('unknown'); detail(error === 'AGENT_CHANGED' ? 'cancelled' : 'unknown')} else if (error != null || state === 'failed' || ok === false) {count('failed'); detail('failed')- const kind = failureKind(error)+ const store = action === 'store_install' || action === 'store_update'+ const kind = (store && typeof error === 'string' ? storeFailures.get(error) : undefined) ?? failureKind(error)count(`error_${kind}`)// Which code an `other` refusal of a create or a resume had: 22 creates and 9 resumes were `other` on// 2026-10-16 (production counters), with nothing to say why. A fixed name from the list, or unlisted.@@ -193,7 +212,10 @@ export function productUsageRequest(type: string, emit: (metric: ProductUsageMettry { emit(`phone_${action}_error_code_${launchErrorCode(error)}` as ProductUsageMetric) } catch { /* Optional measurement. */ }}}- detail(`error_${failure ? failure : error === 'TIMEOUT' ? 'timeout' : typeof error === 'string' && ['AGENT_NOT_FOUND', 'SESSION_NOT_FOUND', 'NOT_FOUND'].includes(error) ? 'not_found' : typeof error === 'string' && ['DELETE_IN_PROGRESS', 'WORKTREE_BUSY', 'BUSY'].includes(error) ? 'conflict' : failureKind(error)}`)+ // A Store install's or update's, whatever its kind: the 11 Windows installs of 2026-10-28 were `other`, and+ // nothing said which refusal. Its family adds up to `store_install_failed` (or `store_update_failed`).+ if (store) count(`error_code_${storeErrorCode(error)}`)+ detail(`error_${failure ? failure : error === 'TIMEOUT' ? 'timeout' : typeof error === 'string' && ['AGENT_NOT_FOUND', 'SESSION_NOT_FOUND', 'NOT_FOUND', 'NOT_INSTALLED'].includes(error) ? 'not_found' : typeof error === 'string' && ['DELETE_IN_PROGRESS', 'WORKTREE_BUSY', 'BUSY', 'DSH_BUSY'].includes(error) ? 'conflict' : kind}`)} else if (state === 'pending' || state === 'preparing' || state === 'starting') { count('pending'); detail('pending') }else if (state === 'unconfirmed' || state === 'unavailable' || state === 'cancelled') { count('unknown'); detail(state === 'cancelled' ? 'cancelled' : 'unknown') }else if (!['create', 'resume', 'restart', 'fork'].includes(action) || hasAgent || state === 'created') { count('ok'); detail('ok') }