@immediately-run/sdk 0.83.0 → 0.85.0

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.
Files changed (53) hide show
  1. package/dist/catalog.cjs +2 -0
  2. package/dist/catalog.cjs.map +1 -1
  3. package/dist/catalog.js +2 -0
  4. package/dist/catalog.js.map +1 -1
  5. package/dist/contribute.cjs.map +1 -1
  6. package/dist/contribute.d.cts +39 -1
  7. package/dist/contribute.d.ts +39 -1
  8. package/dist/contribute.js.map +1 -1
  9. package/dist/index.cjs +2 -0
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.d.cts +4 -3
  12. package/dist/index.d.ts +4 -3
  13. package/dist/index.js +1 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/openBundle.cjs +44 -0
  16. package/dist/openBundle.cjs.map +1 -0
  17. package/dist/openBundle.d.cts +53 -0
  18. package/dist/openBundle.d.ts +53 -0
  19. package/dist/openBundle.js +20 -0
  20. package/dist/openBundle.js.map +1 -0
  21. package/dist/openRepository.cjs +4 -4
  22. package/dist/openRepository.cjs.map +1 -1
  23. package/dist/openRepository.d.cts +12 -2
  24. package/dist/openRepository.d.ts +12 -2
  25. package/dist/openRepository.js +4 -4
  26. package/dist/openRepository.js.map +1 -1
  27. package/dist/protocolDeadline.cjs +15 -0
  28. package/dist/protocolDeadline.cjs.map +1 -1
  29. package/dist/protocolDeadline.js +15 -0
  30. package/dist/protocolDeadline.js.map +1 -1
  31. package/dist/protocolRefusal.cjs.map +1 -1
  32. package/dist/protocolRefusal.d.cts +1 -1
  33. package/dist/protocolRefusal.d.ts +1 -1
  34. package/dist/protocolRefusal.js.map +1 -1
  35. package/dist/protocolSchemes.cjs +1 -0
  36. package/dist/protocolSchemes.cjs.map +1 -1
  37. package/dist/protocolSchemes.d.cts +1 -0
  38. package/dist/protocolSchemes.d.ts +1 -0
  39. package/dist/protocolSchemes.js +2 -0
  40. package/dist/protocolSchemes.js.map +1 -1
  41. package/dist/vcs.cjs +106 -1
  42. package/dist/vcs.cjs.map +1 -1
  43. package/dist/vcs.d.cts +104 -1
  44. package/dist/vcs.d.ts +104 -1
  45. package/dist/vcs.js +99 -1
  46. package/dist/vcs.js.map +1 -1
  47. package/dist/version.cjs +1 -1
  48. package/dist/version.cjs.map +1 -1
  49. package/dist/version.d.cts +1 -1
  50. package/dist/version.d.ts +1 -1
  51. package/dist/version.js +1 -1
  52. package/dist/version.js.map +1 -1
  53. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocolRefusal.ts"],"sourcesContent":["// The one place the SDK turns a host reply envelope into a typed, coded rejection (R6).\n//\n// ---------------------------------------------------------------------------\n// THE CENSUS — miscounted four times. COUNT THE GREP, and say which unit.\n// ---------------------------------------------------------------------------\n//\n// R3-708's review said three copies, then five, then \"ten across eight files\". This file\n// then said ten while the list beneath it summed to twelve, and a fourth reviewer caught\n// that. The count is:\n//\n// **seventeen CALL SITES across twelve FILES** — `grep -n 'throwOnRefusal(' src/*.ts`,\n// minus the declaration here and minus `*.test.*`:\n//\n// dnd.ts · editor.ts · feed.ts · ipc.ts (×2) · mounts.ts (×3) · netFetch.ts ·\n// openExternal.ts · openRepository.ts · secrets.ts · spacesMode.ts · theme.ts (×3) ·\n// vcs.ts\n//\n// Every miscount came from the same two mistakes: reading files instead of counting the\n// grep, and never saying which unit was being counted. `mounts.ts` has three separate\n// request helpers, each with its own copy; R3-780 touched five FILES and seven SITES.\n// \"Ten\" was neither.\n//\n// Not folded, deliberately, and the reason is NOT that they are all unalike — that was the\n// previous excuse and it was false for three of them:\n//\n// · `catalog.ts`, `recents.ts`, `tasks.ts` are pure copies of the shape `ipc.ts` had\n// until R3-780 folded it — untyped `Error & { code?: string }`, `res?.code ??\n// 'unknown'`. (`recents.ts` casts `code` as required rather than optional; immaterial,\n// the cast erases.) They are foldable and nothing here argues otherwise;\n// · `feed.ts`, `netFetch.ts` and `theme.ts` (×3) read `res && 'code' in res`, which\n// THREW `TypeError: Cannot use 'in' operator` on a string reply — FOLDED in R3-817\n// (0.74.3), a behaviour change reviewed as its own item, exactly as this bullet\n// prescribed;\n// · `launch.ts` folds `!res.data?.launchId` into the same condition and RETURNS\n// `{ ok: false, code }` instead of throwing. Different control flow entirely.\n//\n// So the remaining work is two items, not one, and they are not the same size.\n//\n// `check:clones` cannot help with any of this: minLines 6, minTokens 50, and no identifier\n// normalisation, so blocks differing only in type names read as distinct.\n//\n// ---------------------------------------------------------------------------\n// THIS FILE'S OWN TEST IS LOAD-BEARING FOR ALL SEVENTEEN SITES\n// ---------------------------------------------------------------------------\n//\n// Measured: changing the guard to `r.ok !== false` compiles clean and leaves **ten of the\n// seventeen SITES** green — seven of the twelve files: `dnd`, `editor`, `ipc`, `mounts`,\n// `secrets`, `spacesMode` and `vcs`. Every one of them stubs an explicit `{ ok: false }`,\n// so they pin \"throws on a refusal envelope\" and nothing about a malformed or absent\n// reply. The catchers: `openExternal`, `openRepository`, the five R3-817 sites (whose\n// string-reply tests reject on a non-envelope — the mutation never throws), plus\n// `protocolRefusal.test.ts`. (Re-run 2026-09-30 on the post-fold tree: suites red —\n// feed, netFetch, theme, openExternal, openRepository, protocolRefusal; the seven\n// families green.)\n//\n// (An earlier version of this paragraph said \"nine of the twelve sites' suites\", which\n// mixes sites with suites — the exact mistake the census block above is headed about —\n// and omitted `secrets` and `spacesMode` from the green list.)\n//\n// Each inline form this replaced carried its own `!res ||` guard, visible at the call site.\n// That guarantee now lives here alone. Do not weaken `protocolRefusal.test.ts` on the\n// grounds that \"the consumers cover it\" — they do not, and seventeen near-duplicate malformed\n// -reply tests would be the duplication this extraction exists to remove.\n//\n// ---------------------------------------------------------------------------\n// WHICH `ok` THIS READS, AND WHY IT MATTERS\n// ---------------------------------------------------------------------------\n//\n// It reads the DISPATCHER ENVELOPE's `ok` — the host's answer to \"did this call\n// succeed\", not a handler's own return value. site-main declares that envelope\n// (`src/editor/requestDispatcher.ts`):\n//\n// type SpaceResult =\n// | { ok: true; data: unknown }\n// | { ok: false; code: string; message: string };\n//\n// and the sandbox resolves it to the SDK unmodified (`src/protocol/iframe.ts`,\n// `resolve(msg.result)`). So a refusal reaches us as `{ok:false, code, message}` — which\n// is exactly what this function unwraps — and the host produces that frame by THROWING\n// `spaceError(code, message)`. The dispatcher's `.catch` turns the throw into the frame.\n//\n// **A handler that RETURNS `{ok:false, code}` instead of throwing does not produce a\n// refusal.** The dispatcher wraps a return value as `result: {ok: true, data: <return>}`,\n// so the envelope says the call succeeded and the refusal is buried one level down, where\n// nothing looks. Two shipped handlers did this until R3-778 closed it (site-main; audited sdk#184 round 2, 2026-09-25; fixed 2026-09-28 — both now throw, and a dispatcher assertion reddens on the shape):\n//\n// `handleOpenRepository` returns `invalid`, `no-activation`\n// `handleOpenLink` returns `invalid`, `no-activation`, **`declined`**\n//\n// `declined` is the user pressing \"no\" on the host's confirmation dialog, and\n// `openExternal()` reported that to the app as a successful open, until R3-778 closed it. Driven against the built\n// SDK with each reply shape:\n//\n// thrown -> threw, code=no-activation\n// returned -> RESOLVED (the app believes the tab opened)\n//\n// That was a live defect in site-main's handlers until R3-778 closed it (2026-09-28), not here — the envelope is the contract\n// and this reads the contract. Filed as R3-778. It is written down here because this is\n// the file a host author will be pointed at when they ask what shape to reply with, and\n// the answer is: **throw `spaceError`; never return `{ok:false}`.**\n//\n// Deliberately NOT done: sniffing `res.data?.ok === false` as a second refusal shape. On a\n// SUCCESS, `data` is whatever the handler returned — so a handler whose legitimate payload\n// happens to carry `ok: false` would be turned into a refusal. It would bless the broken\n// shape and create a second contract where the spec names one.\n\n/** An error carrying a stable, host-supplied `code` the app can branch on. */\nexport interface CodedRefusalError<C extends string = string> extends Error {\n code: C;\n}\n\n/**\n * Throw a typed, coded error unless the host's reply envelope says the call succeeded.\n *\n * `fallbackMessage` is used when the host refused without a message, and `'unknown'` is\n * the code when it refused without one — a refusal is never reported as a success just\n * because it arrived under-specified.\n *\n * `code` and `message` must be STRINGS to be used. Seventeen sites call this;\n * **sixteen** had an inline copy it replaced (`spacesMode.ts` was written against the\n * helper in R3-708 and replaced nothing). All sixteen tested for PRESENCE, in **three**\n * shapes:\n *\n * - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —\n * `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;\n * - **seven** used the `in` operator — `openExternal`, `openRepository` (with the cast;\n * folded in R3-708) and `feed`, `netFetch`, `theme` ×3 (without it; folded in R3-817,\n * the TypeError fix disclosed above);\n * - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —\n * `ipc.ts`.\n *\n * Every one of them let a host sending `code: 42` surface `err.code === 42` on a field\n * declared `string`, and turned `message: 42` into the string `\"42\"`. Both now fall back,\n * to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by\n * `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is\n * where a consumer learns of it.\n *\n * The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL\n * and `CodedRefusalError` requires it. No runtime difference for a missing code — the old\n * code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back\n * too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`\n * can stop.\n *\n * Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`\n * throws on a string reply.\n *\n * ONE revision of this paragraph got that backwards, and this is the fourth attempt to\n * describe it accurately. The original text was right FOR ITS REFERENT — it named\n * `'code' in res` as a shape replaced, without saying which sites, and at the time the\n * sites it referred to were R3-708's four, two of which used that form. R3-780 then folded\n * five DIFFERENT files and inherited the sentence unchanged, so it became false in place\n * without anyone editing it. That silent shift is the likeliest reason the next revision\n * \"corrected\" it to say NO replaced site used it — which is false the other way:\n * `openExternal` and `openRepository` did.\n *\n * The mechanism is worth more than the correction, because it is repeatable. `'code' in\n * res` is **gone from `main`** since R3-817 (0.74.3) folded the last five — a reviewer who\n * greps `main` finds nothing, and this paragraph is the record of where it lived and why\n * it misread twice before. What a grep of `main` cannot show is that the\n * form was ALSO at two sites R3-708 folded. The tree that answers the question is the one\n * before the fold, `d4b07cc1^`. Read that before rewriting this paragraph again.\n *\n * It is an ASSERTION function, not a `void` one, because the inline form it replaced\n * narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read\n * `res.data` on the next line and stopped compiling without it. A caller that only needs\n * the throw can ignore the narrowing; one that reads the payload gets it for free. (TS\n * requires the call target to be an explicitly-typed declared name — this is why it is a\n * `function` declaration and not an arrow const.)\n *\n * R3-817 (0.74.3): the five remaining inline copies (`feed.ts`, `netFetch.ts`,\n * `theme.ts` ×3) folded onto this — removing a latent defect with them: their\n * `res && 'code' in res` guard threw `TypeError: Cannot use 'in' operator` on a\n * bare-STRING reply (a proxy error page, a relay), escaping past every `err.code`\n * branch an app wrote. This function reads `typeof r?.code === 'string'` and\n * cannot throw on any input; the TypeError path no longer exists.\n */\nexport function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is { ok: true; data?: unknown } {\n const r = res as { ok?: unknown; code?: unknown; message?: unknown } | null | undefined;\n if (r && r.ok === true) return;\n const err = new Error(typeof r?.message === 'string' ? r.message : fallbackMessage) as CodedRefusalError;\n err.code = typeof r?.code === 'string' ? r.code : 'unknown';\n throw err;\n}\n"],"mappings":";AAgLO,SAAS,eAAe,KAAc,iBAAsE;AACjH,QAAM,IAAI;AACV,MAAI,KAAK,EAAE,OAAO,KAAM;AACxB,QAAM,MAAM,IAAI,MAAM,OAAO,GAAG,YAAY,WAAW,EAAE,UAAU,eAAe;AAClF,MAAI,OAAO,OAAO,GAAG,SAAS,WAAW,EAAE,OAAO;AAClD,QAAM;AACR;","names":[]}
