Skip to content
Merged
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
// This file is auto-generated by @archastro/sdk-generator. Do not edit.
// Content hash: b10684f9f76a
// Content hash: 6195fa42cc50

// Contract tests for the generated channel class. Drives the channel
// through a real WebSocket against the harness-service subprocess —
Expand Down Expand Up @@ -404,7 +404,7 @@ describe("ApiChatChannel.apiChatPostMessage (api:chat:post_message)", () => {
});

const channel = await ApiChatChannel.joinTeamThread(rig.socket, "test-id", "test-id", { after_cursor: "test-value", before_cursor: "test-value", include_metadata: true, limit: 1 });
const reply = await channel.apiChatPostMessage({ content: "test content", context: [{ type: "test" }], idempotency_key: "test-key", reply_to: "test-value", uploads: [{}] });
const reply = await channel.apiChatPostMessage({ content: "test content", context: [{ type: "test" }], idempotency_key: "test-key", mentions: ["test-value"], metadata: {}, reply_to: "test-value", uploads: [{}] });
expect(reply).toBeDefined();

const observed = await rig.client.observations("api:chat:team:test-id:thread:test-id", "api:chat:post_message");
Expand Down Expand Up @@ -442,7 +442,7 @@ describe("ApiChatChannel.apiChatPostSimpleMessage (api:chat:post_simple_message)
});

const channel = await ApiChatChannel.joinTeamThread(rig.socket, "test-id", "test-id", { after_cursor: "test-value", before_cursor: "test-value", include_metadata: true, limit: 1 });
const reply = await channel.apiChatPostSimpleMessage({ content: "test content", context: [{ type: "test" }], idempotency_key: "test-key", reply_to: "test-value" });
const reply = await channel.apiChatPostSimpleMessage({ content: "test content", context: [{ type: "test" }], idempotency_key: "test-key", mentions: ["test-value"], metadata: {}, reply_to: "test-value" });
expect(reply).toBeDefined();

const observed = await rig.client.observations("api:chat:team:test-id:thread:test-id", "api:chat:post_simple_message");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
// This file is auto-generated by @archastro/sdk-generator. Do not edit.
// Content hash: 79936f5130bb
// Content hash: 0acc4debbbfa


