( client: ReturnType<typeof createApiClient>, tools?: ToolRegistrationInput<any>[], )
| 240 | } |
| 241 | |
| 242 | export const registerMachine = async ( |
| 243 | client: ReturnType<typeof createApiClient>, |
| 244 | tools?: ToolRegistrationInput<any>[], |
| 245 | ) => { |
| 246 | log("registering machine", { |
| 247 | tools: tools?.map((f) => f.name), |
| 248 | }); |
| 249 | const registerResult = await client.createMachine({ |
| 250 | body: { |
| 251 | tools: tools?.map((func) => ({ |
| 252 | name: func.name, |
| 253 | description: func.description, |
| 254 | schema: JSON.stringify( |
| 255 | isZodType(func.schema) ? zodToJsonSchema(func.schema) : func.schema, |
| 256 | ), |
| 257 | config: func.config, |
| 258 | })), |
| 259 | }, |
| 260 | }); |
| 261 | |
| 262 | if (registerResult?.status !== 200) { |
| 263 | log("Failed to register machine", registerResult); |
| 264 | throw new AgentRPCAPIError("Failed to register machine", registerResult); |
| 265 | } |
| 266 | |
| 267 | return { |
| 268 | clusterId: registerResult.body.clusterId, |
| 269 | }; |
| 270 | }; |
| 271 | |
| 272 | export const pollForJobCompletion = async ( |
| 273 | client: ReturnType<typeof createApiClient>, |
no test coverage detected