@drisp/protocol 0.8.1 → 0.8.2
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/v2.d.ts +4 -3
- package/dist/v2.js +4 -2
- package/package.json +1 -1
package/dist/v2.d.ts
CHANGED
|
@@ -13,11 +13,12 @@ type SizeClass = 'S' | 'M' | 'L';
|
|
|
13
13
|
declare const SIZE_CLASS_CAPS: Readonly<Record<SizeClass, number>>;
|
|
14
14
|
/** What a Run of each class is expected to use: default, not measured. */
|
|
15
15
|
declare const SIZE_CLASS_FORECASTS: Readonly<Record<SizeClass, number>>;
|
|
16
|
-
/** The smallest class whose cap is at least the declared one; above the largest cap is `L`. */
|
|
16
|
+
/** The smallest class whose cap is at least the declared one; above the largest cap is `L`. A cap that is no number reads as `S`. */
|
|
17
17
|
declare function classOfCap(declaredCap: number): SizeClass;
|
|
18
18
|
/**
|
|
19
|
-
* What one attempt holds against the budget: a closed attempt (finished, failed, cancelled) its forecast
|
|
20
|
-
* or queued one still its
|
|
19
|
+
* What one attempt holds against the budget: a closed attempt (finished, failed, cancelled) its forecast, never more
|
|
20
|
+
* than its own declared cap (so the rule stays looser than the cap sum it replaces); a running or queued one still its
|
|
21
|
+
* declared cap. A closed attempt whose cap is no positive number counts its forecast.
|
|
21
22
|
*/
|
|
22
23
|
declare function attemptCost(attempt: {
|
|
23
24
|
tokenCap: number;
|
package/dist/v2.js
CHANGED
|
@@ -59,12 +59,14 @@ var SIZE_CLASS_FORECASTS = {
|
|
|
59
59
|
L: 12e5
|
|
60
60
|
};
|
|
61
61
|
function classOfCap(declaredCap) {
|
|
62
|
-
if (declaredCap <= SIZE_CLASS_CAPS.S) return "S";
|
|
62
|
+
if (Number.isNaN(declaredCap) || declaredCap <= SIZE_CLASS_CAPS.S) return "S";
|
|
63
63
|
if (declaredCap <= SIZE_CLASS_CAPS.M) return "M";
|
|
64
64
|
return "L";
|
|
65
65
|
}
|
|
66
66
|
function attemptCost(attempt) {
|
|
67
|
-
|
|
67
|
+
if (!attempt.closed) return attempt.tokenCap;
|
|
68
|
+
const forecast = SIZE_CLASS_FORECASTS[classOfCap(attempt.tokenCap)];
|
|
69
|
+
return attempt.tokenCap > 0 ? Math.min(attempt.tokenCap, forecast) : forecast;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
// src/v2.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drisp/protocol",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Wire contract between a drisp runner and the hub: zod schemas, inferred types, and JSON Schema for the instance-socket frames, Run, Turn, Interruption, and the event stream",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|