taximeter 0.2.2 → 0.3.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/CHANGELOG.md +6 -0
- package/README.md +116 -12
- package/dist/{chunk-DJPLFDD7.js → chunk-Q2M76JNT.js} +261 -68
- package/dist/cli/index.js +607 -95
- package/dist/index.d.ts +27 -12
- package/dist/index.js +1 -1
- package/dist/ui/assets/index-_UDg88nw.js +101 -0
- package/dist/ui/index.html +1 -1
- package/docs/SDK.md +20 -9
- package/package.json +1 -1
- package/dist/ui/assets/index-DSVhxCXF.js +0 -101
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { Server } from 'node:http';
|
|
|
4
4
|
declare const configSchema: z.ZodObject<{
|
|
5
5
|
budgets: z.ZodPrefault<z.ZodObject<{
|
|
6
6
|
perTask: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
7
|
-
amount: z.ZodString
|
|
7
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
8
|
+
maxPayments: z.ZodOptional<z.ZodNumber>;
|
|
8
9
|
asset: z.ZodString;
|
|
9
10
|
network: z.ZodOptional<z.ZodString>;
|
|
10
11
|
window: z.ZodOptional<z.ZodEnum<{
|
|
@@ -15,7 +16,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
15
16
|
}>>;
|
|
16
17
|
}, z.core.$strict>>>;
|
|
17
18
|
perAgent: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
18
|
-
amount: z.ZodString
|
|
19
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
20
|
+
maxPayments: z.ZodOptional<z.ZodNumber>;
|
|
19
21
|
asset: z.ZodString;
|
|
20
22
|
network: z.ZodOptional<z.ZodString>;
|
|
21
23
|
window: z.ZodOptional<z.ZodEnum<{
|
|
@@ -26,7 +28,8 @@ declare const configSchema: z.ZodObject<{
|
|
|
26
28
|
}>>;
|
|
27
29
|
}, z.core.$strict>>>;
|
|
28
30
|
global: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
29
|
-
amount: z.ZodString
|
|
31
|
+
amount: z.ZodOptional<z.ZodString>;
|
|
32
|
+
maxPayments: z.ZodOptional<z.ZodNumber>;
|
|
30
33
|
asset: z.ZodString;
|
|
31
34
|
network: z.ZodOptional<z.ZodString>;
|
|
32
35
|
window: z.ZodOptional<z.ZodEnum<{
|
|
@@ -59,29 +62,34 @@ type TaximeterConfig = z.infer<typeof configSchema>;
|
|
|
59
62
|
/** Merge validated layers from lowest to highest priority without mutating inputs. */
|
|
60
63
|
declare function parseConfig(...layers: unknown[]): TaximeterConfig;
|
|
61
64
|
|
|
62
|
-
|
|
65
|
+
type ConfigLoadOptions = {
|
|
63
66
|
cwd?: string;
|
|
64
67
|
home?: string;
|
|
65
68
|
env?: unknown;
|
|
66
69
|
configFile?: string;
|
|
67
|
-
|
|
68
|
-
|
|
70
|
+
/** Candidate file contents for validation; this never changes the filesystem. */
|
|
71
|
+
layerOverrides?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
declare function loadConfig(flags?: unknown, options?: ConfigLoadOptions): {
|
|
69
74
|
budgets: {
|
|
70
75
|
perTask: {
|
|
71
|
-
amount: string;
|
|
72
76
|
asset: string;
|
|
77
|
+
amount?: string | undefined;
|
|
78
|
+
maxPayments?: number | undefined;
|
|
73
79
|
network?: string | undefined;
|
|
74
80
|
window?: "1h" | "24h" | "7d" | "30d" | undefined;
|
|
75
81
|
} | null;
|
|
76
82
|
perAgent: {
|
|
77
|
-
amount: string;
|
|
78
83
|
asset: string;
|
|
84
|
+
amount?: string | undefined;
|
|
85
|
+
maxPayments?: number | undefined;
|
|
79
86
|
network?: string | undefined;
|
|
80
87
|
window?: "1h" | "24h" | "7d" | "30d" | undefined;
|
|
81
88
|
} | null;
|
|
82
89
|
global: {
|
|
83
|
-
amount: string;
|
|
84
90
|
asset: string;
|
|
91
|
+
amount?: string | undefined;
|
|
92
|
+
maxPayments?: number | undefined;
|
|
85
93
|
network?: string | undefined;
|
|
86
94
|
window?: "1h" | "24h" | "7d" | "30d" | undefined;
|
|
87
95
|
} | null;
|
|
@@ -98,6 +106,7 @@ declare function loadConfig(flags?: unknown, options?: {
|
|
|
98
106
|
proxy: number;
|
|
99
107
|
dashboard: number;
|
|
100
108
|
};
|
|
109
|
+
db: string;
|
|
101
110
|
upstream?: string | undefined;
|
|
102
111
|
};
|
|
103
112
|
|
|
@@ -178,6 +187,7 @@ declare const blockedBodySchema: z.ZodObject<{
|
|
|
178
187
|
budget: z.ZodNullable<z.ZodString>;
|
|
179
188
|
spent: z.ZodString;
|
|
180
189
|
remaining: z.ZodNullable<z.ZodString>;
|
|
190
|
+
fix: z.ZodOptional<z.ZodString>;
|
|
181
191
|
}, z.core.$strip>;
|
|
182
192
|
type BlockedBody = z.infer<typeof blockedBodySchema>;
|
|
183
193
|
|
|
@@ -191,6 +201,7 @@ type Scope = "perTask" | "perAgent" | "global";
|
|
|
191
201
|
type PolicyState = {
|
|
192
202
|
reserved: PaymentEvent | undefined;
|
|
193
203
|
spent: Record<Scope, string>;
|
|
204
|
+
counts: Record<Scope, string>;
|
|
194
205
|
};
|
|
195
206
|
/** Pure, synchronous budget decision. The caller must reserve in the same transaction. */
|
|
196
207
|
declare function evaluate(proposed: PaymentEvent, events: PaymentEvent[], config: TaximeterConfig, now: number): Decision;
|
|
@@ -206,6 +217,7 @@ declare class Ledger {
|
|
|
206
217
|
policyState(proposed: PaymentEvent, budgets: TaximeterConfig["budgets"], now: number): PolicyState;
|
|
207
218
|
/** Rebuild disposable projections without modifying the append-only audit log. */
|
|
208
219
|
rebuildCache(): void;
|
|
220
|
+
eventCount(): number;
|
|
209
221
|
events(): {
|
|
210
222
|
id: string;
|
|
211
223
|
ts: string;
|
|
@@ -354,7 +366,8 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
354
366
|
config: z.ZodOptional<z.ZodObject<{
|
|
355
367
|
budgets: z.ZodOptional<z.ZodObject<{
|
|
356
368
|
perTask: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
357
|
-
amount: z.ZodOptional<z.ZodString
|
|
369
|
+
amount: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
370
|
+
maxPayments: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
358
371
|
asset: z.ZodOptional<z.ZodString>;
|
|
359
372
|
network: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
360
373
|
window: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
@@ -365,7 +378,8 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
365
378
|
}>>>;
|
|
366
379
|
}, z.core.$strict>>>;
|
|
367
380
|
perAgent: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
368
|
-
amount: z.ZodOptional<z.ZodString
|
|
381
|
+
amount: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
382
|
+
maxPayments: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
369
383
|
asset: z.ZodOptional<z.ZodString>;
|
|
370
384
|
network: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
371
385
|
window: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|
|
@@ -376,7 +390,8 @@ declare const optionsSchema: z.ZodObject<{
|
|
|
376
390
|
}>>>;
|
|
377
391
|
}, z.core.$strict>>>;
|
|
378
392
|
global: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
379
|
-
amount: z.ZodOptional<z.ZodString
|
|
393
|
+
amount: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
394
|
+
maxPayments: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
380
395
|
asset: z.ZodOptional<z.ZodString>;
|
|
381
396
|
network: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
382
397
|
window: z.ZodOptional<z.ZodOptional<z.ZodEnum<{
|