@cortexkit/opencode-openai-auth 1.22.0 → 1.23.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/dist/bin.js +2 -2
- package/dist/index-2z4dbnsf.js +60 -0
- package/dist/{index-677jqrrt.js → index-7hcv94as.js} +1 -1
- package/dist/{index-6afhs2jq.js → index-897br01q.js} +2 -2
- package/dist/{index-1k8a281v.js → index-bbrpg1ms.js} +2 -2
- package/dist/{index-w6kars9d.js → index-bpx4spyr.js} +1 -1
- package/dist/{index-0wh22s62.js → index-d0g5g290.js} +1 -1
- package/dist/{index-67twdyyz.js → index-f340dq90.js} +11 -11
- package/dist/{index-vaf4mqd1.js → index-fasy4end.js} +2 -2
- package/dist/{index-mepr345k.js → index-j700j6at.js} +1 -1
- package/dist/{index-9tg5xx9a.js → index-q2czrasr.js} +1 -1
- package/dist/{index-8bt81cys.js → index-r31f36mn.js} +2 -2
- package/dist/index-s7dwe5n8.js +79 -0
- package/dist/{index-b3bgqy7r.js → index-sx9jjkry.js} +2 -2
- package/dist/{index-xbhtpa9s.js → index-x25m9spd.js} +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/openai-auth.schema.json +274 -27
- package/dist/rpc/port-file.js +1 -1
- package/dist/rpc/protocol.js +1 -1
- package/dist/rpc/rpc-client.js +1 -1
- package/dist/rpc/rpc-dir.js +1 -1
- package/dist/{runtime-layout-DdxprfY1.d.ts → runtime-layout-B07ApQZL.d.ts} +1 -1
- package/dist/sidebar-state.js +1 -1
- package/dist/{token-92yc9q7w.js → token-hczqrmmz.js} +1 -1
- package/dist/token-util-9t4ma4jz.js +1 -0
- package/dist/tui-preferences.js +1 -1
- package/dist/v2/server.d.ts +7 -6
- package/dist/v2/server.js +4 -4
- package/package.json +2 -2
- package/src/tui-compiled/raw/shared/58bc35a3cd459085-define.js +10 -1
- package/src/tui-compiled/raw/shared/87f6e22d4fc34918-resolve.js +10 -5
- package/src/tui-compiled/raw/shared/bfbdd0f9aae56b47-pool-quota.js +10 -0
- package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +1 -1
- package/src/tui-compiled/raw/shared/fe02abeadc535f77-rows.js +8 -3
- package/src/tui-compiled/runtime/shared/58bc35a3cd459085-define.js +10 -1
- package/src/tui-compiled/runtime/shared/87f6e22d4fc34918-resolve.js +10 -5
- package/src/tui-compiled/runtime/shared/bfbdd0f9aae56b47-pool-quota.js +10 -0
- package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +1 -1
- package/src/tui-compiled/runtime/shared/fe02abeadc535f77-rows.js +8 -3
- package/dist/index-dw1nh7dk.js +0 -60
- package/dist/index-ney54jhs.js +0 -79
- package/dist/token-util-g8e70a6j.js +0 -1
|
@@ -10,11 +10,20 @@ export function defineSettings(definition) {
|
|
|
10
10
|
if (name === 'sidebar' && declaration.value.kind !== 'object') {
|
|
11
11
|
throw new TypeError('The sidebar setting must use an object descriptor');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const { overrides } = declaration;
|
|
14
|
+
if (overrides !== undefined &&
|
|
14
15
|
(declaration.value.kind === 'object' ||
|
|
15
16
|
declaration.value.kind === 'record')) {
|
|
16
17
|
throw new TypeError(`Object and record settings cannot use overrides: ${name}`);
|
|
17
18
|
}
|
|
19
|
+
if (overrides?.isolatedHosts !== undefined &&
|
|
20
|
+
(overrides.host !== true ||
|
|
21
|
+
overrides.model === true ||
|
|
22
|
+
!Array.isArray(overrides.isolatedHosts) ||
|
|
23
|
+
overrides.isolatedHosts.length === 0 ||
|
|
24
|
+
!Array.from(overrides.isolatedHosts).every((host) => typeof host === 'string'))) {
|
|
25
|
+
throw new TypeError(`isolatedHosts must be a non-empty array of host names and requires host overrides without model overrides: ${name}`);
|
|
26
|
+
}
|
|
18
27
|
if (!Object.hasOwn(declaration, 'default') ||
|
|
19
28
|
!validateValue(declaration.value, declaration.default, {
|
|
20
29
|
completeObjects: true,
|
|
@@ -4,10 +4,13 @@ function valueAtLevel(declaration, name, snapshot, options) {
|
|
|
4
4
|
if (!snapshot || !Object.hasOwn(snapshot.settings, name))
|
|
5
5
|
return undefined;
|
|
6
6
|
const value = snapshot.settings[name];
|
|
7
|
-
|
|
8
|
-
return value;
|
|
7
|
+
const { overrides } = declaration;
|
|
9
8
|
const { model, host } = options;
|
|
10
|
-
|
|
9
|
+
const isolated = overrides?.isolatedHosts?.includes(host);
|
|
10
|
+
if (overrides === undefined || !isJsonObject(value)) {
|
|
11
|
+
return isolated ? undefined : value;
|
|
12
|
+
}
|
|
13
|
+
if (overrides.model &&
|
|
11
14
|
model !== undefined &&
|
|
12
15
|
model !== 'default' &&
|
|
13
16
|
model !== 'opencode' &&
|
|
@@ -15,12 +18,14 @@ function valueAtLevel(declaration, name, snapshot, options) {
|
|
|
15
18
|
Object.hasOwn(value, model)) {
|
|
16
19
|
return value[model];
|
|
17
20
|
}
|
|
18
|
-
if (
|
|
21
|
+
if (overrides.host &&
|
|
19
22
|
(host === 'opencode' || host === 'pi') &&
|
|
20
23
|
Object.hasOwn(value, host)) {
|
|
21
24
|
return value[host];
|
|
22
25
|
}
|
|
23
|
-
return Object.hasOwn(value, 'default')
|
|
26
|
+
return !isolated && Object.hasOwn(value, 'default')
|
|
27
|
+
? value.default
|
|
28
|
+
: undefined;
|
|
24
29
|
}
|
|
25
30
|
/** Snapshot validation has already removed unusable values and unknown fields. */
|
|
26
31
|
function resolveValue(descriptor, levels) {
|
|
@@ -9,6 +9,16 @@ function isRecord(value) {
|
|
|
9
9
|
function finite(value) {
|
|
10
10
|
return typeof value === "number" && Number.isFinite(value);
|
|
11
11
|
}
|
|
12
|
+
export function resetCreditsOfQuota(quota) {
|
|
13
|
+
const counters = isRecord(quota) ? quota.counters : void 0, resetCredits = isRecord(counters) ? counters.resetCredits : void 0, credits = isRecord(resetCredits) ? resetCredits.value : void 0;
|
|
14
|
+
return finite(credits) ? credits : void 0;
|
|
15
|
+
}
|
|
16
|
+
export function quotaReadAt(row) {
|
|
17
|
+
if (!isQuotaMap(row.quota))
|
|
18
|
+
return;
|
|
19
|
+
const projection = projectQuota(row.quota);
|
|
20
|
+
return projection.limits.some((limit) => limit.kind === "reading") ? projection.checkedAt : void 0;
|
|
21
|
+
}
|
|
12
22
|
function readingFor(label, window) {
|
|
13
23
|
if (!isRecord(window))
|
|
14
24
|
return;
|
|
@@ -215,7 +215,7 @@ export function normalizeAccount(value) {
|
|
|
215
215
|
quota: normalizeQuota(value.quota)
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
-
function normalizeResetState(value) {
|
|
218
|
+
export function normalizeResetState(value) {
|
|
219
219
|
if (!isRecord(value))
|
|
220
220
|
return;
|
|
221
221
|
const normalized = Object.create(null);
|
|
@@ -229,14 +229,15 @@ export function validateAttribution(operation, id, fence) {
|
|
|
229
229
|
throw refusal(operation, id, 'invalid-input', 'the attribution must name a credential epoch that is a positive safe integer');
|
|
230
230
|
}
|
|
231
231
|
/** Exact recorded identity, including absence, is part of a credential fence. */
|
|
232
|
-
export function assertRowAttribution(operation, id, row, fence) {
|
|
232
|
+
export function assertRowAttribution(operation, id, row, fence, expect) {
|
|
233
233
|
if (!row)
|
|
234
234
|
throw unknownRow(operation, id);
|
|
235
235
|
// A row that failed validation has no usable credential epoch to compare.
|
|
236
236
|
if (row.invalid)
|
|
237
237
|
throw refusal(operation, id, 'invalid-row', `row ${id} failed validation`);
|
|
238
238
|
if ((row.credentialEpoch ?? 1) !== fence.credentialEpoch ||
|
|
239
|
-
row.identity !== fence.identity
|
|
239
|
+
row.identity !== fence.identity ||
|
|
240
|
+
(expect?.credential === 'absent' && row.credential !== undefined))
|
|
240
241
|
throw refusal(operation, id, 'attribution', `the ${operation} of ${id} was issued for a credential or account the row no longer holds`, true);
|
|
241
242
|
}
|
|
242
243
|
/** The row is recorded for another account than the one given. */
|
|
@@ -685,6 +686,10 @@ export async function replaceRow(rt, id, credential, input = {}, options = {}) {
|
|
|
685
686
|
const result = await runOperation(ctx, 'replace', id, options.onFailure, async (locks, progress) => {
|
|
686
687
|
checkInput('replace', id, credential);
|
|
687
688
|
validateAttribution('replace', id, options.attribution);
|
|
689
|
+
const expected = options.attribution?.expect;
|
|
690
|
+
if (expected !== undefined &&
|
|
691
|
+
(!isRecord(expected) || expected.credential !== 'absent'))
|
|
692
|
+
throw refusal('replace', id, 'invalid-input', "the attribution's credential expectation must be 'absent'");
|
|
688
693
|
const incoming = input.providerState === undefined
|
|
689
694
|
? undefined
|
|
690
695
|
: acceptProviderState(ctx.providerState, 'replace', id, input.providerState);
|
|
@@ -701,7 +706,7 @@ export async function replaceRow(rt, id, credential, input = {}, options = {}) {
|
|
|
701
706
|
// the fence with that row before finishing the interrupted write
|
|
702
707
|
// on disk, so a stale caller does not even complete a replacement
|
|
703
708
|
// it was never issued for.
|
|
704
|
-
assertRowAttribution('replace', id, tx.row(id), options.attribution);
|
|
709
|
+
assertRowAttribution('replace', id, tx.row(id), options.attribution, expected);
|
|
705
710
|
await tx.completeTorn();
|
|
706
711
|
}
|
|
707
712
|
const row = requireUsableRow('replace', id, tx.row(id), credential);
|
|
@@ -10,11 +10,20 @@ export function defineSettings(definition) {
|
|
|
10
10
|
if (name === 'sidebar' && declaration.value.kind !== 'object') {
|
|
11
11
|
throw new TypeError('The sidebar setting must use an object descriptor');
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
const { overrides } = declaration;
|
|
14
|
+
if (overrides !== undefined &&
|
|
14
15
|
(declaration.value.kind === 'object' ||
|
|
15
16
|
declaration.value.kind === 'record')) {
|
|
16
17
|
throw new TypeError(`Object and record settings cannot use overrides: ${name}`);
|
|
17
18
|
}
|
|
19
|
+
if (overrides?.isolatedHosts !== undefined &&
|
|
20
|
+
(overrides.host !== true ||
|
|
21
|
+
overrides.model === true ||
|
|
22
|
+
!Array.isArray(overrides.isolatedHosts) ||
|
|
23
|
+
overrides.isolatedHosts.length === 0 ||
|
|
24
|
+
!Array.from(overrides.isolatedHosts).every((host) => typeof host === 'string'))) {
|
|
25
|
+
throw new TypeError(`isolatedHosts must be a non-empty array of host names and requires host overrides without model overrides: ${name}`);
|
|
26
|
+
}
|
|
18
27
|
if (!Object.hasOwn(declaration, 'default') ||
|
|
19
28
|
!validateValue(declaration.value, declaration.default, {
|
|
20
29
|
completeObjects: true,
|
|
@@ -4,10 +4,13 @@ function valueAtLevel(declaration, name, snapshot, options) {
|
|
|
4
4
|
if (!snapshot || !Object.hasOwn(snapshot.settings, name))
|
|
5
5
|
return undefined;
|
|
6
6
|
const value = snapshot.settings[name];
|
|
7
|
-
|
|
8
|
-
return value;
|
|
7
|
+
const { overrides } = declaration;
|
|
9
8
|
const { model, host } = options;
|
|
10
|
-
|
|
9
|
+
const isolated = overrides?.isolatedHosts?.includes(host);
|
|
10
|
+
if (overrides === undefined || !isJsonObject(value)) {
|
|
11
|
+
return isolated ? undefined : value;
|
|
12
|
+
}
|
|
13
|
+
if (overrides.model &&
|
|
11
14
|
model !== undefined &&
|
|
12
15
|
model !== 'default' &&
|
|
13
16
|
model !== 'opencode' &&
|
|
@@ -15,12 +18,14 @@ function valueAtLevel(declaration, name, snapshot, options) {
|
|
|
15
18
|
Object.hasOwn(value, model)) {
|
|
16
19
|
return value[model];
|
|
17
20
|
}
|
|
18
|
-
if (
|
|
21
|
+
if (overrides.host &&
|
|
19
22
|
(host === 'opencode' || host === 'pi') &&
|
|
20
23
|
Object.hasOwn(value, host)) {
|
|
21
24
|
return value[host];
|
|
22
25
|
}
|
|
23
|
-
return Object.hasOwn(value, 'default')
|
|
26
|
+
return !isolated && Object.hasOwn(value, 'default')
|
|
27
|
+
? value.default
|
|
28
|
+
: undefined;
|
|
24
29
|
}
|
|
25
30
|
/** Snapshot validation has already removed unusable values and unknown fields. */
|
|
26
31
|
function resolveValue(descriptor, levels) {
|
|
@@ -9,6 +9,16 @@ function isRecord(value) {
|
|
|
9
9
|
function finite(value) {
|
|
10
10
|
return typeof value === "number" && Number.isFinite(value);
|
|
11
11
|
}
|
|
12
|
+
export function resetCreditsOfQuota(quota) {
|
|
13
|
+
const counters = isRecord(quota) ? quota.counters : void 0, resetCredits = isRecord(counters) ? counters.resetCredits : void 0, credits = isRecord(resetCredits) ? resetCredits.value : void 0;
|
|
14
|
+
return finite(credits) ? credits : void 0;
|
|
15
|
+
}
|
|
16
|
+
export function quotaReadAt(row) {
|
|
17
|
+
if (!isQuotaMap(row.quota))
|
|
18
|
+
return;
|
|
19
|
+
const projection = projectQuota(row.quota);
|
|
20
|
+
return projection.limits.some((limit) => limit.kind === "reading") ? projection.checkedAt : void 0;
|
|
21
|
+
}
|
|
12
22
|
function readingFor(label, window) {
|
|
13
23
|
if (!isRecord(window))
|
|
14
24
|
return;
|
|
@@ -215,7 +215,7 @@ export function normalizeAccount(value) {
|
|
|
215
215
|
quota: normalizeQuota(value.quota)
|
|
216
216
|
};
|
|
217
217
|
}
|
|
218
|
-
function normalizeResetState(value) {
|
|
218
|
+
export function normalizeResetState(value) {
|
|
219
219
|
if (!isRecord(value))
|
|
220
220
|
return;
|
|
221
221
|
const normalized = Object.create(null);
|
|
@@ -229,14 +229,15 @@ export function validateAttribution(operation, id, fence) {
|
|
|
229
229
|
throw refusal(operation, id, 'invalid-input', 'the attribution must name a credential epoch that is a positive safe integer');
|
|
230
230
|
}
|
|
231
231
|
/** Exact recorded identity, including absence, is part of a credential fence. */
|
|
232
|
-
export function assertRowAttribution(operation, id, row, fence) {
|
|
232
|
+
export function assertRowAttribution(operation, id, row, fence, expect) {
|
|
233
233
|
if (!row)
|
|
234
234
|
throw unknownRow(operation, id);
|
|
235
235
|
// A row that failed validation has no usable credential epoch to compare.
|
|
236
236
|
if (row.invalid)
|
|
237
237
|
throw refusal(operation, id, 'invalid-row', `row ${id} failed validation`);
|
|
238
238
|
if ((row.credentialEpoch ?? 1) !== fence.credentialEpoch ||
|
|
239
|
-
row.identity !== fence.identity
|
|
239
|
+
row.identity !== fence.identity ||
|
|
240
|
+
(expect?.credential === 'absent' && row.credential !== undefined))
|
|
240
241
|
throw refusal(operation, id, 'attribution', `the ${operation} of ${id} was issued for a credential or account the row no longer holds`, true);
|
|
241
242
|
}
|
|
242
243
|
/** The row is recorded for another account than the one given. */
|
|
@@ -685,6 +686,10 @@ export async function replaceRow(rt, id, credential, input = {}, options = {}) {
|
|
|
685
686
|
const result = await runOperation(ctx, 'replace', id, options.onFailure, async (locks, progress) => {
|
|
686
687
|
checkInput('replace', id, credential);
|
|
687
688
|
validateAttribution('replace', id, options.attribution);
|
|
689
|
+
const expected = options.attribution?.expect;
|
|
690
|
+
if (expected !== undefined &&
|
|
691
|
+
(!isRecord(expected) || expected.credential !== 'absent'))
|
|
692
|
+
throw refusal('replace', id, 'invalid-input', "the attribution's credential expectation must be 'absent'");
|
|
688
693
|
const incoming = input.providerState === undefined
|
|
689
694
|
? undefined
|
|
690
695
|
: acceptProviderState(ctx.providerState, 'replace', id, input.providerState);
|
|
@@ -701,7 +706,7 @@ export async function replaceRow(rt, id, credential, input = {}, options = {}) {
|
|
|
701
706
|
// the fence with that row before finishing the interrupted write
|
|
702
707
|
// on disk, so a stale caller does not even complete a replacement
|
|
703
708
|
// it was never issued for.
|
|
704
|
-
assertRowAttribution('replace', id, tx.row(id), options.attribution);
|
|
709
|
+
assertRowAttribution('replace', id, tx.row(id), options.attribution, expected);
|
|
705
710
|
await tx.completeTorn();
|
|
706
711
|
}
|
|
707
712
|
const row = requireUsableRow('replace', id, tx.row(id), credential);
|