@cortexkit/opencode-antigravity-auth 3.1.8 → 3.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/cli.js +256 -179
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +88 -44
- package/dist/index.js +5466 -4823
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +333 -269
- package/dist/server.js +1321 -608
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
- package/dist/src/common-auth-embedded/claustrum/custody.js +31 -14
- package/dist/src/common-auth-embedded/fs/private-files.js +8 -3
- package/dist/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/opencode2/index.js +1 -1
- package/dist/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/dist/src/common-auth-embedded/opencode2/install.js +14 -4
- package/dist/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
- package/dist/src/common-auth-embedded/routing-accessor/index.js +123 -17
- package/dist/src/common-auth-embedded/setup/process-fence.js +20 -3
- package/dist/src/common-auth-embedded/source-output.json +44 -44
- package/dist/src/common-auth-embedded/store/mutate.js +34 -13
- package/dist/src/ga/server/index.d.ts +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +58 -19
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.d.ts.map +1 -1
- package/dist/src/plugin/__fixtures__/release-model-ids.js +1 -0
- package/dist/src/plugin/__fixtures__/release-model-ids.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +102 -80
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/config/models.d.ts +1 -1
- package/dist/src/plugin/config/models.d.ts.map +1 -1
- package/dist/src/plugin/config/models.js +10 -5
- package/dist/src/plugin/config/models.js.map +1 -1
- package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/src/plugin/fetch-interceptor.js +27 -13
- package/dist/src/plugin/fetch-interceptor.js.map +1 -1
- package/dist/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/src/plugin/ga-location-services.js +21 -11
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.d.ts.map +1 -1
- package/dist/src/plugin/index.js +13 -5
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +8 -8
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
- package/dist/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
- package/dist/src/plugin/shared/opencode-retry-hints.js +22 -0
- package/dist/src/plugin/shared/opencode-retry-hints.js.map +1 -0
- package/dist/src/plugin/shared/request-services.d.ts +2 -0
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +410 -112
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
- package/dist/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing-purpose.js +13 -7
- package/dist/src/plugin/shared/vault-routing-purpose.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing.d.ts +8 -1
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing.js +12 -4
- package/dist/src/plugin/shared/vault-routing.js.map +1 -1
- package/dist/src/plugin/storage.d.ts +1 -0
- package/dist/src/plugin/storage.d.ts.map +1 -1
- package/dist/src/plugin/storage.js +3 -3
- package/dist/src/plugin/storage.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts +6 -13
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +19 -16
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/tui-build-map.json +5 -5
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
- package/dist/types/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
- package/dist/types/src/ga/server/index.d.ts +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/config/models.d.ts +1 -1
- package/dist/types/src/plugin/config/models.d.ts.map +1 -1
- package/dist/types/src/plugin/fetch-interceptor.d.ts.map +1 -1
- package/dist/types/src/plugin/ga-location-services.d.ts.map +1 -1
- package/dist/types/src/plugin/index.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts +2 -0
- package/dist/types/src/plugin/shared/opencode-retry-hints.d.ts.map +1 -0
- package/dist/types/src/plugin/shared/request-services.d.ts +2 -0
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts +6 -2
- package/dist/types/src/plugin/shared/vault-routing-purpose.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts +8 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/types/src/plugin/storage.d.ts +1 -0
- package/dist/types/src/plugin/storage.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts +6 -13
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.d.ts +16 -5
- package/src/common-auth-embedded/claustrum/custody.js +31 -14
- package/src/common-auth-embedded/fs/private-files.js +8 -3
- package/src/common-auth-embedded/opencode2/index.d.ts +1 -1
- package/src/common-auth-embedded/opencode2/index.js +1 -1
- package/src/common-auth-embedded/opencode2/install.d.ts +6 -1
- package/src/common-auth-embedded/opencode2/install.js +14 -4
- package/src/common-auth-embedded/opencode2/types.d.ts +10 -7
- package/src/common-auth-embedded/routing-accessor/index.d.ts +71 -16
- package/src/common-auth-embedded/routing-accessor/index.js +123 -17
- package/src/common-auth-embedded/setup/process-fence.js +20 -3
- package/src/common-auth-embedded/source-output.json +44 -44
- package/src/common-auth-embedded/store/mutate.js +34 -13
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +8 -3
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +8 -3
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { statSync } from 'node:fs';
|
|
2
2
|
import { win32 } from 'node:path';
|
|
3
|
+
import { createLogger } from '../logger/index.js';
|
|
3
4
|
import { defaultCommandRunner } from './command-runner.js';
|
|
4
5
|
const WINDOWS_CIM_TIMEOUT_MS = 45_000;
|
|
6
|
+
const log = createLogger('setup-process-fence');
|
|
5
7
|
// Native Windows PowerShell 5.1 on ARM took 22–44 s per process query, with
|
|
6
8
|
// one cold CIM timeout at 45.8 s; pwsh took less than a second. See
|
|
7
9
|
// .cortexkit/internal-docs/investigations/windows-arm-process-fence/report.md.
|
|
@@ -207,7 +209,7 @@ export async function listSetupProcesses(runner = defaultCommandRunner, options
|
|
|
207
209
|
options.onStep?.({ ...inspection });
|
|
208
210
|
}
|
|
209
211
|
};
|
|
210
|
-
const inspectCim = (args) => {
|
|
212
|
+
const inspectCim = async (args) => {
|
|
211
213
|
const pwsh = win32.resolve(windowsEnv(env, 'ProgramFiles') ?? 'C:\\Program Files', 'PowerShell', '7', 'pwsh.exe');
|
|
212
214
|
const program = (options.isFile ?? isFile)(pwsh) ? 'pwsh' : 'powershell';
|
|
213
215
|
const arm64 = (windowsEnv(env, 'PROCESSOR_ARCHITEW6432') ??
|
|
@@ -215,9 +217,24 @@ export async function listSetupProcesses(runner = defaultCommandRunner, options
|
|
|
215
217
|
const slow = program === 'powershell' && arm64;
|
|
216
218
|
if (slow)
|
|
217
219
|
options.onProgress?.('Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.');
|
|
218
|
-
|
|
220
|
+
const file = program === 'pwsh'
|
|
219
221
|
? pwsh
|
|
220
|
-
: win32.resolve(system32, 'WindowsPowerShell', 'v1.0', 'powershell.exe')
|
|
222
|
+
: win32.resolve(system32, 'WindowsPowerShell', 'v1.0', 'powershell.exe');
|
|
223
|
+
const timeoutMs = slow
|
|
224
|
+
? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS
|
|
225
|
+
: WINDOWS_CIM_TIMEOUT_MS;
|
|
226
|
+
const started = performance.now();
|
|
227
|
+
const result = await inspect('CIM', file, args, timeoutMs, program);
|
|
228
|
+
const remaining = Math.floor(timeoutMs - (performance.now() - started));
|
|
229
|
+
if ((result.exitCode === 3221225477 || result.exitCode === -1073741819) &&
|
|
230
|
+
!result.timedOut &&
|
|
231
|
+
!result.signal &&
|
|
232
|
+
!result.spawnError &&
|
|
233
|
+
remaining > 0) {
|
|
234
|
+
log.warn('Windows process query crashed with an access violation; retrying once');
|
|
235
|
+
return inspect('CIM', file, args, remaining, program);
|
|
236
|
+
}
|
|
237
|
+
return result;
|
|
221
238
|
};
|
|
222
239
|
try {
|
|
223
240
|
if (windows && options.hostImagesOnly) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.55.1",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
|
-
"archiveBytes":
|
|
6
|
+
"archiveBytes": 503150,
|
|
7
7
|
"publicRoots": {
|
|
8
8
|
"./rpc": {
|
|
9
9
|
"types": "./dist/rpc/index.d.ts",
|
|
@@ -74,16 +74,16 @@
|
|
|
74
74
|
"import": "./src/quota-sidebar/index.tsx"
|
|
75
75
|
}
|
|
76
76
|
},
|
|
77
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
78
|
-
"tarballSha256": "
|
|
79
|
-
"sri": "sha512-
|
|
80
|
-
"shasum": "
|
|
77
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.55.1.tgz",
|
|
78
|
+
"tarballSha256": "80a78298cecc98c5b3b7eb3534e2eb77353d582d997962efe9df27a79ef12589",
|
|
79
|
+
"sri": "sha512-koCwml7Kbf2u6fIIaNmHbDOp2B15hGQ/9kZUB3VSYlBtvyp9ldDUJU1yVGUmin5gzwTzAF9c7g/OWPlWNqgMPw==",
|
|
80
|
+
"shasum": "703dd80358754aa4c3d1b9d6a0d3b9d150860daa",
|
|
81
81
|
"canonicalFiles": 257,
|
|
82
|
-
"canonicalBytes":
|
|
82
|
+
"canonicalBytes": 1524660,
|
|
83
83
|
"generator": {
|
|
84
84
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
85
85
|
"version": 4,
|
|
86
|
-
"sha256": "
|
|
86
|
+
"sha256": "53208174ea6d4a497b8ea378bcb8712971742272d2fd766ea4617866dea60f4b"
|
|
87
87
|
},
|
|
88
88
|
"files": [
|
|
89
89
|
{
|
|
@@ -281,17 +281,17 @@
|
|
|
281
281
|
{
|
|
282
282
|
"source": "package/dist/claustrum/custody.d.ts",
|
|
283
283
|
"output": "claustrum/custody.d.ts",
|
|
284
|
-
"bytes":
|
|
285
|
-
"sourceSha256": "
|
|
286
|
-
"outputSha256": "
|
|
284
|
+
"bytes": 18601,
|
|
285
|
+
"sourceSha256": "9c34f311ef87563256138b5aa070216d9dd027c6ddf4110aba630ba14157bc16",
|
|
286
|
+
"outputSha256": "9c34f311ef87563256138b5aa070216d9dd027c6ddf4110aba630ba14157bc16",
|
|
287
287
|
"transform": "verbatim"
|
|
288
288
|
},
|
|
289
289
|
{
|
|
290
290
|
"source": "package/dist/claustrum/custody.js",
|
|
291
291
|
"output": "claustrum/custody.js",
|
|
292
|
-
"bytes":
|
|
293
|
-
"sourceSha256": "
|
|
294
|
-
"outputSha256": "
|
|
292
|
+
"bytes": 44266,
|
|
293
|
+
"sourceSha256": "72d08a16f7fb27c26813501b0e89cddfdf640b9aeac8b89e9c7f9c92663db59c",
|
|
294
|
+
"outputSha256": "72d08a16f7fb27c26813501b0e89cddfdf640b9aeac8b89e9c7f9c92663db59c",
|
|
295
295
|
"transform": "verbatim"
|
|
296
296
|
},
|
|
297
297
|
{
|
|
@@ -681,9 +681,9 @@
|
|
|
681
681
|
{
|
|
682
682
|
"source": "package/dist/fs/private-files.js",
|
|
683
683
|
"output": "fs/private-files.js",
|
|
684
|
-
"bytes":
|
|
685
|
-
"sourceSha256": "
|
|
686
|
-
"outputSha256": "
|
|
684
|
+
"bytes": 15526,
|
|
685
|
+
"sourceSha256": "8456644c921d76d1946c9c04a6784308dfbc4c22be19d88d5b15bf629d5f4226",
|
|
686
|
+
"outputSha256": "8456644c921d76d1946c9c04a6784308dfbc4c22be19d88d5b15bf629d5f4226",
|
|
687
687
|
"transform": "verbatim"
|
|
688
688
|
},
|
|
689
689
|
{
|
|
@@ -897,33 +897,33 @@
|
|
|
897
897
|
{
|
|
898
898
|
"source": "package/dist/opencode2/index.d.ts",
|
|
899
899
|
"output": "opencode2/index.d.ts",
|
|
900
|
-
"bytes":
|
|
901
|
-
"sourceSha256": "
|
|
902
|
-
"outputSha256": "
|
|
900
|
+
"bytes": 1325,
|
|
901
|
+
"sourceSha256": "03baf6a3ea7b26545ec20a03588ac7f30830c84e15f4bbde51d268218ff3e284",
|
|
902
|
+
"outputSha256": "03baf6a3ea7b26545ec20a03588ac7f30830c84e15f4bbde51d268218ff3e284",
|
|
903
903
|
"transform": "verbatim"
|
|
904
904
|
},
|
|
905
905
|
{
|
|
906
906
|
"source": "package/dist/opencode2/index.js",
|
|
907
907
|
"output": "opencode2/index.js",
|
|
908
|
-
"bytes":
|
|
909
|
-
"sourceSha256": "
|
|
910
|
-
"outputSha256": "
|
|
908
|
+
"bytes": 485,
|
|
909
|
+
"sourceSha256": "0a68a5e9af890954e96172fd475ea20e6e137ad20feb0c5ad014d4ea33dfd198",
|
|
910
|
+
"outputSha256": "0a68a5e9af890954e96172fd475ea20e6e137ad20feb0c5ad014d4ea33dfd198",
|
|
911
911
|
"transform": "verbatim"
|
|
912
912
|
},
|
|
913
913
|
{
|
|
914
914
|
"source": "package/dist/opencode2/install.d.ts",
|
|
915
915
|
"output": "opencode2/install.d.ts",
|
|
916
|
-
"bytes":
|
|
917
|
-
"sourceSha256": "
|
|
918
|
-
"outputSha256": "
|
|
916
|
+
"bytes": 4212,
|
|
917
|
+
"sourceSha256": "edb14a4f60ef24c85b5e4f41f94b66b5594f38628c65145841fa4bcf1bf319f6",
|
|
918
|
+
"outputSha256": "edb14a4f60ef24c85b5e4f41f94b66b5594f38628c65145841fa4bcf1bf319f6",
|
|
919
919
|
"transform": "verbatim"
|
|
920
920
|
},
|
|
921
921
|
{
|
|
922
922
|
"source": "package/dist/opencode2/install.js",
|
|
923
923
|
"output": "opencode2/install.js",
|
|
924
|
-
"bytes":
|
|
925
|
-
"sourceSha256": "
|
|
926
|
-
"outputSha256": "
|
|
924
|
+
"bytes": 65592,
|
|
925
|
+
"sourceSha256": "fc98e6bd26a6835d118666b1f27fc0598dbe9f929d793b2fe619d3be7375b988",
|
|
926
|
+
"outputSha256": "fc98e6bd26a6835d118666b1f27fc0598dbe9f929d793b2fe619d3be7375b988",
|
|
927
927
|
"transform": "verbatim"
|
|
928
928
|
},
|
|
929
929
|
{
|
|
@@ -961,9 +961,9 @@
|
|
|
961
961
|
{
|
|
962
962
|
"source": "package/dist/opencode2/types.d.ts",
|
|
963
963
|
"output": "opencode2/types.d.ts",
|
|
964
|
-
"bytes":
|
|
965
|
-
"sourceSha256": "
|
|
966
|
-
"outputSha256": "
|
|
964
|
+
"bytes": 32971,
|
|
965
|
+
"sourceSha256": "955be769b8aacbc13f51d16a94639658424b3e02e29c2a252b4b872bfde9096f",
|
|
966
|
+
"outputSha256": "955be769b8aacbc13f51d16a94639658424b3e02e29c2a252b4b872bfde9096f",
|
|
967
967
|
"transform": "verbatim"
|
|
968
968
|
},
|
|
969
969
|
{
|
|
@@ -1697,9 +1697,9 @@
|
|
|
1697
1697
|
{
|
|
1698
1698
|
"source": "package/dist/setup/process-fence.js",
|
|
1699
1699
|
"output": "setup/process-fence.js",
|
|
1700
|
-
"bytes":
|
|
1701
|
-
"sourceSha256": "
|
|
1702
|
-
"outputSha256": "
|
|
1700
|
+
"bytes": 16615,
|
|
1701
|
+
"sourceSha256": "008c119bd1cbac550370933093c89c0c8020010239b71d9407dacbb8d6125cd7",
|
|
1702
|
+
"outputSha256": "008c119bd1cbac550370933093c89c0c8020010239b71d9407dacbb8d6125cd7",
|
|
1703
1703
|
"transform": "verbatim"
|
|
1704
1704
|
},
|
|
1705
1705
|
{
|
|
@@ -1857,9 +1857,9 @@
|
|
|
1857
1857
|
{
|
|
1858
1858
|
"source": "package/dist/store/mutate.js",
|
|
1859
1859
|
"output": "store/mutate.js",
|
|
1860
|
-
"bytes":
|
|
1861
|
-
"sourceSha256": "
|
|
1862
|
-
"outputSha256": "
|
|
1860
|
+
"bytes": 21075,
|
|
1861
|
+
"sourceSha256": "e2b69c850dface416ff3ebc54e2f57fd5c36b5346055b90195493cada75b6901",
|
|
1862
|
+
"outputSha256": "e2b69c850dface416ff3ebc54e2f57fd5c36b5346055b90195493cada75b6901",
|
|
1863
1863
|
"transform": "verbatim"
|
|
1864
1864
|
},
|
|
1865
1865
|
{
|
|
@@ -2129,17 +2129,17 @@
|
|
|
2129
2129
|
{
|
|
2130
2130
|
"source": "package/dist/routing-accessor/index.d.ts",
|
|
2131
2131
|
"output": "routing-accessor/index.d.ts",
|
|
2132
|
-
"bytes":
|
|
2133
|
-
"sourceSha256": "
|
|
2134
|
-
"outputSha256": "
|
|
2132
|
+
"bytes": 10377,
|
|
2133
|
+
"sourceSha256": "9273612fe071bfdf502d38cc07f5eeca8ecc60d082fa5f578788c7e856a1b15e",
|
|
2134
|
+
"outputSha256": "9273612fe071bfdf502d38cc07f5eeca8ecc60d082fa5f578788c7e856a1b15e",
|
|
2135
2135
|
"transform": "verbatim"
|
|
2136
2136
|
},
|
|
2137
2137
|
{
|
|
2138
2138
|
"source": "package/dist/routing-accessor/index.js",
|
|
2139
2139
|
"output": "routing-accessor/index.js",
|
|
2140
|
-
"bytes":
|
|
2141
|
-
"sourceSha256": "
|
|
2142
|
-
"outputSha256": "
|
|
2140
|
+
"bytes": 22848,
|
|
2141
|
+
"sourceSha256": "13f13701391958c2e1f52d614a78da8d276594a90ee54b4f6af33bf81b4ca669",
|
|
2142
|
+
"outputSha256": "13f13701391958c2e1f52d614a78da8d276594a90ee54b4f6af33bf81b4ca669",
|
|
2143
2143
|
"transform": "verbatim"
|
|
2144
2144
|
}
|
|
2145
2145
|
],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { setTimeout as
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
2
|
import { AtomicSyncError, syncJsonFile, writeJsonAtomic, writeJsonAtomicTracked, } from '../fs/atomic-write.js';
|
|
3
|
-
import { readPrivateText, windowsPrivateFiles } from '../fs/private-files.js';
|
|
3
|
+
import { isWindowsSharingViolation, readPrivateText, windowsPrivateFiles, } from '../fs/private-files.js';
|
|
4
4
|
import { LockContentionError, LockOwnershipError } from '../fs/with-lock.js';
|
|
5
5
|
import { PoolOperationError, } from './errors.js';
|
|
6
6
|
import { callFailureHook } from './hooks.js';
|
|
@@ -8,14 +8,25 @@ import { LockStack, } from './refresh-lock.js';
|
|
|
8
8
|
import { assertNotReserved } from './reserved.js';
|
|
9
9
|
import { CREDENTIAL_STAMP_KEY, classifyConfig, classifyState, ensureEntries, entryIn, isRecord, LEGACY_STORE_VERSION, POOL_KEY, POOL_ROWS_KEY, POOL_SCHEMA_VERSION, retireEpochsIn, rosterOf, rosterRowIn, setEntryIn, } from './schema.js';
|
|
10
10
|
import { completeTornRows, loadRows } from './torn.js';
|
|
11
|
+
// About 1 s in total. A replace usually clears in milliseconds, but an
|
|
12
|
+
// OpenCode 2 turn ends if the first pool read of a request fails, and a
|
|
13
|
+
// scanner opening the new file can hold it longer.
|
|
14
|
+
const sharingRetryDelays = [5, 10, 20, 40, 80, 160, 320, 400];
|
|
11
15
|
async function readText(path) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
for (let attempt = 0;; attempt++) {
|
|
17
|
+
try {
|
|
18
|
+
return await readPrivateText(path, windowsPrivateFiles);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === 'ENOENT')
|
|
22
|
+
return undefined;
|
|
23
|
+
const wait = sharingRetryDelays[attempt];
|
|
24
|
+
// An atomic replace can briefly block a Windows read. Permission
|
|
25
|
+
// refusals are not evidence of a replace and must still surface at once.
|
|
26
|
+
if (wait === undefined || !isWindowsSharingViolation(error))
|
|
27
|
+
throw error;
|
|
28
|
+
await delay(wait);
|
|
29
|
+
}
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
32
|
function parseFile(text) {
|
|
@@ -39,12 +50,22 @@ export async function readPoolConfig(path) {
|
|
|
39
50
|
*/
|
|
40
51
|
export async function readPool(ctx) {
|
|
41
52
|
for (let attempt = 0; attempt < 3; attempt++) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
let configText;
|
|
54
|
+
let stateText;
|
|
55
|
+
let checkedConfigText;
|
|
56
|
+
try {
|
|
57
|
+
configText = await readText(ctx.configPath);
|
|
58
|
+
stateText = await readText(ctx.statePath);
|
|
59
|
+
checkedConfigText = await readText(ctx.configPath);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (isWindowsSharingViolation(error))
|
|
63
|
+
break;
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
45
66
|
if (configText !== checkedConfigText) {
|
|
46
67
|
if (attempt < 2)
|
|
47
|
-
await
|
|
68
|
+
await delay(2 + Math.floor(Math.random() * 4));
|
|
48
69
|
continue;
|
|
49
70
|
}
|
|
50
71
|
const config = classifyConfig(parseFile(configText));
|
|
@@ -70,6 +70,10 @@ function loadBackend() {
|
|
|
70
70
|
});
|
|
71
71
|
return backend;
|
|
72
72
|
}
|
|
73
|
+
function isSharingIoError(detail) {
|
|
74
|
+
return (detail?.reason === 'io-error' &&
|
|
75
|
+
(detail.win32Code === 32 || detail.win32Code === 303));
|
|
76
|
+
}
|
|
73
77
|
export class PrivateFileError extends Error {
|
|
74
78
|
path;
|
|
75
79
|
stage;
|
|
@@ -88,7 +92,9 @@ export class PrivateFileError extends Error {
|
|
|
88
92
|
? // The reason stays on `.reason`: its word "unavailable" would make
|
|
89
93
|
// OpenCode 1 retry a plain error carrying this message.
|
|
90
94
|
`Private file refused at ${stage}: ${path}. 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.`
|
|
91
|
-
:
|
|
95
|
+
: isSharingIoError(detail)
|
|
96
|
+
? `Private file busy at ${stage}: ${path}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).`
|
|
97
|
+
: `Private file refused at ${stage}: ${path} (${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 });
|
|
92
98
|
this.path = path;
|
|
93
99
|
this.stage = stage;
|
|
94
100
|
this.name = 'PrivateFileError';
|
|
@@ -101,8 +107,7 @@ export class PrivateFileError extends Error {
|
|
|
101
107
|
export function isWindowsSharingViolation(error) {
|
|
102
108
|
return (windowsPrivateFiles &&
|
|
103
109
|
error instanceof PrivateFileError &&
|
|
104
|
-
error
|
|
105
|
-
(error.win32Code === 32 || error.win32Code === 303));
|
|
110
|
+
isSharingIoError(error));
|
|
106
111
|
}
|
|
107
112
|
export async function privateOperation(path, stage, operation) {
|
|
108
113
|
try {
|
|
@@ -70,6 +70,10 @@ function loadBackend() {
|
|
|
70
70
|
});
|
|
71
71
|
return backend;
|
|
72
72
|
}
|
|
73
|
+
function isSharingIoError(detail) {
|
|
74
|
+
return (detail?.reason === 'io-error' &&
|
|
75
|
+
(detail.win32Code === 32 || detail.win32Code === 303));
|
|
76
|
+
}
|
|
73
77
|
export class PrivateFileError extends Error {
|
|
74
78
|
path;
|
|
75
79
|
stage;
|
|
@@ -88,7 +92,9 @@ export class PrivateFileError extends Error {
|
|
|
88
92
|
? // The reason stays on `.reason`: its word "unavailable" would make
|
|
89
93
|
// OpenCode 1 retry a plain error carrying this message.
|
|
90
94
|
`Private file refused at ${stage}: ${path}. 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.`
|
|
91
|
-
:
|
|
95
|
+
: isSharingIoError(detail)
|
|
96
|
+
? `Private file busy at ${stage}: ${path}. Another process was replacing or deleting this file at the same moment (Windows error ${detail.win32Code}).`
|
|
97
|
+
: `Private file refused at ${stage}: ${path} (${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 });
|
|
92
98
|
this.path = path;
|
|
93
99
|
this.stage = stage;
|
|
94
100
|
this.name = 'PrivateFileError';
|
|
@@ -101,8 +107,7 @@ export class PrivateFileError extends Error {
|
|
|
101
107
|
export function isWindowsSharingViolation(error) {
|
|
102
108
|
return (windowsPrivateFiles &&
|
|
103
109
|
error instanceof PrivateFileError &&
|
|
104
|
-
error
|
|
105
|
-
(error.win32Code === 32 || error.win32Code === 303));
|
|
110
|
+
isSharingIoError(error));
|
|
106
111
|
}
|
|
107
112
|
export async function privateOperation(path, stage, operation) {
|
|
108
113
|
try {
|