diff --git a/bun.lock b/bun.lock index f84fea8..5682e79 100644 --- a/bun.lock +++ b/bun.lock @@ -100,7 +100,7 @@ "agents-playground": "dist/bin/playground.js", }, "dependencies": { - "@hono/node-server": "^2.1.3", + "@hono/node-server": "^2.1.6", "@hono/zod-openapi": "^1.4.0", "@openagentpack/sdk": "workspace:*", "chokidar": "^4.0.3", @@ -290,7 +290,7 @@ "@floating-ui/utils": ["@floating-ui/utils@0.2.12", "", {}, "sha512-HpCo8tmWzLVad5s2d19EhAz5zqrrQ6s69qd6moPMQvkOuSwDT1YgRfWSVuc4ennqrgv3OHppiOGMQ7oC13yIww=="], - "@hono/node-server": ["@hono/node-server@2.1.5", "", { "peerDependencies": { "hono": "^4 || ^5.0.0-0" } }, "sha512-MgP/I06GdvsilDspMk/qmRzpk8LOUStP6jFAbSRi40W09DhoyUn+Mj7eyKICPqeYKybOjVFLVIAQzvu1bfIa7Q=="], + "@hono/node-server": ["@hono/node-server@2.1.6", "", { "peerDependencies": { "hono": "^4 || ^5.0.0-0" } }, "sha512-p/KH9MnfNcsm3sR6x4lNgm5j+QN4Et8srKredl9DZfXiyZ1UQ3aQ2YVpFLbqktYN5JI+DB+VZFKM2PqE5hLKjQ=="], "@hono/zod-openapi": ["@hono/zod-openapi@1.6.3", "", { "dependencies": { "@asteasolutions/zod-to-openapi": "^9.1.0", "@hono/zod-validator": "^0.9.1", "openapi3-ts": "^4.5.0" }, "peerDependencies": { "hono": ">=4.10.0", "zod": "^4.0.0" } }, "sha512-VYR82Y60plu8g3pN60OUXMVKpmxh3R04Qs++3DY9vtwZ9/sA/BRY0PcRIR+Z37/3itWtM7pYwT9bKiH9JhqV6Q=="], diff --git a/packages/playground/package.json b/packages/playground/package.json index 713e1b0..a19d970 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -40,7 +40,7 @@ "typecheck": "tsc --noEmit" }, "dependencies": { - "@hono/node-server": "^2.1.3", + "@hono/node-server": "^2.1.6", "@hono/zod-openapi": "^1.4.0", "@openagentpack/sdk": "workspace:*", "chokidar": "^4.0.3", diff --git a/packages/sdk/src/internal/providers/bailian/client.ts b/packages/sdk/src/internal/providers/bailian/client.ts index 9c70034..4454b21 100644 --- a/packages/sdk/src/internal/providers/bailian/client.ts +++ b/packages/sdk/src/internal/providers/bailian/client.ts @@ -29,6 +29,7 @@ export class BailianClient extends BaseApiClient { return { "Content-Type": "application/json", Authorization: `Bearer ${this.apiKey}`, + "x-dashscope-agentstudio-source-config": "openagentpack", }; } diff --git a/packages/sdk/tests/unit/bailian-webhook.test.ts b/packages/sdk/tests/unit/bailian-webhook.test.ts index f33902e..02e6314 100644 --- a/packages/sdk/tests/unit/bailian-webhook.test.ts +++ b/packages/sdk/tests/unit/bailian-webhook.test.ts @@ -260,7 +260,11 @@ describe("Bailian webhook wire contract", () => { expect(calls).toHaveLength(1); expect(calls[0]?.url).toBe(`${BASE_URL}${scenario.path}`); expect(calls[0]?.init?.method).toBe(scenario.method); - expect(calls[0]?.init?.headers).toEqual({ "Content-Type": "application/json", Authorization: "Bearer sk-test" }); + expect(calls[0]?.init?.headers).toEqual({ + "Content-Type": "application/json", + Authorization: "Bearer sk-test", + "x-dashscope-agentstudio-source-config": "openagentpack", + }); expect(calls[0]?.init?.signal).toBe(controller.signal); expect(calls[0]?.init?.body).toBe(scenario.body === undefined ? undefined : JSON.stringify(scenario.body)); }); diff --git a/packages/sdk/tests/unit/bailian.test.ts b/packages/sdk/tests/unit/bailian.test.ts index 17f361b..12bd574 100644 --- a/packages/sdk/tests/unit/bailian.test.ts +++ b/packages/sdk/tests/unit/bailian.test.ts @@ -1,5 +1,6 @@ import { afterEach, describe, expect, test } from "bun:test"; import { BailianAdapter } from "../../src/internal/providers/bailian/adapter.ts"; +import { BailianClient } from "../../src/internal/providers/bailian/client.ts"; import { bailianConfigSchema } from "../../src/internal/providers/bailian/config.ts"; import { mapAgent, mapEnvironment, mapInitialEvents, mapSession } from "../../src/internal/providers/bailian/mapper.ts"; import type { ResolvedAgentRefs } from "../../src/internal/providers/interface.ts"; @@ -54,6 +55,23 @@ describe("bailianConfigSchema", () => { }); }); +describe("BailianClient source-config header", () => { + test("every MA request carries x-dashscope-agentstudio-source-config", async () => { + const client = new BailianClient({ apiKey: "sk-test", baseUrl: "https://bailian.test/api/v1/agentstudio" }); + const captured: Headers[] = []; + globalThis.fetch = (async (_input: RequestInfo | URL, init?: RequestInit) => { + captured.push(new Headers(init?.headers)); + return Response.json({ id: "agent_x", name: "Agents/x" }); + }) as typeof fetch; + + await client.get("/agents/agent_x"); + + expect(captured).toHaveLength(1); + expect(captured[0]?.get("x-dashscope-agentstudio-source-config")).toBe("openagentpack"); + expect(captured[0]?.get("Authorization")).toBe("Bearer sk-test"); + }); +}); + describe("BailianAdapter archived agents", () => { test("does not treat an archived agent id as an updatable resource", async () => { const adapter = new BailianAdapter("sk-test", "ws-test", "https://bailian.test/api/v1/agentstudio");