export type BuilderPlanApproval = {brief_revision: number, decision: 'approve' | 'revise', feedback?: string | undefined, interrupt_id: string}; export type BuilderToolApproval = {decision: 'approve' | 'deny', feedback?: string | undefined, interrupt_id: string}; export type BuilderTurnRequest = {request_id: string, workflow_id?: (number | null) | undefined, checkpoint?: (string | null) | undefined, message?: (string | null) | undefined, answers?: ({[key: string]: {[key: string]: Array}} | null) | undefined, approval?: (BuilderPlanApproval | null) | undefined, tool_approval?: (BuilderToolApproval | null) | undefined}; export type CreateApiApiV1WorkflowBuilderSessionIdTurnArgs = {session_id: string, authorization?: (string | null) | undefined, 'X-API-Key'?: (string | null) | undefined, body: BuilderTurnRequest}; export type CreateApiApiV1WorkflowBuilderSessionIdTurnOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send Builder Turn * * POST /api/v1/workflow/builder/{session_id}/turn */ export const createApiApiV1WorkflowBuilderSessionIdTurn = async (args: CreateApiApiV1WorkflowBuilderSessionIdTurnArgs, options?: CreateApiApiV1WorkflowBuilderSessionIdTurnOptions) => { const {baseUrl = "https://app.dograh.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/event-stream") if (args.authorization != null) headers.set("authorization", String(args.authorization)) if (args['X-API-Key'] != null) headers.set("X-API-Key", String(args['X-API-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/workflow/builder/${encodeURIComponent(String(args.session_id))}/turn${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };