-
Notifications
You must be signed in to change notification settings - Fork 2
Add Meta Computer Use agent #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7e3aec2
feat: add Meta Computer Use agent
cursoragent d6ca92e
Merge origin/main into Meta Computer Use branch
cursoragent 5283c91
feat: add muse-spark-1.2/1.3 and max reasoning for Meta Computer Use
cursoragent f48f462
Align Meta Computer Use step types with compacted API history.
cursoragent 2d14503
Keep live Meta Computer Use envelope fields on get responses.
cursoragent 550c81e
Drop Meta envelope fields that other agents omit.
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import { HyperbrowserError } from "../../client"; | ||
| import { BasicResponse } from "../../types"; | ||
| import { POLLING_ATTEMPTS } from "../../types/constants"; | ||
| import { sleep } from "../../utils"; | ||
| import { BaseService } from "../base"; | ||
| import { | ||
| MetaComputerUseTaskResponse, | ||
| MetaComputerUseTaskStatusResponse, | ||
| StartMetaComputerUseTaskParams, | ||
| StartMetaComputerUseTaskResponse, | ||
| } from "../../types/agents/meta-computer-use"; | ||
|
|
||
| export class MetaComputerUseService extends BaseService { | ||
| /** | ||
| * Start a new Meta Computer Use task job | ||
| * @param params The parameters for the task job | ||
| */ | ||
| async start(params: StartMetaComputerUseTaskParams): Promise<StartMetaComputerUseTaskResponse> { | ||
| try { | ||
| return await this.request<StartMetaComputerUseTaskResponse>("/task/meta-computer-use", { | ||
| method: "POST", | ||
| body: JSON.stringify(params), | ||
| }); | ||
| } catch (error) { | ||
| if (error instanceof HyperbrowserError) { | ||
| throw error; | ||
| } | ||
| throw new HyperbrowserError("Failed to start Meta Computer Use task job", undefined); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the status of a Meta Computer Use task job | ||
| * @param id The ID of the task job to get | ||
| */ | ||
| async getStatus(id: string): Promise<MetaComputerUseTaskStatusResponse> { | ||
| try { | ||
| return await this.request<MetaComputerUseTaskStatusResponse>( | ||
| `/task/meta-computer-use/${id}/status` | ||
| ); | ||
| } catch (error) { | ||
| if (error instanceof HyperbrowserError) { | ||
| throw error; | ||
| } | ||
| throw new HyperbrowserError( | ||
| `Failed to get Meta Computer Use task job ${id} status`, | ||
| undefined | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Get the result of a Meta Computer Use task job | ||
| * @param id The ID of the task job to get | ||
| */ | ||
| async get(id: string): Promise<MetaComputerUseTaskResponse> { | ||
| try { | ||
| return await this.request<MetaComputerUseTaskResponse>(`/task/meta-computer-use/${id}`); | ||
| } catch (error) { | ||
| if (error instanceof HyperbrowserError) { | ||
| throw error; | ||
| } | ||
| throw new HyperbrowserError(`Failed to get Meta Computer Use task job ${id}`, undefined); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Stop a Meta Computer Use task job | ||
| * @param id The ID of the task job to stop | ||
| */ | ||
| async stop(id: string): Promise<BasicResponse> { | ||
| try { | ||
| return await this.request<BasicResponse>(`/task/meta-computer-use/${id}/stop`, { | ||
| method: "PUT", | ||
| }); | ||
| } catch (error) { | ||
| if (error instanceof HyperbrowserError) { | ||
| throw error; | ||
| } | ||
| throw new HyperbrowserError(`Failed to stop Meta Computer Use task job ${id}`, undefined); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Start a Meta Computer Use task job and wait for it to complete | ||
| * @param params The parameters for the task job | ||
| */ | ||
| async startAndWait(params: StartMetaComputerUseTaskParams): Promise<MetaComputerUseTaskResponse> { | ||
| const job = await this.start(params); | ||
| const jobId = job.jobId; | ||
| if (!jobId) { | ||
| throw new HyperbrowserError( | ||
| "Failed to start Meta Computer Use task job, could not get job ID" | ||
| ); | ||
| } | ||
|
|
||
| let failures = 0; | ||
| while (true) { | ||
| try { | ||
| const { status } = await this.getStatus(jobId); | ||
| if (status === "completed" || status === "failed" || status === "stopped") { | ||
| return await this.get(jobId); | ||
| } | ||
| failures = 0; | ||
| } catch (error) { | ||
| failures++; | ||
| if (failures >= POLLING_ATTEMPTS) { | ||
| throw new HyperbrowserError( | ||
| `Failed to poll Meta Computer Use task job ${jobId} after ${POLLING_ATTEMPTS} attempts: ${error}` | ||
| ); | ||
| } | ||
| } | ||
| await sleep(2000); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| import { MetaComputerUseLlm, MetaReasoningEffort, MetaComputerUseTaskStatus } from "../constants"; | ||
| import { CreateSessionParams } from "../session"; | ||
|
|
||
| export interface MetaComputerUseApiKeys { | ||
| meta?: string; | ||
| } | ||
|
|
||
| export interface StartMetaComputerUseTaskParams { | ||
| task: string; | ||
| llm?: MetaComputerUseLlm; | ||
| reasoningEffort?: MetaReasoningEffort; | ||
| sessionId?: string; | ||
| maxFailures?: number; | ||
| maxSteps?: number; | ||
| keepBrowserOpen?: boolean; | ||
| sessionOptions?: CreateSessionParams; | ||
| useCustomApiKeys?: boolean; | ||
| apiKeys?: MetaComputerUseApiKeys; | ||
| useComputerAction?: boolean; | ||
| } | ||
|
|
||
| export interface StartMetaComputerUseTaskResponse { | ||
| jobId: string; | ||
| liveUrl: string | null; | ||
| } | ||
|
|
||
| export interface MetaComputerUseTaskStatusResponse { | ||
| status: MetaComputerUseTaskStatus; | ||
| } | ||
|
|
||
| export interface MetaComputerUseStepError { | ||
| code: string; | ||
| message: string; | ||
| } | ||
|
|
||
| export interface MetaComputerUseStepIncompleteDetails { | ||
| reason?: string; | ||
| } | ||
|
|
||
| export interface MetaComputerUseStepReasoning { | ||
| effort?: string | null; | ||
| summary?: string | null; | ||
| } | ||
|
|
||
| export interface MetaComputerUseStepResponse { | ||
| created_at?: number | null; | ||
| completed_at?: number | null; | ||
| output_text?: string | null; | ||
| error?: MetaComputerUseStepError | null; | ||
| incomplete_details?: MetaComputerUseStepIncompleteDetails | null; | ||
| model?: string | null; | ||
| output?: any[]; | ||
| reasoning?: MetaComputerUseStepReasoning | null; | ||
| status?: string | null; | ||
| } | ||
|
|
||
| export interface MetaComputerUseTaskData { | ||
| steps: MetaComputerUseStepResponse[]; | ||
| finalResult: string | null; | ||
| } | ||
|
|
||
| export interface MetaComputerUseTaskMetadata { | ||
| inputTokens?: number | null; | ||
| outputTokens?: number | null; | ||
| numTaskStepsCompleted?: number | null; | ||
| } | ||
|
|
||
| export interface MetaComputerUseTaskResponse { | ||
| jobId: string; | ||
| status: MetaComputerUseTaskStatus; | ||
| metadata?: MetaComputerUseTaskMetadata | null; | ||
| data?: MetaComputerUseTaskData | null; | ||
| error?: string | null; | ||
| liveUrl: string | null; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid reasoning effort value allowed
Medium Severity
MetaReasoningEffortincludesmax, which is not a valid Muse Spark reasoning effort. The supported values areminimal,low,medium,high, andxhigh. Callers who pickmaxfrom the public type will send a value the API rejects.Additional Locations (1)
tests/integration/client-http.test.ts#L295-L296Reviewed by Cursor Bugbot for commit 5283c91. Configure here.