@immediately-run/sdk 0.84.1 → 0.87.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalog.cjs +2 -0
- package/dist/catalog.cjs.map +1 -1
- package/dist/catalog.js +2 -0
- package/dist/catalog.js.map +1 -1
- package/dist/contribute.cjs.map +1 -1
- package/dist/contribute.d.cts +39 -1
- package/dist/contribute.d.ts +39 -1
- package/dist/contribute.js.map +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/openBundle.cjs +44 -0
- package/dist/openBundle.cjs.map +1 -0
- package/dist/openBundle.d.cts +53 -0
- package/dist/openBundle.d.ts +53 -0
- package/dist/openBundle.js +20 -0
- package/dist/openBundle.js.map +1 -0
- package/dist/openRepository.cjs +4 -4
- package/dist/openRepository.cjs.map +1 -1
- package/dist/openRepository.d.cts +12 -2
- package/dist/openRepository.d.ts +12 -2
- package/dist/openRepository.js +4 -4
- package/dist/openRepository.js.map +1 -1
- package/dist/protocolRefusal.cjs.map +1 -1
- package/dist/protocolRefusal.d.cts +15 -21
- package/dist/protocolRefusal.d.ts +15 -21
- package/dist/protocolRefusal.js.map +1 -1
- package/dist/protocolSchemes.cjs +1 -0
- package/dist/protocolSchemes.cjs.map +1 -1
- package/dist/protocolSchemes.d.cts +1 -0
- package/dist/protocolSchemes.d.ts +1 -0
- package/dist/protocolSchemes.js +2 -0
- package/dist/protocolSchemes.js.map +1 -1
- package/dist/recents.cjs +2 -5
- package/dist/recents.cjs.map +1 -1
- package/dist/recents.js +2 -5
- package/dist/recents.js.map +1 -1
- package/dist/routing.cjs +2 -1
- package/dist/routing.cjs.map +1 -1
- package/dist/routing.d.cts +1 -0
- package/dist/routing.d.ts +1 -0
- package/dist/routing.js +2 -1
- package/dist/routing.js.map +1 -1
- package/dist/tasks.cjs +2 -5
- package/dist/tasks.cjs.map +1 -1
- package/dist/tasks.js +2 -5
- package/dist/tasks.js.map +1 -1
- package/dist/vcs.cjs +106 -1
- package/dist/vcs.cjs.map +1 -1
- package/dist/vcs.d.cts +104 -1
- package/dist/vcs.d.ts +104 -1
- package/dist/vcs.js +99 -1
- package/dist/vcs.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +2 -2
package/dist/vcs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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 { 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 upstreamPushable: boolean | 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}\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\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 };\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"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,yBAAkC;AAClC,6BAA+B;AAC/B,0BAAgC;AAChC,sBAA2D;AAC3D,6BAAwB;AA+DxB,MAAM,QAAkB,EAAE,SAAS,CAAC,GAAG,QAAQ,MAAM,KAAK,CAAC,GAAG,aAAa,MAAM;AAEjF,MAAM,gBAAgB,CAAC,MACrB,MAAM,QAAQ,CAAC,KACf,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,OAAQ,EAAgB,SAAS,YAAY,OAAQ,EAAgB,WAAW,QAAQ;AAMhH,MAAM,oBAAoB,CAAC,MAA4C;AACrE,MAAI,MAAM,UAAa,MAAM,KAAM,QAAO;AAC1C,MAAI,OAAO,MAAM,SAAU,QAAO;AAClC,QAAM,IAAI;AAKV,MACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,mBAAmB,YAC5B,OAAO,EAAE,iBAAiB,YAC1B,CAAC,OAAO,SAAS,EAAE,YAAY,KAC/B,OAAO,EAAE,YAAY,aACpB,EAAE,cAAc,WAAc,OAAO,EAAE,cAAc,YAAY,CAAC,OAAO,SAAS,EAAE,SAAS,IAC9F;AACA,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,MAAM,EAAE;AAAA,IACR,gBAAgB,EAAE;AAAA,IAClB,cAAc,EAAE;AAAA,IAChB,SAAS,EAAE;AAAA,IACX,GAAI,EAAE,cAAc,SAAY,EAAE,WAAW,EAAE,UAAU,IAAI,CAAC;AAAA,EAChE;AACF;AAEA,MAAM,cAAU,sCAA4B;AAAA,EAC1C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ;AAGd,QAAI,CAAC,cAAc,IAAI,OAAO,EAAG,QAAO;AACxC,UAAM,SAAS,IAAI,UAAU,OAAO,IAAI,WAAW,WAAY,IAAI,SAAuB;AAC1F,UAAM,MAAM,MAAM,QAAQ,IAAI,GAAG,IAAK,IAAI,MAAkB,CAAC;AAC7D,UAAM,eAAe,kBAAkB,IAAI,YAAY;AACvD,WAAO;AAAA,MACL,SAAS,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,aAAa,IAAI,gBAAgB;AAAA,MACjC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF,CAAC;AAKM,MAAM,cAAc,MAAgB,QAAQ,IAAI;AAKhD,MAAM,mBAAmB,CAAC,aAAsD,QAAQ,SAAS,QAAQ;AAGzG,MAAM,cAAc,MAAgB,QAAQ,IAAI;AA8BvD,MAAM,aAAa,OAAO,QAAgB,MAA+B,CAAC,MAAqB;AAC7F,QAAM,MAAO,UAAM,qCAAgB,+BAAQ,4BAAY,GAAG,QAAQ,CAAC,GAAG,CAAC;AACvE,6CAAe,KAAK,OAAO,MAAM,SAAS;AAC5C;AAIO,MAAM,cAAc,MAAqB,WAAW,aAAa;AAIjE,MAAM,aAAa,MAAqB,WAAW,YAAY;AAM/D,MAAM,mBAAmB,MAAqB,WAAW,SAAS,EAAE,SAAS,KAAK,CAAC;","names":[]}
|
|
1
|
+
{"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,6BAA+B;AAC/B,0BAAgC;AAChC,sBAA2D;AAC3D,6BAAwB;AAsHxB,MAAM,QAAkB,EAAE,SAAS,CAAC,GAAG,QAAQ,MAAM,KAAK,CAAC,GAAG,aAAa,MAAM;AAEjF,MAAM,gBAAgB,CAAC,MACrB,MAAM,QAAQ,CAAC,KACf,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,OAAQ,EAAgB,SAAS,YAAY,OAAQ,EAAgB,WAAW,QAAQ;AAMhH,MAAM,oBAAoB,CAAC,MAA4C;AACrE,MAAI,MAAM,UAAa,MAAM,KAAM,QAAO;AAC1C,MAAI,OAAO,MAAM,SAAU,QAAO;AAClC,QAAM,IAAI;AAKV,MACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,mBAAmB,YA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
|
parentRepo: string;
|
|
15
15
|
parentRef: string;
|
|
16
16
|
parentCommitSha: string;
|
|
17
|
+
/** Prefer {@link VcsState.canPushUpstream}: the same fact, present even when
|
|
18
|
+
* `branch` is `null`. */
|
|
17
19
|
upstreamPushable: boolean | null;
|
|
18
20
|
}
|
|
21
|
+
/** One warning from the host's diff. `kind` is open: today `'large-file'` or
|
|
22
|
+
* `'truncated-manifest-blind-spot'`, and a newer host may send others, so branch on
|
|
23
|
+
* the kinds you know and show `message` for the rest. */
|
|
24
|
+
interface VcsDiffWarning {
|
|
25
|
+
kind: string;
|
|
26
|
+
/** The repo-relative path the warning is about. */
|
|
27
|
+
path: string;
|
|
28
|
+
/** Human-readable text, ready to show. */
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
/** What the working tree was loaded from (the host manifest), so a form can name and
|
|
32
|
+
* link the target and apply §15.0 rule 2 on a tag or commit load. */
|
|
33
|
+
interface VcsTarget {
|
|
34
|
+
namespace: string;
|
|
35
|
+
repository: string;
|
|
36
|
+
ref: string;
|
|
37
|
+
refKind: 'branch' | 'tag' | 'commit';
|
|
38
|
+
/** The loaded commit; `null` when the manifest records none (a REST-built manifest
|
|
39
|
+
* can carry no based-on commit), so a form shows no commit link. */
|
|
40
|
+
commitSha: string | null;
|
|
41
|
+
/** The repository's live default branch; `null` while the host does not know it. */
|
|
42
|
+
defaultBranch: string | null;
|
|
43
|
+
}
|
|
19
44
|
/** One pull request open from the current branch (host `BranchPR`). */
|
|
20
45
|
interface VcsPR {
|
|
21
46
|
number: number;
|
|
@@ -51,7 +76,42 @@ interface VcsState {
|
|
|
51
76
|
* the wire contract exactly (the wire-shape extractor reads union members
|
|
52
77
|
* literally). */
|
|
53
78
|
agentSession?: VcsAgentSession | null | undefined;
|
|
79
|
+
/** What the working tree was loaded from; `null` when there is no manifest. */
|
|
80
|
+
target?: VcsTarget | null | undefined;
|
|
81
|
+
/** The open pull request whose head is the loaded branch, projected host-side. On the
|
|
82
|
+
* snapshot, not on `branch`, because `branch` is `null` when no sidecar names the
|
|
83
|
+
* branch (another device), which is exactly when this is needed. `null` means known:
|
|
84
|
+
* none open; absent means an older host that does not say. `prs` lists every PR the
|
|
85
|
+
* host polled; this names the one whose head is the working branch. */
|
|
86
|
+
openPR?: {
|
|
87
|
+
number: number;
|
|
88
|
+
url: string;
|
|
89
|
+
} | null | undefined;
|
|
90
|
+
/** The save mode a contribute form opens on (CONTRIBUTE_SPEC §15.0 rule 4). The host
|
|
91
|
+
* says `direct` only on a branch that is the user's; absent means `pr`. A default,
|
|
92
|
+
* never a permission: `direct` still needs `contribute:direct`. */
|
|
93
|
+
defaultSaveMode?: 'pr' | 'direct' | undefined;
|
|
94
|
+
/** Whether the user can push to the target repository; `null` while probing. The same
|
|
95
|
+
* fact as `branch.upstreamPushable`, but present when `branch` is `null`; prefer this
|
|
96
|
+
* one when both are set. */
|
|
97
|
+
canPushUpstream?: boolean | null | undefined;
|
|
98
|
+
/** True when the load has no manifest, so contributions are unavailable. The
|
|
99
|
+
* authoritative "no manifest" signal: `target` is `null` exactly when this is true. */
|
|
100
|
+
manifestMissing?: boolean | undefined;
|
|
101
|
+
/** The last diff refresh's failure; `null` after a good refresh. */
|
|
102
|
+
diffError?: string | null | undefined;
|
|
103
|
+
/** The diff's warnings. */
|
|
104
|
+
diffWarnings?: VcsDiffWarning[] | undefined;
|
|
105
|
+
/** Repo-relative paths walked but left out of the changeset: today only the
|
|
106
|
+
* `.immediately.run/` platform sidecar files, never the user's own work. */
|
|
107
|
+
excludedPhantoms?: string[] | undefined;
|
|
108
|
+
/** The manifest is truncated: saving is locked out (CONTRIBUTE_SPEC §7). */
|
|
109
|
+
manifestTruncated?: boolean | undefined;
|
|
54
110
|
}
|
|
111
|
+
/** The refKind values the parser keeps (exported so the suite derives its cases from the
|
|
112
|
+
* producer rather than probing one favourite member — every member must pass through,
|
|
113
|
+
* because a miss silently drops the whole target fact). */
|
|
114
|
+
declare const REF_KINDS: Set<string>;
|
|
55
115
|
/** One-off read of the current source-control state. Returns the empty snapshot
|
|
56
116
|
* until the host answers (or if the app lacks `vcs:read`). Use
|
|
57
117
|
* {@link onVcsStateChange} / {@link useVcsState} to react to live updates. */
|
|
@@ -84,5 +144,48 @@ declare const refreshPRs: () => Promise<void>;
|
|
|
84
144
|
* gate. Requires `confirm: true` (host belt-and-braces). Rejects with a
|
|
85
145
|
* {@link VcsActionError} (`.code`). */
|
|
86
146
|
declare const resetWorkingTree: () => Promise<void>;
|
|
147
|
+
/** One first-parent commit of a bundle's history. */
|
|
148
|
+
interface BundleCommit {
|
|
149
|
+
sha: string;
|
|
150
|
+
/** The first parent, or null for a root commit. */
|
|
151
|
+
parent: string | null;
|
|
152
|
+
message: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A refused bundle-history call. `code` is one of: `forbidden` (the app lacks `vcs:read`,
|
|
156
|
+
* or does not hold the mount), `unsupported` (the mount has no repository history — a
|
|
157
|
+
* space, a local tree — or the tree is too large to compare), `invalid-params` (a
|
|
158
|
+
* malformed sha or path, more than 100 paths or 5 MiB in one read, or a log longer than
|
|
159
|
+
* `max` — the message then starts `history-too-long`), `not-found` (no such commit),
|
|
160
|
+
* `budget` (the provider's rate limit is exhausted; `retryAfter` carries its wait in
|
|
161
|
+
* seconds when it sent one), `unknown`. Nothing enforces the union at runtime — treat an
|
|
162
|
+
* unlisted code as possible.
|
|
163
|
+
*/
|
|
164
|
+
interface BundleHistoryError extends Error {
|
|
165
|
+
code: 'forbidden' | 'unsupported' | 'invalid-params' | 'not-found' | 'budget' | 'unknown';
|
|
166
|
+
retryAfter?: number;
|
|
167
|
+
}
|
|
168
|
+
/** The commit the bundle's ref points at now. Cheap to poll: the host asks GitHub
|
|
169
|
+
* conditionally, so an unchanged head costs no rate limit. */
|
|
170
|
+
declare const bundleHead: (mountId: string) => Promise<string>;
|
|
171
|
+
/** First-parent commits, oldest first, from `until` (default: the head) back to — not
|
|
172
|
+
* including — `since` (default: the root). A merge's second-parent commits never
|
|
173
|
+
* appear. Refused (`invalid-params`, `history-too-long`) beyond `max` (default 200,
|
|
174
|
+
* at most 1000) — never silently truncated. */
|
|
175
|
+
declare const bundleLog: (mountId: string, opts?: {
|
|
176
|
+
since?: string;
|
|
177
|
+
until?: string;
|
|
178
|
+
max?: number;
|
|
179
|
+
}) => Promise<BundleCommit[]>;
|
|
180
|
+
/** Whether commit `a` is an ancestor of commit `b` (reflexive: a commit is its own). */
|
|
181
|
+
declare const bundleIsAncestor: (mountId: string, a: string, b: string) => Promise<boolean>;
|
|
182
|
+
/** Files at commit `sha`, by bundle-relative path; `null` where there is no file. At
|
|
183
|
+
* most 100 paths and 5 MiB per call. */
|
|
184
|
+
declare const bundleRead: (mountId: string, sha: string, paths: string[]) => Promise<Record<string, Uint8Array | null>>;
|
|
185
|
+
/** The bundle-relative paths that differ between two commits (added, removed or changed). */
|
|
186
|
+
declare const bundleDiffPaths: (mountId: string, from: string, to: string) => Promise<string[]>;
|
|
187
|
+
/** Whether the signed-in user may push to the bundle's repository (false signed out).
|
|
188
|
+
* Use it to hide a publish affordance the user could not complete. */
|
|
189
|
+
declare const bundleCanWrite: (mountId: string) => Promise<boolean>;
|
|
87
190
|
|
|
88
|
-
export { type VcsActionError, type VcsAgentSession, type VcsBranch, type VcsChange, type VcsPR, type VcsState, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState };
|
|
191
|
+
export { type BundleCommit, type BundleHistoryError, REF_KINDS, type VcsActionError, type VcsAgentSession, type VcsBranch, type VcsChange, type VcsDiffWarning, type VcsPR, type VcsState, type VcsTarget, bundleCanWrite, bundleDiffPaths, bundleHead, bundleIsAncestor, bundleLog, bundleRead, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState };
|
package/dist/vcs.d.ts
CHANGED
|
@@ -14,8 +14,33 @@ interface VcsBranch {
|
|
|
14
14
|
parentRepo: string;
|
|
15
15
|
parentRef: string;
|
|
16
16
|
parentCommitSha: string;
|
|
17
|
+
/** Prefer {@link VcsState.canPushUpstream}: the same fact, present even when
|
|
18
|
+
* `branch` is `null`. */
|
|
17
19
|
upstreamPushable: boolean | null;
|
|
18
20
|
}
|
|
21
|
+
/** One warning from the host's diff. `kind` is open: today `'large-file'` or
|
|
22
|
+
* `'truncated-manifest-blind-spot'`, and a newer host may send others, so branch on
|
|
23
|
+
* the kinds you know and show `message` for the rest. */
|
|
24
|
+
interface VcsDiffWarning {
|
|
25
|
+
kind: string;
|
|
26
|
+
/** The repo-relative path the warning is about. */
|
|
27
|
+
path: string;
|
|
28
|
+
/** Human-readable text, ready to show. */
|
|
29
|
+
message: string;
|
|
30
|
+
}
|
|
31
|
+
/** What the working tree was loaded from (the host manifest), so a form can name and
|
|
32
|
+
* link the target and apply §15.0 rule 2 on a tag or commit load. */
|
|
33
|
+
interface VcsTarget {
|
|
34
|
+
namespace: string;
|
|
35
|
+
repository: string;
|
|
36
|
+
ref: string;
|
|
37
|
+
refKind: 'branch' | 'tag' | 'commit';
|
|
38
|
+
/** The loaded commit; `null` when the manifest records none (a REST-built manifest
|
|
39
|
+
* can carry no based-on commit), so a form shows no commit link. */
|
|
40
|
+
commitSha: string | null;
|
|
41
|
+
/** The repository's live default branch; `null` while the host does not know it. */
|
|
42
|
+
defaultBranch: string | null;
|
|
43
|
+
}
|
|
19
44
|
/** One pull request open from the current branch (host `BranchPR`). */
|
|
20
45
|
interface VcsPR {
|
|
21
46
|
number: number;
|
|
@@ -51,7 +76,42 @@ interface VcsState {
|
|
|
51
76
|
* the wire contract exactly (the wire-shape extractor reads union members
|
|
52
77
|
* literally). */
|
|
53
78
|
agentSession?: VcsAgentSession | null | undefined;
|
|
79
|
+
/** What the working tree was loaded from; `null` when there is no manifest. */
|
|
80
|
+
target?: VcsTarget | null | undefined;
|
|
81
|
+
/** The open pull request whose head is the loaded branch, projected host-side. On the
|
|
82
|
+
* snapshot, not on `branch`, because `branch` is `null` when no sidecar names the
|
|
83
|
+
* branch (another device), which is exactly when this is needed. `null` means known:
|
|
84
|
+
* none open; absent means an older host that does not say. `prs` lists every PR the
|
|
85
|
+
* host polled; this names the one whose head is the working branch. */
|
|
86
|
+
openPR?: {
|
|
87
|
+
number: number;
|
|
88
|
+
url: string;
|
|
89
|
+
} | null | undefined;
|
|
90
|
+
/** The save mode a contribute form opens on (CONTRIBUTE_SPEC §15.0 rule 4). The host
|
|
91
|
+
* says `direct` only on a branch that is the user's; absent means `pr`. A default,
|
|
92
|
+
* never a permission: `direct` still needs `contribute:direct`. */
|
|
93
|
+
defaultSaveMode?: 'pr' | 'direct' | undefined;
|
|
94
|
+
/** Whether the user can push to the target repository; `null` while probing. The same
|
|
95
|
+
* fact as `branch.upstreamPushable`, but present when `branch` is `null`; prefer this
|
|
96
|
+
* one when both are set. */
|
|
97
|
+
canPushUpstream?: boolean | null | undefined;
|
|
98
|
+
/** True when the load has no manifest, so contributions are unavailable. The
|
|
99
|
+
* authoritative "no manifest" signal: `target` is `null` exactly when this is true. */
|
|
100
|
+
manifestMissing?: boolean | undefined;
|
|
101
|
+
/** The last diff refresh's failure; `null` after a good refresh. */
|
|
102
|
+
diffError?: string | null | undefined;
|
|
103
|
+
/** The diff's warnings. */
|
|
104
|
+
diffWarnings?: VcsDiffWarning[] | undefined;
|
|
105
|
+
/** Repo-relative paths walked but left out of the changeset: today only the
|
|
106
|
+
* `.immediately.run/` platform sidecar files, never the user's own work. */
|
|
107
|
+
excludedPhantoms?: string[] | undefined;
|
|
108
|
+
/** The manifest is truncated: saving is locked out (CONTRIBUTE_SPEC §7). */
|
|
109
|
+
manifestTruncated?: boolean | undefined;
|
|
54
110
|
}
|
|
111
|
+
/** The refKind values the parser keeps (exported so the suite derives its cases from the
|
|
112
|
+
* producer rather than probing one favourite member — every member must pass through,
|
|
113
|
+
* because a miss silently drops the whole target fact). */
|
|
114
|
+
declare const REF_KINDS: Set<string>;
|
|
55
115
|
/** One-off read of the current source-control state. Returns the empty snapshot
|
|
56
116
|
* until the host answers (or if the app lacks `vcs:read`). Use
|
|
57
117
|
* {@link onVcsStateChange} / {@link useVcsState} to react to live updates. */
|
|
@@ -84,5 +144,48 @@ declare const refreshPRs: () => Promise<void>;
|
|
|
84
144
|
* gate. Requires `confirm: true` (host belt-and-braces). Rejects with a
|
|
85
145
|
* {@link VcsActionError} (`.code`). */
|
|
86
146
|
declare const resetWorkingTree: () => Promise<void>;
|
|
147
|
+
/** One first-parent commit of a bundle's history. */
|
|
148
|
+
interface BundleCommit {
|
|
149
|
+
sha: string;
|
|
150
|
+
/** The first parent, or null for a root commit. */
|
|
151
|
+
parent: string | null;
|
|
152
|
+
message: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* A refused bundle-history call. `code` is one of: `forbidden` (the app lacks `vcs:read`,
|
|
156
|
+
* or does not hold the mount), `unsupported` (the mount has no repository history — a
|
|
157
|
+
* space, a local tree — or the tree is too large to compare), `invalid-params` (a
|
|
158
|
+
* malformed sha or path, more than 100 paths or 5 MiB in one read, or a log longer than
|
|
159
|
+
* `max` — the message then starts `history-too-long`), `not-found` (no such commit),
|
|
160
|
+
* `budget` (the provider's rate limit is exhausted; `retryAfter` carries its wait in
|
|
161
|
+
* seconds when it sent one), `unknown`. Nothing enforces the union at runtime — treat an
|
|
162
|
+
* unlisted code as possible.
|
|
163
|
+
*/
|
|
164
|
+
interface BundleHistoryError extends Error {
|
|
165
|
+
code: 'forbidden' | 'unsupported' | 'invalid-params' | 'not-found' | 'budget' | 'unknown';
|
|
166
|
+
retryAfter?: number;
|
|
167
|
+
}
|
|
168
|
+
/** The commit the bundle's ref points at now. Cheap to poll: the host asks GitHub
|
|
169
|
+
* conditionally, so an unchanged head costs no rate limit. */
|
|
170
|
+
declare const bundleHead: (mountId: string) => Promise<string>;
|
|
171
|
+
/** First-parent commits, oldest first, from `until` (default: the head) back to — not
|
|
172
|
+
* including — `since` (default: the root). A merge's second-parent commits never
|
|
173
|
+
* appear. Refused (`invalid-params`, `history-too-long`) beyond `max` (default 200,
|
|
174
|
+
* at most 1000) — never silently truncated. */
|
|
175
|
+
declare const bundleLog: (mountId: string, opts?: {
|
|
176
|
+
since?: string;
|
|
177
|
+
until?: string;
|
|
178
|
+
max?: number;
|
|
179
|
+
}) => Promise<BundleCommit[]>;
|
|
180
|
+
/** Whether commit `a` is an ancestor of commit `b` (reflexive: a commit is its own). */
|
|
181
|
+
declare const bundleIsAncestor: (mountId: string, a: string, b: string) => Promise<boolean>;
|
|
182
|
+
/** Files at commit `sha`, by bundle-relative path; `null` where there is no file. At
|
|
183
|
+
* most 100 paths and 5 MiB per call. */
|
|
184
|
+
declare const bundleRead: (mountId: string, sha: string, paths: string[]) => Promise<Record<string, Uint8Array | null>>;
|
|
185
|
+
/** The bundle-relative paths that differ between two commits (added, removed or changed). */
|
|
186
|
+
declare const bundleDiffPaths: (mountId: string, from: string, to: string) => Promise<string[]>;
|
|
187
|
+
/** Whether the signed-in user may push to the bundle's repository (false signed out).
|
|
188
|
+
* Use it to hide a publish affordance the user could not complete. */
|
|
189
|
+
declare const bundleCanWrite: (mountId: string) => Promise<boolean>;
|
|
87
190
|
|
|
88
|
-
export { type VcsActionError, type VcsAgentSession, type VcsBranch, type VcsChange, type VcsPR, type VcsState, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState };
|
|
191
|
+
export { type BundleCommit, type BundleHistoryError, REF_KINDS, type VcsActionError, type VcsAgentSession, type VcsBranch, type VcsChange, type VcsDiffWarning, type VcsPR, type VcsState, type VcsTarget, bundleCanWrite, bundleDiffPaths, bundleHead, bundleIsAncestor, bundleLog, bundleRead, getVcsState, onVcsStateChange, refreshDiff, refreshPRs, resetWorkingTree, useVcsState };
|
package/dist/vcs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./chunk-VHAA22YE.js";
|
|
2
|
+
import { invoke } from "./catalog.js";
|
|
2
3
|
import { createPushChannel } from "./pushChannel.js";
|
|
3
4
|
import { throwOnRefusal } from "./protocolRefusal.js";
|
|
4
5
|
import { protocolRequest } from "./sandboxUtils.js";
|
|
@@ -21,6 +22,47 @@ const parseAgentSession = (v) => {
|
|
|
21
22
|
...s.updatedAt !== void 0 ? { updatedAt: s.updatedAt } : {}
|
|
22
23
|
};
|
|
23
24
|
};
|
|
25
|
+
const isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === "string");
|
|
26
|
+
const isDiffWarningArray = (v) => Array.isArray(v) && v.every(
|
|
27
|
+
(w) => !!w && typeof w === "object" && typeof w.kind === "string" && typeof w.path === "string" && typeof w.message === "string"
|
|
28
|
+
);
|
|
29
|
+
const REF_KINDS = /* @__PURE__ */ new Set(["branch", "tag", "commit"]);
|
|
30
|
+
const parseTarget = (v) => {
|
|
31
|
+
if (v === null) return null;
|
|
32
|
+
if (!v || typeof v !== "object") return void 0;
|
|
33
|
+
const t = v;
|
|
34
|
+
if (typeof t.namespace !== "string" || typeof t.repository !== "string" || typeof t.ref !== "string" || typeof t.refKind !== "string" || !REF_KINDS.has(t.refKind) || !(t.commitSha === null || typeof t.commitSha === "string" && t.commitSha !== "") || !(t.defaultBranch === null || typeof t.defaultBranch === "string")) {
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
namespace: t.namespace,
|
|
39
|
+
repository: t.repository,
|
|
40
|
+
ref: t.ref,
|
|
41
|
+
refKind: t.refKind,
|
|
42
|
+
commitSha: t.commitSha,
|
|
43
|
+
defaultBranch: t.defaultBranch
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const parseVcsFacts = (msg) => {
|
|
47
|
+
const out = {};
|
|
48
|
+
const target = parseTarget(msg.target);
|
|
49
|
+
if (target !== void 0) out.target = target;
|
|
50
|
+
const openPR = msg.openPR;
|
|
51
|
+
if (openPR === null) out.openPR = null;
|
|
52
|
+
else if (openPR && typeof openPR === "object" && typeof openPR.number === "number" && Number.isFinite(openPR.number) && typeof openPR.url === "string") {
|
|
53
|
+
out.openPR = { number: openPR.number, url: openPR.url };
|
|
54
|
+
}
|
|
55
|
+
if (msg.defaultSaveMode === "pr" || msg.defaultSaveMode === "direct") out.defaultSaveMode = msg.defaultSaveMode;
|
|
56
|
+
if (msg.canPushUpstream === null || typeof msg.canPushUpstream === "boolean")
|
|
57
|
+
out.canPushUpstream = msg.canPushUpstream;
|
|
58
|
+
if (typeof msg.manifestMissing === "boolean") out.manifestMissing = msg.manifestMissing;
|
|
59
|
+
if (msg.diffError === null || typeof msg.diffError === "string") out.diffError = msg.diffError;
|
|
60
|
+
if (isDiffWarningArray(msg.diffWarnings))
|
|
61
|
+
out.diffWarnings = msg.diffWarnings.map(({ kind, path, message }) => ({ kind, path, message }));
|
|
62
|
+
if (isStringArray(msg.excludedPhantoms)) out.excludedPhantoms = msg.excludedPhantoms;
|
|
63
|
+
if (typeof msg.manifestTruncated === "boolean") out.manifestTruncated = msg.manifestTruncated;
|
|
64
|
+
return out;
|
|
65
|
+
};
|
|
24
66
|
const channel = createPushChannel({
|
|
25
67
|
pushType: VCS_STATE,
|
|
26
68
|
requestType: REQUEST_VCS_STATE,
|
|
@@ -35,7 +77,20 @@ const channel = createPushChannel({
|
|
|
35
77
|
branch,
|
|
36
78
|
prs,
|
|
37
79
|
diffLoading: msg.diffLoading === true,
|
|
38
|
-
...agentSession ? { agentSession } : {}
|
|
80
|
+
...agentSession ? { agentSession } : {},
|
|
81
|
+
// Each key is named here, not inside the helper, so the protocol snapshot's
|
|
82
|
+
// `reads` records every field this parser consumes.
|
|
83
|
+
...parseVcsFacts({
|
|
84
|
+
target: msg.target,
|
|
85
|
+
openPR: msg.openPR,
|
|
86
|
+
defaultSaveMode: msg.defaultSaveMode,
|
|
87
|
+
canPushUpstream: msg.canPushUpstream,
|
|
88
|
+
manifestMissing: msg.manifestMissing,
|
|
89
|
+
diffError: msg.diffError,
|
|
90
|
+
diffWarnings: msg.diffWarnings,
|
|
91
|
+
excludedPhantoms: msg.excludedPhantoms,
|
|
92
|
+
manifestTruncated: msg.manifestTruncated
|
|
93
|
+
})
|
|
39
94
|
};
|
|
40
95
|
}
|
|
41
96
|
});
|
|
@@ -49,7 +104,50 @@ const vcsRequest = async (method, arg = {}) => {
|
|
|
49
104
|
const refreshDiff = () => vcsRequest("refreshDiff");
|
|
50
105
|
const refreshPRs = () => vcsRequest("refreshPRs");
|
|
51
106
|
const resetWorkingTree = () => vcsRequest("reset", { confirm: true });
|
|
107
|
+
const fromBase64 = (s) => {
|
|
108
|
+
const bin = atob(s);
|
|
109
|
+
const out = new Uint8Array(bin.length);
|
|
110
|
+
for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
|
|
111
|
+
return out;
|
|
112
|
+
};
|
|
113
|
+
const bundleHead = async (mountId) => {
|
|
114
|
+
const params = { mountId };
|
|
115
|
+
return (await invoke("vcs:bundleHead", params)).sha;
|
|
116
|
+
};
|
|
117
|
+
const bundleLog = async (mountId, opts = {}) => {
|
|
118
|
+
const params = { mountId };
|
|
119
|
+
if (opts.since !== void 0) params.since = opts.since;
|
|
120
|
+
if (opts.until !== void 0) params.until = opts.until;
|
|
121
|
+
if (opts.max !== void 0) params.max = opts.max;
|
|
122
|
+
return (await invoke("vcs:bundleLog", params)).commits;
|
|
123
|
+
};
|
|
124
|
+
const bundleIsAncestor = async (mountId, a, b) => {
|
|
125
|
+
const params = { mountId, a, b };
|
|
126
|
+
return (await invoke("vcs:bundleIsAncestor", params)).ancestor;
|
|
127
|
+
};
|
|
128
|
+
const bundleRead = async (mountId, sha, paths) => {
|
|
129
|
+
const params = { mountId, sha, paths };
|
|
130
|
+
const { files } = await invoke("vcs:bundleRead", params);
|
|
131
|
+
const out = {};
|
|
132
|
+
for (const [path, b64] of Object.entries(files)) out[path] = b64 === null ? null : fromBase64(b64);
|
|
133
|
+
return out;
|
|
134
|
+
};
|
|
135
|
+
const bundleDiffPaths = async (mountId, from, to) => {
|
|
136
|
+
const params = { mountId, from, to };
|
|
137
|
+
return (await invoke("vcs:bundleDiffPaths", params)).paths;
|
|
138
|
+
};
|
|
139
|
+
const bundleCanWrite = async (mountId) => {
|
|
140
|
+
const params = { mountId };
|
|
141
|
+
return (await invoke("vcs:bundleCanWrite", params)).canWrite;
|
|
142
|
+
};
|
|
52
143
|
export {
|
|
144
|
+
REF_KINDS,
|
|
145
|
+
bundleCanWrite,
|
|
146
|
+
bundleDiffPaths,
|
|
147
|
+
bundleHead,
|
|
148
|
+
bundleIsAncestor,
|
|
149
|
+
bundleLog,
|
|
150
|
+
bundleRead,
|
|
53
151
|
getVcsState,
|
|
54
152
|
onVcsStateChange,
|
|
55
153
|
refreshDiff,
|
package/dist/vcs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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 { 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 upstreamPushable: boolean | 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}\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\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 };\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"],"mappings":";AAiBA,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,cAAc,mBAAmB,iBAAiB;AAC3D,SAAS,eAAe;AA+DxB,MAAM,QAAkB,EAAE,SAAS,CAAC,GAAG,QAAQ,MAAM,KAAK,CAAC,GAAG,aAAa,MAAM;AAEjF,MAAM,gBAAgB,CAAC,MACrB,MAAM,QAAQ,CAAC,KACf,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,OAAQ,EAAgB,SAAS,YAAY,OAAQ,EAAgB,WAAW,QAAQ;AAMhH,MAAM,oBAAoB,CAAC,MAA4C;AACrE,MAAI,MAAM,UAAa,MAAM,KAAM,QAAO;AAC1C,MAAI,OAAO,MAAM,SAAU,QAAO;AAClC,QAAM,IAAI;AAKV,MACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,mBAAmB,YAC5B,OAAO,EAAE,iBAAiB,YAC1B,CAAC,OAAO,SAAS,EAAE,YAAY,KAC/B,OAAO,EAAE,YAAY,aACpB,EAAE,cAAc,WAAc,OAAO,EAAE,cAAc,YAAY,CAAC,OAAO,SAAS,EAAE,SAAS,IAC9F;AACA,WAAO;AAAA,EACT;AACA,SAAO;AAAA,IACL,MAAM,EAAE;AAAA,IACR,gBAAgB,EAAE;AAAA,IAClB,cAAc,EAAE;AAAA,IAChB,SAAS,EAAE;AAAA,IACX,GAAI,EAAE,cAAc,SAAY,EAAE,WAAW,EAAE,UAAU,IAAI,CAAC;AAAA,EAChE;AACF;AAEA,MAAM,UAAU,kBAA4B;AAAA,EAC1C,UAAU;AAAA,EACV,aAAa;AAAA,EACb,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ;AAGd,QAAI,CAAC,cAAc,IAAI,OAAO,EAAG,QAAO;AACxC,UAAM,SAAS,IAAI,UAAU,OAAO,IAAI,WAAW,WAAY,IAAI,SAAuB;AAC1F,UAAM,MAAM,MAAM,QAAQ,IAAI,GAAG,IAAK,IAAI,MAAkB,CAAC;AAC7D,UAAM,eAAe,kBAAkB,IAAI,YAAY;AACvD,WAAO;AAAA,MACL,SAAS,IAAI;AAAA,MACb;AAAA,MACA;AAAA,MACA,aAAa,IAAI,gBAAgB;AAAA,MACjC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA,IACzC;AAAA,EACF;AACF,CAAC;AAKM,MAAM,cAAc,MAAgB,QAAQ,IAAI;AAKhD,MAAM,mBAAmB,CAAC,aAAsD,QAAQ,SAAS,QAAQ;AAGzG,MAAM,cAAc,MAAgB,QAAQ,IAAI;AA8BvD,MAAM,aAAa,OAAO,QAAgB,MAA+B,CAAC,MAAqB;AAC7F,QAAM,MAAO,MAAM,gBAAgB,QAAQ,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC;AACvE,iBAAe,KAAK,OAAO,MAAM,SAAS;AAC5C;AAIO,MAAM,cAAc,MAAqB,WAAW,aAAa;AAIjE,MAAM,aAAa,MAAqB,WAAW,YAAY;AAM/D,MAAM,mBAAmB,MAAqB,WAAW,SAAS,EAAE,SAAS,KAAK,CAAC;","names":[]}
|
|
1
|
+
{"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":";AAiBA,SAAS,cAAc;AACvB,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,cAAc,mBAAmB,iBAAiB;AAC3D,SAAS,eAAe;AAsHxB,MAAM,QAAkB,EAAE,SAAS,CAAC,GAAG,QAAQ,MAAM,KAAK,CAAC,GAAG,aAAa,MAAM;AAEjF,MAAM,gBAAgB,CAAC,MACrB,MAAM,QAAQ,CAAC,KACf,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,OAAQ,EAAgB,SAAS,YAAY,OAAQ,EAAgB,WAAW,QAAQ;AAMhH,MAAM,oBAAoB,CAAC,MAA4C;AACrE,MAAI,MAAM,UAAa,MAAM,KAAM,QAAO;AAC1C,MAAI,OAAO,MAAM,SAAU,QAAO;AAClC,QAAM,IAAI;AAKV,MACE,OAAO,EAAE,SAAS,YAClB,OAAO,EAAE,mBAAmB,YAC5B,OAAO,EAAE,iBAAiB,YAC1B,CAAC,OAAO,SAAS,EAAE,YAAY,KAC/B,OAAO,EAAE,YAAY,aACpB,EAA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9C,UAAQ,MAAM,OAAwB,kBAAkB,MAAM,GAAG;AACnE;AAMO,MAAM,YAAY,OACvB,SACA,OAAyD,CAAC,MAC9B;AAC5B,QAAM,SAA4E,EAAE,QAAQ;AAC5F,MAAI,KAAK,UAAU,OAAW,QAAO,QAAQ,KAAK;AAClD,MAAI,KAAK,UAAU,OAAW,QAAO,QAAQ,KAAK;AAClD,MAAI,KAAK,QAAQ,OAAW,QAAO,MAAM,KAAK;AAC9C,UAAQ,MAAM,OAAoC,iBAAiB,MAAM,GAAG;AAC9E;AAGO,MAAM,mBAAmB,OAAO,SAAiB,GAAW,MAAgC;AACjG,QAAM,SAAoD,EAAE,SAAS,GAAG,EAAE;AAC1E,UAAQ,MAAM,OAA8B,wBAAwB,MAAM,GAAG;AAC/E;AAIO,MAAM,aAAa,OACxB,SACA,KACA,UAC+C;AAC/C,QAAM,SAA4D,EAAE,SAAS,KAAK,MAAM;AACxF,QAAM,EAAE,MAAM,IAAI,MAAM,OAAiD,kBAAkB,MAAM;AACjG,QAAM,MAAyC,CAAC;AAChD,aAAW,CAAC,MAAM,GAAG,KAAK,OAAO,QAAQ,KAAK,EAAG,KAAI,IAAI,IAAI,QAAQ,OAAO,OAAO,WAAW,GAAG;AACjG,SAAO;AACT;AAGO,MAAM,kBAAkB,OAAO,SAAiB,MAAc,OAAkC;AACrG,QAAM,SAAwD,EAAE,SAAS,MAAM,GAAG;AAClF,UAAQ,MAAM,OAA4B,uBAAuB,MAAM,GAAG;AAC5E;AAIO,MAAM,iBAAiB,OAAO,YAAsC;AACzE,QAAM,SAA8B,EAAE,QAAQ;AAC9C,UAAQ,MAAM,OAA8B,sBAAsB,MAAM,GAAG;AAC7E;","names":[]}
|
package/dist/version.cjs
CHANGED
|
@@ -21,7 +21,7 @@ __export(version_exports, {
|
|
|
21
21
|
SDK_VERSION: () => SDK_VERSION
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(version_exports);
|
|
24
|
-
const SDK_VERSION = "0.
|
|
24
|
+
const SDK_VERSION = "0.87.1";
|
|
25
25
|
// Annotate the CommonJS export names for ESM import in node:
|
|
26
26
|
0 && (module.exports = {
|
|
27
27
|
SDK_VERSION
|
package/dist/version.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.87.1';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO,MAAM,cAAc;","names":[]}
|
package/dist/version.d.cts
CHANGED
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["// GENERATED by scripts/gen-version.mjs from package.json — do not edit by hand.\n// Regenerated on every build (prebuild); kept honest by version.test.ts.\n\n/** This SDK's package version, baked from package.json at build (SP2-6). */\nexport const SDK_VERSION = '0.87.1';\n"],"mappings":";AAIO,MAAM,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@immediately-run/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.1",
|
|
4
4
|
"description": "Runtime SDK for code executing inside an immediately.run sandbox.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "github:immediately-run/immediately-run-sdk",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"@immediately-run/mdx-plugins": "0.7.1",
|
|
76
76
|
"@immediately-run/platform-constants": "0.2.0",
|
|
77
77
|
"@immediately-run/safe-content": "0.1.0",
|
|
78
|
-
"@immediately-run/sandbox-protocol": "^0.
|
|
78
|
+
"@immediately-run/sandbox-protocol": "^0.25.0",
|
|
79
79
|
"react-error-boundary": "^6.0.0"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|