aden-ts 0.1.1 → 0.2.1

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/index.d.mts CHANGED
@@ -140,6 +140,8 @@ interface BudgetRule {
140
140
  alerts: BudgetAlert[];
141
141
  /** Notification settings */
142
142
  notifications: BudgetNotifications;
143
+ /** Legacy context_id for backwards compatibility */
144
+ context_id?: string;
143
145
  }
144
146
  /**
145
147
  * Throttle rule - rate limiting
@@ -285,13 +287,13 @@ interface ControlAgentOptions {
285
287
  /**
286
288
  * Enable hybrid enforcement (local + server-side validation).
287
289
  * When enabled, budgets above the threshold are validated with the server.
288
- * Default: false
290
+ * Default: true
289
291
  */
290
292
  enableHybridEnforcement?: boolean;
291
293
  /**
292
294
  * Budget usage threshold (percentage) at which to start server validation.
293
295
  * Requests below this threshold use local-only enforcement.
294
- * Default: 80
296
+ * Default: 5
295
297
  */
296
298
  serverValidationThreshold?: number;
297
299
  /**
@@ -308,7 +310,7 @@ interface ControlAgentOptions {
308
310
  /**
309
311
  * Minimum remaining budget (USD) that triggers forced server validation.
310
312
  * Only applies when adaptiveThresholdEnabled is true.
311
- * Default: 1.0
313
+ * Default: 5.0
312
314
  */
313
315
  adaptiveMinRemainingUsd?: number;
314
316
  /**
@@ -2354,7 +2356,26 @@ declare class ControlAgent implements IControlAgent {
2354
2356
  */
2355
2357
  private matchesBlockRule;
2356
2358
  /**
2357
- * Find budgets that apply to the given request based on budget type
2359
+ * Get action priority for finding most restrictive decision.
2360
+ * Higher priority = more restrictive.
2361
+ */
2362
+ private getActionPriority;
2363
+ /**
2364
+ * Evaluate a single budget using local-only enforcement.
2365
+ * Returns a decision if the budget triggers an action, null otherwise.
2366
+ */
2367
+ private evaluateBudgetLocally;
2368
+ /**
2369
+ * Find budgets that apply to the given request based on budget type.
2370
+ *
2371
+ * Matching logic by budget type:
2372
+ * - global: Matches ALL requests
2373
+ * - agent: Matches if request.metadata.agent == budget.name or budget.id
2374
+ * - tenant: Matches if request.metadata.tenant_id == budget.name or budget.id
2375
+ * - customer: Matches if request.metadata.customer_id == budget.name or budget.id
2376
+ * - feature: Matches if request.metadata.feature == budget.name or budget.id
2377
+ * - tag: Matches if any request.metadata.tags intersect with budget.tags
2378
+ * - legacy (context_id): Matches if request.context_id == budget.context_id
2358
2379
  */
2359
2380
  private findApplicableBudgets;
2360
2381
  /**
package/dist/index.d.ts CHANGED
@@ -140,6 +140,8 @@ interface BudgetRule {
140
140
  alerts: BudgetAlert[];
141
141
  /** Notification settings */
142
142
  notifications: BudgetNotifications;
143
+ /** Legacy context_id for backwards compatibility */
144
+ context_id?: string;
143
145
  }
144
146
  /**
145
147
  * Throttle rule - rate limiting
@@ -285,13 +287,13 @@ interface ControlAgentOptions {
285
287
  /**
286
288
  * Enable hybrid enforcement (local + server-side validation).
287
289
  * When enabled, budgets above the threshold are validated with the server.
288
- * Default: false
290
+ * Default: true
289
291
  */
290
292
  enableHybridEnforcement?: boolean;
291
293
  /**
292
294
  * Budget usage threshold (percentage) at which to start server validation.
293
295
  * Requests below this threshold use local-only enforcement.
294
- * Default: 80
296
+ * Default: 5
295
297
  */
296
298
  serverValidationThreshold?: number;
297
299
  /**
@@ -308,7 +310,7 @@ interface ControlAgentOptions {
308
310
  /**
309
311
  * Minimum remaining budget (USD) that triggers forced server validation.
310
312
  * Only applies when adaptiveThresholdEnabled is true.
311
- * Default: 1.0
313
+ * Default: 5.0
312
314
  */
313
315
  adaptiveMinRemainingUsd?: number;
314
316
  /**
@@ -2354,7 +2356,26 @@ declare class ControlAgent implements IControlAgent {
2354
2356
  */
2355
2357
  private matchesBlockRule;
2356
2358
  /**
2357
- * Find budgets that apply to the given request based on budget type
2359
+ * Get action priority for finding most restrictive decision.
2360
+ * Higher priority = more restrictive.
2361
+ */
2362
+ private getActionPriority;
2363
+ /**
2364
+ * Evaluate a single budget using local-only enforcement.
2365
+ * Returns a decision if the budget triggers an action, null otherwise.
2366
+ */
2367
+ private evaluateBudgetLocally;
2368
+ /**
2369
+ * Find budgets that apply to the given request based on budget type.
2370
+ *
2371
+ * Matching logic by budget type:
2372
+ * - global: Matches ALL requests
2373
+ * - agent: Matches if request.metadata.agent == budget.name or budget.id
2374
+ * - tenant: Matches if request.metadata.tenant_id == budget.name or budget.id
2375
+ * - customer: Matches if request.metadata.customer_id == budget.name or budget.id
2376
+ * - feature: Matches if request.metadata.feature == budget.name or budget.id
2377
+ * - tag: Matches if any request.metadata.tags intersect with budget.tags
2378
+ * - legacy (context_id): Matches if request.context_id == budget.context_id
2358
2379
  */
2359
2380
  private findApplicableBudgets;
2360
2381
  /**