@langwatch/server 3.1.0-beta.7 → 3.1.0-beta.9
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/package.json +1 -6
- package/packages/server/dist/cli.cjs +23 -17
- package/cmd/service/main.go +0 -68
- package/go.mod +0 -117
- package/go.sum +0 -299
- package/pkg/breaker/breaker.go +0 -157
- package/pkg/breaker/breaker_test.go +0 -131
- package/pkg/clog/LICENSE +0 -26
- package/pkg/clog/clog.go +0 -90
- package/pkg/clog/clog_test.go +0 -56
- package/pkg/clog/panic.go +0 -39
- package/pkg/config/LICENSE +0 -26
- package/pkg/config/config.go +0 -86
- package/pkg/config/config_test.go +0 -70
- package/pkg/config/otel.go +0 -50
- package/pkg/config/server.go +0 -61
- package/pkg/config/validate.go +0 -80
- package/pkg/config/validate_test.go +0 -74
- package/pkg/contexts/contexts_test.go +0 -34
- package/pkg/contexts/request_id.go +0 -1
- package/pkg/contexts/service_info.go +0 -33
- package/pkg/errfuncs/errfuncs.go +0 -9
- package/pkg/errfuncs/errfuncs_test.go +0 -28
- package/pkg/forkedcontext/forkedcontext.go +0 -57
- package/pkg/health/health.go +0 -123
- package/pkg/health/health_test.go +0 -84
- package/pkg/herr/LICENSE +0 -26
- package/pkg/herr/code.go +0 -14
- package/pkg/herr/herr.go +0 -112
- package/pkg/herr/herr_test.go +0 -78
- package/pkg/herr/http.go +0 -133
- package/pkg/herr/http_test.go +0 -103
- package/pkg/herr/validate.go +0 -72
- package/pkg/herr/validate_test.go +0 -75
- package/pkg/httpmiddleware/bearer.go +0 -47
- package/pkg/httpmiddleware/httputil_test.go +0 -167
- package/pkg/httpmiddleware/inflight.go +0 -23
- package/pkg/httpmiddleware/maxbody.go +0 -30
- package/pkg/httpmiddleware/recover.go +0 -38
- package/pkg/httpmiddleware/requestid.go +0 -40
- package/pkg/httpmiddleware/telemetry.go +0 -96
- package/pkg/httpmiddleware/version.go +0 -16
- package/pkg/jwtverify/verifier.go +0 -72
- package/pkg/jwtverify/verifier_test.go +0 -134
- package/pkg/ksuid/LICENSE +0 -26
- package/pkg/ksuid/ksuid.go +0 -157
- package/pkg/ksuid/ksuid_test.go +0 -107
- package/pkg/ksuid/resources.go +0 -13
- package/pkg/lifecycle/group.go +0 -175
- package/pkg/lifecycle/group_test.go +0 -236
- package/pkg/lifecycle/service.go +0 -112
- package/pkg/netprobe/netprobe.go +0 -89
- package/pkg/netprobe/netprobe_test.go +0 -55
- package/pkg/otelsetup/otelsetup.go +0 -226
- package/pkg/otelsetup/otelsetup_test.go +0 -130
- package/pkg/ptr/LICENSE +0 -26
- package/pkg/ptr/ptr.go +0 -34
- package/pkg/ptr/ptr_test.go +0 -66
- package/pkg/retry/bench_test.go +0 -67
- package/pkg/retry/retry.go +0 -188
- package/pkg/retry/retry_test.go +0 -222
- package/pkg/slicefuncs/LICENSE +0 -26
- package/pkg/slicefuncs/slicefuncs.go +0 -10
- package/pkg/slicefuncs/slicefuncs_test.go +0 -29
- package/pkg/stacktrace/LICENSE +0 -26
- package/pkg/stacktrace/frames.go +0 -77
- package/pkg/stacktrace/frames_test.go +0 -73
- package/services/aigateway/BENCHMARKS.md +0 -110
- package/services/aigateway/README.md +0 -156
- package/services/aigateway/adapters/authresolver/bench_test.go +0 -13
- package/services/aigateway/adapters/authresolver/redis.go +0 -61
- package/services/aigateway/adapters/authresolver/service.go +0 -442
- package/services/aigateway/adapters/authresolver/service_test.go +0 -435
- package/services/aigateway/adapters/budget/bench_test.go +0 -50
- package/services/aigateway/adapters/budget/budget.go +0 -59
- package/services/aigateway/adapters/cacherules/evaluator.go +0 -134
- package/services/aigateway/adapters/cacherules/evaluator_test.go +0 -207
- package/services/aigateway/adapters/controlplane/bench_test.go +0 -40
- package/services/aigateway/adapters/controlplane/client.go +0 -213
- package/services/aigateway/adapters/controlplane/client_test.go +0 -73
- package/services/aigateway/adapters/controlplane/config_wire.go +0 -310
- package/services/aigateway/adapters/controlplane/guardrails.go +0 -88
- package/services/aigateway/adapters/controlplane/signer.go +0 -95
- package/services/aigateway/adapters/controlplane/signer_test.go +0 -64
- package/services/aigateway/adapters/customertracebridge/context.go +0 -48
- package/services/aigateway/adapters/customertracebridge/context_test.go +0 -24
- package/services/aigateway/adapters/customertracebridge/emitter.go +0 -329
- package/services/aigateway/adapters/customertracebridge/emitter_test.go +0 -93
- package/services/aigateway/adapters/customertracebridge/registry.go +0 -82
- package/services/aigateway/adapters/customertracebridge/transport.go +0 -122
- package/services/aigateway/adapters/gatewaytracer/attrs.go +0 -28
- package/services/aigateway/adapters/gatewaytracer/attrs_genai.go +0 -24
- package/services/aigateway/adapters/gatewaytracer/headers.go +0 -8
- package/services/aigateway/adapters/gatewaytracer/tracer.go +0 -101
- package/services/aigateway/adapters/httpapi/bench_test.go +0 -83
- package/services/aigateway/adapters/httpapi/middleware.go +0 -123
- package/services/aigateway/adapters/httpapi/router.go +0 -635
- package/services/aigateway/adapters/httpapi/router_test.go +0 -633
- package/services/aigateway/adapters/modelresolver/resolver.go +0 -107
- package/services/aigateway/adapters/modelresolver/resolver_test.go +0 -140
- package/services/aigateway/adapters/policy/matcher.go +0 -250
- package/services/aigateway/adapters/policy/matcher_test.go +0 -124
- package/services/aigateway/adapters/providers/bifrost.go +0 -798
- package/services/aigateway/adapters/providers/bifrost_parser.go +0 -201
- package/services/aigateway/adapters/providers/bifrost_test.go +0 -181
- package/services/aigateway/adapters/ratelimit/limiter.go +0 -122
- package/services/aigateway/adapters/ratelimit/limiter_test.go +0 -81
- package/services/aigateway/app/app.go +0 -104
- package/services/aigateway/app/dispatch.go +0 -89
- package/services/aigateway/app/dispatch_test.go +0 -475
- package/services/aigateway/app/handlers.go +0 -79
- package/services/aigateway/app/peek_bench_test.go +0 -21
- package/services/aigateway/app/pipeline/bench_test.go +0 -34
- package/services/aigateway/app/pipeline/budget.go +0 -55
- package/services/aigateway/app/pipeline/cache.go +0 -34
- package/services/aigateway/app/pipeline/cachecontrol.go +0 -86
- package/services/aigateway/app/pipeline/cachecontrol_test.go +0 -110
- package/services/aigateway/app/pipeline/guardrail.go +0 -121
- package/services/aigateway/app/pipeline/pipeline.go +0 -159
- package/services/aigateway/app/pipeline/policy.go +0 -23
- package/services/aigateway/app/pipeline/ratelimit.go +0 -21
- package/services/aigateway/app/pipeline/rawframing_test.go +0 -67
- package/services/aigateway/app/pipeline/resolve.go +0 -44
- package/services/aigateway/app/pipeline/trace.go +0 -129
- package/services/aigateway/app/ports.go +0 -61
- package/services/aigateway/cmd/root.go +0 -42
- package/services/aigateway/config.go +0 -86
- package/services/aigateway/deps.go +0 -177
- package/services/aigateway/domain/bundle.go +0 -203
- package/services/aigateway/domain/errors.go +0 -23
- package/services/aigateway/domain/model.go +0 -24
- package/services/aigateway/domain/provider.go +0 -38
- package/services/aigateway/domain/request.go +0 -65
- package/services/aigateway/domain/response.go +0 -56
- package/services/aigateway/domain/verdict.go +0 -55
- package/services/aigateway/serve.go +0 -45
- package/services/aigateway/tests/matrix/README.md +0 -71
- package/services/aigateway/tests/matrix/anthropic_test.go +0 -61
- package/services/aigateway/tests/matrix/azure_test.go +0 -52
- package/services/aigateway/tests/matrix/bedrock_test.go +0 -69
- package/services/aigateway/tests/matrix/gemini_test.go +0 -117
- package/services/aigateway/tests/matrix/matrix_test.go +0 -601
- package/services/aigateway/tests/matrix/openai_test.go +0 -66
- package/services/aigateway/tests/matrix/vertex_test.go +0 -160
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
//go:build live_azure
|
|
2
|
-
|
|
3
|
-
package matrix
|
|
4
|
-
|
|
5
|
-
import (
|
|
6
|
-
"os"
|
|
7
|
-
"testing"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// azureCell builds a resolved cell for Azure OpenAI using TEST_VK_AZURE +
|
|
11
|
-
// AZURE_MODEL (defaults to gpt-5-mini).
|
|
12
|
-
//
|
|
13
|
-
// TEST_VK_AZURE's bound ModelProvider must carry:
|
|
14
|
-
// - azure_openai credential with api_key + endpoint (e.g.
|
|
15
|
-
// https://langwatchopenaisweden.openai.azure.com/)
|
|
16
|
-
// - a deployment_map entry mapping "gpt-5-mini" → the Azure deployment name
|
|
17
|
-
// (Azure routes on deployment, not on the bare model id; the gateway's
|
|
18
|
-
// bifrost adapter substitutes via pc.DeploymentMap).
|
|
19
|
-
func azureCell(t *testing.T, scenario string, body func(string) []byte, streaming bool) resolvedCell {
|
|
20
|
-
t.Helper()
|
|
21
|
-
vk := requireEnv(t, "TEST_VK_AZURE")
|
|
22
|
-
model := os.Getenv("AZURE_MODEL")
|
|
23
|
-
if model == "" {
|
|
24
|
-
model = "gpt-5-mini"
|
|
25
|
-
}
|
|
26
|
-
return resolvedCell{
|
|
27
|
-
cell: cell{provider: "azure", scenario: scenario, body: body},
|
|
28
|
-
vk: vk,
|
|
29
|
-
model: model,
|
|
30
|
-
streaming: streaming,
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
func TestAzure_SimpleCompletion(t *testing.T) {
|
|
35
|
-
runCell(t, azureCell(t, "simple", chatBody_Simple, false))
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
func TestAzure_StreamedCompletion(t *testing.T) {
|
|
39
|
-
runCell(t, azureCell(t, "streamed", chatBody_Streamed, true))
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
func TestAzure_ToolCalling(t *testing.T) {
|
|
43
|
-
runCell(t, azureCell(t, "tool_calling", chatBody_ToolCalling, false))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
func TestAzure_StructuredOutputs(t *testing.T) {
|
|
47
|
-
runCell(t, azureCell(t, "structured_outputs", chatBody_StructuredOutputs, false))
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
func TestAzure_Cache(t *testing.T) {
|
|
51
|
-
runCacheCell(t, azureCell(t, "cache", chatBody_Cache_Prime, false))
|
|
52
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
//go:build live_bedrock
|
|
2
|
-
|
|
3
|
-
package matrix
|
|
4
|
-
|
|
5
|
-
import (
|
|
6
|
-
"os"
|
|
7
|
-
"testing"
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
// bedrockCell builds a resolved cell for AWS Bedrock using TEST_VK_BEDROCK
|
|
11
|
-
// + BEDROCK_MODEL (defaults to the EU cross-region inference profile for
|
|
12
|
-
// claude-haiku-4-5; the un-prefixed `anthropic.claude-3-5-haiku-20241022-v1:0`
|
|
13
|
-
// returns "The provided model identifier is invalid" on the
|
|
14
|
-
// langwatch-dev-bedrock-user IAM policy + eu-central-1 region binding,
|
|
15
|
-
// per the matrix-bedrock VK's customKeys).
|
|
16
|
-
//
|
|
17
|
-
// The gateway's bifrost adapter routes Bedrock requests through the AWS SDK
|
|
18
|
-
// using credentials bound to the VK via the ModelProvider, not env-based
|
|
19
|
-
// boto/SDK credentials — the TEST_VK_BEDROCK VK must have a Bedrock
|
|
20
|
-
// credential bound with AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY /
|
|
21
|
-
// AWS_DEFAULT_REGION in its encrypted customKeys blob.
|
|
22
|
-
func bedrockCell(t *testing.T, scenario string, body func(string) []byte, streaming bool) resolvedCell {
|
|
23
|
-
t.Helper()
|
|
24
|
-
vk := requireEnv(t, "TEST_VK_BEDROCK")
|
|
25
|
-
model := os.Getenv("BEDROCK_MODEL")
|
|
26
|
-
if model == "" {
|
|
27
|
-
model = "eu.anthropic.claude-haiku-4-5-20251001-v1:0"
|
|
28
|
-
}
|
|
29
|
-
return resolvedCell{
|
|
30
|
-
cell: cell{provider: "bedrock", scenario: scenario, body: body},
|
|
31
|
-
vk: vk,
|
|
32
|
-
model: model,
|
|
33
|
-
streaming: streaming,
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
func TestBedrock_SimpleCompletion(t *testing.T) {
|
|
38
|
-
runCell(t, bedrockCell(t, "simple", chatBody_Simple, false))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
func TestBedrock_StreamedCompletion(t *testing.T) {
|
|
42
|
-
runCell(t, bedrockCell(t, "streamed", chatBody_Streamed, true))
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
func TestBedrock_ToolCalling(t *testing.T) {
|
|
46
|
-
runCell(t, bedrockCell(t, "tool_calling", chatBody_ToolCalling, false))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
func TestBedrock_StructuredOutputs(t *testing.T) {
|
|
50
|
-
runCell(t, bedrockCell(t, "structured_outputs", chatBody_StructuredOutputs, false))
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
func TestBedrock_Cache(t *testing.T) {
|
|
54
|
-
// Bedrock cache goes through /v1/chat/completions, NOT /v1/messages —
|
|
55
|
-
// Bifrost's bedrock adapter uses AWS's Converse API and rejects
|
|
56
|
-
// Anthropic-native /v1/messages bodies with 'Unexpected field type'.
|
|
57
|
-
// chatBody_Cache_* detects bedrock's `anthropic.claude-…` model id and
|
|
58
|
-
// emits the system block as a content-block array carrying
|
|
59
|
-
// cache_control: ephemeral, which Bifrost translates to Bedrock's
|
|
60
|
-
// cachePoint marker on Converse. Default is sonnet 4.5 (cache GA);
|
|
61
|
-
// override via BEDROCK_CACHE_MODEL once Haiku 4.5 cache opens.
|
|
62
|
-
cell := bedrockCell(t, "cache", chatBody_Cache_Prime, false)
|
|
63
|
-
if override := os.Getenv("BEDROCK_CACHE_MODEL"); override != "" {
|
|
64
|
-
cell.model = override
|
|
65
|
-
} else {
|
|
66
|
-
cell.model = "eu.anthropic.claude-sonnet-4-5-20250929-v1:0"
|
|
67
|
-
}
|
|
68
|
-
runCacheCell(t, cell)
|
|
69
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
//go:build live_gemini
|
|
2
|
-
|
|
3
|
-
package matrix
|
|
4
|
-
|
|
5
|
-
import (
|
|
6
|
-
"bytes"
|
|
7
|
-
"encoding/json"
|
|
8
|
-
"fmt"
|
|
9
|
-
"io"
|
|
10
|
-
"net/http"
|
|
11
|
-
"os"
|
|
12
|
-
"testing"
|
|
13
|
-
"time"
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
// geminiCell builds a resolved cell for the gemini (Google AI Studio) provider
|
|
17
|
-
// using TEST_VK_GEMINI + GEMINI_MODEL (defaults to gemini-2.5-flash).
|
|
18
|
-
func geminiCell(t *testing.T, scenario string, body func(string) []byte, streaming bool) resolvedCell {
|
|
19
|
-
t.Helper()
|
|
20
|
-
vk := requireEnv(t, "TEST_VK_GEMINI")
|
|
21
|
-
model := os.Getenv("GEMINI_MODEL")
|
|
22
|
-
if model == "" {
|
|
23
|
-
model = "gemini-2.5-flash"
|
|
24
|
-
}
|
|
25
|
-
return resolvedCell{
|
|
26
|
-
cell: cell{provider: "gemini", scenario: scenario, body: body},
|
|
27
|
-
vk: vk,
|
|
28
|
-
model: model,
|
|
29
|
-
streaming: streaming,
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
func TestGemini_SimpleCompletion(t *testing.T) {
|
|
34
|
-
runCell(t, geminiCell(t, "simple", chatBody_Simple, false))
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
func TestGemini_StreamedCompletion(t *testing.T) {
|
|
38
|
-
runCell(t, geminiCell(t, "streamed", chatBody_Streamed, true))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
func TestGemini_ToolCalling(t *testing.T) {
|
|
42
|
-
runCell(t, geminiCell(t, "tool_calling", chatBody_ToolCalling, false))
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
func TestGemini_StructuredOutputs(t *testing.T) {
|
|
46
|
-
runCell(t, geminiCell(t, "structured_outputs", chatBody_StructuredOutputs, false))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// TestGemini_Cache exercises Gemini's explicit `cachedContents` API end-to-end
|
|
50
|
-
// through the gateway. The implicit prefix-cache path returns cached_tokens=0
|
|
51
|
-
// on this account tier (no paid-tier billing for implicit caching), so the
|
|
52
|
-
// matrix proves the explicit path: one direct-API setup call to mint a cached
|
|
53
|
-
// content resource (bypass-the-gateway, holds the long shared prefix), then
|
|
54
|
-
// one chat-completions request through the gateway carrying the
|
|
55
|
-
// `cached_content: <name>` extension key. The gateway parser lifts the key
|
|
56
|
-
// onto Bifrost's ChatParameters.ExtraParams; Bifrost's gemini chat translator
|
|
57
|
-
// reads it off ExtraParams and sets geminiReq.CachedContent on the outbound
|
|
58
|
-
// generateContent call. Response carries cached_read_tokens > 0.
|
|
59
|
-
//
|
|
60
|
-
// Requires GEMINI_API_KEY for the setup call (Generative Language API uses
|
|
61
|
-
// API-key auth, not OAuth). The matrix-gemini VK still uses the gateway's
|
|
62
|
-
// usual credential lookup for the read.
|
|
63
|
-
func TestGemini_Cache(t *testing.T) {
|
|
64
|
-
apiKey := requireEnv(t, "GEMINI_API_KEY")
|
|
65
|
-
cell := geminiCell(t, "cache", nil, false)
|
|
66
|
-
runCachedContentCacheCell(t, cell, func(t *testing.T) string {
|
|
67
|
-
t.Helper()
|
|
68
|
-
return createGeminiCachedContent(t, apiKey, cell.model, cacheablePrefix, "120s")
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// createGeminiCachedContent POSTs to the Gemini Generative Language
|
|
73
|
-
// /v1beta/cachedContents endpoint to mint a cached content resource holding
|
|
74
|
-
// `prefix`. Returns the full resource name (e.g.
|
|
75
|
-
// "cachedContents/abc123") which is the canonical form gemini expects on
|
|
76
|
-
// the `cachedContent` field of subsequent generateContent calls.
|
|
77
|
-
//
|
|
78
|
-
// Direct-API call rather than gateway-routed because the gateway doesn't
|
|
79
|
-
// proxy native gemini setup endpoints — and the cell's purpose is to verify
|
|
80
|
-
// the GENERATE call's cache-read path through the gateway, not the create
|
|
81
|
-
// call. Bypass keeps the test focused.
|
|
82
|
-
func createGeminiCachedContent(t *testing.T, apiKey, model, prefix, ttl string) string {
|
|
83
|
-
t.Helper()
|
|
84
|
-
endpoint := fmt.Sprintf("https://generativelanguage.googleapis.com/v1beta/cachedContents?key=%s", apiKey)
|
|
85
|
-
body, err := json.Marshal(map[string]any{
|
|
86
|
-
"model": "models/" + model,
|
|
87
|
-
"contents": []map[string]any{
|
|
88
|
-
{"role": "user", "parts": []map[string]any{{"text": prefix}}},
|
|
89
|
-
},
|
|
90
|
-
"ttl": ttl,
|
|
91
|
-
})
|
|
92
|
-
if err != nil {
|
|
93
|
-
t.Fatalf("marshal create-cached body: %v", err)
|
|
94
|
-
}
|
|
95
|
-
req, err := http.NewRequest("POST", endpoint, bytes.NewReader(body))
|
|
96
|
-
if err != nil {
|
|
97
|
-
t.Fatalf("build create-cached request: %v", err)
|
|
98
|
-
}
|
|
99
|
-
req.Header.Set("Content-Type", "application/json")
|
|
100
|
-
client := &http.Client{Timeout: 60 * time.Second}
|
|
101
|
-
resp, err := client.Do(req)
|
|
102
|
-
if err != nil {
|
|
103
|
-
t.Fatalf("create-cached POST: %v", err)
|
|
104
|
-
}
|
|
105
|
-
defer resp.Body.Close()
|
|
106
|
-
raw, _ := io.ReadAll(resp.Body)
|
|
107
|
-
if resp.StatusCode != 200 {
|
|
108
|
-
t.Fatalf("create cachedContents: HTTP %d\n%s", resp.StatusCode, raw)
|
|
109
|
-
}
|
|
110
|
-
var parsed struct {
|
|
111
|
-
Name string `json:"name"`
|
|
112
|
-
}
|
|
113
|
-
if err := json.Unmarshal(raw, &parsed); err != nil || parsed.Name == "" {
|
|
114
|
-
t.Fatalf("create cachedContents: parse response: %v\n%s", err, raw)
|
|
115
|
-
}
|
|
116
|
-
return parsed.Name
|
|
117
|
-
}
|