@agentgazer/proxy 0.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/LICENSE +191 -0
- package/README.md +115 -0
- package/dist/__tests__/event-buffer.test.d.ts +2 -0
- package/dist/__tests__/event-buffer.test.d.ts.map +1 -0
- package/dist/__tests__/event-buffer.test.js +290 -0
- package/dist/__tests__/event-buffer.test.js.map +1 -0
- package/dist/__tests__/proxy-server.test.d.ts +2 -0
- package/dist/__tests__/proxy-server.test.d.ts.map +1 -0
- package/dist/__tests__/proxy-server.test.js +1175 -0
- package/dist/__tests__/proxy-server.test.js.map +1 -0
- package/dist/__tests__/rate-limiter.test.d.ts +2 -0
- package/dist/__tests__/rate-limiter.test.d.ts.map +1 -0
- package/dist/__tests__/rate-limiter.test.js +131 -0
- package/dist/__tests__/rate-limiter.test.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +121 -0
- package/dist/cli.js.map +1 -0
- package/dist/event-buffer.d.ts +23 -0
- package/dist/event-buffer.d.ts.map +1 -0
- package/dist/event-buffer.js +87 -0
- package/dist/event-buffer.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/proxy-server.d.ts +22 -0
- package/dist/proxy-server.d.ts.map +1 -0
- package/dist/proxy-server.js +898 -0
- package/dist/proxy-server.js.map +1 -0
- package/dist/rate-limiter.d.ts +34 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/rate-limiter.js +72 -0
- package/dist/rate-limiter.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2025 AgentTrace Contributors
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# @agentgazer/proxy
|
|
2
|
+
|
|
3
|
+
Transparent HTTP proxy for LLM API calls. Forwards requests to upstream providers, extracts usage metrics from responses (including SSE streams), and buffers them for delivery to an AgentGazer server.
|
|
4
|
+
|
|
5
|
+
## Supported providers
|
|
6
|
+
|
|
7
|
+
- OpenAI (`api.openai.com`)
|
|
8
|
+
- Anthropic (`api.anthropic.com`)
|
|
9
|
+
- Google (`generativelanguage.googleapis.com`)
|
|
10
|
+
- Mistral (`api.mistral.ai`)
|
|
11
|
+
- Cohere (`api.cohere.com`)
|
|
12
|
+
- DeepSeek (`api.deepseek.com`)
|
|
13
|
+
- Moonshot (`api.moonshot.cn`)
|
|
14
|
+
- Zhipu / GLM (`open.bigmodel.cn`)
|
|
15
|
+
- MiniMax (`api.minimax.chat`)
|
|
16
|
+
- Baichuan (`api.baichuan-ai.com`)
|
|
17
|
+
- Yi / 01.AI (`api.lingyiwanwu.com`)
|
|
18
|
+
|
|
19
|
+
## How it works
|
|
20
|
+
|
|
21
|
+
1. Your LLM client sends requests to the proxy instead of the provider directly
|
|
22
|
+
2. The proxy detects the provider from the Host header or request path
|
|
23
|
+
3. If configured, a provider API key is injected into the request headers
|
|
24
|
+
4. If configured, a per-provider rate limit is enforced (429 on excess)
|
|
25
|
+
5. The request is forwarded to the real upstream API
|
|
26
|
+
6. The response is streamed back to your client in real-time
|
|
27
|
+
7. Token counts, model, latency, and cost are extracted and buffered
|
|
28
|
+
8. Buffered events are flushed to the AgentGazer server periodically
|
|
29
|
+
|
|
30
|
+
Both standard JSON responses and SSE streaming responses are supported.
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### As part of the CLI (typical)
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx agentgazer start
|
|
38
|
+
# Proxy starts on port 4000
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Standalone CLI
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
agentgazer-proxy --api-key <token> --agent-id proxy \
|
|
45
|
+
--provider-keys '{"openai":"sk-..."}' \
|
|
46
|
+
--rate-limits '{"openai":{"maxRequests":100,"windowSeconds":60}}'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Programmatic
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { startProxy } from "@agentgazer/proxy";
|
|
53
|
+
|
|
54
|
+
const { server, shutdown } = startProxy({
|
|
55
|
+
port: 4000,
|
|
56
|
+
apiKey: "your-token",
|
|
57
|
+
agentId: "proxy",
|
|
58
|
+
endpoint: "http://localhost:8080/api/events",
|
|
59
|
+
providerKeys: {
|
|
60
|
+
openai: "sk-...",
|
|
61
|
+
anthropic: "sk-ant-...",
|
|
62
|
+
},
|
|
63
|
+
rateLimits: {
|
|
64
|
+
openai: { maxRequests: 100, windowSeconds: 60 },
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Later
|
|
69
|
+
await shutdown();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Provider detection
|
|
73
|
+
|
|
74
|
+
The proxy auto-detects the target provider from the `Host` header. Set your LLM client's base URL to `http://localhost:4000` and the proxy handles routing.
|
|
75
|
+
|
|
76
|
+
If auto-detection fails, set the `x-target-url` header to specify the upstream base URL explicitly.
|
|
77
|
+
|
|
78
|
+
### API key injection
|
|
79
|
+
|
|
80
|
+
When `providerKeys` is configured, the proxy injects the correct auth header per provider:
|
|
81
|
+
|
|
82
|
+
| Provider | Header |
|
|
83
|
+
|----------|--------|
|
|
84
|
+
| OpenAI, Mistral, Cohere, DeepSeek, Moonshot, Zhipu, MiniMax, Baichuan, Yi | `Authorization: Bearer <key>` |
|
|
85
|
+
| Anthropic | `x-api-key: <key>` |
|
|
86
|
+
| Google | `x-goog-api-key: <key>` |
|
|
87
|
+
|
|
88
|
+
If the client already provides the auth header, the proxy does not override it.
|
|
89
|
+
|
|
90
|
+
### Rate limiting
|
|
91
|
+
|
|
92
|
+
When `rateLimits` is configured, the proxy enforces a sliding-window rate limit per provider. Requests exceeding the limit receive a `429` response with a `Retry-After` header.
|
|
93
|
+
|
|
94
|
+
### Health check
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
GET http://localhost:4000/health
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Options
|
|
101
|
+
|
|
102
|
+
| Option | Type | Default | Description |
|
|
103
|
+
|--------|------|---------|-------------|
|
|
104
|
+
| `port` | `number` | `4000` | Proxy listen port |
|
|
105
|
+
| `apiKey` | `string` | **required** | Auth token for the AgentGazer server |
|
|
106
|
+
| `agentId` | `string` | **required** | Agent ID for recorded events |
|
|
107
|
+
| `endpoint` | `string` | — | Event ingestion URL |
|
|
108
|
+
| `flushInterval` | `number` | `5000` | Event buffer flush interval in ms |
|
|
109
|
+
| `maxBufferSize` | `number` | `50` | Max buffered events before auto-flush |
|
|
110
|
+
| `providerKeys` | `Record<string, string>` | — | Provider API keys to inject |
|
|
111
|
+
| `rateLimits` | `Record<string, RateLimitConfig>` | — | Per-provider rate limits |
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
Apache-2.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-buffer.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/event-buffer.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const vitest_1 = require("vitest");
|
|
37
|
+
const http = __importStar(require("node:http"));
|
|
38
|
+
const event_buffer_js_1 = require("../event-buffer.js");
|
|
39
|
+
function makeEvent(overrides = {}) {
|
|
40
|
+
return {
|
|
41
|
+
agent_id: "test-agent",
|
|
42
|
+
event_type: "llm_call",
|
|
43
|
+
provider: "openai",
|
|
44
|
+
model: "gpt-4o",
|
|
45
|
+
tokens_in: 100,
|
|
46
|
+
tokens_out: 50,
|
|
47
|
+
tokens_total: 150,
|
|
48
|
+
cost_usd: 0.00075,
|
|
49
|
+
latency_ms: 200,
|
|
50
|
+
status_code: 200,
|
|
51
|
+
source: "proxy",
|
|
52
|
+
timestamp: new Date().toISOString(),
|
|
53
|
+
tags: {},
|
|
54
|
+
...overrides,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a local HTTP server that captures incoming request bodies.
|
|
59
|
+
* Returns the server, its URL, and an array of received batches.
|
|
60
|
+
*/
|
|
61
|
+
function createMockIngestServer() {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
const receivedBatches = [];
|
|
64
|
+
const statusToReturn = { code: 200 };
|
|
65
|
+
const server = http.createServer((req, res) => {
|
|
66
|
+
const chunks = [];
|
|
67
|
+
req.on("data", (chunk) => chunks.push(chunk));
|
|
68
|
+
req.on("end", () => {
|
|
69
|
+
const body = Buffer.concat(chunks).toString("utf-8");
|
|
70
|
+
try {
|
|
71
|
+
const parsed = JSON.parse(body);
|
|
72
|
+
receivedBatches.push(parsed);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// ignore parse errors in tests
|
|
76
|
+
}
|
|
77
|
+
res.writeHead(statusToReturn.code, {
|
|
78
|
+
"Content-Type": "application/json",
|
|
79
|
+
});
|
|
80
|
+
res.end(JSON.stringify({ ok: true }));
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
server.listen(0, "127.0.0.1", () => {
|
|
84
|
+
const addr = server.address();
|
|
85
|
+
resolve({
|
|
86
|
+
server,
|
|
87
|
+
url: `http://127.0.0.1:${addr.port}/v1/events`,
|
|
88
|
+
receivedBatches,
|
|
89
|
+
statusToReturn,
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function closeServer(server) {
|
|
95
|
+
return new Promise((resolve, reject) => {
|
|
96
|
+
server.close((err) => (err ? reject(err) : resolve()));
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
(0, vitest_1.describe)("EventBuffer", () => {
|
|
100
|
+
let mockServer;
|
|
101
|
+
(0, vitest_1.beforeEach)(async () => {
|
|
102
|
+
mockServer = await createMockIngestServer();
|
|
103
|
+
});
|
|
104
|
+
(0, vitest_1.afterEach)(async () => {
|
|
105
|
+
await closeServer(mockServer.server);
|
|
106
|
+
});
|
|
107
|
+
(0, vitest_1.it)("add() buffers events and reports pending count", () => {
|
|
108
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
109
|
+
apiKey: "test-key",
|
|
110
|
+
endpoint: mockServer.url,
|
|
111
|
+
flushInterval: 60_000, // very long so it won't auto-flush by timer
|
|
112
|
+
maxBufferSize: 100,
|
|
113
|
+
});
|
|
114
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
115
|
+
buffer.add(makeEvent());
|
|
116
|
+
(0, vitest_1.expect)(buffer.pending).toBe(1);
|
|
117
|
+
buffer.add(makeEvent());
|
|
118
|
+
buffer.add(makeEvent());
|
|
119
|
+
(0, vitest_1.expect)(buffer.pending).toBe(3);
|
|
120
|
+
});
|
|
121
|
+
(0, vitest_1.it)("flush() sends buffered events to the endpoint", async () => {
|
|
122
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
123
|
+
apiKey: "test-key",
|
|
124
|
+
endpoint: mockServer.url,
|
|
125
|
+
flushInterval: 60_000,
|
|
126
|
+
maxBufferSize: 100,
|
|
127
|
+
});
|
|
128
|
+
const event1 = makeEvent({ model: "gpt-4o" });
|
|
129
|
+
const event2 = makeEvent({ model: "gpt-4o-mini" });
|
|
130
|
+
buffer.add(event1);
|
|
131
|
+
buffer.add(event2);
|
|
132
|
+
(0, vitest_1.expect)(buffer.pending).toBe(2);
|
|
133
|
+
await buffer.flush();
|
|
134
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
135
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(1);
|
|
136
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events).toHaveLength(2);
|
|
137
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events[0].model).toBe("gpt-4o");
|
|
138
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events[1].model).toBe("gpt-4o-mini");
|
|
139
|
+
});
|
|
140
|
+
(0, vitest_1.it)("flush() with empty buffer is a no-op", async () => {
|
|
141
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
142
|
+
apiKey: "test-key",
|
|
143
|
+
endpoint: mockServer.url,
|
|
144
|
+
flushInterval: 60_000,
|
|
145
|
+
maxBufferSize: 100,
|
|
146
|
+
});
|
|
147
|
+
await buffer.flush();
|
|
148
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(0);
|
|
149
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
150
|
+
});
|
|
151
|
+
(0, vitest_1.it)("flush() sends Authorization header with Bearer token", async () => {
|
|
152
|
+
// Use a custom server that captures headers
|
|
153
|
+
const capturedHeaders = [];
|
|
154
|
+
const headerServer = http.createServer((req, res) => {
|
|
155
|
+
capturedHeaders.push(req.headers);
|
|
156
|
+
const chunks = [];
|
|
157
|
+
req.on("data", (c) => chunks.push(c));
|
|
158
|
+
req.on("end", () => {
|
|
159
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
160
|
+
res.end(JSON.stringify({ ok: true }));
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
await new Promise((resolve) => {
|
|
164
|
+
headerServer.listen(0, "127.0.0.1", () => resolve());
|
|
165
|
+
});
|
|
166
|
+
const headerAddr = headerServer.address();
|
|
167
|
+
const headerUrl = `http://127.0.0.1:${headerAddr.port}/v1/events`;
|
|
168
|
+
try {
|
|
169
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
170
|
+
apiKey: "my-secret-api-key",
|
|
171
|
+
endpoint: headerUrl,
|
|
172
|
+
flushInterval: 60_000,
|
|
173
|
+
maxBufferSize: 100,
|
|
174
|
+
});
|
|
175
|
+
buffer.add(makeEvent());
|
|
176
|
+
await buffer.flush();
|
|
177
|
+
(0, vitest_1.expect)(capturedHeaders).toHaveLength(1);
|
|
178
|
+
(0, vitest_1.expect)(capturedHeaders[0].authorization).toBe("Bearer my-secret-api-key");
|
|
179
|
+
(0, vitest_1.expect)(capturedHeaders[0]["content-type"]).toBe("application/json");
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
await new Promise((resolve, reject) => {
|
|
183
|
+
headerServer.close((err) => (err ? reject(err) : resolve()));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
(0, vitest_1.it)("auto-flushes when maxBufferSize is reached", async () => {
|
|
188
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
189
|
+
apiKey: "test-key",
|
|
190
|
+
endpoint: mockServer.url,
|
|
191
|
+
flushInterval: 60_000,
|
|
192
|
+
maxBufferSize: 3,
|
|
193
|
+
});
|
|
194
|
+
buffer.add(makeEvent({ model: "m1" }));
|
|
195
|
+
buffer.add(makeEvent({ model: "m2" }));
|
|
196
|
+
// Not yet at maxBufferSize
|
|
197
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(0);
|
|
198
|
+
// This third add should trigger auto-flush
|
|
199
|
+
buffer.add(makeEvent({ model: "m3" }));
|
|
200
|
+
// flush() is called asynchronously via void; give it time to complete
|
|
201
|
+
await vitest_1.vi.waitFor(() => {
|
|
202
|
+
(0, vitest_1.expect)(mockServer.receivedBatches.length).toBeGreaterThanOrEqual(1);
|
|
203
|
+
}, { timeout: 2000, interval: 50 });
|
|
204
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events).toHaveLength(3);
|
|
205
|
+
});
|
|
206
|
+
(0, vitest_1.it)("re-queues events on failed flush (non-2xx status)", async () => {
|
|
207
|
+
// Make the server return 500
|
|
208
|
+
mockServer.statusToReturn.code = 500;
|
|
209
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
210
|
+
apiKey: "test-key",
|
|
211
|
+
endpoint: mockServer.url,
|
|
212
|
+
flushInterval: 60_000,
|
|
213
|
+
maxBufferSize: 100,
|
|
214
|
+
});
|
|
215
|
+
buffer.add(makeEvent({ model: "m1" }));
|
|
216
|
+
buffer.add(makeEvent({ model: "m2" }));
|
|
217
|
+
await buffer.flush();
|
|
218
|
+
// Events should be re-queued
|
|
219
|
+
(0, vitest_1.expect)(buffer.pending).toBe(2);
|
|
220
|
+
// Now make the server return 200 and try again
|
|
221
|
+
mockServer.statusToReturn.code = 200;
|
|
222
|
+
await buffer.flush();
|
|
223
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
224
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(2);
|
|
225
|
+
});
|
|
226
|
+
(0, vitest_1.it)("re-queues events on network failure", async () => {
|
|
227
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
228
|
+
apiKey: "test-key",
|
|
229
|
+
endpoint: "http://127.0.0.1:1/unreachable-endpoint",
|
|
230
|
+
flushInterval: 60_000,
|
|
231
|
+
maxBufferSize: 100,
|
|
232
|
+
});
|
|
233
|
+
buffer.add(makeEvent({ model: "m1" }));
|
|
234
|
+
// Suppress the expected console.error
|
|
235
|
+
const consoleSpy = vitest_1.vi.spyOn(console, "error").mockImplementation(() => { });
|
|
236
|
+
await buffer.flush();
|
|
237
|
+
// Event should be re-queued since the network request fails
|
|
238
|
+
(0, vitest_1.expect)(buffer.pending).toBe(1);
|
|
239
|
+
consoleSpy.mockRestore();
|
|
240
|
+
});
|
|
241
|
+
(0, vitest_1.it)("shutdown() flushes remaining events and stops the timer", async () => {
|
|
242
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
243
|
+
apiKey: "test-key",
|
|
244
|
+
endpoint: mockServer.url,
|
|
245
|
+
flushInterval: 100, // short interval
|
|
246
|
+
maxBufferSize: 100,
|
|
247
|
+
});
|
|
248
|
+
buffer.start();
|
|
249
|
+
buffer.add(makeEvent({ model: "shutdown-test" }));
|
|
250
|
+
(0, vitest_1.expect)(buffer.pending).toBe(1);
|
|
251
|
+
await buffer.shutdown();
|
|
252
|
+
// After shutdown, events should have been flushed
|
|
253
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
254
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(1);
|
|
255
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events[0].model).toBe("shutdown-test");
|
|
256
|
+
});
|
|
257
|
+
(0, vitest_1.it)("start() is idempotent - calling multiple times does not create multiple timers", async () => {
|
|
258
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
259
|
+
apiKey: "test-key",
|
|
260
|
+
endpoint: mockServer.url,
|
|
261
|
+
flushInterval: 60_000,
|
|
262
|
+
maxBufferSize: 100,
|
|
263
|
+
});
|
|
264
|
+
// Calling start multiple times should not throw or create multiple timers
|
|
265
|
+
buffer.start();
|
|
266
|
+
buffer.start();
|
|
267
|
+
buffer.start();
|
|
268
|
+
buffer.add(makeEvent());
|
|
269
|
+
await buffer.shutdown();
|
|
270
|
+
(0, vitest_1.expect)(buffer.pending).toBe(0);
|
|
271
|
+
(0, vitest_1.expect)(mockServer.receivedBatches).toHaveLength(1);
|
|
272
|
+
});
|
|
273
|
+
(0, vitest_1.it)("timer-based flush triggers periodically", async () => {
|
|
274
|
+
const buffer = new event_buffer_js_1.EventBuffer({
|
|
275
|
+
apiKey: "test-key",
|
|
276
|
+
endpoint: mockServer.url,
|
|
277
|
+
flushInterval: 100, // 100ms interval
|
|
278
|
+
maxBufferSize: 1000,
|
|
279
|
+
});
|
|
280
|
+
buffer.start();
|
|
281
|
+
buffer.add(makeEvent({ model: "timer-test" }));
|
|
282
|
+
// Wait for the timer to trigger a flush
|
|
283
|
+
await vitest_1.vi.waitFor(() => {
|
|
284
|
+
(0, vitest_1.expect)(mockServer.receivedBatches.length).toBeGreaterThanOrEqual(1);
|
|
285
|
+
}, { timeout: 2000, interval: 50 });
|
|
286
|
+
(0, vitest_1.expect)(mockServer.receivedBatches[0].events[0].model).toBe("timer-test");
|
|
287
|
+
await buffer.shutdown();
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
//# sourceMappingURL=event-buffer.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-buffer.test.js","sourceRoot":"","sources":["../../src/__tests__/event-buffer.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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