({
baseUrl,
machineId,
clientAbortController,
apiSecret,
}: {
baseUrl?: string;
machineId?: string;
clientAbortController?: AbortController;
apiSecret?: string;
})
| 6 | * Provides raw API access to the Inferable API. |
| 7 | */ |
| 8 | export const createApiClient = ({ |
| 9 | baseUrl, |
| 10 | machineId, |
| 11 | clientAbortController, |
| 12 | apiSecret, |
| 13 | }: { |
| 14 | baseUrl?: string; |
| 15 | machineId?: string; |
| 16 | clientAbortController?: AbortController; |
| 17 | apiSecret?: string; |
| 18 | }) => |
| 19 | initClient(contract, { |
| 20 | baseUrl: baseUrl ?? "https://api.agentrpc.com", |
| 21 | baseHeaders: { |
| 22 | "x-machine-sdk-version": SDK_VERSION, |
| 23 | "x-machine-sdk-language": "typescript", |
| 24 | ...(apiSecret ? { authorization: apiSecret } : {}), |
| 25 | ...(machineId ? { "x-machine-id": machineId } : {}), |
| 26 | }, |
| 27 | api: async (args) => { |
| 28 | try { |
| 29 | return await tsRestFetchApi({ |
| 30 | ...args, |
| 31 | ...(clientAbortController |
| 32 | ? { signal: clientAbortController.signal } |
| 33 | : {}), |
| 34 | }); |
| 35 | } catch (e) { |
| 36 | return { |
| 37 | status: -1, |
| 38 | headers: new Headers(), |
| 39 | body: e, |
| 40 | }; |
| 41 | } |
| 42 | }, |
| 43 | }); |
no outgoing calls
no test coverage detected