@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,160 +0,0 @@
|
|
|
1
|
-
//go:build live_vertex
|
|
2
|
-
|
|
3
|
-
package matrix
|
|
4
|
-
|
|
5
|
-
import (
|
|
6
|
-
"bytes"
|
|
7
|
-
"encoding/json"
|
|
8
|
-
"fmt"
|
|
9
|
-
"io"
|
|
10
|
-
"net/http"
|
|
11
|
-
"os"
|
|
12
|
-
"os/exec"
|
|
13
|
-
"strings"
|
|
14
|
-
"testing"
|
|
15
|
-
"time"
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
// vertexCell builds a resolved cell for Google Vertex using TEST_VK_VERTEX +
|
|
19
|
-
// VERTEX_MODEL (defaults to gemini-2.5-flash, region us-central1).
|
|
20
|
-
//
|
|
21
|
-
// TEST_VK_VERTEX's bound ModelProvider must carry a vertex_ai credential
|
|
22
|
-
// with project_id + location + service-account JSON in customKeys.
|
|
23
|
-
// Bifrost handles the GCP auth exchange.
|
|
24
|
-
func vertexCell(t *testing.T, scenario string, body func(string) []byte, streaming bool) resolvedCell {
|
|
25
|
-
t.Helper()
|
|
26
|
-
vk := requireEnv(t, "TEST_VK_VERTEX")
|
|
27
|
-
model := os.Getenv("VERTEX_MODEL")
|
|
28
|
-
if model == "" {
|
|
29
|
-
model = "gemini-2.5-flash"
|
|
30
|
-
}
|
|
31
|
-
return resolvedCell{
|
|
32
|
-
cell: cell{provider: "vertex", scenario: scenario, body: body},
|
|
33
|
-
vk: vk,
|
|
34
|
-
model: model,
|
|
35
|
-
streaming: streaming,
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
func TestVertex_SimpleCompletion(t *testing.T) {
|
|
40
|
-
runCell(t, vertexCell(t, "simple", chatBody_Simple, false))
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
func TestVertex_StreamedCompletion(t *testing.T) {
|
|
44
|
-
runCell(t, vertexCell(t, "streamed", chatBody_Streamed, true))
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
func TestVertex_ToolCalling(t *testing.T) {
|
|
48
|
-
runCell(t, vertexCell(t, "tool_calling", chatBody_ToolCalling, false))
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
func TestVertex_StructuredOutputs(t *testing.T) {
|
|
52
|
-
runCell(t, vertexCell(t, "structured_outputs", chatBody_StructuredOutputs, false))
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// TestVertex_Cache exercises Vertex AI's explicit `cachedContents` API
|
|
56
|
-
// end-to-end through the gateway. Same flow as TestGemini_Cache (gateway
|
|
57
|
-
// parser → Bifrost ExtraParams → geminiReq.CachedContent), differs only on
|
|
58
|
-
// the setup call which uses Vertex's project-scoped cachedContents endpoint
|
|
59
|
-
// authenticated with an OAuth2 access token (not API key).
|
|
60
|
-
//
|
|
61
|
-
// Requires:
|
|
62
|
-
// - VERTEX_PROJECT GCP project id (e.g. "langwatch")
|
|
63
|
-
// - VERTEX_LOCATION region (e.g. "us-central1")
|
|
64
|
-
// - VERTEX_ACCESS_TOKEN OAuth2 token, OR
|
|
65
|
-
// - GOOGLE_APPLICATION_CREDENTIALS path to a service-account JSON; the
|
|
66
|
-
// test will exec `gcloud auth print-access-token --account=…` to mint
|
|
67
|
-
// a fresh token (matches the local-dev auth flow).
|
|
68
|
-
//
|
|
69
|
-
// Skip if neither auth path is available — the rest of the matrix still
|
|
70
|
-
// runs without GCP creds.
|
|
71
|
-
func TestVertex_Cache(t *testing.T) {
|
|
72
|
-
project := requireEnv(t, "VERTEX_PROJECT")
|
|
73
|
-
location := os.Getenv("VERTEX_LOCATION")
|
|
74
|
-
if location == "" {
|
|
75
|
-
location = "us-central1"
|
|
76
|
-
}
|
|
77
|
-
token := vertexAccessToken(t)
|
|
78
|
-
|
|
79
|
-
cell := vertexCell(t, "cache", nil, false)
|
|
80
|
-
runCachedContentCacheCell(t, cell, func(t *testing.T) string {
|
|
81
|
-
t.Helper()
|
|
82
|
-
return createVertexCachedContent(t, token, project, location, cell.model, cacheablePrefix, "120s")
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// vertexAccessToken resolves a GCP OAuth2 access token suitable for calling
|
|
87
|
-
// the Vertex AI REST API. Order of preference:
|
|
88
|
-
// - VERTEX_ACCESS_TOKEN env var (CI / preset)
|
|
89
|
-
// - exec `gcloud auth print-access-token` against the configured account
|
|
90
|
-
// (local dev — matches the GOOGLE_APPLICATION_CREDENTIALS flow Bifrost
|
|
91
|
-
// itself uses for the chat call).
|
|
92
|
-
//
|
|
93
|
-
// Skips the test if neither path produces a token.
|
|
94
|
-
func vertexAccessToken(t *testing.T) string {
|
|
95
|
-
t.Helper()
|
|
96
|
-
if v := strings.TrimSpace(os.Getenv("VERTEX_ACCESS_TOKEN")); v != "" {
|
|
97
|
-
return v
|
|
98
|
-
}
|
|
99
|
-
args := []string{"auth", "print-access-token"}
|
|
100
|
-
if account := os.Getenv("VERTEX_GCLOUD_ACCOUNT"); account != "" {
|
|
101
|
-
args = append(args, "--account="+account)
|
|
102
|
-
}
|
|
103
|
-
cmd := exec.Command("gcloud", args...)
|
|
104
|
-
out, err := cmd.Output()
|
|
105
|
-
if err != nil {
|
|
106
|
-
t.Skipf("vertex access token unavailable: gcloud auth print-access-token failed: %v (set VERTEX_ACCESS_TOKEN to skip gcloud)", err)
|
|
107
|
-
}
|
|
108
|
-
tok := strings.TrimSpace(string(out))
|
|
109
|
-
if tok == "" {
|
|
110
|
-
t.Skip("vertex access token unavailable: gcloud returned empty token")
|
|
111
|
-
}
|
|
112
|
-
return tok
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// createVertexCachedContent POSTs to the Vertex AI cachedContents endpoint.
|
|
116
|
-
// Returns the full project-scoped resource name, e.g.
|
|
117
|
-
// "projects/<project_number>/locations/<region>/cachedContents/<id>".
|
|
118
|
-
// Direct-API call rather than gateway-routed for the same reason as the
|
|
119
|
-
// Gemini setup — the cell's purpose is to verify the gateway's GENERATE
|
|
120
|
-
// path, not the create path.
|
|
121
|
-
func createVertexCachedContent(t *testing.T, token, project, location, model, prefix, ttl string) string {
|
|
122
|
-
t.Helper()
|
|
123
|
-
endpoint := fmt.Sprintf(
|
|
124
|
-
"https://%s-aiplatform.googleapis.com/v1/projects/%s/locations/%s/cachedContents",
|
|
125
|
-
location, project, location,
|
|
126
|
-
)
|
|
127
|
-
body, err := json.Marshal(map[string]any{
|
|
128
|
-
"model": fmt.Sprintf("projects/%s/locations/%s/publishers/google/models/%s", project, location, model),
|
|
129
|
-
"contents": []map[string]any{
|
|
130
|
-
{"role": "user", "parts": []map[string]any{{"text": prefix}}},
|
|
131
|
-
},
|
|
132
|
-
"ttl": ttl,
|
|
133
|
-
})
|
|
134
|
-
if err != nil {
|
|
135
|
-
t.Fatalf("marshal create-cached body: %v", err)
|
|
136
|
-
}
|
|
137
|
-
req, err := http.NewRequest("POST", endpoint, bytes.NewReader(body))
|
|
138
|
-
if err != nil {
|
|
139
|
-
t.Fatalf("build create-cached request: %v", err)
|
|
140
|
-
}
|
|
141
|
-
req.Header.Set("Content-Type", "application/json")
|
|
142
|
-
req.Header.Set("Authorization", "Bearer "+token)
|
|
143
|
-
client := &http.Client{Timeout: 60 * time.Second}
|
|
144
|
-
resp, err := client.Do(req)
|
|
145
|
-
if err != nil {
|
|
146
|
-
t.Fatalf("create-cached POST: %v", err)
|
|
147
|
-
}
|
|
148
|
-
defer resp.Body.Close()
|
|
149
|
-
raw, _ := io.ReadAll(resp.Body)
|
|
150
|
-
if resp.StatusCode != 200 {
|
|
151
|
-
t.Fatalf("create cachedContents: HTTP %d\n%s", resp.StatusCode, raw)
|
|
152
|
-
}
|
|
153
|
-
var parsed struct {
|
|
154
|
-
Name string `json:"name"`
|
|
155
|
-
}
|
|
156
|
-
if err := json.Unmarshal(raw, &parsed); err != nil || parsed.Name == "" {
|
|
157
|
-
t.Fatalf("create cachedContents: parse response: %v\n%s", err, raw)
|
|
158
|
-
}
|
|
159
|
-
return parsed.Name
|
|
160
|
-
}
|