1
+ {"version":3,"sources":["../src/protocolRefusal.ts"],"sourcesContent":["// The one place the SDK turns a host reply envelope into a typed, coded rejection (R6).\n//\n// ---------------------------------------------------------------------------\n// THE CENSUS — miscounted four times. COUNT THE GREP, and say which unit.\n// ---------------------------------------------------------------------------\n//\n// R3-708's review said three copies, then five, then \"ten across eight files\". This file\n// then said ten while the list beneath it summed to twelve, and a fourth reviewer caught\n// that. The count is:\n//\n// **eighteen CALL SITES across thirteen FILES** — `grep -n 'throwOnRefusal(' src/*.ts`,\n// minus the declaration here and minus `*.test.*`:\n//\n// dnd.ts · editor.ts · feed.ts · ipc.ts (×2) · mounts.ts (×3) · netFetch.ts ·\n// openBundle.ts · openExternal.ts · openRepository.ts · secrets.ts · spacesMode.ts · theme.ts (×3) ·\n// vcs.ts\n//\n// Every miscount came from the same two mistakes: reading files instead of counting the\n// grep, and never saying which unit was being counted. `mounts.ts` has three separate\n// request helpers, each with its own copy; R3-780 touched five FILES and seven SITES.\n// \"Ten\" was neither.\n//\n// Not folded, deliberately, and the reason is NOT that they are all unalike — that was the\n// previous excuse and it was false for three of them:\n//\n// · `catalog.ts`, `recents.ts`, `tasks.ts` are pure copies of the shape `ipc.ts` had\n// until R3-780 folded it — untyped `Error & { code?: string }`, `res?.code ??\n// 'unknown'`. (`recents.ts` casts `code` as required rather than optional; immaterial,\n// the cast erases.) They are foldable and nothing here argues otherwise;\n// · `feed.ts`, `netFetch.ts` and `theme.ts` (×3) read `res && 'code' in res`, which\n// THREW `TypeError: Cannot use 'in' operator` on a string reply — FOLDED in R3-817\n// (0.74.3), a behaviour change reviewed as its own item, exactly as this bullet\n// prescribed;\n// · `launch.ts` folds `!res.data?.launchId` into the same condition and RETURNS\n// `{ ok: false, code }` instead of throwing. Different control flow entirely.\n//\n// So the remaining work is two items, not one, and they are not the same size.\n//\n// `check:clones` cannot help with any of this: minLines 6, minTokens 50, and no identifier\n// normalisation, so blocks differing only in type names read as distinct.\n//\n// ---------------------------------------------------------------------------\n// THIS FILE'S OWN TEST IS LOAD-BEARING FOR ALL EIGHTEEN SITES\n// ---------------------------------------------------------------------------\n//\n// Measured: changing the guard to `r.ok !== false` compiles clean and leaves **ten of the\n// eighteen SITES** green — seven of the thirteen files: `dnd`, `editor`, `ipc`, `mounts`,\n// `secrets`, `spacesMode` and `vcs`. Every one of them stubs an explicit `{ ok: false }`,\n// so they pin \"throws on a refusal envelope\" and nothing about a malformed or absent\n// reply. The catchers: `openBundle`, `openExternal`, `openRepository`, the five R3-817 sites (whose\n// string-reply tests reject on a non-envelope — the mutation never throws), plus\n// `protocolRefusal.test.ts`. (Re-run 2026-09-30 on the post-fold tree: suites red —\n// feed, netFetch, theme, openExternal, openRepository, protocolRefusal; the seven\n// families green. `openBundle`, the eighteenth site, was added 2026-10-05 and re-run alone\n// under the same mutation: red.)\n//\n// (An earlier version of this paragraph said \"nine of the twelve sites' suites\", which\n// mixes sites with suites — the exact mistake the census block above is headed about —\n// and omitted `secrets` and `spacesMode` from the green list.)\n//\n// Each inline form this replaced carried its own `!res ||` guard, visible at the call site.\n// That guarantee now lives here alone. Do not weaken `protocolRefusal.test.ts` on the\n// grounds that \"the consumers cover it\" — they do not, and eighteen near-duplicate malformed\n// -reply tests would be the duplication this extraction exists to remove.\n//\n// ---------------------------------------------------------------------------\n// WHICH `ok` THIS READS, AND WHY IT MATTERS\n// ---------------------------------------------------------------------------\n//\n// It reads the DISPATCHER ENVELOPE's `ok` — the host's answer to \"did this call\n// succeed\", not a handler's own return value. site-main declares that envelope\n// (`src/editor/requestDispatcher.ts`):\n//\n// type SpaceResult =\n// | { ok: true; data: unknown }\n// | { ok: false; code: string; message: string };\n//\n// and the sandbox resolves it to the SDK unmodified (`src/protocol/iframe.ts`,\n// `resolve(msg.result)`). So a refusal reaches us as `{ok:false, code, message}` — which\n// is exactly what this function unwraps — and the host produces that frame by THROWING\n// `spaceError(code, message)`. The dispatcher's `.catch` turns the throw into the frame.\n//\n// **A handler that RETURNS `{ok:false, code}` instead of throwing does not produce a\n// refusal.** The dispatcher wraps a return value as `result: {ok: true, data: <return>}`,\n// so the envelope says the call succeeded and the refusal is buried one level down, where\n// nothing looks. Two shipped handlers did this until R3-778 closed it (site-main; audited sdk#184 round 2, 2026-09-25; fixed 2026-09-28 — both now throw, and a dispatcher assertion reddens on the shape):\n//\n// `handleOpenRepository` returns `invalid`, `no-activation`\n// `handleOpenLink` returns `invalid`, `no-activation`, **`declined`**\n//\n// `declined` is the user pressing \"no\" on the host's confirmation dialog, and\n// `openExternal()` reported that to the app as a successful open, until R3-778 closed it. Driven against the built\n// SDK with each reply shape:\n//\n// thrown -> threw, code=no-activation\n// returned -> RESOLVED (the app believes the tab opened)\n//\n// That was a live defect in site-main's handlers until R3-778 closed it (2026-09-28), not here — the envelope is the contract\n// and this reads the contract. Filed as R3-778. It is written down here because this is\n// the file a host author will be pointed at when they ask what shape to reply with, and\n// the answer is: **throw `spaceError`; never return `{ok:false}`.**\n//\n// Deliberately NOT done: sniffing `res.data?.ok === false` as a second refusal shape. On a\n// SUCCESS, `data` is whatever the handler returned — so a handler whose legitimate payload\n// happens to carry `ok: false` would be turned into a refusal. It would bless the broken\n// shape and create a second contract where the spec names one.\n\n/** An error carrying a stable, host-supplied `code` the app can branch on. */\nexport interface CodedRefusalError<C extends string = string> extends Error {\n code: C;\n}\n\n/**\n * Throw a typed, coded error unless the host's reply envelope says the call succeeded.\n *\n * `fallbackMessage` is used when the host refused without a message, and `'unknown'` is\n * the code when it refused without one — a refusal is never reported as a success just\n * because it arrived under-specified.\n *\n * `code` and `message` must be STRINGS to be used. Eighteen sites call this;\n * **sixteen** had an inline copy it replaced (`spacesMode.ts` was written against the\n * helper in R3-708 and replaced nothing). All sixteen tested for PRESENCE, in **three**\n * shapes:\n *\n * - **seven** cast the value: `(res?.code as SomeError['code']) ?? 'unknown'` —\n * `dnd`, `editor`, `vcs`, `mounts` (×3), `secrets`;\n * - **seven** used the `in` operator — `openExternal`, `openRepository` (with the cast;\n * folded in R3-708) and `feed`, `netFetch`, `theme` ×3 (without it; folded in R3-817,\n * the TypeError fix disclosed above);\n * - **two** used a bare `res?.code ?? 'unknown'` onto `Error & { code?: string }` —\n * `ipc.ts`.\n *\n * Every one of them let a host sending `code: 42` surface `err.code === 42` on a field\n * declared `string`, and turned `message: 42` into the string `\"42\"`. Both now fall back,\n * to `'unknown'` and `fallbackMessage`. A deliberate tightening, pinned by\n * `protocolRefusal.test.ts` — and since this package ships no changelog, this paragraph is\n * where a consumer learns of it.\n *\n * The `ipc.ts` pair changed one more thing: their anonymous type declared `code` OPTIONAL\n * and `CodedRefusalError` requires it. No runtime difference for a missing code — the old\n * code assigned `'unknown'` exactly when the new one does (a non-string `code` falls back\n * too, as the paragraph above discloses) — but a consumer narrowing on `'code' in err`\n * can stop.\n *\n * Folding the two `in`-operator sites also removed a latent `TypeError`: `'code' in res`\n * throws on a string reply.\n *\n * ONE revision of this paragraph got that backwards, and this is the fourth attempt to\n * describe it accurately. The original text was right FOR ITS REFERENT — it named\n * `'code' in res` as a shape replaced, without saying which sites, and at the time the\n * sites it referred to were R3-708's four, two of which used that form. R3-780 then folded\n * five DIFFERENT files and inherited the sentence unchanged, so it became false in place\n * without anyone editing it. That silent shift is the likeliest reason the next revision\n * \"corrected\" it to say NO replaced site used it — which is false the other way:\n * `openExternal` and `openRepository` did.\n *\n * The mechanism is worth more than the correction, because it is repeatable. `'code' in\n * res` is **gone from `main`** since R3-817 (0.74.3) folded the last five — a reviewer who\n * greps `main` finds nothing, and this paragraph is the record of where it lived and why\n * it misread twice before. What a grep of `main` cannot show is that the\n * form was ALSO at two sites R3-708 folded. The tree that answers the question is the one\n * before the fold, `d4b07cc1^`. Read that before rewriting this paragraph again.\n *\n * It is an ASSERTION function, not a `void` one, because the inline form it replaced\n * narrowed `res` as a side effect of its `if`/`throw`: `secrets.ts` and `mounts.ts` read\n * `res.data` on the next line and stopped compiling without it. A caller that only needs\n * the throw can ignore the narrowing; one that reads the payload gets it for free. (TS\n * requires the call target to be an explicitly-typed declared name — this is why it is a\n * `function` declaration and not an arrow const.)\n *\n * R3-817 (0.74.3): the five remaining inline copies (`feed.ts`, `netFetch.ts`,\n * `theme.ts` ×3) folded onto this — removing a latent defect with them: their\n * `res && 'code' in res` guard threw `TypeError: Cannot use 'in' operator` on a\n * bare-STRING reply (a proxy error page, a relay), escaping past every `err.code`\n * branch an app wrote. This function reads `typeof r?.code === 'string'` and\n * cannot throw on any input; the TypeError path no longer exists.\n */\nexport function throwOnRefusal(res: unknown, fallbackMessage: string): asserts res is { ok: true; data?: unknown } {\n const r = res as { ok?: unknown; code?: unknown; message?: unknown } | null | undefined;\n if (r && r.ok === true) return;\n const err = new Error(typeof r?.message === 'string' ? r.message : fallbackMessage) as CodedRefusalError;\n err.code = typeof r?.code === 'string' ? r.code : 'unknown';\n throw err;\n}\n"],"mappings":";AAiLO,SAAS,eAAe,KAAc,iBAAsE;AACjH,QAAM,IAAI;AACV,MAAI,KAAK,EAAE,OAAO,KAAM;AACxB,QAAM,MAAM,IAAI,MAAM,OAAO,GAAG,YAAY,WAAW,EAAE,UAAU,eAAe;AAClF,MAAI,OAAO,OAAO,GAAG,SAAS,WAAW,EAAE,OAAO;AAClD,QAAM;AACR;","names":[]}
@@ -35,6 +35,7 @@ const SCHEMES = {
35
35
  [import_protocol.PROTOCOL_LAUNCH]: schemeOf(import_protocol.PROTOCOL_LAUNCH),
36
36
  [import_protocol.PROTOCOL_LLM]: schemeOf(import_protocol.PROTOCOL_LLM),
37
37
  [import_protocol.PROTOCOL_LOCALSTORE]: schemeOf(import_protocol.PROTOCOL_LOCALSTORE),
38
+ [import_protocol.PROTOCOL_OPENBUNDLE]: schemeOf(import_protocol.PROTOCOL_OPENBUNDLE),
38
39
  [import_protocol.PROTOCOL_OPENLINK]: schemeOf(import_protocol.PROTOCOL_OPENLINK),
39
40
  [import_protocol.PROTOCOL_OPENREPO]: schemeOf(import_protocol.PROTOCOL_OPENREPO),
40
41
  [import_protocol.PROTOCOL_RECENTS]: schemeOf(import_protocol.PROTOCOL_RECENTS),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,sBAqBO;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kCAAkB,GAAG,SAAS,kCAAkB;AAAA,EACjD,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,oCAAoB,GAAG,SAAS,oCAAoB;AAAA,EACrD,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AACvC;","names":[]}
1
+ {"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENBUNDLE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENBUNDLE]: schemeOf(PROTOCOL_OPENBUNDLE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA2BA,sBAsBO;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kCAAkB,GAAG,SAAS,kCAAkB;AAAA,EACjD,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,4BAAY,GAAG,SAAS,4BAAY;AAAA,EACrC,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,mCAAmB,GAAG,SAAS,mCAAmB;AAAA,EACnD,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,gCAAgB,GAAG,SAAS,gCAAgB;AAAA,EAC7C,CAAC,iCAAiB,GAAG,SAAS,iCAAiB;AAAA,EAC/C,CAAC,+BAAe,GAAG,SAAS,+BAAe;AAAA,EAC3C,CAAC,oCAAoB,GAAG,SAAS,oCAAoB;AAAA,EACrD,CAAC,6BAAa,GAAG,SAAS,6BAAa;AAAA,EACvC,CAAC,8BAAc,GAAG,SAAS,8BAAc;AAAA,EACzC,CAAC,4BAAY,GAAG,SAAS,4BAAY;AACvC;","names":[]}
@@ -10,6 +10,7 @@ declare const SCHEMES: {
10
10
  readonly "protocol-launch": "launch";
11
11
  readonly "protocol-llm": "llm";
12
12
  readonly "protocol-localstore": "localstore";
13
+ readonly "protocol-openbundle": "openbundle";
13
14
  readonly "protocol-openlink": "openlink";
14
15
  readonly "protocol-openrepo": "openrepo";
15
16
  readonly "protocol-recents": "recents";
@@ -10,6 +10,7 @@ declare const SCHEMES: {
10
10
  readonly "protocol-launch": "launch";
11
11
  readonly "protocol-llm": "llm";
12
12
  readonly "protocol-localstore": "localstore";
13
+ readonly "protocol-openbundle": "openbundle";
13
14
  readonly "protocol-openlink": "openlink";
14
15
  readonly "protocol-openrepo": "openrepo";
15
16
  readonly "protocol-recents": "recents";
@@ -10,6 +10,7 @@ import {
10
10
  PROTOCOL_LAUNCH,
11
11
  PROTOCOL_LLM,
12
12
  PROTOCOL_LOCALSTORE,
13
+ PROTOCOL_OPENBUNDLE,
13
14
  PROTOCOL_OPENLINK,
14
15
  PROTOCOL_OPENREPO,
15
16
  PROTOCOL_RECENTS,
@@ -34,6 +35,7 @@ const SCHEMES = {
34
35
  [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),
35
36
  [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),
36
37
  [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),
38
+ [PROTOCOL_OPENBUNDLE]: schemeOf(PROTOCOL_OPENBUNDLE),
37
39
  [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),
38
40
  [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),
39
41
  [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";AA2BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kBAAkB,GAAG,SAAS,kBAAkB;AAAA,EACjD,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,oBAAoB,GAAG,SAAS,oBAAoB;AAAA,EACrD,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AACvC;","names":[]}
1
+ {"version":3,"sources":["../src/protocolSchemes.ts"],"sourcesContent":["// The `protocol-<scheme>` SCHEMES, derived from the wire names.\n//\n// `protocolRequest(scheme, method, params)` takes the scheme — `'theme'` — while the\n// wire name the frame dispatches on is `'protocol-theme'`; the frame adds the prefix.\n// So the typed service wrappers cannot pass the published `PROTOCOL_*` constant\n// directly, and spelling the scheme inline would put a second, unguarded copy of the\n// name back in the tree — exactly what R3-274c removes.\n//\n// Instead the schemes are *derived* from the wire names, keyed BY the wire name:\n//\n// protocolRequest(SCHEMES[PROTOCOL_THEME], 'set', [{ theme }])\n//\n// Keying by the constant is what makes the derivation unfalsifiable — there is no\n// second place to name the family, so there is no pair to get wrong. `schemeOf`\n// returns a template-literal conditional, so each value has a literal type (`'theme'`),\n// which buys two more things:\n//\n// - a wire name that stops matching `protocol-*` stops compiling here, rather than\n// silently producing an empty scheme at runtime;\n// - `check-protocol-snapshot.mjs` resolves `SCHEMES[PROTOCOL_THEME]` through the type\n// checker exactly like a plain literal, so the call sites stay visible to the gate.\n//\n// One export, deliberately: `./*` is a public subpath, so every name added here is\n// public API forever (ways_of_working §6, additive-only).\n//\n// This module is NOT generated — the derivation is the content — so it lives outside\n// `src/generated/`.\nimport {\n PROTOCOL_ANALYTICS,\n PROTOCOL_CONTRIBUTE,\n PROTOCOL_DND,\n PROTOCOL_EDITOR,\n PROTOCOL_FEED,\n PROTOCOL_FETCH,\n PROTOCOL_IPC,\n PROTOCOL_LAUNCH,\n PROTOCOL_LLM,\n PROTOCOL_LOCALSTORE,\n PROTOCOL_OPENBUNDLE,\n PROTOCOL_OPENLINK,\n PROTOCOL_OPENREPO,\n PROTOCOL_RECENTS,\n PROTOCOL_SECRETS,\n PROTOCOL_SETTINGS,\n PROTOCOL_SPACES,\n PROTOCOL_SPACES_MODE,\n PROTOCOL_TASK,\n PROTOCOL_THEME,\n PROTOCOL_VCS,\n} from './generated/protocol';\n\nconst PREFIX = 'protocol-';\n\n/** The scheme half of a `protocol-<scheme>` wire name. */\ntype SchemeOf<N extends string> = N extends `${typeof PREFIX}${infer S}` ? S : never;\n\n/**\n * `'protocol-theme'` → `'theme'`, as a literal type.\n *\n * The cast is the only place the derivation is asserted rather than computed; the\n * `N extends \\`protocol-${string}\\`` bound is what makes it sound — a wire name that is\n * not scheme-shaped is a compile error at the call, not a `never` at runtime.\n */\nconst schemeOf = <N extends `${typeof PREFIX}${string}`>(name: N): SchemeOf<N> =>\n name.slice(PREFIX.length) as SchemeOf<N>;\n\n/** Every `protocol-*` scheme the SDK speaks, keyed by its wire name. */\nexport const SCHEMES = {\n [PROTOCOL_ANALYTICS]: schemeOf(PROTOCOL_ANALYTICS),\n [PROTOCOL_CONTRIBUTE]: schemeOf(PROTOCOL_CONTRIBUTE),\n [PROTOCOL_DND]: schemeOf(PROTOCOL_DND),\n [PROTOCOL_EDITOR]: schemeOf(PROTOCOL_EDITOR),\n [PROTOCOL_FEED]: schemeOf(PROTOCOL_FEED),\n [PROTOCOL_FETCH]: schemeOf(PROTOCOL_FETCH),\n [PROTOCOL_IPC]: schemeOf(PROTOCOL_IPC),\n [PROTOCOL_LAUNCH]: schemeOf(PROTOCOL_LAUNCH),\n [PROTOCOL_LLM]: schemeOf(PROTOCOL_LLM),\n [PROTOCOL_LOCALSTORE]: schemeOf(PROTOCOL_LOCALSTORE),\n [PROTOCOL_OPENBUNDLE]: schemeOf(PROTOCOL_OPENBUNDLE),\n [PROTOCOL_OPENLINK]: schemeOf(PROTOCOL_OPENLINK),\n [PROTOCOL_OPENREPO]: schemeOf(PROTOCOL_OPENREPO),\n [PROTOCOL_RECENTS]: schemeOf(PROTOCOL_RECENTS),\n [PROTOCOL_SECRETS]: schemeOf(PROTOCOL_SECRETS),\n [PROTOCOL_SETTINGS]: schemeOf(PROTOCOL_SETTINGS),\n [PROTOCOL_SPACES]: schemeOf(PROTOCOL_SPACES),\n [PROTOCOL_SPACES_MODE]: schemeOf(PROTOCOL_SPACES_MODE),\n [PROTOCOL_TASK]: schemeOf(PROTOCOL_TASK),\n [PROTOCOL_THEME]: schemeOf(PROTOCOL_THEME),\n [PROTOCOL_VCS]: schemeOf(PROTOCOL_VCS),\n} as const;\n"],"mappings":";AA2BA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,MAAM,SAAS;AAYf,MAAM,WAAW,CAAwC,SACvD,KAAK,MAAM,OAAO,MAAM;AAGnB,MAAM,UAAU;AAAA,EACrB,CAAC,kBAAkB,GAAG,SAAS,kBAAkB;AAAA,EACjD,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,YAAY,GAAG,SAAS,YAAY;AAAA,EACrC,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,mBAAmB,GAAG,SAAS,mBAAmB;AAAA,EACnD,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,gBAAgB,GAAG,SAAS,gBAAgB;AAAA,EAC7C,CAAC,iBAAiB,GAAG,SAAS,iBAAiB;AAAA,EAC/C,CAAC,eAAe,GAAG,SAAS,eAAe;AAAA,EAC3C,CAAC,oBAAoB,GAAG,SAAS,oBAAoB;AAAA,EACrD,CAAC,aAAa,GAAG,SAAS,aAAa;AAAA,EACvC,CAAC,cAAc,GAAG,SAAS,cAAc;AAAA,EACzC,CAAC,YAAY,GAAG,SAAS,YAAY;AACvC;","names":[]}
package/dist/vcs.cjs CHANGED
@@ -18,6 +18,13 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var vcs_exports = {};
20
20
  __export(vcs_exports, {
21
+ REF_KINDS: () => REF_KINDS,
22
+ bundleCanWrite: () => bundleCanWrite,
23
+ bundleDiffPaths: () => bundleDiffPaths,
24
+ bundleHead: () => bundleHead,
25
+ bundleIsAncestor: () => bundleIsAncestor,
26
+ bundleLog: () => bundleLog,
27
+ bundleRead: () => bundleRead,
21
28
  getVcsState: () => getVcsState,
22
29
  onVcsStateChange: () => onVcsStateChange,
23
30
  refreshDiff: () => refreshDiff,
@@ -26,6 +33,7 @@ __export(vcs_exports, {
26
33
  useVcsState: () => useVcsState
27
34
  });
28
35
  module.exports = __toCommonJS(vcs_exports);
36
+ var import_catalog = require("./catalog");
29
37
  var import_pushChannel = require("./pushChannel");
30
38
  var import_protocolRefusal = require("./protocolRefusal");
31
39
  var import_sandboxUtils = require("./sandboxUtils");
@@ -48,6 +56,47 @@ const parseAgentSession = (v) => {
48
56
  ...s.updatedAt !== void 0 ? { updatedAt: s.updatedAt } : {}
49
57
  };
50
58
  };
59
+ const isStringArray = (v) => Array.isArray(v) && v.every((x) => typeof x === "string");
60
+ const isDiffWarningArray = (v) => Array.isArray(v) && v.every(
61
+ (w) => !!w && typeof w === "object" && typeof w.kind === "string" && typeof w.path === "string" && typeof w.message === "string"
62
+ );
63
+ const REF_KINDS = /* @__PURE__ */ new Set(["branch", "tag", "commit"]);
64
+ const parseTarget = (v) => {
65
+ if (v === null) return null;
66
+ if (!v || typeof v !== "object") return void 0;
67
+ const t = v;
68
+ 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")) {
69
+ return void 0;
70
+ }
71
+ return {
72
+ namespace: t.namespace,
73
+ repository: t.repository,
74
+ ref: t.ref,
75
+ refKind: t.refKind,
76
+ commitSha: t.commitSha,
77
+ defaultBranch: t.defaultBranch
78
+ };
79
+ };
80
+ const parseVcsFacts = (msg) => {
81
+ const out = {};
82
+ const target = parseTarget(msg.target);
83
+ if (target !== void 0) out.target = target;
84
+ const openPR = msg.openPR;
85
+ if (openPR === null) out.openPR = null;
86
+ else if (openPR && typeof openPR === "object" && typeof openPR.number === "number" && Number.isFinite(openPR.number) && typeof openPR.url === "string") {
87
+ out.openPR = { number: openPR.number, url: openPR.url };
88
+ }
89
+ if (msg.defaultSaveMode === "pr" || msg.defaultSaveMode === "direct") out.defaultSaveMode = msg.defaultSaveMode;
90
+ if (msg.canPushUpstream === null || typeof msg.canPushUpstream === "boolean")
91
+ out.canPushUpstream = msg.canPushUpstream;
92
+ if (typeof msg.manifestMissing === "boolean") out.manifestMissing = msg.manifestMissing;
93
+ if (msg.diffError === null || typeof msg.diffError === "string") out.diffError = msg.diffError;
94
+ if (isDiffWarningArray(msg.diffWarnings))
95
+ out.diffWarnings = msg.diffWarnings.map(({ kind, path, message }) => ({ kind, path, message }));
96
+ if (isStringArray(msg.excludedPhantoms)) out.excludedPhantoms = msg.excludedPhantoms;
97
+ if (typeof msg.manifestTruncated === "boolean") out.manifestTruncated = msg.manifestTruncated;
98
+ return out;
99
+ };
51
100
  const channel = (0, import_pushChannel.createPushChannel)({
52
101
  pushType: import_protocol.VCS_STATE,
53
102
  requestType: import_protocol.REQUEST_VCS_STATE,
@@ -62,7 +111,20 @@ const channel = (0, import_pushChannel.createPushChannel)({
62
111
  branch,
63
112
  prs,
64
113
  diffLoading: msg.diffLoading === true,
65
- ...agentSession ? { agentSession } : {}
114
+ ...agentSession ? { agentSession } : {},
115
+ // Each key is named here, not inside the helper, so the protocol snapshot's
116
+ // `reads` records every field this parser consumes.
117
+ ...parseVcsFacts({
118
+ target: msg.target,
119
+ openPR: msg.openPR,
120
+ defaultSaveMode: msg.defaultSaveMode,
121
+ canPushUpstream: msg.canPushUpstream,
122
+ manifestMissing: msg.manifestMissing,
123
+ diffError: msg.diffError,
124
+ diffWarnings: msg.diffWarnings,
125
+ excludedPhantoms: msg.excludedPhantoms,
126
+ manifestTruncated: msg.manifestTruncated
127
+ })
66
128
  };
67
129
  }
68
130
  });
@@ -76,8 +138,51 @@ const vcsRequest = async (method, arg = {}) => {
76
138
  const refreshDiff = () => vcsRequest("refreshDiff");
77
139
  const refreshPRs = () => vcsRequest("refreshPRs");
78
140
  const resetWorkingTree = () => vcsRequest("reset", { confirm: true });
141
+ const fromBase64 = (s) => {
142
+ const bin = atob(s);
143
+ const out = new Uint8Array(bin.length);
144
+ for (let i = 0; i < bin.length; i++) out[i] = bin.charCodeAt(i);
145
+ return out;
146
+ };
147
+ const bundleHead = async (mountId) => {
148
+ const params = { mountId };
149
+ return (await (0, import_catalog.invoke)("vcs:bundleHead", params)).sha;
150
+ };
151
+ const bundleLog = async (mountId, opts = {}) => {
152
+ const params = { mountId };
153
+ if (opts.since !== void 0) params.since = opts.since;
154
+ if (opts.until !== void 0) params.until = opts.until;
155
+ if (opts.max !== void 0) params.max = opts.max;
156
+ return (await (0, import_catalog.invoke)("vcs:bundleLog", params)).commits;
157
+ };
158
+ const bundleIsAncestor = async (mountId, a, b) => {
159
+ const params = { mountId, a, b };
160
+ return (await (0, import_catalog.invoke)("vcs:bundleIsAncestor", params)).ancestor;
161
+ };
162
+ const bundleRead = async (mountId, sha, paths) => {
163
+ const params = { mountId, sha, paths };
164
+ const { files } = await (0, import_catalog.invoke)("vcs:bundleRead", params);
165
+ const out = {};
166
+ for (const [path, b64] of Object.entries(files)) out[path] = b64 === null ? null : fromBase64(b64);
167
+ return out;
168
+ };
169
+ const bundleDiffPaths = async (mountId, from, to) => {
170
+ const params = { mountId, from, to };
171
+ return (await (0, import_catalog.invoke)("vcs:bundleDiffPaths", params)).paths;
172
+ };
173
+ const bundleCanWrite = async (mountId) => {
174
+ const params = { mountId };
175
+ return (await (0, import_catalog.invoke)("vcs:bundleCanWrite", params)).canWrite;
176
+ };
79
177
  // Annotate the CommonJS export names for ESM import in node:
80
178
  0 && (module.exports = {
179
+ REF_KINDS,
180
+ bundleCanWrite,
181
+ bundleDiffPaths,
182
+ bundleHead,
183
+ bundleIsAncestor,
184
+ bundleLog,
185
+ bundleRead,
81
186
  getVcsState,
82
187
  onVcsStateChange,
83
188
  refreshDiff,
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":"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","names":[]}
package/dist/vcs.d.cts 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 };