@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.
Files changed (144) hide show
  1. package/package.json +1 -6
  2. package/packages/server/dist/cli.cjs +23 -17
  3. package/cmd/service/main.go +0 -68
  4. package/go.mod +0 -117
  5. package/go.sum +0 -299
  6. package/pkg/breaker/breaker.go +0 -157
  7. package/pkg/breaker/breaker_test.go +0 -131
  8. package/pkg/clog/LICENSE +0 -26
  9. package/pkg/clog/clog.go +0 -90
  10. package/pkg/clog/clog_test.go +0 -56
  11. package/pkg/clog/panic.go +0 -39
  12. package/pkg/config/LICENSE +0 -26
  13. package/pkg/config/config.go +0 -86
  14. package/pkg/config/config_test.go +0 -70
  15. package/pkg/config/otel.go +0 -50
  16. package/pkg/config/server.go +0 -61
  17. package/pkg/config/validate.go +0 -80
  18. package/pkg/config/validate_test.go +0 -74
  19. package/pkg/contexts/contexts_test.go +0 -34
  20. package/pkg/contexts/request_id.go +0 -1
  21. package/pkg/contexts/service_info.go +0 -33
  22. package/pkg/errfuncs/errfuncs.go +0 -9
  23. package/pkg/errfuncs/errfuncs_test.go +0 -28
  24. package/pkg/forkedcontext/forkedcontext.go +0 -57
  25. package/pkg/health/health.go +0 -123
  26. package/pkg/health/health_test.go +0 -84
  27. package/pkg/herr/LICENSE +0 -26
  28. package/pkg/herr/code.go +0 -14
  29. package/pkg/herr/herr.go +0 -112
  30. package/pkg/herr/herr_test.go +0 -78
  31. package/pkg/herr/http.go +0 -133
  32. package/pkg/herr/http_test.go +0 -103
  33. package/pkg/herr/validate.go +0 -72
  34. package/pkg/herr/validate_test.go +0 -75
  35. package/pkg/httpmiddleware/bearer.go +0 -47
  36. package/pkg/httpmiddleware/httputil_test.go +0 -167
  37. package/pkg/httpmiddleware/inflight.go +0 -23
  38. package/pkg/httpmiddleware/maxbody.go +0 -30
  39. package/pkg/httpmiddleware/recover.go +0 -38
  40. package/pkg/httpmiddleware/requestid.go +0 -40
  41. package/pkg/httpmiddleware/telemetry.go +0 -96
  42. package/pkg/httpmiddleware/version.go +0 -16
  43. package/pkg/jwtverify/verifier.go +0 -72
  44. package/pkg/jwtverify/verifier_test.go +0 -134
  45. package/pkg/ksuid/LICENSE +0 -26
  46. package/pkg/ksuid/ksuid.go +0 -157
  47. package/pkg/ksuid/ksuid_test.go +0 -107
  48. package/pkg/ksuid/resources.go +0 -13
  49. package/pkg/lifecycle/group.go +0 -175
  50. package/pkg/lifecycle/group_test.go +0 -236
  51. package/pkg/lifecycle/service.go +0 -112
  52. package/pkg/netprobe/netprobe.go +0 -89
  53. package/pkg/netprobe/netprobe_test.go +0 -55
  54. package/pkg/otelsetup/otelsetup.go +0 -226
  55. package/pkg/otelsetup/otelsetup_test.go +0 -130
  56. package/pkg/ptr/LICENSE +0 -26
  57. package/pkg/ptr/ptr.go +0 -34
  58. package/pkg/ptr/ptr_test.go +0 -66
  59. package/pkg/retry/bench_test.go +0 -67
  60. package/pkg/retry/retry.go +0 -188
  61. package/pkg/retry/retry_test.go +0 -222
  62. package/pkg/slicefuncs/LICENSE +0 -26
  63. package/pkg/slicefuncs/slicefuncs.go +0 -10
  64. package/pkg/slicefuncs/slicefuncs_test.go +0 -29
  65. package/pkg/stacktrace/LICENSE +0 -26
  66. package/pkg/stacktrace/frames.go +0 -77
  67. package/pkg/stacktrace/frames_test.go +0 -73
  68. package/services/aigateway/BENCHMARKS.md +0 -110
  69. package/services/aigateway/README.md +0 -156
  70. package/services/aigateway/adapters/authresolver/bench_test.go +0 -13
  71. package/services/aigateway/adapters/authresolver/redis.go +0 -61
  72. package/services/aigateway/adapters/authresolver/service.go +0 -442
  73. package/services/aigateway/adapters/authresolver/service_test.go +0 -435
  74. package/services/aigateway/adapters/budget/bench_test.go +0 -50
  75. package/services/aigateway/adapters/budget/budget.go +0 -59
  76. package/services/aigateway/adapters/cacherules/evaluator.go +0 -134
  77. package/services/aigateway/adapters/cacherules/evaluator_test.go +0 -207
  78. package/services/aigateway/adapters/controlplane/bench_test.go +0 -40
  79. package/services/aigateway/adapters/controlplane/client.go +0 -213
  80. package/services/aigateway/adapters/controlplane/client_test.go +0 -73
  81. package/services/aigateway/adapters/controlplane/config_wire.go +0 -310
  82. package/services/aigateway/adapters/controlplane/guardrails.go +0 -88
  83. package/services/aigateway/adapters/controlplane/signer.go +0 -95
  84. package/services/aigateway/adapters/controlplane/signer_test.go +0 -64
  85. package/services/aigateway/adapters/customertracebridge/context.go +0 -48
  86. package/services/aigateway/adapters/customertracebridge/context_test.go +0 -24
  87. package/services/aigateway/adapters/customertracebridge/emitter.go +0 -329
  88. package/services/aigateway/adapters/customertracebridge/emitter_test.go +0 -93
  89. package/services/aigateway/adapters/customertracebridge/registry.go +0 -82
  90. package/services/aigateway/adapters/customertracebridge/transport.go +0 -122
  91. package/services/aigateway/adapters/gatewaytracer/attrs.go +0 -28
  92. package/services/aigateway/adapters/gatewaytracer/attrs_genai.go +0 -24
  93. package/services/aigateway/adapters/gatewaytracer/headers.go +0 -8
  94. package/services/aigateway/adapters/gatewaytracer/tracer.go +0 -101
  95. package/services/aigateway/adapters/httpapi/bench_test.go +0 -83
  96. package/services/aigateway/adapters/httpapi/middleware.go +0 -123
  97. package/services/aigateway/adapters/httpapi/router.go +0 -635
  98. package/services/aigateway/adapters/httpapi/router_test.go +0 -633
  99. package/services/aigateway/adapters/modelresolver/resolver.go +0 -107
  100. package/services/aigateway/adapters/modelresolver/resolver_test.go +0 -140
  101. package/services/aigateway/adapters/policy/matcher.go +0 -250
  102. package/services/aigateway/adapters/policy/matcher_test.go +0 -124
  103. package/services/aigateway/adapters/providers/bifrost.go +0 -798
  104. package/services/aigateway/adapters/providers/bifrost_parser.go +0 -201
  105. package/services/aigateway/adapters/providers/bifrost_test.go +0 -181
  106. package/services/aigateway/adapters/ratelimit/limiter.go +0 -122
  107. package/services/aigateway/adapters/ratelimit/limiter_test.go +0 -81
  108. package/services/aigateway/app/app.go +0 -104
  109. package/services/aigateway/app/dispatch.go +0 -89
  110. package/services/aigateway/app/dispatch_test.go +0 -475
  111. package/services/aigateway/app/handlers.go +0 -79
  112. package/services/aigateway/app/peek_bench_test.go +0 -21
  113. package/services/aigateway/app/pipeline/bench_test.go +0 -34
  114. package/services/aigateway/app/pipeline/budget.go +0 -55
  115. package/services/aigateway/app/pipeline/cache.go +0 -34
  116. package/services/aigateway/app/pipeline/cachecontrol.go +0 -86
  117. package/services/aigateway/app/pipeline/cachecontrol_test.go +0 -110
  118. package/services/aigateway/app/pipeline/guardrail.go +0 -121
  119. package/services/aigateway/app/pipeline/pipeline.go +0 -159
  120. package/services/aigateway/app/pipeline/policy.go +0 -23
  121. package/services/aigateway/app/pipeline/ratelimit.go +0 -21
  122. package/services/aigateway/app/pipeline/rawframing_test.go +0 -67
  123. package/services/aigateway/app/pipeline/resolve.go +0 -44
  124. package/services/aigateway/app/pipeline/trace.go +0 -129
  125. package/services/aigateway/app/ports.go +0 -61
  126. package/services/aigateway/cmd/root.go +0 -42
  127. package/services/aigateway/config.go +0 -86
  128. package/services/aigateway/deps.go +0 -177
  129. package/services/aigateway/domain/bundle.go +0 -203
  130. package/services/aigateway/domain/errors.go +0 -23
  131. package/services/aigateway/domain/model.go +0 -24
  132. package/services/aigateway/domain/provider.go +0 -38
  133. package/services/aigateway/domain/request.go +0 -65
  134. package/services/aigateway/domain/response.go +0 -56
  135. package/services/aigateway/domain/verdict.go +0 -55
  136. package/services/aigateway/serve.go +0 -45
  137. package/services/aigateway/tests/matrix/README.md +0 -71
  138. package/services/aigateway/tests/matrix/anthropic_test.go +0 -61
  139. package/services/aigateway/tests/matrix/azure_test.go +0 -52
  140. package/services/aigateway/tests/matrix/bedrock_test.go +0 -69
  141. package/services/aigateway/tests/matrix/gemini_test.go +0 -117
  142. package/services/aigateway/tests/matrix/matrix_test.go +0 -601
  143. package/services/aigateway/tests/matrix/openai_test.go +0 -66
  144. 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
- }