@hilbras/sdk 3.0.0 → 3.1.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/README.md +55 -34
- package/dist/adapters/anthropic.d.ts +0 -1
- package/dist/adapters/anthropic.d.ts.map +1 -1
- package/dist/adapters/anthropic.js +4 -3
- package/dist/adapters/anthropic.js.map +1 -1
- package/dist/adapters/azure.d.ts +0 -1
- package/dist/adapters/azure.d.ts.map +1 -1
- package/dist/adapters/azure.js +4 -2
- package/dist/adapters/azure.js.map +1 -1
- package/dist/adapters/bedrock.d.ts +0 -1
- package/dist/adapters/bedrock.d.ts.map +1 -1
- package/dist/adapters/bedrock.js +4 -4
- package/dist/adapters/bedrock.js.map +1 -1
- package/dist/adapters/cohere.d.ts.map +1 -1
- package/dist/adapters/cohere.js +2 -1
- package/dist/adapters/cohere.js.map +1 -1
- package/dist/adapters/deepgram.js +4 -4
- package/dist/adapters/deepgram.js.map +1 -1
- package/dist/adapters/extra.d.ts +3 -0
- package/dist/adapters/extra.d.ts.map +1 -0
- package/dist/adapters/extra.js +35 -0
- package/dist/adapters/extra.js.map +1 -0
- package/dist/adapters/google-genai.d.ts +0 -1
- package/dist/adapters/google-genai.d.ts.map +1 -1
- package/dist/adapters/google-genai.js +2 -2
- package/dist/adapters/google-genai.js.map +1 -1
- package/dist/adapters/google-vertex.d.ts +0 -1
- package/dist/adapters/google-vertex.d.ts.map +1 -1
- package/dist/adapters/google-vertex.js +2 -2
- package/dist/adapters/google-vertex.js.map +1 -1
- package/dist/adapters/groq.d.ts +0 -1
- package/dist/adapters/groq.d.ts.map +1 -1
- package/dist/adapters/groq.js +4 -3
- package/dist/adapters/groq.js.map +1 -1
- package/dist/adapters/huggingface.d.ts +0 -1
- package/dist/adapters/huggingface.d.ts.map +1 -1
- package/dist/adapters/huggingface.js +2 -2
- package/dist/adapters/huggingface.js.map +1 -1
- package/dist/adapters/ollama.d.ts +0 -1
- package/dist/adapters/ollama.d.ts.map +1 -1
- package/dist/adapters/ollama.js +4 -3
- package/dist/adapters/ollama.js.map +1 -1
- package/dist/adapters/openai-compatible.d.ts +0 -2
- package/dist/adapters/openai-compatible.d.ts.map +1 -1
- package/dist/adapters/openai-compatible.js +4 -2
- package/dist/adapters/openai-compatible.js.map +1 -1
- package/dist/adapters/openai.d.ts +0 -1
- package/dist/adapters/openai.d.ts.map +1 -1
- package/dist/adapters/openai.js +4 -2
- package/dist/adapters/openai.js.map +1 -1
- package/dist/catalog/index.js +1 -1
- package/dist/catalog/index.js.map +1 -1
- package/dist/catalog/models.d.ts.map +1 -1
- package/dist/catalog/models.js +11 -8
- package/dist/catalog/models.js.map +1 -1
- package/dist/catalog/provider-catalog.d.ts +229 -0
- package/dist/catalog/provider-catalog.d.ts.map +1 -0
- package/dist/catalog/provider-catalog.js +1494 -0
- package/dist/catalog/provider-catalog.js.map +1 -0
- package/dist/client/client.d.ts +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +192 -132
- package/dist/client/client.js.map +1 -1
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js.map +1 -1
- package/dist/config/provider-config.d.ts +2 -0
- package/dist/config/provider-config.d.ts.map +1 -1
- package/dist/config/provider-config.js +12 -1
- package/dist/config/provider-config.js.map +1 -1
- package/dist/cost/alerts.d.ts +1 -0
- package/dist/cost/alerts.d.ts.map +1 -1
- package/dist/cost/alerts.js +18 -5
- package/dist/cost/alerts.js.map +1 -1
- package/dist/cost/tracker.d.ts.map +1 -1
- package/dist/cost/tracker.js +8 -8
- package/dist/cost/tracker.js.map +1 -1
- package/dist/features/rag/chunker.d.ts.map +1 -1
- package/dist/features/rag/chunker.js +6 -0
- package/dist/features/rag/chunker.js.map +1 -1
- package/dist/features/rag/in-memory-store.d.ts.map +1 -1
- package/dist/features/rag/in-memory-store.js +2 -0
- package/dist/features/rag/in-memory-store.js.map +1 -1
- package/dist/features/rag/pipeline.d.ts.map +1 -1
- package/dist/features/rag/pipeline.js +3 -6
- package/dist/features/rag/pipeline.js.map +1 -1
- package/dist/features/rag/retriever.d.ts +5 -0
- package/dist/features/rag/retriever.d.ts.map +1 -1
- package/dist/features/rag/retriever.js +22 -25
- package/dist/features/rag/retriever.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/logging/logger.d.ts +4 -46
- package/dist/logging/logger.d.ts.map +1 -1
- package/dist/logging/logger.js +9 -63
- package/dist/logging/logger.js.map +1 -1
- package/dist/middleware/middleware.d.ts +1 -1
- package/dist/middleware/middleware.d.ts.map +1 -1
- package/dist/middleware/middleware.js +28 -10
- package/dist/middleware/middleware.js.map +1 -1
- package/dist/plugin/registry.d.ts +3 -0
- package/dist/plugin/registry.d.ts.map +1 -1
- package/dist/plugin/registry.js +8 -6
- package/dist/plugin/registry.js.map +1 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +9 -7
- package/dist/providers/registry.js.map +1 -1
- package/dist/reliability/circuit-breaker.d.ts.map +1 -1
- package/dist/reliability/circuit-breaker.js +5 -1
- package/dist/reliability/circuit-breaker.js.map +1 -1
- package/dist/security/audit-logger.d.ts +2 -0
- package/dist/security/audit-logger.d.ts.map +1 -1
- package/dist/security/audit-logger.js +39 -23
- package/dist/security/audit-logger.js.map +1 -1
- package/dist/security/pii-guard.d.ts.map +1 -1
- package/dist/security/pii-guard.js +21 -5
- package/dist/security/pii-guard.js.map +1 -1
- package/dist/security/prompt-injection-guard.d.ts.map +1 -1
- package/dist/security/prompt-injection-guard.js +22 -4
- package/dist/security/prompt-injection-guard.js.map +1 -1
- package/dist/security/url-guard.d.ts.map +1 -1
- package/dist/security/url-guard.js +110 -27
- package/dist/security/url-guard.js.map +1 -1
- package/dist/telemetry/body-logger.d.ts.map +1 -1
- package/dist/telemetry/body-logger.js +18 -9
- package/dist/telemetry/body-logger.js.map +1 -1
- package/dist/telemetry/structured-logger.d.ts.map +1 -1
- package/dist/telemetry/structured-logger.js +20 -7
- package/dist/telemetry/structured-logger.js.map +1 -1
- package/dist/transport/fetch.d.ts.map +1 -1
- package/dist/transport/fetch.js +48 -16
- package/dist/transport/fetch.js.map +1 -1
- package/dist/types/tool-builder.d.ts +3 -1
- package/dist/types/tool-builder.d.ts.map +1 -1
- package/dist/types/tool-builder.js +3 -1
- package/dist/types/tool-builder.js.map +1 -1
- package/dist/types/tools.d.ts +0 -2
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/types/tools.js +1 -11
- package/dist/types/tools.js.map +1 -1
- package/package.json +124 -108
- package/dist/catalog/provider-catalog.json +0 -246
- package/dist/client/pipeline.d.ts +0 -134
- package/dist/client/pipeline.d.ts.map +0 -1
- package/dist/client/pipeline.js +0 -222
- package/dist/client/pipeline.js.map +0 -1
- package/dist/features/memory/index.d.ts +0 -3
- package/dist/features/memory/index.d.ts.map +0 -1
- package/dist/features/memory/index.js +0 -2
- package/dist/features/memory/index.js.map +0 -1
- package/dist/features/memory/memory.d.ts +0 -46
- package/dist/features/memory/memory.d.ts.map +0 -1
- package/dist/features/memory/memory.js +0 -152
- package/dist/features/memory/memory.js.map +0 -1
- package/dist/plugin/index.d.ts +0 -9
- package/dist/plugin/index.d.ts.map +0 -1
- package/dist/plugin/index.js +0 -8
- package/dist/plugin/index.js.map +0 -1
- package/dist/security/index.d.ts +0 -18
- package/dist/security/index.d.ts.map +0 -1
- package/dist/security/index.js +0 -12
- package/dist/security/index.js.map +0 -1
- package/dist/telemetry/index.d.ts +0 -15
- package/dist/telemetry/index.d.ts.map +0 -1
- package/dist/telemetry/index.js +0 -11
- package/dist/telemetry/index.js.map +0 -1
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": "0.26.6",
|
|
3
|
-
"generated": "2026-09-19",
|
|
4
|
-
"providers": {
|
|
5
|
-
"openai": {
|
|
6
|
-
"name": "OpenAI",
|
|
7
|
-
"baseUrl": "https://api.openai.com/v1",
|
|
8
|
-
"adapters": ["openai"],
|
|
9
|
-
"envKey": "OPENAI_API_KEY",
|
|
10
|
-
"models": [
|
|
11
|
-
{ "id": "gpt-6-astra", "name": "GPT-6 Astra", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
12
|
-
{ "id": "gpt-5.6-sol", "name": "GPT-5.6 Sol", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
13
|
-
{ "id": "gpt-5.6-terra", "name": "GPT-5.6 Terra", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
14
|
-
{ "id": "gpt-5.6-luna", "name": "GPT-5.6 Luna", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
15
|
-
{ "id": "gpt-5.5", "name": "GPT-5.5", "contextWindow": 200000, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
16
|
-
{ "id": "gpt-5.4-pro", "name": "GPT-5.4 Pro", "contextWindow": 200000, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
17
|
-
{ "id": "gpt-4.5", "name": "GPT-4.5", "contextWindow": 128000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "structuredOutput", "parallelTools"] },
|
|
18
|
-
{ "id": "gpt-4o", "name": "GPT-4o", "contextWindow": 128000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "structuredOutput", "parallelTools"] },
|
|
19
|
-
{ "id": "gpt-4o-mini", "name": "GPT-4o Mini", "contextWindow": 128000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "structuredOutput"] },
|
|
20
|
-
{ "id": "o1", "name": "o1", "contextWindow": 200000, "maxOutput": 100000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
21
|
-
{ "id": "o1-mini", "name": "o1 Mini", "contextWindow": 200000, "maxOutput": 100000, "capabilities": ["streaming", "tools", "reasoning", "structuredOutput"] },
|
|
22
|
-
{ "id": "o3", "name": "o3", "contextWindow": 200000, "maxOutput": 100000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
23
|
-
{ "id": "o4-mini", "name": "o4 Mini", "contextWindow": 200000, "maxOutput": 100000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
24
|
-
{ "id": "text-embedding-3-small", "name": "Embedding 3 Small", "contextWindow": 8191, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
25
|
-
{ "id": "text-embedding-3-large", "name": "Embedding 3 Large", "contextWindow": 8191, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
26
|
-
{ "id": "dall-e-3", "name": "DALL-E 3", "contextWindow": 4096, "maxOutput": 0, "capabilities": ["imageGeneration"] },
|
|
27
|
-
{ "id": "tts-1", "name": "TTS-1", "contextWindow": 4096, "maxOutput": 0, "capabilities": ["speech"] },
|
|
28
|
-
{ "id": "whisper-1", "name": "Whisper v1", "contextWindow": 0, "maxOutput": 0, "capabilities": ["transcription"] }
|
|
29
|
-
]
|
|
30
|
-
},
|
|
31
|
-
"anthropic": {
|
|
32
|
-
"name": "Anthropic",
|
|
33
|
-
"baseUrl": "https://api.anthropic.com",
|
|
34
|
-
"adapters": ["anthropic"],
|
|
35
|
-
"envKey": "ANTHROPIC_API_KEY",
|
|
36
|
-
"models": [
|
|
37
|
-
{ "id": "claude-fable-5-1", "name": "Claude Fable 5.1", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
38
|
-
{ "id": "claude-opus-5", "name": "Claude Opus 5", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
39
|
-
{ "id": "claude-sonnet-5", "name": "Claude Sonnet 5", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
40
|
-
{ "id": "claude-haiku-4-5", "name": "Claude Haiku 4.5", "contextWindow": 200000, "maxOutput": 64000, "capabilities": ["streaming", "tools", "vision", "structuredOutput"] },
|
|
41
|
-
{ "id": "claude-3-5-sonnet-20241022", "name": "Claude 3.5 Sonnet", "contextWindow": 200000, "maxOutput": 8192, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
42
|
-
{ "id": "claude-3-5-haiku-20241022", "name": "Claude 3.5 Haiku", "contextWindow": 200000, "maxOutput": 8192, "capabilities": ["streaming", "tools", "vision"] }
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
"google-genai": {
|
|
46
|
-
"name": "Google Gemini",
|
|
47
|
-
"baseUrl": "https://generativelanguage.googleapis.com",
|
|
48
|
-
"adapters": ["google-genai"],
|
|
49
|
-
"envKey": "GOOGLE_API_KEY",
|
|
50
|
-
"models": [
|
|
51
|
-
{ "id": "gemini-3.8-flash", "name": "Gemini 3.8 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
52
|
-
{ "id": "gemini-3.7-flash", "name": "Gemini 3.7 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
53
|
-
{ "id": "gemini-3.6-flash", "name": "Gemini 3.6 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
54
|
-
{ "id": "gemini-3.5-flash", "name": "Gemini 3.5 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
55
|
-
{ "id": "gemini-3.1-pro-preview", "name": "Gemini 3.1 Pro", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
56
|
-
{ "id": "gemini-3-flash-preview", "name": "Gemini 3 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
57
|
-
{ "id": "gemini-2.5-pro", "name": "Gemini 2.5 Pro", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
58
|
-
{ "id": "gemini-2.5-flash", "name": "Gemini 2.5 Flash", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision"] }
|
|
59
|
-
]
|
|
60
|
-
},
|
|
61
|
-
"azure": {
|
|
62
|
-
"name": "Azure OpenAI",
|
|
63
|
-
"baseUrl": "https://your-resource.openai.azure.com",
|
|
64
|
-
"adapters": ["azure"],
|
|
65
|
-
"envKey": "AZURE_OPENAI_API_KEY",
|
|
66
|
-
"models": [
|
|
67
|
-
{ "id": "gpt-6-astra", "name": "GPT-6 Astra (Azure)", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
68
|
-
{ "id": "gpt-5.6-sol", "name": "GPT-5.6 Sol (Azure)", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
69
|
-
{ "id": "gpt-5.6-terra", "name": "GPT-5.6 Terra (Azure)", "contextWindow": 1050000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
70
|
-
{ "id": "o3", "name": "o3 (Azure)", "contextWindow": 200000, "maxOutput": 100000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
71
|
-
{ "id": "gpt-4o", "name": "GPT-4o (Azure)", "contextWindow": 128000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "structuredOutput", "parallelTools"] }
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"groq": {
|
|
75
|
-
"name": "Groq",
|
|
76
|
-
"baseUrl": "https://api.groq.com/openai/v1",
|
|
77
|
-
"adapters": ["groq"],
|
|
78
|
-
"envKey": "GROQ_API_KEY",
|
|
79
|
-
"models": [
|
|
80
|
-
{ "id": "llama-3.3-70b-versatile", "name": "Llama 3.3 70B", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
81
|
-
{ "id": "llama-3.2-90b-vision", "name": "Llama 3.2 90B Vision", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput"] },
|
|
82
|
-
{ "id": "llama-3.2-11b-vision", "name": "Llama 3.2 11B Vision", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision"] },
|
|
83
|
-
{ "id": "llama-3.2-3b", "name": "Llama 3.2 3B", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "reasoning"] },
|
|
84
|
-
{ "id": "qwen-2.5-coder-32b", "name": "Qwen 2.5 Coder 32B", "contextWindow": 32768, "maxOutput": 16384, "capabilities": ["streaming", "tools", "reasoning", "structuredOutput", "parallelTools"] },
|
|
85
|
-
{ "id": "qwen-2.5-72b-instruct", "name": "Qwen 2.5 72B", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
86
|
-
]
|
|
87
|
-
},
|
|
88
|
-
"bedrock": {
|
|
89
|
-
"name": "AWS Bedrock",
|
|
90
|
-
"baseUrl": "https://bedrock-runtime.{region}.amazonaws.com",
|
|
91
|
-
"adapters": ["bedrock"],
|
|
92
|
-
"envKey": "AWS_BEARER_TOKEN_BEDROCK",
|
|
93
|
-
"models": [
|
|
94
|
-
{ "id": "anthropic.claude-fable-5-1", "name": "Claude Fable 5.1 (Bedrock)", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
95
|
-
{ "id": "anthropic.claude-opus-5", "name": "Claude Opus 5 (Bedrock)", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
96
|
-
{ "id": "anthropic.claude-sonnet-5", "name": "Claude Sonnet 5 (Bedrock)", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
97
|
-
{ "id": "anthropic.claude-haiku-4-5", "name": "Claude Haiku 4.5 (Bedrock)", "contextWindow": 200000, "maxOutput": 64000, "capabilities": ["streaming", "tools", "vision", "structuredOutput"] },
|
|
98
|
-
{ "id": "meta.llama3-3-70b-instruct", "name": "Llama 3.3 70B (Bedrock)", "contextWindow": 131072, "maxOutput": 4096, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
99
|
-
{ "id": "meta.llama3-1-405b-instruct-v1:0", "name": "Llama 3.1 405B (Bedrock)", "contextWindow": 131072, "maxOutput": 4096, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
100
|
-
{ "id": "mistral.mistral-large-2407-v1:0", "name": "Mistral Large 2 (Bedrock)", "contextWindow": 128000, "maxOutput": 8192, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
101
|
-
{ "id": "amazon.nova-pro-v1:0", "name": "Nova Pro (Bedrock)", "contextWindow": 300000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput"] },
|
|
102
|
-
{ "id": "amazon.nova-lite-v1:0", "name": "Nova Lite (Bedrock)", "contextWindow": 300000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision"] }
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
"google-vertex": {
|
|
106
|
-
"name": "Google Vertex AI",
|
|
107
|
-
"baseUrl": "https://{region}-aiplatform.googleapis.com",
|
|
108
|
-
"adapters": ["google-vertex"],
|
|
109
|
-
"envKey": "GOOGLE_APPLICATION_CREDENTIALS",
|
|
110
|
-
"models": [
|
|
111
|
-
{ "id": "google/gemini-3.8-flash", "name": "Gemini 3.8 Flash (Vertex)", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning"] },
|
|
112
|
-
{ "id": "google/gemini-3.7-flash", "name": "Gemini 3.7 Flash (Vertex)", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning"] },
|
|
113
|
-
{ "id": "google/gemini-3.1-pro-preview", "name": "Gemini 3.1 Pro (Vertex)", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning"] },
|
|
114
|
-
{ "id": "google/gemini-2.5-pro", "name": "Gemini 2.5 Pro (Vertex)", "contextWindow": 1048576, "maxOutput": 65536, "capabilities": ["streaming", "tools", "vision", "reasoning"] },
|
|
115
|
-
{ "id": "anthropic/claude-fable-5-1@20260901", "name": "Claude Fable 5.1 (Vertex)", "contextWindow": 1000000, "maxOutput": 128000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
116
|
-
{ "id": "meta/llama-4-maverick", "name": "Llama 4 Maverick (Vertex)", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
117
|
-
]
|
|
118
|
-
},
|
|
119
|
-
"huggingface": {
|
|
120
|
-
"name": "Hugging Face Inference",
|
|
121
|
-
"baseUrl": "https://api-inference.huggingface.co/v1",
|
|
122
|
-
"adapters": ["huggingface"],
|
|
123
|
-
"envKey": "HF_TOKEN",
|
|
124
|
-
"models": [
|
|
125
|
-
{ "id": "meta-llama/Llama-4-Maverick", "name": "Llama 4 Maverick (HF)", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
126
|
-
{ "id": "meta-llama/Llama-4-Scout", "name": "Llama 4 Scout (HF)", "contextWindow": 10000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
127
|
-
{ "id": "meta-llama/Llama-3.3-70B-Instruct", "name": "Llama 3.3 70B (HF)", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
128
|
-
{ "id": "Qwen/Qwen3.8-Max", "name": "Qwen 3.8 Max (HF)", "contextWindow": 1000000, "maxOutput": 131072, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
129
|
-
{ "id": "Qwen/Qwen2.5-72B-Instruct", "name": "Qwen 2.5 72B (HF)", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
130
|
-
{ "id": "deepseek-ai/DeepSeek-V4-Pro", "name": "DeepSeek V4 Pro (HF)", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
131
|
-
{ "id": "deepseek-ai/DeepSeek-V4-Flash", "name": "DeepSeek V4 Flash (HF)", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
132
|
-
]
|
|
133
|
-
},
|
|
134
|
-
"deepseek": {
|
|
135
|
-
"name": "DeepSeek",
|
|
136
|
-
"baseUrl": "https://api.deepseek.com/v1",
|
|
137
|
-
"adapters": ["deepseek"],
|
|
138
|
-
"envKey": "DEEPSEEK_API_KEY",
|
|
139
|
-
"models": [
|
|
140
|
-
{ "id": "deepseek-v4-pro", "name": "DeepSeek V4 Pro", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
141
|
-
{ "id": "deepseek-flash", "name": "DeepSeek V4.1 Flash", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
142
|
-
{ "id": "deepseek-chat", "name": "DeepSeek Chat (legacy)", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
143
|
-
]
|
|
144
|
-
},
|
|
145
|
-
"xai": {
|
|
146
|
-
"name": "xAI (Grok)",
|
|
147
|
-
"baseUrl": "https://api.x.ai/v1",
|
|
148
|
-
"adapters": ["xai"],
|
|
149
|
-
"envKey": "XAI_API_KEY",
|
|
150
|
-
"models": [
|
|
151
|
-
{ "id": "grok-4.6", "name": "Grok 4.6", "contextWindow": 500000, "maxOutput": 32768, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
152
|
-
{ "id": "grok-4.5", "name": "Grok 4.5", "contextWindow": 500000, "maxOutput": 32768, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
153
|
-
{ "id": "grok-4.3", "name": "Grok 4.3", "contextWindow": 1000000, "maxOutput": 32768, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
154
|
-
{ "id": "grok-4.20-0309-reasoning", "name": "Grok 4.20 Reasoning", "contextWindow": 1000000, "maxOutput": 32768, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
155
|
-
]
|
|
156
|
-
},
|
|
157
|
-
"together": {
|
|
158
|
-
"name": "Together AI",
|
|
159
|
-
"baseUrl": "https://api.together.xyz/v1",
|
|
160
|
-
"adapters": ["together"],
|
|
161
|
-
"envKey": "TOGETHER_API_KEY",
|
|
162
|
-
"models": [
|
|
163
|
-
{ "id": "meta-llama/Llama-4-Maverick-17B-128E-Instruct", "name": "Llama 4 Maverick (Together)", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
164
|
-
{ "id": "meta-llama/Llama-4-Scout-17B-16E-Instruct", "name": "Llama 4 Scout (Together)", "contextWindow": 10000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
165
|
-
{ "id": "meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo", "name": "Llama 3.1 405B Turbo", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
166
|
-
{ "id": "deepseek-ai/DeepSeek-V4-Pro", "name": "DeepSeek V4 Pro", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
167
|
-
{ "id": "deepseek-ai/DeepSeek-V4-Flash", "name": "DeepSeek V4 Flash", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
168
|
-
]
|
|
169
|
-
},
|
|
170
|
-
"fireworks": {
|
|
171
|
-
"name": "Fireworks",
|
|
172
|
-
"baseUrl": "https://api.fireworks.ai/inference/v1",
|
|
173
|
-
"adapters": ["fireworks"],
|
|
174
|
-
"envKey": "FIREWORKS_API_KEY",
|
|
175
|
-
"models": [
|
|
176
|
-
{ "id": "accounts/fireworks/models/llama4-maverick-instruct-basic", "name": "Llama 4 Maverick (Fireworks)", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
177
|
-
{ "id": "accounts/fireworks/models/llama4-scout-instruct-basic", "name": "Llama 4 Scout (Fireworks)", "contextWindow": 10000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
178
|
-
{ "id": "accounts/fireworks/models/deepseek-v4-pro", "name": "DeepSeek V4 Pro (Fireworks)", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
179
|
-
]
|
|
180
|
-
},
|
|
181
|
-
"cohere": {
|
|
182
|
-
"name": "Cohere",
|
|
183
|
-
"baseUrl": "https://api.cohere.com/v2",
|
|
184
|
-
"adapters": ["cohere"],
|
|
185
|
-
"envKey": "COHERE_API_KEY",
|
|
186
|
-
"models": [
|
|
187
|
-
{ "id": "command-a-plus-05-2026", "name": "Command A+", "contextWindow": 128000, "maxOutput": 64000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
188
|
-
{ "id": "command-a-03-2025", "name": "Command A", "contextWindow": 256000, "maxOutput": 8000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
189
|
-
{ "id": "command-r-plus", "name": "Command R+", "contextWindow": 128000, "maxOutput": 4096, "capabilities": ["streaming", "tools", "reasoning", "structuredOutput"] },
|
|
190
|
-
{ "id": "rerank-english-v3.0", "name": "Rerank English v3", "contextWindow": 512, "maxOutput": 0, "capabilities": ["rerank"] },
|
|
191
|
-
{ "id": "rerank-multilingual-v3.0", "name": "Rerank Multilingual v3", "contextWindow": 512, "maxOutput": 0, "capabilities": ["rerank"] },
|
|
192
|
-
{ "id": "embed-english-v3.0", "name": "Embed English v3", "contextWindow": 512, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
193
|
-
{ "id": "embed-multilingual-v3.0", "name": "Embed Multilingual v3", "contextWindow": 512, "maxOutput": 0, "capabilities": ["embeddings"] }
|
|
194
|
-
]
|
|
195
|
-
},
|
|
196
|
-
"ollama": {
|
|
197
|
-
"name": "Ollama (Local)",
|
|
198
|
-
"baseUrl": "http://localhost:11434/v1",
|
|
199
|
-
"adapters": ["ollama"],
|
|
200
|
-
"envKey": null,
|
|
201
|
-
"models": [
|
|
202
|
-
{ "id": "llama4:maverick", "name": "Llama 4 Maverick", "contextWindow": 1000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
203
|
-
{ "id": "llama4:scout", "name": "Llama 4 Scout", "contextWindow": 10000000, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
204
|
-
{ "id": "llama3.3:70b", "name": "Llama 3.3 70B", "contextWindow": 131072, "maxOutput": 16384, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
205
|
-
{ "id": "qwen3.8-max:latest", "name": "Qwen 3.8 Max", "contextWindow": 1000000, "maxOutput": 131072, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
206
|
-
{ "id": "deepseek-v4-pro:latest", "name": "DeepSeek V4 Pro", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] },
|
|
207
|
-
{ "id": "deepseek-v4-flash:latest", "name": "DeepSeek V4 Flash", "contextWindow": 1000000, "maxOutput": 384000, "capabilities": ["streaming", "tools", "vision", "reasoning", "structuredOutput", "parallelTools"] }
|
|
208
|
-
]
|
|
209
|
-
},
|
|
210
|
-
"voyageai": {
|
|
211
|
-
"name": "Voyage AI",
|
|
212
|
-
"baseUrl": "https://api.voyageai.com/v1",
|
|
213
|
-
"adapters": ["voyageai"],
|
|
214
|
-
"envKey": "VOYAGE_API_KEY",
|
|
215
|
-
"models": [
|
|
216
|
-
{ "id": "voyage-3-large", "name": "Voyage 3 Large", "contextWindow": 32000, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
217
|
-
{ "id": "voyage-code-3", "name": "Voyage Code 3", "contextWindow": 32000, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
218
|
-
{ "id": "voyage-3", "name": "Voyage 3", "contextWindow": 32000, "maxOutput": 0, "capabilities": ["embeddings"] },
|
|
219
|
-
{ "id": "voyage-3-lite", "name": "Voyage 3 Lite", "contextWindow": 32000, "maxOutput": 0, "capabilities": ["embeddings"] }
|
|
220
|
-
]
|
|
221
|
-
},
|
|
222
|
-
"deepgram": {
|
|
223
|
-
"name": "Deepgram",
|
|
224
|
-
"baseUrl": "https://api.deepgram.com/v1",
|
|
225
|
-
"adapters": ["deepgram"],
|
|
226
|
-
"envKey": "DEEPGRAM_API_KEY",
|
|
227
|
-
"models": [
|
|
228
|
-
{ "id": "nova-2", "name": "Nova 2", "contextWindow": 0, "maxOutput": 0, "capabilities": ["transcription"] },
|
|
229
|
-
{ "id": "nova-2-medical", "name": "Nova 2 Medical", "contextWindow": 0, "maxOutput": 0, "capabilities": ["transcription"] },
|
|
230
|
-
{ "id": "whisper-large", "name": "Whisper Large", "contextWindow": 0, "maxOutput": 0, "capabilities": ["transcription"] }
|
|
231
|
-
]
|
|
232
|
-
},
|
|
233
|
-
"elevenlabs": {
|
|
234
|
-
"name": "ElevenLabs",
|
|
235
|
-
"baseUrl": "https://api.elevenlabs.io/v1",
|
|
236
|
-
"adapters": ["elevenlabs"],
|
|
237
|
-
"envKey": "ELEVENLABS_API_KEY",
|
|
238
|
-
"models": [
|
|
239
|
-
{ "id": "eleven_flash_v2_5", "name": "Eleven Flash v2.5", "contextWindow": 0, "maxOutput": 0, "capabilities": ["speech"] },
|
|
240
|
-
{ "id": "eleven_flash_v2", "name": "Eleven Flash v2", "contextWindow": 0, "maxOutput": 0, "capabilities": ["speech"] },
|
|
241
|
-
{ "id": "eleven_multilingual_v2", "name": "Eleven Multilingual v2", "contextWindow": 0, "maxOutput": 0, "capabilities": ["speech"] },
|
|
242
|
-
{ "id": "eleven_monolingual_v1", "name": "Eleven Monolingual v1", "contextWindow": 0, "maxOutput": 0, "capabilities": ["speech"] }
|
|
243
|
-
]
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @hilbras/sdk — RequestPipeline (v0.10.0 PR-4)
|
|
3
|
-
*
|
|
4
|
-
* The shared reliability lifecycle for a *single attempt*. Used by
|
|
5
|
-
* `HilbrasClient.stream()` and `HilbrasClient.complete()`.
|
|
6
|
-
*
|
|
7
|
-
* Before PR-4, both methods had near-duplicate code for: provider
|
|
8
|
-
* resolution, circuit-breaker check, retry config, timeout signal,
|
|
9
|
-
* budget reservation, budget settle/release, and request.completed /
|
|
10
|
-
* request.failed event emission. The pipeline extracts those concerns
|
|
11
|
-
* for a single attempt. The retry loop and fallback loop stay in the
|
|
12
|
-
* client (where the per-stream consumption semantics live), but they
|
|
13
|
-
* now call `pipeline.runOnce(...)` for each attempt — so a single
|
|
14
|
-
* attempt is one place in the code, not two.
|
|
15
|
-
*
|
|
16
|
-
* Internal-only: not exported from `src/index.ts`.
|
|
17
|
-
*/
|
|
18
|
-
import type { AIProvider } from "../types/adapter.js";
|
|
19
|
-
import type { HookEvent } from "../types/observability.js";
|
|
20
|
-
import type { Message } from "../types/messages.js";
|
|
21
|
-
import type { StreamChunk } from "../types/streams.js";
|
|
22
|
-
import type { ResolvedPolicy } from "../types/policy.js";
|
|
23
|
-
import type { ProviderConfig } from "../types/providers.js";
|
|
24
|
-
import type { ExecutionPolicy } from "../types/policy.js";
|
|
25
|
-
import { type CircuitBreaker } from "../reliability/circuit-breaker.js";
|
|
26
|
-
import { createRetryConfig } from "../reliability/retry.js";
|
|
27
|
-
import type { BudgetTracker } from "../cost/tracker.js";
|
|
28
|
-
/** Per-attempt result for a streaming run. */
|
|
29
|
-
export interface StreamAttemptResult {
|
|
30
|
-
/** Total input tokens reported by the usage chunk, if any. */
|
|
31
|
-
inputTokens?: number;
|
|
32
|
-
/** Total output tokens reported by the usage chunk, if any. */
|
|
33
|
-
outputTokens?: number;
|
|
34
|
-
}
|
|
35
|
-
/** Streaming executor signature. */
|
|
36
|
-
export type StreamExecutor = (args: {
|
|
37
|
-
signal: AbortSignal | undefined;
|
|
38
|
-
providerName: string;
|
|
39
|
-
modelId: string;
|
|
40
|
-
messages: Message[];
|
|
41
|
-
temperature: number | undefined;
|
|
42
|
-
maxTokens: number | undefined;
|
|
43
|
-
tools: import("../types/tools.js").Tool[] | undefined;
|
|
44
|
-
extra: Record<string, unknown> | undefined;
|
|
45
|
-
}) => Promise<{
|
|
46
|
-
chunks: AsyncGenerator<StreamChunk>;
|
|
47
|
-
result: StreamAttemptResult;
|
|
48
|
-
}>;
|
|
49
|
-
/** Non-streaming executor signature. */
|
|
50
|
-
export type CompleteExecutor<T> = (args: {
|
|
51
|
-
signal: AbortSignal | undefined;
|
|
52
|
-
providerName: string;
|
|
53
|
-
modelId: string;
|
|
54
|
-
messages: Message[];
|
|
55
|
-
temperature: number | undefined;
|
|
56
|
-
maxTokens: number | undefined;
|
|
57
|
-
tools: import("../types/tools.js").Tool[] | undefined;
|
|
58
|
-
extra: Record<string, unknown> | undefined;
|
|
59
|
-
}) => Promise<T>;
|
|
60
|
-
/** Result of a successful streaming run. */
|
|
61
|
-
export interface PipelineStreamSuccess {
|
|
62
|
-
ok: true;
|
|
63
|
-
attempts: number;
|
|
64
|
-
inputTokens?: number;
|
|
65
|
-
outputTokens?: number;
|
|
66
|
-
providerName: string;
|
|
67
|
-
modelId: string;
|
|
68
|
-
}
|
|
69
|
-
/** A streaming-executor error that the host should classify (retry/fallback). */
|
|
70
|
-
export interface PipelineStreamFailure {
|
|
71
|
-
ok: false;
|
|
72
|
-
err: unknown;
|
|
73
|
-
}
|
|
74
|
-
export type PipelineStreamResult = PipelineStreamSuccess | PipelineStreamFailure;
|
|
75
|
-
/** Same shape for non-streaming. */
|
|
76
|
-
export type PipelineCompleteResult<T> = {
|
|
77
|
-
ok: true;
|
|
78
|
-
attempts: number;
|
|
79
|
-
value: T;
|
|
80
|
-
providerName: string;
|
|
81
|
-
modelId: string;
|
|
82
|
-
} | {
|
|
83
|
-
ok: false;
|
|
84
|
-
err: unknown;
|
|
85
|
-
};
|
|
86
|
-
/** What the pipeline needs from the host to do its job. */
|
|
87
|
-
export interface PipelineContext {
|
|
88
|
-
requestId: string;
|
|
89
|
-
startTime: number;
|
|
90
|
-
providerConfig: ProviderConfig;
|
|
91
|
-
modelId: string;
|
|
92
|
-
resolved: ResolvedPolicy;
|
|
93
|
-
adapter: AIProvider;
|
|
94
|
-
circuitBreaker: CircuitBreaker | undefined;
|
|
95
|
-
retryConfig: ReturnType<typeof createRetryConfig>;
|
|
96
|
-
signal: AbortSignal | undefined;
|
|
97
|
-
messages: Message[];
|
|
98
|
-
emit: (event: HookEvent) => void;
|
|
99
|
-
budgetTracker: BudgetTracker;
|
|
100
|
-
/** When true (default), the streaming variant settles the budget on the
|
|
101
|
-
* first usage chunk. When false, the budget is settled at the end-of-stream
|
|
102
|
-
* using the estimated cost. */
|
|
103
|
-
settleOnUsage: boolean;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Build a `PipelineContext` for a given client request. The host
|
|
107
|
-
* (HilbrasClient.stream / complete) supplies the resolved fields.
|
|
108
|
-
*/
|
|
109
|
-
export interface BuildContextArgs {
|
|
110
|
-
requestId: string;
|
|
111
|
-
startTime: number;
|
|
112
|
-
providerConfig: ProviderConfig;
|
|
113
|
-
modelId: string;
|
|
114
|
-
policy: ExecutionPolicy | undefined;
|
|
115
|
-
defaultPolicy: ExecutionPolicy | undefined;
|
|
116
|
-
adapter: AIProvider;
|
|
117
|
-
messages: Message[];
|
|
118
|
-
signal: AbortSignal | undefined;
|
|
119
|
-
emit: (event: HookEvent) => void;
|
|
120
|
-
budgetTracker: BudgetTracker;
|
|
121
|
-
settleOnUsage: boolean;
|
|
122
|
-
}
|
|
123
|
-
export declare function buildPipelineContext(args: BuildContextArgs): PipelineContext;
|
|
124
|
-
/**
|
|
125
|
-
* Run a single streaming attempt through the full pipeline (reservation,
|
|
126
|
-
* executor, budget settle, hook emission). Returns a result object the
|
|
127
|
-
* host can use to decide retry/fallback.
|
|
128
|
-
*/
|
|
129
|
-
export declare function runStreamAttempt(ctx: PipelineContext, executor: StreamExecutor, attempt: number): Promise<PipelineStreamResult>;
|
|
130
|
-
/** Run a single non-streaming attempt through the full pipeline. */
|
|
131
|
-
export declare function runCompleteAttempt<T>(ctx: PipelineContext, executor: CompleteExecutor<T>, attempt: number): Promise<PipelineCompleteResult<T>>;
|
|
132
|
-
/** Record a final-failure event for a request that exhausted retries and fallbacks. */
|
|
133
|
-
export declare function recordFailure(ctx: PipelineContext, err: unknown, attempt: number): void;
|
|
134
|
-
//# sourceMappingURL=pipeline.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.d.ts","sourceRoot":"","sources":["../../src/client/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnG,OAAO,EAAE,iBAAiB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-
* The shared reliability lifecycle for a *single attempt*. Used by
|
|
5
|
-
* `HilbrasClient.stream()` and `HilbrasClient.complete()`.
|
|
6
|
-
*
|
|
7
|
-
* Before PR-4, both methods had near-duplicate code for: provider
|
|
8
|
-
* resolution, circuit-breaker check, retry config, timeout signal,
|
|
9
|
-
* budget reservation, budget settle/release, and request.completed /
|
|
10
|
-
* request.failed event emission. The pipeline extracts those concerns
|
|
11
|
-
* for a single attempt. The retry loop and fallback loop stay in the
|
|
12
|
-
* client (where the per-stream consumption semantics live), but they
|
|
13
|
-
* now call `pipeline.runOnce(...)` for each attempt — so a single
|
|
14
|
-
* attempt is one place in the code, not two.
|
|
15
|
-
*
|
|
16
|
-
* Internal-only: not exported from `src/index.ts`.
|
|
17
|
-
*/
|
|
18
|
-
import { ConfigurationError, CircuitBreakerOpenError } from "../errors/index.js";
|
|
19
|
-
import { resolvePolicy } from "../reliability/presets.js";
|
|
20
|
-
import { getCircuitBreakerRegistry } from "../reliability/circuit-breaker.js";
|
|
21
|
-
import { createRetryConfig } from "../reliability/retry.js";
|
|
22
|
-
import { createTimeoutSignal } from "../reliability/timeout.js";
|
|
23
|
-
import { estimateTokens } from "../tokens/counter.js";
|
|
24
|
-
export function buildPipelineContext(args) {
|
|
25
|
-
const resolved = resolvePolicy(args.policy ?? args.defaultPolicy);
|
|
26
|
-
let circuitBreaker;
|
|
27
|
-
if (resolved.circuitBreaker.enabled) {
|
|
28
|
-
circuitBreaker = getCircuitBreakerRegistry().getOrCreate(args.providerConfig.name, {
|
|
29
|
-
failureThreshold: resolved.circuitBreaker.failureThreshold,
|
|
30
|
-
successThreshold: resolved.circuitBreaker.successThreshold,
|
|
31
|
-
timeoutMs: resolved.circuitBreaker.timeoutMs,
|
|
32
|
-
halfOpenMaxCalls: resolved.circuitBreaker.halfOpenMaxCalls,
|
|
33
|
-
});
|
|
34
|
-
if (!circuitBreaker.isAvailable()) {
|
|
35
|
-
args.emit({
|
|
36
|
-
type: "circuit_breaker.open",
|
|
37
|
-
requestId: args.requestId,
|
|
38
|
-
timestamp: performance.now(),
|
|
39
|
-
provider: args.providerConfig.name,
|
|
40
|
-
});
|
|
41
|
-
throw new CircuitBreakerOpenError(args.providerConfig.name, {
|
|
42
|
-
failureCount: circuitBreaker.stats.failureCount,
|
|
43
|
-
retryAfterMs: resolved.circuitBreaker.timeoutMs,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const retryConfig = createRetryConfig({
|
|
48
|
-
maxRetries: resolved.retry.maxRetries,
|
|
49
|
-
retryableStatuses: resolved.retry.retryableStatuses,
|
|
50
|
-
retryableNetworkErrors: resolved.retry.retryableNetworkErrors,
|
|
51
|
-
});
|
|
52
|
-
const timeoutMs = resolved.timeout.requestTimeoutMs || args.providerConfig.timeout;
|
|
53
|
-
const signal = timeoutMs
|
|
54
|
-
? createTimeoutSignal({ requestTimeoutMs: timeoutMs }, args.signal)
|
|
55
|
-
: args.signal;
|
|
56
|
-
return {
|
|
57
|
-
requestId: args.requestId,
|
|
58
|
-
startTime: args.startTime,
|
|
59
|
-
providerConfig: args.providerConfig,
|
|
60
|
-
modelId: args.modelId,
|
|
61
|
-
resolved,
|
|
62
|
-
adapter: args.adapter,
|
|
63
|
-
circuitBreaker,
|
|
64
|
-
retryConfig,
|
|
65
|
-
signal,
|
|
66
|
-
messages: args.messages,
|
|
67
|
-
emit: args.emit,
|
|
68
|
-
budgetTracker: args.budgetTracker,
|
|
69
|
-
settleOnUsage: args.settleOnUsage,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Run a single streaming attempt through the full pipeline (reservation,
|
|
74
|
-
* executor, budget settle, hook emission). Returns a result object the
|
|
75
|
-
* host can use to decide retry/fallback.
|
|
76
|
-
*/
|
|
77
|
-
export async function runStreamAttempt(ctx, executor, attempt) {
|
|
78
|
-
const { requestId, startTime, providerConfig, modelId, signal, messages, emit, budgetTracker, settleOnUsage } = ctx;
|
|
79
|
-
const estimatedCost = budgetTracker.estimate(modelId, providerConfig.name, estimateTokens(messages.map((m) => m.content ?? "").join("")), 0);
|
|
80
|
-
const initialReservation = budgetTracker.reserve(requestId, estimatedCost);
|
|
81
|
-
if (!initialReservation) {
|
|
82
|
-
throw new ConfigurationError(`Budget reservation rejected — estimated cost $${estimatedCost.toFixed(4)} would exceed budget`, `Remaining budget: $${budgetTracker.report().remainingBudget?.toFixed(4) ?? "unknown"}. Options: (1) increase sessionBudget, (2) use a cheaper model, (3) reduce input token count`);
|
|
83
|
-
}
|
|
84
|
-
let reservationActive = true;
|
|
85
|
-
let usageSettled = false;
|
|
86
|
-
let totalIn;
|
|
87
|
-
let totalOut;
|
|
88
|
-
try {
|
|
89
|
-
const { chunks, result } = await executor({
|
|
90
|
-
signal,
|
|
91
|
-
providerName: providerConfig.name,
|
|
92
|
-
modelId,
|
|
93
|
-
messages,
|
|
94
|
-
temperature: undefined,
|
|
95
|
-
maxTokens: undefined,
|
|
96
|
-
tools: undefined,
|
|
97
|
-
extra: undefined,
|
|
98
|
-
});
|
|
99
|
-
for await (const chunk of chunks) {
|
|
100
|
-
if (chunk.type === "usage") {
|
|
101
|
-
const inT = chunk.inputTokens;
|
|
102
|
-
const outT = chunk.outputTokens;
|
|
103
|
-
totalIn = inT;
|
|
104
|
-
totalOut = outT;
|
|
105
|
-
if (reservationActive && !usageSettled && settleOnUsage) {
|
|
106
|
-
const actualCost = budgetTracker.estimate(modelId, providerConfig.name, inT ?? 0, outT ?? 0);
|
|
107
|
-
budgetTracker.settle(requestId, actualCost, { provider: providerConfig.name, model: modelId, phase: "execute" });
|
|
108
|
-
reservationActive = false;
|
|
109
|
-
usageSettled = true;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
if (result.inputTokens !== undefined)
|
|
114
|
-
totalIn = result.inputTokens;
|
|
115
|
-
if (result.outputTokens !== undefined)
|
|
116
|
-
totalOut = result.outputTokens;
|
|
117
|
-
ctx.circuitBreaker?.recordSuccess();
|
|
118
|
-
if (reservationActive) {
|
|
119
|
-
// No usage chunk arrived; settle at the estimate.
|
|
120
|
-
budgetTracker.settle(requestId, estimatedCost, { provider: providerConfig.name, model: modelId, phase: "execute" });
|
|
121
|
-
reservationActive = false;
|
|
122
|
-
}
|
|
123
|
-
emit({
|
|
124
|
-
type: "request.completed",
|
|
125
|
-
requestId,
|
|
126
|
-
timestamp: performance.now(),
|
|
127
|
-
provider: providerConfig.name,
|
|
128
|
-
model: modelId,
|
|
129
|
-
durationMs: performance.now() - startTime,
|
|
130
|
-
attempts: attempt + 1,
|
|
131
|
-
inputTokens: totalIn,
|
|
132
|
-
outputTokens: totalOut,
|
|
133
|
-
structuredOutput: false,
|
|
134
|
-
});
|
|
135
|
-
return { ok: true, attempts: attempt + 1, inputTokens: totalIn, outputTokens: totalOut, providerName: providerConfig.name, modelId };
|
|
136
|
-
}
|
|
137
|
-
catch (err) {
|
|
138
|
-
if (reservationActive) {
|
|
139
|
-
budgetTracker.release(requestId);
|
|
140
|
-
reservationActive = false;
|
|
141
|
-
}
|
|
142
|
-
return { ok: false, err };
|
|
143
|
-
}
|
|
144
|
-
finally {
|
|
145
|
-
// Defensive: in case neither the success nor the catch branch ran
|
|
146
|
-
// (e.g. an exception thrown between them), make sure the reservation
|
|
147
|
-
// is released. Idempotent.
|
|
148
|
-
if (reservationActive) {
|
|
149
|
-
budgetTracker.release(requestId);
|
|
150
|
-
reservationActive = false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
/** Run a single non-streaming attempt through the full pipeline. */
|
|
155
|
-
export async function runCompleteAttempt(ctx, executor, attempt) {
|
|
156
|
-
const { requestId, startTime, providerConfig, modelId, signal, messages, emit, budgetTracker } = ctx;
|
|
157
|
-
const estimatedCost = budgetTracker.estimate(modelId, providerConfig.name, estimateTokens(messages.map((m) => m.content ?? "").join("")), 0);
|
|
158
|
-
const initialReservation = budgetTracker.reserve(requestId, estimatedCost);
|
|
159
|
-
if (!initialReservation) {
|
|
160
|
-
throw new ConfigurationError(`Budget reservation rejected — estimated cost $${estimatedCost.toFixed(4)} would exceed budget`, `Remaining budget: $${budgetTracker.report().remainingBudget?.toFixed(4) ?? "unknown"}. Options: (1) increase sessionBudget, (2) use a cheaper model, (3) reduce input token count`);
|
|
161
|
-
}
|
|
162
|
-
let reservationActive = true;
|
|
163
|
-
try {
|
|
164
|
-
const value = await executor({
|
|
165
|
-
signal,
|
|
166
|
-
providerName: providerConfig.name,
|
|
167
|
-
modelId,
|
|
168
|
-
messages,
|
|
169
|
-
temperature: undefined,
|
|
170
|
-
maxTokens: undefined,
|
|
171
|
-
tools: undefined,
|
|
172
|
-
extra: undefined,
|
|
173
|
-
});
|
|
174
|
-
ctx.circuitBreaker?.recordSuccess();
|
|
175
|
-
if (reservationActive) {
|
|
176
|
-
budgetTracker.settle(requestId, estimatedCost, { provider: providerConfig.name, model: modelId, phase: "execute" });
|
|
177
|
-
reservationActive = false;
|
|
178
|
-
}
|
|
179
|
-
emit({
|
|
180
|
-
type: "request.completed",
|
|
181
|
-
requestId,
|
|
182
|
-
timestamp: performance.now(),
|
|
183
|
-
provider: providerConfig.name,
|
|
184
|
-
model: modelId,
|
|
185
|
-
durationMs: performance.now() - startTime,
|
|
186
|
-
attempts: attempt + 1,
|
|
187
|
-
inputTokens: undefined,
|
|
188
|
-
outputTokens: undefined,
|
|
189
|
-
structuredOutput: false,
|
|
190
|
-
});
|
|
191
|
-
return { ok: true, attempts: attempt + 1, value, providerName: providerConfig.name, modelId };
|
|
192
|
-
}
|
|
193
|
-
catch (err) {
|
|
194
|
-
if (reservationActive) {
|
|
195
|
-
budgetTracker.release(requestId);
|
|
196
|
-
reservationActive = false;
|
|
197
|
-
}
|
|
198
|
-
return { ok: false, err };
|
|
199
|
-
}
|
|
200
|
-
finally {
|
|
201
|
-
if (reservationActive) {
|
|
202
|
-
budgetTracker.release(requestId);
|
|
203
|
-
reservationActive = false;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
/** Record a final-failure event for a request that exhausted retries and fallbacks. */
|
|
208
|
-
export function recordFailure(ctx, err, attempt) {
|
|
209
|
-
const { requestId, startTime, providerConfig, modelId, emit } = ctx;
|
|
210
|
-
ctx.circuitBreaker?.recordFailure(err instanceof Error ? err : undefined);
|
|
211
|
-
emit({
|
|
212
|
-
type: "request.failed",
|
|
213
|
-
requestId,
|
|
214
|
-
timestamp: performance.now(),
|
|
215
|
-
provider: providerConfig.name,
|
|
216
|
-
model: modelId,
|
|
217
|
-
durationMs: performance.now() - startTime,
|
|
218
|
-
attempts: attempt + 1,
|
|
219
|
-
error: err instanceof Error ? err.message : String(err),
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
//# sourceMappingURL=pipeline.js.map
|