11// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22
3+ import type { ZodType } from 'zod' ;
4+
35import { APIResource } from '../core/resource' ;
46import * as TasksAPI from './tasks' ;
57import { APIPromise } from '../core/api-promise' ;
68import { RequestOptions } from '../internal/request-options' ;
79import { path } from '../internal/utils/path' ;
10+ import {
11+ parseStructuredTaskOutput ,
12+ stringifyStructuredOutput ,
13+ type TaskViewWithStructuredOutput ,
14+ type GetTaskStatusParamsWithStructuredOutput ,
15+ type RunTaskCreateParamsWithStructuredOutput ,
16+ } from '../lib/parse' ;
817
918export class Tasks extends APIResource {
1019 /**
@@ -14,6 +23,15 @@ export class Tasks extends APIResource {
1423 return this . _client . post ( '/tasks' , { body, ...options } ) ;
1524 }
1625
26+ createWithStructuredOutput < T extends ZodType > (
27+ body : RunTaskCreateParamsWithStructuredOutput < T > ,
28+ options ?: RequestOptions ,
29+ ) : APIPromise < TaskViewWithStructuredOutput < T > > {
30+ return this . create ( stringifyStructuredOutput ( body ) , options ) . _thenUnwrap ( ( rsp ) =>
31+ parseStructuredTaskOutput ( rsp as TaskView , body ) ,
32+ ) ;
33+ }
34+
1735 /**
1836 * Get Task
1937 */
@@ -25,6 +43,20 @@ export class Tasks extends APIResource {
2543 return this . _client . get ( path `/tasks/${ taskID } ` , { query, ...options } ) ;
2644 }
2745
46+ retrieveWithStructuredOutput < T extends ZodType > (
47+ taskID : string ,
48+ query : GetTaskStatusParamsWithStructuredOutput < T > ,
49+ options ?: RequestOptions ,
50+ ) : APIPromise < TaskViewWithStructuredOutput < T > > {
51+ // NOTE: We manually remove structuredOutputJson from the query object because
52+ // it's not a valid Browser Use Cloud parameter.
53+ const { structuredOutputJson, ...rest } = query ;
54+
55+ return this . retrieve ( taskID , rest , options ) . _thenUnwrap ( ( rsp ) =>
56+ parseStructuredTaskOutput ( rsp as TaskView , query ) ,
57+ ) ;
58+ }
59+
2860 /**
2961 * Update Task
3062 */
0 commit comments