taximeter 0.1.2 → 0.2.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/cli/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  totalSchema,
23
23
  totals,
24
24
  version
25
- } from "../chunk-DWBUWM3G.js";
25
+ } from "../chunk-NXK2MCRO.js";
26
26
 
27
27
  // src/cli/index.ts
28
28
  import { CommanderError } from "commander";
package/dist/index.d.ts CHANGED
@@ -43,6 +43,10 @@ declare const configSchema: z.ZodObject<{
43
43
  allowPayTo: z.ZodDefault<z.ZodArray<z.ZodString>>;
44
44
  maxSinglePayment: z.ZodDefault<z.ZodNullable<z.ZodString>>;
45
45
  maxSingleAsset: z.ZodDefault<z.ZodString>;
46
+ unknownAsset: z.ZodDefault<z.ZodEnum<{
47
+ allow: "allow";
48
+ deny: "deny";
49
+ }>>;
46
50
  }, z.core.$strict>>;
47
51
  ports: z.ZodPrefault<z.ZodObject<{
48
52
  proxy: z.ZodDefault<z.ZodNumber>;
@@ -88,6 +92,7 @@ declare function loadConfig(flags?: unknown, options?: {
88
92
  allowPayTo: string[];
89
93
  maxSinglePayment: string | null;
90
94
  maxSingleAsset: string;
95
+ unknownAsset: "allow" | "deny";
91
96
  };
92
97
  ports: {
93
98
  proxy: number;
@@ -176,13 +181,31 @@ declare const blockedBodySchema: z.ZodObject<{
176
181
  }, z.core.$strip>;
177
182
  type BlockedBody = z.infer<typeof blockedBodySchema>;
178
183
 
184
+ type Decision = {
185
+ allowed: true;
186
+ } | {
187
+ allowed: false;
188
+ body: BlockedBody;
189
+ };
190
+ type Scope = "perTask" | "perAgent" | "global";
191
+ type PolicyState = {
192
+ reserved: PaymentEvent | undefined;
193
+ spent: Record<Scope, string>;
194
+ };
195
+ /** Pure, synchronous budget decision. The caller must reserve in the same transaction. */
196
+ declare function evaluate(proposed: PaymentEvent, events: PaymentEvent[], config: TaximeterConfig, now: number): Decision;
197
+
179
198
  /** Synchronous storage edge; money derivations remain pure in derive.ts. */
180
199
  declare class Ledger {
181
200
  private readonly database;
201
+ private readonly cache;
182
202
  constructor(input: string);
183
203
  transaction<T>(operation: () => T): T;
184
204
  append(input: unknown): boolean;
185
205
  appendOutcome(input: unknown): boolean;
206
+ policyState(proposed: PaymentEvent, budgets: TaximeterConfig["budgets"], now: number): PolicyState;
207
+ /** Rebuild disposable projections without modifying the append-only audit log. */
208
+ rebuildCache(): void;
186
209
  events(): {
187
210
  id: string;
188
211
  ts: string;
@@ -320,15 +343,6 @@ declare function deriveEvents(events: PaymentEvent[], outcomes?: Outcome[]): Pay
320
343
  declare function totals(events: PaymentEvent[]): Total[];
321
344
  declare function formatAmount(amount: string, decimals: number): string;
322
345
 
323
- type Decision = {
324
- allowed: true;
325
- } | {
326
- allowed: false;
327
- body: BlockedBody;
328
- };
329
- /** Pure, synchronous budget decision. The caller must reserve in the same transaction. */
330
- declare function evaluate(proposed: PaymentEvent, events: PaymentEvent[], config: TaximeterConfig, now: number): Decision;
331
-
332
346
  declare function createProxy(options: {
333
347
  ledger: Ledger;
334
348
  config: TaximeterConfig;
@@ -379,6 +393,10 @@ declare const optionsSchema: z.ZodObject<{
379
393
  allowPayTo: z.ZodOptional<z.ZodArray<z.ZodString>>;
380
394
  maxSinglePayment: z.ZodOptional<z.ZodNullable<z.ZodString>>;
381
395
  maxSingleAsset: z.ZodOptional<z.ZodString>;
396
+ unknownAsset: z.ZodOptional<z.ZodEnum<{
397
+ allow: "allow";
398
+ deny: "deny";
399
+ }>>;
382
400
  }, z.core.$strict>>;
383
401
  ports: z.ZodOptional<z.ZodObject<{
384
402
  proxy: z.ZodOptional<z.ZodNumber>;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  toJson,
19
19
  totals,
20
20
  version
21
- } from "./chunk-DWBUWM3G.js";
21
+ } from "./chunk-NXK2MCRO.js";
22
22
 
23
23
  // src/sdk/index.ts
24
24
  import { z } from "zod";