@cortexkit/common-auth 0.32.1 → 0.34.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/claustrum/consumer.d.ts +12 -0
- package/dist/claustrum/consumer.js +36 -0
- package/dist/claustrum/custody.d.ts +16 -4
- package/dist/claustrum/custody.js +74 -9
- package/dist/claustrum/hub.d.ts +3 -2
- package/dist/claustrum/hub.js +8 -0
- package/dist/claustrum/index.d.ts +1 -0
- package/dist/claustrum/roster.d.ts +2 -0
- package/dist/claustrum/roster.js +2 -0
- package/dist/claustrum/usage.d.ts +41 -0
- package/dist/claustrum/usage.js +145 -0
- package/dist/commands/builtins.d.ts +5 -0
- package/dist/commands/builtins.js +38 -0
- package/dist/fs/private-files.d.ts +5 -0
- package/dist/fs/private-files.js +7 -0
- package/dist/fs/refresh-file-lock.js +144 -49
- package/dist/fs/with-lock.js +34 -10
- package/dist/limits/activity.d.ts +26 -0
- package/dist/limits/activity.js +52 -0
- package/dist/limits/axes.d.ts +63 -0
- package/dist/limits/axes.js +7 -0
- package/dist/limits/bridge.d.ts +4 -0
- package/dist/limits/bridge.js +10 -0
- package/dist/limits/decide.d.ts +141 -0
- package/dist/limits/decide.js +383 -0
- package/dist/limits/duration.d.ts +8 -0
- package/dist/limits/duration.js +20 -0
- package/dist/limits/envelope-loss.d.ts +29 -0
- package/dist/limits/envelope-loss.js +150 -0
- package/dist/limits/families.d.ts +57 -0
- package/dist/limits/families.js +143 -0
- package/dist/limits/header-classifier.d.ts +9 -0
- package/dist/limits/header-classifier.js +121 -0
- package/dist/limits/hold.d.ts +13 -0
- package/dist/limits/hold.js +25 -0
- package/dist/limits/identity.d.ts +14 -0
- package/dist/limits/identity.js +21 -0
- package/dist/limits/index.d.ts +44 -0
- package/dist/limits/index.js +25 -0
- package/dist/limits/jitter.d.ts +2 -0
- package/dist/limits/jitter.js +9 -0
- package/dist/limits/labels.d.ts +3 -0
- package/dist/limits/labels.js +11 -0
- package/dist/limits/marker.d.ts +64 -0
- package/dist/limits/marker.js +96 -0
- package/dist/limits/merge-laws.d.ts +14 -0
- package/dist/limits/merge-laws.js +31 -0
- package/dist/limits/namespace.d.ts +89 -0
- package/dist/limits/namespace.js +183 -0
- package/dist/limits/persistence.d.ts +33 -0
- package/dist/limits/persistence.js +9 -0
- package/dist/limits/pi-wait.d.ts +16 -0
- package/dist/limits/pi-wait.js +51 -0
- package/dist/limits/pool-adapter.d.ts +16 -0
- package/dist/limits/pool-adapter.js +162 -0
- package/dist/limits/presets.d.ts +11 -0
- package/dist/limits/presets.js +223 -0
- package/dist/limits/registry.d.ts +49 -0
- package/dist/limits/registry.js +471 -0
- package/dist/limits/request-history.d.ts +77 -0
- package/dist/limits/request-history.js +117 -0
- package/dist/limits/reset.d.ts +21 -0
- package/dist/limits/reset.js +44 -0
- package/dist/limits/routing-hold.d.ts +16 -0
- package/dist/limits/routing-hold.js +23 -0
- package/dist/limits/scope.d.ts +12 -0
- package/dist/limits/scope.js +10 -0
- package/dist/limits/signal.d.ts +41 -0
- package/dist/limits/signal.js +1 -0
- package/dist/limits/terminal.d.ts +52 -0
- package/dist/limits/terminal.js +133 -0
- package/dist/limits/vault-adapter.d.ts +16 -0
- package/dist/limits/vault-adapter.js +123 -0
- package/dist/limits/vault.d.ts +1 -0
- package/dist/limits/vault.js +1 -0
- package/dist/limits/wake.d.ts +21 -0
- package/dist/limits/wake.js +47 -0
- package/dist/limits/wording.d.ts +25 -0
- package/dist/limits/wording.js +114 -0
- package/dist/opencode2/index.d.ts +1 -1
- package/dist/opencode2/install.d.ts +2 -2
- package/dist/opencode2/install.js +161 -18
- package/dist/opencode2/types.d.ts +95 -9
- package/dist/quota/format.d.ts +9 -4
- package/dist/quota/format.js +45 -26
- package/dist/quota-sidebar/index.jsx +27 -19
- package/dist/routing/admission.d.ts +7 -2
- package/dist/routing/admission.js +17 -7
- package/dist/routing-accessor/handle.d.ts +1 -0
- package/dist/routing-accessor/handle.js +10 -0
- package/dist/routing-accessor/index.d.ts +18 -2
- package/dist/routing-accessor/index.js +21 -11
- package/dist/rpc/port-file.d.ts +12 -3
- package/dist/rpc/port-file.js +46 -4
- package/dist/store/attribution.js +3 -2
- package/dist/store/errors.d.ts +1 -1
- package/dist/store/hooks.d.ts +5 -1
- package/dist/store/hooks.js +20 -5
- package/dist/store/index.d.ts +1 -0
- package/dist/store/limits-namespace.d.ts +7 -0
- package/dist/store/limits-namespace.js +34 -0
- package/dist/store/pool.d.ts +10 -1
- package/dist/store/pool.js +2 -0
- package/dist/store/provider-state.js +5 -5
- package/dist/store/refresh.js +1 -1
- package/dist/store/schema.js +9 -4
- package/dist/store/settings.d.ts +2 -0
- package/dist/store/settings.js +11 -4
- package/package.json +10 -2
- package/src/quota/format.ts +56 -26
- package/src/quota-sidebar/index.tsx +56 -32
package/src/quota/format.ts
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
//
|
|
6
6
|
// The rules: a window is named by its length (`5h`, `7d`), or, for a window
|
|
7
7
|
// that binds only one model family, by the label the plugin stored it under.
|
|
8
|
-
// Every figure is "% left". A window the provider did not
|
|
9
|
-
// record or a retirement tombstone) is left out rather than
|
|
10
|
-
// reported". A reset is a short time from now (`resets 2h`).
|
|
11
|
-
// than fifteen minutes says how old it is (`checked 3h ago`).
|
|
8
|
+
// Every reported window figure is "% left". A window the provider did not
|
|
9
|
+
// report (an absence record or a retirement tombstone) is left out rather than
|
|
10
|
+
// written as "not reported". A reset is a short time from now (`resets 2h`).
|
|
11
|
+
// A reading older than fifteen minutes says how old it is (`checked 3h ago`).
|
|
12
12
|
//
|
|
13
13
|
// Like the rest of this module it reads no clock: `now` is a parameter.
|
|
14
14
|
|
|
@@ -54,6 +54,8 @@ export interface QuotaTextOptions {
|
|
|
54
54
|
|
|
55
55
|
export interface QuotaWindowPart {
|
|
56
56
|
kind: 'window' | 'budget'
|
|
57
|
+
/** Unknown windows have no dated percentage; budgets retain their own wording. */
|
|
58
|
+
reading: 'known' | 'unknown'
|
|
57
59
|
/** The display name of a quota window, or `credits` for the budget. */
|
|
58
60
|
name: string
|
|
59
61
|
/**
|
|
@@ -69,7 +71,8 @@ export interface QuotaWindowPart {
|
|
|
69
71
|
remainingPercent?: number
|
|
70
72
|
/** A bare relative reset span such as `4d`, only when the reset is future. */
|
|
71
73
|
resetIn?: string
|
|
72
|
-
|
|
74
|
+
/** The reading time, omitted for a window with no reading. */
|
|
75
|
+
checkedAt?: number
|
|
73
76
|
/** Whether the reset followed this reading and has arrived by `now`. */
|
|
74
77
|
resetSinceReading: boolean
|
|
75
78
|
}
|
|
@@ -164,15 +167,17 @@ function displayOrder(left: ProjectedLimit, right: ProjectedLimit): number {
|
|
|
164
167
|
}
|
|
165
168
|
|
|
166
169
|
/**
|
|
167
|
-
* Structured quota wording for layouts that need one row per window.
|
|
168
|
-
*
|
|
169
|
-
*
|
|
170
|
+
* Structured quota wording for layouts that need one row per window.
|
|
171
|
+
* Windows without a dated percentage remain as explicit unknown parts. Limits
|
|
172
|
+
* marked absent (not reported) or retired (no longer tracked) remain omitted.
|
|
173
|
+
* Reported windows, future resets and the optional age keep the shared
|
|
174
|
+
* formatter's wording and order.
|
|
170
175
|
*/
|
|
171
176
|
export function quotaWindowParts(
|
|
172
177
|
quota: ProjectedQuota | undefined,
|
|
173
178
|
options: QuotaTextOptions,
|
|
174
179
|
): QuotaParts {
|
|
175
|
-
const { windows, age } = scopedWindowParts(quota, options)
|
|
180
|
+
const { windows, age } = scopedWindowParts(quota, options, true)
|
|
176
181
|
const parts = windows.map(({ part }) => part)
|
|
177
182
|
return age === undefined ? { windows: parts } : { windows: parts, age }
|
|
178
183
|
}
|
|
@@ -211,39 +216,58 @@ interface ScopedWindowPart {
|
|
|
211
216
|
spent?: boolean
|
|
212
217
|
}
|
|
213
218
|
|
|
219
|
+
function hasWindowReading(
|
|
220
|
+
limit: ProjectedLimit,
|
|
221
|
+
): limit is ProjectedLimit & { remainingPercent: number } {
|
|
222
|
+
return (
|
|
223
|
+
Number.isFinite(limit.remainingPercent) && Number.isFinite(limit.checkedAt)
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
|
|
214
227
|
/**
|
|
215
228
|
* `quotaWindowParts` with each window's scope kept beside it. The narrow form
|
|
216
229
|
* needs the scope to name and pick model-scoped windows; the public parts do
|
|
217
|
-
* not carry
|
|
230
|
+
* not carry the scope.
|
|
218
231
|
*/
|
|
219
232
|
function scopedWindowParts(
|
|
220
233
|
quota: ProjectedQuota | undefined,
|
|
221
234
|
options: QuotaTextOptions,
|
|
235
|
+
includeUnknown = false,
|
|
222
236
|
): { windows: ScopedWindowPart[]; age?: string } {
|
|
223
237
|
if (!quota) return { windows: [] }
|
|
224
238
|
const { now } = options
|
|
225
239
|
const readings = quota.limits
|
|
226
240
|
.filter(
|
|
227
241
|
(limit) =>
|
|
228
|
-
limit.kind === 'reading' &&
|
|
242
|
+
limit.kind === 'reading' && (includeUnknown || hasWindowReading(limit)),
|
|
229
243
|
)
|
|
230
244
|
.sort(displayOrder)
|
|
231
245
|
const windows: ScopedWindowPart[] = readings.map((limit) => {
|
|
232
|
-
const
|
|
246
|
+
const part: QuotaWindowPart = hasWindowReading(limit)
|
|
247
|
+
? {
|
|
248
|
+
kind: 'window',
|
|
249
|
+
reading: 'known',
|
|
250
|
+
name: quotaWindowName(limit),
|
|
251
|
+
short: '',
|
|
252
|
+
figure: percentLeft(limit.remainingPercent),
|
|
253
|
+
remainingPercent: clampPercent(limit.remainingPercent),
|
|
254
|
+
checkedAt: limit.checkedAt,
|
|
255
|
+
...resetDetails(limit.resetsAt, limit.checkedAt, now),
|
|
256
|
+
}
|
|
257
|
+
: {
|
|
258
|
+
kind: 'window',
|
|
259
|
+
reading: 'unknown',
|
|
260
|
+
name: quotaWindowName(limit),
|
|
261
|
+
short: '',
|
|
262
|
+
figure: 'no reading',
|
|
263
|
+
resetSinceReading: false,
|
|
264
|
+
}
|
|
233
265
|
return {
|
|
234
266
|
scope: limit.scope,
|
|
235
267
|
...(limit.windowMinutes === undefined
|
|
236
268
|
? {}
|
|
237
269
|
: { windowMinutes: limit.windowMinutes }),
|
|
238
|
-
part
|
|
239
|
-
kind: 'window',
|
|
240
|
-
name: quotaWindowName(limit),
|
|
241
|
-
short: '',
|
|
242
|
-
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
243
|
-
remainingPercent,
|
|
244
|
-
checkedAt: limit.checkedAt,
|
|
245
|
-
...resetDetails(limit.resetsAt, limit.checkedAt, now),
|
|
246
|
-
},
|
|
270
|
+
part,
|
|
247
271
|
}
|
|
248
272
|
})
|
|
249
273
|
const budget = quota.budget
|
|
@@ -259,6 +283,7 @@ function scopedWindowParts(
|
|
|
259
283
|
spent: budget.reached,
|
|
260
284
|
part: {
|
|
261
285
|
kind: 'budget',
|
|
286
|
+
reading: 'known',
|
|
262
287
|
name: 'credits',
|
|
263
288
|
short: '',
|
|
264
289
|
figure,
|
|
@@ -272,8 +297,13 @@ function scopedWindowParts(
|
|
|
272
297
|
}
|
|
273
298
|
|
|
274
299
|
withShortNames(windows)
|
|
275
|
-
|
|
276
|
-
|
|
300
|
+
const readingTimes = windows.flatMap(({ part }) =>
|
|
301
|
+
part.reading === 'known' && part.checkedAt !== undefined
|
|
302
|
+
? [part.checkedAt]
|
|
303
|
+
: [],
|
|
304
|
+
)
|
|
305
|
+
if (readingTimes.length > 0) {
|
|
306
|
+
const age = now - Math.min(...readingTimes)
|
|
277
307
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
278
308
|
return { windows, age: `checked ${shortSpan(age)} ago` }
|
|
279
309
|
}
|
|
@@ -478,13 +508,13 @@ export function quotaTextParts(
|
|
|
478
508
|
options: QuotaTextOptions,
|
|
479
509
|
): string[] {
|
|
480
510
|
if (options.form === 'narrow') return narrowTextParts(quota, options)
|
|
481
|
-
const
|
|
511
|
+
const { windows, age } = scopedWindowParts(quota, options)
|
|
482
512
|
const full = (options.form ?? 'full') === 'full'
|
|
483
|
-
const text =
|
|
513
|
+
const text = windows.map(({ part }) => {
|
|
484
514
|
const reset = full && part.resetIn ? `, resets ${part.resetIn}` : ''
|
|
485
515
|
return `${part.kind === 'budget' ? '' : `${part.name} `}${part.figure}${reset}`
|
|
486
516
|
})
|
|
487
|
-
return
|
|
517
|
+
return age === undefined ? text : [...text, age]
|
|
488
518
|
}
|
|
489
519
|
|
|
490
520
|
/**
|
|
@@ -238,17 +238,20 @@ function QuotaRow(props: {
|
|
|
238
238
|
' '.repeat(Math.max(0, props.labelWidth - displayWidth(props.part.name)))
|
|
239
239
|
const figure = () =>
|
|
240
240
|
` ${props.part.kind === 'budget' && props.part.figure.startsWith(`${props.part.name} `) ? props.part.figure.slice(props.part.name.length + 1) : props.part.figure}`
|
|
241
|
+
const hasReading = () => props.part.reading === 'known'
|
|
241
242
|
const used = () => 100 - (props.part.remainingPercent ?? 100)
|
|
242
243
|
// Size notifications can recompute an unchanged fit after text has been flushed
|
|
243
244
|
// for the frame. Keep equal segments, and update fixed slots in place when the
|
|
244
245
|
// bar changes, rather than replacing text nodes during layout.
|
|
245
246
|
const segments = createMemo(
|
|
246
247
|
() =>
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
248
|
+
hasReading()
|
|
249
|
+
? barSegments(
|
|
250
|
+
used(),
|
|
251
|
+
{ ...context.appearance, barWidth: props.barCells },
|
|
252
|
+
props.pace,
|
|
253
|
+
)
|
|
254
|
+
: [],
|
|
252
255
|
undefined,
|
|
253
256
|
{
|
|
254
257
|
equals: (previous, next) =>
|
|
@@ -286,36 +289,49 @@ function QuotaRow(props: {
|
|
|
286
289
|
</text>
|
|
287
290
|
</Show>
|
|
288
291
|
<Show
|
|
289
|
-
when={
|
|
292
|
+
when={hasReading()}
|
|
290
293
|
fallback={
|
|
291
294
|
<text fg={context.theme.textMuted} wrapMode='none'>
|
|
292
|
-
|
|
295
|
+
no reading
|
|
293
296
|
</text>
|
|
294
297
|
}
|
|
295
298
|
>
|
|
296
|
-
<Show
|
|
297
|
-
{
|
|
298
|
-
|
|
299
|
-
{
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
width={segment().text ? undefined : 0}
|
|
304
|
-
>
|
|
305
|
-
{segment().text}
|
|
306
|
-
</text>
|
|
307
|
-
)}
|
|
308
|
-
</Index>
|
|
309
|
-
</Show>
|
|
310
|
-
<text
|
|
311
|
-
fg={context.theme[usageTone(used(), context.appearance)]}
|
|
312
|
-
wrapMode='none'
|
|
299
|
+
<Show
|
|
300
|
+
when={!props.part.resetSinceReading}
|
|
301
|
+
fallback={
|
|
302
|
+
<text fg={context.theme.textMuted} wrapMode='none'>
|
|
303
|
+
reset since last check
|
|
304
|
+
</text>
|
|
305
|
+
}
|
|
313
306
|
>
|
|
314
|
-
{
|
|
315
|
-
|
|
307
|
+
<Show when={props.barCells > 0}>
|
|
308
|
+
{/* Text nodes clear omitted theme colours; empty slots must not reserve a cell. */}
|
|
309
|
+
<Index each={segments()}>
|
|
310
|
+
{(segment) => (
|
|
311
|
+
<text
|
|
312
|
+
fg={context.theme[segment().tone]}
|
|
313
|
+
wrapMode='none'
|
|
314
|
+
width={segment().text ? undefined : 0}
|
|
315
|
+
>
|
|
316
|
+
{segment().text}
|
|
317
|
+
</text>
|
|
318
|
+
)}
|
|
319
|
+
</Index>
|
|
320
|
+
</Show>
|
|
321
|
+
<text
|
|
322
|
+
fg={context.theme[usageTone(used(), context.appearance)]}
|
|
323
|
+
wrapMode='none'
|
|
324
|
+
>
|
|
325
|
+
{figure()}
|
|
326
|
+
</text>
|
|
327
|
+
</Show>
|
|
316
328
|
</Show>
|
|
317
329
|
</box>
|
|
318
|
-
<Show
|
|
330
|
+
<Show
|
|
331
|
+
when={
|
|
332
|
+
hasReading() && props.showReset && !props.part.resetSinceReading
|
|
333
|
+
}
|
|
334
|
+
>
|
|
319
335
|
<box
|
|
320
336
|
width={props.resetWidth}
|
|
321
337
|
flexShrink={0}
|
|
@@ -331,7 +347,10 @@ function QuotaRow(props: {
|
|
|
331
347
|
</Show>
|
|
332
348
|
</box>
|
|
333
349
|
{/* A changed fitted line needs a fresh text node to draw at its new width. */}
|
|
334
|
-
<Show
|
|
350
|
+
<Show
|
|
351
|
+
when={hasReading() && !props.part.resetSinceReading && paceLine()}
|
|
352
|
+
keyed
|
|
353
|
+
>
|
|
335
354
|
{(line: string) => (
|
|
336
355
|
<box width='100%' flexDirection='row'>
|
|
337
356
|
<Show when={props.labelWidth > 0}>
|
|
@@ -357,8 +376,9 @@ function CollapsedAccountRow(props: { account: AccountView }) {
|
|
|
357
376
|
const [width, setWidth] = createSignal(0)
|
|
358
377
|
let row: { width: number } | undefined
|
|
359
378
|
const hasQuota = () =>
|
|
360
|
-
quotaWindowParts(props.account.quota, { now: context.now }).windows.
|
|
361
|
-
|
|
379
|
+
quotaWindowParts(props.account.quota, { now: context.now }).windows.some(
|
|
380
|
+
(part) => part.reading === 'known',
|
|
381
|
+
)
|
|
362
382
|
const text = () =>
|
|
363
383
|
hasQuota()
|
|
364
384
|
? formatQuota(props.account.quota, { now: context.now, form: 'narrow' })
|
|
@@ -431,14 +451,18 @@ function AccountBlock(props: { account: AccountView; marginTop: number }) {
|
|
|
431
451
|
Math.max(
|
|
432
452
|
0,
|
|
433
453
|
...rows().map(({ part }) =>
|
|
434
|
-
part.
|
|
454
|
+
part.reading === 'unknown' || part.resetSinceReading
|
|
455
|
+
? 0
|
|
456
|
+
: displayWidth(part.resetIn ?? ''),
|
|
435
457
|
),
|
|
436
458
|
)
|
|
437
459
|
const figureWidth = createMemo(() =>
|
|
438
460
|
Math.max(
|
|
439
461
|
10,
|
|
440
462
|
...rows()
|
|
441
|
-
.filter(
|
|
463
|
+
.filter(
|
|
464
|
+
({ part }) => part.reading === 'known' && !part.resetSinceReading,
|
|
465
|
+
)
|
|
442
466
|
.map(({ part }) =>
|
|
443
467
|
displayWidth(
|
|
444
468
|
` ${part.kind === 'budget' && part.figure.startsWith(`${part.name} `) ? part.figure.slice(part.name.length + 1) : part.figure}`,
|