@vellumai/vellum-gateway 0.1.7 → 0.1.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/vellum-gateway",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "bun run --watch src/index.ts",
@@ -38,7 +38,21 @@ afterEach(() => {
38
38
  });
39
39
 
40
40
  describe("runtime proxy handler", () => {
41
- test("forwards request to upstream with correct path and query", async () => {
41
+ test("rewrites /v1/assistants/:assistantId/... to /v1/... for upstream", async () => {
42
+ const captured: { url: string }[] = [];
43
+ globalThis.fetch = mock(async (input: any) => {
44
+ captured.push({ url: String(input) });
45
+ return new Response(JSON.stringify({ ok: true }), { status: 200 });
46
+ }) as any;
47
+
48
+ const handler = createRuntimeProxyHandler(makeConfig());
49
+ const req = new Request("http://localhost:7830/v1/assistants/test-assistant/channels/inbound");
50
+ await handler(req);
51
+
52
+ expect(captured[0].url).toBe("http://localhost:7821/v1/channels/inbound");
53
+ });
54
+
55
+ test("forwards request to upstream with correct path and query (assistant-scoped rewrite)", async () => {
42
56
  const captured: { url: string; method: string }[] = [];
43
57
  globalThis.fetch = mock(async (input: any, init?: any) => {
44
58
  captured.push({ url: String(input), method: init?.method ?? "GET" });
@@ -53,7 +67,8 @@ describe("runtime proxy handler", () => {
53
67
  const res = await handler(req);
54
68
 
55
69
  expect(res.status).toBe(200);
56
- expect(captured[0].url).toBe("http://localhost:7821/v1/assistants/test/health?foo=bar");
70
+ // /v1/assistants/test/health is rewritten to /v1/health
71
+ expect(captured[0].url).toBe("http://localhost:7821/v1/health?foo=bar");
57
72
  expect(captured[0].method).toBe("GET");
58
73
  const body = await res.json();
59
74
  expect(body).toEqual({ ok: true });
@@ -57,7 +57,14 @@ export function createRuntimeProxyHandler(config: GatewayConfig) {
57
57
  }
58
58
  }
59
59
 
60
- const upstream = `${config.assistantRuntimeBaseUrl}${url.pathname}${url.search}`;
60
+ // Rewrite /v1/assistants/:assistantId/... → /v1/... for the upstream daemon
61
+ let upstreamPath = url.pathname;
62
+ const assistantScopedMatch = url.pathname.match(/^\/v1\/assistants\/[^/]+\/(.+)$/);
63
+ if (assistantScopedMatch) {
64
+ upstreamPath = `/v1/${assistantScopedMatch[1]}`;
65
+ }
66
+
67
+ const upstream = `${config.assistantRuntimeBaseUrl}${upstreamPath}${url.search}`;
61
68
 
62
69
  const reqHeaders = stripHopByHop(new Headers(req.headers));
63
70
  reqHeaders.delete("host");