The open-source agent harness - the runtime layer that turns an LLM into a working agent.
// This file was auto-generated by Fern from our API Definition.
import * as TrueForgeTypes from "../../src/api/index";
import { TrueForge } from "../../src/Client";
import { mockServerPool } from "../mock-server/MockServerPool";
describe("InternalClient", () => {
test("list_permissions (1)", async () => {
const server = mockServerPool.createServer();
const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });
const rawRequestBody = { resource_ids: ["resource_ids"], resource_type: "agent" };
const rawResponseBody = { data: { permissions: { key: ["USE"] }, type: "agent" } };
server
.mockEndpoint()
.post("/api/internal/list-permissions")
.jsonBody(rawRequestBody)
.respondWith()
.statusCode(200)
.jsonBody(rawResponseBody)
.build();
const response = await client.internal.listPermissions({
resourceIds: ["resource_ids"],
resourceType: "agent",
});
expect(response).toEqual({
data: {
permissions: {
key: ["USE"],
},
type: "agent",
},
});
});
test("list_permissions (2)", async () => {
const server = mockServerPool.createServer();
const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });
const rawRequestBody = { resource_ids: ["resource_ids", "resource_ids"], resource_type: "agent" };
const rawResponseBody = { error: { message: "message" } };
server
.mockEndpoint()
.post("/api/internal/list-permissions")
.jsonBody(rawRequestBody)
.respondWith()
.statusCode(400)
.jsonBody(rawResponseBody)
.build();
await expect(async () => {
return await client.internal.listPermissions({
resourceIds: ["resource_ids", "resource_ids"],
resourceType: "agent",
});
}).rejects.toThrow(TrueForgeTypes.BadRequestError);
});
test("list_permissions (3)", async () => {
const server = mockServerPool.createServer();
const client = new TrueForge({ maxRetries: 0, token: "test", baseUrl: server.baseUrl });
const rawRequestBody = { resource_ids: ["resource_ids", "resource_ids"], resource_type: "agent" };
const rawResponseBody = { error: { message: "message" } };
server
.mockEndpoint()
.post("/api/internal/list-permissions")
.jsonBody(rawRequestBody)
.respondWith()
.statusCode(401)
.jsonBody(rawResponseBody)
.build();
await expect(async () => {
return await client.internal.listPermissions({
resourceIds: ["resource_ids", "resource_ids"],
resourceType: "agent",
});
}).rejects.toThrow(TrueForgeTypes.UnauthorizedError);
});
});