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,CAAmB,SAAS,CAAA,EAAG,IAAA;AACrC,EAAA,MAAM,GAAA,GAAwB;AAAA,IAC5B,OAAA,EAAS,yBAAA;AAAA,IACT,UAAA,EAAY;AAAA,GACd;AACA,EAAA,IAAI,MAAA,KAAW,MAAA,EAAW,GAAA,CAAI,MAAA,GAAS,MAAA;AACvC,EAAA,OAAO,GAAA;AACT","file":"workspaces-config.mjs","sourcesContent":["/**\n * `~/.agentproto/workspaces.json` — single source of truth for the\n * local agentproto control plane. Tracks which directories the user\n * has opted into as agentproto workspaces, plus which one is \"active\"\n * (the daemon's default working set when no workspace is named in\n * a tool call).\n *\n * Why a config file instead of recreating an MCP entry per workspace:\n *   - One daemon = one MCP entry in the user's IDE (clean to read in\n *     `claude mcp list`, no `dapper_willow` / `noble_lantern` spam).\n *   - The daemon walks `workspaces[]` at boot and exposes them all;\n *     tools that need a target take an optional `workspace` arg and\n *     fall back to `active` when omitted.\n *   - The CLI (`agentproto workspace add/list/remove/use`), the daemon,\n *     and the acme-web onboarding dialog all read+write the same\n *     file, so changes from one surface are immediately visible to\n *     the others.\n *\n * File layout is intentionally boring (small, hand-editable JSON) —\n * future fields go on top, never break v1 readers.\n */\n\nimport { promises as fs, readFileSync, realpathSync } from \"node:fs\"\nimport { homedir } from \"node:os\"\nimport { dirname, isAbsolute, resolve } from \"node:path\"\nimport type { CloudRemotePort } from \"@agentproto/cloud-agent\"\n\nexport const WORKSPACES_CONFIG_VERSION = 1 as const\n\n/** Where a workspace's code lives off this machine. Lets a sandbox spawn\n *  (`agent_start({ sandbox, workspaceSlug })`) clone the repo into the box\n *  instead of needing the host path. Holds no secret: `credentialRef` only\n *  names the keychain slot of the PAT used to clone and push. */\nexport interface WorkspaceRemote {\n  /** `https://` clone URL, never carrying userinfo (no `user:token@`). */\n  url: string\n  /** Branch new work branches from when no explicit base is given\n   *  (the box uses `origin/<defaultBranch>`). Absent ⇒ `main`. */\n  defaultBranch?: string\n  /** Keychain slot (`StoreRef.path`) holding the git PAT. */\n  credentialRef?: string\n}\n\nexport const DEFAULT_REMOTE_BRANCH = \"main\"\n\nexport interface WorkspaceEntry {\n  /** Stable handle — what tools accept as `workspace`. Lowercase\n   *  ASCII, hyphen-only. The CLI sanitises arbitrary names down to\n   *  this shape so paste-from-finder Just Works. */\n  slug: string\n  /** Absolute filesystem path. Required absolute so the daemon can\n   *  serve the workspace regardless of its own cwd. */\n  path: string\n  /** ISO-8601 — first time the entry was added. Pure metadata, no\n   *  behavioural impact. */\n  addedAt: string\n  /** Last time the entry was touched (renamed, path edited, used as\n   *  active). Lets the CLI sort by recency without an N+1 stat. */\n  updatedAt: string\n  /** Free-text label the user can attach so workspaces with similar\n   *  slugs stay distinguishable in `agentproto workspace list`. */\n  label?: string\n  /** Optional off-machine clone source — see {@link WorkspaceRemote}. */\n  remote?: WorkspaceRemote\n  /** Set when the entry was registered by an installed app (`app-<slug>`\n   *  workspaces, see `app-workspace.ts`) — the owning appId. Lets the\n   *  runtime tell app-owned entries from user workspaces: only the owning\n   *  app's uninstall removes it, and it is never picked as the implicit\n   *  active workspace. */\n  ownerApp?: string\n}\n\nexport interface WorkspacesConfig {\n  version: typeof WORKSPACES_CONFIG_VERSION\n  /** Active workspace slug — daemon defaults to this when no\n   *  `workspace` arg is passed. May be undefined when no workspaces\n   *  are registered yet. */\n  active?: string\n  workspaces: WorkspaceEntry[]\n}\n\nexport const DEFAULT_CONFIG_DIR = (): string =>\n  resolve(homedir(), \".agentproto\")\nexport const DEFAULT_CONFIG_PATH = (): string =>\n  resolve(DEFAULT_CONFIG_DIR(), \"workspaces.json\")\n\n/** Reduce arbitrary user input to a safe slug. Aligns with what most\n *  tooling validates against (`/^[a-z0-9][a-z0-9-]{0,63}$/`) so the\n *  daemon never has to encode it for URLs or filesystem paths. */\nexport function sanitizeSlug(input: string): string {\n  const trimmed = input.trim().toLowerCase()\n  const cleaned = trimmed\n    .replace(/[^a-z0-9_-]+/g, \"-\")\n    .replace(/^-+|-+$/g, \"\")\n    .slice(0, 64)\n  // Edge case: input was entirely non-conforming — fall back to a\n  // generic so we never return an empty string.\n  return cleaned || \"workspace\"\n}\n\n/** Read the config from disk. Returns an empty config (no workspaces,\n *  no active) when the file is missing — this is the legitimate\n *  first-boot state, not an error. */\nexport async function loadWorkspacesConfig(\n  path: string = DEFAULT_CONFIG_PATH()\n): Promise<WorkspacesConfig> {\n  let raw: string\n  try {\n    raw = await fs.readFile(path, \"utf8\")\n  } catch (err) {\n    if ((err as NodeJS.ErrnoException).code === \"ENOENT\") {\n      return { version: WORKSPACES_CONFIG_VERSION, workspaces: [] }\n    }\n    throw err\n  }\n  let parsed: unknown\n  try {\n    parsed = JSON.parse(raw)\n  } catch (err) {\n    throw new Error(\n      `agentproto: ${path} is not valid JSON (${\n        err instanceof Error ? err.message : String(err)\n      }). Delete the file or fix it manually.`\n    )\n  }\n  return normalizeConfig(parsed)\n}\n\n/** Sync twin of `loadWorkspacesConfig`, sharing its normalisation (and\n *  therefore its slug sanitisation) exactly.\n *\n *  Exists because bucket resolution runs on paths that cannot await: the\n *  sessions registry loads its history synchronously at construction so\n *  the dashboard has rows immediately, and flushes synchronously on\n *  `process.on(\"exit\")` where Node won't await. Both need to know which\n *  slugs are registered. The file is <1KB, so the sync read is cheaper\n *  than the machinery to avoid it. */\nexport function loadWorkspacesConfigSync(\n  path: string = DEFAULT_CONFIG_PATH()\n): WorkspacesConfig {\n  let raw: string\n  try {\n    raw = readFileSync(path, \"utf8\")\n  } catch (err) {\n    if ((err as NodeJS.ErrnoException).code === \"ENOENT\") {\n      return { version: WORKSPACES_CONFIG_VERSION, workspaces: [] }\n    }\n    throw err\n  }\n  let parsed: unknown\n  try {\n    parsed = JSON.parse(raw)\n  } catch (err) {\n    throw new Error(\n      `agentproto: ${path} is not valid JSON (${\n        err instanceof Error ? err.message : String(err)\n      }). Delete the file or fix it manually.`\n    )\n  }\n  return normalizeConfig(parsed)\n}\n\n/** Write the config back. Creates the parent directory if missing.\n *  Atomic-ish: writes to a temp file first, then renames over the\n *  target — avoids the partial-write window where a concurrent reader\n *  sees half a JSON object. */\nexport async function saveWorkspacesConfig(\n  config: WorkspacesConfig,\n  path: string = DEFAULT_CONFIG_PATH()\n): Promise<void> {\n  const normalized = normalizeConfig(config)\n  await fs.mkdir(dirname(path), { recursive: true })\n  const tmp = `${path}.tmp.${process.pid}`\n  await fs.writeFile(tmp, JSON.stringify(normalized, null, 2) + \"\\n\", \"utf8\")\n  await fs.rename(tmp, path)\n}\n\n/**\n * Pure helpers — caller manages persistence. Returns a NEW config\n * (never mutates) so callers can compose multiple updates before\n * a single save.\n */\nexport function addWorkspace(\n  config: WorkspacesConfig,\n  input: { slug: string; path: string; label?: string; ownerApp?: string }\n): WorkspacesConfig {\n  if (!isAbsolute(input.path)) {\n    throw new Error(\n      `addWorkspace: path must be absolute, got \"${input.path}\".`\n    )\n  }\n  const slug = sanitizeSlug(input.slug)\n  const now = new Date().toISOString()\n  const existingIdx = config.workspaces.findIndex(w => w.slug === slug)\n  const next: WorkspaceEntry = existingIdx >= 0\n    ? {\n        ...config.workspaces[existingIdx]!,\n        path: input.path,\n        ...(input.label !== undefined ? { label: input.label } : {}),\n        ...(input.ownerApp !== undefined ? { ownerApp: input.ownerApp } : {}),\n        updatedAt: now,\n      }\n    : {\n        slug,\n        path: input.path,\n        ...(input.label ? { label: input.label } : {}),\n        ...(input.ownerApp ? { ownerApp: input.ownerApp } : {}),\n        addedAt: now,\n        updatedAt: now,\n      }\n  const workspaces = [...config.workspaces]\n  if (existingIdx >= 0) workspaces[existingIdx] = next\n  else workspaces.push(next)\n  // First-add becomes active automatically — saves the user a\n  // separate `workspace use` call right after a fresh `add`. An app-owned\n  // entry never claims the active slot on its own.\n  const active = config.active ?? (input.ownerApp ? undefined : slug)\n  const out: WorkspacesConfig = { ...config, workspaces }\n  if (active !== undefined) out.active = active\n  return out\n}\n\n/** Throws unless `raw` is a plain `https://` URL with a host and no\n *  userinfo/query/fragment; returns it trimmed. A token embedded in a URL\n *  would land in git config, process args and logs — the credential belongs\n *  in `credentialRef`. */\nexport function validateRemoteUrl(raw: string): string {\n  const trimmed = raw.trim()\n  let parsed: URL\n  try {\n    parsed = new URL(trimmed)\n  } catch {\n    throw new Error(`remote url \"${trimmed}\" is not a valid URL.`)\n  }\n  if (parsed.protocol !== \"https:\") {\n    throw new Error(\n      `remote url must use https:// (got \"${parsed.protocol}//\") — ssh/git/http remotes are not supported.`\n    )\n  }\n  if (!parsed.hostname) {\n    throw new Error(`remote url \"${trimmed}\" has no host.`)\n  }\n  if (parsed.username || parsed.password) {\n    throw new Error(\n      \"remote url must not embed credentials; store the token with \" +\n        \"`agentproto workspace remote set <slug> --url … --token-stdin` instead.\"\n    )\n  }\n  if (parsed.search || parsed.hash) {\n    throw new Error(\"remote url must not carry a query string or fragment.\")\n  }\n  return trimmed\n}\n\n/** Throws unless `raw` is a conservative git branch name; returns it trimmed.\n *  It is interpolated into shell commands inside the box, so the charset is\n *  deliberately narrow. */\nexport function validateRemoteBranch(raw: string): string {\n  const trimmed = raw.trim()\n  if (\n    !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(trimmed) ||\n    trimmed.includes(\"..\") ||\n    trimmed.endsWith(\"/\") ||\n    trimmed.endsWith(\".lock\")\n  ) {\n    throw new Error(`remote default branch \"${trimmed}\" is not a valid branch name.`)\n  }\n  return trimmed\n}\n\n/** Throws unless `raw` is a non-empty single-token keychain slot; returns it trimmed. */\nexport function validateCredentialRef(raw: string): string {\n  const trimmed = raw.trim()\n  if (!trimmed || /\\s/.test(trimmed)) {\n    throw new Error(\"remote credentialRef must be a non-empty keychain slot name with no whitespace.\")\n  }\n  return trimmed\n}\n\n/** The port a cloud spawn passes to `@agentproto/cloud-agent` so it can\n *  validate a declared remote and default its branch without importing this\n *  module. */\nexport const workspaceRemotePort: CloudRemotePort = {\n  defaultBranch: DEFAULT_REMOTE_BRANCH,\n  validateUrl: validateRemoteUrl,\n  validateBranch: validateRemoteBranch,\n}\n\n/** Validate a candidate remote, returning a canonical copy. Throws on the\n *  first problem. */\nexport function validateWorkspaceRemote(input: WorkspaceRemote): WorkspaceRemote {\n  return {\n    url: validateRemoteUrl(input.url),\n    ...(input.defaultBranch !== undefined\n      ? { defaultBranch: validateRemoteBranch(input.defaultBranch) }\n      : {}),\n    ...(input.credentialRef !== undefined\n      ? { credentialRef: validateCredentialRef(input.credentialRef) }\n      : {}),\n  }\n}\n\n/** Attach (or replace) the remote on an existing workspace. Throws when the\n *  slug is unknown or the remote is invalid. */\nexport function setWorkspaceRemote(\n  config: WorkspacesConfig,\n  slug: string,\n  remote: WorkspaceRemote\n): WorkspacesConfig {\n  const sanitised = sanitizeSlug(slug)\n  const validated = validateWorkspaceRemote(remote)\n  const idx = config.workspaces.findIndex(w => w.slug === sanitised)\n  if (idx < 0) {\n    throw new Error(\n      `setWorkspaceRemote: no workspace registered with slug \"${sanitised}\".`\n    )\n  }\n  const workspaces = [...config.workspaces]\n  workspaces[idx] = {\n    ...workspaces[idx]!,\n    remote: validated,\n    updatedAt: new Date().toISOString(),\n  }\n  return { ...config, workspaces }\n}\n\n/** Drop the remote from a workspace. Throws when the slug is unknown; a\n *  workspace that had no remote is returned unchanged. */\nexport function unsetWorkspaceRemote(\n  config: WorkspacesConfig,\n  slug: string\n): WorkspacesConfig {\n  const sanitised = sanitizeSlug(slug)\n  const idx = config.workspaces.findIndex(w => w.slug === sanitised)\n  if (idx < 0) {\n    throw new Error(\n      `unsetWorkspaceRemote: no workspace registered with slug \"${sanitised}\".`\n    )\n  }\n  const current = config.workspaces[idx]!\n  if (current.remote === undefined) return config\n  const { remote: _dropped, ...rest } = current\n  const workspaces = [...config.workspaces]\n  workspaces[idx] = { ...rest, updatedAt: new Date().toISOString() }\n  return { ...config, workspaces }\n}\n\nexport function removeWorkspace(\n  config: WorkspacesConfig,\n  slug: string\n): WorkspacesConfig {\n  const sanitised = sanitizeSlug(slug)\n  const workspaces = config.workspaces.filter(w => w.slug !== sanitised)\n  // If the removed workspace was active, hand off to whatever's\n  // first — predictable and avoids leaving the daemon in an\n  // unreachable state when the user removes the only one.\n  let active = config.active\n  if (active === sanitised) {\n    active = firstUserWorkspace(workspaces)?.slug\n  }\n  const next: WorkspacesConfig = { ...config, workspaces }\n  if (active !== undefined) next.active = active\n  else delete next.active\n  return next\n}\n\nexport function setActiveWorkspace(\n  config: WorkspacesConfig,\n  slug: string\n): WorkspacesConfig {\n  const sanitised = sanitizeSlug(slug)\n  if (!config.workspaces.some(w => w.slug === sanitised)) {\n    throw new Error(\n      `setActiveWorkspace: no workspace registered with slug \"${sanitised}\". ` +\n        `Run \\`agentproto workspace add <path> --slug ${sanitised}\\` first.`\n    )\n  }\n  return { ...config, active: sanitised }\n}\n\nexport function findWorkspace(\n  config: WorkspacesConfig,\n  slug: string\n): WorkspaceEntry | undefined {\n  return config.workspaces.find(w => w.slug === sanitizeSlug(slug))\n}\n\n/** Resolve a path through `realpathSync` so symlinked roots (macOS `/tmp` →\n *  `/private/tmp`, a symlinked volume, …) compare equal to their real\n *  location. Falls back to a lexical `resolve` when the path doesn't exist\n *  on disk — `realpathSync` throws on ENOENT, and a not-yet-existing path\n *  still needs a comparable value. */\nfunction canonical(p: string): string {\n  try {\n    return realpathSync(resolve(p))\n  } catch {\n    return resolve(p)\n  }\n}\n\n/** Find a workspace whose path is an ancestor of (or equal to) the\n *  given directory. Returns the most specific match (longest path)\n *  when multiple workspaces nest under the same root. */\nexport function findWorkspaceByPath(\n  config: WorkspacesConfig,\n  dir: string\n): WorkspaceEntry | undefined {\n  const resolved = canonical(dir)\n  const candidates = config.workspaces\n    .filter(w => {\n      const wPath = canonical(w.path)\n      return resolved.startsWith(wPath + \"/\") || resolved === wPath\n    })\n    .sort((a, b) => b.path.length - a.path.length)\n  return candidates[0]\n}\n\n/** The active workspace, or undefined when none is registered. Pure\n *  convenience to avoid re-implementing the lookup at every caller. */\nexport function getActiveWorkspace(\n  config: WorkspacesConfig\n): WorkspaceEntry | undefined {\n  if (!config.active) return firstUserWorkspace(config.workspaces)\n  return (\n    findWorkspace(config, config.active) ?? firstUserWorkspace(config.workspaces)\n  )\n}\n\n/** Implicit-active fallback: the first workspace a user registered. App-owned\n *  entries only become active when explicitly chosen (`workspace use`). */\nfunction firstUserWorkspace(\n  workspaces: readonly WorkspaceEntry[]\n): WorkspaceEntry | undefined {\n  return workspaces.find(w => !w.ownerApp)\n}\n\n/** Lenient read of a hand-editable `remote` block: an invalid one (non-https\n *  URL, URL with userinfo, bad branch) is dropped rather than failing the\n *  whole file, mirroring how malformed workspace entries are skipped. */\nfunction parseStoredRemote(raw: unknown): WorkspaceRemote | undefined {\n  if (!raw || typeof raw !== \"object\") return undefined\n  const r = raw as Record<string, unknown>\n  if (typeof r.url !== \"string\") return undefined\n  try {\n    return validateWorkspaceRemote({\n      url: r.url,\n      ...(typeof r.defaultBranch === \"string\" ? { defaultBranch: r.defaultBranch } : {}),\n      ...(typeof r.credentialRef === \"string\" ? { credentialRef: r.credentialRef } : {}),\n    })\n  } catch {\n    return undefined\n  }\n}\n\n/**\n * Coerce arbitrary parsed JSON into a valid config. Skips entries\n * with missing required fields rather than throwing — partial recovery\n * is friendlier than \"your config file is corrupted, here's a stack\n * trace\". Logs nothing here; the CLI shells that consume this should\n * decide whether to surface a warning.\n */\nfunction normalizeConfig(parsed: unknown): WorkspacesConfig {\n  if (!parsed || typeof parsed !== \"object\") {\n    return { version: WORKSPACES_CONFIG_VERSION, workspaces: [] }\n  }\n  const obj = parsed as Record<string, unknown>\n  const workspaces: WorkspaceEntry[] = []\n  if (Array.isArray(obj.workspaces)) {\n    for (const entry of obj.workspaces) {\n      if (!entry || typeof entry !== \"object\") continue\n      const e = entry as Record<string, unknown>\n      const slug = typeof e.slug === \"string\" ? sanitizeSlug(e.slug) : \"\"\n      const path = typeof e.path === \"string\" ? e.path : \"\"\n      if (!slug || !path) continue\n      const addedAt =\n        typeof e.addedAt === \"string\" ? e.addedAt : new Date().toISOString()\n      const updatedAt = typeof e.updatedAt === \"string\" ? e.updatedAt : addedAt\n      const we: WorkspaceEntry = { slug, path, addedAt, updatedAt }\n      if (typeof e.label === \"string\" && e.label.trim()) {\n        we.label = e.label.trim()\n      }\n      const remote = parseStoredRemote(e.remote)\n      if (remote) we.remote = remote\n      if (typeof e.ownerApp === \"string\" && e.ownerApp.trim()) {\n        we.ownerApp = e.ownerApp.trim()\n      }\n      workspaces.push(we)\n    }\n  }\n  // De-dupe by slug (last wins) — the file is hand-editable so a\n  // typo could have produced two entries with the same slug.\n  const dedup = new Map<string, WorkspaceEntry>()\n  for (const w of workspaces) dedup.set(w.slug, w)\n  const finalList = Array.from(dedup.values())\n  const active =\n    typeof obj.active === \"string\" && finalList.some(w => w.slug === obj.active)\n      ? (obj.active as string)\n      : firstUserWorkspace(finalList)?.slug\n  const out: WorkspacesConfig = {\n    version: WORKSPACES_CONFIG_VERSION,\n    workspaces: finalList,\n  }\n  if (active !== undefined) out.active = active\n  return out\n}\n"]}