@cortexkit/opencode-antigravity-auth 3.1.10 → 3.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +357 -58
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +37 -32
- package/dist/index.js +986 -426
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +86 -63
- package/dist/server.js +1131 -551
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/cli.d.ts +3 -1
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +19 -6
- package/dist/src/cli.js.map +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +32 -0
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/dist/src/common-auth-embedded/claustrum/custody.js +145 -8
- package/dist/src/common-auth-embedded/claustrum/host.js +8 -0
- package/dist/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/src/common-auth-embedded/claustrum/hub.js +10 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/routing-accessor/index.js +5 -3
- package/dist/src/common-auth-embedded/source-output.json +35 -35
- package/dist/src/ga/rpc/protocol.d.ts +11 -5
- package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/src/ga/rpc/protocol.js +11 -3
- package/dist/src/ga/rpc/protocol.js.map +1 -1
- package/dist/src/ga/server/index.d.ts.map +1 -1
- package/dist/src/ga/server/index.js +30 -14
- package/dist/src/ga/server/index.js.map +1 -1
- package/dist/src/ga/tui/host-ga.d.ts +2 -1
- package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
- package/dist/src/ga/tui/host-ga.js +9 -4
- package/dist/src/ga/tui/host-ga.js.map +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/src/plugin/account-access.d.ts +1 -0
- package/dist/src/plugin/account-access.d.ts.map +1 -1
- package/dist/src/plugin/account-access.js +28 -0
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/src/plugin/auth-loader.js +21 -12
- package/dist/src/plugin/auth-loader.js.map +1 -1
- package/dist/src/plugin/background-quota-refresh.d.ts +11 -24
- package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-quota-refresh.js +54 -60
- package/dist/src/plugin/background-quota-refresh.js.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/src/plugin/background-vault-quota-refresh.js +6 -3
- package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
- package/dist/src/plugin/cache/signature-cache.d.ts +3 -0
- package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/src/plugin/cache/signature-cache.js +73 -46
- package/dist/src/plugin/cache/signature-cache.js.map +1 -1
- package/dist/src/plugin/cache.d.ts.map +1 -1
- package/dist/src/plugin/cache.js +17 -7
- package/dist/src/plugin/cache.js.map +1 -1
- package/dist/src/plugin/core/streaming/displayed-thinking.d.ts +23 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.js +58 -0
- package/dist/src/plugin/core/streaming/displayed-thinking.js.map +1 -0
- package/dist/src/plugin/fetch/warmup.d.ts +9 -2
- package/dist/src/plugin/fetch/warmup.d.ts.map +1 -1
- package/dist/src/plugin/fetch/warmup.js +22 -14
- package/dist/src/plugin/fetch/warmup.js.map +1 -1
- package/dist/src/plugin/quota.d.ts +10 -2
- package/dist/src/plugin/quota.d.ts.map +1 -1
- package/dist/src/plugin/quota.js +38 -10
- package/dist/src/plugin/quota.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +51 -19
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts +12 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +27 -42
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +4 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +142 -24
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/runtime.d.ts +3 -4
- package/dist/src/plugin/shared/runtime.d.ts.map +1 -1
- package/dist/src/plugin/shared/runtime.js +2 -2
- package/dist/src/plugin/shared/runtime.js.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.d.ts +13 -7
- package/dist/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-request-credentials.js +24 -18
- package/dist/src/plugin/shared/vault-request-credentials.js.map +1 -1
- package/dist/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
- package/dist/src/setup.d.ts +3 -0
- package/dist/src/setup.d.ts.map +1 -1
- package/dist/src/setup.js +18 -6
- package/dist/src/setup.js.map +1 -1
- package/dist/src/sidebar-state.d.ts +20 -7
- package/dist/src/sidebar-state.d.ts.map +1 -1
- package/dist/src/sidebar-state.js +57 -8
- package/dist/src/sidebar-state.js.map +1 -1
- package/dist/src/tui.d.ts.map +1 -1
- package/dist/src/tui.js +43 -23
- package/dist/src/tui.js.map +1 -1
- package/dist/tui-build-map.json +9 -9
- package/dist/tui-ga-build-map.json +5 -5
- package/dist/types/src/cli.d.ts +3 -1
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/ga/rpc/protocol.d.ts +11 -5
- package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
- package/dist/types/src/ga/server/index.d.ts.map +1 -1
- package/dist/types/src/plugin/account-access.d.ts +1 -0
- package/dist/types/src/plugin/account-access.d.ts.map +1 -1
- package/dist/types/src/plugin/auth-loader.d.ts.map +1 -1
- package/dist/types/src/plugin/background-quota-refresh.d.ts +11 -24
- package/dist/types/src/plugin/background-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/background-vault-quota-refresh.d.ts.map +1 -1
- package/dist/types/src/plugin/cache/signature-cache.d.ts +3 -0
- package/dist/types/src/plugin/cache/signature-cache.d.ts.map +1 -1
- package/dist/types/src/plugin/cache.d.ts.map +1 -1
- package/dist/types/src/plugin/core/streaming/displayed-thinking.d.ts +23 -0
- package/dist/types/src/plugin/core/streaming/displayed-thinking.d.ts.map +1 -0
- package/dist/types/src/plugin/fetch/warmup.d.ts +9 -2
- package/dist/types/src/plugin/fetch/warmup.d.ts.map +1 -1
- package/dist/types/src/plugin/quota.d.ts +10 -2
- package/dist/types/src/plugin/quota.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts +12 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +4 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/runtime.d.ts +3 -4
- package/dist/types/src/plugin/shared/runtime.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts +13 -7
- package/dist/types/src/plugin/shared/vault-request-credentials.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-sidebar-projection.d.ts.map +1 -1
- package/dist/types/src/setup.d.ts +3 -0
- package/dist/types/src/setup.d.ts.map +1 -1
- package/dist/types/src/sidebar-state.d.ts +20 -7
- package/dist/types/src/sidebar-state.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/common-auth-embedded/claustrum/consumer.d.ts +20 -1
- package/src/common-auth-embedded/claustrum/consumer.js +32 -0
- package/src/common-auth-embedded/claustrum/custody.d.ts +39 -1
- package/src/common-auth-embedded/claustrum/custody.js +145 -8
- package/src/common-auth-embedded/claustrum/host.js +8 -0
- package/src/common-auth-embedded/claustrum/hub.d.ts +3 -2
- package/src/common-auth-embedded/claustrum/hub.js +10 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/routing-accessor/index.js +5 -3
- package/src/common-auth-embedded/source-output.json +35 -35
- package/src/sidebar-state.ts +77 -8
- package/src/tui-compiled/sidebar-state.js +40 -1
- package/src/tui-compiled/tui.js +49 -24
- package/src/tui-ga-compiled/host-ga.js +11 -5
- package/src/tui-ga-raw/host-ga.tsx +17 -6
- package/src/tui-raw/sidebar-state.js +40 -1
- package/src/tui-raw/tui.tsx +40 -24
- package/src/tui.tsx +40 -24
|
@@ -111,12 +111,13 @@ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
|
|
|
111
111
|
logger?: ClaustrumLogger;
|
|
112
112
|
}
|
|
113
113
|
/** What a lease may do with the shared custody. */
|
|
114
|
-
export type ClaustrumLeasedCustody = Pick<ClaustrumScopedCustody, 'authorize' | 'reportFailure' | 'reportUsage' | 'usageReportState' | 'forget' | 'keptReceiptState'>;
|
|
114
|
+
export type ClaustrumLeasedCustody = Pick<ClaustrumScopedCustody, 'authorize' | 'reportFailure' | 'reportCondition' | 'clearCondition' | 'reportUsage' | 'usageReportState' | 'forget' | 'keptReceiptState'>;
|
|
115
115
|
/**
|
|
116
116
|
* One acquisition of the hub's shared custody. `custody` throws `closed`
|
|
117
117
|
* after `release()`, and once the connection it belongs to ended for any
|
|
118
118
|
* reason, vault mode going off included. Best-effort `reportUsage` instead
|
|
119
|
-
* ignores reports through an ended lease
|
|
119
|
+
* ignores reports through an ended lease, and the condition calls resolve
|
|
120
|
+
* `skipped` through one. `release()` is idempotent.
|
|
120
121
|
*/
|
|
121
122
|
export interface CustodyLease {
|
|
122
123
|
readonly custody: ClaustrumLeasedCustody;
|
|
@@ -533,6 +533,16 @@ export class ClaustrumDiscoveryHub {
|
|
|
533
533
|
check();
|
|
534
534
|
return custody.reportFailure(attempt, status, source);
|
|
535
535
|
},
|
|
536
|
+
reportCondition: async (attempt, input) => {
|
|
537
|
+
if (state.released || generation.ended)
|
|
538
|
+
return 'skipped';
|
|
539
|
+
return custody.reportCondition(attempt, input);
|
|
540
|
+
},
|
|
541
|
+
clearCondition: async (attempt) => {
|
|
542
|
+
if (state.released || generation.ended)
|
|
543
|
+
return 'skipped';
|
|
544
|
+
return custody.clearCondition(attempt);
|
|
545
|
+
},
|
|
536
546
|
reportUsage: (input) => {
|
|
537
547
|
if (!state.released && !generation.ended)
|
|
538
548
|
custody.reportUsage(input);
|
|
@@ -3,7 +3,7 @@ import type { ClaustrumScopedClient } from './custody.js';
|
|
|
3
3
|
export { ClaustrumCredentialError, type ClaustrumReporterSource, type EnrollmentTokenFile, } from '@cortexkit/claustrum-client';
|
|
4
4
|
export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, type VaultFailureClass, } from './availability.js';
|
|
5
5
|
export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, DEFAULT_CONNECT_TIMEOUT_MS, type SendOptions, } from './consumer.js';
|
|
6
|
-
export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, VAULT_RECEIPT_WAIT_MS, VAULT_YOUNG_OUTAGE_MS, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
|
|
6
|
+
export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, VAULT_RECEIPT_WAIT_MS, VAULT_YOUNG_OUTAGE_MS, type VaultConditionOutcome, type VaultConditionReason, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
|
|
7
7
|
export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, type ClaustrumRequestedGrant, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, validEnrollmentDisplayName, validEnrollmentRequestedGrants, vaultAuthority, } from './enrollment.js';
|
|
8
8
|
export { ClaustrumConsumerError, type ClaustrumConsumerFailureKind, type ClaustrumLogger, } from './errors.js';
|
|
9
9
|
export { connectVaultHost, hasVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from './host.js';
|
|
@@ -184,8 +184,6 @@ function candidateView(candidates) {
|
|
|
184
184
|
accounts.push({ account_id: accountId, credential_id: credentialId });
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
if (accounts.length === 0)
|
|
188
|
-
return undefined;
|
|
189
187
|
const lines = accounts
|
|
190
188
|
.map(({ account_id, credential_id }) => Buffer.from(`${account_id}\t${credential_id}\n`, 'utf8'))
|
|
191
189
|
.sort(Buffer.compare);
|
|
@@ -290,7 +288,11 @@ export async function askRouting(input) {
|
|
|
290
288
|
request.warm_credential = warmCredentialId;
|
|
291
289
|
}
|
|
292
290
|
const candidates = candidateView(input.candidates);
|
|
293
|
-
|
|
291
|
+
// A first ask with nothing usable sends no view, so routing is unrestricted
|
|
292
|
+
// as before. A continue ask always sends one: an empty view after the only
|
|
293
|
+
// account was refused tells routing nothing is left to offer, where a
|
|
294
|
+
// missing view would let it hand back the refused account.
|
|
295
|
+
if (candidates.accounts.length > 0 || request.mode === 'continue')
|
|
294
296
|
request.candidates = candidates;
|
|
295
297
|
const pending = accountFor.call(handle, request, { deadlineMs });
|
|
296
298
|
if (!isObject(pending) || typeof pending.then !== 'function')
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.56.1",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
|
-
"archiveBytes":
|
|
6
|
+
"archiveBytes": 505365,
|
|
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.56.1.tgz",
|
|
78
|
+
"tarballSha256": "32ce3a411b3a8f8034e4c5eb5b79550d7529834567520943ca962d1b13512aa0",
|
|
79
|
+
"sri": "sha512-5JTuezeHbodZacTXEB6mjoicODWsCYh6J/APShcB11/92KAz8xJjcLG+MVmDK+QtL2VmBNwa7yhHCFiKqqIKww==",
|
|
80
|
+
"shasum": "f8b2504321810ab59a448effc2c485c601a039de",
|
|
81
81
|
"canonicalFiles": 257,
|
|
82
|
-
"canonicalBytes":
|
|
82
|
+
"canonicalBytes": 1535775,
|
|
83
83
|
"generator": {
|
|
84
84
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
85
85
|
"version": 4,
|
|
86
|
-
"sha256": "
|
|
86
|
+
"sha256": "4b56cc532fc60af40ef271ae24ab502d7b03e6b546f968066fe7997fc454de60"
|
|
87
87
|
},
|
|
88
88
|
"files": [
|
|
89
89
|
{
|
|
@@ -265,33 +265,33 @@
|
|
|
265
265
|
{
|
|
266
266
|
"source": "package/dist/claustrum/consumer.d.ts",
|
|
267
267
|
"output": "claustrum/consumer.d.ts",
|
|
268
|
-
"bytes":
|
|
269
|
-
"sourceSha256": "
|
|
270
|
-
"outputSha256": "
|
|
268
|
+
"bytes": 15756,
|
|
269
|
+
"sourceSha256": "3118eb0112ebb100c4f0ec8528eae840fee076b99e39d30c9c204042a9e2fc5e",
|
|
270
|
+
"outputSha256": "3118eb0112ebb100c4f0ec8528eae840fee076b99e39d30c9c204042a9e2fc5e",
|
|
271
271
|
"transform": "verbatim"
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
274
|
"source": "package/dist/claustrum/consumer.js",
|
|
275
275
|
"output": "claustrum/consumer.js",
|
|
276
|
-
"bytes":
|
|
277
|
-
"sourceSha256": "
|
|
278
|
-
"outputSha256": "
|
|
276
|
+
"bytes": 42662,
|
|
277
|
+
"sourceSha256": "c257a0ed546c9e55ee93a77a3d2247d8e65274f0dfb944b676f9da1ad23a3df5",
|
|
278
|
+
"outputSha256": "c257a0ed546c9e55ee93a77a3d2247d8e65274f0dfb944b676f9da1ad23a3df5",
|
|
279
279
|
"transform": "verbatim"
|
|
280
280
|
},
|
|
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": 20105,
|
|
285
|
+
"sourceSha256": "3e18a29925889dc0bcae4a23b57df3b6bf683ba9a3e58fe95d3132ca50a2417e",
|
|
286
|
+
"outputSha256": "3e18a29925889dc0bcae4a23b57df3b6bf683ba9a3e58fe95d3132ca50a2417e",
|
|
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": 50079,
|
|
293
|
+
"sourceSha256": "fdb2f9a4eee791b44d6bb953d31bb7f560159302e2f83932c03964e1ae24cf22",
|
|
294
|
+
"outputSha256": "fdb2f9a4eee791b44d6bb953d31bb7f560159302e2f83932c03964e1ae24cf22",
|
|
295
295
|
"transform": "verbatim"
|
|
296
296
|
},
|
|
297
297
|
{
|
|
@@ -353,33 +353,33 @@
|
|
|
353
353
|
{
|
|
354
354
|
"source": "package/dist/claustrum/host.js",
|
|
355
355
|
"output": "claustrum/host.js",
|
|
356
|
-
"bytes":
|
|
357
|
-
"sourceSha256": "
|
|
358
|
-
"outputSha256": "
|
|
356
|
+
"bytes": 4993,
|
|
357
|
+
"sourceSha256": "d2e197db15bfe75de41a892709f4d7d69248293bd80bb5a720b9035e961ec6d7",
|
|
358
|
+
"outputSha256": "d2e197db15bfe75de41a892709f4d7d69248293bd80bb5a720b9035e961ec6d7",
|
|
359
359
|
"transform": "verbatim"
|
|
360
360
|
},
|
|
361
361
|
{
|
|
362
362
|
"source": "package/dist/claustrum/hub.d.ts",
|
|
363
363
|
"output": "claustrum/hub.d.ts",
|
|
364
|
-
"bytes":
|
|
365
|
-
"sourceSha256": "
|
|
366
|
-
"outputSha256": "
|
|
364
|
+
"bytes": 9816,
|
|
365
|
+
"sourceSha256": "71196e15856a31236ae0f77f2e8b37d5216e5f7d42170a1eda27a154d1542b67",
|
|
366
|
+
"outputSha256": "71196e15856a31236ae0f77f2e8b37d5216e5f7d42170a1eda27a154d1542b67",
|
|
367
367
|
"transform": "verbatim"
|
|
368
368
|
},
|
|
369
369
|
{
|
|
370
370
|
"source": "package/dist/claustrum/hub.js",
|
|
371
371
|
"output": "claustrum/hub.js",
|
|
372
|
-
"bytes":
|
|
373
|
-
"sourceSha256": "
|
|
374
|
-
"outputSha256": "
|
|
372
|
+
"bytes": 48839,
|
|
373
|
+
"sourceSha256": "31af42582b6e9694ce334403bc3105fce8864c12d69146f4938a7300a1f718ce",
|
|
374
|
+
"outputSha256": "31af42582b6e9694ce334403bc3105fce8864c12d69146f4938a7300a1f718ce",
|
|
375
375
|
"transform": "verbatim"
|
|
376
376
|
},
|
|
377
377
|
{
|
|
378
378
|
"source": "package/dist/claustrum/index.d.ts",
|
|
379
379
|
"output": "claustrum/index.d.ts",
|
|
380
|
-
"bytes":
|
|
381
|
-
"sourceSha256": "
|
|
382
|
-
"outputSha256": "
|
|
380
|
+
"bytes": 5128,
|
|
381
|
+
"sourceSha256": "522249e709781475b8458130a72ea6885e16e8ea59821100bead9f23ae34ddcb",
|
|
382
|
+
"outputSha256": "522249e709781475b8458130a72ea6885e16e8ea59821100bead9f23ae34ddcb",
|
|
383
383
|
"transform": "verbatim"
|
|
384
384
|
},
|
|
385
385
|
{
|
|
@@ -2137,9 +2137,9 @@
|
|
|
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": 23158,
|
|
2141
|
+
"sourceSha256": "728aa2d9dd16d7e71ff3583aa767b74818850bdd4dbdca1f15e85d0c0c1b09bd",
|
|
2142
|
+
"outputSha256": "728aa2d9dd16d7e71ff3583aa767b74818850bdd4dbdca1f15e85d0c0c1b09bd",
|
|
2143
2143
|
"transform": "verbatim"
|
|
2144
2144
|
}
|
|
2145
2145
|
],
|
package/src/sidebar-state.ts
CHANGED
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
* 100 entries within 24h.
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
|
-
import { chmodSync, mkdirSync, readFileSync } from 'node:fs'
|
|
42
|
+
import { chmodSync, mkdirSync, readFileSync, statSync } from 'node:fs'
|
|
43
|
+
import { readFile, stat } from 'node:fs/promises'
|
|
43
44
|
import { homedir } from 'node:os'
|
|
44
45
|
import { dirname, join } from 'node:path'
|
|
45
46
|
// Subpath imports (not the barrel): this file ships into the TUI's
|
|
@@ -230,13 +231,7 @@ export function getSidebarStateFile(): string {
|
|
|
230
231
|
|
|
231
232
|
/**
|
|
232
233
|
* Read and normalize the sidebar state file. Returns the default state when
|
|
233
|
-
* the file is missing, unreadable, malformed, or schema-incompatible
|
|
234
|
-
* must never throw out of `readSidebarState()`, the panel just shows
|
|
235
|
-
* "Awaiting Antigravity state" and the next poll retries.
|
|
236
|
-
*
|
|
237
|
-
* The read is sync on purpose: the TUI polls on a 2-second timer and the file
|
|
238
|
-
* is tiny (a handful of accounts); an async read here would just add race
|
|
239
|
-
* surface area against Solid's reactive render cycle.
|
|
234
|
+
* the file is missing, unreadable, malformed, or schema-incompatible.
|
|
240
235
|
*/
|
|
241
236
|
export function readSidebarState(
|
|
242
237
|
path: string = getSidebarStateFile(),
|
|
@@ -247,6 +242,80 @@ export function readSidebarState(
|
|
|
247
242
|
} catch {
|
|
248
243
|
return { ...DEFAULT_SIDEBAR_STATE }
|
|
249
244
|
}
|
|
245
|
+
return parseSidebarState(raw)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/** Identifies one version of the state file; see `fileSignature`. */
|
|
249
|
+
export interface SidebarStateBaseline {
|
|
250
|
+
path: string
|
|
251
|
+
signature: string | null
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// Atomic replacement can leave size and mtime unchanged; inode identifies
|
|
255
|
+
// the new file, and ctime invalidates the read on permission changes.
|
|
256
|
+
function fileSignature(info: {
|
|
257
|
+
dev: bigint
|
|
258
|
+
ino: bigint
|
|
259
|
+
size: bigint
|
|
260
|
+
mtimeNs: bigint
|
|
261
|
+
ctimeNs: bigint
|
|
262
|
+
}): string {
|
|
263
|
+
return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Read the state file synchronously with the signature of the version read.
|
|
268
|
+
* The sidebar uses it once at mount, so the very first frame already has the
|
|
269
|
+
* quota bars; the later polls go through `createSidebarStateReader`.
|
|
270
|
+
*/
|
|
271
|
+
export function readSidebarStateWithBaseline(
|
|
272
|
+
path: string = getSidebarStateFile(),
|
|
273
|
+
): { state: SidebarStateV1; baseline: SidebarStateBaseline } {
|
|
274
|
+
try {
|
|
275
|
+
const signature = fileSignature(statSync(path, { bigint: true }))
|
|
276
|
+
const raw = readFileSync(path, 'utf-8')
|
|
277
|
+
return { state: parseSidebarState(raw), baseline: { path, signature } }
|
|
278
|
+
} catch {
|
|
279
|
+
return {
|
|
280
|
+
state: { ...DEFAULT_SIDEBAR_STATE },
|
|
281
|
+
baseline: { path, signature: null },
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Create a reader for one polling consumer. Polls must not overlap. A reader
|
|
288
|
+
* started from a `baseline` returns nothing until the file changes from it.
|
|
289
|
+
*/
|
|
290
|
+
export function createSidebarStateReader(
|
|
291
|
+
baseline?: SidebarStateBaseline,
|
|
292
|
+
): (path?: string) => Promise<SidebarStateV1 | undefined> {
|
|
293
|
+
let previousPath: string | undefined = baseline?.path
|
|
294
|
+
let previousSignature: string | null = baseline?.signature ?? null
|
|
295
|
+
|
|
296
|
+
return async (path = getSidebarStateFile()) => {
|
|
297
|
+
let raw: string
|
|
298
|
+
let signature: string
|
|
299
|
+
try {
|
|
300
|
+
signature = fileSignature(await stat(path, { bigint: true }))
|
|
301
|
+
if (path === previousPath && signature === previousSignature) return
|
|
302
|
+
raw = await readFile(path, 'utf-8')
|
|
303
|
+
} catch {
|
|
304
|
+
const alreadyUnavailable =
|
|
305
|
+
path === previousPath && previousSignature === null
|
|
306
|
+
previousPath = path
|
|
307
|
+
previousSignature = null
|
|
308
|
+
return alreadyUnavailable ? undefined : { ...DEFAULT_SIDEBAR_STATE }
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const loaded = parseSidebarState(raw)
|
|
312
|
+
previousPath = path
|
|
313
|
+
previousSignature = signature
|
|
314
|
+
return loaded
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
function parseSidebarState(raw: string): SidebarStateV1 {
|
|
250
319
|
let parsed: unknown
|
|
251
320
|
try {
|
|
252
321
|
parsed = JSON.parse(raw)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { chmodSync, mkdirSync, readFileSync } from "node:fs";
|
|
1
|
+
import { chmodSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { writeJsonAtomic } from "@cortexkit/antigravity-auth-core/atomic-write";
|
|
@@ -44,6 +45,44 @@ export function readSidebarState(path = getSidebarStateFile()) {
|
|
|
44
45
|
} catch {
|
|
45
46
|
return { ...DEFAULT_SIDEBAR_STATE };
|
|
46
47
|
}
|
|
48
|
+
return parseSidebarState(raw);
|
|
49
|
+
}
|
|
50
|
+
function fileSignature(info) {
|
|
51
|
+
return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`;
|
|
52
|
+
}
|
|
53
|
+
export function readSidebarStateWithBaseline(path = getSidebarStateFile()) {
|
|
54
|
+
try {
|
|
55
|
+
const signature = fileSignature(statSync(path, { bigint: !0 })), raw = readFileSync(path, "utf-8");
|
|
56
|
+
return { state: parseSidebarState(raw), baseline: { path, signature } };
|
|
57
|
+
} catch {
|
|
58
|
+
return {
|
|
59
|
+
state: { ...DEFAULT_SIDEBAR_STATE },
|
|
60
|
+
baseline: { path, signature: null }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function createSidebarStateReader(baseline) {
|
|
65
|
+
let previousPath = baseline?.path, previousSignature = baseline?.signature ?? null;
|
|
66
|
+
return async (path = getSidebarStateFile()) => {
|
|
67
|
+
let raw, signature;
|
|
68
|
+
try {
|
|
69
|
+
signature = fileSignature(await stat(path, { bigint: !0 }));
|
|
70
|
+
if (path === previousPath && signature === previousSignature)
|
|
71
|
+
return;
|
|
72
|
+
raw = await readFile(path, "utf-8");
|
|
73
|
+
} catch {
|
|
74
|
+
const alreadyUnavailable = path === previousPath && previousSignature === null;
|
|
75
|
+
previousPath = path;
|
|
76
|
+
previousSignature = null;
|
|
77
|
+
return alreadyUnavailable ? void 0 : { ...DEFAULT_SIDEBAR_STATE };
|
|
78
|
+
}
|
|
79
|
+
const loaded = parseSidebarState(raw);
|
|
80
|
+
previousPath = path;
|
|
81
|
+
previousSignature = signature;
|
|
82
|
+
return loaded;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function parseSidebarState(raw) {
|
|
47
86
|
let parsed;
|
|
48
87
|
try {
|
|
49
88
|
parsed = JSON.parse(raw);
|
package/src/tui-compiled/tui.js
CHANGED
|
@@ -48,7 +48,7 @@ import { fileURLToPath } from "node:url";
|
|
|
48
48
|
import { createSlot } from "opentui:runtime-module:%40opentui%2Fsolid";
|
|
49
49
|
import { createSignal, onCleanup, onMount } from "opentui:runtime-module:solid-js";
|
|
50
50
|
import { getRpcDir } from "./rpc/rpc-dir.js";
|
|
51
|
-
import {
|
|
51
|
+
import { createSidebarStateReader, readSidebarStateWithBaseline } from "./sidebar-state.js";
|
|
52
52
|
import { createTuiFileLogger } from "./tui/file-logger.js";
|
|
53
53
|
import { createV1MenuTransport, dispatchV1Notification } from "./tui/host-v1.js";
|
|
54
54
|
import { AntigravitySidebar } from "./tui/sidebar-frame.js";
|
|
@@ -276,7 +276,8 @@ function formatError(value) {
|
|
|
276
276
|
|
|
277
277
|
export function SidebarPanel(props) {
|
|
278
278
|
const logger = resolveLogger(props.logger);
|
|
279
|
-
const
|
|
279
|
+
const clock = props.now ?? Date.now;
|
|
280
|
+
const [now, setNow] = createSignal(clock());
|
|
280
281
|
const pollMs = props.pollIntervalMs ?? POLL_INTERVAL_MS;
|
|
281
282
|
const controller = props.controller ?? getSidebarController();
|
|
282
283
|
const collapsed = controller.collapsed;
|
|
@@ -287,32 +288,56 @@ export function SidebarPanel(props) {
|
|
|
287
288
|
const theme = () => props.theme?.() ?? FALLBACK_THEME;
|
|
288
289
|
const [state, setState] = createSignal({
|
|
289
290
|
loaded: EMPTY_STATE,
|
|
290
|
-
lastReadAt: 0,
|
|
291
291
|
lastError: null
|
|
292
292
|
});
|
|
293
|
-
const refresh = () => {
|
|
294
|
-
try {
|
|
295
|
-
const loaded = readSidebarState(props.stateFile);
|
|
296
|
-
setState({
|
|
297
|
-
loaded,
|
|
298
|
-
lastReadAt: now(),
|
|
299
|
-
lastError: null
|
|
300
|
-
});
|
|
301
|
-
} catch (error) {
|
|
302
|
-
logger.warn('sidebar-poll-failed', {
|
|
303
|
-
error: formatError(error)
|
|
304
|
-
});
|
|
305
|
-
setState(prev => ({
|
|
306
|
-
...prev,
|
|
307
|
-
lastReadAt: now(),
|
|
308
|
-
lastError: formatError(error)
|
|
309
|
-
}));
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
293
|
onMount(() => {
|
|
313
|
-
|
|
294
|
+
// Read synchronously once so the first frame already draws the quota bars;
|
|
295
|
+
// the polls below reread only when the file has changed since.
|
|
296
|
+
const first = readSidebarStateWithBaseline(props.stateFile);
|
|
297
|
+
setState({
|
|
298
|
+
loaded: first.state,
|
|
299
|
+
lastError: null
|
|
300
|
+
});
|
|
301
|
+
const readChanged = createSidebarStateReader(first.baseline);
|
|
302
|
+
let mounted = true;
|
|
303
|
+
let reading = false;
|
|
304
|
+
const refresh = async () => {
|
|
305
|
+
if (!mounted) return;
|
|
306
|
+
setNow(clock());
|
|
307
|
+
if (reading) return;
|
|
308
|
+
reading = true;
|
|
309
|
+
try {
|
|
310
|
+
const loaded = await readChanged(props.stateFile);
|
|
311
|
+
if (!mounted) return;
|
|
312
|
+
if (loaded) setState({
|
|
313
|
+
loaded,
|
|
314
|
+
lastError: null
|
|
315
|
+
});else if (state().lastError !== null) {
|
|
316
|
+
setState(prev => ({
|
|
317
|
+
...prev,
|
|
318
|
+
lastError: null
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
} catch (error) {
|
|
322
|
+
if (!mounted) return;
|
|
323
|
+
const message = formatError(error);
|
|
324
|
+
logger.warn('sidebar-poll-failed', {
|
|
325
|
+
error: message
|
|
326
|
+
});
|
|
327
|
+
setState(prev => ({
|
|
328
|
+
...prev,
|
|
329
|
+
lastError: message
|
|
330
|
+
}));
|
|
331
|
+
} finally {
|
|
332
|
+
reading = false;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
void refresh();
|
|
314
336
|
const interval = setInterval(refresh, pollMs);
|
|
315
|
-
onCleanup(() =>
|
|
337
|
+
onCleanup(() => {
|
|
338
|
+
mounted = false;
|
|
339
|
+
clearInterval(interval);
|
|
340
|
+
});
|
|
316
341
|
});
|
|
317
342
|
const lastError = () => state().lastError ?? state().loaded.lastError;
|
|
318
343
|
const currentRoute = () => {
|
|
@@ -358,14 +358,15 @@ export function parseGaStateAnswer(raw) {
|
|
|
358
358
|
issues: ['output.kind: unknown answer']
|
|
359
359
|
};
|
|
360
360
|
}
|
|
361
|
-
keys(output, ['version', 'kind', 'generation', 'scope', 'reset', 'cursor', 'dropped', 'more', 'notifications', 'readSeq', 'accountsStatus', 'accounts', 'route', 'status', 'settings'], ['vaultHostStatus'], 'output', issues);
|
|
361
|
+
keys(output, ['version', 'kind', 'generation', 'scope', 'reset', 'cursor', 'dropped', 'more', 'notifications', 'readSeq', 'accountsStatus', 'accounts', 'route', 'status', 'settings'], ['vaultHostStatus', 'queueID'], 'output', issues);
|
|
362
362
|
if (!isCursor(output.readSeq)) issues.push('output.readSeq: expected a count');
|
|
363
363
|
if (Object.hasOwn(output, 'vaultHostStatus') && output.vaultHostStatus !== 'Served by Thalamus') issues.push('output.vaultHostStatus: expected the hosted vault status');
|
|
364
364
|
checkAccountsStatus(output.accountsStatus, 'output.accountsStatus', issues);
|
|
365
365
|
checkSettings(output.settings, 'output.settings', issues);
|
|
366
366
|
checkGeneration(output.generation, 'output.generation', issues);
|
|
367
|
+
if (Object.hasOwn(output, 'queueID')) checkGeneration(output.queueID, 'output.queueID', issues);
|
|
367
368
|
checkScope(output.scope, 'output.scope', issues);
|
|
368
|
-
if (output.reset !== null && output.reset !== 'initial' && output.reset !== 'generation-changed' && output.reset !== 'cursor-ahead') {
|
|
369
|
+
if (output.reset !== null && output.reset !== 'initial' && output.reset !== 'generation-changed' && output.reset !== 'queue-changed' && output.reset !== 'cursor-ahead') {
|
|
369
370
|
issues.push('output.reset: unknown reset');
|
|
370
371
|
}
|
|
371
372
|
if (!isCursor(output.cursor)) issues.push('output.cursor: expected a cursor');
|
|
@@ -472,11 +473,13 @@ export function createGaLocationClient(options) {
|
|
|
472
473
|
if (isDisposed) throw new GaClientDisposedError();
|
|
473
474
|
const sentEpoch = epoch;
|
|
474
475
|
const key = scopeKey(scope);
|
|
476
|
+
const previous = cursors.get(key);
|
|
475
477
|
const raw = await call('state', {
|
|
476
478
|
version: GA_RPC_VERSION,
|
|
477
479
|
generation,
|
|
478
480
|
scope,
|
|
479
|
-
cursor:
|
|
481
|
+
cursor: previous?.cursor ?? 0,
|
|
482
|
+
queueID: previous?.queueID ?? null
|
|
480
483
|
});
|
|
481
484
|
if (isDisposed || sentEpoch !== epoch) return {
|
|
482
485
|
kind: 'dropped'
|
|
@@ -504,7 +507,10 @@ export function createGaLocationClient(options) {
|
|
|
504
507
|
if (output.generation !== generation) {
|
|
505
508
|
rebind(output.generation);
|
|
506
509
|
}
|
|
507
|
-
cursors.set(key,
|
|
510
|
+
cursors.set(key, {
|
|
511
|
+
cursor: output.cursor,
|
|
512
|
+
queueID: output.queueID ?? null
|
|
513
|
+
});
|
|
508
514
|
return {
|
|
509
515
|
kind: 'snapshot',
|
|
510
516
|
snapshot: output
|
|
@@ -512,7 +518,7 @@ export function createGaLocationClient(options) {
|
|
|
512
518
|
};
|
|
513
519
|
return {
|
|
514
520
|
generation: () => generation,
|
|
515
|
-
cursor: scope => cursors.get(scopeKey(scope)) ?? 0,
|
|
521
|
+
cursor: scope => cursors.get(scopeKey(scope))?.cursor ?? 0,
|
|
516
522
|
disposed: () => isDisposed,
|
|
517
523
|
dispose() {
|
|
518
524
|
isDisposed = true;
|
|
@@ -235,8 +235,14 @@ export interface GaSnapshot {
|
|
|
235
235
|
readonly kind: 'snapshot'
|
|
236
236
|
readonly generation: string
|
|
237
237
|
readonly scope: GaScope
|
|
238
|
-
readonly reset:
|
|
238
|
+
readonly reset:
|
|
239
|
+
| 'initial'
|
|
240
|
+
| 'generation-changed'
|
|
241
|
+
| 'queue-changed'
|
|
242
|
+
| 'cursor-ahead'
|
|
243
|
+
| null
|
|
239
244
|
readonly cursor: number
|
|
245
|
+
readonly queueID?: string
|
|
240
246
|
readonly dropped: number
|
|
241
247
|
readonly more: boolean
|
|
242
248
|
readonly notifications: readonly GaNotification[]
|
|
@@ -684,7 +690,7 @@ export function parseGaStateAnswer(
|
|
|
684
690
|
'status',
|
|
685
691
|
'settings',
|
|
686
692
|
],
|
|
687
|
-
['vaultHostStatus'],
|
|
693
|
+
['vaultHostStatus', 'queueID'],
|
|
688
694
|
'output',
|
|
689
695
|
issues,
|
|
690
696
|
)
|
|
@@ -697,11 +703,14 @@ export function parseGaStateAnswer(
|
|
|
697
703
|
checkAccountsStatus(output.accountsStatus, 'output.accountsStatus', issues)
|
|
698
704
|
checkSettings(output.settings, 'output.settings', issues)
|
|
699
705
|
checkGeneration(output.generation, 'output.generation', issues)
|
|
706
|
+
if (Object.hasOwn(output, 'queueID'))
|
|
707
|
+
checkGeneration(output.queueID, 'output.queueID', issues)
|
|
700
708
|
checkScope(output.scope, 'output.scope', issues)
|
|
701
709
|
if (
|
|
702
710
|
output.reset !== null &&
|
|
703
711
|
output.reset !== 'initial' &&
|
|
704
712
|
output.reset !== 'generation-changed' &&
|
|
713
|
+
output.reset !== 'queue-changed' &&
|
|
705
714
|
output.reset !== 'cursor-ahead'
|
|
706
715
|
) {
|
|
707
716
|
issues.push('output.reset: unknown reset')
|
|
@@ -813,7 +822,7 @@ export function createGaLocationClient(options: {
|
|
|
813
822
|
readonly logger?: GaLogger
|
|
814
823
|
}): GaLocationClient {
|
|
815
824
|
let generation: string | null = null
|
|
816
|
-
const cursors = new Map<string, number>()
|
|
825
|
+
const cursors = new Map<string, { cursor: number; queueID: string | null }>()
|
|
817
826
|
let isDisposed = false
|
|
818
827
|
// Bumped on every rebind and on disposal. A request remembers the epoch
|
|
819
828
|
// it was sent in; an answer from an older epoch is dropped unread.
|
|
@@ -842,11 +851,13 @@ export function createGaLocationClient(options: {
|
|
|
842
851
|
if (isDisposed) throw new GaClientDisposedError()
|
|
843
852
|
const sentEpoch = epoch
|
|
844
853
|
const key = scopeKey(scope)
|
|
854
|
+
const previous = cursors.get(key)
|
|
845
855
|
const raw = await call('state', {
|
|
846
856
|
version: GA_RPC_VERSION,
|
|
847
857
|
generation,
|
|
848
858
|
scope,
|
|
849
|
-
cursor:
|
|
859
|
+
cursor: previous?.cursor ?? 0,
|
|
860
|
+
queueID: previous?.queueID ?? null,
|
|
850
861
|
})
|
|
851
862
|
if (isDisposed || sentEpoch !== epoch) return { kind: 'dropped' }
|
|
852
863
|
const parsed = parseGaStateAnswer(raw)
|
|
@@ -868,13 +879,13 @@ export function createGaLocationClient(options: {
|
|
|
868
879
|
if (output.generation !== generation) {
|
|
869
880
|
rebind(output.generation)
|
|
870
881
|
}
|
|
871
|
-
cursors.set(key, output.cursor)
|
|
882
|
+
cursors.set(key, { cursor: output.cursor, queueID: output.queueID ?? null })
|
|
872
883
|
return { kind: 'snapshot', snapshot: output }
|
|
873
884
|
}
|
|
874
885
|
|
|
875
886
|
return {
|
|
876
887
|
generation: () => generation,
|
|
877
|
-
cursor: (scope) => cursors.get(scopeKey(scope)) ?? 0,
|
|
888
|
+
cursor: (scope) => cursors.get(scopeKey(scope))?.cursor ?? 0,
|
|
878
889
|
disposed: () => isDisposed,
|
|
879
890
|
dispose() {
|
|
880
891
|
isDisposed = true
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { chmodSync, mkdirSync, readFileSync } from "node:fs";
|
|
1
|
+
import { chmodSync, mkdirSync, readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { readFile, stat } from "node:fs/promises";
|
|
2
3
|
import { homedir } from "node:os";
|
|
3
4
|
import { dirname, join } from "node:path";
|
|
4
5
|
import { writeJsonAtomic } from "@cortexkit/antigravity-auth-core/atomic-write";
|
|
@@ -44,6 +45,44 @@ export function readSidebarState(path = getSidebarStateFile()) {
|
|
|
44
45
|
} catch {
|
|
45
46
|
return { ...DEFAULT_SIDEBAR_STATE };
|
|
46
47
|
}
|
|
48
|
+
return parseSidebarState(raw);
|
|
49
|
+
}
|
|
50
|
+
function fileSignature(info) {
|
|
51
|
+
return `${info.dev}:${info.ino}:${info.size}:${info.mtimeNs}:${info.ctimeNs}`;
|
|
52
|
+
}
|
|
53
|
+
export function readSidebarStateWithBaseline(path = getSidebarStateFile()) {
|
|
54
|
+
try {
|
|
55
|
+
const signature = fileSignature(statSync(path, { bigint: !0 })), raw = readFileSync(path, "utf-8");
|
|
56
|
+
return { state: parseSidebarState(raw), baseline: { path, signature } };
|
|
57
|
+
} catch {
|
|
58
|
+
return {
|
|
59
|
+
state: { ...DEFAULT_SIDEBAR_STATE },
|
|
60
|
+
baseline: { path, signature: null }
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function createSidebarStateReader(baseline) {
|
|
65
|
+
let previousPath = baseline?.path, previousSignature = baseline?.signature ?? null;
|
|
66
|
+
return async (path = getSidebarStateFile()) => {
|
|
67
|
+
let raw, signature;
|
|
68
|
+
try {
|
|
69
|
+
signature = fileSignature(await stat(path, { bigint: !0 }));
|
|
70
|
+
if (path === previousPath && signature === previousSignature)
|
|
71
|
+
return;
|
|
72
|
+
raw = await readFile(path, "utf-8");
|
|
73
|
+
} catch {
|
|
74
|
+
const alreadyUnavailable = path === previousPath && previousSignature === null;
|
|
75
|
+
previousPath = path;
|
|
76
|
+
previousSignature = null;
|
|
77
|
+
return alreadyUnavailable ? void 0 : { ...DEFAULT_SIDEBAR_STATE };
|
|
78
|
+
}
|
|
79
|
+
const loaded = parseSidebarState(raw);
|
|
80
|
+
previousPath = path;
|
|
81
|
+
previousSignature = signature;
|
|
82
|
+
return loaded;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function parseSidebarState(raw) {
|
|
47
86
|
let parsed;
|
|
48
87
|
try {
|
|
49
88
|
parsed = JSON.parse(raw);
|