|
|
|
|
@@ -26,7 +26,7 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const tokenEnvKey = "OPENCLAW_TOKEN_JARVIS_MAIN";
|
|
|
|
|
const tokenEnvKey = "OPENCLAW_TOKEN_MOSAIC_MAIN";
|
|
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
vi.clearAllMocks();
|
|
|
|
|
@@ -52,10 +52,10 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
mockPrisma.openClawAgent.findUnique.mockResolvedValue({
|
|
|
|
|
id: "agent-1",
|
|
|
|
|
name: "jarvis-main",
|
|
|
|
|
displayName: "Jarvis (Main)",
|
|
|
|
|
name: "mosaic-main",
|
|
|
|
|
displayName: "Main Orchestrator",
|
|
|
|
|
role: "orchestrator",
|
|
|
|
|
gatewayUrl: "http://jarvis-main:18789",
|
|
|
|
|
gatewayUrl: "http://mosaic-main:18789",
|
|
|
|
|
agentId: "main",
|
|
|
|
|
model: "zai/glm-5",
|
|
|
|
|
isActive: true,
|
|
|
|
|
@@ -72,13 +72,13 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const chunks: string[] = [];
|
|
|
|
|
for await (const chunk of service.streamChat("jarvis-main", messages)) {
|
|
|
|
|
for await (const chunk of service.streamChat("mosaic-main", messages)) {
|
|
|
|
|
chunks.push(chunk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
expect(chunks).toEqual(["Hello", " world"]);
|
|
|
|
|
expect(mockHttpService.axiosRef.post).toHaveBeenCalledWith(
|
|
|
|
|
"http://jarvis-main:18789/v1/chat/completions",
|
|
|
|
|
"http://mosaic-main:18789/v1/chat/completions",
|
|
|
|
|
{
|
|
|
|
|
model: "openclaw:main",
|
|
|
|
|
messages,
|
|
|
|
|
@@ -109,10 +109,10 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
it("throws ServiceUnavailableException when agent is inactive", async () => {
|
|
|
|
|
mockPrisma.openClawAgent.findUnique.mockResolvedValue({
|
|
|
|
|
id: "agent-1",
|
|
|
|
|
name: "jarvis-main",
|
|
|
|
|
displayName: "Jarvis (Main)",
|
|
|
|
|
name: "mosaic-main",
|
|
|
|
|
displayName: "Main Orchestrator",
|
|
|
|
|
role: "orchestrator",
|
|
|
|
|
gatewayUrl: "http://jarvis-main:18789",
|
|
|
|
|
gatewayUrl: "http://mosaic-main:18789",
|
|
|
|
|
agentId: "main",
|
|
|
|
|
model: "zai/glm-5",
|
|
|
|
|
isActive: false,
|
|
|
|
|
@@ -122,7 +122,7 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
(async () => {
|
|
|
|
|
for await (const _chunk of service.streamChat("jarvis-main", [])) {
|
|
|
|
|
for await (const _chunk of service.streamChat("mosaic-main", [])) {
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
})()
|
|
|
|
|
@@ -134,10 +134,10 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
mockPrisma.openClawAgent.findUnique.mockResolvedValue({
|
|
|
|
|
id: "agent-1",
|
|
|
|
|
name: "jarvis-main",
|
|
|
|
|
displayName: "Jarvis (Main)",
|
|
|
|
|
name: "mosaic-main",
|
|
|
|
|
displayName: "Main Orchestrator",
|
|
|
|
|
role: "orchestrator",
|
|
|
|
|
gatewayUrl: "http://jarvis-main:18789",
|
|
|
|
|
gatewayUrl: "http://mosaic-main:18789",
|
|
|
|
|
agentId: "main",
|
|
|
|
|
model: "zai/glm-5",
|
|
|
|
|
isActive: true,
|
|
|
|
|
@@ -147,7 +147,7 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
(async () => {
|
|
|
|
|
for await (const _chunk of service.streamChat("jarvis-main", [])) {
|
|
|
|
|
for await (const _chunk of service.streamChat("mosaic-main", [])) {
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
})()
|
|
|
|
|
@@ -157,10 +157,10 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
it("throws UnauthorizedException when OpenClaw returns 401", async () => {
|
|
|
|
|
mockPrisma.openClawAgent.findUnique.mockResolvedValue({
|
|
|
|
|
id: "agent-1",
|
|
|
|
|
name: "jarvis-main",
|
|
|
|
|
displayName: "Jarvis (Main)",
|
|
|
|
|
name: "mosaic-main",
|
|
|
|
|
displayName: "Main Orchestrator",
|
|
|
|
|
role: "orchestrator",
|
|
|
|
|
gatewayUrl: "http://jarvis-main:18789",
|
|
|
|
|
gatewayUrl: "http://mosaic-main:18789",
|
|
|
|
|
agentId: "main",
|
|
|
|
|
model: "zai/glm-5",
|
|
|
|
|
isActive: true,
|
|
|
|
|
@@ -175,7 +175,7 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
(async () => {
|
|
|
|
|
for await (const _chunk of service.streamChat("jarvis-main", [])) {
|
|
|
|
|
for await (const _chunk of service.streamChat("mosaic-main", [])) {
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
})()
|
|
|
|
|
@@ -185,10 +185,10 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
it("throws ServiceUnavailableException when gateway is offline", async () => {
|
|
|
|
|
mockPrisma.openClawAgent.findUnique.mockResolvedValue({
|
|
|
|
|
id: "agent-1",
|
|
|
|
|
name: "jarvis-main",
|
|
|
|
|
displayName: "Jarvis (Main)",
|
|
|
|
|
name: "mosaic-main",
|
|
|
|
|
displayName: "Main Orchestrator",
|
|
|
|
|
role: "orchestrator",
|
|
|
|
|
gatewayUrl: "http://jarvis-main:18789",
|
|
|
|
|
gatewayUrl: "http://mosaic-main:18789",
|
|
|
|
|
agentId: "main",
|
|
|
|
|
model: "zai/glm-5",
|
|
|
|
|
isActive: true,
|
|
|
|
|
@@ -203,7 +203,7 @@ describe("OpenClawGatewayService", () => {
|
|
|
|
|
|
|
|
|
|
await expect(
|
|
|
|
|
(async () => {
|
|
|
|
|
for await (const _chunk of service.streamChat("jarvis-main", [])) {
|
|
|
|
|
for await (const _chunk of service.streamChat("mosaic-main", [])) {
|
|
|
|
|
// no-op
|
|
|
|
|
}
|
|
|
|
|
})()
|
|
|
|
|
|