{"version":3,"sources":["../src/vcs.ts"],"sourcesContent":["// The `vcs:read` / `vcs:reset` source-control surface — app-facing wrappers\n// (UI_AS_APPS_SPEC §5.3 Recipe A read channel + §8.4 Recipe B actions;\n// migrate-sidebars-to-apps Phase 05; roadmap R3-52).\n//\n// A first-party contribute panel (the `panel.contribute` app, Phase 06) reads the\n// live source-control state the native `SourceControlPanel` shows — the working-tree\n// diff summary, the branch lineage, and the open-PR list — and can trigger a\n// refresh/reset. The host derives all of it from authenticated GitHub calls +\n// the COW layers; NONE of the underlying `DiffResult` / `FileSystem` / OAuth token\n// ever crosses the boundary (§8.10) — the wire carries only the plain-JSON\n// {@link VcsState} the host projects.\n//\n// Read side: a Recipe-A push channel, the same get/onChange/use trio as\n// `editorContext` / `diagnostics`. Inert until the host wires the channel\n// (site-main `channelBridge`); an app without `vcs:read` simply sees the empty\n// initial. Action side: `protocol-vcs` requests gated host-side — `refreshDiff` /\n// `refreshPRs` by `vcs:read`, `resetWorkingTree` by first-party-only `vcs:reset`.\nimport { invoke } from './catalog';\nimport { createPushChannel } from './pushChannel';\nimport { throwOnRefusal } from './protocolRefusal';\nimport { protocolRequest } from './sandboxUtils';\nimport { PROTOCOL_VCS, REQUEST_VCS_STATE, VCS_STATE } from './generated/protocol';\nimport { SCHEMES } from './protocolSchemes';\n\n/** One changed path in the working tree (vs. the loaded ref). `status` mirrors the\n *  host `DiffResult` change kinds; `path` is repo-relative. Contents are NOT\n *  carried — the native panel showed path + status, and a per-file content diff is\n *  a deferred follow-up (plan step 6). */\nexport interface VcsChange {\n  path: string;\n  status: 'created' | 'modified' | 'deleted';\n}\n\n/** The branch the working tree sits on and the upstream it diverged from\n *  (host `BranchInfo`, §15.1). `null` until the user is on a immediately.run-created\n *  branch. `upstreamPushable` is `null` while push access is still being probed. */\nexport interface VcsBranch {\n  name: string;\n  parentRepo: string;\n  parentRef: string;\n  parentCommitSha: string;\n  /** Prefer {@link VcsState.canPushUpstream}: the same fact, present even when\n   *  `branch` is `null`. */\n  upstreamPushable: boolean | null;\n}\n\n/** One warning from the host's diff. `kind` is open: today `'large-file'` or\n *  `'truncated-manifest-blind-spot'`, and a newer host may send others, so branch on\n *  the kinds you know and show `message` for the rest. */\nexport interface VcsDiffWarning {\n  kind: string;\n  /** The repo-relative path the warning is about. */\n  path: string;\n  /** Human-readable text, ready to show. */\n  message: string;\n}\n\n/** What the working tree was loaded from (the host manifest), so a form can name and\n *  link the target and apply §15.0 rule 2 on a tag or commit load. */\nexport interface VcsTarget {\n  namespace: string;\n  repository: string;\n  ref: string;\n  refKind: 'branch' | 'tag' | 'commit';\n  /** The loaded commit; `null` when the manifest records none (a REST-built manifest\n   *  can carry no based-on commit), so a form shows no commit link. */\n  commitSha: string | null;\n  /** The repository's live default branch; `null` while the host does not know it. */\n  defaultBranch: string | null;\n}\n\n/** One pull request open from the current branch (host `BranchPR`). */\nexport interface VcsPR {\n  number: number;\n  url: string;\n  title: string;\n  state: 'open' | 'closed' | 'merged';\n  draft: boolean;\n}\n\n/** The gate facts the host projects about an active agent session on the\n *  target repo (CONTRIBUTE_TRANSCRIPT_SPEC §3/§4, R3-632/R3-659): enough for a\n *  contribute app to render the \"Commit session transcript\" checkbox — never\n *  transcript bytes, a title, or message content. Absent (undefined) unless a\n *  qualifying session exists — R-CT-3: no session ⇒ no fact, not a disabled\n *  rendering of one. */\nexport interface VcsAgentSession {\n  repo: string;\n  conversationId: string;\n  messageCount: number;\n  updatedAt?: number | undefined;\n  running: boolean;\n}\n\n/** The whole source-control snapshot the host projects to a `vcs:read` frame.\n *  Plain JSON — never a `DiffResult` / `FileSystem` / `Journal`. */\nexport interface VcsState {\n  changes: VcsChange[];\n  branch: VcsBranch | null;\n  prs: VcsPR[];\n  /** True while the host is recomputing the diff — the panel shows a spinner\n   *  without a separate request (plan gotcha). */\n  diffLoading: boolean;\n  /** See {@link VcsAgentSession}. Present only while a qualifying agent\n   *  session exists on the target repo. The explicit `| undefined` mirrors\n   *  the wire contract exactly (the wire-shape extractor reads union members\n   *  literally). */\n  agentSession?: VcsAgentSession | null | undefined;\n  /** What the working tree was loaded from; `null` when there is no manifest. */\n  target?: VcsTarget | null | undefined;\n  /** The open pull request whose head is the loaded branch, projected host-side. On the\n   *  snapshot, not on `branch`, because `branch` is `null` when no sidecar names the\n   *  branch (another device), which is exactly when this is needed. `null` means known:\n   *  none open; absent means an older host that does not say. `prs` lists every PR the\n   *  host polled; this names the one whose head is the working branch. */\n  openPR?: { number: number; url: string } | null | undefined;\n  /** The save mode a contribute form opens on (CONTRIBUTE_SPEC §15.0 rule 4). The host\n   *  says `direct` only on a branch that is the user's; absent means `pr`. A default,\n   *  never a permission: `direct` still needs `contribute:direct`. */\n  defaultSaveMode?: 'pr' | 'direct' | undefined;\n  /** Whether the user can push to the target repository; `null` while probing. The same\n   *  fact as `branch.upstreamPushable`, but present when `branch` is `null`; prefer this\n   *  one when both are set. */\n  canPushUpstream?: boolean | null | undefined;\n  /** True when the load has no manifest, so contributions are unavailable. The\n   *  authoritative \"no manifest\" signal: `target` is `null` exactly when this is true. */\n  manifestMissing?: boolean | undefined;\n  /** The last diff refresh's failure; `null` after a good refresh. */\n  diffError?: string | null | undefined;\n  /** The diff's warnings. */\n  diffWarnings?: VcsDiffWarning[] | undefined;\n  /** Repo-relative paths walked but left out of the changeset: today only the\n   *  `.immediately.run/` platform sidecar files, never the user's own work. */\n  excludedPhantoms?: string[] | undefined;\n  /** The manifest is truncated: saving is locked out (CONTRIBUTE_SPEC §7). */\n  manifestTruncated?: boolean | undefined;\n}\n\n/** Value before the host answers — also the value when the app may not read the\n *  channel (no `vcs:read`): an empty, branch-less snapshot. */\nconst EMPTY: VcsState = { changes: [], branch: null, prs: [], diffLoading: false };\n\nconst isChangeArray = (v: unknown): v is VcsChange[] =>\n  Array.isArray(v) &&\n  v.every((c) => !!c && typeof (c as VcsChange).path === 'string' && typeof (c as VcsChange).status === 'string');\n\n// The agentSession fact is fail-closed for the transcript feature (R-CT-1): a\n// malformed one reads as NO session — dropped, never thrown into the vcs\n// channel, so a fault can never conjure a checkbox (and the rest of the\n// snapshot still lands).\nconst parseAgentSession = (v: unknown): VcsAgentSession | undefined => {\n  if (v === undefined || v === null) return undefined;\n  if (typeof v !== 'object') return undefined;\n  const s = v as Record<string, unknown>;\n  // Number.isFinite, not typeof: structured clone (the postMessage transport)\n  // carries NaN/Infinity intact, and a non-finite count must not conjure the\n  // fact — the producer's parser (site-main agentSessionState.ts) rejects the\n  // same way.\n  if (\n    typeof s.repo !== 'string' ||\n    typeof s.conversationId !== 'string' ||\n    typeof s.messageCount !== 'number' ||\n    !Number.isFinite(s.messageCount) ||\n    typeof s.running !== 'boolean' ||\n    (s.updatedAt !== undefined && (typeof s.updatedAt !== 'number' || !Number.isFinite(s.updatedAt)))\n  ) {\n    return undefined;\n  }\n  return {\n    repo: s.repo,\n    conversationId: s.conversationId,\n    messageCount: s.messageCount,\n    running: s.running,\n    ...(s.updatedAt !== undefined ? { updatedAt: s.updatedAt } : {}),\n  };\n};\n\n// The R3-964/986/987 facts are optional and fail to ABSENT, field by field: a\n// malformed value is dropped so the app falls back to its old-host behaviour, and the\n// rest of the snapshot still lands. Nothing is coerced into a value the host did not send.\nconst isStringArray = (v: unknown): v is string[] => Array.isArray(v) && v.every((x) => typeof x === 'string');\n\nconst isDiffWarningArray = (v: unknown): v is VcsDiffWarning[] =>\n  Array.isArray(v) &&\n  v.every(\n    (w) =>\n      !!w &&\n      typeof w === 'object' &&\n      typeof (w as VcsDiffWarning).kind === 'string' &&\n      typeof (w as VcsDiffWarning).path === 'string' &&\n      typeof (w as VcsDiffWarning).message === 'string',\n  );\n/** The refKind values the parser keeps (exported so the suite derives its cases from the\n *  producer rather than probing one favourite member — every member must pass through,\n *  because a miss silently drops the whole target fact). */\nexport const REF_KINDS = new Set(['branch', 'tag', 'commit']);\n\nconst parseTarget = (v: unknown): VcsTarget | null | undefined => {\n  if (v === null) return null;\n  if (!v || typeof v !== 'object') return undefined;\n  const t = v as Record<string, unknown>;\n  if (\n    typeof t.namespace !== 'string' ||\n    typeof t.repository !== 'string' ||\n    typeof t.ref !== 'string' ||\n    typeof t.refKind !== 'string' ||\n    !REF_KINDS.has(t.refKind) ||\n    !(t.commitSha === null || (typeof t.commitSha === 'string' && t.commitSha !== '')) ||\n    !(t.defaultBranch === null || typeof t.defaultBranch === 'string')\n  ) {\n    return undefined;\n  }\n  return {\n    namespace: t.namespace,\n    repository: t.repository,\n    ref: t.ref,\n    refKind: t.refKind as VcsTarget['refKind'],\n    commitSha: t.commitSha,\n    defaultBranch: t.defaultBranch,\n  };\n};\n\n/** The optional R3-964/986/987 facts of a push, each present only when well-typed. */\nconst parseVcsFacts = (msg: Record<string, unknown>): Partial<VcsState> => {\n  const out: Partial<VcsState> = {};\n  const target = parseTarget(msg.target);\n  if (target !== undefined) out.target = target;\n  const openPR = msg.openPR as { number?: unknown; url?: unknown } | null | undefined;\n  if (openPR === null) out.openPR = null;\n  else if (\n    openPR &&\n    typeof openPR === 'object' &&\n    typeof openPR.number === 'number' &&\n    Number.isFinite(openPR.number) &&\n    typeof openPR.url === 'string'\n  ) {\n    out.openPR = { number: openPR.number, url: openPR.url };\n  }\n  if (msg.defaultSaveMode === 'pr' || msg.defaultSaveMode === 'direct') out.defaultSaveMode = msg.defaultSaveMode;\n  if (msg.canPushUpstream === null || typeof msg.canPushUpstream === 'boolean')\n    out.canPushUpstream = msg.canPushUpstream;\n  if (typeof msg.manifestMissing === 'boolean') out.manifestMissing = msg.manifestMissing;\n  if (msg.diffError === null || typeof msg.diffError === 'string') out.diffError = msg.diffError;\n  if (isDiffWarningArray(msg.diffWarnings))\n    out.diffWarnings = msg.diffWarnings.map(({ kind, path, message }) => ({ kind, path, message }));\n  if (isStringArray(msg.excludedPhantoms)) out.excludedPhantoms = msg.excludedPhantoms;\n  if (typeof msg.manifestTruncated === 'boolean') out.manifestTruncated = msg.manifestTruncated;\n  return out;\n};\n\nconst channel = createPushChannel<VcsState>({\n  pushType: VCS_STATE,\n  requestType: REQUEST_VCS_STATE,\n  initial: EMPTY,\n  parse: (msg) => {\n    // Require a well-formed `changes` array; tolerate an absent branch/prs. A\n    // malformed push is ignored (returns undefined) so the last good state stands.\n    if (!isChangeArray(msg.changes)) return undefined;\n    const branch = msg.branch && typeof msg.branch === 'object' ? (msg.branch as VcsBranch) : null;\n    const prs = Array.isArray(msg.prs) ? (msg.prs as VcsPR[]) : [];\n    const agentSession = parseAgentSession(msg.agentSession);\n    return {\n      changes: msg.changes,\n      branch,\n      prs,\n      diffLoading: msg.diffLoading === true,\n      ...(agentSession ? { agentSession } : {}),\n      // Each key is named here, not inside the helper, so the protocol snapshot's\n      // `reads` records every field this parser consumes.\n      ...parseVcsFacts({\n        target: msg.target,\n        openPR: msg.openPR,\n        defaultSaveMode: msg.defaultSaveMode,\n        canPushUpstream: msg.canPushUpstream,\n        manifestMissing: msg.manifestMissing,\n        diffError: msg.diffError,\n        diffWarnings: msg.diffWarnings,\n        excludedPhantoms: msg.excludedPhantoms,\n        manifestTruncated: msg.manifestTruncated,\n      }),\n    };\n  },\n});\n\n/** One-off read of the current source-control state. Returns the empty snapshot\n *  until the host answers (or if the app lacks `vcs:read`). Use\n *  {@link onVcsStateChange} / {@link useVcsState} to react to live updates. */\nexport const getVcsState = (): VcsState => channel.get();\n\n/** Subscribe to source-control changes. Invoked immediately with the current\n *  value, then on every host push (diff refresh, PR poll, branch change). Returns\n *  an unsubscribe. */\nexport const onVcsStateChange = (listener: (state: VcsState) => void): (() => void) => channel.onChange(listener);\n\n/** React hook: the current source-control state, re-rendering on every change. */\nexport const useVcsState = (): VcsState => channel.use();\n\n// ---------------------------------------------------------------------------\n// Actions (Recipe B, §8.4). The app NAMES an intent and the HOST performs it —\n// the COW/journal stays in the kernel (§2/§4). `refreshDiff`/`refreshPRs` only\n// cause a host-side recompute + a fresh push (gated `vcs:read`, no new authority);\n// `resetWorkingTree` DISCARDS the user's unsaved work, gated by the first-party-only\n// `vcs:reset` — a fork can never hold it. The arm-then-confirm UX stays in the app;\n// the authority is gated host-side (§8.9), and the host requires `confirm:true` as\n// belt-and-braces (T22).\n// ---------------------------------------------------------------------------\n\n/** An error from a `vcs` action, carrying a machine-readable `.code`.\n *\n *  **What you actually catch.** The SDK throws a plain `Error` with `.code` assigned — a\n *  `CodedRefusalError` from `protocolRefusal.ts` — never a distinct class. This interface\n *  documents the `.code` VALUES the host sends. Nothing enforces the union at runtime —\n *  `.code` is whatever string arrived — so treat an unlisted code as possible and\n *  `instanceof Error` as the only reliable test.\n */\nexport interface VcsActionError extends Error {\n  code:\n    | 'forbidden' // the frame lacks the required capability (`vcs:read` / `vcs:reset`)\n    | 'invalid-params' // reset called without `confirm: true`\n    | 'no-target' // there is no host contribute session (not in edit mode)\n    | 'unknown';\n}\n\ntype VcsResult = { ok: true; data: unknown } | { ok: false; code: string; message: string };\n\nconst vcsRequest = async (method: string, arg: Record<string, unknown> = {}): Promise<void> => {\n  const res = (await protocolRequest(SCHEMES[PROTOCOL_VCS], method, [arg])) as VcsResult;\n  throwOnRefusal(res, `vcs ${method} failed`);\n};\n\n/** Ask the host to recompute the working-tree diff and push a fresh {@link VcsState}.\n *  Gated `vcs:read`. Rejects with a {@link VcsActionError} (`.code`). */\nexport const refreshDiff = (): Promise<void> => vcsRequest('refreshDiff');\n\n/** Ask the host to re-poll the open PRs and push a fresh {@link VcsState}. Gated\n *  `vcs:read`. Rejects with a {@link VcsActionError} (`.code`). */\nexport const refreshPRs = (): Promise<void> => vcsRequest('refreshPRs');\n\n/** Ask the host to DISCARD the working tree (COW writable wipe + journal clear) —\n *  irreversible. First-party-only (`vcs:reset`); a fork/preview is refused at the\n *  gate. Requires `confirm: true` (host belt-and-braces). Rejects with a\n *  {@link VcsActionError} (`.code`). */\nexport const resetWorkingTree = (): Promise<void> => vcsRequest('reset', { confirm: true });\n\n// ---------------------------------------------------------------------------------------\n// R3-954 — bundle history (COLLABORATION_SESSIONS §16). Read-only history of a\n// GitHub-backed bundle mount THIS app holds (the URL-dispatched corpus, or the editor's\n// working tree): the head of its ref, the first-parent log, ancestry, files at a past\n// commit, changed paths, and the user's write permission. Gated `vcs:read`; the host\n// refuses a mount the app does not hold `forbidden`. Paths are bundle-relative (relative\n// to the mount's content directory). Each call is a literal `invoke('vcs:…')` so the\n// wire-shape gate (`protocol:check`) records its fields against the published protocol.\n\n/** One first-parent commit of a bundle's history. */\nexport interface BundleCommit {\n  sha: string;\n  /** The first parent, or null for a root commit. */\n  parent: string | null;\n  message: string;\n}\n\n/**\n * A refused bundle-history call. `code` is one of: `forbidden` (the app lacks `vcs:read`,\n * or does not hold the mount), `unsupported` (the mount has no repository history — a\n * space, a local tree — or the tree is too large to compare), `invalid-params` (a\n * malformed sha or path, more than 100 paths or 5 MiB in one read, or a log longer than\n * `max` — the message then starts `history-too-long`), `not-found` (no such commit),\n * `budget` (the provider's rate limit is exhausted; `retryAfter` carries its wait in\n * seconds when it sent one), `unknown`. Nothing enforces the union at runtime — treat an\n * unlisted code as possible.\n */\nexport interface BundleHistoryError extends Error {\n  code: 'forbidden' | 'unsupported' | 'invalid-params' | 'not-found' | 'budget' | 'unknown';\n  retryAfter?: number;\n}\n\nconst fromBase64 = (s: string): Uint8Array => {\n  const bin = atob(s);\n  const out = new Uint8Array(bin.length);\n  for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);\n  return out;\n};\n\n/** The commit the bundle's ref points at now. Cheap to poll: the host asks GitHub\n *  conditionally, so an unchanged head costs no rate limit. */\nexport const bundleHead = async (mountId: string): Promise<string> => {\n  const params: { mountId: string } = { mountId };\n  return (await invoke<{ sha: string }>('vcs:bundleHead', params)).sha;\n};\n\n/** First-parent commits, oldest first, from `until` (default: the head) back to — not\n *  including — `since` (default: the root). A merge's second-parent commits never\n *  appear. Refused (`invalid-params`, `history-too-long`) beyond `max` (default 200,\n *  at most 1000) — never silently truncated. */\nexport const bundleLog = async (\n  mountId: string,\n  opts: { since?: string; until?: string; max?: number } = {},\n): Promise<BundleCommit[]> => {\n  const params: { mountId: string; since?: string; until?: string; max?: number } = { mountId };\n  if (opts.since !== undefined) params.since = opts.since;\n  if (opts.until !== undefined) params.until = opts.until;\n  if (opts.max !== undefined) params.max = opts.max;\n  return (await invoke<{ commits: BundleCommit[] }>('vcs:bundleLog', params)).commits;\n};\n\n/** Whether commit `a` is an ancestor of commit `b` (reflexive: a commit is its own). */\nexport const bundleIsAncestor = async (mountId: string, a: string, b: string): Promise<boolean> => {\n  const params: { mountId: string; a: string; b: string } = { mountId, a, b };\n  return (await invoke<{ ancestor: boolean }>('vcs:bundleIsAncestor', params)).ancestor;\n};\n\n/** Files at commit `sha`, by bundle-relative path; `null` where there is no file. At\n *  most 100 paths and 5 MiB per call. */\nexport const bundleRead = async (\n  mountId: string,\n  sha: string,\n  paths: string[],\n): Promise<Record<string, Uint8Array | null>> => {\n  const params: { mountId: string; sha: string; paths: string[] } = { mountId, sha, paths };\n  const { files } = await invoke<{ files: Record<string, string | null> }>('vcs:bundleRead', params);\n  const out: Record<string, Uint8Array | null> = {};\n  for (const [path, b64] of Object.entries(files)) out[path] = b64 === null ? null : fromBase64(b64);\n  return out;\n};\n\n/** The bundle-relative paths that differ between two commits (added, removed or changed). */\nexport const bundleDiffPaths = async (mountId: string, from: string, to: string): Promise<string[]> => {\n  const params: { mountId: string; from: string; to: string } = { mountId, from, to };\n  return (await invoke<{ paths: string[] }>('vcs:bundleDiffPaths', params)).paths;\n};\n\n/** Whether the signed-in user may push to the bundle's repository (false signed out).\n *  Use it to hide a publish affordance the user could not complete. */\nexport const bundleCanWrite = async (mountId: string): Promise<boolean> => {\n  const params: { mountId: string } = { mountId };\n  return (await invoke<{ canWrite: boolean }>('vcs:bundleCanWrite', params)).canWrite;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,qBAAuB;AACvB,yBAAkC;AAClC,6B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