import { describe, it, expect, beforeEach, afterEach } from "vitest";
Expand Down Expand Up @@ -35,12 +35,12 @@ afterEach(() => {
describe("contract: agent_sessions (SSE)", () => {
describe("v1.agent_sessions.stream (GET /api/v1/agent_sessions/{agent_session}/stream)", () => {
it("yields the declared SSE events in order", async () => {
await harness.registerStreamScenario({ route: "GET /api/v1/agent_sessions/{agent_session}/stream", actions: [{ type: "autoEmit", event: "session_update" }] });
await harness.registerStreamScenario({ route: "GET /api/v1/agent_sessions/{agent_session}/stream", actions: [{ type: "autoEmit", event: "session_event" }, { type: "autoEmit", event: "session_update" }] });
const events: Array<{ event: string; data: unknown }> = [];
for await (const ev of client.v1.agent_sessions.stream("test-value")) {
events.push(ev);
}
expect(events.map((e) => e.event)).toEqual(["session_update"]);
expect(events.map((e) => e.event)).toEqual(["session_event","session_update"]);
});

it("rejects with ApiError on a non-2xx status", async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
// This file is auto-generated by @archastro/sdk-generator. Do not edit.
// Content hash: ff9e0a1e2748
// Content hash: da7f574165da


import { describe, it, expect } from "vitest";
Expand Down Expand Up @@ -101,6 +101,55 @@ describe("contract: agent_computers", () => {
}
});

it("PATCH /api/v1/agent_computers/{computer} returns successfully", async () => {
const result = await client.v1.agent_computers.update("test-value", {});
expect(result).toBeUndefined();
});

it("PATCH /api/v1/agent_computers/{computer} returns 401", async () => {
const ec = errorClient(401);
try {
await ec.v1.agent_computers.update("test-value", {});
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(401);
}
});

it("PATCH /api/v1/agent_computers/{computer} returns 403", async () => {
const ec = errorClient(403);
try {
await ec.v1.agent_computers.update("test-value", {});
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(403);
}
});

it("PATCH /api/v1/agent_computers/{computer} returns 404", async () => {
const ec = errorClient(404);
try {
await ec.v1.agent_computers.update("test-value", {});
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(404);
}
});

it("PATCH /api/v1/agent_computers/{computer} returns 422", async () => {
const ec = errorClient(422);
try {
await ec.v1.agent_computers.update("test-value", {});
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(422);
}
});

it("POST /api/v1/agent_computers/{computer}/exec returns successfully", async () => {
const result = await client.v1.agent_computers.exec("test-value", { command: "test-value" });
expect(result).toBeDefined();
Expand Down
237 changes: 237 additions & 0 deletions packages/sdk/__tests__/contract/v1/agent_requests.contract.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
// Copyright (c) 2026 ArchAstro Inc. Licensed under the MIT License.
// This file is auto-generated by @archastro/sdk-generator. Do not edit.
// Content hash: cc309736c038


import { describe, it, expect } from "vitest";
import { PlatformClient } from "../../../src/index.js";
import { ApiError } from "../../../src/runtime/http-client.js";

const PRISM_URL = process.env.PRISM_URL ?? "http://127.0.0.1:4040";

const client = new PlatformClient({
baseUrl: PRISM_URL,
defaultHeaders: { "x-archastro-api-key": "pk_test-key" },
accessToken: "test-token",
});

function errorClient(code: number): PlatformClient {
return new PlatformClient({
baseUrl: PRISM_URL,
defaultHeaders: { "x-archastro-api-key": "pk_test-key", "Prefer": `code=${code}` },
accessToken: "test-token",
});
}

describe("contract: agent_requests", () => {
describe("agent_requests", () => {
it("GET /api/v1/agent_requests returns successfully", async () => {
const result = await client.v1.agent_requests.list();
expect(result).toBeDefined();
});

it("GET /api/v1/agent_requests returns 401", async () => {
const ec = errorClient(401);
try {
await ec.v1.agent_requests.list();
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(401);
}
});

it("GET /api/v1/agent_requests returns 422", async () => {
const ec = errorClient(422);
try {
await ec.v1.agent_requests.list();
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(422);
}
});

it("GET /api/v1/agent_requests/{agent_request} returns successfully", async () => {
const result = await client.v1.agent_requests.get("test-value");
expect(result).toBeDefined();
});

it("GET /api/v1/agent_requests/{agent_request} returns 401", async () => {
const ec = errorClient(401);
try {
await ec.v1.agent_requests.get("test-value");
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(401);
}
});

it("GET /api/v1/agent_requests/{agent_request} returns 403", async () => {
const ec = errorClient(403);
try {
await ec.v1.agent_requests.get("test-value");
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(403);
}
});

it("GET /api/v1/agent_requests/{agent_request} returns 404", async () => {
const ec = errorClient(404);
try {
await ec.v1.agent_requests.get("test-value");
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(404);
}
});

it("GET /api/v1/agent_requests/{agent_request} returns 409", async () => {
const ec = errorClient(409);
try {
await ec.v1.agent_requests.get("test-value");
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(409);
}
});

it("GET /api/v1/agent_requests/{agent_request} returns 422", async () => {
const ec = errorClient(422);
try {
await ec.v1.agent_requests.get("test-value");
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(422);
}
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns successfully", async () => {
const result = await client.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect(result).toBeDefined();
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns 401", async () => {
const ec = errorClient(401);
try {
await ec.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(401);
}
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns 403", async () => {
const ec = errorClient(403);
try {
await ec.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(403);
}
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns 404", async () => {
const ec = errorClient(404);
try {
await ec.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(404);
}
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns 409", async () => {
const ec = errorClient(409);
try {
await ec.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(409);
}
});

it("POST /api/v1/agent_requests/{agent_request}/reject returns 422", async () => {
const ec = errorClient(422);
try {
await ec.v1.agent_requests.reject("test-value", { reason: "test-value" });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(422);
}
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns successfully", async () => {
const result = await client.v1.agent_requests.resolve("test-value", { input: {} });
expect(result).toBeDefined();
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns 401", async () => {
const ec = errorClient(401);
try {
await ec.v1.agent_requests.resolve("test-value", { input: {} });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(401);
}
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns 403", async () => {
const ec = errorClient(403);
try {
await ec.v1.agent_requests.resolve("test-value", { input: {} });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(403);
}
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns 404", async () => {
const ec = errorClient(404);
try {
await ec.v1.agent_requests.resolve("test-value", { input: {} });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(404);
}
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns 409", async () => {
const ec = errorClient(409);
try {
await ec.v1.agent_requests.resolve("test-value", { input: {} });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(409);
}
});

it("POST /api/v1/agent_requests/{agent_request}/resolve returns 422", async () => {
const ec = errorClient(422);
try {
await ec.v1.agent_requests.resolve("test-value", { input: {} });
expect.fail("Expected ApiError to be thrown");
} catch (e) {
expect(e).toBeInstanceOf(ApiError);
expect((e as ApiError).status).toBe(422);
}
});

});

});
Loading
Loading