@cortexkit/opencode-antigravity-auth 3.0.41 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/cli.js +1316 -1124
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +116 -106
- package/dist/index.js +1257 -720
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +187 -169
- package/dist/server.js +1310 -773
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/dist/src/common-auth-embedded/claustrum/custody.js +147 -2
- package/dist/src/common-auth-embedded/claustrum/hub.js +47 -1
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +13 -9
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +65 -12
- package/dist/src/common-auth-embedded/routing-accessor/index.js +114 -15
- package/dist/src/common-auth-embedded/settings/edit.d.ts +1 -0
- package/dist/src/common-auth-embedded/settings/edit.js +48 -2
- package/dist/src/common-auth-embedded/settings/handle.d.ts +2 -1
- package/dist/src/common-auth-embedded/settings/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/settings/update.d.ts +14 -0
- package/dist/src/common-auth-embedded/settings/update.js +28 -9
- package/dist/src/common-auth-embedded/source-output.json +55 -46
- 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.d.ts +1 -1
- package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
- package/dist/src/plugin/account-access.js +1 -1
- package/dist/src/plugin/account-access.js.map +1 -1
- package/dist/src/plugin/catalog.d.ts.map +1 -1
- package/dist/src/plugin/catalog.js +4 -2
- package/dist/src/plugin/catalog.js.map +1 -1
- package/dist/src/plugin/config/models.d.ts +9 -0
- package/dist/src/plugin/config/models.d.ts.map +1 -1
- package/dist/src/plugin/config/models.js +18 -0
- package/dist/src/plugin/config/models.js.map +1 -1
- package/dist/src/plugin/config/updater.js +2 -2
- package/dist/src/plugin/config/updater.js.map +1 -1
- package/dist/src/plugin/core/streaming/terminal-event.d.ts +14 -0
- package/dist/src/plugin/core/streaming/terminal-event.d.ts.map +1 -0
- package/dist/src/plugin/core/streaming/terminal-event.js +39 -0
- package/dist/src/plugin/core/streaming/terminal-event.js.map +1 -0
- package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/src/plugin/core/streaming/transformer.js +1 -13
- package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
- package/dist/src/plugin/ga-location-services.js +1 -1
- package/dist/src/plugin/ga-location-services.js.map +1 -1
- package/dist/src/plugin/index.js +1 -1
- package/dist/src/plugin/index.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +10 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +6 -0
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/request.d.ts.map +1 -1
- package/dist/src/plugin/request.js +101 -47
- package/dist/src/plugin/request.js.map +1 -1
- package/dist/src/plugin/search.d.ts +7 -0
- package/dist/src/plugin/search.d.ts.map +1 -1
- package/dist/src/plugin/search.js +9 -15
- package/dist/src/plugin/search.js.map +1 -1
- package/dist/src/plugin/session-context.d.ts +1 -1
- package/dist/src/plugin/session-context.d.ts.map +1 -1
- package/dist/src/plugin/session-context.js +2 -5
- package/dist/src/plugin/session-context.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts +8 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +98 -11
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/shared/vault-routing.d.ts +9 -1
- package/dist/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/dist/src/plugin/shared/vault-routing.js +34 -12
- package/dist/src/plugin/shared/vault-routing.js.map +1 -1
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +65 -12
- package/dist/types/src/plugin/catalog.d.ts.map +1 -1
- package/dist/types/src/plugin/config/models.d.ts +9 -0
- package/dist/types/src/plugin/config/models.d.ts.map +1 -1
- package/dist/types/src/plugin/core/streaming/terminal-event.d.ts +14 -0
- package/dist/types/src/plugin/core/streaming/terminal-event.d.ts.map +1 -0
- package/dist/types/src/plugin/core/streaming/transformer.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts +10 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/types/src/plugin/request.d.ts.map +1 -1
- package/dist/types/src/plugin/search.d.ts +7 -0
- package/dist/types/src/plugin/search.d.ts.map +1 -1
- package/dist/types/src/plugin/session-context.d.ts +1 -1
- package/dist/types/src/plugin/session-context.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts +8 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts +9 -1
- package/dist/types/src/plugin/shared/vault-routing.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/custody.d.ts +4 -0
- package/src/common-auth-embedded/claustrum/custody.js +147 -2
- package/src/common-auth-embedded/claustrum/hub.js +47 -1
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -1
- package/src/common-auth-embedded/claustrum/index.js +1 -1
- package/src/common-auth-embedded/fs/refresh-file-lock.js +13 -9
- package/src/common-auth-embedded/routing-accessor/index.d.ts +65 -12
- package/src/common-auth-embedded/routing-accessor/index.js +114 -15
- package/src/common-auth-embedded/settings/edit.d.ts +1 -0
- package/src/common-auth-embedded/settings/edit.js +48 -2
- package/src/common-auth-embedded/settings/handle.d.ts +2 -1
- package/src/common-auth-embedded/settings/index.d.ts +1 -0
- package/src/common-auth-embedded/settings/update.d.ts +14 -0
- package/src/common-auth-embedded/settings/update.js +28 -9
- package/src/common-auth-embedded/source-output.json +55 -46
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Optional THALAMUS routing for vault mode and advisory turn
|
|
3
|
-
* shaping. Account ids are vault account ids, not local pool
|
|
4
|
-
* persisted here; plugins on routes the runner does not serve
|
|
2
|
+
* Optional THALAMUS routing for vault mode, plugin wait reports and advisory turn
|
|
3
|
+
* notes for request shaping. Account ids are vault account ids, not local pool
|
|
4
|
+
* rows. Nothing is persisted here; plugins on routes the runner does not serve
|
|
5
|
+
* get no turn notes.
|
|
5
6
|
*/
|
|
6
7
|
import { isCacheWarmStopReason, } from './cache-policy.js';
|
|
7
8
|
import { routingHandle } from './handle.js';
|
|
8
9
|
export { CACHE_WARM_STOP_REASONS, isCacheWarmStopReason, reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
|
|
10
|
+
/** Keep this closed list aligned with the routing contract when adding a reason. */
|
|
11
|
+
export const PLUGIN_WAIT_REASONS = [
|
|
12
|
+
'account_limit',
|
|
13
|
+
'account_free',
|
|
14
|
+
'rate_limited',
|
|
15
|
+
'server_busy',
|
|
16
|
+
'quota_reading',
|
|
17
|
+
'routing_hold',
|
|
18
|
+
];
|
|
9
19
|
function isObject(value) {
|
|
10
20
|
return typeof value === 'object' && value !== null;
|
|
11
21
|
}
|
|
@@ -136,11 +146,35 @@ function selectionFor(answer, candidates) {
|
|
|
136
146
|
}
|
|
137
147
|
return { candidate };
|
|
138
148
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
function refusalFor(value) {
|
|
150
|
+
if (!isObject(value))
|
|
151
|
+
return undefined;
|
|
152
|
+
const code = value.code;
|
|
153
|
+
if (code !== 'account_limit_exhausted' &&
|
|
154
|
+
code !== 'account_selection_refused' &&
|
|
155
|
+
code !== 'account_selection_final') {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
const refused = { code };
|
|
159
|
+
const routingCode = value.routing_code;
|
|
160
|
+
if (typeof routingCode === 'string' &&
|
|
161
|
+
/^[a-z0-9._-]{1,64}$/.test(routingCode)) {
|
|
162
|
+
refused.routingCode = routingCode;
|
|
163
|
+
}
|
|
164
|
+
const retryAfterSecs = value.retry_after_secs;
|
|
165
|
+
if (typeof retryAfterSecs === 'number' &&
|
|
166
|
+
Number.isFinite(retryAfterSecs) &&
|
|
167
|
+
retryAfterSecs >= 0) {
|
|
168
|
+
refused.retryAfterSecs = retryAfterSecs;
|
|
169
|
+
}
|
|
170
|
+
const resetsAtMs = value.resets_at_ms;
|
|
171
|
+
if (typeof resetsAtMs === 'number' &&
|
|
172
|
+
Number.isSafeInteger(resetsAtMs) &&
|
|
173
|
+
resetsAtMs > 0) {
|
|
174
|
+
refused.resetsAtMs = resetsAtMs;
|
|
175
|
+
}
|
|
176
|
+
return { refused };
|
|
177
|
+
}
|
|
144
178
|
export async function askRouting(input) {
|
|
145
179
|
let timer;
|
|
146
180
|
try {
|
|
@@ -150,9 +184,9 @@ export async function askRouting(input) {
|
|
|
150
184
|
const accountFor = handle.accountFor;
|
|
151
185
|
if (typeof accountFor !== 'function')
|
|
152
186
|
return undefined;
|
|
153
|
-
const requested = input.deadlineMs ??
|
|
187
|
+
const requested = input.deadlineMs ?? 1500;
|
|
154
188
|
const deadlineMs = Number.isNaN(requested)
|
|
155
|
-
?
|
|
189
|
+
? 1500
|
|
156
190
|
: Math.min(2000, Math.max(1, requested));
|
|
157
191
|
const expired = new Promise((resolve) => {
|
|
158
192
|
timer = setTimeout(() => resolve(undefined), deadlineMs);
|
|
@@ -166,10 +200,22 @@ export async function askRouting(input) {
|
|
|
166
200
|
if (typeof cap === 'number' && Number.isFinite(cap)) {
|
|
167
201
|
request.hold_wait_max_s = Math.max(0, Math.floor(cap));
|
|
168
202
|
}
|
|
203
|
+
if (input.refusals === true)
|
|
204
|
+
request.refusals = true;
|
|
205
|
+
const warmCredentialId = input.warmCredentialId;
|
|
206
|
+
if (isNonEmptyString(warmCredentialId) &&
|
|
207
|
+
warmCredentialId.length <= 256 &&
|
|
208
|
+
!/\p{Cc}/u.test(warmCredentialId) &&
|
|
209
|
+
input.candidates.some((candidate) => candidate.credentialId === warmCredentialId)) {
|
|
210
|
+
request.warm_credential = warmCredentialId;
|
|
211
|
+
}
|
|
169
212
|
const pending = accountFor.call(handle, request, { deadlineMs });
|
|
170
213
|
if (!isObject(pending) || typeof pending.then !== 'function')
|
|
171
214
|
return undefined;
|
|
172
215
|
const answer = await Promise.race([pending, expired]);
|
|
216
|
+
if (input.refusals === true && isObject(answer) && 'refused' in answer) {
|
|
217
|
+
return refusalFor(answer.refused);
|
|
218
|
+
}
|
|
173
219
|
return selectionFor(answer, input.candidates);
|
|
174
220
|
}
|
|
175
221
|
catch {
|
|
@@ -181,14 +227,15 @@ export async function askRouting(input) {
|
|
|
181
227
|
}
|
|
182
228
|
}
|
|
183
229
|
/**
|
|
184
|
-
* Report a vault request, billing result or turn-note event without
|
|
185
|
-
* routing. Only contract fields are sent, and all accessor failures
|
|
186
|
-
* Headers must already be limited to rate-limit headers by the
|
|
187
|
-
* are not filtered or redacted here.
|
|
230
|
+
* Report a vault request, billing result, plugin wait or turn-note event without
|
|
231
|
+
* waiting for routing. Only contract fields are sent, and all accessor failures
|
|
232
|
+
* are ignored. Headers must already be limited to rate-limit headers by the
|
|
233
|
+
* caller; values are not filtered or redacted here.
|
|
188
234
|
*/
|
|
189
235
|
export function reportRouting(input) {
|
|
190
236
|
try {
|
|
191
|
-
const
|
|
237
|
+
const sessionId = input.sessionId;
|
|
238
|
+
const handle = routingHandle(sessionId);
|
|
192
239
|
if (!handle)
|
|
193
240
|
return;
|
|
194
241
|
const report = handle.report;
|
|
@@ -197,6 +244,45 @@ export function reportRouting(input) {
|
|
|
197
244
|
let payload;
|
|
198
245
|
if ('kind' in input) {
|
|
199
246
|
switch (input.kind) {
|
|
247
|
+
case 'wait': {
|
|
248
|
+
const { phase, waitId, reason, nextMs, attempt, message, outcome } = input;
|
|
249
|
+
if (!isNonEmptyString(sessionId) ||
|
|
250
|
+
(phase !== 'start' && phase !== 'end') ||
|
|
251
|
+
!isNonEmptyString(waitId) ||
|
|
252
|
+
waitId.length > 64 ||
|
|
253
|
+
/[^A-Za-z0-9._:-]/.test(waitId) ||
|
|
254
|
+
!PLUGIN_WAIT_REASONS.includes(reason))
|
|
255
|
+
return;
|
|
256
|
+
payload = {
|
|
257
|
+
kind: 'wait',
|
|
258
|
+
phase,
|
|
259
|
+
wait_id: waitId,
|
|
260
|
+
reason,
|
|
261
|
+
...(typeof nextMs === 'number' &&
|
|
262
|
+
Number.isSafeInteger(nextMs) &&
|
|
263
|
+
nextMs > 0
|
|
264
|
+
? { next_ms: nextMs }
|
|
265
|
+
: {}),
|
|
266
|
+
...(typeof attempt === 'number' &&
|
|
267
|
+
Number.isInteger(attempt) &&
|
|
268
|
+
attempt >= 1
|
|
269
|
+
? { attempt }
|
|
270
|
+
: {}),
|
|
271
|
+
...(typeof message === 'string' &&
|
|
272
|
+
message.length >= 1 &&
|
|
273
|
+
message.length <= 160 &&
|
|
274
|
+
!/\p{Cc}/u.test(message)
|
|
275
|
+
? { message }
|
|
276
|
+
: {}),
|
|
277
|
+
...(phase === 'end' &&
|
|
278
|
+
(outcome === 'resumed' ||
|
|
279
|
+
outcome === 'cancelled' ||
|
|
280
|
+
outcome === 'abandoned')
|
|
281
|
+
? { outcome }
|
|
282
|
+
: {}),
|
|
283
|
+
};
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
200
286
|
case 'billing': {
|
|
201
287
|
const { attemptId, requestKind, credentialId, provider, model, outcome, accountId, providerRequestId, providerResponseId, userMessageId, status, attempt, chargeBasis, usage: inputUsage, usageByModel: inputUsageByModel, cache: inputCache, } = input;
|
|
202
288
|
if (!isNonEmptyString(attemptId) ||
|
|
@@ -334,6 +420,19 @@ export function reportRouting(input) {
|
|
|
334
420
|
};
|
|
335
421
|
break;
|
|
336
422
|
}
|
|
423
|
+
case 'credential_refused': {
|
|
424
|
+
const { credentialId, providerCode } = input;
|
|
425
|
+
if (!isNonEmptyString(credentialId) ||
|
|
426
|
+
typeof providerCode !== 'string' ||
|
|
427
|
+
!/^[a-z0-9._-]{1,64}$/.test(providerCode))
|
|
428
|
+
return;
|
|
429
|
+
payload = {
|
|
430
|
+
...identity,
|
|
431
|
+
outcome: 'credential_refused',
|
|
432
|
+
provider_code: providerCode,
|
|
433
|
+
};
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
337
436
|
default:
|
|
338
437
|
return;
|
|
339
438
|
}
|
|
@@ -37,7 +37,12 @@ function descriptorAtPath(descriptor, path) {
|
|
|
37
37
|
}
|
|
38
38
|
return current;
|
|
39
39
|
}
|
|
40
|
-
function destination(declaration, setting, value, { host, model }) {
|
|
40
|
+
function destination(declaration, setting, value, { host, model }, level) {
|
|
41
|
+
if (level !== undefined) {
|
|
42
|
+
return level === 'default' && !isJsonObject(value)
|
|
43
|
+
? [setting]
|
|
44
|
+
: [setting, level];
|
|
45
|
+
}
|
|
41
46
|
if (declaration.overrides !== undefined && isJsonObject(value)) {
|
|
42
47
|
if (declaration.overrides.model &&
|
|
43
48
|
model !== undefined &&
|
|
@@ -75,6 +80,20 @@ function checkPath(parsed, path) {
|
|
|
75
80
|
invalid();
|
|
76
81
|
}
|
|
77
82
|
}
|
|
83
|
+
function preservePlainDefault(parsed, setting) {
|
|
84
|
+
const node = parsed.tree && findNodeAtLocation(parsed.tree, [setting]);
|
|
85
|
+
if (!node)
|
|
86
|
+
invalid();
|
|
87
|
+
// Keep the original value text so comments inside a list survive promotion.
|
|
88
|
+
const value = parsed.text.slice(node.offset, node.offset + node.length);
|
|
89
|
+
return parseForEdit(applyEdits(parsed.text, [
|
|
90
|
+
{
|
|
91
|
+
offset: node.offset,
|
|
92
|
+
length: node.length,
|
|
93
|
+
content: `{ "default": ${value} }`,
|
|
94
|
+
},
|
|
95
|
+
]));
|
|
96
|
+
}
|
|
78
97
|
/** Remove only the member's own tokens; intervening comment lines belong to neither neighbor. */
|
|
79
98
|
function removeMember(text, tree, path) {
|
|
80
99
|
const property = tree && findNodeAtLocation(tree, path)?.parent;
|
|
@@ -157,6 +176,18 @@ export function applySettingsEdits(definition, source, edits, context) {
|
|
|
157
176
|
if (!Object.hasOwn(definition.settings, edit.setting))
|
|
158
177
|
invalid();
|
|
159
178
|
const declaration = definition.settings[edit.setting];
|
|
179
|
+
if (edit.level !== undefined) {
|
|
180
|
+
if (edit.path !== undefined)
|
|
181
|
+
invalid();
|
|
182
|
+
if (edit.level === 'default') {
|
|
183
|
+
if (declaration.overrides === undefined)
|
|
184
|
+
invalid();
|
|
185
|
+
}
|
|
186
|
+
else if ((edit.level !== 'opencode' && edit.level !== 'pi') ||
|
|
187
|
+
!declaration.overrides?.host) {
|
|
188
|
+
invalid();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
160
191
|
if (edit.path !== undefined &&
|
|
161
192
|
declaration.value.kind !== 'object' &&
|
|
162
193
|
declaration.value.kind !== 'record')
|
|
@@ -170,9 +201,24 @@ export function applySettingsEdits(definition, source, edits, context) {
|
|
|
170
201
|
const units = [];
|
|
171
202
|
for (const edit of edits) {
|
|
172
203
|
const declaration = definition.settings[edit.setting];
|
|
204
|
+
if (edit.level !== undefined &&
|
|
205
|
+
edit.level !== 'default' &&
|
|
206
|
+
!isJsonObject(working.value[edit.setting])) {
|
|
207
|
+
if (edit.remove === true)
|
|
208
|
+
continue;
|
|
209
|
+
if (Object.hasOwn(working.value, edit.setting)) {
|
|
210
|
+
working = preservePlainDefault(working, edit.setting);
|
|
211
|
+
}
|
|
212
|
+
// Earlier root edits now refer to the override's default, if it exists.
|
|
213
|
+
for (const unit of units) {
|
|
214
|
+
if (unit.path.length === 1 && unit.path[0] === edit.setting) {
|
|
215
|
+
unit.path.push('default');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
173
219
|
const base = edit.path !== undefined
|
|
174
220
|
? [edit.setting]
|
|
175
|
-
: destination(declaration, edit.setting, working.value[edit.setting], context);
|
|
221
|
+
: destination(declaration, edit.setting, working.value[edit.setting], context, edit.level);
|
|
176
222
|
const path = [...base, ...(edit.path ?? [])];
|
|
177
223
|
checkPath(working, path);
|
|
178
224
|
units.push(resolutionUnit(declaration.value, base, edit.path ?? []));
|
|
@@ -4,6 +4,7 @@ import { type ValueOf } from './descriptors.js';
|
|
|
4
4
|
import type { SettingsEdit, UpdateResult } from './edit.js';
|
|
5
5
|
import { type GetOptions } from './resolve.js';
|
|
6
6
|
import { type ReportEntry } from './snapshot.js';
|
|
7
|
+
import { type SettingsUpdatePlan } from './update.js';
|
|
7
8
|
export interface LegacyProjectSource {
|
|
8
9
|
readonly path: string;
|
|
9
10
|
read(text: string): unknown;
|
|
@@ -22,7 +23,7 @@ export interface SettingsHandle<S extends Readonly<Record<string, SettingDeclara
|
|
|
22
23
|
}): Promise<void>;
|
|
23
24
|
get<K extends keyof S & string>(name: K, options: GetOptions): Promise<ValueOf<S[K]['value']>>;
|
|
24
25
|
report(): ReportEntry[];
|
|
25
|
-
update(edits: readonly SettingsEdit[], options: Pick<GetOptions, 'host' | 'model'>): Promise<UpdateResult>;
|
|
26
|
+
update(edits: readonly SettingsEdit[] | SettingsUpdatePlan, options: Pick<GetOptions, 'host' | 'model'>): Promise<UpdateResult>;
|
|
26
27
|
watch(onChange: () => void): () => void;
|
|
27
28
|
}
|
|
28
29
|
/** Internal test hook; not part of the settings package exports. */
|
|
@@ -8,3 +8,4 @@ export { SETTINGS_REFUSAL_CODES, SettingsRefusal, type SettingsRefusalCode, } fr
|
|
|
8
8
|
export type { GetOptions } from './resolve.js';
|
|
9
9
|
export { settingsJsonSchema } from './schema.js';
|
|
10
10
|
export type { ReportEntry, ReportReason } from './snapshot.js';
|
|
11
|
+
export type { SettingsCurrent, SettingsUpdatePlan } from './update.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SettingsDefinition } from './define.js';
|
|
2
|
+
import { type SettingsEdit, type UpdateResult } from './edit.js';
|
|
3
|
+
import type { OpenSettingsOptions } from './handle.js';
|
|
4
|
+
import type { GetOptions } from './resolve.js';
|
|
5
|
+
export type SettingsCurrent = {
|
|
6
|
+
readonly status: 'missing';
|
|
7
|
+
} | {
|
|
8
|
+
readonly status: 'ready';
|
|
9
|
+
readonly document: Readonly<Record<string, unknown>>;
|
|
10
|
+
};
|
|
11
|
+
/** Compute edits synchronously from an immutable copy read under the write lock. */
|
|
12
|
+
export type SettingsUpdatePlan = (current: SettingsCurrent) => readonly SettingsEdit[];
|
|
13
|
+
/** Lock the canonical user file so symlink aliases serialize the same edits. */
|
|
14
|
+
export declare function updateSettings(definition: SettingsDefinition, options: OpenSettingsOptions, edits: readonly SettingsEdit[] | SettingsUpdatePlan, context: Pick<GetOptions, 'host' | 'model'>): Promise<UpdateResult>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { basename, dirname, join } from 'node:path';
|
|
2
2
|
import { ensurePrivateDirectory } from '../fs/private-files.js';
|
|
3
3
|
import { withLock } from '../fs/with-lock.js';
|
|
4
|
+
import { deepFreeze } from './descriptors.js';
|
|
4
5
|
import { applySettingsEdits, } from './edit.js';
|
|
5
6
|
import { SettingsFs } from './fs.js';
|
|
6
7
|
import { rethrowSettingsLockError } from './lock-errors.js';
|
|
@@ -23,21 +24,24 @@ async function writeTarget(file) {
|
|
|
23
24
|
catch (error) {
|
|
24
25
|
if (error.code !== 'ENOENT')
|
|
25
26
|
unavailable(file, error);
|
|
27
|
+
let isSymlink = false;
|
|
26
28
|
try {
|
|
27
|
-
await SettingsFs.lstat(file);
|
|
29
|
+
isSymlink = (await SettingsFs.lstat(file)).isSymbolicLink();
|
|
28
30
|
}
|
|
29
31
|
catch (lstatError) {
|
|
30
32
|
if (lstatError.code !== 'ENOENT')
|
|
31
33
|
unavailable(file, lstatError);
|
|
32
|
-
try {
|
|
33
|
-
return join(await SettingsFs.realpath(dirname(file)), basename(file));
|
|
34
|
-
}
|
|
35
|
-
catch (parentError) {
|
|
36
|
-
unavailable(file, parentError);
|
|
37
|
-
}
|
|
38
34
|
}
|
|
39
|
-
//
|
|
40
|
-
|
|
35
|
+
// Only a symlink whose realpath is missing is a dangling entry.
|
|
36
|
+
if (isSymlink)
|
|
37
|
+
unavailable(file, error);
|
|
38
|
+
// Bun 1.4 can fail realpath for regular files during a concurrent atomic replace.
|
|
39
|
+
try {
|
|
40
|
+
return join(await SettingsFs.realpath(dirname(file)), basename(file));
|
|
41
|
+
}
|
|
42
|
+
catch (parentError) {
|
|
43
|
+
unavailable(file, parentError);
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
}
|
|
43
47
|
/** Lock the canonical user file so symlink aliases serialize the same edits. */
|
|
@@ -97,6 +101,21 @@ export async function updateSettings(definition, options, edits, context) {
|
|
|
97
101
|
if (Number.isInteger(version) && version > 1) {
|
|
98
102
|
throw new SettingsRefusal('settings-newer-version', 'Settings were written by a newer version');
|
|
99
103
|
}
|
|
104
|
+
if (typeof edits === 'function') {
|
|
105
|
+
const planned = edits(deepFreeze(missing
|
|
106
|
+
? { status: 'missing' }
|
|
107
|
+
: {
|
|
108
|
+
status: 'ready',
|
|
109
|
+
document: structuredClone(parsed.value),
|
|
110
|
+
}));
|
|
111
|
+
if (planned !== null &&
|
|
112
|
+
(typeof planned === 'object' || typeof planned === 'function') &&
|
|
113
|
+
'then' in planned &&
|
|
114
|
+
typeof planned.then === 'function') {
|
|
115
|
+
throw new SettingsRefusal('settings-invalid-value', 'Settings update plans must be synchronous');
|
|
116
|
+
}
|
|
117
|
+
edits = planned;
|
|
118
|
+
}
|
|
100
119
|
if (!parsed.tree) {
|
|
101
120
|
source = `${parsed.hasBom ? '\uFEFF' : ''}// ${definition.plugin} settings\n{\n "schema_version": 1\n}\n`;
|
|
102
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.49.1",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
6
|
"publicRoots": {
|
|
7
7
|
"./rpc": {
|
|
@@ -73,15 +73,16 @@
|
|
|
73
73
|
"import": "./src/quota-sidebar/index.tsx"
|
|
74
74
|
}
|
|
75
75
|
},
|
|
76
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
77
|
-
"tarballSha256": "
|
|
78
|
-
"sri": "sha512-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
76
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.49.1.tgz",
|
|
77
|
+
"tarballSha256": "51f844a7cdc018ce795b642b8ac9bc3fb42e3fd5a5c23b6977bf097c854fe1ca",
|
|
78
|
+
"sri": "sha512-bN32JvabenbUQU0HeYFzrf2PhgH9p+YO5T7jIDspMSM6lOf/jRykdX0TZ154nUo95ZbhS/4f4b4BxU7kMt6+LQ==",
|
|
79
|
+
"shasum": "5e3e69e6aa76b884374dc816066f0c887c52d21b",
|
|
80
|
+
"canonicalFiles": 252,
|
|
81
|
+
"canonicalBytes": 1503837,
|
|
81
82
|
"generator": {
|
|
82
83
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
83
84
|
"version": 4,
|
|
84
|
-
"sha256": "
|
|
85
|
+
"sha256": "b4c837b90ca6f9266a0bfcd74a6412b64db0b98475aa40cef05c4be65d4a6770"
|
|
85
86
|
},
|
|
86
87
|
"files": [
|
|
87
88
|
{
|
|
@@ -279,17 +280,17 @@
|
|
|
279
280
|
{
|
|
280
281
|
"source": "package/dist/claustrum/custody.d.ts",
|
|
281
282
|
"output": "claustrum/custody.d.ts",
|
|
282
|
-
"bytes":
|
|
283
|
-
"sourceSha256": "
|
|
284
|
-
"outputSha256": "
|
|
283
|
+
"bytes": 18127,
|
|
284
|
+
"sourceSha256": "8c4cb2f52551ae36a32c4e68201767df0d19ba396302ed6c2d723d0e066166f6",
|
|
285
|
+
"outputSha256": "8c4cb2f52551ae36a32c4e68201767df0d19ba396302ed6c2d723d0e066166f6",
|
|
285
286
|
"transform": "verbatim"
|
|
286
287
|
},
|
|
287
288
|
{
|
|
288
289
|
"source": "package/dist/claustrum/custody.js",
|
|
289
290
|
"output": "claustrum/custody.js",
|
|
290
|
-
"bytes":
|
|
291
|
-
"sourceSha256": "
|
|
292
|
-
"outputSha256": "
|
|
291
|
+
"bytes": 43691,
|
|
292
|
+
"sourceSha256": "65a376031c602bc4592fa6402c3cb5a14219245c10c134aed7239fdf11f1e88c",
|
|
293
|
+
"outputSha256": "65a376031c602bc4592fa6402c3cb5a14219245c10c134aed7239fdf11f1e88c",
|
|
293
294
|
"transform": "verbatim"
|
|
294
295
|
},
|
|
295
296
|
{
|
|
@@ -367,25 +368,25 @@
|
|
|
367
368
|
{
|
|
368
369
|
"source": "package/dist/claustrum/hub.js",
|
|
369
370
|
"output": "claustrum/hub.js",
|
|
370
|
-
"bytes":
|
|
371
|
-
"sourceSha256": "
|
|
372
|
-
"outputSha256": "
|
|
371
|
+
"bytes": 48395,
|
|
372
|
+
"sourceSha256": "77bb04f1e6956eb2419b4d497fd2c478f59833f0a1bcc7650a090bd5c8a6ec23",
|
|
373
|
+
"outputSha256": "77bb04f1e6956eb2419b4d497fd2c478f59833f0a1bcc7650a090bd5c8a6ec23",
|
|
373
374
|
"transform": "verbatim"
|
|
374
375
|
},
|
|
375
376
|
{
|
|
376
377
|
"source": "package/dist/claustrum/index.d.ts",
|
|
377
378
|
"output": "claustrum/index.d.ts",
|
|
378
|
-
"bytes":
|
|
379
|
-
"sourceSha256": "
|
|
380
|
-
"outputSha256": "
|
|
379
|
+
"bytes": 5073,
|
|
380
|
+
"sourceSha256": "9e6722e2c38df279563804af98297aa6558efd8e50eb253e348a23b22e6e9785",
|
|
381
|
+
"outputSha256": "9e6722e2c38df279563804af98297aa6558efd8e50eb253e348a23b22e6e9785",
|
|
381
382
|
"transform": "verbatim"
|
|
382
383
|
},
|
|
383
384
|
{
|
|
384
385
|
"source": "package/dist/claustrum/index.js",
|
|
385
386
|
"output": "claustrum/index.js",
|
|
386
|
-
"bytes":
|
|
387
|
-
"sourceSha256": "
|
|
388
|
-
"outputSha256": "
|
|
387
|
+
"bytes": 4168,
|
|
388
|
+
"sourceSha256": "a770d6b8d5f8f50d1e4a4043f79c3660962add6fe2a6ec12552847ea0be04ca2",
|
|
389
|
+
"outputSha256": "a770d6b8d5f8f50d1e4a4043f79c3660962add6fe2a6ec12552847ea0be04ca2",
|
|
389
390
|
"transform": "verbatim"
|
|
390
391
|
},
|
|
391
392
|
{
|
|
@@ -679,9 +680,9 @@
|
|
|
679
680
|
{
|
|
680
681
|
"source": "package/dist/fs/refresh-file-lock.js",
|
|
681
682
|
"output": "fs/refresh-file-lock.js",
|
|
682
|
-
"bytes":
|
|
683
|
-
"sourceSha256": "
|
|
684
|
-
"outputSha256": "
|
|
683
|
+
"bytes": 53498,
|
|
684
|
+
"sourceSha256": "0ba013556cedf94cd643de80d3a8383c0cbd0db425940c67bf516056fc6bba9d",
|
|
685
|
+
"outputSha256": "0ba013556cedf94cd643de80d3a8383c0cbd0db425940c67bf516056fc6bba9d",
|
|
685
686
|
"transform": "verbatim"
|
|
686
687
|
},
|
|
687
688
|
{
|
|
@@ -1335,17 +1336,17 @@
|
|
|
1335
1336
|
{
|
|
1336
1337
|
"source": "package/dist/settings/edit.d.ts",
|
|
1337
1338
|
"output": "settings/edit.d.ts",
|
|
1338
|
-
"bytes":
|
|
1339
|
-
"sourceSha256": "
|
|
1340
|
-
"outputSha256": "
|
|
1339
|
+
"bytes": 705,
|
|
1340
|
+
"sourceSha256": "12c877c921cdd0ba40948e558afedbcf2ee5f8ff8708908bed9b55a5c1e7800d",
|
|
1341
|
+
"outputSha256": "12c877c921cdd0ba40948e558afedbcf2ee5f8ff8708908bed9b55a5c1e7800d",
|
|
1341
1342
|
"transform": "verbatim"
|
|
1342
1343
|
},
|
|
1343
1344
|
{
|
|
1344
1345
|
"source": "package/dist/settings/edit.js",
|
|
1345
1346
|
"output": "settings/edit.js",
|
|
1346
|
-
"bytes":
|
|
1347
|
-
"sourceSha256": "
|
|
1348
|
-
"outputSha256": "
|
|
1347
|
+
"bytes": 10682,
|
|
1348
|
+
"sourceSha256": "bee8adcd3f244bfa8be32cbbe75e90707a1ffc8e622c70ca0e94471f39415911",
|
|
1349
|
+
"outputSha256": "bee8adcd3f244bfa8be32cbbe75e90707a1ffc8e622c70ca0e94471f39415911",
|
|
1349
1350
|
"transform": "verbatim"
|
|
1350
1351
|
},
|
|
1351
1352
|
{
|
|
@@ -1359,9 +1360,9 @@
|
|
|
1359
1360
|
{
|
|
1360
1361
|
"source": "package/dist/settings/handle.d.ts",
|
|
1361
1362
|
"output": "settings/handle.d.ts",
|
|
1362
|
-
"bytes":
|
|
1363
|
-
"sourceSha256": "
|
|
1364
|
-
"outputSha256": "
|
|
1363
|
+
"bytes": 1652,
|
|
1364
|
+
"sourceSha256": "f6e23fd2f13b2f3d1942dee6db4f4e802d2763e3d4b4eb18ed6cca88974762ff",
|
|
1365
|
+
"outputSha256": "f6e23fd2f13b2f3d1942dee6db4f4e802d2763e3d4b4eb18ed6cca88974762ff",
|
|
1365
1366
|
"transform": "verbatim"
|
|
1366
1367
|
},
|
|
1367
1368
|
{
|
|
@@ -1375,9 +1376,9 @@
|
|
|
1375
1376
|
{
|
|
1376
1377
|
"source": "package/dist/settings/index.d.ts",
|
|
1377
1378
|
"output": "settings/index.d.ts",
|
|
1378
|
-
"bytes":
|
|
1379
|
-
"sourceSha256": "
|
|
1380
|
-
"outputSha256": "
|
|
1379
|
+
"bytes": 987,
|
|
1380
|
+
"sourceSha256": "23dff586898ffb2fa2f95597518e82ed9c19b1a6e5ed4187dc01675eff67f4fa",
|
|
1381
|
+
"outputSha256": "23dff586898ffb2fa2f95597518e82ed9c19b1a6e5ed4187dc01675eff67f4fa",
|
|
1381
1382
|
"transform": "verbatim"
|
|
1382
1383
|
},
|
|
1383
1384
|
{
|
|
@@ -1508,12 +1509,20 @@
|
|
|
1508
1509
|
"outputSha256": "353437b45c3b96f3df6d64de05765acb2e4da54b6ac9d293fcd5ccbb6517ad3b",
|
|
1509
1510
|
"transform": "verbatim"
|
|
1510
1511
|
},
|
|
1512
|
+
{
|
|
1513
|
+
"source": "package/dist/settings/update.d.ts",
|
|
1514
|
+
"output": "settings/update.d.ts",
|
|
1515
|
+
"bytes": 863,
|
|
1516
|
+
"sourceSha256": "4bb1820b65c2cdca47332d051a9f68aa88e1277ae97ae72f1679dc6baf615cb1",
|
|
1517
|
+
"outputSha256": "4bb1820b65c2cdca47332d051a9f68aa88e1277ae97ae72f1679dc6baf615cb1",
|
|
1518
|
+
"transform": "verbatim"
|
|
1519
|
+
},
|
|
1511
1520
|
{
|
|
1512
1521
|
"source": "package/dist/settings/update.js",
|
|
1513
1522
|
"output": "settings/update.js",
|
|
1514
|
-
"bytes":
|
|
1515
|
-
"sourceSha256": "
|
|
1516
|
-
"outputSha256": "
|
|
1523
|
+
"bytes": 6482,
|
|
1524
|
+
"sourceSha256": "f3d7446d74d22d59131563c2b915f46ea00973d89378bceceffd7bb757d26570",
|
|
1525
|
+
"outputSha256": "f3d7446d74d22d59131563c2b915f46ea00973d89378bceceffd7bb757d26570",
|
|
1517
1526
|
"transform": "verbatim"
|
|
1518
1527
|
},
|
|
1519
1528
|
{
|
|
@@ -2079,17 +2088,17 @@
|
|
|
2079
2088
|
{
|
|
2080
2089
|
"source": "package/dist/routing-accessor/index.d.ts",
|
|
2081
2090
|
"output": "routing-accessor/index.d.ts",
|
|
2082
|
-
"bytes":
|
|
2083
|
-
"sourceSha256": "
|
|
2084
|
-
"outputSha256": "
|
|
2091
|
+
"bytes": 8159,
|
|
2092
|
+
"sourceSha256": "be4ee94f1f7ebcc587388df1c4c7744d2f15d6f1cabe08734fdec91012b0946f",
|
|
2093
|
+
"outputSha256": "be4ee94f1f7ebcc587388df1c4c7744d2f15d6f1cabe08734fdec91012b0946f",
|
|
2085
2094
|
"transform": "verbatim"
|
|
2086
2095
|
},
|
|
2087
2096
|
{
|
|
2088
2097
|
"source": "package/dist/routing-accessor/index.js",
|
|
2089
2098
|
"output": "routing-accessor/index.js",
|
|
2090
|
-
"bytes":
|
|
2091
|
-
"sourceSha256": "
|
|
2092
|
-
"outputSha256": "
|
|
2099
|
+
"bytes": 18496,
|
|
2100
|
+
"sourceSha256": "e4b90716dfc490aa2abca9062b46f2da30b49d8478d101888efbb6b93de63662",
|
|
2101
|
+
"outputSha256": "e4b90716dfc490aa2abca9062b46f2da30b49d8478d101888efbb6b93de63662",
|
|
2093
2102
|
"transform": "verbatim"
|
|
2094
2103
|
}
|
|
2095
2104
|
],
|