@cortexkit/opencode-antigravity-auth 3.1.5 → 3.1.8

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 (66) hide show
  1. package/dist/cli.js +73 -118
  2. package/dist/cli.js.map +3 -3
  3. package/dist/cli.meta.json +22 -32
  4. package/dist/index.js +1850 -1854
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +179 -150
  7. package/dist/server.js +1962 -1965
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/claustrum/availability.js +1 -1
  11. package/dist/src/common-auth-embedded/claustrum/custody.js +1 -1
  12. package/dist/src/common-auth-embedded/fs/private-files.js +6 -2
  13. package/dist/src/common-auth-embedded/pi-slot/index.d.ts +1 -1
  14. package/dist/src/common-auth-embedded/pi-slot/index.js +1 -1
  15. package/dist/src/common-auth-embedded/pi-slot/slot.d.ts +6 -9
  16. package/dist/src/common-auth-embedded/pi-slot/slot.js +42 -105
  17. package/dist/src/common-auth-embedded/rpc/index.d.ts +1 -1
  18. package/dist/src/common-auth-embedded/rpc/index.js +1 -1
  19. package/dist/src/common-auth-embedded/rpc/port-file.d.ts +4 -0
  20. package/dist/src/common-auth-embedded/rpc/port-file.js +55 -49
  21. package/dist/src/common-auth-embedded/rpc/rpc-server.js +3 -2
  22. package/dist/src/common-auth-embedded/rpc/startup-sweep.js +32 -0
  23. package/dist/src/common-auth-embedded/source-output.json +53 -44
  24. package/dist/src/ga/server/index.d.ts +1 -1
  25. package/dist/src/ga/server/index.d.ts.map +1 -1
  26. package/dist/src/ga/server/index.js +6 -0
  27. package/dist/src/ga/server/index.js.map +1 -1
  28. package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
  29. package/dist/src/plugin/__fixtures__/verified-store.js +3 -3
  30. package/dist/src/plugin/request-helpers.js +3 -3
  31. package/dist/src/plugin/request-helpers.js.map +1 -1
  32. package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
  33. package/dist/src/plugin/shared/request-services.js +5 -2
  34. package/dist/src/plugin/shared/request-services.js.map +1 -1
  35. package/dist/src/runtime-layout.d.ts.map +1 -1
  36. package/dist/src/runtime-layout.js +5 -2
  37. package/dist/src/runtime-layout.js.map +1 -1
  38. package/dist/src/setup.d.ts.map +1 -1
  39. package/dist/src/setup.js +2 -7
  40. package/dist/src/setup.js.map +1 -1
  41. package/dist/tui-build-map.json +9 -9
  42. package/dist/tui-ga-build-map.json +1 -1
  43. package/dist/types/src/ga/server/index.d.ts +1 -1
  44. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  45. package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
  46. package/dist/types/src/runtime-layout.d.ts.map +1 -1
  47. package/dist/types/src/setup.d.ts.map +1 -1
  48. package/package.json +2 -2
  49. package/src/common-auth-embedded/claustrum/availability.js +1 -1
  50. package/src/common-auth-embedded/claustrum/custody.js +1 -1
  51. package/src/common-auth-embedded/fs/private-files.js +6 -2
  52. package/src/common-auth-embedded/pi-slot/index.d.ts +1 -1
  53. package/src/common-auth-embedded/pi-slot/index.js +1 -1
  54. package/src/common-auth-embedded/pi-slot/slot.d.ts +6 -9
  55. package/src/common-auth-embedded/pi-slot/slot.js +42 -105
  56. package/src/common-auth-embedded/rpc/index.d.ts +1 -1
  57. package/src/common-auth-embedded/rpc/index.js +1 -1
  58. package/src/common-auth-embedded/rpc/port-file.d.ts +4 -0
  59. package/src/common-auth-embedded/rpc/port-file.js +55 -49
  60. package/src/common-auth-embedded/rpc/rpc-server.js +3 -2
  61. package/src/common-auth-embedded/rpc/startup-sweep.js +32 -0
  62. package/src/common-auth-embedded/source-output.json +53 -44
  63. package/src/tui-compiled/common-auth-embedded/fs/private-files.js +6 -2
  64. package/src/tui-compiled/common-auth-embedded/rpc/port-file.js +55 -49
  65. package/src/tui-raw/common-auth-embedded/fs/private-files.js +6 -2
  66. package/src/tui-raw/common-auth-embedded/rpc/port-file.js +55 -49
package/dist/cli.js CHANGED
@@ -610,7 +610,9 @@ function ioCode(detail) {
610
610
  return detail?.code ?? "ERR_PRIVATE_FILE";
611
611
  }
612
612
  function privateFilesUnavailable(cause) {
613
- return Object.assign(new Error("Windows private-files native addon is unavailable", { cause }), {
613
+ return Object.assign(new Error("Windows private-files native addon could not be loaded", {
614
+ cause
615
+ }), {
614
616
  code: "ERR_PRIVATE_FILES_UNAVAILABLE",
615
617
  reason: PRIVATE_FILES_UNAVAILABLE_REASON
616
618
  });
@@ -883,7 +885,11 @@ var init_private_files = __esm({
883
885
  orphanPath;
884
886
  constructor(path2, stage, cause) {
885
887
  const detail = cause;
886
- super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path2} (${PRIVATE_FILES_UNAVAILABLE_REASON}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.` : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
888
+ super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? (
889
+ // The reason stays on `.reason`: its word "unavailable" would make
890
+ // OpenCode 1 retry a plain error carrying this message.
891
+ `Private file refused at ${stage}: ${path2}. The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`
892
+ ) : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
887
893
  this.path = path2;
888
894
  this.stage = stage;
889
895
  this.name = "PrivateFileError";
@@ -5973,7 +5979,7 @@ var init_account_repository = __esm({
5973
5979
  assertPublicationReceipt(plan, receipt2) {
5974
5980
  if (!receipt2)
5975
5981
  return;
5976
- const digest3 = createHash2("sha256").update(canonicalJson(encodePublicationPlan(plan))).digest("hex");
5982
+ const digest2 = createHash2("sha256").update(canonicalJson(encodePublicationPlan(plan))).digest("hex");
5977
5983
  const removed = plan.remove.map((row) => ({
5978
5984
  id: row.id,
5979
5985
  credentialEpoch: row.attribution.credentialEpoch
@@ -5984,7 +5990,7 @@ var init_account_repository = __esm({
5984
5990
  reservation: row.reservation,
5985
5991
  enabled: row.enabled
5986
5992
  }));
5987
- if (receipt2.operationId !== plan.operationId || receipt2.planDigest !== digest3 || !isDeepStrictEqual2(receipt2.removed, removed) || !isDeepStrictEqual2(receipt2.finalized, finalized)) {
5993
+ if (receipt2.operationId !== plan.operationId || receipt2.planDigest !== digest2 || !isDeepStrictEqual2(receipt2.removed, removed) || !isDeepStrictEqual2(receipt2.finalized, finalized)) {
5988
5994
  throw refusal("replacePool", "publication-mismatch", "the native receipt does not prove this replacement plan");
5989
5995
  }
5990
5996
  }
@@ -10963,13 +10969,13 @@ function buildRawRows(config, state, codec, providerCodec) {
10963
10969
  function providerStateFields(account, credential, credentialEpoch2, identity3, codec) {
10964
10970
  if (!isRecord4(account) || !Object.hasOwn(account, PROVIDER_STATE_KEY))
10965
10971
  return {};
10966
- const digest3 = boundProviderStateDigest(account, credential, credentialEpoch2, identity3);
10967
- if (digest3 === void 0)
10972
+ const digest2 = boundProviderStateDigest(account, credential, credentialEpoch2, identity3);
10973
+ if (digest2 === void 0)
10968
10974
  return { providerStateDropped: "uncovered" };
10969
10975
  const value = account[PROVIDER_STATE_KEY];
10970
10976
  if (!codec || !runInsideCodec(() => codec.validate(value)))
10971
10977
  return { providerStateDropped: "invalid" };
10972
- if (providerStateDigest(codec, value) !== digest3)
10978
+ if (providerStateDigest(codec, value) !== digest2)
10973
10979
  return { providerStateDropped: "uncovered" };
10974
10980
  return { providerState: value };
10975
10981
  }
@@ -11963,9 +11969,9 @@ async function planProviderStateIn(tx, codec, operation, row, mutator, declinabl
11963
11969
  nextAccount[CREDENTIAL_STAMP_KEY] = nextStamp;
11964
11970
  } else {
11965
11971
  nextAccount[PROVIDER_STATE_KEY] = next;
11966
- const digest3 = providerStateDigest(codec, next);
11967
- if (stamp.providerState !== digest3)
11968
- nextAccount[CREDENTIAL_STAMP_KEY] = { ...rawStamp, providerState: digest3 };
11972
+ const digest2 = providerStateDigest(codec, next);
11973
+ if (stamp.providerState !== digest2)
11974
+ nextAccount[CREDENTIAL_STAMP_KEY] = { ...rawStamp, providerState: digest2 };
11969
11975
  }
11970
11976
  return {
11971
11977
  kind: "changed",
@@ -16047,7 +16053,7 @@ var init_availability = __esm({
16047
16053
  */
16048
16054
  reason;
16049
16055
  constructor(reason) {
16050
- super("unavailable", "Claustrum scoped operation unavailable");
16056
+ super("unavailable", "Claustrum vault could not be reached");
16051
16057
  this.name = "ClaustrumUnreachableError";
16052
16058
  if (reason === "host-accessor-missing" || reason === "host-accessor-failed")
16053
16059
  this.reason = reason;
@@ -19060,7 +19066,7 @@ var init_custody = __esm({
19060
19066
  throw error;
19061
19067
  if (classifyVaultFailure(error) === "unreachable")
19062
19068
  throw new ClaustrumUnreachableError(error instanceof ClaustrumUnreachableError ? error.reason : void 0);
19063
- throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation unavailable");
19069
+ throw new ClaustrumConsumerError("unavailable", "Claustrum scoped operation failed");
19064
19070
  } finally {
19065
19071
  removeAbortListener?.();
19066
19072
  }
@@ -22723,7 +22729,6 @@ var init_lock = __esm({
22723
22729
  });
22724
22730
 
22725
22731
  // ../core/dist/common-auth-embedded/pi-slot/slot.js
22726
- import { createHash as createHash8 } from "node:crypto";
22727
22732
  import { constants as constants2 } from "node:fs";
22728
22733
  import { lstat as lstat5, mkdir as mkdir10, open as open7, unlink as unlink8 } from "node:fs/promises";
22729
22734
  import { dirname as dirname12, resolve as resolve13 } from "node:path";
@@ -22791,28 +22796,17 @@ function rootSpans(text2) {
22791
22796
  function object2(value) {
22792
22797
  return typeof value === "object" && value !== null && !Array.isArray(value);
22793
22798
  }
22794
- function canonical3(value) {
22795
- if (Array.isArray(value))
22796
- return `[${value.map(canonical3).join(",")}]`;
22797
- if (object2(value)) {
22798
- return `{${Object.keys(value).sort().map((key) => `${JSON.stringify(key)}:${canonical3(value[key])}`).join(",")}}`;
22799
- }
22800
- return JSON.stringify(value);
22801
- }
22802
- function digest2(value) {
22803
- return createHash8("sha256").update(canonical3(value)).digest("hex");
22804
- }
22805
22799
  function code(error) {
22806
22800
  return object2(error) ? error.code : void 0;
22807
22801
  }
22808
- async function safeRead(path2, privateFile = false, afterReadCheck) {
22802
+ async function safeRead(path2, afterReadCheck) {
22809
22803
  if (windowsPrivateFiles) {
22810
22804
  try {
22811
22805
  await afterReadCheck?.(path2);
22812
22806
  const bytes = await readPrivateBuffer(path2, true);
22813
22807
  const text2 = bytes.toString("utf8");
22814
22808
  if (!bytes.equals(Buffer.from(text2)))
22815
- throw new PiSlotError(privateFile ? "invalid-stash" : "invalid-auth");
22809
+ throw new PiSlotError("invalid-auth");
22816
22810
  return text2;
22817
22811
  } catch (error) {
22818
22812
  if (code(error) === "ENOENT")
@@ -22824,7 +22818,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
22824
22818
  try {
22825
22819
  file = await open7(path2, constants2.O_RDONLY | constants2.O_NOFOLLOW);
22826
22820
  const stat16 = await file.stat();
22827
- if (!stat16.isFile() || privateFile && (stat16.mode & 511) !== 384) {
22821
+ if (!stat16.isFile()) {
22828
22822
  throw new PiSlotError("unsafe-path");
22829
22823
  }
22830
22824
  await afterReadCheck?.(path2);
@@ -22835,7 +22829,7 @@ async function safeRead(path2, privateFile = false, afterReadCheck) {
22835
22829
  const bytes = await file.readFile();
22836
22830
  const text2 = bytes.toString("utf8");
22837
22831
  if (!bytes.equals(Buffer.from(text2))) {
22838
- throw new PiSlotError(privateFile ? "invalid-stash" : "invalid-auth");
22832
+ throw new PiSlotError("invalid-auth");
22839
22833
  }
22840
22834
  return text2;
22841
22835
  } catch (error) {
@@ -22870,10 +22864,6 @@ function parseAuth(text2, provider2) {
22870
22864
  throw new PiSlotError("invalid-auth");
22871
22865
  }
22872
22866
  }
22873
- function entryText(auth) {
22874
- const value = auth.property?.value;
22875
- return value ? auth.text.slice(value.offset, value.offset + value.length) : null;
22876
- }
22877
22867
  function replaceEntry(auth, provider2, next) {
22878
22868
  const { text: text2, root, property } = auth;
22879
22869
  const properties = root.children ?? [];
@@ -22932,24 +22922,8 @@ function createPiSlot(options, onStep, hooks) {
22932
22922
  if (authPath === stashPath || stashPath === `${authPath}.lock`) {
22933
22923
  throw new PiSlotError("invalid-options");
22934
22924
  }
22935
- const authIdentity = digest2(authPath);
22936
- const placeholderIdentity = digest2(placeholderKey);
22937
22925
  const placeholder = { type: "api_key", key: placeholderKey };
22938
- const isPlaceholder = (entry) => digest2(entry) === digest2(placeholder);
22939
- async function loadStash() {
22940
- const text2 = await safeRead(stashPath, true, hooks?.afterReadCheck);
22941
- if (text2 === void 0)
22942
- return void 0;
22943
- try {
22944
- const stash = JSON.parse(text2);
22945
- if (stash.version !== 1 || stash.provider !== provider2 || stash.authIdentity !== authIdentity || stash.placeholderIdentity !== placeholderIdentity || stash.entry !== null && !object2(stash.entry) || stash.sha256 !== digest2(stash.entry) || (stash.entry === null ? stash.entryJson !== null : typeof stash.entryJson !== "string" || digest2(JSON.parse(stash.entryJson)) !== stash.sha256)) {
22946
- throw new Error();
22947
- }
22948
- return stash;
22949
- } catch {
22950
- throw new PiSlotError("invalid-stash");
22951
- }
22952
- }
22926
+ const isPlaceholder = (entry) => entry !== null && Object.keys(entry).length === 2 && entry.type === placeholder.type && entry.key === placeholder.key;
22953
22927
  async function locked(fn) {
22954
22928
  let release;
22955
22929
  let assertFresh;
@@ -22997,11 +22971,25 @@ function createPiSlot(options, onStep, hooks) {
22997
22971
  }
22998
22972
  }
22999
22973
  async function load() {
23000
- const auth = parseAuth(await safeRead(authPath, false, hooks?.afterReadCheck) ?? "{}", provider2);
23001
- const stash = await loadStash();
23002
- return { auth, stash };
22974
+ return parseAuth(await safeRead(authPath, hooks?.afterReadCheck) ?? "{}", provider2);
23003
22975
  }
23004
22976
  async function deleteStash(assertLock) {
22977
+ try {
22978
+ const file = await lstat5(stashPath);
22979
+ if (!file.isFile())
22980
+ throw new PiSlotError("unsafe-path");
22981
+ } catch (error) {
22982
+ if (code(error) === "ENOENT")
22983
+ return;
22984
+ throw error;
22985
+ }
22986
+ if (windowsPrivateFiles)
22987
+ await verifySafeDirectory(dirname12(stashPath));
22988
+ else {
22989
+ const dir = await lstat5(dirname12(stashPath));
22990
+ if (!dir.isDirectory() || (dir.mode & 511) !== 448)
22991
+ throw new PiSlotError("unsafe-path");
22992
+ }
23005
22993
  assertLock();
23006
22994
  await unlink8(stashPath);
23007
22995
  await syncDir(dirname12(stashPath));
@@ -23009,58 +22997,27 @@ function createPiSlot(options, onStep, hooks) {
23009
22997
  }
23010
22998
  return {
23011
22999
  inspect: () => locked(async () => {
23012
- const { auth, stash } = await load();
23013
- const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" : !stash || digest2(auth.entry) === stash.sha256 ? "original" : "foreign";
23014
- return { slot, stash: stash ? "valid" : "missing" };
23000
+ const auth = await load();
23001
+ const slot = isPlaceholder(auth.entry) ? "placeholder" : auth.entry === null ? "empty" : "original";
23002
+ return { slot };
23015
23003
  }),
23016
23004
  enterVault: () => locked(async (assertLock) => {
23017
- const { auth, stash } = await load();
23018
- if (isPlaceholder(auth.entry)) {
23019
- if (!stash)
23020
- throw new PiSlotError("missing-stash");
23021
- return;
23022
- }
23023
- if (stash && digest2(auth.entry) !== stash.sha256)
23024
- throw new PiSlotError("conflict");
23025
- if (!stash) {
23026
- if (windowsPrivateFiles)
23027
- await ensurePrivateDirectory(dirname12(stashPath));
23028
- else {
23029
- await mkdir10(dirname12(stashPath), { recursive: true, mode: 448 });
23030
- const dir = await lstat5(dirname12(stashPath));
23031
- if (!dir.isDirectory() || (dir.mode & 511) !== 448)
23032
- throw new PiSlotError("unsafe-path");
23033
- }
23034
- const saved = {
23035
- version: 1,
23036
- provider: provider2,
23037
- authIdentity,
23038
- placeholderIdentity,
23039
- entry: auth.entry,
23040
- entryJson: entryText(auth),
23041
- sha256: digest2(auth.entry)
23042
- };
23043
- await atomicWrite(stashPath, JSON.stringify(saved), assertLock, hooks?.beforeRename);
23044
- onStep?.("stash-written");
23005
+ const auth = await load();
23006
+ if (!isPlaceholder(auth.entry)) {
23007
+ await atomicWrite(authPath, replaceEntry(auth, provider2, JSON.stringify(placeholder)), assertLock, hooks?.beforeRename);
23008
+ onStep?.("auth-written");
23045
23009
  }
23046
- await atomicWrite(authPath, replaceEntry(auth, provider2, JSON.stringify(placeholder)), assertLock, hooks?.beforeRename);
23047
- onStep?.("auth-written");
23010
+ await deleteStash(assertLock);
23048
23011
  }),
23049
23012
  exitVault: () => locked(async (assertLock) => {
23050
- const { auth, stash } = await load();
23051
- if (!stash) {
23052
- if (isPlaceholder(auth.entry))
23053
- throw new PiSlotError("missing-stash");
23054
- return "nothing-to-do";
23055
- }
23056
- if (isPlaceholder(auth.entry)) {
23057
- await atomicWrite(authPath, replaceEntry(auth, provider2, stash.entryJson), assertLock, hooks?.beforeRename);
23013
+ const auth = await load();
23014
+ const cleared = isPlaceholder(auth.entry);
23015
+ if (cleared) {
23016
+ await atomicWrite(authPath, replaceEntry(auth, provider2, null), assertLock, hooks?.beforeRename);
23058
23017
  onStep?.("auth-written");
23059
- } else if (digest2(auth.entry) !== stash.sha256) {
23060
- return "conflict";
23061
23018
  }
23062
23019
  await deleteStash(assertLock);
23063
- return "restored";
23020
+ return cleared ? "cleared" : "nothing-to-do";
23064
23021
  })
23065
23022
  };
23066
23023
  }
@@ -23435,12 +23392,12 @@ var init_project = __esm({
23435
23392
  });
23436
23393
 
23437
23394
  // ../core/dist/quota-manager.js
23438
- import { createHash as createHash9 } from "node:crypto";
23395
+ import { createHash as createHash8 } from "node:crypto";
23439
23396
  function defaultKeyOf(account) {
23440
23397
  if (account.email)
23441
23398
  return `e:${account.email.toLowerCase()}`;
23442
23399
  const token = account.refreshToken || "";
23443
- return `t:${createHash9("sha256").update(token).digest("hex").slice(0, 16)}`;
23400
+ return `t:${createHash8("sha256").update(token).digest("hex").slice(0, 16)}`;
23444
23401
  }
23445
23402
  function createQuotaManager(options) {
23446
23403
  const now = options.now ?? (() => Date.now());
@@ -23673,7 +23630,7 @@ function createQuotaManager(options) {
23673
23630
  };
23674
23631
  }
23675
23632
  function hashKey(key) {
23676
- return createHash9("sha256").update(key).digest("hex").slice(0, 8);
23633
+ return createHash8("sha256").update(key).digest("hex").slice(0, 8);
23677
23634
  }
23678
23635
  function classifyQuotaGroup(modelName, displayName, hasArgonPool = false) {
23679
23636
  if (isGeminiArgonModel(modelName))
@@ -24238,7 +24195,9 @@ function ioCode2(detail) {
24238
24195
  return detail?.code ?? "ERR_PRIVATE_FILE";
24239
24196
  }
24240
24197
  function privateFilesUnavailable2(cause) {
24241
- return Object.assign(new Error("Windows private-files native addon is unavailable", { cause }), {
24198
+ return Object.assign(new Error("Windows private-files native addon could not be loaded", {
24199
+ cause
24200
+ }), {
24242
24201
  code: "ERR_PRIVATE_FILES_UNAVAILABLE",
24243
24202
  reason: PRIVATE_FILES_UNAVAILABLE_REASON2
24244
24203
  });
@@ -24511,7 +24470,11 @@ var init_private_files2 = __esm({
24511
24470
  orphanPath;
24512
24471
  constructor(path2, stage, cause) {
24513
24472
  const detail = cause;
24514
- super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? `Private file refused at ${stage}: ${path2} (${PRIVATE_FILES_UNAVAILABLE_REASON2}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.` : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
24473
+ super(detail?.code === "ERR_PRIVATE_FILES_UNAVAILABLE" ? (
24474
+ // The reason stays on `.reason`: its word "unavailable" would make
24475
+ // OpenCode 1 retry a plain error carrying this message.
24476
+ `Private file refused at ${stage}: ${path2}. The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`
24477
+ ) : `Private file refused at ${stage}: ${path2} (${detail?.reason ?? detail?.code ?? "io-error"}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
24515
24478
  this.path = path2;
24516
24479
  this.stage = stage;
24517
24480
  this.name = "PrivateFileError";
@@ -25557,7 +25520,7 @@ __export(runtime_layout_exports, {
25557
25520
  runStoreMove: () => runStoreMove,
25558
25521
  writeStateHomeStoreForward: () => writeStateHomeStoreForward
25559
25522
  });
25560
- import { createHash as createHash10 } from "node:crypto";
25523
+ import { createHash as createHash9 } from "node:crypto";
25561
25524
  import {
25562
25525
  chmod as chmod4,
25563
25526
  mkdir as mkdir12,
@@ -25571,8 +25534,8 @@ import {
25571
25534
  import { basename as basename6, dirname as dirname16, join as join14, resolve as resolve17 } from "node:path";
25572
25535
  function refusalMessage(stateDir, errorClass2) {
25573
25536
  if (errorClass2 === "ERR_PRIVATE_FILES_SECURITY")
25574
- return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it (${errorClass2}). Replace it with a plain folder of your own, then restart OpenCode.`;
25575
- return `antigravity-auth cannot start: it could not settle where its vault files live in ${stateDir} (${errorClass2}). Check that this folder can be created and written by your user, then restart OpenCode.`;
25537
+ return `antigravity-auth cannot start: ${stateDir} is not a folder only your user can access, or it is a link, so the plugin will not use it. Replace it with a plain folder of your own, then restart OpenCode. Check the plugin log for details.`;
25538
+ return `antigravity-auth cannot start: it could not settle where its vault files live in ${stateDir}. Check that this folder can be created and written by your user, then restart OpenCode. Check the plugin log for details.`;
25576
25539
  }
25577
25540
  function foreignFolder(stateDir, identity3) {
25578
25541
  return new RuntimeLayoutRefusal(
@@ -26382,7 +26345,7 @@ function layoutFiles(location, accountFile) {
26382
26345
  };
26383
26346
  }
26384
26347
  function sha256(bytes) {
26385
- return createHash10("sha256").update(bytes).digest("hex");
26348
+ return createHash9("sha256").update(bytes).digest("hex");
26386
26349
  }
26387
26350
  function vaultStateFile(files) {
26388
26351
  return {
@@ -27160,7 +27123,7 @@ var init_storage = __esm({
27160
27123
  });
27161
27124
 
27162
27125
  // src/runtime-paths.ts
27163
- import { createHash as createHash11 } from "node:crypto";
27126
+ import { createHash as createHash10 } from "node:crypto";
27164
27127
  import { existsSync as existsSync4, promises as fs2, readFileSync as readFileSync2, realpathSync as realpathSync2 } from "node:fs";
27165
27128
  import { homedir as homedir5 } from "node:os";
27166
27129
  import { dirname as dirname18, join as join16, resolve as resolve19 } from "node:path";
@@ -27189,7 +27152,7 @@ function runtimeLayoutLocation(configDir = getConfigDir()) {
27189
27152
  configDir,
27190
27153
  stateHomeDir: isDefaultConfigDir ? join16(root, "opencode") : join16(
27191
27154
  root,
27192
- `opencode-${createHash11("sha256").update(key).digest("hex").slice(0, 16)}`
27155
+ `opencode-${createHash10("sha256").update(key).digest("hex").slice(0, 16)}`
27193
27156
  ),
27194
27157
  isDefaultConfigDir
27195
27158
  };
@@ -29151,7 +29114,7 @@ async function select2(terminal, items, options) {
29151
29114
  }
29152
29115
 
29153
29116
  // src/common-auth-embedded/claustrum/enrollment.js
29154
- import { createHash as createHash12, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
29117
+ import { createHash as createHash11, randomBytes as randomBytes3, randomUUID as randomUUID15 } from "node:crypto";
29155
29118
  import { constants as fsConstants2 } from "node:fs";
29156
29119
  import { chmod as chmod5, mkdir as mkdir14, open as open10, readFile as readFile12, realpath as realpath4, rename as rename12, stat as stat13, unlink as unlink13 } from "node:fs/promises";
29157
29120
  import { basename as basename8, dirname as dirname20, extname as extname2, isAbsolute as isAbsolute4, join as join19, resolve as resolve22 } from "node:path";
@@ -30892,7 +30855,7 @@ var ClaustrumEnrollmentManager2 = class {
30892
30855
  }
30893
30856
  if (!state.requestId) {
30894
30857
  try {
30895
- const requestSecretHash = createHash12("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
30858
+ const requestSecretHash = createHash11("sha256").update(Buffer.from(state.requestSecret, "hex")).digest("hex");
30896
30859
  const proposal = {
30897
30860
  name: state.proposedName,
30898
30861
  requestSecretHash
@@ -32827,20 +32790,12 @@ Setup has not completed the OpenCode 2 native Google connection.
32827
32790
  });
32828
32791
  } else if (selected === "pi") {
32829
32792
  const { openPiSlot: openPiSlot2 } = await loadCommonAuthPiSlot();
32830
- const inspection = await openPiSlot2({
32793
+ await openPiSlot2({
32831
32794
  authPath: nativeAuthPath("pi", context),
32832
32795
  stashPath: join23(piDir, "google-login-stash.json"),
32833
32796
  provider: ANTIGRAVITY_PROVIDER_ID,
32834
32797
  placeholderKey: PI_PLACEHOLDER_KEY
32835
32798
  }).inspect();
32836
- if (inspection.slot === "foreign")
32837
- throw new Error(
32838
- "Pi has a different login from its saved stash; resolve the conflict before vault setup."
32839
- );
32840
- if (inspection.slot === "placeholder" && inspection.stash === "missing")
32841
- throw new Error(
32842
- "Pi holds a vault marker without its saved login stash; resolve it before vault setup."
32843
- );
32844
32799
  }
32845
32800
  }
32846
32801
  if (forceLogin && context.mode === "local" && context.hosts.includes("opencode") && context.opencodeGeneration !== "2") {