Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/sdk/src/internal/providers/bailian/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class BailianClient extends BaseApiClient {
return {
"Content-Type": "application/json",
Authorization: `Bearer ${this.apiKey}`,
"x-dashscope-source-config": "openagentpack",
};
}

Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/tests/unit/bailian-webhook.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-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));
});
Expand Down
18 changes: 18 additions & 0 deletions packages/sdk/tests/unit/bailian.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -54,6 +55,23 @@ describe("bailianConfigSchema", () => {
});
});

describe("BailianClient source-config header", () => {
test("every MA request carries x-dashscope-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-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");
Expand Down
Loading