{"version":3,"file":"server.mjs","names":["contribution","readLine","contribution","payloadOf","errorTargetFor","failureText","contribution","contribution","contribution","contribution","contribution","apiRoute","channelGitChanges","channelGitWorktrees","rootSession","hookAgentSettled","hookToolExecutionEnd","resourceDoompiGit","resourceDoompiGitReadme","resourceDoompiUseGit","toolRunWorktree"],"sources":["../../src/extensions/workspaces/sessions/(backend)/_lib/root.server.ts","../../src/extensions/workspaces/sessions/(backend)/root.server.ts","../../src/services/branchDiff/index.ts","../../src/services/gitAuth/index.ts","../../src/services/newSessionRequest/index.ts","../../src/extensions/(backend)/api/git/_lib/route.server.ts","../../src/extensions/(backend)/api/git/route.server.ts","../../src/services/gitFailure/index.ts","../../src/services/gitSync/index.ts","../../src/types/gitReview.ts","../../src/extensions/(backend)/channel/_lib/git-changes.server.ts","../../src/extensions/(backend)/channel/git-changes.server.ts","../../src/types/webWorktrees.ts","../../src/extensions/(backend)/channel/_lib/git-worktrees.server.ts","../../src/extensions/(backend)/channel/git-worktrees.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/agent-settled.server.ts","../../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGit.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiGitReadme.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/_lib/doompiUseGit.server.ts","../../src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server.ts","../../src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server.ts","../../generated/server.ts"],"sourcesContent":["import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport {\n  type DoomHeadlessExecutionContext,\n  type DoomHeadlessHook,\n  type DoomHeadlessResource,\n  type DoomHeadlessTool,\n  type DoomHeadlessToolResult,\n} from '@agimon-ai/doompi-core/headless';\nimport { readPackageResource, type DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\nimport { readDoomSessionDelivery } from '@agimon-ai/doompi-session';\n\nimport { RunWorktreeToolSchema, type RunWorktreeToolParams } from '../../../../../schemas/runWorktreeTool';\nimport { createWorktreeGit } from '../../../../../services/gitCli';\nimport {\n  executeRunWorktreeTool,\n  RUN_WORKTREE_DESCRIPTION,\n  RUN_WORKTREE_TOOL_NAME,\n  validateParams,\n} from '../../../../../services/runWorktree';\nimport {\n  createWorktreeMessageInbox,\n  GIT_SESSION_CHANGED_EVENT,\n  WORKTREE_MESSAGE_VERSION,\n} from '../../../../../services/worktreeEvents';\nimport { createWorktreeOperations } from '../../../../../services/worktreeOperations';\n\nfunction progressResult(action: RunWorktreeToolParams['action'], label: string): DoomHeadlessToolResult {\n  return { content: [{ type: 'text', text: label }], details: { action } };\n}\n\nexport function createGitSession({ context, host: serverHost }: DoomServerPluginContext) {\n  if (serverHost.context.directEvents === undefined)\n    throw new Error('Git headless facet requires the session direct event bus.');\n  if (serverHost.context.sessionId === undefined) throw new Error('Git headless facet requires a session identity.');\n  const sessionId = serverHost.context.sessionId;\n  const directEvents = serverHost.context.directEvents;\n  const messageInbox = createWorktreeMessageInbox(directEvents, sessionId);\n  const operations = createWorktreeOperations({\n    git: createWorktreeGit(),\n    sessionService: serverHost.context.sessionService,\n    messageInbox,\n    sessionDelivery: () => readDoomSessionDelivery(context),\n  });\n  const resources: DoomHeadlessResource[] = [\n    {\n      // The package index is Help-catalog material, not standing instruction, so it\n      // only enters the prompt while Help mode is active. Matches the Pi facet,\n      // which has always routed this through the Help service.\n      when: { state: { 'minor-mode': 'help' }, attribution: { kind: 'minor', mode: 'help' } },\n      name: 'doompi-git',\n      kind: 'context',\n      read: () => readPackageResource(import.meta.url, 'llms.txt'),\n    },\n    {\n      name: 'doompi-use-git',\n      kind: 'skill',\n      read: () => readPackageResource(import.meta.url, 'src/prompts/doompi-use-git/SKILL.md'),\n    },\n  ];\n\n  const tool: DoomHeadlessTool<typeof RunWorktreeToolSchema> = {\n    name: RUN_WORKTREE_TOOL_NAME,\n    label: 'Worktree',\n    description: RUN_WORKTREE_DESCRIPTION,\n    parameters: RunWorktreeToolSchema,\n    promptSnippet: 'Create and manage Git worktree sessions',\n    executionMode: 'serial',\n    async execute(_toolCallId, parameters, signal, onUpdate, execution) {\n      const params = validateParams(parameters) as RunWorktreeToolParams;\n      return executeRunWorktreeTool(params, operations, execution, {\n        ...(signal === undefined ? {} : { signal }),\n        onProgress: (label) => onUpdate?.(progressResult(params.action, label)),\n      });\n    },\n  };\n  // A tool call or a settled turn may have changed the checkout. The hub's\n  // '# diff' channel coalesces these, so a burst of tool calls costs one recount.\n  const changed = (_event: unknown, execution: DoomHeadlessExecutionContext): void => {\n    directEvents.publish(GIT_SESSION_CHANGED_EVENT, execution.sessionId, { version: WORKTREE_MESSAGE_VERSION });\n  };\n  const hooks: DoomHeadlessHook[] = [\n    { event: 'tool_execution_end', handle: changed },\n    { event: 'agent_settled', handle: changed },\n  ];\n  return { value: { resources, tool, hooks }, onDispose: () => messageInbox.close() };\n}\n\nconst root = defineRoot(createGitSession);\nexport type GitServerScope = Awaited<ReturnType<typeof root>>['value'];\nexport default root;\n","import { defineRoot } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/root.server';\n\nexport default defineRoot(contribution);\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport type {\n  GitChangesView,\n  GitDiffHunk,\n  GitDiffRow,\n  GitReviewFileDiff,\n  GitReviewFileEntry,\n  GitReviewFileStatus,\n} from '../../types/gitReview';\nimport { READ_TIMEOUT_MS, runGit } from '../gitCli';\nimport type { BranchDiff, BranchDiffOptions, BranchReview, ReviewBase } from './type';\n\n/**\n * What a session's checkout changed against its base, the way a pull request\n * shows it: every commit since the branch left its base, plus staged, unstaged\n * and untracked work.\n *\n * DESIGN PATTERNS:\n * - git computes every diff. The counts come from `--numstat` and the hunks\n *   from the same unified diff, so the two always agree.\n * - The base is the worktree's own recorded base when there is one, then the\n *   remote's default branch, then the branch's upstream, and with none of those\n *   only uncommitted work counts. It is always named in the UI.\n * - Untracked files are read only when they are small regular files; a symlink\n *   shows its link text and is never followed.\n *\n * AVOID:\n * - Passing a browser path to git without checking it against the change set.\n */\n\n/** git's well-known empty tree, the base of a repository with no commits. */\nconst EMPTY_TREE = '4b825dc642cb6eb9a060e54bf8d69288fbee4904';\nconst MAX_LISTED_FILES = 500;\nconst MAX_UNTRACKED_COUNTED = 200;\nconst MAX_FILE_BYTES = 1_048_576;\nconst MAX_ROWS = 5_000;\nconst BINARY_PROBE_BYTES = 8_192;\nconst SHORT_SHA = 7;\nconst DEFAULT_BRANCHES = ['main', 'master'];\n\nasync function read(cwd: string, args: readonly string[]): Promise<string | undefined> {\n  const result = await runGit(cwd, args, { timeout: READ_TIMEOUT_MS });\n  return result.code === 0 ? result.stdout : undefined;\n}\n\nasync function readLine(cwd: string, args: readonly string[]): Promise<string | undefined> {\n  const out = (await read(cwd, args))?.trim();\n  return out === undefined || out === '' ? undefined : out;\n}\n\nasync function commitExists(cwd: string, ref: string): Promise<boolean> {\n  return (await readLine(cwd, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`])) !== undefined;\n}\n\n/** A local branch's upstream, so the review measures against what fetch keeps current. */\nasync function upstreamOf(cwd: string, ref: string): Promise<string | undefined> {\n  return readLine(cwd, ['rev-parse', '--abbrev-ref', '--symbolic-full-name', `${ref}@{upstream}`]);\n}\n\n/** The ref the review is measured against. Exported for sync, whose rebase uses the same base. */\nexport async function resolveBaseRef(\n  cwd: string,\n  branch: string | undefined,\n  recordedBaseRef?: string,\n): Promise<string | undefined> {\n  // An existing-branch worktree records the branch itself as its base, which\n  // would make every review empty.\n  const recordedIsSelf =\n    recordedBaseRef === undefined ||\n    (branch !== undefined && (recordedBaseRef === branch || recordedBaseRef.endsWith(`/${branch}`)));\n  if (!recordedIsSelf && recordedBaseRef !== undefined && (await commitExists(cwd, recordedBaseRef))) {\n    const isLocal =\n      (await readLine(cwd, ['rev-parse', '--verify', '--quiet', `refs/heads/${recordedBaseRef}`])) !== undefined;\n    return (isLocal ? await upstreamOf(cwd, recordedBaseRef) : undefined) ?? recordedBaseRef;\n  }\n  const originHead = await readLine(cwd, ['symbolic-ref', '--quiet', '--short', 'refs/remotes/origin/HEAD']);\n  if (originHead !== undefined) return originHead;\n  for (const name of DEFAULT_BRANCHES) {\n    if (await commitExists(cwd, `origin/${name}`)) return `origin/${name}`;\n  }\n  return branch === undefined ? undefined : upstreamOf(cwd, branch);\n}\n\nasync function resolveBase(cwd: string, branch: string | undefined, recordedBaseRef?: string): Promise<ReviewBase> {\n  const ref = await resolveBaseRef(cwd, branch, recordedBaseRef);\n  const head = await commitExists(cwd, 'HEAD');\n  if (ref !== undefined && head) {\n    const mergeBase = await readLine(cwd, ['merge-base', ref, 'HEAD']);\n    if (mergeBase !== undefined) return { ref, from: mergeBase, mergeBase: mergeBase.slice(0, SHORT_SHA) };\n  }\n  return { from: head ? 'HEAD' : EMPTY_TREE };\n}\n\n/** NUL-separated fields from a `-z` listing, without the trailing empty one. */\nfunction zFields(out: string | undefined): string[] {\n  if (out === undefined || out === '') return [];\n  const fields = out.split('\\0');\n  if (fields.at(-1) === '') fields.pop();\n  return fields;\n}\n\nconst NAME_STATUS: Readonly<Record<string, GitReviewFileStatus>> = {\n  A: 'added',\n  D: 'deleted',\n  M: 'modified',\n  T: 'modified',\n};\n\n/** Line count of a small regular file, or undefined when it is binary, large, or not a regular file. */\nfunction untrackedLines(root: string, relPath: string): { lines: number; binary: boolean } | undefined {\n  const absolute = path.join(root, relPath);\n  let stat: fs.Stats;\n  try {\n    stat = fs.lstatSync(absolute);\n  } catch {\n    return undefined;\n  }\n  if (stat.isSymbolicLink()) return { lines: 1, binary: false };\n  if (!stat.isFile() || stat.size > MAX_FILE_BYTES) return undefined;\n  const content = fs.readFileSync(absolute);\n  if (content.subarray(0, BINARY_PROBE_BYTES).includes(0)) return { lines: 0, binary: true };\n  if (content.length === 0) return { lines: 0, binary: false };\n  const text = content.toString('utf8');\n  const newlines = text.split('\\n').length - 1;\n  return { lines: text.endsWith('\\n') ? newlines : newlines + 1, binary: false };\n}\n\n/** The hunks of a unified diff, numbering each row by the file it lives in. */\nexport function parseUnifiedDiff(diff: string): { hunks: GitDiffHunk[]; binary: boolean; rows: number } {\n  const hunks: GitDiffHunk[] = [];\n  let current: GitDiffHunk | undefined;\n  let oldLine = 0;\n  let newLine = 0;\n  let rows = 0;\n  let binary = false;\n  for (const line of diff.split('\\n')) {\n    const header = /^@@ -(\\d+)(?:,\\d+)? \\+(\\d+)(?:,\\d+)? @@/u.exec(line);\n    if (header !== null) {\n      oldLine = Number(header[1]);\n      newLine = Number(header[2]);\n      current = { start: newLine, rows: [] };\n      hunks.push(current);\n      continue;\n    }\n    if (current === undefined) {\n      if (line.startsWith('Binary files ') || line === 'GIT binary patch') binary = true;\n      continue;\n    }\n    const marker = line[0];\n    let row: GitDiffRow | undefined;\n    if (marker === ' ') row = { marker: ' ', line: newLine, content: line.slice(1) };\n    else if (marker === '-') row = { marker: '-', line: oldLine, content: line.slice(1) };\n    else if (marker === '+') row = { marker: '+', line: newLine, content: line.slice(1) };\n    // `\\ No newline at end of file` and the trailing empty split are not rows.\n    if (row === undefined) continue;\n    if (marker !== '+') oldLine += 1;\n    if (marker !== '-') newLine += 1;\n    current.rows.push(row);\n    rows += 1;\n  }\n  return { hunks, binary, rows };\n}\n\nexport function createBranchDiff(): BranchDiff {\n  return {\n    async review(cwd: string, options: BranchDiffOptions = {}): Promise<BranchReview | undefined> {\n      const root = await readLine(cwd, ['rev-parse', '--show-toplevel']);\n      if (root === undefined) return undefined;\n      const branch = await readLine(root, ['symbolic-ref', '--quiet', '--short', 'HEAD']);\n      const base = await resolveBase(root, branch, options.recordedBaseRef);\n\n      const numstat = zFields(await read(root, ['diff', '--numstat', '-z', '--no-renames', base.from]));\n      const nameStatus = zFields(await read(root, ['diff', '--name-status', '-z', '--no-renames', base.from]));\n      const unmerged = new Set(zFields(await read(root, ['diff', '--name-only', '--diff-filter=U', '-z'])));\n      const statusOf = new Map<string, GitReviewFileStatus>();\n      for (let index = 0; index + 1 < nameStatus.length; index += 2) {\n        statusOf.set(nameStatus[index + 1] ?? '', NAME_STATUS[(nameStatus[index] ?? '').charAt(0)] ?? 'modified');\n      }\n\n      const entries: GitReviewFileEntry[] = [];\n      for (const field of numstat) {\n        const [added = '', removed = '', ...rest] = field.split('\\t');\n        const filePath = rest.join('\\t');\n        if (filePath === '') continue;\n        const binary = added === '-' && removed === '-';\n        entries.push({\n          path: filePath,\n          status: unmerged.has(filePath) ? 'conflicted' : (statusOf.get(filePath) ?? 'modified'),\n          added: binary ? 0 : Number(added),\n          removed: binary ? 0 : Number(removed),\n          ...(binary ? { binary: true } : {}),\n        });\n      }\n\n      const untracked = zFields(await read(root, ['ls-files', '--others', '--exclude-standard', '-z']));\n      untracked.forEach((relPath, index) => {\n        const counted = index < MAX_UNTRACKED_COUNTED ? untrackedLines(root, relPath) : undefined;\n        entries.push({\n          path: relPath,\n          status: 'untracked',\n          added: counted?.lines ?? 0,\n          removed: 0,\n          ...(counted?.binary ? { binary: true } : {}),\n        });\n      });\n      entries.sort((left, right) => left.path.localeCompare(right.path));\n\n      const conflicts = [...unmerged];\n      const rebaseMerge = await readLine(root, ['rev-parse', '--git-path', 'rebase-merge']);\n      const rebaseApply = await readLine(root, ['rev-parse', '--git-path', 'rebase-apply']);\n      const rebasing = [rebaseMerge, rebaseApply].some(\n        (gitPath) => gitPath !== undefined && fs.existsSync(path.resolve(root, gitPath)),\n      );\n\n      const upstreamRef = branch === undefined ? undefined : await upstreamOf(root, branch);\n      let upstream: GitChangesView['upstream'];\n      if (upstreamRef !== undefined) {\n        const counts = await readLine(root, ['rev-list', '--left-right', '--count', `${upstreamRef}...HEAD`]);\n        const [behind, ahead] = (counts ?? '').split(/\\s+/u).map(Number);\n        if (Number.isInteger(ahead) && Number.isInteger(behind))\n          upstream = { ref: upstreamRef, ahead: ahead!, behind: behind! };\n      }\n\n      const truncated = entries.length > MAX_LISTED_FILES || untracked.length > MAX_UNTRACKED_COUNTED;\n      const added = entries.reduce((sum, entry) => sum + entry.added, 0);\n      const removed = entries.reduce((sum, entry) => sum + entry.removed, 0);\n      const changes: GitChangesView = {\n        added,\n        removed,\n        files: entries.length,\n        ...(branch === undefined ? {} : { branch }),\n        ...(base.ref === undefined ? {} : { base: base.ref }),\n        ...(truncated ? { truncated: true } : {}),\n        ...(upstream === undefined ? {} : { upstream }),\n        ...(rebasing ? { rebase: { conflicts } } : {}),\n      };\n      return {\n        root,\n        base,\n        changes,\n        summary: {\n          repository: true,\n          files: entries.slice(0, MAX_LISTED_FILES),\n          ...(branch === undefined ? {} : { branch }),\n          ...(base.ref === undefined ? {} : { base: base.ref }),\n          ...(base.mergeBase === undefined ? {} : { mergeBase: base.mergeBase }),\n          ...(truncated ? { truncated: true } : {}),\n        },\n      };\n    },\n\n    async fileDiff(review: BranchReview, filePath: string): Promise<GitReviewFileDiff> {\n      const entry = review.summary.files.find((file) => file.path === filePath);\n      if (entry === undefined) throw new Error('That path is not in this review.');\n      if (entry.status === 'untracked') {\n        const absolute = path.join(review.root, entry.path);\n        const stat = fs.lstatSync(absolute);\n        if (stat.isSymbolicLink()) {\n          return {\n            path: entry.path,\n            hunks: [{ start: 1, rows: [{ marker: '+', line: 1, content: fs.readlinkSync(absolute) }] }],\n          };\n        }\n        if (!stat.isFile() || stat.size > MAX_FILE_BYTES) return { path: entry.path, hunks: [], tooLarge: true };\n        const content = fs.readFileSync(absolute);\n        if (content.subarray(0, BINARY_PROBE_BYTES).includes(0)) return { path: entry.path, hunks: [], binary: true };\n        const lines = content.toString('utf8').split('\\n');\n        if (lines.at(-1) === '') lines.pop();\n        if (lines.length > MAX_ROWS) return { path: entry.path, hunks: [], tooLarge: true };\n        return {\n          path: entry.path,\n          hunks:\n            lines.length === 0\n              ? []\n              : [{ start: 1, rows: lines.map((content, index) => ({ marker: '+', line: index + 1, content })) }],\n        };\n      }\n      const result = await runGit(\n        review.root,\n        [\n          'diff',\n          '-U3',\n          '--no-color',\n          '--no-ext-diff',\n          '--no-textconv',\n          '--no-renames',\n          review.base.from,\n          '--',\n          `:(top,literal)${entry.path}`,\n        ],\n        { timeout: READ_TIMEOUT_MS, maxBuffer: MAX_FILE_BYTES },\n      );\n      if (result.overflow) return { path: entry.path, hunks: [], tooLarge: true };\n      if (result.code !== 0) throw new Error(`git diff failed (exit ${String(result.code)}).`);\n      const parsed = parseUnifiedDiff(result.stdout);\n      if (parsed.binary || entry.binary === true) return { path: entry.path, hunks: [], binary: true };\n      if (parsed.rows > MAX_ROWS) return { path: entry.path, hunks: [], tooLarge: true };\n      return { path: entry.path, hunks: parsed.hunks };\n    },\n  };\n}\n","import fs from 'node:fs';\nimport os from 'node:os';\nimport path from 'node:path';\n\nimport type { GitAuthView } from '../../types/gitAuth';\nimport { readJson, writeJsonAtomic } from '../atomicJson';\nimport { invalidRequest } from '../errors';\nimport { credentialsFile, doomGitRoot } from '../paths';\nimport type { GitAuthConfig, GitAuthFile, GitAuthStore, RemoteEnv } from './type';\n\n/**\n * Per-workspace remote auth for doompi-git's own fetch, pull, push and rebase.\n *\n * DESIGN PATTERNS:\n * - One file outside every repository, folder 0700 and file 0600, repaired on\n *   read if something loosened it. The token never leaves this module except\n *   into the environment of one git child process.\n * - Config reaches git through GIT_CONFIG_COUNT environment entries, never\n *   argv, so nothing secret shows in `ps`. The first entry empties the\n *   credential helper list, which is what keeps macOS's osxkeychain helper from\n *   storing the token after a successful push.\n * - The token is offered only to the host it was entered for. A repository\n *   whose remote points anywhere else gets this machine's own credentials.\n *\n * AVOID:\n * - Touching process.env. The hub runs every session; anything set there\n *   would reach the agent's shell, which the user ruled out.\n */\n\nconst OWNER_ONLY_DIRECTORY = 0o700;\nconst OWNER_ONLY_FILE = 0o600;\nconst LOOSE_BITS = 0o077;\nconst HOST_PATTERN = /^[a-z0-9.-]{1,253}(:\\d{1,5})?$/u;\nconst MAX_USERNAME = 256;\nconst MAX_TOKEN = 4096;\nconst SETTINGS_HINT = 'Open settings, then repository, then git remote.';\n\n/** Environment that would make git log or skip what this module relies on. */\nconst STRIPPED_ALWAYS = ['GIT_CURL_VERBOSE', 'GIT_TRACE_REDACT'];\nconst STRIPPED_PREFIXES = ['GIT_TRACE'];\n/** Environment that could redirect or override credentials when the workspace's own are in play. */\nconst STRIPPED_CREDENTIALED = [\n  'GIT_CONFIG_PARAMETERS',\n  'GIT_CONFIG_COUNT',\n  'GIT_SSL_NO_VERIFY',\n  'SSH_ASKPASS',\n  'GIT_SSH',\n  'GIT_SSH_COMMAND',\n];\nconst CONFIG_ENTRY = /^GIT_CONFIG_(KEY|VALUE)_\\d+$/u;\n\n/** The inline helper: answers `get` from this child's environment, and ignores `store` and `erase`. */\nconst ENV_CREDENTIAL_HELPER =\n  '!f(){ test \"$1\" = get && printf \"username=%s\\\\npassword=%s\\\\n\" \"$DOOMPI_GIT_USERNAME\" \"$DOOMPI_GIT_TOKEN\"; }; f';\n\n/** Whether a value holds an ASCII control character; a newline in a credential field could add a line to git's credential protocol. */\nfunction hasControl(value: string): boolean {\n  for (let index = 0; index < value.length; index += 1) {\n    const code = value.charCodeAt(index);\n    if (code < 0x20 || code === 0x7f) return true;\n  }\n  return false;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/** The workspace key: the canonical root, so a symlinked path and its target share one entry. */\nfunction workspaceKey(workspaceRoot: string): string {\n  try {\n    return fs.realpathSync(workspaceRoot);\n  } catch {\n    return path.resolve(workspaceRoot);\n  }\n}\n\nfunction expandHome(keyPath: string, homeDir: string): string {\n  return keyPath.startsWith('~/') ? path.join(homeDir, keyPath.slice(2)) : keyPath;\n}\n\nfunction parseConfig(value: unknown): GitAuthConfig | undefined {\n  if (!isRecord(value)) return undefined;\n  if (value.method === 'none') return { method: 'none' };\n  if (value.method === 'ssh') {\n    if (value.keyPath === undefined) return { method: 'ssh' };\n    return typeof value.keyPath === 'string' && value.keyPath !== ''\n      ? { method: 'ssh', keyPath: value.keyPath }\n      : undefined;\n  }\n  if (\n    value.method === 'https' &&\n    typeof value.host === 'string' &&\n    typeof value.username === 'string' &&\n    typeof value.token === 'string' &&\n    value.token !== ''\n  ) {\n    return { method: 'https', host: value.host, username: value.username, token: value.token };\n  }\n  return undefined;\n}\n\n/** What the browser may see. The token becomes a yes or no. */\nexport function publicView(config: GitAuthConfig): GitAuthView {\n  if (config.method === 'ssh')\n    return config.keyPath === undefined\n      ? { method: 'ssh', ssh: {} }\n      : { method: 'ssh', ssh: { keyPath: config.keyPath } };\n  if (config.method === 'https') {\n    return { method: 'https', https: { host: config.host, username: config.username, hasToken: config.token !== '' } };\n  }\n  return { method: 'none' };\n}\n\n/**\n * A browser save request, checked field by field. An absent HTTPS token keeps\n * the saved one, and only for the same host: a token never follows a host it\n * was not entered for.\n */\nexport function parseGitAuthSave(request: unknown, current: GitAuthConfig, homeDir: string): GitAuthConfig {\n  if (!isRecord(request))\n    throw invalidRequest('The git auth request is not an object.', 'Send method none, ssh or https.');\n  if (request.method === 'none') return { method: 'none' };\n  if (request.method === 'ssh') {\n    if (request.keyPath === undefined || request.keyPath === '') return { method: 'ssh' };\n    if (typeof request.keyPath !== 'string' || hasControl(request.keyPath)) {\n      throw invalidRequest('The key path is not a plain path.', 'Give the key as an absolute path or one under ~/.');\n    }\n    const keyPath = request.keyPath.trim();\n    if (!keyPath.startsWith('/') && !keyPath.startsWith('~/')) {\n      throw invalidRequest('The key path is not absolute.', 'Give the key as an absolute path or one under ~/.');\n    }\n    let isFile = false;\n    try {\n      isFile = fs.statSync(expandHome(keyPath, homeDir)).isFile();\n    } catch {\n      isFile = false;\n    }\n    if (!isFile)\n      throw invalidRequest(`No key file at ${keyPath}.`, 'Check the path, or leave it blank to use ssh-agent.');\n    return { method: 'ssh', keyPath };\n  }\n  if (request.method === 'https') {\n    const host = typeof request.host === 'string' ? request.host.trim().toLowerCase() : '';\n    if (!HOST_PATTERN.test(host))\n      throw invalidRequest('The host is not a host name.', 'Use a host like github.com, with an optional :port.');\n    const username = typeof request.username === 'string' ? request.username.trim() : '';\n    if (username === '' || username.length > MAX_USERNAME || hasControl(username)) {\n      throw invalidRequest('The username is empty or not plain text.', 'Enter the username the host knows you by.');\n    }\n    if (request.token !== undefined && request.token !== '') {\n      if (typeof request.token !== 'string' || request.token.length > MAX_TOKEN || hasControl(request.token)) {\n        throw invalidRequest('The token is not plain text.', 'Paste the token again without line breaks.');\n      }\n      return { method: 'https', host, username, token: request.token };\n    }\n    if (current.method === 'https' && current.host === host && current.token !== '') {\n      return { method: 'https', host, username, token: current.token };\n    }\n    throw invalidRequest(\n      current.method === 'https' ? 'The host changed, so the saved token cannot follow it.' : 'A token is required.',\n      'Enter the personal access token for this host.',\n    );\n  }\n  throw invalidRequest('The git auth method is unknown.', 'Send method none, ssh or https.');\n}\n\n/** Tightens a file or folder something left readable by group or others. */\nfunction tighten(target: string, mode: number): void {\n  try {\n    if ((fs.statSync(target).mode & LOOSE_BITS) !== 0) fs.chmodSync(target, mode);\n  } catch {\n    // Absent is fine: the first save creates it with the right mode.\n  }\n}\n\nexport function createGitAuthStore(homeDir: string = os.homedir()): GitAuthStore {\n  const file = credentialsFile(homeDir);\n  const readFile = (): GitAuthFile => {\n    tighten(file, OWNER_ONLY_FILE);\n    const raw = readJson<unknown>(file);\n    const workspaces: Record<string, GitAuthConfig> = {};\n    if (isRecord(raw) && raw.version === 1 && isRecord(raw.workspaces)) {\n      for (const [key, value] of Object.entries(raw.workspaces)) {\n        // A malformed entry is treated as unset rather than guessed at.\n        const config = parseConfig(value);\n        if (config !== undefined) workspaces[key] = config;\n      }\n    }\n    return { version: 1, workspaces };\n  };\n  const read = (workspaceRoot: string): GitAuthConfig =>\n    readFile().workspaces[workspaceKey(workspaceRoot)] ?? { method: 'none' };\n\n  return {\n    read,\n    view: (workspaceRoot) => publicView(read(workspaceRoot)),\n    save(workspaceRoot, request) {\n      const key = workspaceKey(workspaceRoot);\n      const current = readFile();\n      const next = parseGitAuthSave(request, current.workspaces[key] ?? { method: 'none' }, homeDir);\n      const root = doomGitRoot(homeDir);\n      fs.mkdirSync(root, { recursive: true, mode: OWNER_ONLY_DIRECTORY });\n      fs.chmodSync(root, OWNER_ONLY_DIRECTORY);\n      const workspaces = { ...current.workspaces };\n      if (next.method === 'none') delete workspaces[key];\n      else workspaces[key] = next;\n      writeJsonAtomic(file, { version: 1, workspaces } satisfies GitAuthFile);\n      fs.chmodSync(file, OWNER_ONLY_FILE);\n      return publicView(next);\n    },\n  };\n}\n\n/** The transport and host a remote URL names, or undefined for a local path or anything else. */\nexport function remoteTransport(url: string): { kind: 'https' | 'http' | 'ssh'; host: string } | undefined {\n  const trimmed = url.trim();\n  if (/^[a-z][a-z0-9+.-]*:\\/\\//iu.test(trimmed)) {\n    try {\n      const parsed = new URL(trimmed);\n      const kind =\n        parsed.protocol === 'https:'\n          ? 'https'\n          : parsed.protocol === 'http:'\n            ? 'http'\n            : parsed.protocol === 'ssh:'\n              ? 'ssh'\n              : undefined;\n      return kind === undefined ? undefined : { kind, host: parsed.host.toLowerCase() };\n    } catch {\n      return undefined;\n    }\n  }\n  // scp-like `user@host:path`: a colon before any slash, and not a Windows drive.\n  const scp = /^(?:[^@/]+@)?([^:/]+):(?!\\/\\/)/u.exec(trimmed);\n  if (scp !== null && scp[1] !== undefined && scp[1].length > 1) return { kind: 'ssh', host: scp[1].toLowerCase() };\n  return undefined;\n}\n\n/** Quotes one word for the POSIX shell git runs GIT_SSH_COMMAND through. */\nfunction shellQuote(value: string): string {\n  return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n}\n\n/**\n * The environment for one fetch or push against `remoteUrl`.\n *\n * Every call drops tracing (which can log credentials) and turns prompts off,\n * because no terminal is attached. Only when the workspace's method matches the\n * remote does anything secret go in, and then only into this child's env.\n */\nexport function remoteEnv(\n  config: GitAuthConfig,\n  remoteUrl: string,\n  baseEnv: NodeJS.ProcessEnv,\n  homeDir: string,\n): RemoteEnv {\n  const env: NodeJS.ProcessEnv = { ...baseEnv };\n  for (const key of Object.keys(env)) {\n    if (STRIPPED_ALWAYS.includes(key) || STRIPPED_PREFIXES.some((prefix) => key.startsWith(prefix))) delete env[key];\n  }\n  env.GIT_TERMINAL_PROMPT = '0';\n  env.GCM_INTERACTIVE = 'never';\n\n  const transport = remoteTransport(remoteUrl);\n  const credentialed = (): void => {\n    for (const key of Object.keys(env)) {\n      if (STRIPPED_CREDENTIALED.includes(key) || CONFIG_ENTRY.test(key)) delete env[key];\n    }\n    // Takes precedence over a core.askPass the repository's own config names.\n    env.GIT_ASKPASS = 'true';\n  };\n\n  if (config.method === 'https') {\n    if (transport?.kind !== 'https' || transport.host !== config.host) {\n      return {\n        env,\n        credentialed: false,\n        mismatch: `This workspace's token is for https://${config.host}, and this remote is not.`,\n      };\n    }\n    credentialed();\n    env.GIT_CONFIG_COUNT = '3';\n    env.GIT_CONFIG_KEY_0 = 'credential.helper';\n    env.GIT_CONFIG_VALUE_0 = '';\n    env.GIT_CONFIG_KEY_1 = `credential.https://${config.host}.helper`;\n    env.GIT_CONFIG_VALUE_1 = ENV_CREDENTIAL_HELPER;\n    env.GIT_CONFIG_KEY_2 = 'http.sslVerify';\n    env.GIT_CONFIG_VALUE_2 = 'true';\n    env.GIT_ALLOW_PROTOCOL = 'https';\n    env.DOOMPI_GIT_USERNAME = config.username;\n    env.DOOMPI_GIT_TOKEN = config.token;\n    return { env, credentialed: true };\n  }\n\n  if (config.method === 'ssh') {\n    if (transport?.kind !== 'ssh') {\n      return { env, credentialed: false, mismatch: 'This workspace uses SSH, and this remote is not an SSH remote.' };\n    }\n    credentialed();\n    const identity =\n      config.keyPath === undefined\n        ? []\n        : ['-i', shellQuote(expandHome(config.keyPath, homeDir)), '-o', 'IdentitiesOnly=yes'];\n    // No StrictHostKeyChecking override: an unknown host is refused, and the\n    // recovery says to trust it once from a terminal.\n    env.GIT_SSH_COMMAND = ['ssh', ...identity, '-o', 'BatchMode=yes', '-o', 'ConnectTimeout=15'].join(' ');\n    env.GIT_ALLOW_PROTOCOL = 'ssh';\n    return { env, credentialed: true };\n  }\n\n  return { env, credentialed: false };\n}\n\nexport { SETTINGS_HINT };\n","// @scaffold-generated\nimport { validRefName } from '../worktreeNaming';\nimport type { NewSessionRequestResult } from './type';\n\nconst MAX_NAME_LENGTH = 120;\n\n/** Trimmed text, undefined when absent or blank, false when not text at all. */\nfunction optionalText(value: unknown): string | undefined | false {\n  if (value === undefined) return undefined;\n  if (typeof value !== 'string') return false;\n  const trimmed = value.trim();\n  return trimmed === '' ? undefined : trimmed;\n}\n\n/**\n * Validates a new-session dialog request for a worktree session. Every ref is\n * checked here, before it can reach git as a positional argument.\n */\nexport function newSessionRequest(body: unknown): NewSessionRequestResult {\n  if (typeof body !== 'object' || body === null || Array.isArray(body)) return { error: 'A request body is required.' };\n  const record = body as Record<string, unknown>;\n  const branch = optionalText(record.branch);\n  if (branch === undefined || branch === false || !validRefName(branch))\n    return { error: 'A valid branch name is required.' };\n  const name = optionalText(record.name);\n  if (name === false || (name !== undefined && name.length > MAX_NAME_LENGTH))\n    return { error: `The session name must be text of up to ${String(MAX_NAME_LENGTH)} characters.` };\n  const named = name === undefined ? {} : { name };\n  if (record.mode === 'existing-branch') {\n    const remote = optionalText(record.remote);\n    if (remote === false || (remote !== undefined && !validRefName(remote)))\n      return { error: 'That remote name is not valid.' };\n    return { mode: 'existing-branch', branch, ...(remote === undefined ? {} : { remote }), ...named };\n  }\n  if (record.mode === 'new-branch') {\n    const baseRef = optionalText(record.baseRef);\n    if (baseRef === false || (baseRef !== undefined && !validRefName(baseRef)))\n      return { error: 'That base branch is not valid.' };\n    return { mode: 'new-branch', branch, ...(baseRef === undefined ? {} : { baseRef }), ...named };\n  }\n  return { error: 'The mode must be existing-branch or new-branch.' };\n}\n","import os from 'node:os';\n\nimport type { DoomApi, DoomApiContext, DoomApiHandler } from '@agimon-ai/doompi-core/packageApi';\n\nimport {\n  GIT_API_BASE_PATH,\n  GIT_AUTH_PATH,\n  GIT_BRANCHES_PATH,\n  GIT_REVIEW_FILE_PATH,\n  GIT_REVIEW_PATH,\n  GIT_SESSIONS_PATH,\n} from '../../../../../constants/git';\nimport { createBranchDiff } from '../../../../../services/branchDiff';\nimport { DoomGitExpectedError } from '../../../../../services/errors';\nimport { createGitAuthStore } from '../../../../../services/gitAuth';\nimport { createWorktreeGit } from '../../../../../services/gitCli';\nimport { newSessionRequest } from '../../../../../services/newSessionRequest';\nimport { registryFile } from '../../../../../services/paths';\nimport { GIT_WORKTREE_LIFECYCLE_EVENT } from '../../../../../services/worktreeEvents';\nimport { createWorktreeOperations } from '../../../../../services/worktreeOperations';\nimport { createWorktreeRegistry } from '../../../../../services/worktreeRegistry';\nimport type { GitReviewSummary } from '../../../../../types/gitReview';\nimport type { GitBranchesResponse, GitSessionCreated } from '../../../../../types/gitSessions';\n\n/**\n * The worktree surface the cockpit panel calls.\n *\n * Hub-scoped because worktrees are a property of a repository, not of one\n * session: the panel lists and creates them whether or not the session that\n * made them is focused, and a session-scoped API would disappear with it.\n *\n * The panel names a repository by the hub's opaque id and never by path.\n * `resolveRepository` turns that into an admitted root, so a browser cannot\n * point this at a directory the cockpit was never given.\n */\nfunction badRequest(message: string): Response {\n  return Response.json({ error: message }, { status: 400 });\n}\n\nfunction failed(error: unknown): Response {\n  if (error instanceof DoomGitExpectedError) {\n    return Response.json({ error: error.message, code: error.code }, { status: error.retryable ? 503 : 409 });\n  }\n  // Never the raw message: a git failure can carry a remote URL with a token.\n  return Response.json({ error: 'The worktree operation failed.' }, { status: 500 });\n}\n\nexport const api: DoomApi = {\n  basePath: GIT_API_BASE_PATH,\n  start(context: DoomApiContext): DoomApiHandler {\n    if (context.directEvents === undefined) throw new Error('Git hub API requires the direct event bus.');\n    const directEvents = context.directEvents;\n    const publishLifecycle = (sessionId: string, repositoryRoot: string): void => {\n      directEvents.publish(GIT_WORKTREE_LIFECYCLE_EVENT, sessionId, { version: 1 as const, repositoryRoot });\n    };\n    const git = createWorktreeGit();\n    const operations = createWorktreeOperations({\n      git,\n      sessionService: context.sessionService,\n      ...(context.homeDirectory === undefined ? {} : { homeDir: context.homeDirectory }),\n    });\n\n    /**\n     * The new-session dialog's routes: the workspace's branches, and a top-level\n     * worktree session on one. Workspace-mounted only, and always rooted at the\n     * mount's own workspace, so a request can never name another directory.\n     */\n    const newSession = async (request: Request, url: URL): Promise<Response | undefined> => {\n      const isBranches = request.method === 'GET' && url.pathname === GIT_BRANCHES_PATH;\n      const isCreate = request.method === 'POST' && url.pathname === GIT_SESSIONS_PATH;\n      if (!isBranches && !isCreate) return undefined;\n      const workspaceRoot = context.scope === 'workspace' ? context.workspaceRoot : undefined;\n      if (workspaceRoot === undefined)\n        return Response.json({ error: 'This route belongs to a workspace.' }, { status: 404 });\n      if (isBranches) {\n        const repositoryRoot = await git.repositoryRoot(workspaceRoot);\n        const branches: GitBranchesResponse =\n          repositoryRoot === undefined\n            ? { repository: false, local: [], remote: [] }\n            : { repository: true, ...(await git.listBranches(repositoryRoot)) };\n        return Response.json(branches);\n      }\n      const parsed = newSessionRequest(await request.json().catch(() => undefined));\n      if ('error' in parsed) return badRequest(parsed.error);\n      const record = await operations.spawn(\n        { cwd: workspaceRoot },\n        {\n          branch: parsed.branch,\n          checkout: parsed.mode === 'existing-branch' ? 'existing' : 'new',\n          ...(parsed.mode === 'existing-branch' && parsed.remote !== undefined ? { remote: parsed.remote } : {}),\n          ...(parsed.mode === 'new-branch' && parsed.baseRef !== undefined ? { baseRef: parsed.baseRef } : {}),\n          ...(parsed.name === undefined ? {} : { name: parsed.name }),\n        },\n      );\n      publishLifecycle(record.sessionId, record.repositoryRoot);\n      const created: GitSessionCreated = { sessionId: record.sessionId, worktreeId: record.id };\n      return Response.json(created, { status: 201 });\n    };\n\n    /** The admitted root for a request, or a response explaining why not. */\n    const rootOf = (url: URL): string | Response => {\n      const repositoryId = url.searchParams.get('repositoryId');\n      if (repositoryId === null || repositoryId === '') return badRequest('A repositoryId is required.');\n      const root = context.resolveRepository?.(repositoryId);\n      if (root === undefined) return badRequest('That repository is not admitted to this cockpit.');\n      return root;\n    };\n\n    const homeDir = context.homeDirectory ?? os.homedir();\n    const gitAuth = createGitAuthStore(homeDir);\n    const branchDiff = createBranchDiff();\n    const pendingReviews = new Map<string, ReturnType<typeof branchDiff.review>>();\n\n    /**\n     * A workspace's remote auth. Workspace mounts only, so the step-up gate on\n     * `PUT /api/workspaces/<id>/plugins/git/auth` is the one way to write it.\n     * The view never carries the token.\n     */\n    const auth = async (request: Request, url: URL): Promise<Response | undefined> => {\n      if (url.pathname !== GIT_AUTH_PATH) return undefined;\n      if (context.scope !== 'workspace')\n        return Response.json({ error: 'This route belongs to a workspace.' }, { status: 404 });\n      if (request.method !== 'GET' && request.method !== 'PUT')\n        return Response.json({ error: 'Use GET or PUT.' }, { status: 405 });\n      const root = rootOf(url);\n      if (root instanceof Response) return root;\n      if (request.method === 'GET') return Response.json(gitAuth.view(root));\n      try {\n        return Response.json(gitAuth.save(root, await request.json().catch(() => undefined)));\n      } catch (error) {\n        // The settings page shows this next to the field, so it gets the plain\n        // sentence and its recovery, not the tool-facing `[code]` form.\n        if (error instanceof DoomGitExpectedError && error.code === 'invalid_request') {\n          const text = error.message.replace(/^\\[[a-z_]+\\] /u, '').replace('\\nRecovery: ', ' ');\n          return Response.json({ error: text, code: error.code }, { status: 400 });\n        }\n        throw error;\n      }\n    };\n\n    /**\n     * The session's change against its base. Session mounts only, rooted at the\n     * session's own checkout; a file is served only when it is in the change set\n     * computed for the request. Overlapping requests share an in-flight snapshot.\n     */\n    const review = async (request: Request, url: URL): Promise<Response | undefined> => {\n      if (url.pathname !== GIT_REVIEW_PATH && url.pathname !== GIT_REVIEW_FILE_PATH) return undefined;\n      const cwd = context.scope === 'session' ? context.cwd : undefined;\n      if (cwd === undefined) return Response.json({ error: 'This route belongs to a session.' }, { status: 404 });\n      if (request.method !== 'GET') return Response.json({ error: 'Use GET.' }, { status: 405 });\n      let recordedBaseRef: string | undefined;\n      try {\n        recordedBaseRef = createWorktreeRegistry(registryFile(cwd, homeDir))\n          .list()\n          .find((record) => record.sessionId === context.sessionId)?.baseRef;\n      } catch {\n        recordedBaseRef = undefined;\n      }\n      const key = JSON.stringify([cwd, recordedBaseRef ?? null]);\n      let pending = pendingReviews.get(key);\n      if (pending === undefined) {\n        pending = branchDiff\n          .review(cwd, recordedBaseRef === undefined ? {} : { recordedBaseRef })\n          .finally(() => pendingReviews.delete(key));\n        pendingReviews.set(key, pending);\n      }\n      const result = await pending;\n      if (url.pathname === GIT_REVIEW_PATH) {\n        const outside: GitReviewSummary = { repository: false, files: [] };\n        return Response.json(result?.summary ?? outside);\n      }\n      const filePath = url.searchParams.get('path') ?? '';\n      if (result === undefined || !result.summary.files.some((file) => file.path === filePath)) {\n        return Response.json({ error: 'That file is not part of this review.' }, { status: 404 });\n      }\n      return Response.json(await branchDiff.fileDiff(result, filePath));\n    };\n\n    return {\n      async fetch(request) {\n        const url = new URL(request.url);\n        try {\n          const answered =\n            (await newSession(request, url)) ?? (await auth(request, url)) ?? (await review(request, url));\n          if (answered !== undefined) return answered;\n        } catch (error) {\n          context.onNotice(`git request failed: ${(error as Error).name}`);\n          return failed(error);\n        }\n        const root = rootOf(url);\n        if (root instanceof Response) return root;\n        // The operations layer works from a cwd, and an admitted repository\n        // root is one.\n        const callerContext = { cwd: root, sessionId: url.searchParams.get('sessionId') ?? '' };\n        const isMutation =\n          (request.method === 'POST' && url.pathname === '/worktrees') ||\n          (request.method === 'DELETE' && /^\\/worktrees\\/[^/]+$/u.test(url.pathname));\n        if (isMutation && callerContext.sessionId === '')\n          return badRequest('A sessionId is required for worktree mutations.');\n\n        try {\n          if (request.method === 'GET' && url.pathname === '/worktrees') {\n            return Response.json({ worktrees: await operations.list(callerContext) });\n          }\n          if (request.method === 'POST' && url.pathname === '/worktrees') {\n            const body = (await request.json()) as { branch?: string; baseRef?: string; name?: string };\n            if (typeof body.branch !== 'string' || body.branch.trim() === '') {\n              return badRequest('A branch is required.');\n            }\n            const record = await operations.spawn(callerContext, {\n              branch: body.branch,\n              ...(body.baseRef === undefined ? {} : { baseRef: body.baseRef }),\n              ...(body.name === undefined ? {} : { name: body.name }),\n            });\n            publishLifecycle(callerContext.sessionId, record.repositoryRoot);\n            return Response.json({ worktree: record }, { status: 201 });\n          }\n          const closing = /^\\/worktrees\\/([^/]+)$/u.exec(url.pathname);\n          if (request.method === 'DELETE' && closing) {\n            const record = await operations.close(\n              callerContext,\n              decodeURIComponent(String(closing[1])),\n              url.searchParams.get('force') === 'true',\n            );\n            publishLifecycle(callerContext.sessionId, record.repositoryRoot);\n            return Response.json({ worktree: record });\n          }\n          return Response.json({ error: 'No such worktree route.' }, { status: 404 });\n        } catch (error) {\n          context.onNotice(`worktree request failed: ${(error as Error).name}`);\n          return failed(error);\n        }\n      },\n      close() {},\n    };\n  },\n};\n\nexport default api;\n","import { defineRoute } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/route.server';\n\nexport default defineRoute(contribution);\n","import { DoomGitExpectedError, type DoomGitErrorCode } from '../errors';\nimport { SETTINGS_HINT } from '../gitAuth';\nimport type { GitResult } from '../gitCli';\n\n/**\n * Turns a failed remote git call into an expected error a reader can act on.\n *\n * git's stderr is matched and then dropped. It never reaches a message, a\n * notice or a tool result, because a remote URL in it can carry a token. LC_ALL\n * is pinned to C by the runner, so these English phrases are the ones git\n * prints. Order matters: a 401 also says \"unable to access\", and auth must win.\n */\n\ninterface Rule {\n  code: DoomGitErrorCode;\n  phrases: readonly string[];\n  message: string;\n  recovery: string;\n  retryable: boolean;\n}\n\nconst RULES: readonly Rule[] = [\n  {\n    code: 'host_key_changed',\n    phrases: ['remote host identification has changed'],\n    message: \"The remote's SSH host key changed since this machine last saw it.\",\n    recovery: 'Check with the host that the change is expected, then update ~/.ssh/known_hosts from a terminal.',\n    retryable: false,\n  },\n  {\n    code: 'host_key_unknown',\n    phrases: ['host key verification failed', 'no ed25519 host key is known', 'no rsa host key is known'],\n    message: \"This machine does not trust the remote's SSH host key yet.\",\n    recovery: 'Run `ssh -T git@<host>` once in a terminal and accept the key, then try again.',\n    retryable: false,\n  },\n  {\n    code: 'auth_failed',\n    phrases: [\n      'authentication failed',\n      'could not read username',\n      'could not read password',\n      'permission denied (publickey',\n      'returned error: 401',\n      'returned error: 403',\n      'terminal prompts disabled',\n      'load key',\n      'unprotected private key',\n      'invalid format',\n    ],\n    message: 'The remote refused the credentials.',\n    recovery: `Check this workspace's git remote auth. ${SETTINGS_HINT}`,\n    retryable: false,\n  },\n  {\n    code: 'repository_not_found',\n    phrases: ['repository not found', 'does not appear to be a git repository'],\n    message: 'The remote repository was not found, or these credentials cannot see it.',\n    recovery: `Check the remote URL and that the credentials have access. ${SETTINGS_HINT}`,\n    retryable: false,\n  },\n  {\n    code: 'remote_unreachable',\n    phrases: [\n      'could not resolve host',\n      'connection refused',\n      'connection timed out',\n      'operation timed out',\n      'unable to access',\n      'network is unreachable',\n    ],\n    message: 'The remote could not be reached.',\n    recovery: 'Check the network and the remote URL, then try again.',\n    retryable: true,\n  },\n  {\n    code: 'push_lease_rejected',\n    phrases: ['(stale info)'],\n    message: 'The remote branch moved since your last fetch, so the force push was refused.',\n    recovery: 'Pull to see the new commits, then decide whether to push again.',\n    retryable: false,\n  },\n  {\n    code: 'push_needs_force',\n    phrases: ['(non-fast-forward)', '(fetch first)'],\n    message: 'The remote branch has commits yours replaced, usually after a rebase.',\n    recovery: 'Confirm a force push with lease, or pull first to keep the remote commits.',\n    retryable: false,\n  },\n  {\n    code: 'worktree_dirty',\n    phrases: [\n      'unstaged changes',\n      'uncommitted changes',\n      'would be overwritten',\n      'your index contains uncommitted changes',\n    ],\n    message: 'There are uncommitted changes in the way.',\n    recovery: 'Commit or stash your changes first.',\n    retryable: false,\n  },\n];\n\nexport function classifyGitFailure(operation: string, result: GitResult, mismatch?: string): DoomGitExpectedError {\n  if (result.timedOut) {\n    return new DoomGitExpectedError(\n      'git_timeout',\n      `git ${operation} took too long and was stopped.`,\n      true,\n      'Check the network, then try again.',\n    );\n  }\n  const text = `${result.stderr}\\n${result.stdout}`.toLowerCase();\n  const rule = RULES.find((candidate) => candidate.phrases.some((phrase) => text.includes(phrase)));\n  if (rule === undefined) {\n    return new DoomGitExpectedError(\n      'git_failed',\n      `git ${operation} failed (exit ${String(result.code)}).`,\n      false,\n      'Run the same command in a terminal in this checkout to see what git says.',\n    );\n  }\n  const recovery =\n    rule.code === 'auth_failed' && mismatch !== undefined ? `${mismatch} ${rule.recovery}` : rule.recovery;\n  return new DoomGitExpectedError(rule.code, rule.message, rule.retryable, recovery);\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nimport { resolveBaseRef } from '../branchDiff';\nimport { DoomGitExpectedError } from '../errors';\nimport { remoteEnv } from '../gitAuth';\nimport { NETWORK_TIMEOUT_MS, READ_TIMEOUT_MS, REBASE_TIMEOUT_MS, runGit } from '../gitCli';\nimport { classifyGitFailure } from '../gitFailure';\nimport type { GitSync, GitSyncContext, GitSyncOptions, GitSyncOutcome } from './type';\n\n/**\n * Manual pull, push and rebase for a session's checkout.\n *\n * DESIGN PATTERNS:\n * - The workspace's auth goes into the environment of the one fetch or push\n *   that needs it, built fresh per call. Rebase itself runs locally and never\n *   sees a credential.\n * - Fetch and rebase are separate commands, so a hung network can never leave a\n *   rebase half applied.\n * - A conflicted rebase is not an error. It is left paused for the reader to\n *   hand to the agent or abort, and git's own state reports it from then on.\n * - Pull and rebase refuse uncommitted tracked changes rather than stash them.\n *   Untracked files only block when git says they would be overwritten.\n * - Push never forces on its own. A rejection comes back as `push_needs_force`,\n *   and only a confirmed retry sends `--force-with-lease --force-if-includes`,\n *   which git refuses if the remote holds commits this branch never integrated.\n */\n\nconst DONE: GitSyncOutcome = { outcome: 'done' };\n\nfunction expected(\n  code: ConstructorParameters<typeof DoomGitExpectedError>[0],\n  message: string,\n  recovery: string,\n): DoomGitExpectedError {\n  return new DoomGitExpectedError(code, message, false, recovery);\n}\n\nasync function readLine(cwd: string, args: readonly string[]): Promise<string | undefined> {\n  const result = await runGit(cwd, args, { timeout: READ_TIMEOUT_MS });\n  const out = result.stdout.trim();\n  return result.code === 0 && out !== '' ? out : undefined;\n}\n\nasync function toplevel(cwd: string): Promise<string> {\n  const root = await readLine(cwd, ['rev-parse', '--show-toplevel']);\n  if (root === undefined)\n    throw expected(\n      'not_a_repository',\n      'This session is not in a git checkout.',\n      'Open the session in a git repository.',\n    );\n  return root;\n}\n\nasync function rebasing(root: string): Promise<boolean> {\n  for (const name of ['rebase-merge', 'rebase-apply']) {\n    const gitPath = await readLine(root, ['rev-parse', '--git-path', name]);\n    if (gitPath !== undefined && fs.existsSync(path.resolve(root, gitPath))) return true;\n  }\n  return false;\n}\n\nasync function conflicts(root: string): Promise<string[]> {\n  const result = await runGit(root, ['diff', '--name-only', '--diff-filter=U', '-z'], { timeout: READ_TIMEOUT_MS });\n  return result.stdout.split('\\0').filter((file) => file !== '');\n}\n\nasync function currentBranch(root: string): Promise<string> {\n  const branch = await readLine(root, ['symbolic-ref', '--quiet', '--short', 'HEAD']);\n  if (branch === undefined) {\n    throw expected('detached_head', 'HEAD is detached, so there is no branch to sync.', 'Check out a branch first.');\n  }\n  return branch;\n}\n\nasync function guard(root: string, needsCleanTree: boolean): Promise<string> {\n  if (await rebasing(root)) {\n    throw expected(\n      'rebase_in_progress',\n      'A rebase is paused in this checkout.',\n      'Ask the agent to resolve it, or abort the rebase.',\n    );\n  }\n  const branch = await currentBranch(root);\n  if (needsCleanTree) {\n    const dirty = await readLine(root, ['status', '--porcelain', '--untracked-files=no']);\n    if (dirty !== undefined)\n      throw expected('worktree_dirty', 'There are uncommitted changes.', 'Commit or stash your changes first.');\n  }\n  return branch;\n}\n\nexport function createGitSync(options: GitSyncOptions): GitSync {\n  const baseEnv = options.baseEnv ?? process.env;\n\n  /** One credentialed network command against `remote`, classified on failure. */\n  const network = async (\n    root: string,\n    context: GitSyncContext,\n    remote: string,\n    operation: string,\n    args: readonly string[],\n    urlArgs: readonly string[] = [],\n  ): Promise<void> => {\n    const url = await readLine(root, ['remote', 'get-url', ...urlArgs, remote]);\n    if (url === undefined)\n      throw expected('no_remote', `There is no remote named ${remote}.`, 'Add the remote in a terminal first.');\n    const prepared = remoteEnv(context.auth, url, baseEnv, options.homeDir);\n    const result = await runGit(root, args, { timeout: NETWORK_TIMEOUT_MS, env: prepared.env });\n    if (result.code !== 0) throw classifyGitFailure(operation, result, prepared.mismatch);\n  };\n\n  /** Rebases onto `onto`; a stop on conflicts leaves the rebase paused and says so. */\n  const rebaseOnto = async (root: string, onto: string): Promise<GitSyncOutcome> => {\n    const result = await runGit(root, ['rebase', onto], {\n      timeout: REBASE_TIMEOUT_MS,\n      env: { ...baseEnv, GIT_EDITOR: 'true', GIT_TERMINAL_PROMPT: '0' },\n    });\n    if (result.code === 0) return DONE;\n    if (await rebasing(root)) return { outcome: 'paused', conflicts: await conflicts(root) };\n    throw classifyGitFailure('rebase', result);\n  };\n\n  /** The remote a ref like `origin/main` or `refs/remotes/origin/main` belongs to. */\n  const remoteOfRef = async (root: string, ref: string): Promise<string | undefined> => {\n    const full = await readLine(root, ['rev-parse', '--symbolic-full-name', ref]);\n    if (full === undefined || !full.startsWith('refs/remotes/')) return undefined;\n    const rest = full.slice('refs/remotes/'.length);\n    const cut = rest.indexOf('/');\n    return cut > 0 ? rest.slice(0, cut) : undefined;\n  };\n\n  return {\n    async pull(context) {\n      const root = await toplevel(context.cwd);\n      const branch = await guard(root, true);\n      const remote = await readLine(root, ['config', `branch.${branch}.remote`]);\n      const upstream = await readLine(root, [\n        'rev-parse',\n        '--abbrev-ref',\n        '--symbolic-full-name',\n        `${branch}@{upstream}`,\n      ]);\n      if (remote === undefined || upstream === undefined) {\n        throw expected('no_upstream', `${branch} has no upstream to pull from.`, 'Push once to set an upstream.');\n      }\n      // A branch tracking another local branch has nothing to fetch.\n      if (remote !== '.') await network(root, context, remote, 'fetch', ['fetch', '--prune', remote]);\n      return rebaseOnto(root, upstream);\n    },\n\n    async push(context, force) {\n      const root = await toplevel(context.cwd);\n      const branch = await guard(root, false);\n      const configuredRemote = await readLine(root, ['config', `branch.${branch}.remote`]);\n      const merge = await readLine(root, ['config', `branch.${branch}.merge`]);\n      let remote = configuredRemote;\n      let target = merge;\n      const args = ['push', '--porcelain'];\n      if (remote === undefined || target === undefined || remote === '.') {\n        const remotes = ((await readLine(root, ['remote'])) ?? '').split('\\n').filter((name) => name !== '');\n        remote = remotes.includes('origin') ? 'origin' : remotes.length === 1 ? remotes[0] : undefined;\n        if (remote === undefined) {\n          throw expected(\n            'no_remote',\n            'There is no remote to push to.',\n            remotes.length === 0\n              ? 'Add a remote in a terminal first.'\n              : 'Push once from a terminal to choose the remote.',\n          );\n        }\n        target = `refs/heads/${branch}`;\n        args.push('--set-upstream');\n      }\n      if (force) args.push(`--force-with-lease=${target}`, '--force-if-includes');\n      args.push(remote, `HEAD:${target}`);\n      await network(root, context, remote, 'push', args, ['--push']);\n      return DONE;\n    },\n\n    async rebase(context) {\n      const root = await toplevel(context.cwd);\n      const branch = await guard(root, true);\n      const base = await resolveBaseRef(root, branch, context.recordedBaseRef);\n      if (base === undefined)\n        throw expected(\n          'no_base',\n          'No base branch to rebase onto.',\n          'Fetch the remote, or create the worktree from a base.',\n        );\n      const remote = await remoteOfRef(root, base);\n      if (remote !== undefined) await network(root, context, remote, 'fetch', ['fetch', '--prune', remote]);\n      return rebaseOnto(root, base);\n    },\n\n    async abortRebase(context) {\n      const root = await toplevel(context.cwd);\n      if (!(await rebasing(root))) return DONE;\n      const result = await runGit(root, ['rebase', '--abort'], { timeout: REBASE_TIMEOUT_MS });\n      if (result.code !== 0) throw classifyGitFailure('rebase --abort', result);\n      return DONE;\n    },\n  };\n}\n","/**\n * The cockpit's view of what this session changed against its base: the counts\n * the '# diff' group shows, what the review tab lists and draws, and the manual\n * sync that sits beside them.\n *\n * DESIGN PATTERNS:\n * - Declarations only, shared by the hub and the page.\n * - Its own channel, apart from worktrees. Worktrees are repository\n *   management; the diff is this session's code change.\n * - A diff row carries one line number whose file follows from its marker: the\n *   new file's for context and additions, the old file's for removals. It is\n *   the same shape the shared DiffView draws.\n *\n * AVOID:\n * - Behaviour or node builtins. Browser code imports this file.\n */\n\n/** The session channel carrying this checkout's changes and the sync around them. */\nexport const GIT_CHANGES_TYPE = 'git_changes';\n\n/** The sync actions the review tab offers. */\nexport type GitSyncAction = 'pull' | 'push' | 'rebase' | 'abort-rebase';\n\n/** What the review tab asks the hub to run. `force` only follows a confirmed rejected push. */\nexport type GitChangesCommand =\n  | { action: 'pull' }\n  | { action: 'push'; force?: true }\n  | { action: 'rebase' }\n  | { action: 'abort-rebase' };\n\nexport type GitSyncErrorTarget =\n  | { action: 'pull' | 'rebase' | 'abort-rebase' }\n  /** A push the remote rejected as non-fast-forward; the tab offers a lease force after a confirm. */\n  | { action: 'push'; forceRequired?: true };\n\nexport interface GitChangesPayload {\n  /** Absent outside a git checkout. */\n  changes?: GitChangesView;\n  /** Label of the sync command in flight. */\n  pending?: string;\n  /** The last sync failure, cleared when the next command starts. */\n  error?: string;\n  errorTarget?: GitSyncErrorTarget;\n}\n\n/** What the session changed since its base, as the '# diff' lane and the review header show it. */\nexport interface GitChangesView {\n  /** The checked-out branch; absent on a detached HEAD. */\n  branch?: string;\n  /** The ref the changes are measured against; absent when none resolved, so only uncommitted work counts. */\n  base?: string;\n  added: number;\n  removed: number;\n  files: number;\n  /** More files changed than were counted. */\n  truncated?: boolean;\n  /** The branch's upstream and how far apart the two are. */\n  upstream?: { ref: string; ahead: number; behind: number };\n  /** Present while a rebase is paused on conflicts. */\n  rebase?: { conflicts: string[] };\n}\n\nexport type GitReviewFileStatus = 'added' | 'modified' | 'deleted' | 'untracked' | 'conflicted';\n\n/** One changed file in the review list. */\nexport interface GitReviewFileEntry {\n  /** Repository-relative, forward slashes. */\n  path: string;\n  status: GitReviewFileStatus;\n  added: number;\n  removed: number;\n  binary?: boolean;\n}\n\n/** The review tab's file list. */\nexport interface GitReviewSummary {\n  /** False when the session's directory is not a git checkout. */\n  repository: boolean;\n  branch?: string;\n  base?: string;\n  /** Short sha of the commit the diff starts from. */\n  mergeBase?: string;\n  files: GitReviewFileEntry[];\n  truncated?: boolean;\n}\n\nexport interface GitDiffRow {\n  marker: '+' | '-' | ' ';\n  line: number;\n  content: string;\n}\n\nexport interface GitDiffHunk {\n  start: number;\n  rows: GitDiffRow[];\n}\n\n/** One file's hunks, fetched when the reader expands it. */\nexport interface GitReviewFileDiff {\n  path: string;\n  hunks: GitDiffHunk[];\n  binary?: true;\n  /** The diff was past the size cap and is not drawn. */\n  tooLarge?: true;\n}\n","/**\n * The '# diff' data channel: this session's change against its base, and the\n * manual sync commands the review tab sends back through it.\n *\n * DESIGN PATTERNS:\n * - Apart from the worktrees channel. Worktrees are repository management;\n *   this is the session's own code change.\n * - Push, not poll. The session facet publishes a \"changed\" event after every\n *   tool call and settled turn; recounts are coalesced to one in flight plus\n *   one rerun, so a burst of tool calls costs at most two.\n * - One sync command per session. A rebase and a push must never overlap.\n * - Auth is read fresh for each command from the session's workspace, and goes\n *   only into that command's git child.\n *\n * AVOID:\n * - Echoing git output. Failures go through classifyGitFailure, which matches\n *   stderr and drops it, because a remote URL in it can carry a token.\n */\nimport os from 'node:os';\n\nimport type { DoomHubChannel, DoomHubChannelSource, DoomHubSessionScope } from '@agimon-ai/doompi-core/hubChannel';\n\nimport { createBranchDiff } from '../../../../services/branchDiff';\nimport type { BranchDiff } from '../../../../services/branchDiff/type';\nimport { DoomGitExpectedError } from '../../../../services/errors';\nimport { createGitAuthStore } from '../../../../services/gitAuth';\nimport type { GitAuthStore } from '../../../../services/gitAuth/type';\nimport { createGitSync } from '../../../../services/gitSync';\nimport type { GitSync, GitSyncOutcome } from '../../../../services/gitSync/type';\nimport { registryFile } from '../../../../services/paths';\nimport { GIT_SESSION_CHANGED_EVENT, isSessionChangedEvent } from '../../../../services/worktreeEvents';\nimport { createWorktreeRegistry } from '../../../../services/worktreeRegistry';\nimport {\n  GIT_CHANGES_TYPE,\n  type GitChangesCommand,\n  type GitChangesPayload,\n  type GitChangesView,\n  type GitSyncErrorTarget,\n} from '../../../../types/gitReview';\n\ninterface SessionState {\n  changes: GitChangesView | undefined;\n  pending: string | undefined;\n  error: string | undefined;\n  errorTarget: GitSyncErrorTarget | undefined;\n}\n\n/** What the channel needs from its surroundings, injected so tests stay off this machine's home. */\nexport interface GitChangesChannelOptions {\n  homeDir?: string;\n  diff?: BranchDiff;\n  sync?: GitSync;\n  auth?: GitAuthStore;\n}\n\nfunction payloadOf(state: SessionState): GitChangesPayload {\n  return {\n    ...(state.changes === undefined ? {} : { changes: state.changes }),\n    ...(state.pending === undefined ? {} : { pending: state.pending }),\n    ...(state.error === undefined ? {} : { error: state.error }),\n    ...(state.errorTarget === undefined ? {} : { errorTarget: state.errorTarget }),\n  };\n}\n\n/** A command the page sent, or undefined when the frame was not one. */\nexport function parseChangesCommand(payload: unknown): GitChangesCommand | undefined {\n  if (typeof payload !== 'object' || payload === null) return undefined;\n  const value = payload as Record<string, unknown>;\n  if (value.action === 'pull' || value.action === 'rebase' || value.action === 'abort-rebase')\n    return { action: value.action };\n  if (value.action === 'push') return value.force === true ? { action: 'push', force: true } : { action: 'push' };\n  return undefined;\n}\n\nconst PENDING: Readonly<Record<GitChangesCommand['action'], string>> = {\n  pull: 'pulling…',\n  push: 'pushing…',\n  rebase: 'rebasing…',\n  'abort-rebase': 'aborting the rebase…',\n};\n\n/** The error target a failure maps to: a rejected plain push asks for a confirmed lease force. */\nfunction errorTargetFor(command: GitChangesCommand, error: unknown): GitSyncErrorTarget {\n  if (command.action !== 'push') return { action: command.action };\n  const needsForce =\n    error instanceof DoomGitExpectedError && error.code === 'push_needs_force' && command.force !== true;\n  return needsForce ? { action: 'push', forceRequired: true } : { action: 'push' };\n}\n\nfunction failureText(error: unknown): string {\n  // The expected error's message carries its own `[code]` prefix and recovery\n  // line; the page shows the human part.\n  if (error instanceof DoomGitExpectedError)\n    return error.message.replace(/^\\[[a-z_]+\\] /u, '').replace('\\nRecovery: ', ' ');\n  return 'The git command failed.';\n}\n\nexport function createGitChangesChannel(options: GitChangesChannelOptions = {}): DoomHubChannel {\n  let receiveCommand: ((scope: DoomHubSessionScope, payload: unknown) => void) | undefined;\n\n  return {\n    frameType: GIT_CHANGES_TYPE,\n    start(host) {\n      const homeDir = options.homeDir ?? os.homedir();\n      const diff = options.diff ?? createBranchDiff();\n      const sync = options.sync ?? createGitSync({ homeDir });\n      const auth = options.auth ?? createGitAuthStore(homeDir);\n      const latest = new Map<string, SessionState>();\n      const subscriptions = new Map<string, () => void>();\n      const scopes = new Map<string, DoomHubSessionScope>();\n      const inFlight = new Set<string>();\n      const rerun = new Set<string>();\n      const busy = new Set<string>();\n\n      /** The base the session's own worktree was created from, when it has one. */\n      const recordedBaseRef = (scope: DoomHubSessionScope): string | undefined => {\n        try {\n          return createWorktreeRegistry(registryFile(scope.cwd, homeDir))\n            .list()\n            .find((record) => record.sessionId === scope.sessionId)?.baseRef;\n        } catch {\n          return undefined;\n        }\n      };\n\n      /** Republishes a session, skipping a frame that would say nothing new. */\n      const publish = (sessionId: string, next: SessionState): void => {\n        const previous = latest.get(sessionId);\n        latest.set(sessionId, next);\n        if (previous !== undefined && JSON.stringify(payloadOf(previous)) === JSON.stringify(payloadOf(next))) return;\n        host.publish(sessionId, payloadOf(next));\n      };\n\n      const update = (sessionId: string, patch: Partial<SessionState>): void => {\n        const previous = latest.get(sessionId) ?? {\n          changes: undefined,\n          pending: undefined,\n          error: undefined,\n          errorTarget: undefined,\n        };\n        publish(sessionId, { ...previous, ...patch });\n      };\n\n      /** Recounts one session; a request while one runs schedules exactly one more. */\n      const refresh = (sessionId: string): void => {\n        const scope = scopes.get(sessionId);\n        if (scope === undefined) return;\n        if (inFlight.has(sessionId)) {\n          rerun.add(sessionId);\n          return;\n        }\n        inFlight.add(sessionId);\n        const base = recordedBaseRef(scope);\n        void diff\n          .review(scope.cwd, base === undefined ? {} : { recordedBaseRef: base })\n          .then((review) => {\n            if (scopes.has(sessionId)) update(sessionId, { changes: review?.changes });\n          })\n          .catch((error: unknown) => {\n            host.onNotice(\n              `git diff refresh failed for ${sessionId} (${error instanceof Error ? error.name : 'unknown'})`,\n            );\n          })\n          .finally(() => {\n            inFlight.delete(sessionId);\n            if (rerun.delete(sessionId)) refresh(sessionId);\n          });\n      };\n\n      const run = (scope: DoomHubSessionScope, command: GitChangesCommand): Promise<GitSyncOutcome> => {\n        const workspaceRoot = scope.sessionContext?.workspaceRoot ?? scope.cwd;\n        const base = recordedBaseRef(scope);\n        const context = {\n          cwd: scope.cwd,\n          auth: auth.read(workspaceRoot),\n          ...(base === undefined ? {} : { recordedBaseRef: base }),\n        };\n        if (command.action === 'pull') return sync.pull(context);\n        if (command.action === 'push') return sync.push(context, command.force === true);\n        if (command.action === 'rebase') return sync.rebase(context);\n        return sync.abortRebase(context);\n      };\n\n      const source: DoomHubChannelSource = {\n        payloadFor(scope) {\n          const state = latest.get(scope.sessionId);\n          return state === undefined ? undefined : payloadOf(state);\n        },\n        sessionAdded(scope) {\n          scopes.set(scope.sessionId, scope);\n          refresh(scope.sessionId);\n          const unsubscribe = host.directEvents.subscribe(GIT_SESSION_CHANGED_EVENT, scope.sessionId, (payload) => {\n            if (isSessionChangedEvent(payload)) refresh(scope.sessionId);\n          });\n          subscriptions.set(scope.sessionId, unsubscribe);\n        },\n        sessionRemoved(sessionId) {\n          subscriptions.get(sessionId)?.();\n          subscriptions.delete(sessionId);\n          scopes.delete(sessionId);\n          latest.delete(sessionId);\n          rerun.delete(sessionId);\n          busy.delete(sessionId);\n        },\n        close() {\n          for (const unsubscribe of subscriptions.values()) unsubscribe();\n          subscriptions.clear();\n          scopes.clear();\n          latest.clear();\n          rerun.clear();\n          busy.clear();\n        },\n      };\n\n      receiveCommand = (scope, payload) => {\n        const command = parseChangesCommand(payload);\n        if (command === undefined || !scopes.has(scope.sessionId)) return;\n        if (busy.has(scope.sessionId)) return;\n        busy.add(scope.sessionId);\n        update(scope.sessionId, { pending: PENDING[command.action], error: undefined, errorTarget: undefined });\n        void run(scope, command)\n          .then(() => update(scope.sessionId, { pending: undefined }))\n          .catch((error: unknown) => {\n            host.onNotice(\n              `git ${command.action} failed for ${scope.sessionId} (${error instanceof DoomGitExpectedError ? error.code : 'unexpected'})`,\n            );\n            update(scope.sessionId, {\n              pending: undefined,\n              error: failureText(error),\n              errorTarget: errorTargetFor(command, error),\n            });\n          })\n          .finally(() => {\n            busy.delete(scope.sessionId);\n            // A paused rebase, a moved upstream and new commits all show in the recount.\n            refresh(scope.sessionId);\n          });\n      };\n\n      return source;\n    },\n    receive(scope, payload) {\n      receiveCommand?.(scope, payload);\n    },\n  };\n}\n\nexport default createGitChangesChannel;\n","import { defineChannel } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/git-changes.server';\n\nexport default defineChannel(contribution);\n","/**\n * The cockpit's view of this session's worktrees.\n *\n * DESIGN PATTERNS:\n * - Declarations only. The channel frame type is a constant so the hub and the\n *   page cannot drift apart on a string.\n * - A view is the subset of a record the dock needs, not the record. The\n *   registry may hold paths and provenance the page has no business rendering.\n *\n * AVOID:\n * - Adding behaviour here. This file is imported by browser code, so it must\n *   stay free of node builtins.\n */\n\n/** The data channel carrying one session's worktrees to the page. */\nexport const GIT_WORKTREES_TYPE = 'git_worktrees';\n\n/** One worktree, as the activity dock and its panel render it. */\nexport interface WorktreeView {\n  id: string;\n  branch: string;\n  path: string;\n  /** The session the hub started for this worktree, when it is still live. */\n  sessionId: string | null;\n  /** True once the directory the record names has gone missing. */\n  orphaned: boolean;\n  /**\n   * True when the session that asked for this worktree is gone.\n   *\n   * An owned worktree is only ever shown to its own session. This flag marks\n   * the exception: once the parent is dead nobody would see the worktree at\n   * all, so every session in the repository does, and may close it.\n   */\n  unowned: boolean;\n}\n\n/**\n * What the panel asks the hub channel to do.\n *\n * The dock acts through its own channel rather than through the agent: a\n * worktree made from the panel and one made by the tool take the same\n * `worktreeOperations` path, but the panel no longer has to spend a turn of\n * the conversation to get there.\n */\nexport type GitWorktreesCommand =\n  | { action: 'create'; branch: string; baseRef?: string; reservationId?: string }\n  | { action: 'close'; id: string; force?: boolean };\n\nexport type WorktreeErrorTarget = { action: 'create' } | { action: 'close'; id: string };\n\nexport interface GitWorktreesPayload {\n  worktrees: WorktreeView[];\n  /** Label of the operation in flight, absent when the session is idle. */\n  pending?: string;\n  /** The last failure, cleared when the next command starts. */\n  error?: string;\n  /** The operation that produced the last failure, when known. */\n  errorTarget?: WorktreeErrorTarget;\n}\n","/**\n * The worktrees data channel, and the commands the dock sends back through it.\n *\n * The registry is durable state only. Live lifecycle changes arrive through the\n * hub-owned direct event bus, so this channel never polls or claims files.\n */\nimport type {\n  DoomHubChannel,\n  DoomHubChannelSource,\n  DoomHubSessionScope,\n  DoomHubSessionService,\n} from '@agimon-ai/doompi-core/hubChannel';\n\nimport { DoomGitExpectedError, HubUnavailableError } from '../../../../services/errors';\nimport { createWorktreeGit } from '../../../../services/gitCli';\nimport { registryFile } from '../../../../services/paths';\nimport { GIT_WORKTREE_LIFECYCLE_EVENT, isWorktreeLifecycleEvent } from '../../../../services/worktreeEvents';\nimport { createWorktreeOperations, type WorktreeOperations } from '../../../../services/worktreeOperations';\nimport { createWorktreeRegistry } from '../../../../services/worktreeRegistry';\nimport {\n  GIT_WORKTREES_TYPE,\n  type GitWorktreesCommand,\n  type WorktreeErrorTarget,\n  type WorktreeView,\n} from '../../../../types/webWorktrees';\n\ninterface SessionState {\n  worktrees: WorktreeView[];\n  pending: string | undefined;\n  error: string | undefined;\n  errorTarget: WorktreeErrorTarget | undefined;\n}\n\nfunction payloadOf(state: SessionState): Record<string, unknown> {\n  return {\n    worktrees: state.worktrees,\n    ...(state.pending === undefined ? {} : { pending: state.pending }),\n    ...(state.error === undefined ? {} : { error: state.error }),\n    ...(state.errorTarget === undefined ? {} : { errorTarget: state.errorTarget }),\n  };\n}\n\n/** What the channel needs from its surroundings, injected so tests stay off this machine. */\nexport interface WorktreesChannelOptions {\n  operations?: WorktreeOperations;\n  homeDir?: string;\n}\n\ninterface ViewDeps {\n  homeDir: string | undefined;\n  sessionService: DoomHubSessionService;\n}\n\n/** Worktrees visible to this session, using the hub's live session table for ownership. */\nfunction viewsFor(scope: DoomHubSessionScope, deps: ViewDeps): WorktreeView[] {\n  try {\n    return createWorktreeRegistry(registryFile(scope.cwd, deps.homeDir))\n      .list()\n      .flatMap((record) => {\n        // A worktree opened on its own from the new-session dialog belongs to the session\n        // inside it; sibling sessions in the repository never see it.\n        if (record.parentSessionId === undefined && record.sessionId !== scope.sessionId) return [];\n        const owned = record.parentSessionId === undefined || record.parentSessionId === scope.sessionId;\n        const unowned = !owned && !deps.sessionService.isLive(record.parentSessionId!);\n        if (!owned && !unowned) return [];\n        return [\n          {\n            id: record.id,\n            branch: record.branch,\n            path: record.path,\n            sessionId: record.status === 'orphaned' ? null : record.sessionId,\n            orphaned: record.status === 'orphaned',\n            unowned,\n          },\n        ];\n      });\n  } catch {\n    return [];\n  }\n}\n\nfunction sameList(left: readonly WorktreeView[], right: readonly WorktreeView[]): boolean {\n  if (left.length !== right.length) return false;\n  return left.every((entry, index) => {\n    const other = right[index];\n    return (\n      other !== undefined &&\n      entry.id === other.id &&\n      entry.branch === other.branch &&\n      entry.sessionId === other.sessionId &&\n      entry.orphaned === other.orphaned &&\n      entry.unowned === other.unowned\n    );\n  });\n}\n\nfunction errorTargetFor(command: GitWorktreesCommand): WorktreeErrorTarget {\n  return command.action === 'create' ? { action: 'create' } : { action: 'close', id: command.id };\n}\n\n/** A command the page sent, or undefined when the frame was not one. */\nfunction parseCommand(payload: unknown): GitWorktreesCommand | undefined {\n  if (typeof payload !== 'object' || payload === null) return undefined;\n  const value = payload as Record<string, unknown>;\n  if (value.action === 'create') {\n    if (typeof value.branch !== 'string' || value.branch.trim() === '') return undefined;\n    if (\n      value.reservationId !== undefined &&\n      (typeof value.reservationId !== 'string' || !/^[A-Za-z0-9_-]+$/u.test(value.reservationId))\n    )\n      return undefined;\n    return {\n      action: 'create',\n      branch: value.branch.trim(),\n      ...(typeof value.baseRef === 'string' && value.baseRef.trim() !== '' ? { baseRef: value.baseRef.trim() } : {}),\n      ...(typeof value.reservationId === 'string' ? { reservationId: value.reservationId } : {}),\n    };\n  }\n  if (value.action === 'close') {\n    if (typeof value.id !== 'string' || value.id === '') return undefined;\n    return { action: 'close', id: value.id, ...(value.force === true ? { force: true } : {}) };\n  }\n  return undefined;\n}\n\n/**\n * What the reader is told when a command fails.\n *\n * An expected failure explains itself. Anything else is summarised, never\n * echoed: a git error can carry a remote URL with a token in it.\n */\nfunction failureText(error: unknown): string {\n  return error instanceof DoomGitExpectedError ? error.message : 'The worktree operation failed.';\n}\n\n/** Starts one direct-event subscription per managed session. */\nexport function createWorktreesChannel(options: WorktreesChannelOptions = {}): DoomHubChannel {\n  // Assigned by start, because receive is reachable only while the channel is\n  // running and the command needs the state the direct event subscriptions keep.\n  let receiveCommand: ((scope: DoomHubSessionScope, payload: unknown) => void) | undefined;\n\n  return {\n    frameType: GIT_WORKTREES_TYPE,\n    start(host) {\n      const sessionService = host.sessionService;\n      if (sessionService === undefined) {\n        throw new HubUnavailableError('The cockpit session service is unavailable. Start the cockpit and try again.');\n      }\n      const worktrees =\n        options.operations ??\n        createWorktreeOperations({\n          git: createWorktreeGit(),\n          sessionService,\n        });\n      /** Announces a successful mutation to this session's lifecycle subscribers. */\n      const publishLifecycle = (scope: DoomHubSessionScope, repositoryRoot: string): void => {\n        host.directEvents.publish(GIT_WORKTREE_LIFECYCLE_EVENT, scope.sessionId, {\n          version: 1,\n          repositoryRoot,\n        });\n      };\n      const unregisterWorktreeProvisioner = sessionService.registerReservedWorktreeProvisioner?.(\n        async ({ reservationId, parentSessionId, signal }) => {\n          const parent = host.sessions().find((scope) => scope.sessionId === parentSessionId);\n          if (parent === undefined) throw new Error('The conversation parent session is unavailable.');\n          const branch = `doompi/conversation-${reservationId.slice(0, 12)}`;\n          const record = await worktrees.spawn(\n            { cwd: parent.cwd, sessionId: parent.sessionId },\n            { branch, name: `conversation ${reservationId.slice(0, 8)}`, reservationId },\n            { signal },\n          );\n          const reservations = sessionService.reservations;\n          if (reservations === undefined) throw new Error('Conversation reservations are unavailable.');\n          const session = await reservations.complete(reservationId, parentSessionId);\n          publishLifecycle(parent, record.repositoryRoot);\n          return session;\n        },\n      );\n      const views: ViewDeps = { homeDir: options.homeDir, sessionService };\n      const latest = new Map<string, SessionState>();\n      const subscriptions = new Map<string, () => void>();\n      const busy = new Set<string>();\n      const generations = new Map<string, symbol>();\n      const newGeneration = (sessionId: string): symbol => {\n        const generation = Symbol(sessionId);\n        generations.set(sessionId, generation);\n        return generation;\n      };\n\n      /** Republishes a session, skipping a frame that would say nothing new. */\n      const publish = (scope: DoomHubSessionScope, force: boolean): void => {\n        const previous = latest.get(scope.sessionId);\n        const next: SessionState = {\n          worktrees: viewsFor(scope, views),\n          pending: previous?.pending,\n          error: previous?.error,\n          errorTarget: previous?.errorTarget,\n        };\n        if (\n          !force &&\n          previous !== undefined &&\n          sameList(previous.worktrees, next.worktrees) &&\n          previous.pending === next.pending &&\n          previous.error === next.error &&\n          previous.errorTarget === next.errorTarget\n        ) {\n          return;\n        }\n        latest.set(scope.sessionId, next);\n        host.publish(scope.sessionId, payloadOf(next));\n      };\n\n      const mark = (\n        scope: DoomHubSessionScope,\n        pending: string | undefined,\n        error: string | undefined,\n        errorTarget: WorktreeErrorTarget | undefined,\n      ): void => {\n        const previous = latest.get(scope.sessionId);\n        latest.set(scope.sessionId, {\n          worktrees: previous?.worktrees ?? viewsFor(scope, views),\n          pending,\n          error,\n          errorTarget,\n        });\n        publish(scope, true);\n      };\n\n      const run = async (\n        scope: DoomHubSessionScope,\n        command: GitWorktreesCommand,\n        generation: symbol,\n      ): Promise<void> => {\n        const context = { cwd: scope.cwd, sessionId: scope.sessionId };\n        const markCurrent = (\n          pending: string | undefined,\n          error: string | undefined,\n          errorTarget: WorktreeErrorTarget | undefined,\n        ): void => {\n          if (generations.get(scope.sessionId) !== generation) return;\n          mark(scope, pending, error, errorTarget);\n        };\n        if (command.action === 'create') {\n          markCurrent(`creating ${command.branch}…`, undefined, undefined);\n          const record = await worktrees.spawn(\n            context,\n            {\n              branch: command.branch,\n              ...(command.baseRef === undefined ? {} : { baseRef: command.baseRef }),\n              ...(command.reservationId === undefined ? {} : { reservationId: command.reservationId }),\n            },\n            // Each phase replaces the label, so the panel says what is\n            // happening instead of holding one line for the whole wait.\n            { onProgress: (label) => markCurrent(label, undefined, undefined) },\n          );\n          if (generations.get(scope.sessionId) !== generation) return;\n          publishLifecycle(scope, record.repositoryRoot);\n          return;\n        }\n        markCurrent(`closing ${command.id}…`, undefined, undefined);\n        const record = await worktrees.close(context, command.id, command.force ?? false);\n        if (generations.get(scope.sessionId) !== generation) return;\n        publishLifecycle(scope, record.repositoryRoot);\n      };\n\n      const source: DoomHubChannelSource = {\n        payloadFor(scope) {\n          const state = latest.get(scope.sessionId);\n          return state === undefined ? undefined : payloadOf(state);\n        },\n        sessionAdded(scope) {\n          newGeneration(scope.sessionId);\n          publish(scope, false);\n          const unsubscribe = host.directEvents.subscribe(GIT_WORKTREE_LIFECYCLE_EVENT, scope.sessionId, (payload) => {\n            if (!isWorktreeLifecycleEvent(payload)) return;\n            let sameRepository = false;\n            try {\n              sameRepository =\n                registryFile(scope.cwd, options.homeDir) === registryFile(payload.repositoryRoot, options.homeDir);\n            } catch {\n              sameRepository = false;\n            }\n            if (sameRepository) publish(scope, false);\n          });\n          subscriptions.set(scope.sessionId, unsubscribe);\n        },\n        sessionRemoved(sessionId) {\n          newGeneration(sessionId);\n          subscriptions.get(sessionId)?.();\n          subscriptions.delete(sessionId);\n          latest.delete(sessionId);\n          busy.delete(sessionId);\n        },\n        close() {\n          unregisterWorktreeProvisioner?.();\n          for (const unsubscribe of subscriptions.values()) unsubscribe();\n          subscriptions.clear();\n          latest.clear();\n          busy.clear();\n          generations.clear();\n        },\n      };\n      receiveCommand = (scope, payload) => {\n        const command = parseCommand(payload);\n        if (command === undefined) return;\n        // One operation per session. A create runs for minutes, and a second\n        // click must not start a second worktree behind the first.\n        if (busy.has(scope.sessionId)) return;\n        const generation = generations.get(scope.sessionId);\n        if (generation === undefined) return;\n        busy.add(scope.sessionId);\n        void run(scope, command, generation)\n          .then(() => {\n            if (generations.get(scope.sessionId) !== generation) return;\n            mark(scope, undefined, undefined, undefined);\n          })\n          .catch((error: unknown) => {\n            if (generations.get(scope.sessionId) !== generation) return;\n            host.onNotice(`worktree command failed for ${scope.sessionId} (${failureText(error)})`);\n            mark(scope, undefined, failureText(error), errorTargetFor(command));\n          })\n          .finally(() => {\n            if (generations.get(scope.sessionId) === generation) busy.delete(scope.sessionId);\n          });\n      };\n\n      return source;\n    },\n    receive(scope, payload) {\n      receiveCommand?.(scope, payload);\n    },\n  };\n}\n\nexport default createWorktreesChannel;\n","import { defineChannel } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/git-worktrees.server';\n\nexport default defineChannel(contribution);\n","import { defineHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../_lib/root.server';\n\nexport default defineHook((context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.hooks[1]!);\n","import { defineHook, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../_lib/root.server';\n\nexport default defineHook((context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.hooks[0]!);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../../_lib/root.server';\n\nexport default (context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.resources[0]!;\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/doompiGit.server';\n\nexport default defineResource(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../../_lib/root.server';\n\nexport default (context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.resources[2]!;\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/doompiGitReadme.server';\n\nexport default defineResource(contribution);\n","import type { WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../../_lib/root.server';\n\nexport default (context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.resources[1]!;\n","import { defineResource } from '@agimon-ai/doompi-core/extensionFile';\n\nimport contribution from './_lib/doompiUseGit.server';\n\nexport default defineResource(contribution);\n","import { defineServerTool, type WithRoot } from '@agimon-ai/doompi-core/extensionFile';\nimport type { DoomServerPluginContext } from '@agimon-ai/doompi-core/serverFacet';\n\nimport type { GitServerScope } from '../_lib/root.server';\n\nexport default defineServerTool((context: WithRoot<DoomServerPluginContext, GitServerScope>) => context.root.tool);\n","// Generated by @agimon-ai/doompi-build. Do not edit by hand.\nimport { defineServerPlugin, type DoomServerSessionPlugin } from '@agimon-ai/doompi-core/serverFacet';\nimport { composeRootHooks } from '@agimon-ai/doompi-core/extensionFile';\n\nimport rootSession from '../src/extensions/workspaces/sessions/(backend)/root.server';\nimport apiRoute from '../src/extensions/(backend)/api/git/route.server';\nimport channelGitChanges from '../src/extensions/(backend)/channel/git-changes.server';\nimport channelGitWorktrees from '../src/extensions/(backend)/channel/git-worktrees.server';\nimport hookAgentSettled from '../src/extensions/workspaces/sessions/(backend)/hook/agent-settled.server';\nimport hookToolExecutionEnd from '../src/extensions/workspaces/sessions/(backend)/hook/tool-execution-end.server';\nimport resourceDoompiGit from '../src/extensions/workspaces/sessions/(backend)/resource/doompiGit.server';\nimport resourceDoompiGitReadme from '../src/extensions/workspaces/sessions/(backend)/resource/doompiGitReadme.server';\nimport resourceDoompiUseGit from '../src/extensions/workspaces/sessions/(backend)/resource/doompiUseGit.server';\nimport toolRunWorktree from '../src/extensions/workspaces/sessions/(backend)/tool/runWorktree.server';\n\ntype Factory<T, C> = (context: C) => T;\nconst at = <T, C>(value: T | Factory<T, C>, context: C): T =>\n  typeof value === 'function' ? (value as Factory<T, C>)(context) : value;\nconst via = <T>(identity: Record<string, unknown>, value: unknown): T =>\n  (value === undefined ? undefined : { ...identity, ...(value as object) }) as T;\n\nexport const facet = defineServerPlugin({\n  name: '@agimon-ai/doompi-git',\n  global: (context) => ({\n    get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n    get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'git_changes' }, channelGitChanges()), () => via({ frameType: 'git_worktrees' }, channelGitWorktrees())]; },\n  }),\n  workspace: (context) => ({\n    get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n    get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'git_changes' }, channelGitChanges()), () => via({ frameType: 'git_worktrees' }, channelGitWorktrees())]; },\n  }),\n  session: async (context) => {\n    const scopeSession = await rootSession(context);\n    const contextSession = { ...context, root: scopeSession.value };\n    return {\n      ...composeRootHooks(scopeSession),\n      get api(): DoomServerSessionPlugin['api'] { return [at(apiRoute, context)]; },\n      get channels(): DoomServerSessionPlugin['channels'] { return [() => via({ frameType: 'git_changes' }, channelGitChanges()), () => via({ frameType: 'git_worktrees' }, channelGitWorktrees())]; },\n      get hooks(): DoomServerSessionPlugin['hooks'] { return [via({ event: 'agent_settled' }, at(hookAgentSettled, contextSession)), via({ event: 'tool_execution_end' }, at(hookToolExecutionEnd, contextSession))]; },\n      get resources(): DoomServerSessionPlugin['resources'] { return [at(resourceDoompiGit, contextSession), at(resourceDoompiGitReadme, contextSession), at(resourceDoompiUseGit, contextSession)]; },\n      get tools(): DoomServerSessionPlugin['tools'] { return [via({ name: 'run_worktree' }, at(toolRunWorktree, contextSession))]; },\n      services: [...(scopeSession.services ?? [])],\n      get activities(): DoomServerSessionPlugin['activities'] { return [...(scopeSession.activities ?? [])]; },\n    };\n  },\n});\n\nexport default facet;\n"],"mappings":";;;;;;;;;AA0BA,SAAS,eAAe,QAAyC,OAAuC;CACtG,OAAO;EAAE,SAAS,CAAC;GAAE,MAAM;GAAQ,MAAM;EAAM,CAAC;EAAG,SAAS,EAAE,OAAO;CAAE;AACzE;AAEA,SAAgB,iBAAiB,EAAE,SAAS,MAAM,cAAuC;CACvF,IAAI,WAAW,QAAQ,iBAAiB,KAAA,GACtC,MAAM,IAAI,MAAM,2DAA2D;CAC7E,IAAI,WAAW,QAAQ,cAAc,KAAA,GAAW,MAAM,IAAI,MAAM,iDAAiD;CACjH,MAAM,YAAY,WAAW,QAAQ;CACrC,MAAM,eAAe,WAAW,QAAQ;CACxC,MAAM,eAAe,2BAA2B,cAAc,SAAS;CACvE,MAAM,aAAa,yBAAyB;EAC1C,KAAK,kBAAkB;EACvB,gBAAgB,WAAW,QAAQ;EACnC;EACA,uBAAuB,wBAAwB,OAAO;CACxD,CAAC;CACD,MAAM,YAAoC,CACxC;EAIE,MAAM;GAAE,OAAO,EAAE,cAAc,OAAO;GAAG,aAAa;IAAE,MAAM;IAAS,MAAM;GAAO;EAAE;EACtF,MAAM;EACN,MAAM;EACN,YAAY,oBAAoB,YAAY,KAAK,UAAU;CAC7D,GACA;EACE,MAAM;EACN,MAAM;EACN,YAAY,oBAAoB,YAAY,KAAK,qCAAqC;CACxF,CACF;CAEA,MAAM,OAAuD;EAC3D,MAAM;EACN,OAAO;EACP,aAAa;EACb,YAAY;EACZ,eAAe;EACf,eAAe;EACf,MAAM,QAAQ,aAAa,YAAY,QAAQ,UAAU,WAAW;GAClE,MAAM,SAAS,eAA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