ai-functions 2.1.1 → 2.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/.turbo/turbo-build.log +1 -4
- package/CHANGELOG.md +68 -1
- package/README.md +397 -157
- package/dist/ai-promise.d.ts +50 -3
- package/dist/ai-promise.d.ts.map +1 -1
- package/dist/ai-promise.js +410 -51
- package/dist/ai-promise.js.map +1 -1
- package/dist/ai-schemas.d.ts +56 -0
- package/dist/ai-schemas.d.ts.map +1 -0
- package/dist/ai-schemas.js +53 -0
- package/dist/ai-schemas.js.map +1 -0
- package/dist/ai.d.ts +16 -242
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js +54 -837
- package/dist/ai.js.map +1 -1
- package/dist/batch/anthropic.d.ts +6 -4
- package/dist/batch/anthropic.d.ts.map +1 -1
- package/dist/batch/anthropic.js +83 -145
- package/dist/batch/anthropic.js.map +1 -1
- package/dist/batch/bedrock.d.ts +8 -30
- package/dist/batch/bedrock.d.ts.map +1 -1
- package/dist/batch/bedrock.js +155 -338
- package/dist/batch/bedrock.js.map +1 -1
- package/dist/batch/cloudflare.d.ts +8 -20
- package/dist/batch/cloudflare.d.ts.map +1 -1
- package/dist/batch/cloudflare.js +68 -189
- package/dist/batch/cloudflare.js.map +1 -1
- package/dist/batch/google.d.ts +6 -20
- package/dist/batch/google.d.ts.map +1 -1
- package/dist/batch/google.js +70 -238
- package/dist/batch/google.js.map +1 -1
- package/dist/batch/index.d.ts +4 -1
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +4 -1
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/memory.d.ts +1 -1
- package/dist/batch/memory.d.ts.map +1 -1
- package/dist/batch/memory.js +14 -10
- package/dist/batch/memory.js.map +1 -1
- package/dist/batch/openai.d.ts +11 -14
- package/dist/batch/openai.d.ts.map +1 -1
- package/dist/batch/openai.js +52 -156
- package/dist/batch/openai.js.map +1 -1
- package/dist/batch/provider.d.ts +111 -0
- package/dist/batch/provider.d.ts.map +1 -0
- package/dist/batch/provider.js +233 -0
- package/dist/batch/provider.js.map +1 -0
- package/dist/batch-map.d.ts.map +1 -1
- package/dist/batch-map.js +23 -17
- package/dist/batch-map.js.map +1 -1
- package/dist/batch-queue.d.ts +65 -0
- package/dist/batch-queue.d.ts.map +1 -1
- package/dist/batch-queue.js +169 -14
- package/dist/batch-queue.js.map +1 -1
- package/dist/budget.d.ts +272 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +513 -0
- package/dist/budget.js.map +1 -0
- package/dist/cache.d.ts +295 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +433 -0
- package/dist/cache.js.map +1 -0
- package/dist/context.d.ts +42 -8
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +64 -62
- package/dist/context.js.map +1 -1
- package/dist/digital-objects-registry.d.ts +229 -0
- package/dist/digital-objects-registry.d.ts.map +1 -0
- package/dist/digital-objects-registry.js +617 -0
- package/dist/digital-objects-registry.js.map +1 -0
- package/dist/embeddings.d.ts +2 -2
- package/dist/embeddings.d.ts.map +1 -1
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +35 -0
- package/dist/errors.js.map +1 -0
- package/dist/eval/runner.d.ts +10 -1
- package/dist/eval/runner.d.ts.map +1 -1
- package/dist/eval/runner.js +41 -35
- package/dist/eval/runner.js.map +1 -1
- package/dist/eval-log/in-memory.d.ts +34 -0
- package/dist/eval-log/in-memory.d.ts.map +1 -0
- package/dist/eval-log/in-memory.js +84 -0
- package/dist/eval-log/in-memory.js.map +1 -0
- package/dist/eval-log/index.d.ts +29 -0
- package/dist/eval-log/index.d.ts.map +1 -0
- package/dist/eval-log/index.js +39 -0
- package/dist/eval-log/index.js.map +1 -0
- package/dist/eval-log/types.d.ts +101 -0
- package/dist/eval-log/types.d.ts.map +1 -0
- package/dist/eval-log/types.js +16 -0
- package/dist/eval-log/types.js.map +1 -0
- package/dist/function-registry.d.ts +116 -0
- package/dist/function-registry.d.ts.map +1 -0
- package/dist/function-registry.js +546 -0
- package/dist/function-registry.js.map +1 -0
- package/dist/generate.d.ts +9 -3
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +18 -22
- package/dist/generate.js.map +1 -1
- package/dist/index.d.ts +35 -20
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -42
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +118 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +187 -0
- package/dist/logger.js.map +1 -0
- package/dist/middleware/budget.d.ts +84 -0
- package/dist/middleware/budget.d.ts.map +1 -0
- package/dist/middleware/budget.js +110 -0
- package/dist/middleware/budget.js.map +1 -0
- package/dist/middleware/cache.d.ts +103 -0
- package/dist/middleware/cache.d.ts.map +1 -0
- package/dist/middleware/cache.js +228 -0
- package/dist/middleware/cache.js.map +1 -0
- package/dist/middleware/embed-cache.d.ts +99 -0
- package/dist/middleware/embed-cache.d.ts.map +1 -0
- package/dist/middleware/embed-cache.js +128 -0
- package/dist/middleware/embed-cache.js.map +1 -0
- package/dist/middleware/index.d.ts +11 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +11 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/trace.d.ts +103 -0
- package/dist/middleware/trace.d.ts.map +1 -0
- package/dist/middleware/trace.js +176 -0
- package/dist/middleware/trace.js.map +1 -0
- package/dist/primitives.d.ts +120 -1
- package/dist/primitives.d.ts.map +1 -1
- package/dist/primitives.js +398 -26
- package/dist/primitives.js.map +1 -1
- package/dist/retry.d.ts +368 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +646 -0
- package/dist/retry.js.map +1 -0
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +2 -10
- package/dist/schema.js.map +1 -1
- package/dist/telemetry.d.ts +128 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +285 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +6 -1
- package/dist/template.js.map +1 -1
- package/dist/tool-orchestration.d.ts +453 -0
- package/dist/tool-orchestration.d.ts.map +1 -0
- package/dist/tool-orchestration.js +763 -0
- package/dist/tool-orchestration.js.map +1 -0
- package/dist/type-guards.d.ts +28 -0
- package/dist/type-guards.d.ts.map +1 -0
- package/dist/type-guards.js +29 -0
- package/dist/type-guards.js.map +1 -0
- package/dist/types.d.ts +135 -17
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +36 -1
- package/dist/types.js.map +1 -1
- package/dist/wrap-for-v3.d.ts +80 -0
- package/dist/wrap-for-v3.d.ts.map +1 -0
- package/dist/wrap-for-v3.js +89 -0
- package/dist/wrap-for-v3.js.map +1 -0
- package/examples/00-quickstart.ts +232 -0
- package/examples/01-rag-chatbot.ts +212 -0
- package/examples/02-multi-agent-research.ts +290 -0
- package/examples/03-email-classification.ts +379 -0
- package/examples/04-content-moderation.ts +400 -0
- package/examples/05-document-extraction.ts +455 -0
- package/examples/06-streaming-chat-nextjs.ts +437 -0
- package/examples/07-cloudflare-worker.ts +483 -0
- package/examples/08-batch-processing.ts +491 -0
- package/examples/09-budget-constrained.ts +527 -0
- package/examples/10-tool-orchestration.ts +565 -0
- package/examples/11-retry-resilience.ts +403 -0
- package/examples/12-caching-strategies.ts +422 -0
- package/examples/README.md +145 -0
- package/package.json +10 -6
- package/src/ai-promise.ts +528 -99
- package/src/ai-schemas.ts +122 -0
- package/src/ai.ts +69 -1153
- package/src/batch/anthropic.ts +96 -161
- package/src/batch/bedrock.ts +203 -454
- package/src/batch/cloudflare.ts +99 -282
- package/src/batch/google.ts +91 -297
- package/src/batch/index.ts +4 -1
- package/src/batch/memory.ts +15 -10
- package/src/batch/openai.ts +65 -193
- package/src/batch/provider.ts +336 -0
- package/src/batch-map.ts +29 -24
- package/src/batch-queue.ts +200 -11
- package/src/budget.ts +740 -0
- package/src/cache.ts +681 -0
- package/src/context.ts +122 -76
- package/src/digital-objects-registry.ts +750 -0
- package/src/errors.ts +37 -0
- package/src/eval/runner.ts +63 -38
- package/src/eval-log/in-memory.ts +90 -0
- package/src/eval-log/index.ts +46 -0
- package/src/eval-log/types.ts +110 -0
- package/src/function-registry.ts +671 -0
- package/src/generate.ts +33 -33
- package/src/index.ts +325 -49
- package/src/logger.ts +232 -0
- package/src/middleware/budget.ts +171 -0
- package/src/middleware/cache.ts +299 -0
- package/src/middleware/embed-cache.ts +195 -0
- package/src/middleware/index.ts +23 -0
- package/src/middleware/trace.ts +248 -0
- package/src/primitives.ts +589 -62
- package/src/retry.ts +902 -0
- package/src/schema.ts +8 -17
- package/src/telemetry.ts +403 -0
- package/src/template.ts +8 -4
- package/src/tool-orchestration.ts +1173 -0
- package/src/type-guards.ts +31 -0
- package/src/types.ts +164 -25
- package/src/wrap-for-v3.ts +105 -0
- package/test/ai-promise.test.ts +1080 -0
- package/test/ai-proxy.test.ts +1 -1
- package/test/backward-compat.test.ts +147 -0
- package/test/batch-autosubmit-errors.test.ts +610 -0
- package/test/batch-blog-posts.test.ts +87 -129
- package/test/budget-tracking.test.ts +800 -0
- package/test/cache.test.ts +712 -0
- package/test/context-isolation.test.ts +687 -0
- package/test/core-functions.test.ts +183 -579
- package/test/decide.test.ts +154 -322
- package/test/define.test.ts +211 -8
- package/test/digital-objects-registry.test.ts +760 -0
- package/test/embedding-cache-middleware.test.ts +140 -0
- package/test/evals/deterministic.eval.test.ts +376 -0
- package/test/generate-core.test.ts +140 -229
- package/test/implicit-batch.test.ts +22 -65
- package/test/json-parse-error-handling.test.ts +463 -0
- package/test/retry-policy-integration.test.ts +117 -0
- package/test/retry.test.ts +1016 -0
- package/test/schema.test.ts +55 -19
- package/test/streaming.test.ts +316 -0
- package/test/template.test.ts +1164 -0
- package/test/tool-orchestration.test.ts +1040 -0
- package/test/wrap-for-v3.test.ts +612 -0
- package/vitest.config.js +6 -0
- package/vitest.config.ts +20 -0
- package/dist/rpc/auth.d.ts +0 -69
- package/dist/rpc/auth.d.ts.map +0 -1
- package/dist/rpc/auth.js +0 -136
- package/dist/rpc/auth.js.map +0 -1
- package/dist/rpc/client.d.ts +0 -62
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/client.js +0 -103
- package/dist/rpc/client.js.map +0 -1
- package/dist/rpc/deferred.d.ts +0 -60
- package/dist/rpc/deferred.d.ts.map +0 -1
- package/dist/rpc/deferred.js +0 -96
- package/dist/rpc/deferred.js.map +0 -1
- package/dist/rpc/index.d.ts +0 -22
- package/dist/rpc/index.d.ts.map +0 -1
- package/dist/rpc/index.js +0 -38
- package/dist/rpc/index.js.map +0 -1
- package/dist/rpc/local.d.ts +0 -42
- package/dist/rpc/local.d.ts.map +0 -1
- package/dist/rpc/local.js +0 -50
- package/dist/rpc/local.js.map +0 -1
- package/dist/rpc/server.d.ts +0 -165
- package/dist/rpc/server.d.ts.map +0 -1
- package/dist/rpc/server.js +0 -405
- package/dist/rpc/server.js.map +0 -1
- package/dist/rpc/session.d.ts +0 -32
- package/dist/rpc/session.d.ts.map +0 -1
- package/dist/rpc/session.js +0 -43
- package/dist/rpc/session.js.map +0 -1
- package/dist/rpc/transport.d.ts +0 -306
- package/dist/rpc/transport.d.ts.map +0 -1
- package/dist/rpc/transport.js +0 -731
- package/dist/rpc/transport.js.map +0 -1
- package/src/batch/anthropic.js +0 -256
- package/src/batch/bedrock.js +0 -584
- package/src/batch/cloudflare.js +0 -287
- package/src/batch/google.js +0 -359
- package/src/batch/index.js +0 -30
- package/src/batch/memory.js +0 -187
- package/src/batch/openai.js +0 -402
- package/src/eval/index.js +0 -7
- package/src/eval/models.js +0 -119
- package/src/eval/runner.js +0 -147
- package/test/schema.test.js +0 -96
package/dist/budget.js
ADDED
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Budget Tracking and Request Tracing for AI Functions
|
|
3
|
+
*
|
|
4
|
+
* Provides:
|
|
5
|
+
* - Token counting and estimation
|
|
6
|
+
* - Cost tracking by model
|
|
7
|
+
* - Budget limits with alerts
|
|
8
|
+
* - Request ID generation and tracing
|
|
9
|
+
* - User/tenant context isolation
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { randomUUID } from 'crypto';
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Default Model Pricing (per million tokens, USD)
|
|
16
|
+
// ============================================================================
|
|
17
|
+
const DEFAULT_MODEL_PRICING = {
|
|
18
|
+
// OpenAI models
|
|
19
|
+
'gpt-4o': { inputPricePerMillion: 2.5, outputPricePerMillion: 10 },
|
|
20
|
+
'gpt-4o-mini': { inputPricePerMillion: 0.15, outputPricePerMillion: 0.6 },
|
|
21
|
+
'gpt-4-turbo': { inputPricePerMillion: 10, outputPricePerMillion: 30 },
|
|
22
|
+
'gpt-4': { inputPricePerMillion: 30, outputPricePerMillion: 60 },
|
|
23
|
+
'gpt-3.5-turbo': { inputPricePerMillion: 0.5, outputPricePerMillion: 1.5 },
|
|
24
|
+
o1: { inputPricePerMillion: 15, outputPricePerMillion: 60 },
|
|
25
|
+
'o1-mini': { inputPricePerMillion: 3, outputPricePerMillion: 12 },
|
|
26
|
+
'o1-preview': { inputPricePerMillion: 15, outputPricePerMillion: 60 },
|
|
27
|
+
'o3-mini': { inputPricePerMillion: 1.1, outputPricePerMillion: 4.4 },
|
|
28
|
+
// Anthropic models
|
|
29
|
+
'claude-opus-4-20250514': { inputPricePerMillion: 15, outputPricePerMillion: 75 },
|
|
30
|
+
'claude-sonnet-4-20250514': { inputPricePerMillion: 3, outputPricePerMillion: 15 },
|
|
31
|
+
'claude-3-5-sonnet-latest': { inputPricePerMillion: 3, outputPricePerMillion: 15 },
|
|
32
|
+
'claude-3-5-haiku-latest': { inputPricePerMillion: 0.25, outputPricePerMillion: 1.25 },
|
|
33
|
+
'claude-3-opus-20240229': { inputPricePerMillion: 15, outputPricePerMillion: 75 },
|
|
34
|
+
'claude-3-sonnet-20240229': { inputPricePerMillion: 3, outputPricePerMillion: 15 },
|
|
35
|
+
'claude-3-haiku-20240307': { inputPricePerMillion: 0.25, outputPricePerMillion: 1.25 },
|
|
36
|
+
// Google models
|
|
37
|
+
'gemini-2.0-flash': { inputPricePerMillion: 0.1, outputPricePerMillion: 0.4 },
|
|
38
|
+
'gemini-1.5-pro': { inputPricePerMillion: 1.25, outputPricePerMillion: 5 },
|
|
39
|
+
'gemini-1.5-flash': { inputPricePerMillion: 0.075, outputPricePerMillion: 0.3 },
|
|
40
|
+
// Default fallback
|
|
41
|
+
default: { inputPricePerMillion: 1, outputPricePerMillion: 3 },
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Token counter for estimating token usage
|
|
45
|
+
*
|
|
46
|
+
* Uses a simple character-based estimation that works across models.
|
|
47
|
+
* For production, consider integrating tiktoken for more accurate counts.
|
|
48
|
+
*/
|
|
49
|
+
export class TokenCounter {
|
|
50
|
+
/** Average characters per token (rough estimate) */
|
|
51
|
+
charsPerToken = 4;
|
|
52
|
+
/** Overhead tokens per message for formatting */
|
|
53
|
+
messageOverhead = 4;
|
|
54
|
+
/**
|
|
55
|
+
* Estimate tokens for a text string
|
|
56
|
+
*/
|
|
57
|
+
estimateTokens(text, _model) {
|
|
58
|
+
if (!text)
|
|
59
|
+
return 0;
|
|
60
|
+
// Count characters
|
|
61
|
+
const charCount = text.length;
|
|
62
|
+
// Rough estimate: ~4 chars per token for English
|
|
63
|
+
// Unicode characters may use more tokens
|
|
64
|
+
const unicodeChars = Array.from(text).filter((char) => char.charCodeAt(0) > 127).length;
|
|
65
|
+
const asciiChars = charCount - unicodeChars;
|
|
66
|
+
// ASCII chars: ~4 per token, Unicode: ~2 per token (rough)
|
|
67
|
+
const asciiTokens = Math.ceil(asciiChars / this.charsPerToken);
|
|
68
|
+
const unicodeTokens = Math.ceil(unicodeChars / 2);
|
|
69
|
+
return asciiTokens + unicodeTokens;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Count tokens in a message array including formatting overhead
|
|
73
|
+
*/
|
|
74
|
+
countMessageTokens(messages, model) {
|
|
75
|
+
let total = 0;
|
|
76
|
+
for (const message of messages) {
|
|
77
|
+
// Content tokens
|
|
78
|
+
total += this.estimateTokens(message.content, model);
|
|
79
|
+
// Role tokens (user, assistant, system)
|
|
80
|
+
total += this.estimateTokens(message.role, model);
|
|
81
|
+
// Message formatting overhead
|
|
82
|
+
total += this.messageOverhead;
|
|
83
|
+
}
|
|
84
|
+
return total;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// Budget Exceeded Error
|
|
89
|
+
// ============================================================================
|
|
90
|
+
/**
|
|
91
|
+
* Error thrown when budget is exceeded
|
|
92
|
+
*/
|
|
93
|
+
export class BudgetExceededError extends Error {
|
|
94
|
+
type;
|
|
95
|
+
limit;
|
|
96
|
+
current;
|
|
97
|
+
requested;
|
|
98
|
+
constructor(message, type, limit, current, requested) {
|
|
99
|
+
super(message);
|
|
100
|
+
this.type = type;
|
|
101
|
+
this.limit = limit;
|
|
102
|
+
this.current = current;
|
|
103
|
+
this.requested = requested;
|
|
104
|
+
this.name = 'BudgetExceededError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
// ============================================================================
|
|
108
|
+
// Budget Tracker
|
|
109
|
+
// ============================================================================
|
|
110
|
+
/**
|
|
111
|
+
* Tracks token usage and costs with budget limits
|
|
112
|
+
*/
|
|
113
|
+
export class BudgetTracker {
|
|
114
|
+
totalInputTokens = 0;
|
|
115
|
+
totalOutputTokens = 0;
|
|
116
|
+
usageByModel = {};
|
|
117
|
+
triggeredThresholds = new Set();
|
|
118
|
+
requests = [];
|
|
119
|
+
config;
|
|
120
|
+
constructor(config = {}) {
|
|
121
|
+
this.config = {
|
|
122
|
+
maxRequestHistory: 100,
|
|
123
|
+
...config,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Record token usage from a request
|
|
128
|
+
*/
|
|
129
|
+
recordUsage(usage) {
|
|
130
|
+
const { inputTokens, outputTokens, model = 'default' } = usage;
|
|
131
|
+
this.totalInputTokens += inputTokens;
|
|
132
|
+
this.totalOutputTokens += outputTokens;
|
|
133
|
+
// Track by model
|
|
134
|
+
if (!this.usageByModel[model]) {
|
|
135
|
+
this.usageByModel[model] = { inputTokens: 0, outputTokens: 0, cost: 0 };
|
|
136
|
+
}
|
|
137
|
+
this.usageByModel[model].inputTokens += inputTokens;
|
|
138
|
+
this.usageByModel[model].outputTokens += outputTokens;
|
|
139
|
+
// Calculate cost for this usage
|
|
140
|
+
const pricing = this.getPricing(model);
|
|
141
|
+
const cost = this.calculateCost(inputTokens, outputTokens, pricing);
|
|
142
|
+
this.usageByModel[model].cost += cost;
|
|
143
|
+
// Check for budget exceeded
|
|
144
|
+
this.checkLimitsAfterRecording();
|
|
145
|
+
// Check for alerts
|
|
146
|
+
this.checkAlerts();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Record a complete request with timing info
|
|
150
|
+
*/
|
|
151
|
+
recordRequest(info) {
|
|
152
|
+
const duration = info.endTime - info.startTime;
|
|
153
|
+
const storedRequest = {
|
|
154
|
+
...info,
|
|
155
|
+
duration,
|
|
156
|
+
};
|
|
157
|
+
this.requests.push(storedRequest);
|
|
158
|
+
// Trim history if needed
|
|
159
|
+
const maxHistory = this.config.maxRequestHistory ?? 100;
|
|
160
|
+
while (this.requests.length > maxHistory) {
|
|
161
|
+
this.requests.shift();
|
|
162
|
+
}
|
|
163
|
+
// Also record the token usage
|
|
164
|
+
this.recordUsage({
|
|
165
|
+
inputTokens: info.inputTokens,
|
|
166
|
+
outputTokens: info.outputTokens,
|
|
167
|
+
model: info.model,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get all recorded requests
|
|
172
|
+
*/
|
|
173
|
+
getRequests() {
|
|
174
|
+
return [...this.requests];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Check if a proposed request would exceed budget
|
|
178
|
+
*/
|
|
179
|
+
checkBudget(options) {
|
|
180
|
+
const { estimatedTokens = 0, model = 'default' } = options;
|
|
181
|
+
// Check token limit
|
|
182
|
+
if (this.config.maxTokens !== undefined) {
|
|
183
|
+
const projectedTotal = this.getTotalTokens() + estimatedTokens;
|
|
184
|
+
if (projectedTotal > this.config.maxTokens) {
|
|
185
|
+
throw new BudgetExceededError(`Token budget exceeded: ${projectedTotal} tokens would exceed limit of ${this.config.maxTokens}`, 'tokens', this.config.maxTokens, this.getTotalTokens(), estimatedTokens);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// Check cost limit
|
|
189
|
+
if (this.config.maxCost !== undefined) {
|
|
190
|
+
const pricing = this.getPricing(model);
|
|
191
|
+
// Estimate cost assuming half input, half output
|
|
192
|
+
const estimatedCost = this.calculateCost(Math.floor(estimatedTokens / 2), Math.ceil(estimatedTokens / 2), pricing);
|
|
193
|
+
const projectedCost = this.getTotalCost() + estimatedCost;
|
|
194
|
+
if (projectedCost > this.config.maxCost) {
|
|
195
|
+
throw new BudgetExceededError(`Cost budget exceeded: $${projectedCost.toFixed(4)} would exceed limit of $${this.config.maxCost}`, 'cost', this.config.maxCost, this.getTotalCost(), estimatedCost);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Check limits after recording and throw if exceeded
|
|
201
|
+
*/
|
|
202
|
+
checkLimitsAfterRecording() {
|
|
203
|
+
// Check token limit
|
|
204
|
+
if (this.config.maxTokens !== undefined) {
|
|
205
|
+
if (this.getTotalTokens() > this.config.maxTokens) {
|
|
206
|
+
throw new BudgetExceededError(`Token budget exceeded: ${this.getTotalTokens()} tokens exceeds limit of ${this.config.maxTokens}`, 'tokens', this.config.maxTokens, this.getTotalTokens());
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Check cost limit
|
|
210
|
+
if (this.config.maxCost !== undefined) {
|
|
211
|
+
const currentCost = this.getTotalCost();
|
|
212
|
+
if (currentCost > this.config.maxCost) {
|
|
213
|
+
throw new BudgetExceededError(`Cost budget exceeded: $${currentCost.toFixed(4)} exceeds limit of $${this.config.maxCost}`, 'cost', this.config.maxCost, currentCost);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Check and trigger alerts
|
|
219
|
+
*/
|
|
220
|
+
checkAlerts() {
|
|
221
|
+
if (!this.config.alertThresholds || !this.config.onAlert)
|
|
222
|
+
return;
|
|
223
|
+
// Check token-based alerts
|
|
224
|
+
if (this.config.maxTokens !== undefined) {
|
|
225
|
+
const usage = this.getTotalTokens() / this.config.maxTokens;
|
|
226
|
+
for (const threshold of this.config.alertThresholds) {
|
|
227
|
+
if (usage >= threshold && !this.triggeredThresholds.has(threshold)) {
|
|
228
|
+
this.triggeredThresholds.add(threshold);
|
|
229
|
+
this.config.onAlert({
|
|
230
|
+
threshold,
|
|
231
|
+
currentUsage: this.getTotalTokens(),
|
|
232
|
+
limit: this.config.maxTokens,
|
|
233
|
+
type: 'tokens',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// Check cost-based alerts
|
|
239
|
+
if (this.config.maxCost !== undefined) {
|
|
240
|
+
const costUsage = this.getTotalCost() / this.config.maxCost;
|
|
241
|
+
for (const threshold of this.config.alertThresholds) {
|
|
242
|
+
// Use a different key to not conflict with token thresholds
|
|
243
|
+
const costThresholdKey = threshold + 1000;
|
|
244
|
+
if (costUsage >= threshold && !this.triggeredThresholds.has(costThresholdKey)) {
|
|
245
|
+
this.triggeredThresholds.add(costThresholdKey);
|
|
246
|
+
this.config.onAlert({
|
|
247
|
+
threshold,
|
|
248
|
+
currentUsage: this.getTotalCost(),
|
|
249
|
+
limit: this.config.maxCost,
|
|
250
|
+
type: 'cost',
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Get total input tokens
|
|
258
|
+
*/
|
|
259
|
+
getTotalInputTokens() {
|
|
260
|
+
return this.totalInputTokens;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get total output tokens
|
|
264
|
+
*/
|
|
265
|
+
getTotalOutputTokens() {
|
|
266
|
+
return this.totalOutputTokens;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Get total tokens (input + output)
|
|
270
|
+
*/
|
|
271
|
+
getTotalTokens() {
|
|
272
|
+
return this.totalInputTokens + this.totalOutputTokens;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Get total cost in USD
|
|
276
|
+
*/
|
|
277
|
+
getTotalCost() {
|
|
278
|
+
let total = 0;
|
|
279
|
+
for (const model of Object.keys(this.usageByModel)) {
|
|
280
|
+
const usage = this.usageByModel[model];
|
|
281
|
+
if (usage) {
|
|
282
|
+
total += usage.cost;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return total;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get cost breakdown by model
|
|
289
|
+
*/
|
|
290
|
+
getCostByModel() {
|
|
291
|
+
const result = {};
|
|
292
|
+
for (const model of Object.keys(this.usageByModel)) {
|
|
293
|
+
const usage = this.usageByModel[model];
|
|
294
|
+
if (usage) {
|
|
295
|
+
result[model] = usage.cost;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
return result;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get remaining budget
|
|
302
|
+
*/
|
|
303
|
+
getRemainingBudget() {
|
|
304
|
+
const result = {};
|
|
305
|
+
if (this.config.maxTokens !== undefined) {
|
|
306
|
+
result.tokens = Math.max(0, this.config.maxTokens - this.getTotalTokens());
|
|
307
|
+
}
|
|
308
|
+
if (this.config.maxCost !== undefined) {
|
|
309
|
+
result.cost = Math.max(0, this.config.maxCost - this.getTotalCost());
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Reset all tracking
|
|
315
|
+
*/
|
|
316
|
+
reset() {
|
|
317
|
+
this.totalInputTokens = 0;
|
|
318
|
+
this.totalOutputTokens = 0;
|
|
319
|
+
this.usageByModel = {};
|
|
320
|
+
this.triggeredThresholds.clear();
|
|
321
|
+
this.requests = [];
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Export current state for persistence
|
|
325
|
+
*/
|
|
326
|
+
export() {
|
|
327
|
+
return {
|
|
328
|
+
totalInputTokens: this.totalInputTokens,
|
|
329
|
+
totalOutputTokens: this.totalOutputTokens,
|
|
330
|
+
totalCost: this.getTotalCost(),
|
|
331
|
+
usageByModel: { ...this.usageByModel },
|
|
332
|
+
triggeredThresholds: Array.from(this.triggeredThresholds),
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Import previously exported state
|
|
337
|
+
*/
|
|
338
|
+
import(snapshot) {
|
|
339
|
+
this.totalInputTokens = snapshot.totalInputTokens;
|
|
340
|
+
this.totalOutputTokens = snapshot.totalOutputTokens;
|
|
341
|
+
this.usageByModel = { ...snapshot.usageByModel };
|
|
342
|
+
this.triggeredThresholds = new Set(snapshot.triggeredThresholds);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Get pricing for a model
|
|
346
|
+
*/
|
|
347
|
+
getPricing(model) {
|
|
348
|
+
// Check custom pricing first
|
|
349
|
+
const customPrice = this.config.customPricing?.[model];
|
|
350
|
+
if (customPrice) {
|
|
351
|
+
return customPrice;
|
|
352
|
+
}
|
|
353
|
+
// Check default pricing
|
|
354
|
+
const defaultPrice = DEFAULT_MODEL_PRICING[model];
|
|
355
|
+
if (defaultPrice) {
|
|
356
|
+
return defaultPrice;
|
|
357
|
+
}
|
|
358
|
+
// Fallback to default (always defined)
|
|
359
|
+
return DEFAULT_MODEL_PRICING['default'];
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Calculate cost for token usage
|
|
363
|
+
*/
|
|
364
|
+
calculateCost(inputTokens, outputTokens, pricing) {
|
|
365
|
+
const inputCost = (inputTokens / 1_000_000) * pricing.inputPricePerMillion;
|
|
366
|
+
const outputCost = (outputTokens / 1_000_000) * pricing.outputPricePerMillion;
|
|
367
|
+
return inputCost + outputCost;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
// ============================================================================
|
|
371
|
+
// Request Context
|
|
372
|
+
// ============================================================================
|
|
373
|
+
/**
|
|
374
|
+
* Request context for tracing and user isolation
|
|
375
|
+
*/
|
|
376
|
+
export class RequestContext {
|
|
377
|
+
requestId;
|
|
378
|
+
userId;
|
|
379
|
+
tenantId;
|
|
380
|
+
parentRequestId;
|
|
381
|
+
depth;
|
|
382
|
+
metadata;
|
|
383
|
+
traceId;
|
|
384
|
+
spanId;
|
|
385
|
+
constructor(options = {}) {
|
|
386
|
+
this.requestId = options.requestId ?? randomUUID();
|
|
387
|
+
if (options.userId !== undefined)
|
|
388
|
+
this.userId = options.userId;
|
|
389
|
+
if (options.tenantId !== undefined)
|
|
390
|
+
this.tenantId = options.tenantId;
|
|
391
|
+
if (options.parentRequestId !== undefined)
|
|
392
|
+
this.parentRequestId = options.parentRequestId;
|
|
393
|
+
this.depth = options.depth ?? 0;
|
|
394
|
+
if (options.metadata !== undefined)
|
|
395
|
+
this.metadata = options.metadata;
|
|
396
|
+
// Generate trace/span IDs for W3C traceparent
|
|
397
|
+
this.traceId = randomUUID().replace(/-/g, '');
|
|
398
|
+
this.spanId = randomUUID().replace(/-/g, '').slice(0, 16);
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Create a child context that inherits from this one
|
|
402
|
+
*/
|
|
403
|
+
createChild(options = {}) {
|
|
404
|
+
// Destructure to separate metadata from other options
|
|
405
|
+
const { metadata: childMetadata, ...restOptions } = options;
|
|
406
|
+
return new RequestContext({
|
|
407
|
+
userId: this.userId,
|
|
408
|
+
tenantId: this.tenantId,
|
|
409
|
+
parentRequestId: this.requestId,
|
|
410
|
+
...restOptions,
|
|
411
|
+
metadata: {
|
|
412
|
+
...this.metadata,
|
|
413
|
+
...childMetadata,
|
|
414
|
+
},
|
|
415
|
+
depth: this.depth + 1,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Serialize to trace headers
|
|
420
|
+
*/
|
|
421
|
+
toTraceHeaders() {
|
|
422
|
+
const headers = {
|
|
423
|
+
'x-request-id': this.requestId,
|
|
424
|
+
};
|
|
425
|
+
if (this.userId) {
|
|
426
|
+
headers['x-user-id'] = this.userId;
|
|
427
|
+
}
|
|
428
|
+
if (this.tenantId) {
|
|
429
|
+
headers['x-tenant-id'] = this.tenantId;
|
|
430
|
+
}
|
|
431
|
+
if (this.parentRequestId) {
|
|
432
|
+
headers['x-parent-request-id'] = this.parentRequestId;
|
|
433
|
+
}
|
|
434
|
+
return headers;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Generate W3C traceparent header
|
|
438
|
+
* Format: version-trace_id-parent_id-flags
|
|
439
|
+
*/
|
|
440
|
+
toTraceparent() {
|
|
441
|
+
const version = '00';
|
|
442
|
+
const flags = '01'; // sampled
|
|
443
|
+
return `${version}-${this.traceId}-${this.spanId}-${flags}`;
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Create a RequestContext from trace headers
|
|
447
|
+
*/
|
|
448
|
+
static fromHeaders(headers) {
|
|
449
|
+
const opts = {};
|
|
450
|
+
if (headers['x-request-id'] !== undefined)
|
|
451
|
+
opts.requestId = headers['x-request-id'];
|
|
452
|
+
if (headers['x-user-id'] !== undefined)
|
|
453
|
+
opts.userId = headers['x-user-id'];
|
|
454
|
+
if (headers['x-tenant-id'] !== undefined)
|
|
455
|
+
opts.tenantId = headers['x-tenant-id'];
|
|
456
|
+
if (headers['x-parent-request-id'] !== undefined)
|
|
457
|
+
opts.parentRequestId = headers['x-parent-request-id'];
|
|
458
|
+
return new RequestContext(opts);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Create a new request context
|
|
463
|
+
*/
|
|
464
|
+
export function createRequestContext(options = {}) {
|
|
465
|
+
return new RequestContext(options);
|
|
466
|
+
}
|
|
467
|
+
// Track nested budget contexts
|
|
468
|
+
let currentBudgetTracker = null;
|
|
469
|
+
/**
|
|
470
|
+
* Execute a function with budget tracking
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* const result = await withBudget({ maxTokens: 1000 }, async (tracker) => {
|
|
475
|
+
* tracker.recordUsage({ inputTokens: 100, outputTokens: 50 })
|
|
476
|
+
* return 'success'
|
|
477
|
+
* })
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
export async function withBudget(options, fn) {
|
|
481
|
+
const { userId, tenantId, ...budgetConfig } = options;
|
|
482
|
+
const tracker = new BudgetTracker(budgetConfig);
|
|
483
|
+
const ctxOptions = {};
|
|
484
|
+
if (userId !== undefined)
|
|
485
|
+
ctxOptions.userId = userId;
|
|
486
|
+
if (tenantId !== undefined)
|
|
487
|
+
ctxOptions.tenantId = tenantId;
|
|
488
|
+
const ctx = userId || tenantId ? createRequestContext(ctxOptions) : undefined;
|
|
489
|
+
// Track parent tracker for nested contexts
|
|
490
|
+
const parentTracker = currentBudgetTracker;
|
|
491
|
+
// Create a wrapper tracker that propagates to parent
|
|
492
|
+
const wrappedTracker = new Proxy(tracker, {
|
|
493
|
+
get(target, prop, receiver) {
|
|
494
|
+
const value = Reflect.get(target, prop, receiver);
|
|
495
|
+
// Wrap recordUsage to propagate to parent
|
|
496
|
+
if (prop === 'recordUsage' && parentTracker) {
|
|
497
|
+
return (usage) => {
|
|
498
|
+
target.recordUsage(usage);
|
|
499
|
+
parentTracker.recordUsage(usage);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
return value;
|
|
503
|
+
},
|
|
504
|
+
});
|
|
505
|
+
currentBudgetTracker = tracker;
|
|
506
|
+
try {
|
|
507
|
+
return await fn(wrappedTracker, ctx);
|
|
508
|
+
}
|
|
509
|
+
finally {
|
|
510
|
+
currentBudgetTracker = parentTracker;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
//# sourceMappingURL=budget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"budget.js","sourceRoot":"","sources":["../src/budget.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAsGnC,+EAA+E;AAC/E,kDAAkD;AAClD,+EAA+E;AAE/E,MAAM,qBAAqB,GAAiC;IAC1D,gBAAgB;IAChB,QAAQ,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,qBAAqB,EAAE,EAAE,EAAE;IAClE,aAAa,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,qBAAqB,EAAE,GAAG,EAAE;IACzE,aAAa,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE;IACtE,OAAO,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE;IAChE,eAAe,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE;IAC1E,EAAE,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE;IAC3D,SAAS,EAAE,EAAE,oBAAoB,EAAE,CAAC,EAAE,qBAAqB,EAAE,EAAE,EAAE;IACjE,YAAY,EAAE,EAAE,oBAAoB,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE;IACrE,SAAS,EAAE,EAAE,oBAAoB,EAAE,GAAG,EAAE,qBAAqB,EAAE,GAAG,EAAE;IAEpE,mBAAmB;IACnB,wBAAwB,EAAE,EAAE,oBAAoB,EAAE,EAA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