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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hyperbrowser/sdk",
"version": "1.2.0",
"version": "1.2.1",
"description": "Node SDK for Hyperbrowser API",
"author": "",
"repository": {
Expand Down
6 changes: 5 additions & 1 deletion src/types/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export type GrokComputerUseLlm = "grok-4.7" | "grok-4.6" | "grok-4.5";

export type GrokReasoningEffort = "low" | "medium" | "high";

export type MetaComputerUseLlm = "muse-spark-1.1" | "muse-spark-1.2" | "muse-spark-1.3";
export type MetaComputerUseLlm =
| "muse-spark-1.1"
| "muse-spark-1.2"
| "muse-spark-1.3"
| "muse-wonder-1.0";

export type MetaReasoningEffort = "minimal" | "low" | "medium" | "high" | "xhigh" | "max";

Expand Down
146 changes: 76 additions & 70 deletions tests/integration/client-http.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import http, { IncomingMessage, ServerResponse } from "node:http";
import { afterEach, describe, expect, test } from "vitest";
import { HyperbrowserClient } from "../../src/client";
import type { MetaComputerUseLlm } from "../../src/types";

type RecordedRequest = {
method?: string;
Expand Down Expand Up @@ -38,7 +39,9 @@ const sendJson = (response: ServerResponse, statusCode: number, payload: unknown
response.end(encoded);
};

const startServer = async (): Promise<TestServer> => {
const startServer = async (
metaModel: MetaComputerUseLlm = "muse-spark-1.3"
): Promise<TestServer> => {
const requests: RecordedRequest[] = [];
const server = http.createServer(async (request, response) => {
const body = await readJsonBody(request);
Expand Down Expand Up @@ -90,7 +93,7 @@ const startServer = async (): Promise<TestServer> => {
output_text: "Second sentence in the Ecology section.",
error: null,
incomplete_details: null,
model: "muse-spark-1.3",
model: metaModel,
output: [
{
type: "function_call",
Expand Down Expand Up @@ -389,76 +392,79 @@ describe("client HTTP integration", () => {
]);
});

test("Meta Computer Use starts, polls, reads, and stops a task", async () => {
const server = await startServer();
servers.push(server);
const client = new HyperbrowserClient({
apiKey: "test-api-key",
baseUrl: server.baseUrl,
});

const started = await client.agents.metaComputerUse.start({
task: "Complete the task",
llm: "muse-spark-1.3",
reasoningEffort: "max",
useCustomApiKeys: true,
apiKeys: { meta: "meta-key" },
});
const status = await client.agents.metaComputerUse.getStatus(started.jobId);
const result = await client.agents.metaComputerUse.get(started.jobId);
const stopped = await client.agents.metaComputerUse.stop(started.jobId);

expect(started).toEqual({ jobId: "meta_job_123", liveUrl: null });
expect(status).toEqual({ status: "completed" });
expect(result.data?.finalResult).toBe("done");
expect(result.data?.steps[0]).toMatchObject({
created_at: 1788743504,
completed_at: 1788743511,
model: "muse-spark-1.3",
reasoning: { effort: "medium", summary: "concise" },
});
expect(result.data?.steps[0].output?.[0]).toMatchObject({
type: "function_call",
name: "computer.computer",
});
expect(stopped).toEqual({ success: true });
expect(server.requests).toEqual([
{
method: "POST",
url: "/api/task/meta-computer-use",
test.each(["muse-spark-1.3", "muse-wonder-1.0"] as const)(
"Meta Computer Use starts, polls, reads, and stops a %s task",
async (llm) => {
const server = await startServer(llm);
servers.push(server);
const client = new HyperbrowserClient({
apiKey: "test-api-key",
contentType: "application/json",
body: {
task: "Complete the task",
llm: "muse-spark-1.3",
reasoningEffort: "max",
useCustomApiKeys: true,
apiKeys: { meta: "meta-key" },
baseUrl: server.baseUrl,
});

const started = await client.agents.metaComputerUse.start({
task: "Complete the task",
llm,
reasoningEffort: "max",
useCustomApiKeys: true,
apiKeys: { meta: "meta-key" },
});
const status = await client.agents.metaComputerUse.getStatus(started.jobId);
const result = await client.agents.metaComputerUse.get(started.jobId);
const stopped = await client.agents.metaComputerUse.stop(started.jobId);

expect(started).toEqual({ jobId: "meta_job_123", liveUrl: null });
expect(status).toEqual({ status: "completed" });
expect(result.data?.finalResult).toBe("done");
expect(result.data?.steps[0]).toMatchObject({
created_at: 1788743504,
completed_at: 1788743511,
model: llm,
reasoning: { effort: "medium", summary: "concise" },
});
expect(result.data?.steps[0].output?.[0]).toMatchObject({
type: "function_call",
name: "computer.computer",
});
expect(stopped).toEqual({ success: true });
expect(server.requests).toEqual([
{
method: "POST",
url: "/api/task/meta-computer-use",
apiKey: "test-api-key",
contentType: "application/json",
body: {
task: "Complete the task",
llm,
reasoningEffort: "max",
useCustomApiKeys: true,
apiKeys: { meta: "meta-key" },
},
},
},
{
method: "GET",
url: "/api/task/meta-computer-use/meta_job_123/status",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
{
method: "GET",
url: "/api/task/meta-computer-use/meta_job_123",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
{
method: "PUT",
url: "/api/task/meta-computer-use/meta_job_123/stop",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
]);
});
{
method: "GET",
url: "/api/task/meta-computer-use/meta_job_123/status",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
{
method: "GET",
url: "/api/task/meta-computer-use/meta_job_123",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
{
method: "PUT",
url: "/api/task/meta-computer-use/meta_job_123/stop",
apiKey: "test-api-key",
contentType: "application/json",
body: undefined,
},
]);
}
);

test("Jev Computer Use starts, polls, reads, and stops a task", async () => {
const server = await startServer();
Expand Down